Commit a09a7123 authored by neo's avatar neo

[DEV] update old reporte id when merge manalcelldata

parent 2c437838
......@@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.CellDataSourceType;
......@@ -26,6 +27,7 @@ import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.service.impl.DistributedIdService;
import pwc.taxtech.atms.service.impl.HttpFileService;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.dpo.MergerManaualCellData;
import pwc.taxtech.atms.vat.dpo.PeriodCellTemplateConfigExtendDto;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.report.functions.*;
......@@ -83,6 +85,20 @@ public class ReportGeneratorImpl {
return periodResources;
}
@Transactional
public void updateManaCellDataWithNewReport(String projectId, Integer period) {
List<MergerManaualCellData> result = periodCellDataMapper.selectManualToBeMerged(projectId, period);
if (!result.isEmpty()) {
result.forEach(m -> {
PeriodCellData pcd = new PeriodCellData();
pcd.setId(m.getId());
pcd.setReportId(m.getNewReportId());
periodCellDataMapper.updateByPrimaryKeySelective(pcd);
});
}
}
@Transactional
public void updateWorkbookCaclsValueToDb(String projectId, Integer period, Workbook workbook, PeriodResources resources, PeriodJob job) {
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
......@@ -336,9 +352,9 @@ public class ReportGeneratorImpl {
} catch (Exception e) {
e.printStackTrace();
job.setStatus(WrapPeriodJobDto.STATUS_ERROR);
job.setErrorMsg("cacals report for code "+code +" failed");
job.setErrorMsg("cacals report for code " + code + " failed");
}finally {
} finally {
job.setCurrentStep(code);
periodJobMapper.updateByPrimaryKey(job);
}
......
......@@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil;
......@@ -273,6 +274,7 @@ public class ReportServiceImpl {
}
@Transactional
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
try {
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
......@@ -496,22 +498,33 @@ public class ReportServiceImpl {
new Thread(new Runnable() {
@Override
public void run() {
updateConfig(projectId, periodParam, isMergeManualData, templates, genJob);
try {
PeriodResources resources = reportGenerator.getPeriodResources(projectId, periodParam,
templates.stream().map(Template::getId).collect(Collectors.toList()));
updateConfig(projectId, periodParam, isMergeManualData, templates, genJob);
Workbook workbook = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob);
PeriodResources resources = reportGenerator.getPeriodResources(projectId, periodParam,
templates.stream().map(Template::getId).collect(Collectors.toList()));
reportGenerator.addFunctionsAndContext(workbook, functions, reportGenerator.initContext(resources, periodParam));
reportGenerator.setConfigAndDataToWorkBook(workbook, resources);
Workbook workbook = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob);
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateAll();
reportGenerator.addFunctionsAndContext(workbook, functions, reportGenerator.initContext(resources, periodParam));
reportGenerator.setConfigAndDataToWorkBook(workbook, resources);
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, genJob);
genJob.setStatus(WrapPeriodJobDto.STATUS_END);
periodJobMapper.updateByPrimaryKey(genJob);
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateAll();
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, genJob);
reportGenerator.updateManaCellDataWithNewReport(projectId, periodParam);
genJob.setStatus(WrapPeriodJobDto.STATUS_END);
}catch (Exception e){
e.printStackTrace();
genJob.setStatus(WrapPeriodJobDto.STATUS_ERROR);
genJob.setErrorMsg("Server error");
}finally {
periodJobMapper.updateByPrimaryKey(genJob);
}
}
}).start();
operationResultDto.setData(genJob);
......
......@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.MergerManaualCellData;
import pwc.taxtech.atms.vat.entity.PCTEntity;
import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodCellDataExample;
......@@ -130,4 +131,35 @@ public interface PeriodCellDataMapper extends MyVatMapper {
" </foreach>" +
"</script>")
List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter, @Param("projectId") String projectId);
@Select("" +
"SELECT " +
" d.ID AS id, " +
" d.REPORT_ID AS reportId, " +
" d.CELL_TEMPLATE_ID AS cellTemplateId, " +
" p.REPORT_TEMPLATE_ID AS templateId, " +
" t.ID AS newReportId " +
"FROM " +
" PERIOD_CELL_DATA d " +
" JOIN PERIOD_CELL_TEMPLATE p ON d.CELL_TEMPLATE_ID = p.CELL_TEMPLATE_ID " +
" LEFT JOIN PERIOD_REPORT t ON p.REPORT_TEMPLATE_ID = t.TEMPLATE_ID " +
"WHERE " +
" d.PROJECT_ID = #{projectId} " +
" AND p.PROJECT_ID = #{projectId} " +
" AND t.PROJECT_ID = #{projectId} " +
" AND d.PERIOD = #{period} " +
" AND p.PERIOD = #{period} " +
" AND t.PERIOD = #{period} " +
" AND d.REPORT_ID NOT IN ( " +
" SELECT " +
" ID " +
" FROM " +
" PERIOD_REPORT " +
" WHERE " +
" PROJECT_ID = #{projectId} " +
" AND PERIOD = #{period} " +
" )" +
"")
List<MergerManaualCellData> selectManualToBeMerged(@Param("projectId") String projectId, @Param("period") Integer period);
}
\ No newline at end of file
package pwc.taxtech.atms.vat.dpo;
public class MergerManaualCellData {
private Long id;
private Long reportId;
private Long cellTemplateId;
private Long templateId;
private Long newReportId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getReportId() {
return reportId;
}
public void setReportId(Long reportId) {
this.reportId = reportId;
}
public Long getCellTemplateId() {
return cellTemplateId;
}
public void setCellTemplateId(Long cellTemplateId) {
this.cellTemplateId = cellTemplateId;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public Long getNewReportId() {
return newReportId;
}
public void setNewReportId(Long newReportId) {
this.newReportId = newReportId;
}
}
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