|
@@ -0,0 +1,123 @@
|
|
|
+package cn.hnthyy.thmz.controller.mz;
|
|
|
+
|
|
|
+import cn.hnthyy.thmz.Utils.TokenUtil;
|
|
|
+import cn.hnthyy.thmz.comment.UserLoginToken;
|
|
|
+import cn.hnthyy.thmz.entity.thmz.CriticalValue;
|
|
|
+import cn.hnthyy.thmz.entity.thmz.User;
|
|
|
+import cn.hnthyy.thmz.service.thmz.CriticalValueService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+public class CriticalValueController {
|
|
|
+ @Autowired
|
|
|
+ private CriticalValueService criticalValueService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取危急值列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @UserLoginToken
|
|
|
+ @RequestMapping(value = "/getCriticalValueList", method = {RequestMethod.POST})
|
|
|
+ public Map<String, Object> getCriticalValueList(@RequestBody CriticalValue criticalValue, HttpServletRequest httpServletRequest) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ try {
|
|
|
+ if(criticalValue==null){
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询参数不能为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(criticalValue.getCommonParams())) {
|
|
|
+ criticalValue.setCommonParams(null);
|
|
|
+ } else {
|
|
|
+ criticalValue.setCommonParams("%" + criticalValue.getCommonParams() + "%");
|
|
|
+ }
|
|
|
+ User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
+ criticalValue.setEmployeeCodes("%" + tokenUser.getUserCode() + "%");
|
|
|
+ if (StringUtils.isBlank(criticalValue.getBeginDate())) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询记录失败,开始日期参数为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(criticalValue.getEndDate())) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询记录失败,结束日期参数为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ if (criticalValue.getPageSize() == null) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询记录失败,每页显示条数参数为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ if (criticalValue.getOffset() == null) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询记录失败,当前所在页参数为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ Integer total = criticalValueService.queryCountCriticalValue(criticalValue);
|
|
|
+ if(total==0){
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "未查询到危急值信息");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ List<CriticalValue> criticalValueList = criticalValueService.queryCriticalValueWithPage(criticalValue);
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取危急值列表成功");
|
|
|
+ resultMap.put("total", total);
|
|
|
+ resultMap.put("data", criticalValueList);
|
|
|
+ return resultMap;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "系统出错,请联系管理员");
|
|
|
+ log.error("系统异常,错误信息{}", e);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID查询危急值
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @UserLoginToken
|
|
|
+ @RequestMapping(value = "/getCriticalValueById", method = {RequestMethod.GET})
|
|
|
+ public Map<String, Object> getCriticalValueById(@RequestParam("id") Long id) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ try {
|
|
|
+ if(id==null){
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "查询参数不能为空");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ CriticalValue criticalValue = criticalValueService.queryCriticalValueById(id);
|
|
|
+ if(criticalValue==null){
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "未查询到危急值信息");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "获取危急值成功");
|
|
|
+ resultMap.put("data", criticalValue);
|
|
|
+ return resultMap;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "系统出错,请联系管理员");
|
|
|
+ log.error("系统异常,错误信息{}", e);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|