Commit 1d4157a9 authored by 高建强's avatar 高建强

item:三维屏告警消息初始化推送

parent d4b32d10
......@@ -45,7 +45,7 @@ public class ProtalDataRo extends BasicsRo {
* 任务编号,如果无任务,则填充0
*/
@Label("任务id")
private Long taskId=0l;
private Long taskId= 0L;
/**
* 任务状态
*/
......
......@@ -7,7 +7,10 @@ import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -27,17 +30,40 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "装备性能指标Api")
public class EquipmentSpecificIndexController extends BaseController {
@Value("${autoSys.alarm.nameKeys}")
private String nameKeys;
@Value("${autoSys.alarm.status}")
private String status;
@Value("${autoSys.alarm.value}")
private String value;
@Autowired
private EquipmentSpecificIndexService equipmentSpecificIndexService;
@Permission
@ApiOperation(httpMethod = "GET", value = "获取最新告警状态", notes = "获取最新告警状态")
@RequestMapping(value = "/queryInitAlarm", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryInitAlerm(@ApiParam(value = "告警状态", required = true) @RequestParam String status,
public CommonResponse queryInitAlerm(@ApiParam(value = "物联采集属性值", required = true) @RequestParam String value,
@ApiParam(value = "多nameKey,中间英文逗号隔开", required = true) @RequestParam String nameKeys,
@ApiParam(value = "多status,中间英文逗号隔开", required = true) @RequestParam String pollStatus) {
@ApiParam(value = "多status,中间英文逗号隔开", required = true) @RequestParam String status) {
return CommonResponseUtil.success(equipmentSpecificIndexService.queryInitAlarm(status, nameKeys, pollStatus));
return CommonResponseUtil.success(equipmentSpecificIndexService.queryInitAlarm(value, nameKeys, status));
}
@Permission
@ApiOperation(httpMethod = "GET", value = "获取三维初始化告警信息", notes = "获取三维初始化告警信息")
@RequestMapping(value = "/getInitAlarm", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getInitAlarm(@ApiParam(value = "物联采集属性值") @RequestParam(required = false) String value,
@ApiParam(value = "多nameKey,中间英文逗号隔开") @RequestParam(required = false) String nameKeys,
@ApiParam(value = "多status,中间英文逗号隔开") @RequestParam(required = false) String status) {
if (!StringUtils.isNotBlank(value) && !StringUtils.isNotBlank(nameKeys) && !StringUtils.isNotBlank(status)) {
value = this.value;
nameKeys = this.nameKeys;
status = this.status;
}
return CommonResponseUtil.success(equipmentSpecificIndexService.getInitAlarm(value, nameKeys, status));
}
}
\ No newline at end of file
......@@ -16,5 +16,7 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif
List<EquipmentSpecificIndexVo> findByDetailIdInAndNameKey(@Param("list") List<Object> equipDetailIdList, @Param("nameKey") String nameKey);
List<EquipmentSpecificIndexVo> queryInitAlarm(@Param("status") String status, @Param("list") String[] nameKeys);
List<EquipmentSpecificIndexVo> queryInitAlarm(@Param("value") String value, @Param("list") String[] nameKeys);
List<EquipmentSpecificIndexVo> getInitAlarm(@Param("value") String value, @Param("list") String[] nameKeys);
}
package com.yeejoin.amos.fas.business.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.business.vo.PollPointVo;
import org.apache.ibatis.annotations.Param;
......@@ -17,5 +18,7 @@ import java.util.List;
*/
public interface PollPointMapper extends BaseMapper<PollPointVo> {
List<PollPointVo> queryInitAlarm(@Param("list") String[] pollStatus);
List<PollPointVo> queryInitAlarm(@Param("list") String[] status);
List<EquipmentSpecificIndexVo> getInitAlarm(@Param("list") String[] status);
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
......@@ -31,14 +32,24 @@ public class EquipmentSpecificIndexServiceImpl implements EquipmentSpecificIndex
private PollPointMapper pollPointMapper;
@Override
public Map<String, Object> queryInitAlarm(String status, String nameKeys, String pollStatus) {
public Map<String, Object> queryInitAlarm(String value, String nameKeys, String status) {
Map<String, Object> map = new HashMap<>(16);
// 查询设备告警
List<EquipmentSpecificIndexVo> equipmentSpecificAlarmVoList = equipmentSpecificIndexMapper.queryInitAlarm(status, nameKeys.split(","));
List<EquipmentSpecificIndexVo> equipmentSpecificAlarmVoList = equipmentSpecificIndexMapper.queryInitAlarm(value, nameKeys.split(","));
map.put("equip", equipmentSpecificAlarmVoList);
// 查询巡检告警
List<PollPointVo> pollPointVoList = pollPointMapper.queryInitAlarm(pollStatus.split(","));
List<PollPointVo> pollPointVoList = pollPointMapper.queryInitAlarm(status.split(","));
map.put("poll", pollPointVoList);
return map;
}
@Override
public List<EquipmentSpecificIndexVo> getInitAlarm(String value, String nameKeys, String status) {
// 查询设备告警
List<EquipmentSpecificIndexVo> equipmentSpecificAlarmVoList = equipmentSpecificIndexMapper.getInitAlarm(value, nameKeys.split(","));
// 查询巡检告警
List<EquipmentSpecificIndexVo> pollPointVoList = pollPointMapper.getInitAlarm(status.split(","));
pollPointVoList.stream().sequential().collect(Collectors.toCollection(() -> equipmentSpecificAlarmVoList));
return equipmentSpecificAlarmVoList;
}
}
\ No newline at end of file
......@@ -153,7 +153,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
log.info("iotCode 性能指标属于: " + topicEntity.getType());
EquipmentSpecificIndexVo equipmentSpecificIndex = JSONObject.parseObject(topicEntity.getMessage(), EquipmentSpecificIndexVo.class);
long eqSpecId = equipmentSpecificIndex.getEquipmentSpecificId();
String nameKey = equipmentSpecificIndex.getNameKey();
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(eqSpecId);
// 三维屏指标状态推送
if ("fireAlarm".equals(nameKey) || "fault".equals(nameKey) || "shield".equals(nameKey)) {
if (equipmentSpecific != null) {
equipmentSpecificIndex.setId(equipmentSpecific.getId());
equipmentSpecificIndex.setName(equipmentSpecific.getName());
equipmentSpecificIndex.setCode(equipmentSpecific.getCode());
}
equipmentSpecificIndex.setType("equip");
String title = String.format("/%s/%s", serviceName, "data/refresh/indexStatus");
webMqttComponent.publish(title, JSON.toJSONString(equipmentSpecificIndex));
}
Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(eqSpecId);
Toke toke = remoteSecurityService.getServerToken();
AlarmParam deviceData = new AlarmParam();
......
......@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.fas.business.vo.*;
import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.enums.ReserveEnum;
import com.yeejoin.amos.fas.core.util.DateUtil;
......@@ -105,10 +106,6 @@ import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.business.vo.TopicEntityVo;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
import com.yeejoin.amos.fas.common.enums.CheckStatusEnum;
import com.yeejoin.amos.fas.common.enums.DataRefreshTypeEum;
......@@ -839,11 +836,28 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Async
void protalRuleMessagePush(ProtalDataRo protalData, String token, String product, String appKey) {
String bacthNo = UUID.randomUUID().toString();
String nodeState = protalData.getNodeState();
String name = protalData.getName();
protalData.setBatchNo(bacthNo);
protalData.setOriginalNodeState(protalData.getNodeState());
protalData.setOriginalNodeState(nodeState);
protalData.setUserName(protalData.getCheckUser());
protalData.setPointName(protalData.getName());
protalData.setPointName(name);
try {
EquipmentSpecificIndexVo specificIndexVo = new EquipmentSpecificIndexVo();
specificIndexVo.setId(protalData.getId());
specificIndexVo.setName(name);
specificIndexVo.setCode(protalData.getPointNo());
specificIndexVo.setType("patrol");
specificIndexVo.setNameKey("patrol");
if ("2".equals(nodeState) || "3".equals(nodeState)) {
specificIndexVo.setValue("true");
} else {
specificIndexVo.setValue("false");
}
// 三维屏巡检点状态推送
String title = String.format("/%s/%s", serviceName, "data/refresh/indexStatus");
webMqttComponent.publish(title, JSON.toJSONString(specificIndexVo));
RequestContext.setToken(token);
RequestContext.setProduct(product);
log.info("巡检消息发送规则" + JSONObject.toJSONString(protalData));
......
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import java.util.List;
import java.util.Map;
/**
......@@ -13,5 +16,7 @@ import java.util.Map;
*/
public interface EquipmentSpecificIndexService {
Map<String, Object> queryInitAlarm(String status, String nameKeys, String pollStatus);
Map<String, Object> queryInitAlarm(String value, String nameKeys, String status);
List<EquipmentSpecificIndexVo> getInitAlarm(String value, String nameKeys, String status);
}
\ No newline at end of file
......@@ -2,9 +2,7 @@ package com.yeejoin.amos.fas.business.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
......@@ -17,8 +15,6 @@ import lombok.EqualsAndHashCode;
*/
@Data
@Api("巡检点Vo")
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
public class PollPointVo {
@ApiModelProperty("巡检点名称")
......@@ -29,4 +25,5 @@ public class PollPointVo {
@ApiModelProperty("巡检点状态:0 未纳入巡检,1 合格;2 不合格;3 漏检")
private String status;
}
\ No newline at end of file
......@@ -31,17 +31,50 @@
<select id="queryInitAlarm" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo">
SELECT
wed.id,
wed.`name`,
wed.`code`,
wei.name_key
wei.name_key,
wei.`name` AS equipmentIndexName,
wsi.`value`
FROM
`wl_equipment_specific_index` wsi
LEFT JOIN wl_equipment_index wei ON wsi.equipment_index_id = wei.id
LEFT JOIN wl_equipment_specific wes ON wsi.equipment_specific_id = wes.id
LEFT JOIN wl_equipment_detail wed ON wed.id = wes.equipment_detail_id
<where>
<if test="value != null and value != ''">
AND wsi.`value` = #{value}
</if>
<if test="list != null and list.length > 0">
AND
<foreach collection="list" item="item" index="index" open="(" close=")" separator="OR">
wei.name_key = #{item}
</foreach>
</if>
</where>
GROUP BY
wsi.equipment_specific_id
ORDER BY
wsi.update_date DESC
</select>
<select id="getInitAlarm" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo">
SELECT
wed.id,
wed.`name`,
wed.`code`,
wei.name_key,
wei.`name` AS equipmentIndexName,
wsi.`value`,
'equip' AS type
FROM
`wl_equipment_specific_index` wsi
LEFT JOIN wl_equipment_index wei ON wsi.equipment_index_id = wei.id
LEFT JOIN wl_equipment_specific wes ON wsi.equipment_specific_id = wes.id
LEFT JOIN wl_equipment_detail wed ON wed.id = wes.equipment_detail_id
<where>
<if test="status != null and status != ''">
AND wsi.`value` = #{status}
<if test="value != null and value != ''">
AND wsi.`value` = #{value}
</if>
<if test="list != null and list.length > 0">
AND
......
......@@ -2,8 +2,6 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.fas.business.dao.mapper.PollPointMapper">
<select id="queryInitAlarm" resultType="com.yeejoin.amos.fas.business.vo.PollPointVo">
SELECT
p.`name`,
......@@ -20,4 +18,29 @@
</if>
</where>
</select>
<select id="getInitAlarm" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo">
SELECT
p.id,
p.`name`,
p.point_no AS `code`,
'patrol' AS type,
'patrol' AS nameKey,
CASE
WHEN p.`status` = '2' THEN
'true'
WHEN p.`status` = '3' THEN
'true' ELSE 'false'
END AS `value`
FROM
`p_point` p
<where>
<if test="list != null and list.length > 0">
AND
<foreach collection="list" item="item" index="index" open="(" close=")" separator="OR">
p.`status` = #{item}
</foreach>
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment