|
|
@ -321,7 +321,7 @@ public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntit |
|
|
|
Date endDate = LocalDateUtils.localDateToDate(YearMonth.now().minusMonths(NumConstant.ONE).atEndOfMonth()); |
|
|
|
// 根据 考核规则表-外键(公式id),查询绩效考核公式表,待运行公式方法
|
|
|
|
KpiFormulaDTO kpiFormula = kpiFormulaDao.queryFormula(kpiRule.getReferenceId()); |
|
|
|
// 初始化JavaScript引擎
|
|
|
|
// 初始化JavaScriptEngine引擎
|
|
|
|
Invocable invocable = this.initInvocable(kpiFormula.getFormula(), ruleCode); |
|
|
|
// 公式所有参数对应的元数据编码、升序排列
|
|
|
|
List<String> metaDateCodeList = this.getRuleParmOfMetaDateCodeList(kpiRule.getId()); |
|
|
@ -331,24 +331,25 @@ public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntit |
|
|
|
String functionName = kpiFormula.getFunctionName(); |
|
|
|
// 部门类别
|
|
|
|
String[] deptTypeKeyArray = kpiRule.getDeptTypeKey().split(StrConstant.COMMA); |
|
|
|
if (deptTypeKeyArray.length > NumConstant.ZERO) { |
|
|
|
for (String deptTypeKey : deptTypeKeyArray) { |
|
|
|
int pageIndex = NumConstant.ONE; |
|
|
|
List<Long> deptIdList = deptUtils.getDeptIdList(deptTypeKey, NumConstant.TWENTY, pageIndex); |
|
|
|
do { |
|
|
|
for (Long deptId : deptIdList) { |
|
|
|
BigDecimal[] paramValue = selectArrayOfMetaDataValue(deptId, startDate, endDate, metaDateCodeList); |
|
|
|
// 参数准备完全时,执行js运算
|
|
|
|
if (paramValue.length == paramAmount) { |
|
|
|
// 执行js中的函数 参数:js方法名 + 参数
|
|
|
|
Double score = this.calcByJavaScript(invocable, functionName, ruleCode, paramValue); |
|
|
|
this.packageFormulaResultToSaveOrUpdate(deptId, ruleCode, score, startDate, endDate, kpiCycle); |
|
|
|
} |
|
|
|
if (null == deptTypeKeyArray || deptTypeKeyArray.length == NumConstant.ZERO) { |
|
|
|
return; |
|
|
|
} |
|
|
|
for (String deptTypeKey : deptTypeKeyArray) { |
|
|
|
int pageIndex = NumConstant.ONE; |
|
|
|
List<Long> deptIdList = deptUtils.getDeptIdList(deptTypeKey, NumConstant.TWENTY, pageIndex); |
|
|
|
do { |
|
|
|
for (Long deptId : deptIdList) { |
|
|
|
BigDecimal[] paramValue = selectArrayOfMetaDataValue(deptId, startDate, endDate, metaDateCodeList); |
|
|
|
// 参数准备完全时,执行js运算
|
|
|
|
if (paramValue.length == paramAmount) { |
|
|
|
// 执行js中的函数 参数:js方法名 + 参数
|
|
|
|
Double score = this.calcByJavaScript(invocable, functionName, ruleCode, paramValue); |
|
|
|
this.packageFormulaResultToSaveOrUpdate(deptId, ruleCode, score, startDate, endDate, kpiCycle); |
|
|
|
} |
|
|
|
pageIndex++; |
|
|
|
deptIdList = deptUtils.getDeptIdList(deptTypeKey, NumConstant.TWENTY, pageIndex); |
|
|
|
} while (CollUtil.isNotEmpty(deptIdList)); |
|
|
|
} |
|
|
|
} |
|
|
|
pageIndex++; |
|
|
|
deptIdList = deptUtils.getDeptIdList(deptTypeKey, NumConstant.TWENTY, pageIndex); |
|
|
|
} while (CollUtil.isNotEmpty(deptIdList)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|