Commit 5b3df9e0 authored by eddie.woo's avatar eddie.woo

merge

parents c4501047 fd4a320a
package pwc.taxtech.atms.dto.vatdto;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.Template;
......@@ -27,9 +34,8 @@ public class WrapPeriodJobDto {
job.setProjectId(projectId);
job.setPeriod(period);
job.setId(UUID.randomUUID().toString());
job.setStatus(STATUS_BEGIN);
job.setCurrentStep(STEP_UPDATE_CONFIG);
setStatus(job,STEP_UPDATE_CONFIG,STATUS_BEGIN);
StringBuilder builder = new StringBuilder(STEP_UPDATE_CONFIG);
templates.forEach(m -> {
builder.append(",").append(m.getCode());
......@@ -38,4 +44,53 @@ public class WrapPeriodJobDto {
job.setStepsCode(builder.toString());
return job;
}
@Getter
@Setter
public static class Task {
String code;
String status;
}
public static List<Task> fromJson(String taskJson) {
return JSON.parseObject(taskJson, new TypeReference<List<Task>>() {});
}
public static String toJson(List<Task> tasks) {
return JSON.toJSONString(tasks);
}
public static void setStatus(PeriodJob periodJob, String code, String status) {
List<Task> list;
if (StringUtils.isBlank(periodJob.getStatus())) {
list = new ArrayList<>();
} else {
list = fromJson(periodJob.getStatus());
}
Task t = new Task();
t.code = code;
t.status = status;
boolean contains = false;
for (Task m : list) {
if (m.code.equals(t.code)) {
m.status = status;
contains = true;
break;
}
}
if(!contains)list.add(t);
periodJob.setStatus(toJson(list));
}
public static void setStatus(PeriodJob periodJob, String status) {
List<Task> list;
if (StringUtils.isBlank(periodJob.getStatus())) {
list = new ArrayList<>();
} else {
list = fromJson(periodJob.getStatus());
}
list.get(list.size()-1).status=status;
periodJob.setStatus(toJson(list));
}
}
......@@ -42,6 +42,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*;
@Component
public class ReportServiceImpl {
private final static Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class);
......@@ -244,23 +246,16 @@ public class ReportServiceImpl {
}
@Transactional
public 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);
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
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) {
......@@ -452,13 +447,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)) {
......@@ -489,13 +484,9 @@ public class ReportServiceImpl {
evaluator.evaluateAll();
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, isMergeManualData, genJob);
genJob.setStatus(WrapPeriodJobDto.STATUS_END);
periodJobMapper.updateByPrimaryKey(genJob);
} catch (Exception e) {
genJob.setStatus(WrapPeriodJobDto.STATUS_ERROR);
genJob.setErrorMsg("Sever error "+e.getMessage());
setStatus(genJob, STATUS_ERROR);
genJob.setErrorMsg("Sever error " + e.getMessage());
periodJobMapper.updateByPrimaryKey(genJob);
e.printStackTrace();
}
......
jdbc_url=jdbc:oracle:thin:@10.158.230.144:11521:XE
jdbc_user=TAX_ADMIN
jdbc_password=taxadmin2018
jdbc_user=tax_admin_longi
jdbc_password=tax_admin_longi
#jdbc_password=111111
jdbc_admin_db=tax_admin
jdbc_admin_db=tax_admin_longi
#jdbc_url=jdbc:oracle:thin:@10.158.230.144:11521:XE
#jdbc_user=tax_admin_longi
......
......@@ -2579,6 +2579,8 @@
$scope.agreeApproval =function(){
vatApproveService.checkTask(vatSessionService.approvalInfo.instanceId,'agreed',$scope.comment).success(function(){
vatCommonService.setProjectStatus(vatSessionService.project.id, vatSessionService.month, constant.ProjectStatusEnum.Completed
, constant.DictionaryDictKey.WFDataProcess, enums.FinishStatusEnum.Finished);
$("#ApprovalComment").modal('hide');
});
}
......
......@@ -570,6 +570,8 @@
item.status = 'completed';
if($scope.timer){
$interval.cancel($scope.timer);
vatCommonService.setProjectStatus(vatSessionService.project.id, vatSessionService.month, constant.ProjectStatusEnum.Generated
, constant.DictionaryDictKey.WFDataProcess, enums.FinishStatusEnum.Finished);
}
}else if(job.status == 'Begin'){
item.status = 'processing';
......
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