Commit c23e993b authored by maoying's avatar maoying

解决冲突

parents 064cdd91 2882a6f5
package com.yeejoin.amos.fas.common.enums;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
* @Package: com.yeejoin.amos.fas.common.enums
* @ClassName: SqlKeyWordEnum
* @Author: Jianqiang Gao
* @Description: SqlKeyWordEnum
* @Date: 2022/5/20 17:59
* @Version: 1.0
*/
public enum SqlKeyWordEnum {
AND("and", "并且"),
OR("or", "或者");
private String key;
private String value;
SqlKeyWordEnum(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@RuleFact(value = "动态预案",project = "换流站消防专项预案")
......@@ -94,4 +95,7 @@ public class ContingencyRo implements Serializable {
private String fireMonitorCodes;
@Label("消防炮id")
private String fireMonitorIds;
@Label("参数map")
private Map<String, Object> params = new HashMap<>();
}
package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentFireEquipmentService;
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;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
* @Package: com.yeejoin.amos.fas.business.controller
* @ClassName: equipmentFireEquipmentController
* @Author: Jianqiang Gao
* @Description: equipmentFireEquipmentController
* @Date: 2022/5/23 10:11
* @Version: 1.0
*/
@RestController
@RequestMapping(value = "/api/equipFireEquip")
public class equipmentFireEquipmentController {
@Autowired
private IEquipmentFireEquipmentService equipmentFireEquipmentService;
@ApiOperation(value = "判断是否自动执行", notes = "判断是否自动执行")
@GetMapping("/automaticExecute")
public Object automaticExecute(@RequestParam(required = false) String equipmentId,
@RequestParam(required = false) String equipCode,
@RequestParam(required = false) String equipSpeCode,
@RequestParam(required = false) String type,
@RequestParam(required = false) String indexKeys,
@RequestParam(required = false) String value) {
return equipmentFireEquipmentService.automaticExecute(equipmentId, equipCode, equipSpeCode, type, indexKeys, value);
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 装备性能指标 Mapper 接口
......@@ -19,4 +20,6 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif
List<EquipmentSpecificIndexVo> queryInitAlarm(@Param("value") String value, @Param("list") String[] nameKeys);
List<EquipmentSpecificIndexVo> getInitAlarm(@Param("value") String value, @Param("list") String[] nameKeys);
Map<String, Object> countEquipIndexAndValueOfNum(@Param("list") List<Long> equipSpecificIdList, @Param("equipCodes") String[] equipCodes, @Param("equipSpeCodes") String[] equipSpeCodes, @Param("indexKeys") String[] indexKeys, @Param("value") String value);
}
......@@ -33,4 +33,9 @@ public interface IEquipmentFireEquipmentDao extends BaseDao<EquipmentFireEquipme
@Query(value = "delete FROM `f_equipment_fire_equipment` WHERE equipment_id = ?1", nativeQuery = true)
void deleteByEquipmentId(Long id);
@Query(value = "SELECT ffe.* FROM f_equipment_fire_equipment ffe LEFT JOIN wl_equipment_specific es ON ffe.fire_equipment_id = es.id LEFT JOIN wl_equipment_detail ed ON es.equipment_detail_id = ed.id WHERE ffe.equipment_id = ?1 AND ed.`code` IN ?2", nativeQuery = true)
List<EquipmentFireEquipment> findByEquipIdAndEquipCodeIn(Long equipmentId, String[] equipCodes);
@Query(value = "SELECT ffe.* FROM f_equipment_fire_equipment ffe LEFT JOIN wl_equipment_specific es ON ffe.fire_equipment_id = es.id WHERE ffe.equipment_id = ?1 AND es.`code` IN ?2", nativeQuery = true)
List<EquipmentFireEquipment> findByEquipIdAndEquipSpeCodeIn(Long equipmentId, String[] equipSpeCodes);
}
package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.repository.IEquipmentFireEquipmentDao;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificIndexService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentFireEquipmentService;
import com.yeejoin.amos.fas.common.enums.SqlKeyWordEnum;
import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
* @Package: com.yeejoin.amos.fas.business.service.impl
* @ClassName: EquipmentFireEquipmentServiceImpl
* @Author: Jianqiang Gao
* @Description:
* @Date: 2022/5/20 14:40
* @Version: 1.0
*/
@Service
public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmentService {
private final Logger log = LoggerFactory.getLogger(EquipmentFireEquipmentServiceImpl.class);
private static final String TYPE = "or";
private static final String VALUE = "true";
@Autowired
private IEquipmentFireEquipmentService equipmentFireEquipmentService;
@Autowired
private EquipmentSpecificIndexService equipmentSpecificIndexService;
@Autowired
private IEquipmentFireEquipmentDao equipmentFireEquipmentDao;
@Override
public List<EquipmentFireEquipment> findByEquipmentId(Long equipmentId) {
return equipmentFireEquipmentDao.findAllByEquipmentId(equipmentId);
}
@Override
public List<EquipmentFireEquipment> findByEquipIdAndEquipCodeIn(Long equipmentId, String[] equipCodes) {
return equipmentFireEquipmentDao.findByEquipIdAndEquipCodeIn(equipmentId, equipCodes);
}
@Override
public List<EquipmentFireEquipment> findByEquipIdAndEquipSpeCodeIn(Long equipmentId, String[] equipSpeCodes) {
return equipmentFireEquipmentDao.findByEquipIdAndEquipSpeCodeIn(equipmentId, equipSpeCodes);
}
@Override
public Object automaticExecute(String equipmentId, String equipCode, String equipSpeCode, String type, String indexKeys, String value) {
Map<String, Object> map = null;
if (StringUtils.isBlank(type)) {
type = TYPE;
}
if (StringUtils.isBlank(value)) {
value = VALUE;
}
if (StringUtils.isNotBlank(equipmentId)) {
// 1. 查询重点设备绑定的消防设备
List<EquipmentFireEquipment> list = null;
if (StringUtils.isBlank(equipSpeCode)) {
if (StringUtils.isBlank(equipCode)) {
list = equipmentFireEquipmentService.findByEquipmentId(Long.parseLong(equipmentId));
} else {
list = equipmentFireEquipmentService.findByEquipIdAndEquipCodeIn(Long.parseLong(equipmentId), equipCode.split(","));
}
} else {
list = equipmentFireEquipmentService.findByEquipIdAndEquipSpeCodeIn(Long.parseLong(equipmentId), equipSpeCode.split(","));
}
if (!CollectionUtils.isEmpty(list)) {
List<Long> equipSpecificIdList = list.stream().map(EquipmentFireEquipment::getFireEquipmentId).collect(Collectors.toList());
// 2 获取消防设备满足条件的集合
if (StringUtils.isNotBlank(indexKeys)) {
map = equipmentSpecificIndexService.countEquipIndexAndValueOfNum(equipSpecificIdList, null, null, indexKeys.split(","), value);
} else {
map = equipmentSpecificIndexService.countEquipIndexAndValueOfNum(equipSpecificIdList, null, null, null, value);
}
}
} else {
// 不存在重点设备,直接查消防设备
if (StringUtils.isNotBlank(equipSpeCode)) {
if (StringUtils.isNotBlank(indexKeys)) {
map = equipmentSpecificIndexService.countEquipIndexAndValueOfNum(null, null, equipSpeCode.split(","), indexKeys.split(","), value);
} else {
map = equipmentSpecificIndexService.countEquipIndexAndValueOfNum(null, null, equipSpeCode.split(","), null, value);
}
} else if (StringUtils.isNotBlank(equipCode)) {
if (StringUtils.isNotBlank(indexKeys)) {
map = equipmentSpecificIndexService.countEquipIndexAndValueOfNum(null, equipCode.split(","), null, indexKeys.split(","), value);
} else {
map = equipmentSpecificIndexService.countEquipIndexAndValueOfNum(null, equipCode.split(","), null, null, value);
}
}
}
if (!CollectionUtils.isEmpty(map)) {
Integer total = Integer.parseInt(map.get("total").toString());
Integer count = Integer.parseInt(map.get("count").toString());
if (SqlKeyWordEnum.AND.getKey().equalsIgnoreCase(type)) {
if (total.equals(count)) {
return true;
}
} else if (SqlKeyWordEnum.OR.getKey().equalsIgnoreCase(type)) {
if (count != 0) {
return true;
}
}
}
return false;
}
}
......@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
* @Package: com.yeejoin.amos.fas.business.service.impl
* @ClassName: EquipmentSpecificIndexServiceImpl
* @Author: Jianqiang Gao
* @Description: EquipmentSpecificIndexServiceImpl
* @Description: EquipmentSpecificIndexServiceImpl
* @Date: 2021/1/18 16:35
* @Version: 1.0
*/
......@@ -38,7 +38,7 @@ public class EquipmentSpecificIndexServiceImpl implements EquipmentSpecificIndex
List<EquipmentSpecificIndexVo> equipmentSpecificAlarmVoList = equipmentSpecificIndexMapper.queryInitAlarm(value, nameKeys.split(","));
map.put("equip", equipmentSpecificAlarmVoList);
// 查询巡检告警
List<PollPointVo> pollPointVoList = pollPointMapper.queryInitAlarm(status.split(","));
List<PollPointVo> pollPointVoList = pollPointMapper.queryInitAlarm(status.split(","));
map.put("poll", pollPointVoList);
return map;
}
......@@ -48,8 +48,13 @@ public class EquipmentSpecificIndexServiceImpl implements EquipmentSpecificIndex
// 查询设备告警
List<EquipmentSpecificIndexVo> equipmentSpecificAlarmVoList = equipmentSpecificIndexMapper.getInitAlarm(value, nameKeys.split(","));
// 查询巡检告警
List<EquipmentSpecificIndexVo> pollPointVoList = pollPointMapper.getInitAlarm(status.split(","));
List<EquipmentSpecificIndexVo> pollPointVoList = pollPointMapper.getInitAlarm(status.split(","));
pollPointVoList.stream().sequential().collect(Collectors.toCollection(() -> equipmentSpecificAlarmVoList));
return equipmentSpecificAlarmVoList;
}
@Override
public Map<String, Object> countEquipIndexAndValueOfNum(List<Long> equipSpecificIdList, String[] equipCodes, String[] equipSpeCodes, String[] indexKeys, String value) {
return equipmentSpecificIndexMapper.countEquipIndexAndValueOfNum(equipSpecificIdList, equipCodes, equipSpeCodes, indexKeys, value);
}
}
\ No newline at end of file
......@@ -8,7 +8,6 @@ import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe;
import com.yeejoin.amos.fas.business.bo.PlanFlagBo;
import com.yeejoin.amos.fas.business.bo.SafetyExecuteBo;
import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
......@@ -27,7 +26,6 @@ import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum;
import com.yeejoin.amos.fas.core.util.StringUtil;
import com.yeejoin.amos.fas.dao.entity.*;
import org.apache.commons.lang3.ArrayUtils;
//import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -71,10 +69,10 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Value("${data.type.fireMonitor}")
private String fireMonitor;
@Value("${integrated3Dtype}")
private String integrated3Dtype;
@Autowired
private WebMqttComponent webMqttComponent;
......@@ -156,8 +154,8 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
Long eqSpecId = equipmentSpecificIndex.getEquipmentSpecificId();
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(eqSpecId);
log.info("========equipmentSpecific==========: " + JSON.toJSONString(equipmentSpecific));
if(ObjectUtils.isEmpty(equipmentSpecific)){
return;
if (ObjectUtils.isEmpty(equipmentSpecific)) {
return;
}
String specificIndexType = equipmentSpecificIndex.getType();
String typeCode = equipmentSpecificIndex.getTypeCode();
......@@ -177,10 +175,10 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
sendWaterLevel(formInstanceVo);
}
}
if(topicEntity.getSimulationDate().equals("false") && nameKeys.contains(typeCode) && indexStateIsChange(equipmentSpecificIndex)){
log.info("指标值没有发生变化: " + equipmentSpecificIndex.getIotCode()+"-"+equipmentSpecificIndex.getNameKey()+":"+equipmentSpecificIndex.getValue());
if (topicEntity.getSimulationDate().equals("false") && nameKeys.contains(typeCode) && indexStateIsChange(equipmentSpecificIndex)) {
log.info("指标值没有发生变化: " + equipmentSpecificIndex.getIotCode() + "-" + equipmentSpecificIndex.getNameKey() + ":" + equipmentSpecificIndex.getValue());
// 三维屏指标状态推送
equipmentSpecificIndex.setId(equipmentSpecific.getId());
equipmentSpecificIndex.setName(equipmentSpecific.getName());
equipmentSpecificIndex.setCode(equipmentSpecific.getCode());
......@@ -201,7 +199,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
// }
}
Equipment equipment = topicEntity.getEquipment()==null?impAndFireEquipMapper.queryImpEqumtByFireEquipmt(eqSpecId):topicEntity.getEquipment();
Equipment equipment = topicEntity.getEquipment() == null ? impAndFireEquipMapper.queryImpEqumtByFireEquipmt(eqSpecId) : topicEntity.getEquipment();
Toke toke = remoteSecurityService.getServerToken();
AlarmParam deviceData = new AlarmParam();
......@@ -254,7 +252,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
String dateString = formatter.format(new Date());
String topicOne = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(equipmentSpecific.getOrgCode(), dateString)));
refreshFireSafety(equipmentSpecific.getOrgCode());
} else {
// 监测数据逻辑
......@@ -286,26 +284,27 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
/**
* 三维故障火警模块推送最新5条数据
*
* @param orgCode
*/
private void refreshFireSafety(String orgCode){
String title = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "fireSafety");
private void refreshFireSafety(String orgCode) {
String title = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "fireSafety");
List<SafetyExecuteBo> dataList = view3dService.getSafetyExecuteListTop5("fire", orgCode);
Map<String, Object> result = new HashMap<>();
result.put("type", "fire");
result.put("dataList", dataList);
webMqttComponent.publish(title, JSON.toJSONString(result));
}
private void startPlan(Equipment equipment, Toke toke, Long fireEquipmentId) {
PlanDetailVo planDetailVo = planDetailMapper.getPlanDetailByEquipmentId(equipment.getId());
//3d页面打开且存在预案,套用之前数字源码启动逻辑 进行预案的启动
boolean isOnLine = "web".equals(integrated3Dtype)?this.getOpen3dUser():true;
//this.getOpen3dUser();
log.info("isOnLine==="+isOnLine);
log.info("planDetailVo==="+JSONObject.toJSONString(planDetailVo));
boolean isOnLine = "web".equals(integrated3Dtype) ? this.getOpen3dUser() : true;
//this.getOpen3dUser();
log.info("isOnLine===" + isOnLine);
log.info("planDetailVo===" + JSONObject.toJSONString(planDetailVo));
if (planDetailVo != null && isOnLine) {
ContingencyPlanParamVo vo = new ContingencyPlanParamVo();
vo.setUserId(loginId);
......@@ -510,7 +509,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
contingencyRo.setEquipmentPosition3d(equipment.getPosition3d());
contingencyRo.setEquipmentCode(equipment.getCode());
contingencyRo.setEquipmentOrgCode(equipment.getOrgCode());
contingencyRo.getParams().put("equipmentId", equipment.getId());
//查询重点设备关联视频点位
Map<String, Object> cameraInfo = impAndFireEquipMapper.queryCamera(String.valueOf(equipment.getId()));
if (cameraInfo != null && !cameraInfo.isEmpty()) {
......
......@@ -19,4 +19,6 @@ public interface EquipmentSpecificIndexService {
Map<String, Object> queryInitAlarm(String value, String nameKeys, String status);
List<EquipmentSpecificIndexVo> getInitAlarm(String value, String nameKeys, String status);
Map<String, Object> countEquipIndexAndValueOfNum(List<Long> equipSpecificIdList, String[] equipCodes, String[] equipSpeCodes, String[] indexKeys, String value);
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment;
import java.util.List;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
* @Package: com.yeejoin.amos.fas.business.service
* @ClassName: IEquipmentFireEquipmentService
* @Author: Jianqiang Gao
* @Description:
* @Date: 2022/5/20 14:40
* @Version: 1.0
*/
public interface IEquipmentFireEquipmentService {
List<EquipmentFireEquipment> findByEquipmentId(Long equipmentId);
List<EquipmentFireEquipment> findByEquipIdAndEquipCodeIn(Long equipmentId, String[] equipCodes);
List<EquipmentFireEquipment> findByEquipIdAndEquipSpeCodeIn(Long equipmentId, String[] equipSpeCodes);
Object automaticExecute(String equipmentId, String equipCode, String equipSpeCode, String type, String indexKeys, String value);
}
......@@ -88,35 +88,44 @@
ORDER BY
wes.realtime_iot_index_update_date DESC
</select>
<!-- <select id="getInitAlarm" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo">-->
<!-- SELECT-->
<!-- concat(wes.id) as id,-->
<!-- concat(wes.id) as equipmentSpecificId,-->
<!-- wed.`name`,-->
<!-- wes.`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-->
<!-- wei.is_iot = 1 -->
<!-- <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.type_code = #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- GROUP BY-->
<!-- wsi.equipment_specific_id-->
<!-- ORDER BY-->
<!-- wsi.update_date DESC-->
<!-- </select>-->
<select id="countEquipIndexAndValueOfNum" resultType="map">
SELECT
COUNT( 1 ) AS total,
IF
(
SUM( IF ( esi.`value` = #{value}, 1, 0 ) ) IS NULL,
0,
SUM( IF ( esi.`value` = #{value}, 1, 0 ) )
) AS count
FROM
`wl_equipment_specific_index` esi
LEFT JOIN wl_equipment_specific es ON esi.equipment_specific_id = es.id
LEFT JOIN wl_equipment_detail ed ON es.equipment_detail_id = ed.id
<where>
<if test="list != null and list.size() > 0">
AND esi.equipment_specific_id IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="equipCodes != null and equipCodes.length > 0">
AND ed.`code` IN
<foreach collection="equipCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="equipSpeCodes != null and equipSpeCodes.length > 0">
AND es.`code` IN
<foreach collection="equipSpeCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="indexKeys != null and indexKeys.length > 0">
AND esi.equipment_index_key IN
<foreach collection="indexKeys" item="item" index="index" open="(" close=")" separator=",">
#{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