Commit 65ca902b by zhangkb

修改单位指标分布表数据算法逻辑

parent 95360e1f
...@@ -108,6 +108,9 @@ public class BeforeCompareUnitCalActor extends AbstractActor{ ...@@ -108,6 +108,9 @@ public class BeforeCompareUnitCalActor extends AbstractActor{
//整合考核指标报表数据3 //整合考核指标报表数据3
logger.info("进行date:"+currentDate+" 指标报表3数据整合"); logger.info("进行date:"+currentDate+" 指标报表3数据整合");
//删除历史数据
indicatorsReportService.deleteReportThreeDataByParam(currentDate,
new ArrayList<String>(compareObjMap.keySet()));
for(CompareUnitDef unitDef : currentCompareUnitDef) { for(CompareUnitDef unitDef : currentCompareUnitDef) {
indicatorsReportService.dealDriveIndReportThreeData( indicatorsReportService.dealDriveIndReportThreeData(
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")), unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
......
package com.keymobile.indicators.api.report; package com.keymobile.indicators.api.report;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.keymobile.indicators.model.entity.indicators.CompareUnitDef;
import com.keymobile.indicators.service.report.IndicatorsReportService; import com.keymobile.indicators.service.report.IndicatorsReportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -42,4 +48,29 @@ public class IndicatorReportCtrl { ...@@ -42,4 +48,29 @@ public class IndicatorReportCtrl {
indicatorsReportService.dealDriveIndReportTwoData(compareUnitId, indIds, compareObjs, date); indicatorsReportService.dealDriveIndReportTwoData(compareUnitId, indIds, compareObjs, date);
return "整合考核指标报表数据2开始整合..."; return "整合考核指标报表数据2开始整合...";
} }
@ApiOperation(value = "整合考核指标报表数据3", notes = "整合考核指标报表数据3")
@PostMapping(value = "/dealDriveReportThree")
public String dealDriveReportThree(@RequestBody List<CompareUnitDef> compareUnitList) {
Map<String,String> compareObjMap = new HashMap<>();
Integer date = null;
for(CompareUnitDef unitDef : compareUnitList) {
//用map整合对标机构
List<String> compareObjsList =Arrays
.asList(unitDef.getCompareObjs().split(","));
for(String compareObj : compareObjsList) {
compareObjMap.put(compareObj, compareObj);
}
date = unitDef.getDate();
}
//删除历史数据
indicatorsReportService.deleteReportThreeDataByParam(date,
new ArrayList<String>(compareObjMap.keySet()));
for(CompareUnitDef unitDef : compareUnitList) {
indicatorsReportService.dealDriveIndReportThreeData(
unitDef.getCompareId(), Arrays.asList(unitDef.getIndIds().split(",")),
unitDef.getDate());
}
return "完成考核指标报表数据3整合";
}
} }
package com.keymobile.indicators.model.mapper.report; package com.keymobile.indicators.model.mapper.report;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -17,4 +18,6 @@ public interface ReportThreeMapper extends BaseMapper<IndicatorsReportThree>{ ...@@ -17,4 +18,6 @@ public interface ReportThreeMapper extends BaseMapper<IndicatorsReportThree>{
public void batchSave(@Param("datas")List<IndicatorsReportThree> datas); public void batchSave(@Param("datas")List<IndicatorsReportThree> datas);
public void batchUpdate(@Param("datas")List<IndicatorsReportThree> datas); public void batchUpdate(@Param("datas")List<IndicatorsReportThree> datas);
public void deleteByParam(Map<String,Object> param);
} }
...@@ -122,6 +122,15 @@ public class IndicatorsReportService { ...@@ -122,6 +122,15 @@ public class IndicatorsReportService {
} }
} }
public void deleteReportThreeDataByParam(Integer date,List<String> compareObjs) {
Map<String,Object> paramMap = new HashMap<>();
String type = this.getCompareType(date);
paramMap.put("date", date);
paramMap.put("type", type);
paramMap.put("compareObjs", compareObjs);
reportThreeMapper.deleteByParam(paramMap);
}
public void dealDriveIndReportThreeData(String compareId,List<String> indIds,Integer date) { public void dealDriveIndReportThreeData(String compareId,List<String> indIds,Integer date) {
List<IndicatorsReportThree> dataList = new ArrayList<>(); List<IndicatorsReportThree> dataList = new ArrayList<>();
String type = this.getCompareType(date); String type = this.getCompareType(date);
...@@ -184,8 +193,9 @@ public class IndicatorsReportService { ...@@ -184,8 +193,9 @@ public class IndicatorsReportService {
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("1".equals(growCalType)) {//差比 if(Double.parseDouble(calResult.getValue())-
if(Double.parseDouble(calGowthValue)>0) {//同比提升 Double.parseDouble(sameCalResult.getValue()) > 0) {
if("0".equals(indRule)) {//正向
//填充指标提升个数 //填充指标提升个数
if(indReportData.getIndImproveCount()==null) { if(indReportData.getIndImproveCount()==null) {
indReportData.setIndImproveCount(1); indReportData.setIndImproveCount(1);
...@@ -194,27 +204,16 @@ public class IndicatorsReportService { ...@@ -194,27 +204,16 @@ public class IndicatorsReportService {
indReportData.getIndImproveCount()+1); indReportData.getIndImproveCount()+1);
} }
} }
}else { }
if(Double.parseDouble(calGowthValue)>0) { if(Double.parseDouble(calResult.getValue())-
if("0".equals(indRule)) {//正向 Double.parseDouble(sameCalResult.getValue()) < 0) {
//填充指标提升个数 if("1".equals(indRule)) {//反向
if(indReportData.getIndImproveCount()==null) { //填充指标提升个数
indReportData.setIndImproveCount(1); if(indReportData.getIndImproveCount()==null) {
}else { indReportData.setIndImproveCount(1);
indReportData.setIndImproveCount( }else {
indReportData.getIndImproveCount()+1); indReportData.setIndImproveCount(
} indReportData.getIndImproveCount()+1);
}
}
if(Double.parseDouble(calGowthValue)<0){
if("1".equals(indRule)) {//反向
//填充指标提升个数
if(indReportData.getIndImproveCount()==null) {
indReportData.setIndImproveCount(1);
}else {
indReportData.setIndImproveCount(
indReportData.getIndImproveCount()+1);
}
} }
} }
} }
...@@ -231,24 +230,16 @@ public class IndicatorsReportService { ...@@ -231,24 +230,16 @@ public class IndicatorsReportService {
//算提升前三末三指标个数 //算提升前三末三指标个数
if(!improveValue.isEmpty()) { if(!improveValue.isEmpty()) {
Map<String,Integer> resultRank = new HashMap<>(); Map<String,Integer> resultRank = new HashMap<>();
if("1".equals(growCalType)) {//差比,无论正反向,都有大到小排序 resultRank = CalculateUtils.rankValue(improveValue, indRule);
resultRank = CalculateUtils.rankValue(improveValue, "0");
}else {//差值
resultRank = CalculateUtils.rankValue(improveValue, indRule);
}
//提升前三 //提升前三
dataList = this.fillImproveHeadAndAfterCount(resultRank, dataList, 0); dataList = this.fillImproveHeadAndAfterCount(resultRank, dataList, 0);
if("1".equals(growCalType)) {//差比 if("0".equals(indRule)) {
resultRank = CalculateUtils.rankValue(improveValue, "1"); indRule = "1";
}else {//差值 }else {
if("0".equals(indRule)) { indRule = "0";
indRule = "1";
}else {
indRule = "0";
}
resultRank = CalculateUtils.rankValue(improveValue, indRule);
} }
resultRank = CalculateUtils.rankValue(improveValue, indRule);
//提升末三 //提升末三
dataList = this.fillImproveHeadAndAfterCount(resultRank, dataList, 1); dataList = this.fillImproveHeadAndAfterCount(resultRank, dataList, 1);
} }
...@@ -260,7 +251,6 @@ public class IndicatorsReportService { ...@@ -260,7 +251,6 @@ public class IndicatorsReportService {
private List<IndicatorsReportThree> fillImproveHeadAndAfterCount(Map<String,Integer> resultRank private List<IndicatorsReportThree> fillImproveHeadAndAfterCount(Map<String,Integer> resultRank
,List<IndicatorsReportThree> dataList,Integer type){ ,List<IndicatorsReportThree> dataList,Integer type){
resultRank = CalculateUtils.sortMapByValue(resultRank,0); resultRank = CalculateUtils.sortMapByValue(resultRank,0);
int limitNum = 0;
for(IndicatorsReportThree indReportData : dataList) { for(IndicatorsReportThree indReportData : dataList) {
//判断是否存在 //判断是否存在
IndicatorsReportThree DBIndReportData = reportThreeMapper.getByParam( IndicatorsReportThree DBIndReportData = reportThreeMapper.getByParam(
...@@ -280,52 +270,24 @@ public class IndicatorsReportService { ...@@ -280,52 +270,24 @@ public class IndicatorsReportService {
for(Map.Entry<String, Integer> map : resultRank.entrySet()) { for(Map.Entry<String, Integer> map : resultRank.entrySet()) {
if(map.getValue()==1 || map.getValue()==2 || map.getValue()==3) { if(map.getValue()==1 || map.getValue()==2 || map.getValue()==3) {
if(indReportData.getCompareObj().equals(map.getKey())) { if(indReportData.getCompareObj().equals(map.getKey())) {
if(map.getValue()==1) { if(type==0) {
if(type==0) { //填充提升前三指标个数
//填充提升前三指标个数 if(indReportData.getIndImproveHeadThreeCount()==null) {
if(indReportData.getIndImproveHeadThreeCount()==null) { indReportData.setIndImproveHeadThreeCount(1);
indReportData.setIndImproveHeadThreeCount(1);
}else {
indReportData.setIndImproveHeadThreeCount(
indReportData.getIndImproveHeadThreeCount()+1);
}
limitNum++;
break;
}else { }else {
//填充提升末三指标个数 indReportData.setIndImproveHeadThreeCount(
if(indReportData.getIndImproveAfterThreeCount()==null) { indReportData.getIndImproveHeadThreeCount()+1);
indReportData.setIndImproveAfterThreeCount(1);
}else {
indReportData.setIndImproveAfterThreeCount(
indReportData.getIndImproveAfterThreeCount()+1);
}
limitNum++;
break;
} }
break;
}else { }else {
if(limitNum<3) { //填充提升末三指标个数
if(type==0) { if(indReportData.getIndImproveAfterThreeCount()==null) {
//填充提升前三指标个数 indReportData.setIndImproveAfterThreeCount(1);
if(indReportData.getIndImproveHeadThreeCount()==null) { }else {
indReportData.setIndImproveHeadThreeCount(1); indReportData.setIndImproveAfterThreeCount(
}else { indReportData.getIndImproveAfterThreeCount()+1);
indReportData.setIndImproveHeadThreeCount(
indReportData.getIndImproveHeadThreeCount()+1);
}
limitNum++;
break;
}else {
//填充提升末三指标个数
if(indReportData.getIndImproveAfterThreeCount()==null) {
indReportData.setIndImproveAfterThreeCount(1);
}else {
indReportData.setIndImproveAfterThreeCount(
indReportData.getIndImproveAfterThreeCount()+1);
}
limitNum++;
break;
}
} }
break;
} }
} }
} }
......
...@@ -10,6 +10,18 @@ ...@@ -10,6 +10,18 @@
compare_type = #{type} compare_type = #{type}
</select> </select>
<delete id="deleteByParam" parameterType="map">
delete
from indicators_report_three
where
compare_date = #{date} and
compare_type = #{type} and
compare_obj in
<foreach item="compareObj" collection="compareObjs" open="(" close=")" separator=",">
#{compareObj}
</foreach>
</delete>
<insert id="batchSave" parameterType="java.util.List"> <insert id="batchSave" parameterType="java.util.List">
insert into indicators_report_three( insert into indicators_report_three(
compare_obj, compare_obj_desc, compare_date, compare_type, batter_average_ind_count, compare_obj, compare_obj_desc, compare_date, compare_type, batter_average_ind_count,
......
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