Commit a7fab01f authored by neo's avatar neo

[DEV] fixed bb with manula formual value

parent 99f91997
......@@ -326,7 +326,7 @@ public class ReportGeneratorImpl {
cellData.setUpdateTime(new Date());
cellData.setProjectId(projectId);
cellData.setPeriod(period);
periodCellDataMapper.insertSelective(cellData);
//after insert celldata, insert the celldatasource for link celldata and datasource
PeriodDataSourceExample dataSourceExample = new PeriodDataSourceExample();
......@@ -335,6 +335,10 @@ public class ReportGeneratorImpl {
List<PeriodDataSource> dataSourceList = SpringContextUtil.periodDataSourceMapper.selectByExample(dataSourceExample);
for (int ii = 0; ii < dataSourceList.size(); ii++) {
PeriodDataSource dataSource = dataSourceList.get(ii);
if (dataSource.getType().intValue() == 10) {//s手工数据源
cellData.setData(dataSource.getAmount() + "");
}
PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId());
cellDataSource.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId());
......@@ -346,6 +350,8 @@ public class ReportGeneratorImpl {
cellDataSource.setProjectId(projectId);
SpringContextUtil.periodCellDataSourceMapper.insertSelective(cellDataSource);
}
periodCellDataMapper.insertSelective(cellData);
}
}
}
......@@ -644,6 +650,7 @@ public class ReportGeneratorImpl {
List<PCTEntity> manuaPctResults = periodCellDataMapper.queryManualPCTs(parameter, projectId);
Map<PCTEntity, BigDecimal> pctCache = new HashMap<>();
Map<PCTEntity, PCTEntity> pctCachePCT = new HashMap<>();
pctResults.forEach(m -> {
BigDecimal data = null;
try {
......@@ -653,30 +660,37 @@ public class ReportGeneratorImpl {
data = BigDecimal.ZERO;
}
pctCache.put(m, data);
pctCachePCT.put(m, m);
});
manuaPctResults.forEach(m -> {
BigDecimal data = null;
try {
data = new BigDecimal(m.getData());
} catch (NumberFormatException e) {
logger.warn("number format ecption for parameter {}", m);
data = BigDecimal.ZERO;
}
if (!pctCache.containsKey(m))
pctCache.put(m, data);
else pctCache.get(m).add(data);
});
configMapToPCTs.forEach((k, v) -> {
v.forEach(pctStr -> {
List<PCTEntity> entities = formulaMapToPCT.get(pctStr);
List<PCTEntity> manualEntities = new ArrayList<>();
BigDecimal result = new BigDecimal("0");
String resultStr = "";
for (PCTEntity entity : entities) {
result = pctCache.containsKey(entity) ? result.add(pctCache.get(entity)) : result;
if (manuaPctResults.contains(entity)) {
manualEntities.add(entity);
} else {
result = pctCache.containsKey(entity) ? result.add(pctCache.get(entity)) : result;
}
}
resultStr = result.toString();
if (!manualEntities.isEmpty()) {
for (PCTEntity m : manualEntities) {
if (pctCachePCT.containsKey(m)) {
if (!StringUtils.isEmpty(pctCachePCT.get(m).getFormulaExp())) {
resultStr += ("+" + pctCachePCT.get(m).getFormulaExp() + "+" + m.getData());
} else {
if (!StringUtils.isEmpty(m.getData()))
resultStr += ("+" + m.getData());
}
}
}
}
k.setParsedFormula(k.getParsedFormula().replace(pctStr, result.toString()));
k.setParsedFormula(k.getParsedFormula().replace(pctStr, resultStr));
});
});
......
......@@ -117,7 +117,7 @@ public interface PeriodCellDataMapper extends MyVatMapper {
@Select("<script>" +
"SELECT " +
" R.PERIOD as period, C.CELL_TEMPLATE_ID AS cellTemplateId, DATA as data " +
" R.PERIOD as period, C.CELL_TEMPLATE_ID AS cellTemplateId, DATA as data ,FORMULA_EXP as formulaExp" +
"FROM " +
" PERIOD_CELL_DATA C, " +
" PERIOD_REPORT R " +
......@@ -140,7 +140,7 @@ public interface PeriodCellDataMapper extends MyVatMapper {
"FROM " +
" PERIOD_DATA_SOURCE p " +
"WHERE " +
" PROJECT_ID = #{projectId} AND " +
" PROJECT_ID = #{projectId} AND p.TYPE = 10 " +
" <foreach item=\"item\" index=\"index\" collection=\"list\"" +
" open=\"(\" separator=\"OR\" close=\")\">" +
" ( p.PERIOD=#{item.period} AND p.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" +
......
......@@ -4,6 +4,7 @@ public class PCTEntity {
Integer period;
Long cellTemplateId;
String data;
String formulaExp;
public PCTEntity() {
}
......@@ -49,4 +50,12 @@ public class PCTEntity {
public void setData(String data) {
this.data = data;
}
public String getFormulaExp() {
return formulaExp;
}
public void setFormulaExp(String formulaExp) {
this.formulaExp = formulaExp;
}
}
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