Commit 0d1cb7cd authored by 高东东's avatar 高东东

Merge branch 'gaodongdong' into dev_upgrade_rule

parents 3d1733d8 636f3615
...@@ -12,14 +12,18 @@ import java.util.Date; ...@@ -12,14 +12,18 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -28,6 +32,7 @@ import com.yeejoin.amos.component.rule.MethodParam; ...@@ -28,6 +32,7 @@ import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean; import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod; import com.yeejoin.amos.component.rule.RuleMethod;
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.model.SetpEnum; import com.yeejoin.amos.fas.business.action.model.SetpEnum;
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.result.ActionResult; import com.yeejoin.amos.fas.business.action.result.ActionResult;
...@@ -35,13 +40,17 @@ import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult; ...@@ -35,13 +40,17 @@ import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage; import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.action.util.StepComparator; import com.yeejoin.amos.fas.business.action.util.StepComparator;
import com.yeejoin.amos.fas.business.feign.IDutyModeServer; import com.yeejoin.amos.fas.business.feign.IDutyModeServer;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl; import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
import com.yeejoin.amos.fas.business.service.intfc.FireStengthService; import com.yeejoin.amos.fas.business.service.intfc.FireStengthService;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance; import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService; import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus; import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.util.HttpUtil; import com.yeejoin.amos.fas.business.util.HttpUtil;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
@Component @Component
...@@ -78,10 +87,15 @@ public class ContingencyAction implements CustomerAction { ...@@ -78,10 +87,15 @@ public class ContingencyAction implements CustomerAction {
@Autowired @Autowired
private IDutyModeServer dutyModeServer; private IDutyModeServer dutyModeServer;
@Autowired
private RedisTemplate redisTemplate;
private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>(); private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>();
private static Map<String, Map<String, String>> stringStringMap = new HashMap<>(); private static Map<String, Map<String, String>> stringStringMap = new HashMap<>();
static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>();
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1) //当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{ /* private static Map<String, String> positionMap = new HashMap<String, String>() {{
...@@ -186,26 +200,65 @@ public class ContingencyAction implements CustomerAction { ...@@ -186,26 +200,65 @@ public class ContingencyAction implements CustomerAction {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
HashMap preStep = new HashMap(); HashMap preStep = new HashMap();
StepComparator comparator = new StepComparator(); StepComparator comparator = new StepComparator();
Arrays.sort(stepArr, comparator);
boolean flage = false;
SetpEnum pstep = null;
for (SetpEnum step : stepArr) { for (SetpEnum step : stepArr) {
if (Long.valueOf(step.getValue()) >= Long.valueOf(stepCode)) { if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode)) {
if (!ObjectUtils.isEmpty(pstep)) {
preStep.put("stepCode", pstep.getValue());
preStep.put("stepName", pstep.getTitle());
}
flage = true;
}
if (flage) {
HashMap map = new HashMap(); HashMap map = new HashMap();
map.put("stepCode", step.getValue()); map.put("stepCode", step.getValue());
map.put("stepName", step.getTitle()); map.put("stepName", step.getTitle());
list.add(map); list.add(map);
} }
else if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode) - 1) { pstep = step;
preStep.put("stepCode", step.getValue());
preStep.put("stepName", step.getTitle());
}
} }
tempmap1.put("step", list); tempmap1.put("step", list);
tempmap1.put("preStep", preStep); tempmap1.put("preStep", preStep);
result.add(tempmap1); result.add(tempmap1);
log.info("巡检消息发送规则" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result); this.sendcmd("steparea", contingencyRo, result);
} }
// public static void main(String[] args) {
// SetpEnum[] stepArr = SetpEnum.values();
// Map<String, Object> tempmap1 = new HashMap<>();
// ArrayList list = new ArrayList();
// HashMap preStep = new HashMap();
// StepComparator comparator = new StepComparator();
// Arrays.sort(stepArr, comparator);
// boolean flage = false;
// SetpEnum pstep = null;
// for (SetpEnum step : stepArr) {
// if (Long.valueOf(step.getValue()) == Long.valueOf("3")) {
// if (!ObjectUtils.isEmpty(pstep)) {
// preStep.put("stepCode", pstep.getValue());
// preStep.put("stepName", pstep.getTitle());
// }
// flage = true;
// }
// if (flage) {
// HashMap map = new HashMap();
// map.put("stepCode", step.getValue());
// map.put("stepName", step.getTitle());
// list.add(map);
// }
// pstep = step;
// }
//
// tempmap1.put("step", list);
// tempmap1.put("preStep", preStep);
// log.info("巡检消息发送规则" + JSONObject.toJSONString(tempmap1));
// }
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
* @param paramObj 预案对象 * @param paramObj 预案对象
...@@ -533,7 +586,155 @@ public class ContingencyAction implements CustomerAction { ...@@ -533,7 +586,155 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
} }
/**
* 启动预案
*
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "启动预案", project = "青海换流站消防预案")
public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "startPlan");
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.opsForValue().set("contingencyRo", contingencyRo);
}
/**
* 启动预案
*
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "结束预案", project = "青海换流站消防预案")
public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan");
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo");
}
private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE";
@Autowired
private RemoteSecurityService remoteSecurityService;
@RuleMethod(methodLabel = "自动执行步骤", project = "青海换流站消防预案")
public void autoExecute(
@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "步骤状态") String stepState,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = cacheMap.getValue(TOKE);
if (toke == null) {
toke = remoteSecurityService.come();
Long times = (long) (20 * 24 * 60 * 60);
cacheMap.setex(TOKE, toke, times);
}
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM");
iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState);
} catch (Exception e) {
e.printStackTrace();
}
}
@RuleMethod(methodLabel = "添加步骤执行", project = "青海换流站消防预案")
public void addExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
result.add(tempmap1);
DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints = new HashMap<>();
}
equipemtnPoints.put(stepCode+"-"+buttonCode, content);
tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
this.sendcmd("message", null, result);
}
@RuleMethod(methodLabel = "清除步骤执行", project = "青海换流站消防预案")
public void clearExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints.remove(stepCode+"-"+buttonCode);
}
tempmap1.put("type", "buttonCache");
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
tempmap1.put("content", equipemtnPoints.values());
} else {
tempmap1.put("content", new ArrayList());
}
tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
@RuleMethod(methodLabel = "同步自动执行步骤", project = "青海换流站消防预案")
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
private void stopSnapshop(ContingencyRo contingencyRo) { private void stopSnapshop(ContingencyRo contingencyRo) {
if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo())) if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo()))
RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull(); RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull();
......
package com.yeejoin.amos.fas.business.action.model;
import java.io.Serializable;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
@RuleFact(value = "设备数据",project = "青海换流站消防预案")
@Data
public class DeviceRo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 299646964348882067L;
@Label("点编码")
private String pointCode;
@Label("值")
private String value;
@Label("重点装备ID")
private Long equipmentId;
}
...@@ -8,17 +8,17 @@ public enum SetpEnum implements RuleConstants{ ...@@ -8,17 +8,17 @@ public enum SetpEnum implements RuleConstants{
STEP1("1", "停运换流阀、拨打报警电话", 1), STEP1("1", "停运换流阀、拨打报警电话", 1),
STEP2("2", "开启水喷雾系统", 2), STEP2("2", "开启水喷雾系统", 2),
STEP3("3", "断开上级电源", 3), STEP3("3", "断开上级电源", 3),
STEP4("10", "开启油枕排油系统", 4), STEP4("4", "开启油枕排油系统", 4),
STEP5("11", "消防炮“一键启动”", 5), STEP5("5", "消防炮“一键启动”", 5),
STEP6("12", "消防供水", 6), // STEP6("6", "消防供水", 6),
STEP7("13", "阀厅防护", 7), STEP7("7", "阀厅防护", 7),
STEP8("14", "本体排油", 8), STEP8("8", "本体排油", 8),
STEP9("4", "停运空调和水冷系统", 9), STEP9("9", "停运空调和水冷系统", 9),
STEP10("5", "驻站消防指挥权准备交接", 10), STEP10("10", "驻站消防指挥权准备交接", 10),
STEP11("6", "驻站消防指挥权交接", 11), STEP11("11", "驻站消防指挥权交接", 11),
STEP12("7", "电缆沟封堵", 12), STEP12("12", "电缆沟封堵", 12),
STEP13("8", "灭火指挥权交接", 13), STEP13("13", "灭火指挥权交接", 13),
STEP14("9", "应急处置结束", 14); STEP14("14", "应急处置结束", 14);
private String stepCode; private String stepCode;
......
...@@ -170,8 +170,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -170,8 +170,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
SetpEnum step = SetpEnum.getStepByCode(stepCode); SetpEnum step = SetpEnum.getStepByCode(stepCode);
contingencyRo.setStep(step.getValue()); contingencyRo.setStep(step.getValue());
contingencyRo.setStepState(stepMap.get(stepKey)); contingencyRo.setStepState(stepMap.get(stepKey));
// contingencyRo.setStep(stepCode);
log.info("stepstate:" + contingencyRo.getStepState()); log.info("stepstate:" + contingencyRo.getStepState());
log.info("stepCode:" + stepCode);
Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId())); Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId()));
// 获取重点设备胚胎指标 // 获取重点设备胚胎指标
// 获取遥信指标 // 获取遥信指标
...@@ -189,7 +190,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -189,7 +190,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
} }
contingencyRo.setTelemetryMap(telemetryMap); contingencyRo.setTelemetryMap(telemetryMap);
ruleTrigger.publish(contingencyRo, "青海换流站消防预案/test", ArrayUtils.toArray("极Ⅰ高端YY换流变B相")); ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
// 刷新记录区 // 刷新记录区
......
...@@ -26,6 +26,7 @@ import org.slf4j.Logger; ...@@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.HashOperations;
...@@ -49,10 +50,12 @@ import com.google.common.collect.Sets; ...@@ -49,10 +50,12 @@ 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.CheckInputItemRo; import com.yeejoin.amos.fas.business.action.model.CheckInputItemRo;
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.model.FireEquimentDataRo; import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo; import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo; import com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo;
import com.yeejoin.amos.fas.business.action.model.SetpEnum; import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.bo.BindRegionBo; import com.yeejoin.amos.fas.business.bo.BindRegionBo;
import com.yeejoin.amos.fas.business.bo.JpushMsgBo; import com.yeejoin.amos.fas.business.bo.JpushMsgBo;
import com.yeejoin.amos.fas.business.bo.JpushMsgContentBo; import com.yeejoin.amos.fas.business.bo.JpushMsgContentBo;
...@@ -516,6 +519,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -516,6 +519,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception { public void alermContingency(String batchNo, FireEquipment fireEquipment, Equipment equipment) throws Exception {
Object oldContingencyRo = redisTemplate.opsForValue().get("contingencyRo");
ContingencyRo contingencyRo = new ContingencyRo(); ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo); contingencyRo.setBatchNo(batchNo);
contingencyRo.setEquipmentId(String.valueOf(equipment.getId())); contingencyRo.setEquipmentId(String.valueOf(equipment.getId()));
...@@ -523,8 +527,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -523,8 +527,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setFireEquipmentId(String.valueOf(fireEquipment.getId())); contingencyRo.setFireEquipmentId(String.valueOf(fireEquipment.getId()));
contingencyRo.setFireEquipmentName(fireEquipment.getName()); contingencyRo.setFireEquipmentName(fireEquipment.getName());
// if (ObjectUtils.isEmpty(oldContingencyRo)) {
// contingencyRo.setStep(SetpEnum.STEP0.getValue());
// } else {
// contingencyRo.setStep(((ContingencyRo)oldContingencyRo).getStep());
// }
contingencyRo.setStep(SetpEnum.STEP0.getValue()); contingencyRo.setStep(SetpEnum.STEP0.getValue());
//contingencyRo.setNodeState(deviceData.getNodeState());
contingencyRo.setConfirm("NONE"); contingencyRo.setConfirm("NONE");
contingencyRo.setFireTruckRoute(equipment.getFireTruckRoute()); contingencyRo.setFireTruckRoute(equipment.getFireTruckRoute());
contingencyRo.setRunstep(false); contingencyRo.setRunstep(false);
...@@ -557,12 +566,27 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -557,12 +566,27 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
} }
} }
log.debug("开始调用规则");
//Object result = remoteRuleServer.fireRuleFlow(contingencyRo, equipment.getReservePlan(), equipment.getName()); // 获取遥信指标
List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH");
HashMap<String, Integer> telesignallingMap = new HashMap<>();
for (Map map : points) {
telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1);
}
contingencyRo.setTelesignallingMap(telesignallingMap);
// 获取遥测指标
points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE");
HashMap<String, Double> telemetryMap = new HashMap<>();
for (Map map : points) {
telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString()));
}
contingencyRo.setTelemetryMap(telemetryMap);
log.debug("开始调用规则");
Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
// Object result = ruleTrigger.publish(contingencyRo, "青海换流站消防预案/预案执行", ArrayUtils.toArray("极Ⅰ高端YY换流变B相"));
log.debug("规则调用返回==",result); log.debug("规则调用返回==",result);
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData(); ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData); BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
iContingencyOriginalDataDao.save(contingencyOriginalData); iContingencyOriginalDataDao.save(contingencyOriginalData);
...@@ -821,12 +845,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -821,12 +845,20 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType); saveFireEquipmentData(fireEquipmentPoint, fireEquipment, deviceData, fireEquipmentPointType);
// 根据监测点设备信息获取保护的重点装备 // 根据监测点设备信息获取保护的重点装备
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId()); equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(fireEquipmentPoint.getFireEquipmentId());
DeviceRo deviceRo = new DeviceRo();
deviceRo.setEquipmentId(equipment.getId());
deviceRo.setPointCode(deviceData.getPointCode());
deviceRo.setValue(deviceData.getState());
triggerPlanDevice(deviceRo, equipment, toke);
// Boolean have = equipmentGroupedPointDao.existsByEqpPointIdAndEquipId(fireEquipmentPoint.getId(), equipment.getId()); // Boolean have = equipmentGroupedPointDao.existsByEqpPointIdAndEquipId(fireEquipmentPoint.getId(), equipment.getId());
Boolean have = impAndFireEquipMapper.existsAlarmPointByEqpPointIdAndEquipId(fireEquipmentPoint.getId(), equipment.getId()); Boolean have = impAndFireEquipMapper.existsAlarmPointByEqpPointIdAndEquipId(fireEquipmentPoint.getId(), equipment.getId());
if (!ObjectUtils.isEmpty(have) && have) { if (!ObjectUtils.isEmpty(have) && have) {
//动态预案执行 //动态预案执行
dynamicPlan(deviceData, equipment, fireEquipment,toke); dynamicPlan(deviceData, equipment, fireEquipment,toke);
} }
} }
} }
...@@ -840,7 +872,14 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -840,7 +872,14 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
*/ */
@Async @Async
void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, Toke toke) { void dynamicPlan(AlarmParam deviceData, Equipment equipment, FireEquipment fireEquipment, Toke toke) {
String batchNo = UUID.randomUUID().toString(); Object contingencyRo = redisTemplate.opsForValue().get("contingencyRo");
String batchNo = null;
// if (!ObjectUtils.isEmpty(contingencyRo)) {
// batchNo = ((ContingencyRo)contingencyRo).getBatchNo();
// } else {
// batchNo = UUID.randomUUID().toString();
// }
batchNo = UUID.randomUUID().toString();
RequestContext.setToken(toke.getToke()); RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct()); RequestContext.setProduct(toke.getProduct());
try { try {
...@@ -849,6 +888,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -849,6 +888,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Async
public void triggerPlanDevice(DeviceRo deviceRo, Equipment equipment, Toke toke) {
try {
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
Object result1 = ruleTrigger.publish(deviceRo, equipment.getReservePlan(), ArrayUtils.toArray());
} catch (Exception e) {
e.printStackTrace();
}
}
@Override @Override
@javax.transaction.Transactional @javax.transaction.Transactional
...@@ -919,6 +969,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -919,6 +969,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iDataRefreshService.sendRefreshDataWithArea(View3dRefreshAreaEum.monitor_data.getCode(), content); iDataRefreshService.sendRefreshDataWithArea(View3dRefreshAreaEum.monitor_data.getCode(), content);
} }
} }
String topic = String.format("/%s/%s/%s", serviceName, "yinan","telesignaling");
webMqttComponent.publish(topic, JSON.toJSONString(deviceData));
List<AlarmParam> list = new ArrayList<>(); List<AlarmParam> list = new ArrayList<>();
list.add(deviceData); list.add(deviceData);
//保存所有数据(遥测,遥信)到mongo //保存所有数据(遥测,遥信)到mongo
...@@ -1008,12 +1061,21 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1008,12 +1061,21 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId, monitor, st)); fmeaIds.forEach(fmeaId -> rsDataQueue.addEquipmentMessage(fmeaId, monitor, st));
} }
} }
@Autowired
private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}")
private String pushType;
@Value("${spring.application.name}")
private String serviceName;
@Async @Async
public void sendAnalogue(EquipCommunicationData data) { public void sendAnalogue(EquipCommunicationData data) {
try { try {
redisTemplate.opsForHash().put("Analogue", data.getPointCode(), data); redisTemplate.opsForHash().put("Analogue", data.getPointCode(), data);
remoteWebSocketServer.sendMessage("plan", JSON.toJSONString(data)); // remoteWebSocketServer.sendMessage("plan", JSON.toJSONString(data));
String topic = String.format("/%s/%s/%s", serviceName, "yinan","analogue");
webMqttComponent.publish(topic, JSON.toJSONString(data));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -9,6 +9,7 @@ import org.aspectj.lang.annotation.Before; ...@@ -9,6 +9,7 @@ import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -31,15 +32,16 @@ public class PermissionAspect { ...@@ -31,15 +32,16 @@ public class PermissionAspect {
logger.info("======开始权限校验======"); logger.info("======开始权限校验======");
// 用户token // 用户token
String token = (String) request.getHeader("token"); String token = (String) request.getHeader("token");
String product = (String) request.getHeader("product"); token = ObjectUtils.isEmpty(token) ? (String) request.getHeader("X-Access-Token") : token;
String appKey = (String) request.getHeader("appKey"); String product = (String) request.getHeader("product");
logger.info("用户token:" + token); String appKey = (String) request.getHeader("appKey");
RequestContext.setToken(token); logger.info("用户token:" + token);
RequestContext.setProduct(product); RequestContext.setToken(token);
RequestContext.setAppKey(appKey); RequestContext.setProduct(product);
if (!TokenOperation.refresh(token)) { RequestContext.setAppKey(appKey);
throw new PermissionException("登录信息失效,请重新登录"); if (!TokenOperation.refresh(token)) {
} throw new PermissionException("登录信息失效,请重新登录");
}
} }
} }
...@@ -15,7 +15,7 @@ eureka.client.healthcheck.enabled = true ...@@ -15,7 +15,7 @@ eureka.client.healthcheck.enabled = true
eureka.client.fetchRegistry = true eureka.client.fetchRegistry = true
eureka.instance.prefer-ip-address=true eureka.instance.prefer-ip-address=true
#DB properties: #DB properties:
spring.datasource.url=jdbc:mysql://172.16.11.33:3306/safety-business-2.0.37?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.datasource.url=jdbc:mysql://172.16.11.33:3306/v2.0_zmd_yeejoin_safety_business?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=admin_1234 spring.datasource.password=admin_1234
spring.datasource.driver-class-name = com.mysql.jdbc.Driver spring.datasource.driver-class-name = com.mysql.jdbc.Driver
......
spring.application.name = Amos-autosys-gdd spring.application.name = Amos-autosys
server.port = 8083 server.port = 8083
......
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