ea10bd28 dengxuelong

化验日报-在线值

1 个父辈 408a631f
package com.skua.modules.report.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.core.api.vo.Result;
import com.skua.modules.report.entity.ReportDisplay;
import com.skua.modules.report.entity.ReportHeader;
import com.skua.modules.report.mapper.FReportManageMapper;
import com.skua.modules.report.mapper.ReportHeaderMapper;
import com.skua.modules.report.service.IJmReportService;
import com.skua.modules.report.service.IReportDisplayService;
import com.skua.modules.report.vo.ReportShow;
import com.skua.modules.util.ReportUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
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 javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Api(tags = "积木 报表展示")
@RestController
@RequestMapping("/report/jmReport")
public class JmReportController {
@Autowired
ReportDisplayController reportDisplayController;
@Autowired
FReportManageMapper reportManageMapper;
@Autowired
IReportDisplayService reportDisplayService;
@Autowired
ReportHeaderMapper reportHeaderMapper;
@Autowired
IJmReportService jmReportService;
@ApiOperation(value = "化验日报-在线值", notes = "积木报表")
@GetMapping(value = "/hyrbZxz")
public Map trCount(
@RequestParam(name = "departId" ) String departId,
@RequestParam(name = "date" ) String date //yyyy-MM-dd
) {
Map returnData = new HashMap();
//查询【表头】 保持和[生产报表]一致
QueryWrapper<ReportDisplay> reportDisplayQueryWrapper = new QueryWrapper<>();
reportDisplayQueryWrapper.eq("depart_id",departId);
reportDisplayQueryWrapper.eq("report_name","生产报表");
ReportDisplay reportDisplay = reportDisplayService.getOne(reportDisplayQueryWrapper);
if (reportDisplay == null) {
return returnData;
}
List<Map<String, String>> reportHeaderList = reportHeaderMapper.hyrbZxz(reportDisplay.getId());
Map<String, String> reportHeaderMap = reportHeaderList.stream().collect(Collectors.toMap(v -> v.get("tag"), o -> o.get("metricId")));
//查询【数据】
ReportShow params = new ReportShow();
params.setId(reportDisplay.getId());
params.setDepartId(departId);
params.setStartDateTime(date + " 00:00:00");
params.setEndDateTime(date + " 23:59:59");
params.setReportType("day");
Result<List<Map<String, Object>>> dataListResult = reportDisplayController.reprotShow(params);
List<Map<String, Object>> dataList = CollectionUtils.isEmpty(dataListResult.getResult()) ? new LinkedList<>() : dataListResult.getResult();//(正常情况下只有一条)
//查询【告警上限】
List<Map<String, String>> limitList = reportHeaderMapper.queryLimit(departId);
Map<String, String> limitMap = limitList.stream().collect(Collectors.toMap(v -> v.get("tag"), o -> o.get("maxValue")));
List<String> tagList = Arrays.asList("CSCOD","CSNH3N","CSPH","CSTN","CSTP","JSCOD","JSNH3N","JSPH","JSTN","JSTP","JSSS","CSSS");
//组装数据
for (Map<String, Object> dataMap : dataList) {
for (String tag : tagList) {
String metricId = reportHeaderMap.get(tag);//点位Id
dataMap.put(tag, dataMap.get(metricId));
BigDecimal minValue = tag.contains("PH") ? new BigDecimal("6") : BigDecimal.ZERO; //PH的阈值固定为6~9
BigDecimal maxValue = tag.contains("PH") ? new BigDecimal("9") : ReportUtil.getBigDecimalValue(tag, limitMap);
maxValue = maxValue == null ? new BigDecimal("9999999") : maxValue;
boolean flag = false;
BigDecimal valueBigDecimal = ReportUtil.newBigDecimal(metricId, null);
if(valueBigDecimal != null && (valueBigDecimal.compareTo(minValue) < 0 || valueBigDecimal.compareTo(maxValue) > 0)){
flag = true; //超标!
}
dataMap.put(tag + "_是否超标", flag ? "yes" : "no"); //判断是否告警
}
}
returnData.put("data",dataList);
return returnData;
}
}
package com.skua.modules.report.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.report.entity.ReportHeader;
......@@ -15,4 +16,13 @@ public interface ReportHeaderMapper extends BaseMapper<ReportHeader> {
//查询报表信息
List<ReportHeader> headerAll(@Param("reportId") String reportId);
List<Map<String, String>> hyrbZxz(String id);
/**
* 查询告警上限值
* @param depart
* @return
*/
List<Map<String, String>> queryLimit(String depart);
}
......
......@@ -30,4 +30,31 @@
report_id =#{reportId}
ORDER BY sort_num
</select>
<select id="hyrbZxz" resultType="java.util.Map">
select m.metric_uid_tag as 'tag', h.key_index as 'metricId', h.title
from report_header h
join sys_monitor_metric_info m on h.key_index = m.id
where
h.report_id = #{id}
and metric_uid_tag is not null
and metric_uid_tag != ''
</select>
<select id="queryLimit" resultType="java.util.Map">
SELECT
b.alarm_param_code AS tag,
b.alarm_param_upper_limit AS `maxValue`
FROM
sys_factory_info a
LEFT JOIN alarm_param_standard_config b ON a.out_level = b.alarm_level_standard_id
WHERE
depart_id = #{depart}
UNION ALL
SELECT
index_code,
upper
FROM
water_quality_in_level
WHERE
depart_id = #{depart}
</select>
</mapper>
......
......@@ -49,6 +49,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
filterChainDefinitionMap.put("/report/jmReport/*", "anon");//积木报表
filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!