Commit de1edd17 authored by 高东东's avatar 高东东

添加预案代码

parent 8646f87c
...@@ -856,29 +856,27 @@ public class ContingencyAction implements CustomerAction { ...@@ -856,29 +856,27 @@ public class ContingencyAction implements CustomerAction {
public void clearExecute( public void clearExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) { @MethodParam(paramLabel = "重点设备ID") String fireEquipmentId) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode); content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode); content.put("buttonCode", buttonCode);
if (ObjectUtils.isEmpty(fireEquipmentId)) {
DeviceRo ro = (DeviceRo) paramObj; return;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints.remove(stepCode + "-" + buttonCode);
} }
String batchNo = planDetailMapper.queryBatchNoByFireEquipmentId(fireEquipmentId);
if (ObjectUtils.isEmpty(batchNo)) {
return;
}
content.put("batchNo",batchNo );
tempmap1.put("type", "buttonCache"); tempmap1.put("type", "buttonCache");
if (!ObjectUtils.isEmpty(equipemtnPoints)) { tempmap1.put("content",content);
tempmap1.put("content", equipemtnPoints.values());
} else {
tempmap1.put("content", new ArrayList());
}
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", ro, result); this.sendcmd("message", result);
} }
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案") @RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
...@@ -916,7 +914,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -916,7 +914,7 @@ public class ContingencyAction implements CustomerAction {
} }
} }
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) { public void sendcmd(String msgType, SafteyPlanResult result) {
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName( constructor = Class.forName(
...@@ -924,7 +922,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -924,7 +922,7 @@ public class ContingencyAction implements CustomerAction {
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, null, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
...@@ -933,11 +931,8 @@ public class ContingencyAction implements CustomerAction { ...@@ -933,11 +931,8 @@ public class ContingencyAction implements CustomerAction {
event.setMsgBody(toipResponse.toJsonStr()); event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic); event.setTopic(topic);
event.setMsgType(msgType); event.setMsgType(msgType);
event.setContingency(deviceRo);
contingencyLogPublisher.publish(event); contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())) { }
action.execute(msgType, deviceRo);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -13,12 +13,22 @@ public class DeviceRo implements Serializable{ ...@@ -13,12 +13,22 @@ public class DeviceRo implements Serializable{
/** /**
* *
*/ */
private static final long serialVersionUID = 299646964348882067L; private static final long serialVersionUID = 7404825884689318992L;
@Label("点编码") @Label("点编码")
private String pointCode; private String pointCode;
@Label("值") @Label("值")
private String value; private String value;
@Label("重点装备ID") @Label("装备ID")
private Long equipmentId; private Long equipmentId;
@Label("装备编码")
private String equipmentCode;
@Label("重点装备编码")
private String equipmentSpecificCode;
@Label("重点装备ID")
private Long equipmentSpecificId;
@Label("物联编码")
private String iotCode;
@Label("物联指标KEY")
private String equipmentIndexKey;
} }
...@@ -45,4 +45,5 @@ public interface ImpAndFireEquipMapper extends BaseMapper { ...@@ -45,4 +45,5 @@ public interface ImpAndFireEquipMapper extends BaseMapper {
EquipmentSpecificIndexVo findFireEqupmentByCode(String code); EquipmentSpecificIndexVo findFireEqupmentByCode(String code);
} }
...@@ -54,4 +54,7 @@ public interface PlanDetailMapper { ...@@ -54,4 +54,7 @@ public interface PlanDetailMapper {
Integer planReset(@Param("date") Date date); Integer planReset(@Param("date") Date date);
List<PlanDetailSyncBo> getPlanDetailSyncBoList(Map<String, Object> map); List<PlanDetailSyncBo> getPlanDetailSyncBoList(Map<String, Object> map);
String queryBatchNoByFireEquipmentId(@Param("fireEquipmentId") String fireEquipmentId);
} }
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PlanDetail; import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -22,4 +24,5 @@ public interface IPlanDetailDao extends BaseDao<PlanDetail, Long> { ...@@ -22,4 +24,5 @@ public interface IPlanDetailDao extends BaseDao<PlanDetail, Long> {
List<PlanDetail> getPlanDetailsByIdInAndIsDelete(List<Long> idList, Boolean isDelete); List<PlanDetail> getPlanDetailsByIdInAndIsDelete(List<Long> idList, Boolean isDelete);
boolean existsByClassifyIdInAndIsDelete(Collection<Long> classifyList, Boolean isDelete); boolean existsByClassifyIdInAndIsDelete(Collection<Long> classifyList, Boolean isDelete);
} }
...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists; ...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.yeejoin.amos.component.rule.RuleTrigger; import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe; import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe;
import com.yeejoin.amos.fas.business.bo.SafetyExecuteBo; import com.yeejoin.amos.fas.business.bo.SafetyExecuteBo;
...@@ -74,6 +75,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -74,6 +75,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Value("${integrated3Dtype}") @Value("${integrated3Dtype}")
private String integrated3Dtype; private String integrated3Dtype;
@Value("${plan.dynamic.execut.topic}")
private String planDynamicExecutTopic;
@Autowired @Autowired
private WebMqttComponent webMqttComponent; private WebMqttComponent webMqttComponent;
...@@ -277,9 +281,35 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -277,9 +281,35 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
String title = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/monitorData"); String title = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/monitorData");
webMqttComponent.publish(title, JSON.toJSONString(view3dService.getEquipStatusList(equipmentSpecific.getOrgCode()))); webMqttComponent.publish(title, JSON.toJSONString(view3dService.getEquipStatusList(equipmentSpecific.getOrgCode())));
} }
DeviceRo deviceRo = new DeviceRo();
// Equipment equipment1 = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(eqSpecId);
// deviceRo.setEquipmentCode(equipment1.getCode());
// deviceRo.setEquipmentId(equipment1.getId());
deviceRo.setEquipmentSpecificId(equipmentSpecific.getId());
deviceRo.setEquipmentSpecificCode(equipmentSpecific.getCode());
deviceRo.setIotCode(equipmentSpecific.getIotCode());
deviceRo.setValue(equipmentSpecificIndex.getValue());
deviceRo.setEquipmentIndexKey(equipmentSpecificIndex.getNameKey());
planAutoExec(equipment, toke, deviceRo);
} }
@Async /**
* 触发规则(用来)动态执行规则步骤
* @param equipment
* @param toke
* @param deviceRo
*/
private void planAutoExec(Equipment equipment, Toke toke, DeviceRo deviceRo) {
try {
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
ruleTrigger.publish(deviceRo, planDynamicExecutTopic, new String[] {});
} catch (Exception e) {
e.printStackTrace();
}
}
@Async
public void sendWaterLevel(FormInstanceVo formInstanceVo) { public void sendWaterLevel(FormInstanceVo formInstanceVo) {
try { try {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "analogue"); String topic = String.format("/%s/%s/%s", serviceName, stationName, "analogue");
......
...@@ -131,6 +131,9 @@ public class RuleRunigSnapshotServiceImpl ...@@ -131,6 +131,9 @@ public class RuleRunigSnapshotServiceImpl
} else { } else {
batchNo = (String) redisTemplate.opsForValue().get(RiskSourceServiceImpl.cacheKeyForCanBeRunning()); batchNo = (String) redisTemplate.opsForValue().get(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
} }
if (ObjectUtils.isEmpty(batchNo)) {
return;
}
RuleRuningSnapshot ruleRuningSnapshot = new RuleRuningSnapshot(); RuleRuningSnapshot ruleRuningSnapshot = new RuleRuningSnapshot();
ruleRuningSnapshot.setId(UUID.randomUUID().toString()); ruleRuningSnapshot.setId(UUID.randomUUID().toString());
ruleRuningSnapshot.setMethodClass("com.yeejoin.amos.fas.business.action.ContingencyAction"); ruleRuningSnapshot.setMethodClass("com.yeejoin.amos.fas.business.action.ContingencyAction");
......
...@@ -80,3 +80,5 @@ integrated3Dtype =web ...@@ -80,3 +80,5 @@ integrated3Dtype =web
#数据同步开关 #数据同步开关
systemctl.sync.switch=true systemctl.sync.switch=true
plan.dynamic.execut.topic=\u6362\u6D41\u7AD9\u6D88\u9632\u4E13\u9879\u9884\u6848/autoExec
...@@ -161,4 +161,20 @@ ...@@ -161,4 +161,20 @@
</if> </if>
</where> </where>
</select> </select>
<select id="queryBatchNoByFireEquipmentId" resultType="String" >
SELECT
p.batch_no
FROM
f_equipment_fire_equipment fe
RIGHT JOIN f_equipment e ON fe.equipment_id = e.id
RIGHT JOIN c_plan_operation_record p ON e.id = p.fire_equipment_id
WHERE
fe.fire_equipment_id = #{fireEquipmentId}
AND p.end_time is null
AND p.`status` = 0
ORDER BY p.start_time desc
limit 0, 1
</select>
</mapper> </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