|
@ -33,6 +33,7 @@ import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
import com.elink.esua.epdc.constant.KpiFieldConstant; |
|
|
import com.elink.esua.epdc.constant.KpiFieldConstant; |
|
|
import com.elink.esua.epdc.dao.*; |
|
|
import com.elink.esua.epdc.dao.*; |
|
|
import com.elink.esua.epdc.dto.*; |
|
|
import com.elink.esua.epdc.dto.*; |
|
|
|
|
|
import com.elink.esua.epdc.dto.form.KpiMetaDataOfEventsFormDTO; |
|
|
import com.elink.esua.epdc.dto.form.KpiRuleSaveOrUpdateFormDTO; |
|
|
import com.elink.esua.epdc.dto.form.KpiRuleSaveOrUpdateFormDTO; |
|
|
import com.elink.esua.epdc.dto.result.KpiRuleQueryResultDTO; |
|
|
import com.elink.esua.epdc.dto.result.KpiRuleQueryResultDTO; |
|
|
import com.elink.esua.epdc.entity.*; |
|
|
import com.elink.esua.epdc.entity.*; |
|
@ -41,6 +42,7 @@ import com.elink.esua.epdc.enums.KpiRuleModeEnum; |
|
|
import com.elink.esua.epdc.service.KpiRuleService; |
|
|
import com.elink.esua.epdc.service.KpiRuleService; |
|
|
import com.elink.esua.epdc.utils.DeptUtils; |
|
|
import com.elink.esua.epdc.utils.DeptUtils; |
|
|
import com.google.common.collect.Lists; |
|
|
import com.google.common.collect.Lists; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
@ -53,6 +55,7 @@ import javax.script.ScriptEngine; |
|
|
import javax.script.ScriptEngineManager; |
|
|
import javax.script.ScriptEngineManager; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.time.YearMonth; |
|
|
import java.time.YearMonth; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
@ -62,6 +65,7 @@ import java.util.*; |
|
|
* @author qu qu@elink-cn.com |
|
|
* @author qu qu@elink-cn.com |
|
|
* @since v1.0.0 2019-11-27 |
|
|
* @since v1.0.0 2019-11-27 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntity> implements KpiRuleService { |
|
|
public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntity> implements KpiRuleService { |
|
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
@ -306,69 +310,64 @@ public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntit |
|
|
* @Date: 2019-12-19 |
|
|
* @Date: 2019-12-19 |
|
|
*/ |
|
|
*/ |
|
|
public Result calcWorkScoreByRuleCode(String ruleCode){ |
|
|
public Result calcWorkScoreByRuleCode(String ruleCode){ |
|
|
// 每次JOB启动时,根据当前时间,获取上一个月的:月初-月末时间
|
|
|
|
|
|
YearMonth now = YearMonth.now(); |
|
|
|
|
|
Date startDate = LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ONE).atDay(NumConstant.ONE)); |
|
|
|
|
|
Date endDate = LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ONE).atEndOfMonth()); |
|
|
|
|
|
|
|
|
|
|
|
// 查询考核规则表
|
|
|
// 查询考核规则表
|
|
|
KpiRuleDTO kpiRuleDTO = kpiRuleDao.queryKpiRuleMetaFormula(ruleCode); |
|
|
KpiRuleDTO kpiRuleDTO = kpiRuleDao.queryKpiRuleMetaFormula(ruleCode); |
|
|
// 根据 考核规则表-外键(公式id),查询绩效考核公式表,待运行公式方法
|
|
|
//每次JOB启动时,根据当前时间,获取时间范围
|
|
|
KpiFormulaDTO kpiFormulaDTO = kpiFormulaDao.queryFormula(kpiRuleDTO.getReferenceId()); |
|
|
Map<String, Date> mapDate = this.initKpiParam(kpiRuleDTO.getKpiCycle(), "calcWorkScoreByRuleCode"); |
|
|
// 根据 考核规则表-主键,查询公式参数表,排序:1,2,3,4,5
|
|
|
if (mapDate != null){ |
|
|
List<KpiRuleParamDTO> ruleParamList = kpiRuleParamDao.queryFormulaParam(kpiRuleDTO.getId()); |
|
|
// 根据 考核规则表-外键(公式id),查询绩效考核公式表,待运行公式方法
|
|
|
List<String> metaDateCodeList = Lists.newArrayList(); |
|
|
KpiFormulaDTO kpiFormulaDTO = kpiFormulaDao.queryFormula(kpiRuleDTO.getReferenceId()); |
|
|
for (int i = 0; i < ruleParamList.size(); i++) { |
|
|
// 根据 考核规则表-主键,查询公式参数表,排序:1,2,3,4,5
|
|
|
metaDateCodeList.add(ruleParamList.get(i).getMetaDataCode()); |
|
|
List<KpiRuleParamDTO> ruleParamList = kpiRuleParamDao.queryFormulaParam(kpiRuleDTO.getId()); |
|
|
} |
|
|
List<String> metaDateCodeList = Lists.newArrayList(); |
|
|
|
|
|
for (int i = 0; i < ruleParamList.size(); i++) { |
|
|
int pageSize = NumConstant.THIRTY; |
|
|
metaDateCodeList.add(ruleParamList.get(i).getMetaDataCode()); |
|
|
int pageIndex = NumConstant.ONE; |
|
|
} |
|
|
|
|
|
|
|
|
List<Long> deptIdList = deptUtils.getDeptIdList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
|
|
|
do { |
|
|
|
|
|
|
|
|
|
|
|
for (Long deptId : deptIdList) { |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal[] paramValue = selectArrayOfMetaDate(deptId, startDate, endDate, metaDateCodeList); |
|
|
|
|
|
|
|
|
|
|
|
//参数准备完全时,执行js运算
|
|
|
int pageSize = NumConstant.THIRTY; |
|
|
if (paramValue.length == kpiFormulaDTO.getParamAmount()) { |
|
|
int pageIndex = NumConstant.ONE; |
|
|
BigDecimal workScore; |
|
|
List<Long> deptIdList = deptUtils.getDeptIdList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
try { |
|
|
do { |
|
|
//获得一个javascipt的执行引擎
|
|
|
|
|
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); |
|
|
for (Long deptId : deptIdList) { |
|
|
//执行js代码:参数为:公式运行方法
|
|
|
|
|
|
engine.eval(kpiFormulaDTO.getFormula()); |
|
|
BigDecimal[] paramValue = selectArrayOfMetaDate(deptId, mapDate.get("startDate"), mapDate.get("endDate"), metaDateCodeList); |
|
|
//是否可调用方法
|
|
|
//参数准备完全时,执行js运算
|
|
|
boolean flag = engine instanceof Invocable; |
|
|
if (paramValue.length == kpiFormulaDTO.getParamAmount()) { |
|
|
if (!flag) { |
|
|
BigDecimal workScore; |
|
|
return new Result().error("运行方法异常"); |
|
|
try { |
|
|
|
|
|
//获得一个javascipt的执行引擎
|
|
|
|
|
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); |
|
|
|
|
|
//执行js代码:参数为:公式运行方法
|
|
|
|
|
|
engine.eval(kpiFormulaDTO.getFormula()); |
|
|
|
|
|
//是否可调用方法
|
|
|
|
|
|
boolean flag = engine instanceof Invocable; |
|
|
|
|
|
if (!flag) { |
|
|
|
|
|
return new Result().error("运行方法异常"); |
|
|
|
|
|
} |
|
|
|
|
|
Invocable in = (Invocable) engine; |
|
|
|
|
|
//执行js中的函数 参数:js方法名 + 参数
|
|
|
|
|
|
Double result = (Double) in.invokeFunction(kpiFormulaDTO.getFunctionName(), paramValue); |
|
|
|
|
|
Double workScoreDoouble = (double) Math.round(result * 100) / 100; |
|
|
|
|
|
workScore = new BigDecimal(workScoreDoouble); |
|
|
|
|
|
// 网格考核最终得分 表操作
|
|
|
|
|
|
KpiResultGridEntity kpiManualScoreEntity = new KpiResultGridEntity(); |
|
|
|
|
|
kpiManualScoreEntity.setWorkScore(workScore); |
|
|
|
|
|
kpiManualScoreEntity.setGridId(deptId); |
|
|
|
|
|
kpiManualScoreEntity.setStartDate(mapDate.get("startDate")); |
|
|
|
|
|
kpiManualScoreEntity.setEndDate(mapDate.get("endDate")); |
|
|
|
|
|
kpiManualScoreEntity.setKpiCycle(kpiRuleDTO.getKpiCycle()); |
|
|
|
|
|
this.saveOrUpdateKpiResult(kpiManualScoreEntity); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return new Result().error("运行方法异常" + e.getMessage()); |
|
|
} |
|
|
} |
|
|
Invocable in = (Invocable) engine; |
|
|
|
|
|
//执行js中的函数 参数:js方法名 + 参数
|
|
|
|
|
|
Double result = (Double) in.invokeFunction(kpiFormulaDTO.getFunctionName(), paramValue); |
|
|
|
|
|
Double workScoreDoouble = (double) Math.round(result * 100) / 100; |
|
|
|
|
|
workScore = new BigDecimal(workScoreDoouble); |
|
|
|
|
|
// 网格考核最终得分 表操作
|
|
|
|
|
|
KpiResultGridEntity kpiManualScoreEntity = new KpiResultGridEntity(); |
|
|
|
|
|
kpiManualScoreEntity.setWorkScore(workScore); |
|
|
|
|
|
kpiManualScoreEntity.setGridId(deptId); |
|
|
|
|
|
kpiManualScoreEntity.setStartDate(startDate); |
|
|
|
|
|
kpiManualScoreEntity.setEndDate(endDate); |
|
|
|
|
|
kpiManualScoreEntity.setKpiCycle(kpiRuleDTO.getKpiCycle()); |
|
|
|
|
|
this.saveOrUpdateKpiResult(kpiManualScoreEntity); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return new Result().error("运行方法异常" + e.getMessage()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
pageIndex++; |
|
|
|
|
|
deptIdList = deptUtils.getDeptIdList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
pageIndex++; |
|
|
} while (CollUtil.isNotEmpty(deptIdList)); |
|
|
deptIdList = deptUtils.getDeptIdList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
} |
|
|
} while (CollUtil.isNotEmpty(deptIdList)); |
|
|
|
|
|
|
|
|
|
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -386,48 +385,41 @@ public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntit |
|
|
// 根据 考核规则表-外键(公式id),查询绩效考核公式表,待运行公式方法
|
|
|
// 根据 考核规则表-外键(公式id),查询绩效考核公式表,待运行公式方法
|
|
|
KpiFormulaDTO kpiFormulaDTO = kpiFormulaDao.queryFormula(kpiRuleDTO.getReferenceId()); |
|
|
KpiFormulaDTO kpiFormulaDTO = kpiFormulaDao.queryFormula(kpiRuleDTO.getReferenceId()); |
|
|
|
|
|
|
|
|
YearMonth now = YearMonth.now();//2019/12
|
|
|
|
|
|
Date endDate = LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ONE).atEndOfMonth()); |
|
|
|
|
|
// 考核周期
|
|
|
// 考核周期
|
|
|
String kpiCycle = kpiRuleDTO.getKpiCycle(); |
|
|
String kpiCycle = kpiRuleDTO.getKpiCycle(); |
|
|
// 考核结束日
|
|
|
//每次JOB启动时,根据当前时间,获取时间范围
|
|
|
kpiResultGridEntity.setEndDate(endDate); |
|
|
Map<String, Date> mapDate = this.initKpiParam(kpiCycle, "calcBaseGridFinalScoreByRuleCode"); |
|
|
// 考核开始日
|
|
|
if (mapDate != null) { |
|
|
if (kpiCycle.equals(KpiCycleEnum.KPI_CYCLE_MONTH.getValue())) { |
|
|
kpiResultGridEntity.setEndDate(mapDate.get("endDate")); |
|
|
kpiResultGridEntity.setStartDate(LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ONE).atDay(NumConstant.ONE))); |
|
|
kpiResultGridEntity.setStartDate(mapDate.get("startDate")); |
|
|
} else if (kpiCycle.equals(KpiCycleEnum.KPI_CYCLE_QUARTER.getValue())) { |
|
|
//查询网格最终得分:所有网格
|
|
|
kpiResultGridEntity.setStartDate(LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.THREE).atDay(NumConstant.ONE))); |
|
|
List<KpiResultGridEntity> resultGrid = kpiResultGridDao.selectKpiResultGrid(kpiResultGridEntity); |
|
|
} else if (kpiCycle.equals(KpiCycleEnum.KPI_CYCLE_YEAR.getValue())) { |
|
|
for (KpiResultGridEntity kpi : resultGrid){ |
|
|
kpiResultGridEntity.setStartDate(LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ELEVEN).atDay(NumConstant.ONE))); |
|
|
BigDecimal finalScore; |
|
|
} |
|
|
try { |
|
|
|
|
|
//获得一个javascipt的执行引擎
|
|
|
//查询网格最终得分:所有网格
|
|
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); |
|
|
List<KpiResultGridEntity> resultGrid = kpiResultGridDao.selectKpiResultGrid(kpiResultGridEntity); |
|
|
//执行js代码:参数为:公式运行方法
|
|
|
for (KpiResultGridEntity kpi : resultGrid){ |
|
|
engine.eval(kpiFormulaDTO.getFormula()); |
|
|
BigDecimal finalScore; |
|
|
//是否可调用方法
|
|
|
try { |
|
|
boolean flag = engine instanceof Invocable; |
|
|
//获得一个javascipt的执行引擎
|
|
|
if (!flag) { |
|
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); |
|
|
return new Result().error("运行方法异常"); |
|
|
//执行js代码:参数为:公式运行方法
|
|
|
} |
|
|
engine.eval(kpiFormulaDTO.getFormula()); |
|
|
Invocable in = (Invocable) engine; |
|
|
//是否可调用方法
|
|
|
//执行js中的函数 参数:js方法名 + 参数
|
|
|
boolean flag = engine instanceof Invocable; |
|
|
Double result = (Double) in.invokeFunction(kpiFormulaDTO.getFunctionName(), kpi.getManualScore(),kpi.getWorkScore()); |
|
|
if (!flag) { |
|
|
Double finalScoreDoouble = (double) Math.round(result * 100) / 100; |
|
|
return new Result().error("运行方法异常"); |
|
|
finalScore = new BigDecimal(finalScoreDoouble); |
|
|
|
|
|
// 网格考核最终得分 表操作
|
|
|
|
|
|
KpiResultGridEntity kpiManualScore = new KpiResultGridEntity(); |
|
|
|
|
|
kpiManualScore.setFinalScore(finalScore); |
|
|
|
|
|
kpiManualScore.setId(kpi.getId()); |
|
|
|
|
|
kpiResultGridDao.updateById(kpiManualScore); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return new Result().error("运行方法异常" + e.getMessage()); |
|
|
} |
|
|
} |
|
|
Invocable in = (Invocable) engine; |
|
|
|
|
|
//执行js中的函数 参数:js方法名 + 参数
|
|
|
|
|
|
Double result = (Double) in.invokeFunction(kpiFormulaDTO.getFunctionName(), kpi.getManualScore(),kpi.getWorkScore()); |
|
|
|
|
|
Double finalScoreDoouble = (double) Math.round(result * 100) / 100; |
|
|
|
|
|
finalScore = new BigDecimal(finalScoreDoouble); |
|
|
|
|
|
// 网格考核最终得分 表操作
|
|
|
|
|
|
KpiResultGridEntity kpiManualScore = new KpiResultGridEntity(); |
|
|
|
|
|
kpiManualScore.setFinalScore(finalScore); |
|
|
|
|
|
kpiManualScore.setId(kpi.getId()); |
|
|
|
|
|
kpiResultGridDao.updateById(kpiManualScore); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
return new Result().error("运行方法异常" + e.getMessage()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return new Result(); |
|
|
return new Result(); |
|
@ -511,37 +503,31 @@ public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntit |
|
|
KpiResultSuperiorEntity kpiResultSuperiorEntity = new KpiResultSuperiorEntity(); |
|
|
KpiResultSuperiorEntity kpiResultSuperiorEntity = new KpiResultSuperiorEntity(); |
|
|
KpiRuleDTO kpiRuleDTO = kpiRuleDao.queryKpiRuleMetaFormula(ruleCode);// 查询考核规则表
|
|
|
KpiRuleDTO kpiRuleDTO = kpiRuleDao.queryKpiRuleMetaFormula(ruleCode);// 查询考核规则表
|
|
|
|
|
|
|
|
|
YearMonth now = YearMonth.now(); |
|
|
|
|
|
Date endDate = LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ONE).atEndOfMonth()); |
|
|
|
|
|
// 考核周期
|
|
|
// 考核周期
|
|
|
String kpiCycle = kpiRuleDTO.getKpiCycle(); |
|
|
String kpiCycle = kpiRuleDTO.getKpiCycle(); |
|
|
// 考核结束日
|
|
|
//每次JOB启动时,根据当前时间,获取时间范围
|
|
|
kpiResultSuperiorEntity.setEndDate(endDate); |
|
|
Map<String, Date> mapDate = this.initKpiParam(kpiCycle, "calcDistrictStreetGeneralRule"); |
|
|
// 考核开始日
|
|
|
if (mapDate != null) { |
|
|
if (kpiCycle.equals(KpiCycleEnum.KPI_CYCLE_MONTH.getValue())) { |
|
|
kpiResultSuperiorEntity.setEndDate(mapDate.get("endDate")); |
|
|
kpiResultSuperiorEntity.setStartDate(LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ONE).atDay(NumConstant.ONE))); |
|
|
kpiResultSuperiorEntity.setStartDate(mapDate.get("startDate")); |
|
|
} else if (kpiCycle.equals(KpiCycleEnum.KPI_CYCLE_QUARTER.getValue())) { |
|
|
kpiResultSuperiorEntity.setKpiCycle(kpiCycle); |
|
|
kpiResultSuperiorEntity.setStartDate(LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.THREE).atDay(NumConstant.ONE))); |
|
|
|
|
|
} else if (kpiCycle.equals(KpiCycleEnum.KPI_CYCLE_YEAR.getValue())) { |
|
|
// 根据 考核规则表-主键,查询公式参数表,排序:1,2,3,4,5,6
|
|
|
kpiResultSuperiorEntity.setStartDate(LocalDateUtils.localDateToDate(now.minusMonths(NumConstant.ELEVEN).atDay(NumConstant.ONE))); |
|
|
List<KpiRuleParamDTO> ruleParamList = kpiRuleParamDao.queryFormulaParam(kpiRuleDTO.getId()); |
|
|
} |
|
|
List<String> metaDateCodeList = Lists.newArrayList(); |
|
|
kpiResultSuperiorEntity.setKpiCycle(kpiCycle); |
|
|
for (int i = 0; i < ruleParamList.size(); i++) { |
|
|
|
|
|
metaDateCodeList.add(ruleParamList.get(i).getMetaDataCode()); |
|
|
// 根据 考核规则表-主键,查询公式参数表,排序:1,2,3,4,5,6
|
|
|
} |
|
|
List<KpiRuleParamDTO> ruleParamList = kpiRuleParamDao.queryFormulaParam(kpiRuleDTO.getId()); |
|
|
//区 考核最终得分计算
|
|
|
List<String> metaDateCodeList = Lists.newArrayList(); |
|
|
this.assessmentScoreCalculation(kpiRuleDTO.getReferenceId(), |
|
|
for (int i = 0; i < ruleParamList.size(); i++) { |
|
|
kpiResultSuperiorEntity.getStartDate(),kpiResultSuperiorEntity.getEndDate(), |
|
|
metaDateCodeList.add(ruleParamList.get(i).getMetaDataCode()); |
|
|
metaDateCodeList,OrganizationTypeConstant.ORG_TYPE_DISTRICT_DEPT,kpiCycle); |
|
|
|
|
|
|
|
|
|
|
|
//街区 考核最终得分计算
|
|
|
|
|
|
this.assessmentScoreCalculation(kpiRuleDTO.getReferenceId(), |
|
|
|
|
|
kpiResultSuperiorEntity.getStartDate(),kpiResultSuperiorEntity.getEndDate(), |
|
|
|
|
|
metaDateCodeList,OrganizationTypeConstant.ORG_TYPE_STREET_DEPT,kpiCycle); |
|
|
} |
|
|
} |
|
|
//区 考核最终得分计算
|
|
|
|
|
|
this.assessmentScoreCalculation(kpiRuleDTO.getReferenceId(), |
|
|
|
|
|
kpiResultSuperiorEntity.getStartDate(),kpiResultSuperiorEntity.getEndDate(), |
|
|
|
|
|
metaDateCodeList,OrganizationTypeConstant.ORG_TYPE_DISTRICT_DEPT,kpiCycle); |
|
|
|
|
|
|
|
|
|
|
|
//街区 考核最终得分计算
|
|
|
|
|
|
this.assessmentScoreCalculation(kpiRuleDTO.getReferenceId(), |
|
|
|
|
|
kpiResultSuperiorEntity.getStartDate(),kpiResultSuperiorEntity.getEndDate(), |
|
|
|
|
|
metaDateCodeList,OrganizationTypeConstant.ORG_TYPE_STREET_DEPT,kpiCycle); |
|
|
|
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -628,4 +614,38 @@ public class KpiRuleServiceImpl extends BaseServiceImpl<KpiRuleDao, KpiRuleEntit |
|
|
return new Result().ok(calculationScore); |
|
|
return new Result().ok(calculationScore); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据月、季、年 以及当前月份,初始化统计元数据值的参数,用于模块间调用 |
|
|
|
|
|
* |
|
|
|
|
|
* @param kpiCycle 月、季、年 |
|
|
|
|
|
* @param methodName 调用此方法的方法名,用于日志打印 |
|
|
|
|
|
* @return java.util.Date 若返回空值:当前月份无法针对传入的考核周期进行考核 |
|
|
|
|
|
* @author zhangyong |
|
|
|
|
|
* @date 2019/12/24 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String,Date> initKpiParam(String kpiCycle, String methodName) { |
|
|
|
|
|
LocalDate startDate = null; |
|
|
|
|
|
YearMonth now = YearMonth.now(); |
|
|
|
|
|
if (KpiCycleEnum.KPI_CYCLE_MONTH.getValue().equals(kpiCycle)) { |
|
|
|
|
|
startDate = now.minusMonths(NumConstant.ONE).atDay(NumConstant.ONE); |
|
|
|
|
|
} else if (KpiCycleEnum.KPI_CYCLE_QUARTER.getValue().equals(kpiCycle)) { |
|
|
|
|
|
int monthValue = now.getMonthValue(); |
|
|
|
|
|
if (monthValue == NumConstant.ONE || monthValue == NumConstant.FOUR || monthValue == NumConstant.SEVEN || monthValue == NumConstant.TEN) { |
|
|
|
|
|
startDate = now.minusMonths(NumConstant.THREE).atDay(NumConstant.ONE); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (KpiCycleEnum.KPI_CYCLE_YEAR.getValue().equals(kpiCycle)) { |
|
|
|
|
|
if (now.getMonthValue() == NumConstant.ONE) { |
|
|
|
|
|
startDate = now.minusMonths(NumConstant.TWELVE).atDay(NumConstant.ONE); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (null == startDate) { |
|
|
|
|
|
log.error("当前时间:{},无法按照{}执行绩效考核{}", LocalDateTime.now().toString(), kpiCycle, methodName); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
log.info("开始执行:{},当前时间:{},考核周期:{}", methodName, LocalDateTime.now().toString(), kpiCycle); |
|
|
|
|
|
Map<String,Date> map = new HashMap<String, Date>(); |
|
|
|
|
|
map.put("startDate", LocalDateUtils.localDateToDate(startDate)); |
|
|
|
|
|
map.put("endDate", LocalDateUtils.localDateToDate(YearMonth.now().minusMonths(NumConstant.ONE).atEndOfMonth())); |
|
|
|
|
|
return map; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|