Commit dc60ded3 by zhangkb

修改计算考核指标增幅逻辑代码

parent 7bfa8031
...@@ -29,6 +29,7 @@ public class DriveIndDef { ...@@ -29,6 +29,7 @@ public class DriveIndDef {
private String indCalScoreRuleDesc;//计分规则描述 private String indCalScoreRuleDesc;//计分规则描述
private String isUnitCalScore;//是否参与单位得分计算 是:1 否:0 private String isUnitCalScore;//是否参与单位得分计算 是:1 否:0
private String indFrequency;//指标频度 0:月度给数 1:季度给数 2:年度给数 private String indFrequency;//指标频度 0:月度给数 1:季度给数 2:年度给数
private String growCalType;//增幅计算类型 0:本期-同期 1:(本期-同期)/同期*100
private String version;//版本号 private String version;//版本号
private Integer catalogId;//挂靠目录id private Integer catalogId;//挂靠目录id
private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标 private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
......
...@@ -194,8 +194,9 @@ public class IndicatorsValueService { ...@@ -194,8 +194,9 @@ public class IndicatorsValueService {
dataMap.put("currentValue",driveIndCalResult.getValue()); dataMap.put("currentValue",driveIndCalResult.getValue());
dataMap.put("currentRank", String.valueOf(driveIndCalResult.getRank())); dataMap.put("currentRank", String.valueOf(driveIndCalResult.getRank()));
dataMap.put("sameValue", sameDriveIndCalResult.getValue()); dataMap.put("sameValue", sameDriveIndCalResult.getValue());
String calGowth = CalculateUtils.calGowth(deiveIndDef.getIndUnit(), String calGowth = CalculateUtils.calGowth(
driveIndCalResult.getValue(), sameDriveIndCalResult.getValue(), "1"); driveIndCalResult.getValue(), sameDriveIndCalResult.getValue(),
deiveIndDef.getGrowCalType());
dataMap.put("calGowth", calGowth); dataMap.put("calGowth", calGowth);
gowthMap.put(compareObj, calGowth); gowthMap.put(compareObj, calGowth);
...@@ -412,7 +413,8 @@ public class IndicatorsValueService { ...@@ -412,7 +413,8 @@ public class IndicatorsValueService {
} }
//根据指标id获取指标信息 //根据指标id获取指标信息
DriveIndDef driveIndDef = driveIndDefService.getById(indId); DriveIndDef driveIndDef = driveIndDefService.getById(indId);
rate = CalculateUtils.calGowth(driveIndDef.getIndUnit(),currentValue, sameValue,"0"); rate = CalculateUtils.calGowth(currentValue,
sameValue,driveIndDef.getGrowCalType());
XSSFRow row = excelSheet.getRow(rowMap.get(indId)); XSSFRow row = excelSheet.getRow(rowMap.get(indId));
row.getCell(3).setCellValue(currentValue); row.getCell(3).setCellValue(currentValue);
...@@ -523,37 +525,41 @@ public class IndicatorsValueService { ...@@ -523,37 +525,41 @@ public class IndicatorsValueService {
} }
//根据考核指标id获取本期和同期的指标值 //根据考核指标id获取本期和同期的指标值
for(String indId : indIds) { for(String indId : indIds) {
List<DriveIndCalResultDef> driveResult = driveIndCalResultDefMapper.findByIndId(indId); DriveIndDef deiveIndDef = driveIndDefService.getById(indId);
for(DriveIndCalResultDef result : driveResult) { if(deiveIndDef!=null) {
String region = result.getCompareObj(); List<DriveIndCalResultDef> driveResult = driveIndCalResultDefMapper.findByIndId(indId);
if(rowMap.get(region)!=null) { for(DriveIndCalResultDef result : driveResult) {
XSSFRow row = excelSheet.getRow(rowMap.get(region)); String region = result.getCompareObj();
if(result.getDate()==201912) { if(rowMap.get(region)!=null) {
row.getCell(cellMap.get(indId)).setCellValue(result.getValue()); XSSFRow row = excelSheet.getRow(rowMap.get(region));
if(result.getDate()==201912) {
row.getCell(cellMap.get(indId)).setCellValue(result.getValue());
}else {
row.getCell((cellMap.get(indId)+1)).setCellValue(result.getValue());
}
}else { }else {
row.getCell((cellMap.get(indId)+1)).setCellValue(result.getValue()); logger.info("找不到 "+region+" 对应的列");
} }
}else {
logger.info("找不到 "+region+" 对应的列"); //算一次
} if(result.getDate()==201912) {
String currentValue = "";
//算一次 String sameValue = "";
if(result.getDate()==201912) { //算增幅
String currentValue = ""; List<DriveIndCalResultDef> gowthValues = driveIndCalResultDefMapper
String sameValue = ""; .findByIndIdAndCompareObj(indId, region);
//算增幅 for(DriveIndCalResultDef gowth : gowthValues) {
List<DriveIndCalResultDef> gowthValues = driveIndCalResultDefMapper if(gowth.getDate()==201912) {
.findByIndIdAndCompareObj(indId, region); currentValue = gowth.getValue();
for(DriveIndCalResultDef gowth : gowthValues) { }else {
if(gowth.getDate()==201912) { sameValue = gowth.getValue();
currentValue = gowth.getValue(); }
}else {
sameValue = gowth.getValue();
} }
XSSFRow row = excelSheet.getRow(rowMap.get(region));
row.getCell((cellMap.get(indId)+2)).setCellValue(
CalculateUtils.calGowth(
currentValue, sameValue,deiveIndDef.getGrowCalType()));
} }
XSSFRow row = excelSheet.getRow(rowMap.get(region));
row.getCell((cellMap.get(indId)+2)).setCellValue(
CalculateUtils.calGowth(gowthValues.get(0).getUnit(), currentValue, sameValue,null));
} }
} }
} }
......
package com.keymobile.indicators.utils; package com.keymobile.indicators.utils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -18,19 +17,15 @@ import com.googlecode.aviator.AviatorEvaluator; ...@@ -18,19 +17,15 @@ import com.googlecode.aviator.AviatorEvaluator;
public class CalculateUtils { public class CalculateUtils {
private static Logger logger = LoggerFactory.getLogger(CalculateUtils.class); private static Logger logger = LoggerFactory.getLogger(CalculateUtils.class);
public static String calGowth(String unit,String currentValue,String sameValue,String type) { //type:0 : 本期-同期 1:(本期-同期)/同期
public static String calGowth(String currentValue,String sameValue,String type) {
String gowthValue = ""; String gowthValue = "";
StringBuilder formula = new StringBuilder(); StringBuilder formula = new StringBuilder();
if(!"NaN".equals(currentValue) && !"Infinite".equals(currentValue) if(!"NaN".equals(currentValue) && !"Infinite".equals(currentValue)
&& !"NaN".equals(sameValue) && !"Infinite".equals(sameValue)) { && !"NaN".equals(sameValue) && !"Infinite".equals(sameValue)) {
Object value = null; Object value = null;
if("0".equals(type)) { if("0".equals(type)) {
if("%".equals(unit)) { formula.append(currentValue).append("-").append(sameValue);
formula.append(currentValue).append("-").append(sameValue);
}else {
formula.append("(").append(currentValue).append("-").append(sameValue).append(")")
.append("/").append(sameValue).append("*100");
}
}else { }else {
formula.append("(").append(currentValue).append("-").append(sameValue).append(")") formula.append("(").append(currentValue).append("-").append(sameValue).append(")")
.append("/").append(sameValue).append("*100"); .append("/").append(sameValue).append("*100");
......
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