瀏覽代碼

考评预警

chenminghua 1 年之前
父節點
當前提交
019ca30c91

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

@@ -1,15 +1,13 @@
 package com.ims.eval.controller;
 
 
+import com.ims.eval.entity.BinStage;
+import com.ims.eval.entity.EvaluationWarningRule;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IEvaluationWarningRuleService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
@@ -28,7 +26,7 @@ public class EvaluationWarningRuleController {
 	@Autowired
 	private IEvaluationWarningRuleService warningRuleService;
 
-	@ApiOperation(value = "考评预警规则")
+	@ApiOperation(value = "考评预警规则", notes = "查询")
 	@GetMapping(value = "list")
 	public R EvaluationWarningRuleList(
 		@RequestParam(value = "binSection", required = false) String binSection, //业务板块
@@ -36,4 +34,15 @@ public class EvaluationWarningRuleController {
 		Map<String, Object> map = warningRuleService.warningRuleList(binSection, ruleName);
 		return R.ok().data(map);
 	}
+
+
+	@ApiOperation(value = "考评预警规则添加、更新", notes = "")
+	@PostMapping(value = "save")
+	public R EvaluationWarningRuleSave(@RequestHeader("code") String code, @RequestBody EvaluationWarningRule warningRule){
+		boolean flag = warningRuleService.saveOrUpdate(code, warningRule);
+		if (flag) {
+			return R.ok();
+		}
+		return R.error();
+	}
 }

+ 11 - 6
ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationWarningRule.java

@@ -2,12 +2,14 @@ package com.ims.eval.entity;
 
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import java.time.LocalDate;
+import java.util.Date;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author wang
@@ -32,7 +34,7 @@ public class EvaluationWarningRule extends Model {
     /**
      * 指标id
      */
-    private String indicatorId;
+    private String indicatorCode;
 
     /**
      * 指标信息(计划值、完成值、偏差等信息)
@@ -47,7 +49,7 @@ public class EvaluationWarningRule extends Model {
     /**
      * 预警规则
      */
-    private String rule;
+    private String expression;
 
     /**
      * 预警等级(1低级,2中级,3高级)
@@ -77,17 +79,20 @@ public class EvaluationWarningRule extends Model {
     /**
      * 创建时间
      */
-    private LocalDate createTime;
+    private Date createTime;
 
     /**
      * 修改时间
      */
-    private LocalDate updateTime;
+    private Date updateTime;
 
     /**
      * 是否启用
      */
     private Boolean enable;
 
-
+	/**
+	 * ND/YD/JD
+	 */
+	private String type;
 }

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluationWarningRuleService.java

@@ -22,4 +22,6 @@ public interface IEvaluationWarningRuleService extends IService<EvaluationWarnin
 	 * @return
 	 */
     Map<String, Object> warningRuleList(String binSection, String ruleName);
+
+	boolean saveOrUpdate(String code, EvaluationWarningRule warningRule);
 }

+ 24 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningRuleServiceImpl.java

@@ -1,11 +1,16 @@
 package com.ims.eval.service.impl;
 
+import com.ims.common.utils.StringUtils;
 import com.ims.eval.entity.EvaluationWarningRule;
 import com.ims.eval.dao.EvaluationWarningRuleMapper;
+import com.ims.eval.entity.dto.response.MyuserResDTO;
 import com.ims.eval.service.IEvaluationWarningRuleService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ims.eval.service.IUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.Map;
 
 /**
@@ -19,9 +24,28 @@ import java.util.Map;
 @Service
 public class EvaluationWarningRuleServiceImpl extends ServiceImpl<EvaluationWarningRuleMapper, EvaluationWarningRule> implements IEvaluationWarningRuleService {
 
+	@Autowired
+	private IUserService userService;
+
 	@Override
 	public Map<String, Object> warningRuleList(String binSection, String ruleName) {
 		Map<String, Object> map = baseMapper.selectWarningRule(binSection, ruleName);
 		return map;
 	}
+
+	@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());
+			}
+		}
+		return saveOrUpdate(warningRule);
+	}
 }

+ 9 - 3
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/UserServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
+import springfox.documentation.annotations.Cacheable;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.LinkedHashMap;
@@ -87,11 +88,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements
 		super.saveOrUpdate(user);
 	}
 
+	@Cacheable(value = "user_code")
 	@Override
 	public MyuserResDTO getSysUser(String code) {
-		Object json = remoteServiceBuilder.getGatewayUrl().getSysUser(code);
-		MyuserResDTO user = JSON.parseObject(json.toString(), MyuserResDTO.class);
-		return user;
+		try{
+			Object json = remoteServiceBuilder.getGatewayUrl().getSysUser(code);
+			MyuserResDTO user = JSON.parseObject(json.toString(), MyuserResDTO.class);
+			return user;
+		} catch (Exception e){
+			return null;
+		}
 	}
 
 	@Override

+ 13 - 18
ims-service/ims-eval/src/main/resources/mappers/EvaluateWarningRuleMapper.xml.xml

@@ -6,10 +6,10 @@
     <resultMap id="BaseResultMap" type="com.ims.eval.entity.EvaluationWarningRule">
         <id column="id" property="id" />
         <result column="bin_section" property="binSection" />
-        <result column="indicator_id" property="binStage" />
+        <result column="indicator_code" property="indicatorCode" />
         <result column="indicator_info" property="indicatorInfo" />
         <result column="bin_stage" property="binStage" />
-        <result column="rule" property="rule" />
+        <result column="expression" property="expression" />
         <result column="grade" property="grade" />
         <result column="rule_name" property="ruleName" />
         <result column="rule_des" property="ruleDes" />
@@ -18,38 +18,33 @@
         <result column="create_time" property="createTime" />
         <result column="update_time" property="updateTime" />
         <result column="enable" property="enable" />
+        <result column="type" property="type" />
     </resultMap>
 
 
     <select id="selectWarningRule" resultType="java.util.Map">
         SELECT
         er.*,
-
+        bs.section_name,
+        bs.section_code,
+        s.stage_name,
+        s.stage_code
         FROM
         evaluation_warning_rule er
-        LEFT JOIN evaluation_portal_attach ea ON ep.id = ea.portal_id
-        LEFT JOIN bin_section bs ON ep.bin_section = bs.section_code
+        LEFT JOIN bin_section bs ON bs.id = er.bin_section
+        LEFT JOIN bin_stage s ON s.id = er.bin_stage
+        LEFT JOIN indicator i ON i.id = er.indicator_id
         <where>
 
             <if test="binSection !=null and binSection !=''">
-                AND ep.bin_section = #{binSection}
-            </if>
-            <if test="year !=null and year !=''">
-                AND ep.year = #{year}
-            </if>
-
-            <if test="season !=null and season !=''">
-                AND ep.season = #{season}
+                AND er.bin_section = #{binSection}
             </if>
-
-            <if test="season ==null">
-                AND ep.season is null
+            <if test="ruleName !=null and ruleName !=''">
+                AND er.rule_name like concat('%',#{ruleName},'%');
             </if>
 
         </where>
 
-        ORDER BY SCORE DESC
-
     </select>