chenminghua 1 yıl önce
ebeveyn
işleme
48bea5065d

+ 2 - 6
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationWarningRuleController.java

@@ -2,7 +2,6 @@ package com.ims.eval.controller;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.ims.eval.entity.BinStage;
 import com.ims.eval.entity.EvaluationWarningInfo;
 import com.ims.eval.entity.EvaluationWarningRule;
 import com.ims.eval.entity.dto.result.R;
@@ -12,9 +11,6 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-import java.util.Map;
-
 /**
  * <p>
  *  前端控制器
@@ -49,7 +45,7 @@ public class EvaluationWarningRuleController {
 
 	@ApiOperation(value = "考评预警规则添加、更新", notes = "")
 	@PostMapping(value = "rule/save")
-	public R EvaluationWarningRuleSave(@RequestHeader(value = "code", required = false) String code, @RequestBody EvaluationWarningRule warningRule){
+	public R EvaluationWarningRuleSave(@RequestHeader(value = "Code", required = false) String code, @RequestBody EvaluationWarningRule warningRule){
 		boolean flag = warningRuleService.saveOrUpdate(code, warningRule);
 		if (flag) {
 			return R.ok();
@@ -84,7 +80,7 @@ public class EvaluationWarningRuleController {
 
 	@ApiOperation(value = "考评预警详情更新", notes = "")
 	@PostMapping(value = "info/save")
-	public R EvaluationWarningInfoSave(@RequestHeader("code") String code, @RequestBody EvaluationWarningInfo warningInfo){
+	public R EvaluationWarningInfoSave(@RequestHeader("Code") String code, @RequestBody EvaluationWarningInfo warningInfo){
 		boolean flag = warningInfoService.updateItem(code, warningInfo);
 		if (flag) {
 			return R.ok();

+ 2 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationWarningInfo.java

@@ -86,9 +86,9 @@ public class EvaluationWarningInfo extends Model {
      */
     private Date createTime;
 
-	private Double targetValue;
+	private String targetValue;
 
-	private Double completeValue;
+	private String completeValue;
 
 	private String company;
 }

+ 52 - 48
ims-service/ims-eval/src/main/java/com/ims/eval/schedule/EvaluationWarningSchedule.java

@@ -3,6 +3,7 @@ package com.ims.eval.schedule;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ims.common.utils.DateUtils;
 import com.ims.common.utils.FormulaUtils;
+import com.ims.common.utils.StringUtils;
 import com.ims.eval.entity.EvaluationDeptBusinessAssessment;
 import com.ims.eval.entity.EvaluationWarningInfo;
 import com.ims.eval.entity.EvaluationWarningRule;
@@ -49,8 +50,8 @@ public class EvaluationWarningSchedule {
 	/**
 	 * 年度考评
 	 */
-//	@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningRuleResolveNDKP(){
 		List<EvaluationWarningRule> list = warningRuleService.warningRuleList(null, null, TYPE_NDKP, true);
 		List<Map<String, Object>> companys = evaluationService.getCompanyWarning(TYPE_NDKP);
@@ -64,8 +65,8 @@ public class EvaluationWarningSchedule {
 	/**
 	 * 季度考评
 	 */
-//	@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningRuleResolveJDKP(){
 		List<EvaluationWarningRule> list = warningRuleService.warningRuleList(null, null, TYPE_JDKP, true);
 		List<Map<String, Object>> companys = evaluationService.getCompanyWarning(TYPE_JDKP);
@@ -79,8 +80,8 @@ public class EvaluationWarningSchedule {
 	/**
 	 * 月度考评
 	 */
-//	@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 0 23 * * ?") // cron表达式: 每天23点触发
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningRuleResolveYDKP(){
 		List<EvaluationWarningRule> list = warningRuleService.warningRuleList(null, null, TYPE_YDKP, true);
 		List<Map<String, Object>> companys = evaluationService.getCompanyWarning(TYPE_YDKP);
@@ -96,114 +97,117 @@ public class EvaluationWarningSchedule {
 	/**
 	 * 单位年度考评
 	 */
-//	@Scheduled(cron = "0 0 0 1 4 ?") // cron表达式: 每年4月1号0点触发
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 0 0 1 4 ?") // cron表达式: 每年4月1号0点触发
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningEvaluationNDKP(){
 		Calendar cal = Calendar.getInstance();
 		String year = String.valueOf(cal.get(Calendar.YEAR));
 		List<OrganizationEvaluation> list = evaluationService.list(null, TYPE_NDKP, year, null);
 
-		String company = "";
+		String company = "公司本部";
 		String title = "单位年度考评";
 		String content = "";
 		if (list == null || list.size() == 0) {
 			content = "单位年度考评计划未建立";
-			company = "公司本部";
+			saveWarningInfo(null, null, title, content, null, null, null, company);
+		}
+		Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
+		if (optional.isPresent()){
+			content = "单位年度考评流程未启动";
+			company = StringUtils.isNotEmpty(optional.get().getCreateOrgName()) ? optional.get().getCreateOrgName() : company;
+			saveWarningInfo(null, null, title, content, null, null, null, company);
 		}
-		Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
-		content = optional.isPresent() ? "单位年度考评流程未启动" : content;
-		company = optional.isPresent() ? optional.get().getCreateOrgName() : company;
-
-		saveWarningInfo(null, null, title, content, null, 0, 0, company);
 	}
 
 	/**
 	 * 单位季度考评
 	 */
-//	@Scheduled(cron = "0 5 20 1 1,4,7,10 ?") // cron表达式: 每个季度的第一个月的20号的5执行一次
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 5 20 1 1,4,7,10 ?") // cron表达式: 每个季度的第一个月的20号的5执行一次
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningEvaluationJDKP(){
 		Calendar cal = Calendar.getInstance();
 		String year = String.valueOf(cal.get(Calendar.YEAR));
 		String season = String.valueOf(DateUtils.getSeason(cal.getTime()));
 		List<OrganizationEvaluation> list = evaluationService.list(null, TYPE_JDKP, year, season);
 
-		String company = "";
+		String company = "公司本部";
 		String title = "单位季度考评";
 		String content = "";
 		if (list == null || list.size() == 0) {
 			content = "单位季度考评计划未建立";
-			company = "公司本部";
+			saveWarningInfo(null, null, title, content, null, null, null, company);
+		}
+		Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
+		if (optional.isPresent()){
+			content = "单位季度考评流程未启动";
+			company = StringUtils.isNotEmpty(optional.get().getCreateOrgName()) ? optional.get().getCreateOrgName() : company;
+			saveWarningInfo(null, null, title, content, null, null, null, company);
 		}
-		Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
-		content = optional.isPresent() ? "单位季度考评流程未启动" : content;
-		company = optional.isPresent() ? optional.get().getCreateOrgName() : company;
-
-		saveWarningInfo(null, null, title, content, null, 0, 0, company);
 	}
 
 	/**
 	 * 单位月度考评
 	 */
-//	@Scheduled(cron = "0 0 7 5 * ?") // cron表达式: 每月5日上午7点触发
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 0 7 5 * ?") // cron表达式: 每月5日上午7点触发
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningEvaluationYDKP(){
 		Calendar cal = Calendar.getInstance();
 		String year = String.valueOf(cal.get(Calendar.YEAR));
 		String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
 		List<OrganizationEvaluation> list = evaluationService.list(null, TYPE_YDKP, year, month);
 
-		String company = "";
+		String company = "公司本部";
 		String title = "单位月度考评";
 		String content = "";
 		if (list == null || list.size() == 0) {
 			content = "单位月度考评计划未建立";
-			company = "公司本部";
+			saveWarningInfo(null, null, title, content, null, null, null, company);
+		}
+		Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
+		if (optional.isPresent()){
+			content = "单位季度考评流程未启动";
+			company = StringUtils.isNotEmpty(optional.get().getCreateOrgName()) ? optional.get().getCreateOrgName() : company;
+			saveWarningInfo(null, null, title, content, null, null, null, company);
 		}
-		Optional<OrganizationEvaluation> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
-		content = optional.isPresent() ? "单位月度考评流程未启动" : content;
-		company = optional.isPresent() ? optional.get().getCreateOrgName() : company;
-
-		saveWarningInfo(null, null, title, content, null, 0, 0, company);
 	}
 
 
 	/**
 	 * 部门年度考评
 	 */
-//	@Scheduled(cron = "0 0 0 1 4 ?") // cron表达式: 每年4月1号0点触发
-	@Scheduled(cron="0/50 * * * * ?")
+	@Scheduled(cron = "0 0 0 1 4 ?") // cron表达式: 每年4月1号0点触发
+//	@Scheduled(cron="0/50 * * * * ?")
 	public void warningEvaluationDeptYDKP(){
 		Calendar cal = Calendar.getInstance();
 		String year = String.valueOf(cal.get(Calendar.YEAR));
 		List<EvaluationDeptBusinessAssessment> list = assessmentService.list(year);
 
-		String company = "";
+		String company = "公司部门";
 		String title = "部门年度考评";
 		String content = "";
 		if (list == null || list.size() == 0) {
 			content = "部门年度考评计划未建立";
-			company = "公司部门";
+			saveWarningInfo(null, null, title, content, null, null, null, company);
+		}
+		Optional<EvaluationDeptBusinessAssessment> optional = list.stream().filter(item -> item.getStage().contains("未启动")).findFirst();
+		if (optional.isPresent()){
+			content = "部门年度考评计划流程未启动";
+			company = optional.isPresent() ? optional.get().getDeptName() : company;
+			saveWarningInfo(null, null, title, content, null, null, null, company);
 		}
-		Optional<EvaluationDeptBusinessAssessment> optional = list.stream().filter(item -> item.getStage().equals("流程未启动")).findFirst();
-		content = optional.isPresent() ? "部门年度考评计划流程未启动" : content;
-		company = optional.isPresent() ? optional.get().getDeptName() : company;
-
-		saveWarningInfo(null, null, title, content, null, 0, 0, company);
 	}
 
 
 
 	private void calculate(List<EvaluationWarningRule> rules, List<Map<String, Object>> companys, String type){
-		Calendar cal = Calendar.getInstance();
 		Map<Object, List<Map<String, Object>>> collect = companys.stream().collect(Collectors.groupingBy(m -> m.get("indicator_id")));
 		for (EvaluationWarningRule rule : rules){
 			if (!isFocus(rule, type)){
 				continue;
 			}
 			String company = "";
-			double targetValue = 0;
-			double completeValue = 0;
+			String targetValue = null;
+			String completeValue = null;
 			String expression = rule.getExpression();
 			List<Map<String, Object>> list = collect.get(rule.getIndicatorId());
 			for (Map<String, Object> mp : list){
@@ -211,8 +215,8 @@ public class EvaluationWarningSchedule {
 					//替换表达式数值
 					expression.replace("[" + mp.get("option_code") + "]", String.valueOf(mp.get("quantified_value")));
 				}
-				targetValue = mp.containsKey("JHZ") ? (double) mp.get("JHZ") : mp.containsKey("DBZ") ? (double) mp.get("DBZ") : 0;
-				completeValue = mp.containsKey("WCZ") ? (double) mp.get("WCZ") : 0;
+				targetValue = mp.containsKey("JHZ") ? (String) mp.get("JHZ") : mp.containsKey("DBZ") ? (String) mp.get("DBZ") : mp.containsKey("MBZ") ? (String) mp.get("MBZ") : null;
+				completeValue = mp.containsKey("WCZ") ? (String) mp.get("WCZ") : null;
 				company = mp.containsKey("organization_short_name") ? String.valueOf(mp.get("organization_short_name")) : company;
 			}
 			/**
@@ -226,7 +230,7 @@ public class EvaluationWarningSchedule {
 	}
 
 	private void saveWarningInfo(String binSection, String indicatorId, String title,  String content,
-								 String ruleId, double targetValue, double completeValue, String company){
+								 String ruleId, String targetValue, String completeValue, String company){
 		EvaluationWarningInfo info = new EvaluationWarningInfo();
 		info.setBinSection(binSection);
 		info.setIndicatorId(indicatorId);

+ 10 - 8
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningInfoServiceImpl.java

@@ -3,6 +3,7 @@ package com.ims.eval.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ims.common.utils.DateUtils;
 import com.ims.common.utils.StringUtils;
 import com.ims.eval.cache.CacheContext;
 import com.ims.eval.config.CustomException;
@@ -50,11 +51,11 @@ public class EvaluationWarningInfoServiceImpl extends ServiceImpl<EvaluationWarn
 		}
 
 		if (StringUtils.isNotEmpty(st)) {
-			qw.lambda().ge(EvaluationWarningInfo::getCreateTime, st);
+			qw.lambda().ge(EvaluationWarningInfo::getCreateTime, DateUtils.strToDate(st, DateUtils.format1));
 		}
 
 		if (StringUtils.isNotEmpty(et)){
-			qw.lambda().le(EvaluationWarningInfo::getCreateTime, et);
+			qw.lambda().le(EvaluationWarningInfo::getCreateTime, DateUtils.strToDate(et, DateUtils.format1));
 		}
 		qw.orderByDesc("create_time");
 
@@ -66,12 +67,13 @@ public class EvaluationWarningInfoServiceImpl extends ServiceImpl<EvaluationWarn
 
 	@Override
 	public boolean updateItem(String code, EvaluationWarningInfo warningInfo) {
-		MyuserResDTO user = userService.getSysUser(code);
-//		MyuserResDTO user = new MyuserResDTO();
-		if (user != null){
-			warningInfo.setUserName(user.getName());
-			warningInfo.setUserCode(code);
-			warningInfo.setDeptId(user.getDeptId());
+		if (StringUtils.isNotEmpty(code) && !code.equals("null")){
+			MyuserResDTO user = userService.getSysUser(code);
+			if (user != null){
+				warningInfo.setUserName(user.getName());
+				warningInfo.setUserCode(code);
+				warningInfo.setDeptId(user.getDeptId());
+			}
 		}
 
 		return saveOrUpdate(warningInfo);

+ 10 - 9
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningRuleServiceImpl.java

@@ -68,15 +68,16 @@ public class EvaluationWarningRuleServiceImpl extends ServiceImpl<EvaluationWarn
 
 	@Override
 	public boolean saveOrUpdate(String code, EvaluationWarningRule warningRule) {
-		MyuserResDTO user = userService.getSysUser(code);
-//		MyuserResDTO user = new MyuserResDTO();
-		if (user != null){
-			if (StringUtils.isNotEmpty(warningRule.getId())){
-				warningRule.setUpdateBy(user.getName());
-				warningRule.setUpdateTime(new Date());
-			} else {
-				warningRule.setCreateBy(user.getName());
-				warningRule.setCreateTime(new Date());
+		if (StringUtils.isNotEmpty(code) && !code.equals("null")){
+			MyuserResDTO user = userService.getSysUser(code);
+			if (user != null){
+				if (StringUtils.isNotEmpty(warningRule.getId())){
+					warningRule.setUpdateBy(user.getName());
+					warningRule.setUpdateTime(new Date());
+				} else {
+					warningRule.setCreateBy(user.getName());
+					warningRule.setCreateTime(new Date());
+				}
 			}
 		}
 		return saveOrUpdate(warningRule);