Commit 6ea32431 authored by neo's avatar neo

[DEV] add munaul cell data and cell data source

parent 1e75eb4b
......@@ -296,10 +296,6 @@ public class ReportGeneratorImpl {
for (int ii = 0; ii < dataSourceList.size(); ii++) {
PeriodDataSource dataSource = dataSourceList.get(ii);
if (isMergeMunual && dataSource.getType().intValue() == 10) {
cellData.setData(dataSource.getAmount() + "");
if (dataSourceList.size() == 1) cellData.setFormulaExp(dataSource.getAmount() + "");
}
PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId());
cellDataSource.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId());
......@@ -315,6 +311,77 @@ public class ReportGeneratorImpl {
periodCellDataMapper.insertSelective(cellData);
}
}
if (isMergeMunual) {
List<PeriodCellTemplateConfig> keyInCellTemplateConfigs = resources.getPeriodCellTemplateConfigs().stream()
.filter(a -> a.getReportTemplateId().equals(templateId) && a.getDataSourceType().equals(CellDataSourceType.KeyIn.getCode()))
.collect(Collectors.toList());
for (PeriodCellTemplateConfig keyInCellTemplateConfig : keyInCellTemplateConfigs) {
PeriodDataSourceExample dataSourceExample = new PeriodDataSourceExample();
dataSourceExample.createCriteria().andPeriodEqualTo(period).andProjectIdEqualTo(projectId)
.andCellTemplateIdEqualTo(keyInCellTemplateConfig.getCellTemplateId()).andTypeEqualTo(10);
List<PeriodDataSource> dataSourceList = SpringContextUtil.periodDataSourceMapper.selectByExample(dataSourceExample);
if (!dataSourceList.isEmpty() && dataSourceList.size() == 1) {
PeriodCellDataExample cellDataExample = new PeriodCellDataExample();
cellDataExample.createCriteria().andPeriodEqualTo(period).andProjectIdEqualTo(projectId)
.andCellTemplateIdEqualTo(keyInCellTemplateConfig.getCellTemplateId());
List<PeriodCellData> cellDataList = periodCellDataMapper.selectByExample(cellDataExample);
if (cellDataList.size() == 1) {
PeriodCellData cellData = cellDataList.get(0);
PeriodDataSource dataSource = dataSourceList.get(0);
cellData.setData(dataSource.getAmount() + "");
if (StringUtils.isEmpty(cellData.getFormulaExp().trim()))
cellData.setFormulaExp(dataSource.getAmount() + "");
PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId());
cellDataSource.setCellTemplateId(keyInCellTemplateConfig.getCellTemplateId());
cellDataSource.setCellDataId(cellData.getId());
cellDataSource.setDataSourceId(dataSource.getId());
cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date());
cellDataSource.setPeriod(period);
cellDataSource.setProjectId(projectId);
SpringContextUtil.periodCellDataSourceMapper.insertSelective(cellDataSource);
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
}else if(cellDataList.isEmpty()){
PeriodCellData cellData = new PeriodCellData();
Long cellDataId = distributedIdService.nextId();
cellData.setId(cellDataId);
cellData.setReportId(reportId);
cellData.setCellTemplateId(keyInCellTemplateConfig.getCellTemplateId());
cellData.setCreateBy("Admin");
cellData.setCreateTime(new Date());
cellData.setUpdateBy("Admin");
cellData.setUpdateTime(new Date());
cellData.setProjectId(projectId);
cellData.setPeriod(period);
PeriodDataSource dataSource = dataSourceList.get(0);
cellData.setData(dataSource.getAmount() + "");
cellData.setFormulaExp(dataSource.getAmount() + "");
PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId());
cellDataSource.setCellTemplateId(keyInCellTemplateConfig.getCellTemplateId());
cellDataSource.setCellDataId(cellData.getId());
cellDataSource.setDataSourceId(dataSource.getId());
cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date());
cellDataSource.setPeriod(period);
cellDataSource.setProjectId(projectId);
SpringContextUtil.periodCellDataSourceMapper.insertSelective(cellDataSource);
periodCellDataMapper.insert(cellData);
}else {
logger.warn("should not be !!!");
}
}
}
}
}
} catch (Exception e) {
......
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