Commit 6f5819ae authored by suhuiguang's avatar suhuiguang

1.修改消息

parent f2771e3f
......@@ -45,4 +45,8 @@ public interface PlanDetailMapper {
List<PlanDetailVo> filterList(@Param("planName") String planName, @Param("classifyId") List<Long> classifyId, @Param("planRange") List<String> planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight, @Param("start") int start, @Param("size") int size);
List<String> getRuleIdByEquipment(@Param("id") Long id);
PlanDetailVo getPlanDetailByEquipmentId(@Param("fire_equipment_id") Long fireEquipmentId);
}
package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.fas.business.action.CustomerAction;
......@@ -26,6 +27,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper;
......@@ -44,18 +46,12 @@ import java.util.*;
public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private final Logger logger = LogManager.getLogger(ContingencyPlanServiceImpl.class);
@Autowired
private IEquipmentService equipmentService;
@Autowired
private IRiskSourceService riskSourceService;
@Autowired
private IPlanOperationRecordDao planOperationRecordDao;
@Autowired
private IEquipmentFireEquipmentDao equipmentFireEquipmentDao;
@Qualifier("iEquipmentDao")
@Autowired
private IEquipmentDao equipmentDao;
@Autowired
private EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired
......@@ -67,8 +63,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private CustomerAction customerAction;
@Value("${now.gateway.address}")
private String gateWayAddress;
// @Value("${number.plan.projectName}")
// private String projectName;
private final PlanOperationRecordMapper planOperationRecordMapper;
private final IPlanDetailDao planDetailDao;
private final IPlanDocDao planDocDao;
......@@ -84,6 +78,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Autowired
IContingencyInstance iContingencyInstance;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Autowired
public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao,
IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper,
PlanEquipmentMapper planEquipmentMapper, PlanRuleMapper planRuleMapper, PlanDocMapper planDocMapper,
......@@ -119,7 +118,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
Optional<PlanDetail> PlanDetailOp = planDetailDao.findById(Long.valueOf(vo.getPlanId()));
List<PlanEquipment> equipmentList = planEquipmentDao.findByPlanId(PlanDetailOp.get().getId());
//预案启动
if (PlanDetailOp.get() != null) {
//获取规则名称
List<PlanRule> planRuleList = planRuleDao.getPlanDocsByPlanId(Long.valueOf(vo.getPlanId()));
if (planRuleList.size() == 0) {
......@@ -135,17 +133,27 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
equipment.setReservePlan("换流站消防专项预案" + "/" + planRuleList.get(0).getRuleId());
//电力设备绑定装备
EquipmentSpecificForRiskVo equipmentSpecific;
if(vo.getFireEquipmentId() != null){
equipmentSpecific = equipmentSpecificMapper.getOneById(vo.getFireEquipmentId());
//不会为null 在告警处理时已经判断过
if (equipmentSpecific == null) {
result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备");
return result;
}
} else {
List<EquipmentFireEquipment> equipmentFireEquipmentList = equipmentFireEquipmentDao.findAllByEquipmentId(equipmentList.get(0).getFireEquipmentId());
if (equipmentFireEquipmentList.size() == 0) {
result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备");
return result;
}
//查询设备
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(equipmentFireEquipmentList.get(0).getFireEquipmentId());
equipmentSpecific = equipmentSpecificMapper.getOneById(equipmentFireEquipmentList.get(0).getFireEquipmentId());
if (equipmentSpecific == null) {
result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备");
return result;
}
}
//插入运行记录表
PlanOperationRecord planOperationRecord = new PlanOperationRecord();
......@@ -168,7 +176,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord);
//预案启动
AlarmParam deviceData = new AlarmParam();
deviceData.setMonitor(equipment != null ? equipment.getName() : "");
deviceData.setMonitor(equipment.getName());
deviceData.setId(String.valueOf(equipmentSpecific.getId()));
deviceData.setCode(equipmentSpecific.getCode());
String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, operationRecord.getId());
......@@ -182,7 +190,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
result.setMessage(ReserveEnum.RUN.getText());
result.setBatchNo(batchNo);
}
}
return result;
}
......@@ -644,21 +651,23 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} catch (MqttException e) {
logger.fatal("订阅规则删除同步消息失败,资源删除或取消无法同步", e);
}
/*try {
emqKeeper.getMqttClient().subscribe(DELETE_SYNC_PLAN_EQUIP, (s, mqttMessage) -> {
byte[] payload = mqttMessage.getPayload();
try {
List<Long> ids = (List<Long>) ClazzUtils.deserializableObject(payload);
if (!ValidationUtil.isEmpty(ids)) {
planEquipmentMapper.logicDeleteByEquipIdList(ids);
emqKeeper.getMqttClient().subscribe(VIEW_3D_OPEN_STATUS, (s, mqttMessage) -> {
Map msg = JSON.parseObject(mqttMessage.toString());
if(msg.containsKey("status") && msg.containsKey("seq")){
String seq = msg.get("seq").toString();
String status = msg.get("status").toString();
String key = KEY_VIEW_3D_PAGE + seq;
if("offLine".equals(status)){
redisTemplate.delete(key);
} else {
redisTemplate.opsForValue().set(key,status);
}
} catch (Exception e) {
logger.error("预案保护对象删除同步出错", e);
}
});
} catch (MqttException e) {
logger.fatal("订阅保护对象删除同步消息失败,资源删除或取消无法同步", e);
}*/
logger.fatal("订阅规则删除同步消息失败,资源删除或取消无法同步", e);
}
}
}
\ No newline at end of file
......@@ -23,14 +23,19 @@ public interface IContingencyPlanService {
String DELETE_SYNC_PLAN_DOC = "DELETE_SYNC_PLAN_DOC";
String DELETE_SYNC_PLAN_RULE = "urule/package/remove";
String DELETE_SYNC_PLAN_EQUIP = "DELETE_SYNC_PLAN_EQUIP";
String VIEW_3D_OPEN_STATUS = "/view/3d/page";
/**
* 3d用戶在线redis key前缀
*/
String KEY_VIEW_3D_PAGE = "KEY_VIEW_3D_PAGE_";
ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke) throws Exception;
ContingencyPlanParamVo equipmentScene(Long equipmentId,String riskType );
ContingencyPlanParamVo equipmentScene(Long equipmentId, String riskType);
/**
* 创建
*
* @param planDetail
* @return
*/
......@@ -39,6 +44,7 @@ public interface IContingencyPlanService {
/**
* 编辑
*
* @param planDetail
* @return
*/
......@@ -47,6 +53,7 @@ public interface IContingencyPlanService {
/**
* 单个详情
*
* @param id
* @return
*/
......@@ -54,6 +61,7 @@ public interface IContingencyPlanService {
/**
* 启用
*
* @param idList
* @return
*/
......@@ -61,6 +69,7 @@ public interface IContingencyPlanService {
/**
* 停用
*
* @param idList
* @return
*/
......@@ -68,6 +77,7 @@ public interface IContingencyPlanService {
/**
* 删除
*
* @param idList
* @return
*/
......@@ -76,6 +86,7 @@ public interface IContingencyPlanService {
/**
* 分页查询
*
* @param page 分页
* @param planName 预案名称
* @param classifyId 预案类型
......@@ -89,18 +100,21 @@ public interface IContingencyPlanService {
/**
* 查询预案使用的文档ID
*
* @return
*/
Map<Long, Long> getPlanUsedDocs();
/**
* 查询预案使用的规则ID
*
* @return
*/
Map<String, Long> getPlanUsedRules();
/**
* 查询预案使用的装备ID
*
* @return
*/
Map<Long, Long> getPlanUsedEquipments();
......@@ -112,7 +126,7 @@ public interface IContingencyPlanService {
Map<String, Object> firstGetRecord(String batchNo);
List<HashMap<String,Object>> getRecordList(String batchNo);
List<HashMap<String, Object>> getRecordList(String batchNo);
Page recordListByPage(Page page, Long planId, String planName, List<Long> classifyId, Date startTimeLeft, Date startTimeRight, Integer executionType, Integer planPattern);
......
package com.yeejoin.amos.fas.business.vo;
//请求参数
import lombok.Data;
/**
* @author DELL
*/
@Data
public class ContingencyPlanParamVo {
public Long fireEquipmentId;
public String planId;
public Integer status;
......@@ -11,44 +18,5 @@ public class ContingencyPlanParamVo {
public String riskType;
public String userName;
public String userId;
public String getPlanId() {
return planId;
}
public void setPlanId(String planId) {
this.planId = planId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getRiskType() {
return riskType;
}
public void setRiskType(String riskType) {
this.riskType = riskType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
......@@ -24,7 +24,7 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
private IContingencyPlanService contingencyPlanService;
@Override
public void run(ApplicationArguments args) throws Exception {
public void run(ApplicationArguments args) {
equipmentHandlerService.subscribeTopic();
contingencyPlanService.subscribeTopic();
}
......
......@@ -121,4 +121,16 @@
AND equip.is_delete != 1
AND rule.is_delete !=1
</select>
<select id="getPlanDetailByEquipmentId" resultType="com.yeejoin.amos.fas.business.vo.PlanDetailVo">
select
d.id,
d.status
from
c_plan_detail d,
c_plan_equipment e
where e.plan_id = d.id
and e.fire_equipment_id=#{fireEquipmentId}
and d.is_delete = false
limit 1
</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