Commit 9926ec57 authored by maoying's avatar maoying

Merge branch 'dev_upgrade_plan6' of…

Merge branch 'dev_upgrade_plan6' of http://39.98.45.134:8090/station/YeeAmosFireAutoSysRoot into dev_upgrade_plan6
parents c23e993b ba7d1663
......@@ -103,6 +103,9 @@ public class ContingencyAction implements CustomerAction {
@Autowired
IRocketMQService rocketMQService;
@Autowired
private IContingencyInstance contingencyInstance;
@Value("${rocket-plan-topic}")
private String rocketTopic;
......@@ -510,7 +513,6 @@ public class ContingencyAction implements CustomerAction {
result.add(tempmap1);
this.sendcmd("optionarea", paramObj, result);
}
......@@ -703,7 +705,6 @@ public class ContingencyAction implements CustomerAction {
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.opsForValue().set("contingencyRo", contingencyRo);
}
......@@ -851,6 +852,7 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "自动执行动作", project = "换流站消防专项预案")
public void autoExecuteAction(
@MethodParam(paramLabel = "当前步骤") String currentSetup,
@MethodParam(paramLabel = "按钮状态") String buttonStatus,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "规则主题") String topic,
......@@ -858,6 +860,8 @@ public class ContingencyAction implements CustomerAction {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
contingencyRo.setButtonState(buttonStatus);
contingencyRo.setButtonCode(buttonCode);
contingencyRo.setStepState(topic);
contingencyRo.setStep(currentSetup);
try {
//电力设备
Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
......@@ -867,6 +871,26 @@ public class ContingencyAction implements CustomerAction {
}
}
@RuleMethod(methodLabel = "自动执行动作V2", project = "换流站消防专项预案")
public void autoExecuteActionV2(
@MethodParam(paramLabel = "步骤编码") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "按钮状态") String confirm,
@MethodParam(paramLabel = "步骤状态") String stepState,
@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
try {
contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, null, null);
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) {
Constructor<?> constructor;
try {
......
......@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping(value = "/api/equipFireEquip")
public class equipmentFireEquipmentController {
public class EquipmentFireEquipmentController {
@Autowired
private IEquipmentFireEquipmentService equipmentFireEquipmentService;
......
......@@ -6,19 +6,24 @@ import com.yeejoin.amos.fas.business.action.ContingencyAction;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import com.yeejoin.amos.fas.business.bo.FirePlanAlarmBo;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper;
import com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper;
import com.yeejoin.amos.fas.business.dao.mapper.View3dMapper;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IRocketMQService;
import com.yeejoin.amos.fas.business.service.model.Operate;
import com.yeejoin.amos.fas.business.service.model.OperateGroup;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -26,10 +31,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.*;
......@@ -38,6 +44,8 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
private static final Logger log = LoggerFactory.getLogger(ContingencyInstanceImpl.class);
static LinkedList<Map<String, String>> fireQueue = new LinkedList<>();
@Autowired
private IContingencyPlanInstanceRepository repository;
......@@ -45,9 +53,6 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
IContingencyOriginalDataDao iContingencyOriginalDataDao;
@Autowired
private RestTemplate restTemplate;
@Autowired
private ImpAndFireEquipMapper impAndFireEquipMapper;
@Autowired
......@@ -57,10 +62,16 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
private FireEquipPointMapper fireEquipPointMapper;
@Autowired
private IContingencyInstance iContingencyInstance;
IRocketMQService rocketMQService;
@Autowired
private IEquipmentService equipmentService;
private RemoteSecurityService remoteSecurityService;
@Value("${rocket-equip-alarm-topic}")
private String rocketTopicFireEquipAlarm;
@Autowired
private View3dMapper view3dMapper;
@Value("${station.name}")
private String stationName;
......@@ -309,6 +320,71 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
iContingencyOriginalDataDao.updateByButtonStep(step, batchNo);
}
@Override
public Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String token, String product) throws Exception {
Map<String, String> map = new HashMap<>();
map.put("batchNo", batchNo);
map.put("stepCode", stepCode);
map.put("buttonCode", buttonCode);
map.put("confirm", buttonState);
map.put("contingencyPlanId", contingencyPlanId);
map.put("stepState", stepStateOnbutton);
if (StringUtils.isNotBlank(token) || StringUtils.isNotBlank(product)) {
Toke serverToken = remoteSecurityService.getServerToken();
map.put("token", serverToken.getToke());
map.put("product", serverToken.getProduct());
} else {
map.put("token", token);
map.put("product", product);
}
fireQueue.addLast(map);
//应急指挥给总部推送消息
sendPlanAlarm(batchNo, buttonCode);
return Optional.empty();
}
private void sendPlanAlarm(String batchNo, String buttonCode) {
//确警后推送报警数据
if ("FIRE_CONFIRM".equals(buttonCode)) {
FirePlanAlarmBo firePlanAlarm = view3dMapper.getPlanAlarmInfo(batchNo);
List<FirePlanAlarmBo> list = new ArrayList<FirePlanAlarmBo>();
list.add(firePlanAlarm);
rocketMQService.sendMsg(rocketTopicFireEquipAlarm, "plan_alarm", list);
}
}
@Scheduled(cron = "*/2 * * * * ?")
public void runFireQueue() throws Exception {
if (fireQueue.size() == 0)
return;
Map<String, String> map = fireQueue.getFirst();
String batchNo = map.get("batchNo");
String stepCode = map.get("stepCode");
String buttonCode = map.get("buttonCode");
String confirm = map.get("confirm");
String contingencyPlanId = map.get("contingencyPlanId");
String stepState = map.get("stepState");
String token = map.get("token");
String product = map.get("product");
try {
log.info("fireQueue-size:" + fireQueue.size());
log.info("stepCode:" + map.get("stepCode"));
log.info("buttonCode:" + map.get("buttonCode"));
log.info("confirm:" + map.get("confirm"));
log.info("stepState:" + map.get("stepState"));
RequestContext.setToken(token);
RequestContext.setProduct(product);
setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm);
fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
} catch (Exception e) {
throw e;
} finally {
fireQueue.removeFirst();
}
}
public List<String> getNumberPlan(Long id) {
List<String> ruleId = planDetailMapper.getRuleIdByEquipment(id);
return ruleId;
......
......@@ -22,4 +22,6 @@ public interface IContingencyInstance {
Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton) throws Exception;
void updateStep(String step, String batchNo);
Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String token, String product) throws Exception;
}
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