Commit dc60ded3 by zhangkb

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

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