ea10bd28 dengxuelong

化验日报-在线值

1 个父辈 408a631f
1 package com.skua.modules.report.controller;
2
3 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 import com.skua.core.api.vo.Result;
5 import com.skua.modules.report.entity.ReportDisplay;
6 import com.skua.modules.report.entity.ReportHeader;
7 import com.skua.modules.report.mapper.FReportManageMapper;
8 import com.skua.modules.report.mapper.ReportHeaderMapper;
9 import com.skua.modules.report.service.IJmReportService;
10 import com.skua.modules.report.service.IReportDisplayService;
11 import com.skua.modules.report.vo.ReportShow;
12 import com.skua.modules.util.ReportUtil;
13 import io.swagger.annotations.Api;
14 import io.swagger.annotations.ApiOperation;
15 import io.swagger.annotations.ApiParam;
16 import lombok.extern.slf4j.Slf4j;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.util.CollectionUtils;
19 import org.springframework.web.bind.annotation.GetMapping;
20 import org.springframework.web.bind.annotation.RequestMapping;
21 import org.springframework.web.bind.annotation.RequestParam;
22 import org.springframework.web.bind.annotation.RestController;
23
24 import javax.servlet.http.HttpServletRequest;
25 import java.math.BigDecimal;
26 import java.util.*;
27 import java.util.stream.Collectors;
28
29 @Slf4j
30 @Api(tags = "积木 报表展示")
31 @RestController
32 @RequestMapping("/report/jmReport")
33 public class JmReportController {
34 @Autowired
35 ReportDisplayController reportDisplayController;
36 @Autowired
37 FReportManageMapper reportManageMapper;
38 @Autowired
39 IReportDisplayService reportDisplayService;
40 @Autowired
41 ReportHeaderMapper reportHeaderMapper;
42 @Autowired
43 IJmReportService jmReportService;
44
45 @ApiOperation(value = "化验日报-在线值", notes = "积木报表")
46 @GetMapping(value = "/hyrbZxz")
47 public Map trCount(
48 @RequestParam(name = "departId" ) String departId,
49 @RequestParam(name = "date" ) String date //yyyy-MM-dd
50 ) {
51
52 Map returnData = new HashMap();
53
54 //查询【表头】 保持和[生产报表]一致
55 QueryWrapper<ReportDisplay> reportDisplayQueryWrapper = new QueryWrapper<>();
56 reportDisplayQueryWrapper.eq("depart_id",departId);
57 reportDisplayQueryWrapper.eq("report_name","生产报表");
58 ReportDisplay reportDisplay = reportDisplayService.getOne(reportDisplayQueryWrapper);
59 if (reportDisplay == null) {
60 return returnData;
61 }
62 List<Map<String, String>> reportHeaderList = reportHeaderMapper.hyrbZxz(reportDisplay.getId());
63 Map<String, String> reportHeaderMap = reportHeaderList.stream().collect(Collectors.toMap(v -> v.get("tag"), o -> o.get("metricId")));
64
65
66 //查询【数据】
67 ReportShow params = new ReportShow();
68 params.setId(reportDisplay.getId());
69 params.setDepartId(departId);
70 params.setStartDateTime(date + " 00:00:00");
71 params.setEndDateTime(date + " 23:59:59");
72 params.setReportType("day");
73 Result<List<Map<String, Object>>> dataListResult = reportDisplayController.reprotShow(params);
74 List<Map<String, Object>> dataList = CollectionUtils.isEmpty(dataListResult.getResult()) ? new LinkedList<>() : dataListResult.getResult();//(正常情况下只有一条)
75
76
77
78
79 //查询【告警上限】
80 List<Map<String, String>> limitList = reportHeaderMapper.queryLimit(departId);
81 Map<String, String> limitMap = limitList.stream().collect(Collectors.toMap(v -> v.get("tag"), o -> o.get("maxValue")));
82
83
84 List<String> tagList = Arrays.asList("CSCOD","CSNH3N","CSPH","CSTN","CSTP","JSCOD","JSNH3N","JSPH","JSTN","JSTP","JSSS","CSSS");
85 //组装数据
86 for (Map<String, Object> dataMap : dataList) {
87 for (String tag : tagList) {
88 String metricId = reportHeaderMap.get(tag);//点位Id
89 dataMap.put(tag, dataMap.get(metricId));
90
91 BigDecimal minValue = tag.contains("PH") ? new BigDecimal("6") : BigDecimal.ZERO; //PH的阈值固定为6~9
92 BigDecimal maxValue = tag.contains("PH") ? new BigDecimal("9") : ReportUtil.getBigDecimalValue(tag, limitMap);
93 maxValue = maxValue == null ? new BigDecimal("9999999") : maxValue;
94 boolean flag = false;
95 BigDecimal valueBigDecimal = ReportUtil.newBigDecimal(metricId, null);
96 if(valueBigDecimal != null && (valueBigDecimal.compareTo(minValue) < 0 || valueBigDecimal.compareTo(maxValue) > 0)){
97 flag = true; //超标!
98 }
99
100 dataMap.put(tag + "_是否超标", flag ? "yes" : "no"); //判断是否告警
101 }
102
103 }
104
105
106 returnData.put("data",dataList);
107 return returnData;
108 }
109
110 }
1 package com.skua.modules.report.mapper; 1 package com.skua.modules.report.mapper;
2 2
3 import java.util.List; 3 import java.util.List;
4 import java.util.Map;
4 5
5 import org.apache.ibatis.annotations.Param; 6 import org.apache.ibatis.annotations.Param;
6 import com.skua.modules.report.entity.ReportHeader; 7 import com.skua.modules.report.entity.ReportHeader;
...@@ -15,4 +16,13 @@ public interface ReportHeaderMapper extends BaseMapper<ReportHeader> { ...@@ -15,4 +16,13 @@ public interface ReportHeaderMapper extends BaseMapper<ReportHeader> {
15 16
16 //查询报表信息 17 //查询报表信息
17 List<ReportHeader> headerAll(@Param("reportId") String reportId); 18 List<ReportHeader> headerAll(@Param("reportId") String reportId);
19
20 List<Map<String, String>> hyrbZxz(String id);
21
22 /**
23 * 查询告警上限值
24 * @param depart
25 * @return
26 */
27 List<Map<String, String>> queryLimit(String depart);
18 } 28 }
......
...@@ -30,4 +30,31 @@ ...@@ -30,4 +30,31 @@
30 report_id =#{reportId} 30 report_id =#{reportId}
31 ORDER BY sort_num 31 ORDER BY sort_num
32 </select> 32 </select>
33 <select id="hyrbZxz" resultType="java.util.Map">
34 select m.metric_uid_tag as 'tag', h.key_index as 'metricId', h.title
35 from report_header h
36 join sys_monitor_metric_info m on h.key_index = m.id
37 where
38 h.report_id = #{id}
39 and metric_uid_tag is not null
40 and metric_uid_tag != ''
41 </select>
42 <select id="queryLimit" resultType="java.util.Map">
43 SELECT
44 b.alarm_param_code AS tag,
45 b.alarm_param_upper_limit AS `maxValue`
46 FROM
47 sys_factory_info a
48 LEFT JOIN alarm_param_standard_config b ON a.out_level = b.alarm_level_standard_id
49 WHERE
50 depart_id = #{depart}
51 UNION ALL
52 SELECT
53 index_code,
54 upper
55 FROM
56 water_quality_in_level
57 WHERE
58 depart_id = #{depart}
59 </select>
33 </mapper> 60 </mapper>
......
...@@ -49,6 +49,7 @@ public class ShiroConfig { ...@@ -49,6 +49,7 @@ public class ShiroConfig {
49 filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除 49 filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
50 filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串 50 filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
51 filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码 51 filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
52 filterChainDefinitionMap.put("/report/jmReport/*", "anon");//积木报表
52 filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录 53 filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
53 filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在 54 filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
54 filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册 55 filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!