Commit de0f6192 authored by neo's avatar neo

[Bugfix] fixed status

parent eb762354
......@@ -248,21 +248,15 @@ public class ReportServiceImpl {
@Transactional
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
try {
job.setStatus(WrapPeriodJobDto.STATUS_BEGIN);
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
setStatus(job, STATUS_BEGIN);
periodJobMapper.updateByPrimaryKey(job);
copyTemplateAndConfigFromAdmin(projectId, templates, period);
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
copyTemplateAndConfigFromAdmin(projectId, templates, period);
} catch (Exception ex) {
job.setStatus(WrapPeriodJobDto.STATUS_ERROR);
job.setErrorMsg("error update config with projectId " + projectId + " period" + period);
logger.error(ex.getMessage(), ex);
} finally {
periodJobMapper.updateByPrimaryKey(job);
}
setStatus(job, STATUS_END);
periodJobMapper.updateByPrimaryKey(job);
}
private List<Template> getTemplatesByProjectId(String projectId) {
......@@ -454,13 +448,13 @@ public class ReportServiceImpl {
public OperationResultDto generateData(String projectId, EnumServiceType serviceType, Boolean isMergeManualData,
Integer periodParam, Integer reportType, Optional<String> generator) {
OperationResultDto operationResultDto = new OperationResultDto();
MyAsserts.assertEq(serviceType, EnumServiceType.VAT, new NotFoundException());
PeriodJobExample example = new PeriodJobExample();
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(periodParam)
.andStatusEqualTo(WrapPeriodJobDto.STATUS_BEGIN);
MyAsserts.assertEmpty(periodJobMapper.selectByExample(example), Exceptions.TASK_HAS_BEGINNING);
String status = periodApprovalMapper.getStatusByProjectIdAndPeriod(projectId, periodParam);
MyAsserts.assertTrue(status == null || status.equals(Constant.APPROVAL_DISAGREED), Exceptions.REPORT_IN_PROCESS_OR_AGREED_EXCEPTION);
MyAsserts.assertEq(serviceType, EnumServiceType.VAT, new NotFoundException());
PeriodJobExample example = new PeriodJobExample();
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(periodParam)
.andStatusEqualTo(WrapPeriodJobDto.STATUS_BEGIN);
MyAsserts.assertEmpty(periodJobMapper.selectByExample(example), Exceptions.TASK_HAS_BEGINNING);
String status = periodApprovalMapper.getStatusByProjectIdAndPeriod(projectId, periodParam);
MyAsserts.assertTrue(status == null || status.equals(Constant.APPROVAL_DISAGREED), Exceptions.REPORT_IN_PROCESS_OR_AGREED_EXCEPTION);
try {
if (serviceType.equals(EnumServiceType.VAT) && (periodParam == null || periodParam <= 0)) {
......@@ -478,7 +472,6 @@ public class ReportServiceImpl {
try {
updateConfig(projectId, periodParam, isMergeManualData, templates, genJob);
setStatus(genJob,STEP_UPDATE_CONFIG,STATUS_END);
PeriodResources resources = reportGenerator.getPeriodResources(projectId, periodParam,
templates.stream().map(Template::getId).collect(Collectors.toList()));
......@@ -493,8 +486,8 @@ public class ReportServiceImpl {
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, isMergeManualData, genJob);
} catch (Exception e) {
setStatus(genJob,STATUS_ERROR);
genJob.setErrorMsg("Sever error "+e.getMessage());
setStatus(genJob, STATUS_ERROR);
genJob.setErrorMsg("Sever error " + e.getMessage());
periodJobMapper.updateByPrimaryKey(genJob);
e.printStackTrace();
}
......
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