Commit 25eeac76 by zhangkb

修改改善提升评分逻辑

parent 05a0e356
...@@ -113,7 +113,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{ ...@@ -113,7 +113,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
Map<String,String> scoreMap = indScorecardService.calculateIndiScore( Map<String,String> scoreMap = indScorecardService.calculateIndiScore(
driveIndCalResult.getIndId(), driveIndCalResult.getDate(), driveIndCalResult.getIndId(), driveIndCalResult.getDate(),
driveIndCalResult.getCompareObj(), markType, driveIndCalResult.getCompareObj(), markType,
driveIndCalResult.getCompareId()); driveIndCalResult.getCompareId(),compareObjs);
driveIndCalResult.setScore(scoreMap.get("score")); driveIndCalResult.setScore(scoreMap.get("score"));
driveIndCalResult.setImproveScore(scoreMap.get("improveScore")); driveIndCalResult.setImproveScore(scoreMap.get("improveScore"));
driveIndCalResultService.saveOrUpdate(driveIndCalResult); driveIndCalResultService.saveOrUpdate(driveIndCalResult);
......
package com.keymobile.indicators.api.hytobacco; package com.keymobile.indicators.api.hytobacco;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -51,7 +52,8 @@ public class IndScorecardCtrl { ...@@ -51,7 +52,8 @@ public class IndScorecardCtrl {
@PostMapping(value = "/calculateIndiScore") @PostMapping(value = "/calculateIndiScore")
public Map<String,String> calculateIndiScore(@RequestParam String indId,@RequestParam int date, public Map<String,String> calculateIndiScore(@RequestParam String indId,@RequestParam int date,
@RequestParam String compareObj,@RequestParam String indScorecardId, @RequestParam String compareObj,@RequestParam String indScorecardId,
@RequestParam String compareId) { @RequestParam String compareId,@RequestBody List<String> compareObjs) {
return indScorecardService.calculateIndiScore(indId, date, compareObj, indScorecardId,compareId); return indScorecardService.calculateIndiScore(indId, date, compareObj,
indScorecardId,compareId,compareObjs);
} }
} }
...@@ -84,4 +84,11 @@ public class IndicatorsValueCtrl { ...@@ -84,4 +84,11 @@ public class IndicatorsValueCtrl {
@RequestParam String type,@RequestParam(required=false) String compareIds) throws Exception{ @RequestParam String type,@RequestParam(required=false) String compareIds) throws Exception{
indicatorsValueService.fillExcelFileFive(indIds,date,type,compareIds); indicatorsValueService.fillExcelFileFive(indIds,date,type,compareIds);
} }
@ApiOperation(value = "填充excel file6数据", notes = "填充excel file6数据")
@PostMapping(value = "/fillExcelFileSix")
public void fillExcelFileSix(@RequestBody List<String> indIds,
@RequestParam String dateString) throws Exception{
indicatorsValueService.fillExcelFileSix(indIds,dateString);
}
} }
...@@ -12,6 +12,8 @@ public interface DriveIndCalResultRepository extends MongoRepository<DriveIndCal ...@@ -12,6 +12,8 @@ public interface DriveIndCalResultRepository extends MongoRepository<DriveIndCal
public List<DriveIndCalResult> findByIndId(String indId); public List<DriveIndCalResult> findByIndId(String indId);
public List<DriveIndCalResult> findByIndIdAndDateIn(String indId,List<Integer> dates);
public List<DriveIndCalResult> findByIndIdAndCompareObj(String indId,String compareObj); public List<DriveIndCalResult> findByIndIdAndCompareObj(String indId,String compareObj);
public Optional<DriveIndCalResult> findByIndIdAndDateAndCompareObj(String indId,int date,String compareObj); public Optional<DriveIndCalResult> findByIndIdAndDateAndCompareObj(String indId,int date,String compareObj);
......
...@@ -62,7 +62,7 @@ public class IndScorecardService { ...@@ -62,7 +62,7 @@ public class IndScorecardService {
} }
public Map<String,String> calculateIndiScore(String indId,int date,String compareObj, public Map<String,String> calculateIndiScore(String indId,int date,String compareObj,
String indScorecardId,String compareId) { String indScorecardId,String compareId,List<String> compareObjs) {
Map<String,String> result = new HashMap<>(); Map<String,String> result = new HashMap<>();
String indScoreValue = "0.0"; String indScoreValue = "0.0";
String indImproveScoreValue = "0.0"; String indImproveScoreValue = "0.0";
...@@ -163,23 +163,23 @@ public class IndScorecardService { ...@@ -163,23 +163,23 @@ public class IndScorecardService {
} }
} }
} }
//改善提升 }
//同期 }
Optional<DriveIndCalResult> sameCompareObjResult = driveIndResultRepo //改善提升
.findByIndIdAndDateAndCompareObj(indId, (date-100), compareObj); //同期
if(sameCompareObjResult.isPresent()) { Optional<DriveIndCalResult> sameCompareObjResult = driveIndResultRepo
double improveScore = this.calImproveValue(acsType, unit, .findByIndIdAndDateAndCompareObj(indId, (date-100), compareObj);
scoreCard.getImproveScoreItem(), currentCompareObjResult.get(), if(sameCompareObjResult.isPresent()) {
sameCompareObjResult.get()); double improveScore = this.calImproveValue(acsType, unit,
if(scoreCard.getLimitScore()!=0) { scoreCard.getImproveScoreItem(), currentCompareObjResult.get(),
if(improveScore>scoreCard.getLimitScore()) { sameCompareObjResult.get(),compareObjs);
improveScore = scoreCard.getLimitScore(); if(scoreCard.getLimitScore()!=0) {
} if(improveScore>scoreCard.getLimitScore()) {
} improveScore = scoreCard.getLimitScore();
indImproveScoreValue = String.format("%.4f",new BigDecimal(improveScore));
result.put("improveScore",indImproveScoreValue);
} }
} }
indImproveScoreValue = String.format("%.4f",new BigDecimal(improveScore));
result.put("improveScore",indImproveScoreValue);
} }
} }
}else { }else {
...@@ -194,12 +194,31 @@ public class IndScorecardService { ...@@ -194,12 +194,31 @@ public class IndScorecardService {
} }
private double calImproveValue(String acsType,String unit,List<ImproveScoreDef> importScoreDefList, private double calImproveValue(String acsType,String unit,List<ImproveScoreDef> importScoreDefList,
DriveIndCalResult current,DriveIndCalResult same) { DriveIndCalResult current,DriveIndCalResult same,List<String> compareObjs) {
double sumValue = 0; double sumValue = 0;
for(ImproveScoreDef scoreDef : importScoreDefList) { for(ImproveScoreDef scoreDef : importScoreDefList) {
// 0:同期排位比 1:单位同期比 // 0:同期排位比 1:单位同期比
if("0".equals(scoreDef.getGradeType())) { if("0".equals(scoreDef.getGradeType())) {
int rankDiff = same.getRank()-current.getRank(); int rankDiff = 0;
if(compareObjs.isEmpty()) {
rankDiff = same.getRank()-current.getRank();
}else {
//考虑同期分组有变的情况,把组内成原同期的指标值拿出来再进行排名
Map<String,String> values = new HashMap<>();
for(String compareObj : compareObjs) {
Optional<DriveIndCalResult> sameCompareObjResult = driveIndResultRepo
.findByIndIdAndDateAndCompareObj(current.getIndId(),
(current.getDate()-100), compareObj);
if(sameCompareObjResult.isPresent()) {
values.put(compareObj, sameCompareObjResult.get().getValue());
}else {
values.put(compareObj, "0");
}
}
//排名
Map<String,Integer> rankValue = CalculateUtils.rankValue(values, acsType);
rankDiff = rankValue.get(current.getCompareObj())-current.getRank();
}
//加减分操作 0:加分 1:减分 //加减分操作 0:加分 1:减分
if("0".equals(scoreDef.getGradeOp())) { if("0".equals(scoreDef.getGradeOp())) {
if(rankDiff>0) { if(rankDiff>0) {
......
...@@ -255,6 +255,56 @@ public class IndicatorsValueService { ...@@ -255,6 +255,56 @@ public class IndicatorsValueService {
logger.info("填充完成"); logger.info("填充完成");
} }
//填充2020第一季度县数据
public void fillExcelFileSix(List<String> indIds,String dateString) throws Exception{
FileInputStream fs=new FileInputStream("D://indicatorsFile/file6.xlsx");
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(fs);
XSSFSheet excelSheet = xssfWorkbook.getSheet("Sheet1");
Map<String,Integer> cellMap = new HashMap<>();
cellMap.put("FC001", 2);cellMap.put("FC002", 4);cellMap.put("FC003", 6);cellMap.put("FC004", 8);
cellMap.put("FC005", 10);cellMap.put("FC0011", 12);cellMap.put("FC0012", 14);cellMap.put("FC0020", 16);
Map<String,Integer> rowMap = new HashMap<>();
//获取行值
for(int i=1;i<91;i++) {
XSSFRow row = excelSheet.getRow(i);
String value = row.getCell(1)==null?
"":row.getCell(1).getStringCellValue();
if(StringUtils.isNotBlank(value)) {
rowMap.put(value, i);
}
}
String[] dates = dateString.split(";");
List<Integer> dateList = new ArrayList<>();
for(String date : dates) {
dateList.add(Integer.valueOf(date));
}
//根据考核指标id获取本期和同期的指标值
for(String indId : indIds) {
List<DriveIndCalResult> driveResult = driveIndResultRepo.findByIndIdAndDateIn(indId, dateList);
for(DriveIndCalResult result : driveResult) {
String region = result.getCompareObj();
if(rowMap.get(region)!=null) {
XSSFRow row = excelSheet.getRow(rowMap.get(region));
if(result.getDate()==dateList.get(0)) {
row.getCell(cellMap.get(indId)).setCellValue(result.getValue());
}else {
row.getCell((cellMap.get(indId)+1)).setCellValue(result.getValue());
}
}else {
logger.info("找不到 "+region+" 对应的列");
}
}
}
FileOutputStream out=new FileOutputStream("D://indicatorsFile/file6.xlsx");
out.flush();
xssfWorkbook.write(out);
out.close();
fs.close();
logger.info("填充完成");
}
//填充县考核指标值 //填充县考核指标值
public void fillExcelFileTwo(List<String> indIds) throws Exception{ public void fillExcelFileTwo(List<String> indIds) throws Exception{
FileInputStream fs=new FileInputStream("D://indicatorsFile/file2.xlsx"); FileInputStream fs=new FileInputStream("D://indicatorsFile/file2.xlsx");
...@@ -507,9 +557,9 @@ public class IndicatorsValueService { ...@@ -507,9 +557,9 @@ public class IndicatorsValueService {
indMappingIndId.put("零售客户进货规格数之和(个)", "F006");indMappingIndId.put("零售客户总数(个)", "F008"); indMappingIndId.put("零售客户进货规格数之和(个)", "F006");indMappingIndId.put("零售客户总数(个)", "F008");
indMappingIndId.put("卷烟销售单箱均价(万元)", "F0010");indMappingIndId.put("卷烟营销费用(万元)", "F0016"); indMappingIndId.put("卷烟销售单箱均价(万元)", "F0010");indMappingIndId.put("卷烟营销费用(万元)", "F0016");
indMappingIndId.put("卷烟管理费用(万元)", "F0018");indMappingIndId.put("查获烟叶量(千克)", "F0032"); indMappingIndId.put("卷烟管理费用(万元)", "F0018");indMappingIndId.put("查获烟叶量(千克)", "F0032");
indMappingIndId.put("查获烟丝量(千克)", "F0034");indMappingIndId.put("查获真烟量(万支)", "F0040"); indMappingIndId.put("查获烟丝量(千克)", "F0034");indMappingIndId.put("查获假私烟量(万支)", "F0036");
indMappingIndId.put("查获未当案件卷烟量(万支)", "F0058");indMappingIndId.put("专卖线在岗人员数(人)", "F0038"); indMappingIndId.put("查获真烟量(万支)", "F0040");indMappingIndId.put("查获未当案件卷烟量(万支)", "F0058");
indMappingIndId.put("营销线在岗人员数(人)", "F0014"); indMappingIndId.put("专卖线在岗人员数(人)", "F0038");indMappingIndId.put("营销线在岗人员数(人)", "F0014");
String regex = "\\((.*?))"; String regex = "\\((.*?))";
Pattern pattern = Pattern.compile(regex); Pattern pattern = Pattern.compile(regex);
...@@ -575,6 +625,8 @@ public class IndicatorsValueService { ...@@ -575,6 +625,8 @@ public class IndicatorsValueService {
} }
} }
} }
this.addIndicatorData(datas);
logger.info("导入完成");
} }
public void importIndicatorsData(XSSFWorkbook xssfWorkbook) throws Exception{ public void importIndicatorsData(XSSFWorkbook xssfWorkbook) throws Exception{
......
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