Commit abb89b56 authored by neo's avatar neo

[optimize] fixed gen all report data

parent 8541823a
...@@ -41,4 +41,12 @@ public class MyAsserts { ...@@ -41,4 +41,12 @@ public class MyAsserts {
public static void assertEmpty(Collection obj, ApiException exception) { public static void assertEmpty(Collection obj, ApiException exception) {
if (obj != null && !obj.isEmpty()) throw exception; if (obj != null && !obj.isEmpty()) throw exception;
} }
public static <T,S> void assertEq(T t,S s,ApiException exception){
if(s != t) throw exception;
}
public static <T,S> void assertNotEq(T t,S s,ApiException exception){
if(s == t) throw exception;
}
} }
...@@ -66,127 +66,43 @@ public class ReportGeneratorImpl { ...@@ -66,127 +66,43 @@ public class ReportGeneratorImpl {
public String generateData(String projectId, List<Long> templateIds, Boolean ifDeleteManualDataSource, public String generateData(String projectId, List<Long> templateIds, Boolean ifDeleteManualDataSource,
List<String> exceptCellTemplates, Integer periodParam, Optional<String> generator) { List<String> exceptCellTemplates, Integer periodParam, Optional<String> generator) {
Date createTime = new Date();
int period = periodParam != null ? periodParam : 0; int period = periodParam != null ? periodParam : 0;
Project project = projectMapper.selectByPrimaryKey(projectId); Project project = projectMapper.selectByPrimaryKey(projectId);
if (templateIds.isEmpty()) templateIds.add(Long.MAX_VALUE);
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample(); if (templateIds.isEmpty()) templateIds.add(Long.MAX_VALUE);
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andIdIn(templateIds); List<PeriodTemplate> periodTemplateList = queryPeriodTemplates(projectId, period, templateIds);
List<PeriodTemplate> periodTemplateList = periodTemplateMapper.selectByExample(periodTemplateExample);
List<Long> periodTemplateIdList = periodTemplateList.stream() List<Long> periodTemplateIdList = periodTemplateList.stream()
.map(PeriodTemplate::getTemplateId) .map(PeriodTemplate::getTemplateId)
.collect(Collectors.toList()); .collect(Collectors.toList());
Long templateGroupId = periodTemplateList.size() > 0 ? periodTemplateList.get(0).getTemplateGroupId() : 0; Long templateGroupId = periodTemplateList.size() > 0 ? periodTemplateList.get(0).getTemplateGroupId() : 0;
List<PeriodCellTemplate> periodCellTemplateList = queryPeriodCellTemplates(projectId, period, periodTemplateIdList);
List<PeriodCellTemplateConfig> periodCellTemplateConfigList = queryPeriodCellTemplateConfigs(projectId, period, periodTemplateIdList);
PeriodCellTemplateExample periodCellTemplateExample = new PeriodCellTemplateExample();
if (periodTemplateIdList.isEmpty()) periodTemplateIdList.add(Long.MAX_VALUE);
periodCellTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andReportTemplateIdIn(periodTemplateIdList).andPeriodEqualTo(period);
List<PeriodCellTemplate> periodCellTemplateList = periodCellTemplateMapper.selectByExample(periodCellTemplateExample);
PeriodCellTemplateConfigExample periodCellTemplateConfigExample = new PeriodCellTemplateConfigExample();
// only get formula config
periodCellTemplateConfigExample.createCriteria().andProjectIdEqualTo(projectId).andReportTemplateIdIn(periodTemplateIdList).andPeriodEqualTo(period);
List<PeriodCellTemplateConfig> periodCellTemplateConfigList =
periodCellTemplateConfigMapper.selectByExample(periodCellTemplateConfigExample);
//Map<String, String> templateCodeAndPath = new HashMap<>();
//periodTemplateList.forEach(a -> templateCodeAndPath.put(a.getCode(), getTemplatePath(a.getPath())));
Optional<Workbook> workbook = createWorkBookWithExcelFileList(periodTemplateList); Optional<Workbook> workbook = createWorkBookWithExcelFileList(periodTemplateList);
if (workbook.isPresent()) { if (workbook.isPresent()) {
Workbook newWorkbook = workbook.get(); Workbook newWorkbook = workbook.get();
FormulaContext formulaContext = new FormulaContext(); FormulaContext formulaContext = FormulaContext.extractContextFromProject(project).fixedFormula(period, templateGroupId, formulaAgent);
formulaContext.setFormulaAgent(formulaAgent);
formulaContext.setPeriod(period);
formulaContext.setReportTemplateGroupId(templateGroupId);
formulaContext.setProjectId(project.getId());
formulaContext.setYear(project.getYear());
formulaContext.setIsYear(period == 0);
formulaContext.setIfRound(true);
formulaContext.setOrganizationId(project.getOrganizationId());
formulaContext.setIfRound(true);
addFunctionsToWorkbook(newWorkbook, formulaContext); addFunctionsToWorkbook(newWorkbook, formulaContext);
int sheetCount = newWorkbook.getNumberOfSheets();
List<Cell> otherFormulaCells = new ArrayList<>();
List<Cell> bbFormulaCells = new ArrayList<>();
for (int i = 0; i < sheetCount; i++) { setConfigAndDataToWorkBook(newWorkbook, periodTemplateList, periodCellTemplateList, periodCellTemplateConfigList);
Sheet sheet = newWorkbook.getSheetAt(i);
String code = sheet.getSheetName();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream()
.filter(a -> a.getCode().equals(code))
.findFirst();
Long templateId;
if (periodTemplate.isPresent()) {
templateId = periodTemplate.get().getTemplateId();
} else {
templateId = 0L;
}
if (templateId > 0) {
//get cell template and cell template config with templateId
Map<PeriodCellTemplate, PeriodCellTemplateConfig> cellTemplatePeriodCellTemplateConfigMap = new HashMap<>();
List<PeriodCellTemplate> tempPeriodCellTemplateList = periodCellTemplateList.stream()
.filter(a -> a.getReportTemplateId().equals(templateId))
.collect(Collectors.toList());
tempPeriodCellTemplateList.forEach(a -> {
Optional<PeriodCellTemplateConfig> tempCellTemplateConfig = periodCellTemplateConfigList.stream()
.filter(item -> item.getCellTemplateId().equals(a.getCellTemplateId())
&& item.getDataSourceType().equals(CellDataSourceType.Formula.getCode()))
.findFirst();
tempCellTemplateConfig.ifPresent(periodCellTemplateConfig ->
cellTemplatePeriodCellTemplateConfigMap.put(a, periodCellTemplateConfig));
});
cellTemplatePeriodCellTemplateConfigMap.forEach((k, v) -> { FormulaEvaluator evaluator = newWorkbook.getCreationHelper().createFormulaEvaluator();
Row row = sheet.getRow(k.getRowIndex()); evaluator.evaluateAll();
if (null == row) {
sheet.createRow(k.getRowIndex());
}
row = sheet.getRow(k.getRowIndex());
Cell cell = row.getCell(k.getColumnIndex());
if (null == cell) {
row.createCell(k.getColumnIndex());
}
cell = row.getCell(k.getColumnIndex());
//todo:后面单独处理kv的公式 List<PeriodReport> reports = createReportsByTemplates(workbook.get(), periodTemplateList, projectId, period);
if (StringUtils.isNotBlank(v.getFormula()) && !v.getFormula().contains("@")) { updateWorkbookCaclsValueToDb(projectId,period,workbook.get(),reports,periodTemplateList,periodCellTemplateList,periodCellTemplateConfigList);
cell.setCellFormula(v.getFormula()); return "generate report successful";
logger.debug("formula:" + v.getFormula());
if (v.getFormula().startsWith("BB(")) {
bbFormulaCells.add(cell);
} else { } else {
otherFormulaCells.add(cell); return "GenerateReport failed";
}
//kv 公式处理
} else if (v.getFormula().contains("@")) {
if (StringUtils.isNotBlank(v.getKeyValueParsedFormula())) {
cell.setCellFormula(v.getKeyValueParsedFormula());
logger.debug("formula:" + v.getKeyValueParsedFormula());
otherFormulaCells.add(cell);
}
}
});
} }
} }
FormulaEvaluator evaluator = newWorkbook.getCreationHelper().createFormulaEvaluator();
otherFormulaCells.stream().forEach(m -> {
evaluator.evaluateFormulaCellEnum(m);
});
bbFormulaCells.stream().forEach(n -> {
evaluator.evaluateFormulaCellEnum(n);
});
//todo:loop all the cell which existing in the cellTemplateConfig, save the data to DB private void updateWorkbookCaclsValueToDb(String projectId,Integer period,Workbook workbook,List<PeriodReport> periodReports,
for (int i = 0; i < sheetCount; i++) { List<PeriodTemplate> periodTemplateList,
Sheet sheet = newWorkbook.getSheetAt(i); List<PeriodCellTemplate> periodCellTemplateList,List<PeriodCellTemplateConfig> periodCellTemplateConfigList){
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
String code = sheet.getSheetName(); String code = sheet.getSheetName();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream() Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream()
.filter(a -> a.getCode().equals(code)) .filter(a -> a.getCode().equals(code))
...@@ -198,21 +114,18 @@ public class ReportGeneratorImpl { ...@@ -198,21 +114,18 @@ public class ReportGeneratorImpl {
templateId = 0L; templateId = 0L;
} }
if (templateId > 0) { Optional<PeriodReport> periodReport = periodReports.stream()
//todo: create report into DB .filter(a -> a.getTemplateId().equals(templateId))
PeriodReport report = new PeriodReport(); .findFirst();
Long reportId = distributedIdService.nextId(); Long reportId;
report.setId(reportId); if (periodReport.isPresent()) {
report.setTemplateId(templateId); reportId = periodReport.get().getId();
report.setPeriod(period); } else {
report.setProjectId(projectId); reportId = 0L;
report.setCreateBy("Admin"); }
report.setCreateTime(createTime);
report.setUpdateBy("Admin");
report.setUpdateTime(createTime);
report.setProjectId(projectId);
reportMapper.insertSelective(report);
if (templateId > 0) {
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = periodCellTemplateConfigList.stream() List<PeriodCellTemplateConfig> periodCellTemplateConfigs = periodCellTemplateConfigList.stream()
.filter(a -> a.getReportTemplateId().equals(templateId) && a.getDataSourceType().equals(CellDataSourceType.Formula.getCode())) .filter(a -> a.getReportTemplateId().equals(templateId) && a.getDataSourceType().equals(CellDataSourceType.Formula.getCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -330,8 +243,8 @@ public class ReportGeneratorImpl { ...@@ -330,8 +243,8 @@ public class ReportGeneratorImpl {
} }
dataSource.setName("ReportDataSource"); dataSource.setName("ReportDataSource");
dataSource.setDescription(findStr); dataSource.setDescription(findStr);
dataSource.setCreateTime(createTime); dataSource.setCreateTime(new Date());
dataSource.setUpdateTime(createTime); dataSource.setUpdateTime(new Date());
dataSource.setCreateBy("Admin"); dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin"); dataSource.setUpdateBy("Admin");
dataSource.setPeriod(period); dataSource.setPeriod(period);
...@@ -404,9 +317,9 @@ public class ReportGeneratorImpl { ...@@ -404,9 +317,9 @@ public class ReportGeneratorImpl {
// cellData.setFormulaExp(EMPTY); // cellData.setFormulaExp(EMPTY);
// } // }
cellData.setCreateBy("Admin"); cellData.setCreateBy("Admin");
cellData.setCreateTime(createTime); cellData.setCreateTime(new Date());
cellData.setUpdateBy("Admin"); cellData.setUpdateBy("Admin");
cellData.setUpdateTime(createTime); cellData.setUpdateTime(new Date());
cellData.setProjectId(projectId); cellData.setProjectId(projectId);
cellData.setPeriod(period); cellData.setPeriod(period);
periodCellDataMapper.insertSelective(cellData); periodCellDataMapper.insertSelective(cellData);
...@@ -423,8 +336,8 @@ public class ReportGeneratorImpl { ...@@ -423,8 +336,8 @@ public class ReportGeneratorImpl {
cellDataSource.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId()); cellDataSource.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId());
cellDataSource.setCellDataId(cellDataId); cellDataSource.setCellDataId(cellDataId);
cellDataSource.setDataSourceId(dataSource.getId()); cellDataSource.setDataSourceId(dataSource.getId());
cellDataSource.setCreateTime(createTime); cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(createTime); cellDataSource.setUpdateTime(new Date());
cellDataSource.setPeriod(period); cellDataSource.setPeriod(period);
cellDataSource.setProjectId(projectId); cellDataSource.setProjectId(projectId);
SpringContextUtil.periodCellDataSourceMapper.insertSelective(cellDataSource); SpringContextUtil.periodCellDataSourceMapper.insertSelective(cellDataSource);
...@@ -433,10 +346,121 @@ public class ReportGeneratorImpl { ...@@ -433,10 +346,121 @@ public class ReportGeneratorImpl {
} }
} }
} }
return "generate report successful"; }
private List<PeriodReport> createReportsByTemplates(Workbook workbook, List<PeriodTemplate> periodTemplateList, String projectId, Integer period) {
List<PeriodReport> reports = new ArrayList<>();
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
String code = sheet.getSheetName();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream()
.filter(a -> a.getCode().equals(code))
.findFirst();
Long templateId;
if (periodTemplate.isPresent()) {
templateId = periodTemplate.get().getTemplateId();
} else { } else {
return "GenerateReport failed"; templateId = 0L;
}
if (templateId > 0) {
PeriodReport report = new PeriodReport();
Long reportId = distributedIdService.nextId();
report.setId(reportId);
report.setTemplateId(templateId);
report.setPeriod(period);
report.setProjectId(projectId);
report.setCreateBy("Admin");
report.setCreateTime(new Date());
report.setUpdateBy("Admin");
report.setUpdateTime(new Date());
report.setProjectId(projectId);
reportMapper.insertSelective(report);
reports.add(report);
}
}
return reports;
}
private void setConfigAndDataToWorkBook(Workbook workbook, List<PeriodTemplate> periodTemplates,
List<PeriodCellTemplate> periodCellTemplates,
List<PeriodCellTemplateConfig> periodCellTemplateConfigs) {
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
String code = sheet.getSheetName();
Optional<PeriodTemplate> periodTemplate = periodTemplates.stream()
.filter(a -> a.getCode().equals(code))
.findFirst();
Long templateId;
if (periodTemplate.isPresent()) {
templateId = periodTemplate.get().getTemplateId();
} else {
templateId = 0L;
}
if (templateId > 0) {
//get cell template and cell template config with templateId
Map<PeriodCellTemplate, PeriodCellTemplateConfig> cellTemplatePeriodCellTemplateConfigMap = new HashMap<>();
List<PeriodCellTemplate> tempPeriodCellTemplateList = periodCellTemplates.stream()
.filter(a -> a.getReportTemplateId().equals(templateId))
.collect(Collectors.toList());
tempPeriodCellTemplateList.forEach(a -> {
Optional<PeriodCellTemplateConfig> tempCellTemplateConfig = periodCellTemplateConfigs.stream()
.filter(item -> item.getCellTemplateId().equals(a.getCellTemplateId())
&& item.getDataSourceType().equals(CellDataSourceType.Formula.getCode()))
.findFirst();
tempCellTemplateConfig.ifPresent(periodCellTemplateConfig ->
cellTemplatePeriodCellTemplateConfigMap.put(a, periodCellTemplateConfig));
});
cellTemplatePeriodCellTemplateConfigMap.forEach((k, v) -> {
Row row = sheet.getRow(k.getRowIndex());
if (null == row) {
sheet.createRow(k.getRowIndex());
}
row = sheet.getRow(k.getRowIndex());
Cell cell = row.getCell(k.getColumnIndex());
if (null == cell) {
row.createCell(k.getColumnIndex());
}
cell = row.getCell(k.getColumnIndex());
//todo:后面单独处理kv的公式
if (StringUtils.isNotBlank(v.getFormula()) && !v.getFormula().contains("@")) {
cell.setCellFormula(v.getFormula());
logger.debug("formula:" + v.getFormula());
//kv 公式处理
} else if (v.getFormula().contains("@")) {
if (StringUtils.isNotBlank(v.getKeyValueParsedFormula())) {
cell.setCellFormula(v.getKeyValueParsedFormula());
logger.debug("formula:" + v.getKeyValueParsedFormula());
}
}
});
}
}
}
private List<PeriodTemplate> queryPeriodTemplates(String projectId, Integer period, List<Long> templateIds) {
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andIdIn(templateIds);
return periodTemplateMapper.selectByExample(periodTemplateExample);
} }
private List<PeriodCellTemplate> queryPeriodCellTemplates(String projectId, Integer period, List<Long> periodTemplateIdList) {
PeriodCellTemplateExample periodCellTemplateExample = new PeriodCellTemplateExample();
if (periodTemplateIdList.isEmpty()) periodTemplateIdList.add(Long.MAX_VALUE);
periodCellTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andReportTemplateIdIn(periodTemplateIdList).andPeriodEqualTo(period);
return periodCellTemplateMapper.selectByExample(periodCellTemplateExample);
}
private List<PeriodCellTemplateConfig> queryPeriodCellTemplateConfigs(String projectId, Integer period, List<Long> periodTemplateIdList) {
PeriodCellTemplateConfigExample periodCellTemplateConfigExample = new PeriodCellTemplateConfigExample();
periodCellTemplateConfigExample.createCriteria().andProjectIdEqualTo(projectId).andReportTemplateIdIn(periodTemplateIdList).andPeriodEqualTo(period);
return periodCellTemplateConfigMapper.selectByExample(periodCellTemplateConfigExample);
} }
private String getTemplatePath(String path) { private String getTemplatePath(String path) {
......
...@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; ...@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil; import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant; import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.*; import pwc.taxtech.atms.constant.enums.*;
...@@ -18,6 +19,7 @@ import pwc.taxtech.atms.dpo.ReportDto; ...@@ -18,6 +19,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.entity.*; import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.NotFoundException;
import pwc.taxtech.atms.exception.NotSupportedException; import pwc.taxtech.atms.exception.NotSupportedException;
import pwc.taxtech.atms.service.impl.CellConfigTranslater; import pwc.taxtech.atms.service.impl.CellConfigTranslater;
import pwc.taxtech.atms.service.impl.DistributedIdService; import pwc.taxtech.atms.service.impl.DistributedIdService;
...@@ -292,7 +294,7 @@ public class ReportServiceImpl { ...@@ -292,7 +294,7 @@ public class ReportServiceImpl {
CellTemplateConfigExample cellTemplateConfigExample = new CellTemplateConfigExample(); CellTemplateConfigExample cellTemplateConfigExample = new CellTemplateConfigExample();
cellTemplateConfigExample.createCriteria().andReportTemplateIdEqualTo(templateId); cellTemplateConfigExample.createCriteria().andReportTemplateIdEqualTo(templateId);
List<CellTemplateConfig> cellTemplateConfigList = cellTemplateConfigMapper.selectByExample(cellTemplateConfigExample); List<CellTemplateConfig> cellTemplateConfigList = cellTemplateConfigMapper.selectByExample(cellTemplateConfigExample);
if(cellTemplateConfigList.isEmpty())return; if (cellTemplateConfigList.isEmpty()) return;
List<PeriodCellTemplateConfig> periodCellTemplateConfigList = new ArrayList<>(); List<PeriodCellTemplateConfig> periodCellTemplateConfigList = new ArrayList<>();
...@@ -465,22 +467,29 @@ public class ReportServiceImpl { ...@@ -465,22 +467,29 @@ public class ReportServiceImpl {
return operationResultDto; return operationResultDto;
} }
if (serviceType != EnumServiceType.VAT) { MyAsserts.assertEq(serviceType, EnumServiceType.VAT, new NotFoundException());
// 暂不支持非CIT/VAT service批量后端生成报表 List<Long> templateIds = queryTemplates(projectId, periodParam, reportType, serviceType.getCode().toString());
throw new NotSupportedException();
}
int period = periodParam; String rslt = reportGenerator.generateData(projectId, templateIds, ifDeleteManualDataSource, null, periodParam, generator);
String serviceTypeStr = serviceType.getCode().toString(); if (StringUtils.isBlank(rslt)) {
operationResultDto.setResultMsg("ReportGenerateFailed!");
return operationResultDto;
}
operationResultDto.setResult(true);
} catch (Exception ex) {
operationResultDto.setResult(false);
logger.error(ex.getMessage(), ex);
}
return operationResultDto;
}
private List<Long> queryTemplates(String projectId, Integer period, Integer reportType, String serviceTypeStr) {
ProjectServiceTypeExample projectServiceTypeExample = new ProjectServiceTypeExample(); ProjectServiceTypeExample projectServiceTypeExample = new ProjectServiceTypeExample();
projectServiceTypeExample.createCriteria().andServiceTypeIdEqualTo(serviceTypeStr).andProjectIdEqualTo(projectId); projectServiceTypeExample.createCriteria().andServiceTypeIdEqualTo(serviceTypeStr).andProjectIdEqualTo(projectId);
Optional<Long> templateGroupId = projectServiceTypeMapper.selectByExample(projectServiceTypeExample).stream() Optional<Long> templateGroupId = projectServiceTypeMapper.selectByExample(projectServiceTypeExample).stream()
.map(ProjectServiceType::getTemplateGroupId).findFirst(); .map(ProjectServiceType::getTemplateGroupId).findFirst();
if (templateGroupId == null) {
operationResultDto.setResultMsg("TemplateGroupNotExist"); MyAsserts.assertNotNull(templateGroupId, new NotFoundException("not found group"));
return operationResultDto;
}
List<Long> templateIds; List<Long> templateIds;
if (reportType != null) { if (reportType != null) {
...@@ -500,17 +509,7 @@ public class ReportServiceImpl { ...@@ -500,17 +509,7 @@ public class ReportServiceImpl {
templateIds = periodTemplateMapper.selectByExample(periodTemplateExample).stream().map(PeriodTemplate::getId).collect(Collectors.toList()); templateIds = periodTemplateMapper.selectByExample(periodTemplateExample).stream().map(PeriodTemplate::getId).collect(Collectors.toList());
} }
String rslt = reportGenerator.generateData(projectId, templateIds, ifDeleteManualDataSource, null, periodParam, generator); return templateIds;
if (StringUtils.isBlank(rslt)) {
operationResultDto.setResultMsg("ReportGenerateFailed!");
return operationResultDto;
}
operationResultDto.setResult(true);
} catch (Exception ex) {
operationResultDto.setResult(false);
logger.error(ex.getMessage(), ex);
}
return operationResultDto;
} }
public List<CellTemplateReferenceDto> getTemplateReferences(int period) { public List<CellTemplateReferenceDto> getTemplateReferences(int period) {
......
...@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl.report.functions; ...@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl.report.functions;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.vat.service.impl.FormulaAgent; import pwc.taxtech.atms.vat.service.impl.FormulaAgent;
@Setter @Setter
...@@ -36,4 +37,22 @@ public class FormulaContext { ...@@ -36,4 +37,22 @@ public class FormulaContext {
private FormulaAgent formulaAgent; private FormulaAgent formulaAgent;
//private Map<String, FormulaResult> replaceSpecialCellFormulaDic; //private Map<String, FormulaResult> replaceSpecialCellFormulaDic;
public static FormulaContext extractContextFromProject(Project project){
FormulaContext formulaContext = new FormulaContext();
formulaContext.setProjectId(project.getId());
formulaContext.setYear(project.getYear());
formulaContext.setIfRound(true);
formulaContext.setOrganizationId(project.getOrganizationId());
formulaContext.setIfRound(true);
return formulaContext;
}
public FormulaContext fixedFormula(Integer period,Long reportTemplateGroupId,FormulaAgent agent){
this.period=period;
this.formulaAgent=agent;
this.reportTemplateGroupId=reportTemplateGroupId;
this.isYear=(period==0);
return this;
}
} }
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