Commit 2082d9aa by hzc

报表四清表增加时间维度条件。报表四新增指标排名字段

parent 54eb478d
...@@ -78,6 +78,12 @@ public class IndicatorsReportFour implements Serializable { ...@@ -78,6 +78,12 @@ public class IndicatorsReportFour implements Serializable {
private String value; private String value;
/** /**
* 指标值排名
*/
@Column(name = "value_rank" )
private Integer valueRank;
/**
* 同期值 * 同期值
*/ */
@Column(name = "same_value" ) @Column(name = "same_value" )
......
...@@ -18,5 +18,5 @@ import java.util.List; ...@@ -18,5 +18,5 @@ import java.util.List;
public interface IndicatorsReportFourMapper extends BaseMapper<IndicatorsReportFour> { public interface IndicatorsReportFourMapper extends BaseMapper<IndicatorsReportFour> {
void batchInsert(@Param("indicatorsReportFours") List<IndicatorsReportFour> indicatorsReportFours); void batchInsert(@Param("indicatorsReportFours") List<IndicatorsReportFour> indicatorsReportFours);
void deleteByCompareCatalog(String compareCatalog); void deleteByCompareCatalog(@Param("compareCatalog") String compareCatalog,@Param("date") Integer date);
} }
...@@ -37,7 +37,7 @@ import com.keymobile.indicators.utils.CalculateUtils; ...@@ -37,7 +37,7 @@ import com.keymobile.indicators.utils.CalculateUtils;
@Service @Service
public class IndicatorsReportService { public class IndicatorsReportService {
private Logger logger = LoggerFactory.getLogger(IndicatorsReportService.class); private Logger logger = LoggerFactory.getLogger(IndicatorsReportService.class);
@Autowired @Autowired
private ReportOneMapper reportOneMapper; private ReportOneMapper reportOneMapper;
@Autowired @Autowired
...@@ -55,7 +55,7 @@ public class IndicatorsReportService { ...@@ -55,7 +55,7 @@ public class IndicatorsReportService {
@Autowired @Autowired
private IndicatorsReportFourMapper indicatorsReportFourMapper; private IndicatorsReportFourMapper indicatorsReportFourMapper;
//保存指标本期同期结果 //保存指标本期同期结果
public Integer saveOrUpdateReportTwo(IndicatorsReportTwo reportTwoData) { public Integer saveOrUpdateReportTwo(IndicatorsReportTwo reportTwoData) {
if(reportTwoData.getId()==null) { if(reportTwoData.getId()==null) {
...@@ -65,7 +65,7 @@ public class IndicatorsReportService { ...@@ -65,7 +65,7 @@ public class IndicatorsReportService {
} }
return reportTwoData.getId(); return reportTwoData.getId();
} }
public void batchSaveOrUpdateReportThree(List<IndicatorsReportThree> reportThreeDatas) { public void batchSaveOrUpdateReportThree(List<IndicatorsReportThree> reportThreeDatas) {
List<IndicatorsReportThree> addList = new ArrayList<>(); List<IndicatorsReportThree> addList = new ArrayList<>();
List<IndicatorsReportThree> updateList = new ArrayList<>(); List<IndicatorsReportThree> updateList = new ArrayList<>();
...@@ -83,7 +83,7 @@ public class IndicatorsReportService { ...@@ -83,7 +83,7 @@ public class IndicatorsReportService {
reportThreeMapper.batchUpdate(updateList); reportThreeMapper.batchUpdate(updateList);
} }
} }
public void batchSaveOrUpdateReportTwo(List<IndicatorsReportTwo> reportTwoDatas) { public void batchSaveOrUpdateReportTwo(List<IndicatorsReportTwo> reportTwoDatas) {
List<IndicatorsReportTwo> addList = new ArrayList<>(); List<IndicatorsReportTwo> addList = new ArrayList<>();
List<IndicatorsReportTwo> updateList = new ArrayList<>(); List<IndicatorsReportTwo> updateList = new ArrayList<>();
...@@ -101,7 +101,7 @@ public class IndicatorsReportService { ...@@ -101,7 +101,7 @@ public class IndicatorsReportService {
reportTwoMapper.batchUpdate(updateList); reportTwoMapper.batchUpdate(updateList);
} }
} }
public Integer saveOrUpdate(IndicatorsReportOne reportData) { public Integer saveOrUpdate(IndicatorsReportOne reportData) {
if(reportData.getId()==null) { if(reportData.getId()==null) {
reportOneMapper.insert(reportData); reportOneMapper.insert(reportData);
...@@ -110,7 +110,7 @@ public class IndicatorsReportService { ...@@ -110,7 +110,7 @@ public class IndicatorsReportService {
} }
return reportData.getId(); return reportData.getId();
} }
public void batchSaveOrUpdate(List<IndicatorsReportOne> reportDatas) { public void batchSaveOrUpdate(List<IndicatorsReportOne> reportDatas) {
List<IndicatorsReportOne> addList = new ArrayList<>(); List<IndicatorsReportOne> addList = new ArrayList<>();
List<IndicatorsReportOne> updateList = new ArrayList<>(); List<IndicatorsReportOne> updateList = new ArrayList<>();
...@@ -128,9 +128,9 @@ public class IndicatorsReportService { ...@@ -128,9 +128,9 @@ public class IndicatorsReportService {
reportOneMapper.batchUpdate(updateList); reportOneMapper.batchUpdate(updateList);
} }
} }
public void deleteReportThreeDataByParam(String compareCatalog,Integer date, public void deleteReportThreeDataByParam(String compareCatalog,Integer date,
List<String> compareObjs,String code) { List<String> compareObjs,String code) {
if(compareObjs!=null&&compareObjs.size()>0){ if(compareObjs!=null&&compareObjs.size()>0){
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
String type = this.getCompareType(date); String type = this.getCompareType(date);
...@@ -143,15 +143,15 @@ public class IndicatorsReportService { ...@@ -143,15 +143,15 @@ public class IndicatorsReportService {
reportThreeMapper.deleteByParam(paramMap); reportThreeMapper.deleteByParam(paramMap);
log.info("开始清除报表四数据:compareCatalog={}",compareCatalog); log.info("开始清除报表四数据:compareCatalog={}",compareCatalog);
indicatorsReportFourMapper.deleteByCompareCatalog(compareCatalog); indicatorsReportFourMapper.deleteByCompareCatalog(compareCatalog,date);
}else{ }else{
log.info("指标层级为空或对标主体为空-不清除报表三数据"); log.info("指标层级为空或对标主体为空-不清除报表三数据");
} }
return ; return ;
} }
public void dealDriveIndReportThreeData(String compareCatalog,String compareId,List<String> indIds, public void dealDriveIndReportThreeData(String compareCatalog,String compareId,List<String> indIds,
Integer date,String code) throws Exception{ Integer date,String code) throws Exception{
String type = this.getCompareType(date); String type = this.getCompareType(date);
/** /**
* key:rankMarkAfterMap 末三 ,rankMarkBeforeMap 前三 ,单位id获取排名 * key:rankMarkAfterMap 末三 ,rankMarkBeforeMap 前三 ,单位id获取排名
...@@ -159,7 +159,7 @@ public class IndicatorsReportService { ...@@ -159,7 +159,7 @@ public class IndicatorsReportService {
* @Author hzc * @Author hzc
**/ **/
Map<String,Map<String,Integer>> rankMarkMap = new HashMap<>(); Map<String,Map<String,Integer>> rankMarkMap = new HashMap<>();
//报表四数据 //报表四数据
List<IndicatorsReportFour> indicatorsReportFours = new ArrayList<>(); List<IndicatorsReportFour> indicatorsReportFours = new ArrayList<>();
for(String indId : indIds) { for(String indId : indIds) {
List<IndicatorsReportThree> dataList = new ArrayList<>(); List<IndicatorsReportThree> dataList = new ArrayList<>();
...@@ -212,7 +212,7 @@ public class IndicatorsReportService { ...@@ -212,7 +212,7 @@ public class IndicatorsReportService {
indicatorsReportFour.setIndRule(indRule); indicatorsReportFour.setIndRule(indRule);
indicatorsReportFour.setCompareId(compareId); indicatorsReportFour.setCompareId(compareId);
indicatorsReportFour.setValue(calResult.getValue()); indicatorsReportFour.setValue(calResult.getValue());
indicatorsReportFour.setValueRank(calResult.getRank());
//设置对标单元目录 //设置对标单元目录
indicatorsReportFour.setCompareCatalog(compareCatalog); indicatorsReportFour.setCompareCatalog(compareCatalog);
indicatorsReportFour.setCode(code); indicatorsReportFour.setCode(code);
...@@ -230,7 +230,7 @@ public class IndicatorsReportService { ...@@ -230,7 +230,7 @@ public class IndicatorsReportService {
indicatorsReportFour.setAverage(average); indicatorsReportFour.setAverage(average);
//对比平均数 //对比平均数
indicatorsReportFour.setCompareAvg(compareAvg); indicatorsReportFour.setCompareAvg(compareAvg);
//末三 //末三
indicatorsReportFour.setRankMarkAfter(rankMarkAfterMap.get(calResult.getCompareObj())); indicatorsReportFour.setRankMarkAfter(rankMarkAfterMap.get(calResult.getCompareObj()));
//前三 //前三
indicatorsReportFour.setRankMarkBefore(rankMarkBeforeMap.get(calResult.getCompareObj())); indicatorsReportFour.setRankMarkBefore(rankMarkBeforeMap.get(calResult.getCompareObj()));
...@@ -238,7 +238,7 @@ public class IndicatorsReportService { ...@@ -238,7 +238,7 @@ public class IndicatorsReportService {
//填充排名前三末三指标个数 //填充排名前三末三指标个数
indReportData = this.fillRankHeadAndAfterCount(indReportData,calResults, indRule); indReportData = this.fillRankHeadAndAfterCount(indReportData,calResults, indRule);
//判断是否存在同期数据 //判断是否存在同期数据
DriveIndCalResultDef sameCalResult = driveIndCalResultDefMapper. DriveIndCalResultDef sameCalResult = driveIndCalResultDefMapper.
findByCompareIdAndCompareObjAndIndIdAndDate( findByCompareIdAndCompareObjAndIndIdAndDate(
...@@ -255,13 +255,13 @@ public class IndicatorsReportService { ...@@ -255,13 +255,13 @@ public class IndicatorsReportService {
//保存同期值 //保存同期值
indicatorsReportFour.setSameValue(sameCalResult.getValue()); indicatorsReportFour.setSameValue(sameCalResult.getValue());
//算增幅 //算增幅
if(!"NaN".equals(sameCalResult.getValue()) if(!"NaN".equals(sameCalResult.getValue())
&& !"Infinite".equals(sameCalResult.getValue()) && !"Infinite".equals(sameCalResult.getValue())
&& StringUtils.isNotBlank(sameCalResult.getValue()) && StringUtils.isNotBlank(sameCalResult.getValue())
&& !"NaN".equals(calResult.getValue()) && !"NaN".equals(calResult.getValue())
&& !"Infinite".equals(calResult.getValue()) && !"Infinite".equals(calResult.getValue())
&& StringUtils.isNotBlank(calResult.getValue())) { && StringUtils.isNotBlank(calResult.getValue())) {
String calGowthValue = CalculateUtils.calGowth(calResult.getValue(), String calGowthValue = CalculateUtils.calGowth(calResult.getValue(),
sameCalResult.getValue(),growCalType); sameCalResult.getValue(),growCalType);
if(StringUtils.isNotBlank(calGowthValue)) { if(StringUtils.isNotBlank(calGowthValue)) {
if(Double.parseDouble(calResult.getValue())- if(Double.parseDouble(calResult.getValue())-
...@@ -331,7 +331,7 @@ public class IndicatorsReportService { ...@@ -331,7 +331,7 @@ public class IndicatorsReportService {
dataList = this.fillImproveHeadAndAfterCount(compareCatalog,resultRank, dataList, 0, code); dataList = this.fillImproveHeadAndAfterCount(compareCatalog,resultRank, dataList, 0, code);
//清空map //清空map
resultRank.clear(); resultRank.clear();
if("0".equals(indRule)) { if("0".equals(indRule)) {
indRule = "1"; indRule = "1";
}else { }else {
...@@ -346,7 +346,7 @@ public class IndicatorsReportService { ...@@ -346,7 +346,7 @@ public class IndicatorsReportService {
//保存报表四数据 //保存报表四数据
if(indicatorsReportFours.size()>0){ if(indicatorsReportFours.size()>0){
log.info("保存报表四数据,条数:{}",indicatorsReportFours.size()); log.info("保存报表四数据,条数:{}",indicatorsReportFours.size());
indicatorsReportFourMapper.batchInsert(indicatorsReportFours); indicatorsReportFourMapper.batchInsert(indicatorsReportFours);
} }
} }
...@@ -390,12 +390,12 @@ public class IndicatorsReportService { ...@@ -390,12 +390,12 @@ public class IndicatorsReportService {
} }
returnValue.put("rankMarkAfterMap",rankMarkAfterMap); returnValue.put("rankMarkAfterMap",rankMarkAfterMap);
returnValue.put("rankMarkBeforeMap",rankMarkBeforeMap); returnValue.put("rankMarkBeforeMap",rankMarkBeforeMap);
return returnValue; return returnValue;
} }
//type:0 前三 1末三 //type:0 前三 1末三
private List<IndicatorsReportThree> fillImproveHeadAndAfterCount(String compareCatalog, private List<IndicatorsReportThree> fillImproveHeadAndAfterCount(String compareCatalog,
Map<String,Integer> resultRank,List<IndicatorsReportThree> dataList,Integer type,String code){ Map<String,Integer> resultRank,List<IndicatorsReportThree> dataList,Integer type,String code){
resultRank = CalculateUtils.sortMapByValue(resultRank,0); resultRank = CalculateUtils.sortMapByValue(resultRank,0);
for(IndicatorsReportThree indReportData : dataList) { for(IndicatorsReportThree indReportData : dataList) {
//判断是否存在 //判断是否存在
...@@ -406,7 +406,7 @@ public class IndicatorsReportService { ...@@ -406,7 +406,7 @@ public class IndicatorsReportService {
indReportData.setId(DBIndReportData.getId()); indReportData.setId(DBIndReportData.getId());
} }
//算指标提升率 //算指标提升率
if(indReportData.getEffectiveIndCount()!=null && if(indReportData.getEffectiveIndCount()!=null &&
indReportData.getIndImproveCount()!=null) { indReportData.getIndImproveCount()!=null) {
String improveRate = String.format("%.4f", String improveRate = String.format("%.4f",
new BigDecimal(indReportData.getIndImproveCount()*1.0/ new BigDecimal(indReportData.getIndImproveCount()*1.0/
...@@ -441,10 +441,10 @@ public class IndicatorsReportService { ...@@ -441,10 +441,10 @@ public class IndicatorsReportService {
} }
return dataList; return dataList;
} }
//填充排名前三末三指标个数 //填充排名前三末三指标个数
private IndicatorsReportThree fillRankHeadAndAfterCount(IndicatorsReportThree indReportData, private IndicatorsReportThree fillRankHeadAndAfterCount(IndicatorsReportThree indReportData,
List<DriveIndCalResultDef> calResults,String indRule) { List<DriveIndCalResultDef> calResults,String indRule) {
Map<String,String> valueMap = new HashMap<>(); Map<String,String> valueMap = new HashMap<>();
//前三 //前三
for(DriveIndCalResultDef calResult : calResults) { for(DriveIndCalResultDef calResult : calResults) {
...@@ -464,7 +464,7 @@ public class IndicatorsReportService { ...@@ -464,7 +464,7 @@ public class IndicatorsReportService {
indReportData.setRankOneCount(1); indReportData.setRankOneCount(1);
}else { }else {
indReportData.setRankOneCount( indReportData.setRankOneCount(
indReportData.getRankOneCount()+1); indReportData.getRankOneCount()+1);
} }
} }
if(calResult.getRank()==2) { if(calResult.getRank()==2) {
...@@ -472,7 +472,7 @@ public class IndicatorsReportService { ...@@ -472,7 +472,7 @@ public class IndicatorsReportService {
indReportData.setRankTwoCount(1); indReportData.setRankTwoCount(1);
}else { }else {
indReportData.setRankTwoCount( indReportData.setRankTwoCount(
indReportData.getRankTwoCount()+1); indReportData.getRankTwoCount()+1);
} }
} }
if(calResult.getRank()==3) { if(calResult.getRank()==3) {
...@@ -480,7 +480,7 @@ public class IndicatorsReportService { ...@@ -480,7 +480,7 @@ public class IndicatorsReportService {
indReportData.setRankThreeCount(1); indReportData.setRankThreeCount(1);
}else { }else {
indReportData.setRankThreeCount( indReportData.setRankThreeCount(
indReportData.getRankThreeCount()+1); indReportData.getRankThreeCount()+1);
} }
} }
} }
...@@ -511,7 +511,7 @@ public class IndicatorsReportService { ...@@ -511,7 +511,7 @@ public class IndicatorsReportService {
indReportData.setRankLastOneCount(1); indReportData.setRankLastOneCount(1);
}else { }else {
indReportData.setRankLastOneCount( indReportData.setRankLastOneCount(
indReportData.getRankLastOneCount()+1); indReportData.getRankLastOneCount()+1);
} }
} }
if(map.getValue()==2) { if(map.getValue()==2) {
...@@ -519,7 +519,7 @@ public class IndicatorsReportService { ...@@ -519,7 +519,7 @@ public class IndicatorsReportService {
indReportData.setRankLastTwoCount(1); indReportData.setRankLastTwoCount(1);
}else { }else {
indReportData.setRankLastTwoCount( indReportData.setRankLastTwoCount(
indReportData.getRankLastTwoCount()+1); indReportData.getRankLastTwoCount()+1);
} }
} }
if(map.getValue()==3) { if(map.getValue()==3) {
...@@ -527,7 +527,7 @@ public class IndicatorsReportService { ...@@ -527,7 +527,7 @@ public class IndicatorsReportService {
indReportData.setRankLastThreeCount(1); indReportData.setRankLastThreeCount(1);
}else { }else {
indReportData.setRankLastThreeCount( indReportData.setRankLastThreeCount(
indReportData.getRankLastThreeCount()+1); indReportData.getRankLastThreeCount()+1);
} }
} }
} }
...@@ -537,13 +537,13 @@ public class IndicatorsReportService { ...@@ -537,13 +537,13 @@ public class IndicatorsReportService {
} }
return indReportData; return indReportData;
} }
//填充优劣平均数个数 //填充优劣平均数个数
private Map<String,Object> fillAverageCount(IndicatorsReportThree indReportData, private Map<String,Object> fillAverageCount(IndicatorsReportThree indReportData,
DriveIndCalResultDef calResult,String indRule) { DriveIndCalResultDef calResult,String indRule) {
String average = null; String average = null;
//优于平均水平的指标个数 //优于平均水平的指标个数
if(StringUtils.isNotBlank(calResult.getActualAverage()) if(StringUtils.isNotBlank(calResult.getActualAverage())
&& !"0.0".equals(calResult.getActualAverage())) { && !"0.0".equals(calResult.getActualAverage())) {
average = calResult.getActualAverage(); average = calResult.getActualAverage();
}else { }else {
...@@ -555,7 +555,7 @@ public class IndicatorsReportService { ...@@ -555,7 +555,7 @@ public class IndicatorsReportService {
* @Author hzc * @Author hzc
**/ **/
Integer compareAvg=2; Integer compareAvg=2;
if(StringUtils.isNotBlank(average) if(StringUtils.isNotBlank(average)
&& StringUtils.isNotBlank(calResult.getValue())) { && StringUtils.isNotBlank(calResult.getValue())) {
//指标值大于平均数 //指标值大于平均数
if(Double.parseDouble(calResult.getValue()) > Double.parseDouble(average)) { if(Double.parseDouble(calResult.getValue()) > Double.parseDouble(average)) {
...@@ -602,10 +602,10 @@ public class IndicatorsReportService { ...@@ -602,10 +602,10 @@ public class IndicatorsReportService {
returnMap.put("average",average); returnMap.put("average",average);
return returnMap; return returnMap;
} }
@Async @Async
public void dealDriveIndReportTwoData(String compareCatalog,String compareUnitId,List<String> indIds, public void dealDriveIndReportTwoData(String compareCatalog,String compareUnitId,List<String> indIds,
List<String> compareObjs,Integer date,String code) { List<String> compareObjs,Integer date,String code) {
List<IndicatorsReportTwo> dataList = new ArrayList<>(); List<IndicatorsReportTwo> dataList = new ArrayList<>();
String type = this.getCompareType(date); String type = this.getCompareType(date);
for(String indId : indIds) { for(String indId : indIds) {
...@@ -632,14 +632,14 @@ public class IndicatorsReportService { ...@@ -632,14 +632,14 @@ public class IndicatorsReportService {
indReportData.setCompareCatalog(compareCatalog); indReportData.setCompareCatalog(compareCatalog);
//设置对标单元id //设置对标单元id
indReportData.setCompareUnitId(compareUnitId); indReportData.setCompareUnitId(compareUnitId);
indReportData = fillDriveIndiReportTwoData(compareCatalog,indId, calDatas, indReportData, indReportData = fillDriveIndiReportTwoData(compareCatalog,indId, calDatas, indReportData,
date, compareObjs, code); date, compareObjs, code);
dataList.add(indReportData); dataList.add(indReportData);
} }
} }
this.batchSaveOrUpdateReportTwo(dataList);//批量新增或修改 this.batchSaveOrUpdateReportTwo(dataList);//批量新增或修改
} }
//异步执行基础项数据整合 //异步执行基础项数据整合
@Async @Async
public void dealBaseIndReportOneData(Integer date,List<String> compareObjs,String code) { public void dealBaseIndReportOneData(Integer date,List<String> compareObjs,String code) {
...@@ -658,21 +658,21 @@ public class IndicatorsReportService { ...@@ -658,21 +658,21 @@ public class IndicatorsReportService {
indReportData.setUnit(indiData.getUnit()); indReportData.setUnit(indiData.getUnit());
indReportData.setCode(code); indReportData.setCode(code);
indReportData = fillBaseIndiReportOneData(indiData,indReportData,code); indReportData = fillBaseIndiReportOneData(indiData,indReportData,code);
datas.add(indReportData); datas.add(indReportData);
} }
//批量新增或修改 //批量新增或修改
this.batchSaveOrUpdate(datas); this.batchSaveOrUpdate(datas);
logger.info("完成:"+date+" 基础项本期同期整合"); logger.info("完成:"+date+" 基础项本期同期整合");
} }
public void dealReportOneDatas(String compareCatalog,List<DriveIndCalResultDef> calDatas,String code) { public void dealReportOneDatas(String compareCatalog,List<DriveIndCalResultDef> calDatas,String code) {
List<IndicatorsReportOne> datas = new ArrayList<>(); List<IndicatorsReportOne> datas = new ArrayList<>();
for(DriveIndCalResultDef calData : calDatas) { for(DriveIndCalResultDef calData : calDatas) {
String type = this.getCompareType(calData.getDate()); String type = this.getCompareType(calData.getDate());
//判断是否存在 //判断是否存在
IndicatorsReportOne indReportData = reportOneMapper.getByParam( IndicatorsReportOne indReportData = reportOneMapper.getByParam(
calData.getIndId(), calData.getCompareObj(), calData.getDate(), calData.getIndId(), calData.getCompareObj(), calData.getDate(),
type, code, compareCatalog); type, code, compareCatalog);
if(indReportData==null) { if(indReportData==null) {
indReportData = new IndicatorsReportOne(); indReportData = new IndicatorsReportOne();
...@@ -686,11 +686,11 @@ public class IndicatorsReportService { ...@@ -686,11 +686,11 @@ public class IndicatorsReportService {
//批量新增或修改 //批量新增或修改
this.batchSaveOrUpdate(datas); this.batchSaveOrUpdate(datas);
} }
//整合指标本期同期指标报表数据 //整合指标本期同期指标报表数据
@Async @Async
public String dealReportOne(String compareCatalog,String compareId,List<String> indIds, public String dealReportOne(String compareCatalog,String compareId,List<String> indIds,
List<String> compareObjs,Integer date,String code) { List<String> compareObjs,Integer date,String code) {
int count=0; int count=0;
for(String indId : indIds) { for(String indId : indIds) {
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
...@@ -759,10 +759,10 @@ public class IndicatorsReportService { ...@@ -759,10 +759,10 @@ public class IndicatorsReportService {
compareCatalog,compareId,date,count); compareCatalog,compareId,date,count);
return "deal indicators report one success"; return "deal indicators report one success";
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public IndicatorsReportTwo fillDriveIndiReportTwoData(String compareCatalog,String indId,List<DriveIndCalResultDef> calDatas, public IndicatorsReportTwo fillDriveIndiReportTwoData(String compareCatalog,String indId,List<DriveIndCalResultDef> calDatas,
IndicatorsReportTwo indReportData,Integer date,List<String> compareObjs,String code) { IndicatorsReportTwo indReportData,Integer date,List<String> compareObjs,String code) {
//针对省对市对标获取前三末三地区顺序 //针对省对市对标获取前三末三地区顺序
Map<String,Integer> objSort = new HashMap<>(); Map<String,Integer> objSort = new HashMap<>();
objSort.put("4301",1);objSort.put("4302",2);objSort.put("4303",3); objSort.put("4301",1);objSort.put("4302",2);objSort.put("4303",3);
...@@ -770,7 +770,7 @@ public class IndicatorsReportService { ...@@ -770,7 +770,7 @@ public class IndicatorsReportService {
objSort.put("4307",7);objSort.put("4308",8);objSort.put("4309",9); objSort.put("4307",7);objSort.put("4308",8);objSort.put("4309",9);
objSort.put("4310",10);objSort.put("4311",11);objSort.put("4312",12); objSort.put("4310",10);objSort.put("4311",11);objSort.put("4312",12);
objSort.put("4313",13);objSort.put("4331",14); objSort.put("4313",13);objSort.put("4331",14);
String average = null;//定义存储指标组内平均值 String average = null;//定义存储指标组内平均值
String sameAverage = null;//定义存储指标组内同期平均值 String sameAverage = null;//定义存储指标组内同期平均值
//根据指标id获取指标详情 //根据指标id获取指标详情
...@@ -800,21 +800,21 @@ public class IndicatorsReportService { ...@@ -800,21 +800,21 @@ public class IndicatorsReportService {
indRule = driveIndDef.getIndRule(); indRule = driveIndDef.getIndRule();
} }
//算平均分同比 //算平均分同比
String averageRate = CalculateUtils.calGowth(currentActualAverage.getValue(), String averageRate = CalculateUtils.calGowth(currentActualAverage.getValue(),
sameActualAverage.getValue(), driveIndDef.getGrowCalType()); sameActualAverage.getValue(), driveIndDef.getGrowCalType());
indReportData.setAverageRate(averageRate); indReportData.setAverageRate(averageRate);
//计算变化趋势 //计算变化趋势
if(StringUtils.isNotBlank(averageRate)) { if(StringUtils.isNotBlank(averageRate)) {
if("1".equals(indRule)) {//反向 if("1".equals(indRule)) {//反向
if(Double.parseDouble(currentActualAverage.getValue())> if(Double.parseDouble(currentActualAverage.getValue())>
Double.parseDouble(sameActualAverage.getValue())) { Double.parseDouble(sameActualAverage.getValue())) {
indReportData.setTrend("1");//趋差 indReportData.setTrend("1");//趋差
}else { }else {
indReportData.setTrend("0"); indReportData.setTrend("0");
} }
}else {//其他当正向处理 }else {//其他当正向处理
if(Double.parseDouble(currentActualAverage.getValue())> if(Double.parseDouble(currentActualAverage.getValue())>
Double.parseDouble(sameActualAverage.getValue())) { Double.parseDouble(sameActualAverage.getValue())) {
indReportData.setTrend("0");//趋好 indReportData.setTrend("0");//趋好
}else { }else {
indReportData.setTrend("1"); indReportData.setTrend("1");
...@@ -833,7 +833,7 @@ public class IndicatorsReportService { ...@@ -833,7 +833,7 @@ public class IndicatorsReportService {
List<DriveIndCalResultDef> sameCalDatas = driveIndCalResultDefMapper List<DriveIndCalResultDef> sameCalDatas = driveIndCalResultDefMapper
.findByIndIdAndDateAndCompareObjIn(paramMap); .findByIndIdAndDateAndCompareObjIn(paramMap);
if(!sameCalDatas.isEmpty()) { if(!sameCalDatas.isEmpty()) {
if(sameCalDatas.get(0).getActualAverage()!=null && if(sameCalDatas.get(0).getActualAverage()!=null &&
!"0.0".equals(sameCalDatas.get(0).getActualAverage())) { !"0.0".equals(sameCalDatas.get(0).getActualAverage())) {
sameAverage = sameCalDatas.get(0).getActualAverage(); sameAverage = sameCalDatas.get(0).getActualAverage();
}else { }else {
...@@ -842,7 +842,7 @@ public class IndicatorsReportService { ...@@ -842,7 +842,7 @@ public class IndicatorsReportService {
indReportData.setSameAverage(sameAverage); indReportData.setSameAverage(sameAverage);
} }
//填充本期实际平均值 //填充本期实际平均值
if(calDatas.get(0).getActualAverage()!=null && if(calDatas.get(0).getActualAverage()!=null &&
!"0.0".equals(calDatas.get(0).getActualAverage())) { !"0.0".equals(calDatas.get(0).getActualAverage())) {
average = calDatas.get(0).getActualAverage(); average = calDatas.get(0).getActualAverage();
}else { }else {
...@@ -874,7 +874,7 @@ public class IndicatorsReportService { ...@@ -874,7 +874,7 @@ public class IndicatorsReportService {
driveIndDef.getIndRule(),average, calDatas)); driveIndDef.getIndRule(),average, calDatas));
} }
//同比提升单位 //同比提升单位
Map<String,Object> sameImproveResult = this.sameImproveUnits(compareCatalog,indId, date, Map<String,Object> sameImproveResult = this.sameImproveUnits(compareCatalog,indId, date,
compareObjs,calDatas,code); compareObjs,calDatas,code);
if(Integer.parseInt(sameImproveResult.get("improveNum").toString())!=0) { if(Integer.parseInt(sameImproveResult.get("improveNum").toString())!=0) {
indReportData.setSameImproveUnits(Integer.parseInt(sameImproveResult.get("improveNum").toString())); indReportData.setSameImproveUnits(Integer.parseInt(sameImproveResult.get("improveNum").toString()));
...@@ -911,7 +911,7 @@ public class IndicatorsReportService { ...@@ -911,7 +911,7 @@ public class IndicatorsReportService {
objSortRank = CalculateUtils.rankByObjSort(resultRank, objSort); objSortRank = CalculateUtils.rankByObjSort(resultRank, objSort);
resultRank = (Map<String,Integer>)objSortRank.get("rankMap"); resultRank = (Map<String,Integer>)objSortRank.get("rankMap");
end = Integer.parseInt(objSortRank.get("rankNum").toString()); end = Integer.parseInt(objSortRank.get("rankNum").toString());
for(Map.Entry<String,Integer> entry : resultRank.entrySet()) { for(Map.Entry<String,Integer> entry : resultRank.entrySet()) {
sameImproveAfterThree.append(entry.getKey()).append(";"); sameImproveAfterThree.append(entry.getKey()).append(";");
sameImproveAfterThreeDesc.append(compareObjMapper.get(entry.getKey())).append(";"); sameImproveAfterThreeDesc.append(compareObjMapper.get(entry.getKey())).append(";");
...@@ -939,7 +939,7 @@ public class IndicatorsReportService { ...@@ -939,7 +939,7 @@ public class IndicatorsReportService {
StringBuilder rankTwoDesc = new StringBuilder(""); StringBuilder rankTwoDesc = new StringBuilder("");
StringBuilder rankThree = new StringBuilder(""); StringBuilder rankThree = new StringBuilder("");
StringBuilder rankThreeDesc = new StringBuilder(""); StringBuilder rankThreeDesc = new StringBuilder("");
Map<String,Integer> rankMap = new LinkedHashMap<>(); Map<String,Integer> rankMap = new LinkedHashMap<>();
Map<String,String> objDescMap = new HashMap<>(); Map<String,String> objDescMap = new HashMap<>();
for(DriveIndCalResultDef calData : calDatas) { for(DriveIndCalResultDef calData : calDatas) {
...@@ -979,7 +979,7 @@ public class IndicatorsReportService { ...@@ -979,7 +979,7 @@ public class IndicatorsReportService {
indReportData.setRankTwoDesc(rankTwoDesc.toString()); indReportData.setRankTwoDesc(rankTwoDesc.toString());
indReportData.setRankThree(rankThree.toString()); indReportData.setRankThree(rankThree.toString());
indReportData.setRankThreeDesc(rankThreeDesc.toString()); indReportData.setRankThreeDesc(rankThreeDesc.toString());
rankMap.clear(); rankMap.clear();
//排名末三 //排名末三
start = 0; start = 0;
...@@ -992,9 +992,9 @@ public class IndicatorsReportService { ...@@ -992,9 +992,9 @@ public class IndicatorsReportService {
StringBuilder rankLastTwoDesc = new StringBuilder(""); StringBuilder rankLastTwoDesc = new StringBuilder("");
StringBuilder rankLastThree = new StringBuilder(""); StringBuilder rankLastThree = new StringBuilder("");
StringBuilder rankLastThreeDesc = new StringBuilder(""); StringBuilder rankLastThreeDesc = new StringBuilder("");
for(int i=(calDatas.size()-1);i>=0;i--) { for(int i=(calDatas.size()-1);i>=0;i--) {
if("NaN".equals(calDatas.get(i).getValue()) || if("NaN".equals(calDatas.get(i).getValue()) ||
"Infinite".equals(calDatas.get(i).getValue())) { "Infinite".equals(calDatas.get(i).getValue())) {
continue; continue;
} }
...@@ -1037,14 +1037,14 @@ public class IndicatorsReportService { ...@@ -1037,14 +1037,14 @@ public class IndicatorsReportService {
} }
return indReportData; return indReportData;
} }
//同比提升单位数 //同比提升单位数
private Map<String,Object> sameImproveUnits(String compareCatalog,String indId,Integer date, private Map<String,Object> sameImproveUnits(String compareCatalog,String indId,Integer date,
List<String> compareObjs,List<DriveIndCalResultDef> currentCalDatas,String code) { List<String> compareObjs,List<DriveIndCalResultDef> currentCalDatas,String code) {
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
Integer improveNum = 0;//单位提升数 Integer improveNum = 0;//单位提升数
Map<String,Integer> resultRank = new HashMap<>(); Map<String,Integer> resultRank = new HashMap<>();
//根据指标id获取指标详情 //根据指标id获取指标详情
DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(indId); DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(indId);
if(driveIndDef!=null) { if(driveIndDef!=null) {
...@@ -1063,7 +1063,7 @@ public class IndicatorsReportService { ...@@ -1063,7 +1063,7 @@ public class IndicatorsReportService {
for(DriveIndCalResultDef currentCalData : currentCalDatas) { for(DriveIndCalResultDef currentCalData : currentCalDatas) {
for(DriveIndCalResultDef sameCalData : sameCalDatas) { for(DriveIndCalResultDef sameCalData : sameCalDatas) {
if(sameCalData.getCompareObj().equals(currentCalData.getCompareObj()) if(sameCalData.getCompareObj().equals(currentCalData.getCompareObj())
&& !"NaN".equals(sameCalData.getValue()) && !"NaN".equals(sameCalData.getValue())
&& !"Infinite".equals(sameCalData.getValue()) && !"Infinite".equals(sameCalData.getValue())
&& StringUtils.isNotBlank(sameCalData.getValue()) && StringUtils.isNotBlank(sameCalData.getValue())
&& !"NaN".equals(currentCalData.getValue()) && !"NaN".equals(currentCalData.getValue())
...@@ -1071,7 +1071,7 @@ public class IndicatorsReportService { ...@@ -1071,7 +1071,7 @@ public class IndicatorsReportService {
&& StringUtils.isNotBlank(currentCalData.getValue())) { && StringUtils.isNotBlank(currentCalData.getValue())) {
//同比提升单位指本期与同期值相比要好的单位(考虑指标的正反向) //同比提升单位指本期与同期值相比要好的单位(考虑指标的正反向)
rankMap.put(currentCalData.getCompareObj(),CalculateUtils.calGowth( rankMap.put(currentCalData.getCompareObj(),CalculateUtils.calGowth(
currentCalData.getValue(), sameCalData.getValue(), currentCalData.getValue(), sameCalData.getValue(),
driveIndDef.getGrowCalType())); driveIndDef.getGrowCalType()));
//如果是正向指标 //如果是正向指标
if("0".equals(indRule)) { if("0".equals(indRule)) {
...@@ -1101,12 +1101,12 @@ public class IndicatorsReportService { ...@@ -1101,12 +1101,12 @@ public class IndicatorsReportService {
result.put("resultRank", resultRank); result.put("resultRank", resultRank);
return result; return result;
} }
//统计优于平均数量 //统计优于平均数量
private Integer bestAverageUnits(String indRule,String average,List<DriveIndCalResultDef> calDatas) { private Integer bestAverageUnits(String indRule,String average,List<DriveIndCalResultDef> calDatas) {
Integer result = 0; Integer result = 0;
for(DriveIndCalResultDef calData : calDatas) { for(DriveIndCalResultDef calData : calDatas) {
if(StringUtils.isNotBlank(calData.getValue()) && !"NaN".equals(calData.getValue()) if(StringUtils.isNotBlank(calData.getValue()) && !"NaN".equals(calData.getValue())
&& !"Infinite".equals(calData.getValue())) { && !"Infinite".equals(calData.getValue())) {
//如果是正向指标 //如果是正向指标
if("0".equals(indRule)) { if("0".equals(indRule)) {
...@@ -1122,9 +1122,9 @@ public class IndicatorsReportService { ...@@ -1122,9 +1122,9 @@ public class IndicatorsReportService {
} }
return result; return result;
} }
public IndicatorsReportOne fillBaseIndiReportOneData(IndicatorsData indiData, public IndicatorsReportOne fillBaseIndiReportOneData(IndicatorsData indiData,
IndicatorsReportOne indReportData,String code) { IndicatorsReportOne indReportData,String code) {
indReportData.setIndId(indiData.getIndId()); indReportData.setIndId(indiData.getIndId());
//根据基础项id获取基础项信息 //根据基础项id获取基础项信息
BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indiData.getIndId()); BaseIndDef baseIndDef = baseIndDefMapper.selectByPrimaryKey(indiData.getIndId());
...@@ -1140,7 +1140,7 @@ public class IndicatorsReportService { ...@@ -1140,7 +1140,7 @@ public class IndicatorsReportService {
indReportData.setCurrentValue(new BigDecimal(indiData.getValue())); indReportData.setCurrentValue(new BigDecimal(indiData.getValue()));
} }
//查找同期基础项 //查找同期基础项
IndicatorsData sameIndData = baseIndDataService.getSingleIndData(indiData.getIndId(), IndicatorsData sameIndData = baseIndDataService.getSingleIndData(indiData.getIndId(),
(indiData.getDim2()-100), indiData.getDim1(), code); (indiData.getDim2()-100), indiData.getDim1(), code);
if(sameIndData!=null) { if(sameIndData!=null) {
if(StringUtils.isNotBlank(sameIndData.getValue())) { if(StringUtils.isNotBlank(sameIndData.getValue())) {
...@@ -1149,9 +1149,9 @@ public class IndicatorsReportService { ...@@ -1149,9 +1149,9 @@ public class IndicatorsReportService {
} }
return indReportData; return indReportData;
} }
public IndicatorsReportOne fillReportOneData(DriveIndCalResultDef calData, public IndicatorsReportOne fillReportOneData(DriveIndCalResultDef calData,
IndicatorsReportOne indReportData,String code,String compareCatalog) { IndicatorsReportOne indReportData,String code,String compareCatalog) {
indReportData.setIndId(calData.getIndId()); indReportData.setIndId(calData.getIndId());
//根据指标id获取指标信息 //根据指标id获取指标信息
DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(calData.getIndId()); DriveIndDef driveIndDef = driveIndDefMapper.selectByPrimaryKey(calData.getIndId());
...@@ -1170,7 +1170,7 @@ public class IndicatorsReportService { ...@@ -1170,7 +1170,7 @@ public class IndicatorsReportService {
if(StringUtils.isNotBlank(calData.getScore())) { if(StringUtils.isNotBlank(calData.getScore())) {
indReportData.setCurrentScore(new BigDecimal(calData.getScore())); indReportData.setCurrentScore(new BigDecimal(calData.getScore()));
} }
if(StringUtils.isNotBlank(calData.getImproveScore()) if(StringUtils.isNotBlank(calData.getImproveScore())
&& !"No".equals(calData.getImproveScore())) { && !"No".equals(calData.getImproveScore())) {
indReportData.setCurrentImprove(new BigDecimal(calData.getImproveScore())); indReportData.setCurrentImprove(new BigDecimal(calData.getImproveScore()));
} }
...@@ -1194,7 +1194,7 @@ public class IndicatorsReportService { ...@@ -1194,7 +1194,7 @@ public class IndicatorsReportService {
if(driveIndDef!=null && StringUtils.isNotBlank(driveIndDef.getGrowCalType())) { if(driveIndDef!=null && StringUtils.isNotBlank(driveIndDef.getGrowCalType())) {
growCalType = driveIndDef.getGrowCalType(); growCalType = driveIndDef.getGrowCalType();
} }
String calGowth = CalculateUtils.calGowth(calData.getValue(), sameCalData.getValue(), String calGowth = CalculateUtils.calGowth(calData.getValue(), sameCalData.getValue(),
growCalType); growCalType);
if(StringUtils.isNotBlank(calGowth)) { if(StringUtils.isNotBlank(calGowth)) {
indReportData.setValueRate(new BigDecimal(calGowth)); indReportData.setValueRate(new BigDecimal(calGowth));
...@@ -1202,7 +1202,7 @@ public class IndicatorsReportService { ...@@ -1202,7 +1202,7 @@ public class IndicatorsReportService {
} }
return indReportData; return indReportData;
} }
public String getCompareType(Integer date) { public String getCompareType(Integer date) {
if(date!=null) { if(date!=null) {
if(date.toString().length()>6) { if(date.toString().length()>6) {
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
</insert> </insert>
<delete id="deleteByCompareCatalog"> <delete id="deleteByCompareCatalog">
delete from indicators_report_four where compare_catalog=#{compareCatalog} delete from indicators_report_four
where compare_catalog=#{compareCatalog} and compare_date=#{date}
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
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