Commit 201ba46b authored by chase's avatar chase

fix bug

parent c3095df3
...@@ -305,7 +305,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -305,7 +305,7 @@ public class ReportServiceImpl extends BaseService {
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) { private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate(); List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
//根据收入类型映射生成开票记录关联数据 //根据收入类型映射生成开票记录关联数据
assembleInvoiceRecord(projectId, period,isMergeManualData); assembleInvoiceRecord(projectId, period, isMergeManualData);
//生成trial_balance_final数据 //生成trial_balance_final数据
assembleTrialBalanceFinal(projectId, period); assembleTrialBalanceFinal(projectId, period);
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData); clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
...@@ -333,7 +333,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -333,7 +333,7 @@ public class ReportServiceImpl extends BaseService {
trialBalanceFinalMapper.generateFinalData(projectId, Integer.valueOf(queryPeriod), lastProject == null ? "0" : lastProject.getId(), Integer.valueOf(lastPeriod)); trialBalanceFinalMapper.generateFinalData(projectId, Integer.valueOf(queryPeriod), lastProject == null ? "0" : lastProject.getId(), Integer.valueOf(lastPeriod));
} }
public void assembleInvoiceRecord(String projectId, Integer period,Boolean isMergeManualData) { public void assembleInvoiceRecord(String projectId, Integer period, Boolean isMergeManualData) {
Project project = projectMapper.selectByPrimaryKey(projectId); Project project = projectMapper.selectByPrimaryKey(projectId);
MyAsserts.assertNotNull(project, Exceptions.NOT_FOUND_REPORT_EXCEPTION); MyAsserts.assertNotNull(project, Exceptions.NOT_FOUND_REPORT_EXCEPTION);
String queryDate = project.getYear() + "-" + (period < 10 ? ("0" + period) : (period + "")); String queryDate = project.getYear() + "-" + (period < 10 ? ("0" + period) : (period + ""));
...@@ -345,10 +345,10 @@ public class ReportServiceImpl extends BaseService { ...@@ -345,10 +345,10 @@ public class ReportServiceImpl extends BaseService {
InvoiceRecordExample delExample = new InvoiceRecordExample(); InvoiceRecordExample delExample = new InvoiceRecordExample();
delExample.createCriteria().andProjectIdEqualTo(projectId). delExample.createCriteria().andProjectIdEqualTo(projectId).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", ""))); andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
if(isMergeManualData){ if (isMergeManualData) {
invoiceRecordMapper.clearRevenueCof(true,false,delExample); invoiceRecordMapper.clearRevenueCof(true, false, delExample);
}else{ } else {
invoiceRecordMapper.clearRevenueCof(true,true,delExample); invoiceRecordMapper.clearRevenueCof(true, true, delExample);
} }
Map<String, Long> map = new HashMap<>(); Map<String, Long> map = new HashMap<>();
...@@ -470,12 +470,14 @@ public class ReportServiceImpl extends BaseService { ...@@ -470,12 +470,14 @@ public class ReportServiceImpl extends BaseService {
for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) { for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r); Row row = sheet.getRow(r);
for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) { for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) {
Cell cell = row.getCell(c); Cell cell = row.getCell(c);
if (cell == null) { if (cell == null) {
continue;//todo cell == null 如何处理 continue;//todo cell == null 如何处理
} }
if (r <= addRowIndex + 1) { if (r <= addRowIndex + 1) {
if(r == addRowIndex + 1 && c>TaxesCalculateReportEnum.Column.Column_14.getIndex()){
assembleOriginalTemplateData(template,projectId,period,r,c,addRowIndex,cellTemplateList,cellTemplateConfigList);
}else{
String cellId = projectId + template.getId() + period + r + c; String cellId = projectId + template.getId() + period + r + c;
if ((r - 1) >= 0 && (r - 1) < configIds.size()) { if ((r - 1) >= 0 && (r - 1) < configIds.size()) {
cellId += configIds.get(configIds.size() - r); cellId += configIds.get(configIds.size() - r);
...@@ -537,7 +539,26 @@ public class ReportServiceImpl extends BaseService { ...@@ -537,7 +539,26 @@ public class ReportServiceImpl extends BaseService {
if (r > 0 && r <= addRowIndex && hasHandDatas.contains(c)) { if (r > 0 && r <= addRowIndex && hasHandDatas.contains(c)) {
addManualConfig(cellTemplate, cell, now, cellTemplateConfigList); addManualConfig(cellTemplate, cell, now, cellTemplateConfigList);
} }
}
} else { } else {
assembleOriginalTemplateData(template,projectId,period,r,c,addRowIndex,cellTemplateList,cellTemplateConfigList);
}
}
}
List<List<PeriodCellTemplate>> tmpList = CommonUtils.subListWithLen(cellTemplateList, CommonUtils.BATCH_NUM);
// tmpList.forEach(list -> cellTemplateMapper.batchInsert2(list));
tmpList.forEach(list -> periodCellTemplateMapper.batchInsert(list));//todo 批量插入优化
List<List<PeriodCellTemplateConfig>> tmpConfigList = CommonUtils.subListWithLen(cellTemplateConfigList, CommonUtils.BATCH_NUM);
tmpConfigList.forEach(list -> periodCellTemplateConfigMapper.batchInsert(list));
} catch (Exception e) {
logger.error("importTemplateExcelFile error.", e);
throw new ServiceException(ErrorMessage.SystemError);
}
}
public void assembleOriginalTemplateData(Template template, String projectId, Integer period,
Integer r, Integer c, Integer addRowIndex,
List<PeriodCellTemplate> cellTemplateList, List<PeriodCellTemplateConfig> cellTemplateConfigList) {
//查询原来行cell是否有CellTemplate //查询原来行cell是否有CellTemplate
CellTemplateExample cellTemplateExample = new CellTemplateExample(); CellTemplateExample cellTemplateExample = new CellTemplateExample();
cellTemplateExample.createCriteria().andReportTemplateIdEqualTo(template.getId()).andRowIndexEqualTo(r - addRowIndex).andColumnIndexEqualTo(c); cellTemplateExample.createCriteria().andReportTemplateIdEqualTo(template.getId()).andRowIndexEqualTo(r - addRowIndex).andColumnIndexEqualTo(c);
...@@ -605,18 +626,6 @@ public class ReportServiceImpl extends BaseService { ...@@ -605,18 +626,6 @@ public class ReportServiceImpl extends BaseService {
} }
} }
} }
}
}
List<List<PeriodCellTemplate>> tmpList = CommonUtils.subListWithLen(cellTemplateList, CommonUtils.BATCH_NUM);
// tmpList.forEach(list -> cellTemplateMapper.batchInsert2(list));
tmpList.forEach(list -> periodCellTemplateMapper.batchInsert(list));//todo 批量插入优化
List<List<PeriodCellTemplateConfig>> tmpConfigList = CommonUtils.subListWithLen(cellTemplateConfigList, CommonUtils.BATCH_NUM);
tmpConfigList.forEach(list -> periodCellTemplateConfigMapper.batchInsert(list));
} catch (Exception e) {
logger.error("importTemplateExcelFile error.", e);
throw new ServiceException(ErrorMessage.SystemError);
}
}
private void addManualConfig(PeriodCellTemplate cellTemplate, Cell cell, Date now, List<PeriodCellTemplateConfig> list) { private void addManualConfig(PeriodCellTemplate cellTemplate, Cell cell, Date now, List<PeriodCellTemplateConfig> list) {
PeriodCellTemplateConfig configManual = new PeriodCellTemplateConfig(); PeriodCellTemplateConfig configManual = new PeriodCellTemplateConfig();
...@@ -987,7 +996,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -987,7 +996,7 @@ public class ReportServiceImpl extends BaseService {
Workbook workbook = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob); Workbook workbook = reportGenerator.createWorkBookByPeriodTemplate(resources.getPeriodTemplates(), genJob);
reportGenerator.addFunctionsAndContext(workbook, functions, reportGenerator.initContext(resources, periodParam),false); reportGenerator.addFunctionsAndContext(workbook, functions, reportGenerator.initContext(resources, periodParam), false);
reportGenerator.setConfigAndDataToWorkBook(workbook, resources); reportGenerator.setConfigAndDataToWorkBook(workbook, resources);
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
...@@ -1029,7 +1038,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -1029,7 +1038,7 @@ public class ReportServiceImpl extends BaseService {
periodCellTemplateConfigDtos.forEach(a -> { periodCellTemplateConfigDtos.forEach(a -> {
workbook4Validate.getSheetAt(a.getSheetNumber() - 1).getRow(a.getRowNumber()).getCell(a.getColNumber()).setCellFormula(a.getParsedValidation()); workbook4Validate.getSheetAt(a.getSheetNumber() - 1).getRow(a.getRowNumber()).getCell(a.getColNumber()).setCellFormula(a.getParsedValidation());
}); });
reportGenerator.addFunctionsAndContext(workbook4Validate, functions, reportGenerator.initContext(resources, periodParam),true); reportGenerator.addFunctionsAndContext(workbook4Validate, functions, reportGenerator.initContext(resources, periodParam), true);
FormulaEvaluator validateEvaluator = workbook4Validate.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator validateEvaluator = workbook4Validate.getCreationHelper().createFormulaEvaluator();
validateEvaluator.evaluateAll(); validateEvaluator.evaluateAll();
//todo: 4.then save the validation result to cellData table //todo: 4.then save the validation result to cellData table
...@@ -2423,7 +2432,7 @@ public class ReportServiceImpl extends BaseService { ...@@ -2423,7 +2432,7 @@ public class ReportServiceImpl extends BaseService {
} }
dataList.add(orgTypeList); dataList.add(orgTypeList);
} }
if(dataList.size() == 0){ if (dataList.size() == 0) {
throw new Exception("没有可导出的数据"); throw new Exception("没有可导出的数据");
} }
if (template.getIsSystemType()) { if (template.getIsSystemType()) {
......
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