Commit 6cb2f1fd authored by neo's avatar neo

[DEv] add get job api impl

parent 63bedb84
...@@ -10,6 +10,7 @@ import pwc.taxtech.atms.dpo.ReportDto; ...@@ -10,6 +10,7 @@ import pwc.taxtech.atms.dpo.ReportDto;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.*; import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig; import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
import pwc.taxtech.atms.vat.entity.PeriodJob;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount; import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl; import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl;
...@@ -32,13 +33,25 @@ public class ReportController { ...@@ -32,13 +33,25 @@ public class ReportController {
return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period); return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
} }
@RequestMapping(value = "generateByTotal/{projectId}/{ifDeleteManualDataSource}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "generateByTotal/{projectId}/{mergeManual}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto generateAllData(@PathVariable String projectId, @PathVariable Boolean ifDeleteManualDataSource, public OperationResultDto generateAllData(@PathVariable String projectId, @PathVariable Boolean ifDeleteManualDataSource,
@PathVariable Integer period, @RequestParam Optional<String> generator, @PathVariable Integer period, @RequestParam Optional<String> generator,
@RequestParam Boolean mergeManual) { @PathVariable Boolean mergeManual) {
return reportService.generateData(projectId, EnumServiceType.VAT, mergeManual, period, null, generator); return reportService.generateData(projectId, EnumServiceType.VAT, mergeManual, period, null, generator);
} }
@RequestMapping(value = "getRunningJob/{projectId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public PeriodJob getRunningJob(@PathVariable String projectId, @PathVariable Integer period) {
return reportService.getRunningJob(projectId, period);
}
@RequestMapping(value = "getJobStatus/{projectId}//{period}/{jobId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public PeriodJob getJobStatus(@PathVariable String projectId, @PathVariable Integer period, @PathVariable String jobId) {
return reportService.getJobStatus(projectId, period, jobId);
}
@RequestMapping(value = "templateReferences/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "templateReferences/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<CellTemplateReferenceDto> getTemplateReferences(@PathVariable int period) { public List<CellTemplateReferenceDto> getTemplateReferences(@PathVariable int period) {
return reportService.getTemplateReferences(period); return reportService.getTemplateReferences(period);
......
...@@ -17,4 +17,5 @@ public class Exceptions { ...@@ -17,4 +17,5 @@ public class Exceptions {
public static final ApiException PROJECT_EMPTY_EXCEPTION = new BadParameterException("projectId is empty"); public static final ApiException PROJECT_EMPTY_EXCEPTION = new BadParameterException("projectId is empty");
public static final ApiException PROJECT_PROJECT_EXCEPTION = new NotFoundException("not found project"); public static final ApiException PROJECT_PROJECT_EXCEPTION = new NotFoundException("not found project");
public static final ApiException NOT_FOUND_TEMPLATE_GROUP_EXCEPTION = new NotFoundException("not found template group"); public static final ApiException NOT_FOUND_TEMPLATE_GROUP_EXCEPTION = new NotFoundException("not found template group");
public static final ApiException NOT_FOUND_EXCEPTION = new NotFoundException("not found resources");
} }
...@@ -489,13 +489,13 @@ public class ReportServiceImpl { ...@@ -489,13 +489,13 @@ public class ReportServiceImpl {
Workbook workbook = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob); Workbook workbook = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob);
reportGenerator.addFunctionsAndContext(workbook,functions, reportGenerator.initContext(resources, periodParam)); reportGenerator.addFunctionsAndContext(workbook, functions, reportGenerator.initContext(resources, periodParam));
reportGenerator.setConfigAndDataToWorkBook(workbook,resources); reportGenerator.setConfigAndDataToWorkBook(workbook, resources);
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateAll(); evaluator.evaluateAll();
reportGenerator.updateWorkbookCaclsValueToDb(projectId,periodParam,workbook,resources,genJob); reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, genJob);
genJob.setStatus(WrapPeriodJobDto.STATUS_END); genJob.setStatus(WrapPeriodJobDto.STATUS_END);
periodJobMapper.updateByPrimaryKey(genJob); periodJobMapper.updateByPrimaryKey(genJob);
} }
...@@ -1227,4 +1227,14 @@ public class ReportServiceImpl { ...@@ -1227,4 +1227,14 @@ public class ReportServiceImpl {
private String combine(String parent, String child) { private String combine(String parent, String child) {
return String.format("%s" + File.separator + "%s", parent, child); return String.format("%s" + File.separator + "%s", parent, child);
} }
public PeriodJob getRunningJob(String projectId, Integer period) {
return periodJobMapper.getRunningJob(projectId, period);
}
public PeriodJob getJobStatus(String projectId, Integer period, String jobId) {
PeriodJob job = periodJobMapper.getJobStatus(projectId, period, jobId);
MyAsserts.assertNotNull(job, Exceptions.NOT_FOUND_EXCEPTION);
return job;
}
} }
...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.vat.dao; ...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.vat.dao;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.PeriodJob; import pwc.taxtech.atms.vat.entity.PeriodJob;
...@@ -105,4 +106,40 @@ public interface PeriodJobMapper extends MyVatMapper { ...@@ -105,4 +106,40 @@ public interface PeriodJobMapper extends MyVatMapper {
* @mbg.generated * @mbg.generated
*/ */
int updateByPrimaryKey(PeriodJob record); int updateByPrimaryKey(PeriodJob record);
@Select("SELECT " +
" ID AS id, " +
" NAME AS name, " +
" CURRENT_STEP AS currentStep, " +
" PROJECT_ID AS projectId, " +
" PERIOD AS period, " +
" STEPS_CODE AS stepsCode, " +
" CREATE_TIME AS createTime, " +
" STATUS AS status, " +
" ERROR_MSG AS errorMsg " +
"FROM " +
" PERIOD_JOB " +
"WHERE " +
" STATUS = 'Begin' " +
" AND PROJECT_ID = #{projectId} " +
" AND PERIOD =#{period}")
PeriodJob getRunningJob(@Param("projectId") String projectId, @Param("period") Integer period);
@Select("SELECT " +
" ID AS id, " +
" NAME AS name, " +
" CURRENT_STEP AS currentStep, " +
" PROJECT_ID AS projectId, " +
" PERIOD AS period, " +
" STEPS_CODE AS stepsCode, " +
" CREATE_TIME AS createTime, " +
" STATUS AS status, " +
" ERROR_MSG AS errorMsg " +
"FROM " +
" PERIOD_JOB " +
"WHERE " +
" PROJECT_ID = #{projectId} " +
" AND PERIOD =#{period} " +
" AND ID = #{id}")
PeriodJob getJobStatus(@Param("projectId") String projectId, @Param("period") Integer period,@Param("id") String id);
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment