Commit 62769d43 authored by 田涛's avatar 田涛

Merge remote-tracking branch 'origin/dev_upgrade-1225' into dev_upgrade-1225

parents 01d46bd7 53741e0c
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Component;
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.result.ActionResult; import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult; import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
import com.yeejoin.amos.fas.business.action.result.message.ActionResultMessage; import com.yeejoin.amos.fas.business.action.result.message.ActionResultMessage;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import org.springframework.stereotype.Component;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/** /**
* *
...@@ -67,4 +65,8 @@ public class BubbleTipAction implements CustomerAction ...@@ -67,4 +65,8 @@ public class BubbleTipAction implements CustomerAction
} }
} }
@Override
public void intreeuptPlan(String batchNo) {
}
} }
...@@ -184,37 +184,6 @@ public class ContingencyAction implements CustomerAction { ...@@ -184,37 +184,6 @@ public class ContingencyAction implements CustomerAction {
} }
public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
* @param paramObj 预案对象 * @param paramObj 预案对象
...@@ -260,6 +229,62 @@ public class ContingencyAction implements CustomerAction { ...@@ -260,6 +229,62 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("steparea", contingencyRo, result); this.sendcmd("steparea", contingencyRo, result);
} }
public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendweb(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"numberPlan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} catch (Exception e) {
e.printStackTrace();
}
}
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
* @param paramObj 预案对象 * @param paramObj 预案对象
...@@ -298,13 +323,15 @@ public class ContingencyAction implements CustomerAction { ...@@ -298,13 +323,15 @@ public class ContingencyAction implements CustomerAction {
}); });
} }
tempmap1.put("content", records); tempmap1.put("content", records);
tempmap1.put("status",PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
result.add(tempmap1); result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------"+result);
this.sendcmd("recordarea", paramObj, result); this.sendcmd("recordarea", paramObj, result);
this.sendweb("recordarea", paramObj, result);
} }
/** /**
...@@ -508,9 +535,8 @@ public class ContingencyAction implements CustomerAction { ...@@ -508,9 +535,8 @@ public class ContingencyAction implements CustomerAction {
e.printStackTrace(); e.printStackTrace();
} }
result.add(tempmap1); result.add(tempmap1);
System.out.println("--------------------saveOperation----------------------"+result);
this.sendcmd("recordarea", paramObj, result); this.sendcmd("recordarea", paramObj, result);
} }
private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) { private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) {
...@@ -642,10 +668,11 @@ public class ContingencyAction implements CustomerAction { ...@@ -642,10 +668,11 @@ public class ContingencyAction implements CustomerAction {
tempmap1.put("type", "event"); tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan"); tempmap1.put("content", "stopPlan");
//数字预案结束状态
tempmap1.put("status",PlanRecordStatusEnum.COMPLETE.getCode());
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo"); redisTemplate.delete("contingencyRo");
// 结束预案,更新设备重点设备参数 // 结束预案,更新设备重点设备参数
...@@ -658,9 +685,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -658,9 +685,10 @@ public class ContingencyAction implements CustomerAction {
equipmentService.save(equipment); equipmentService.save(equipment);
} }
} }
// 结束预案 更新预案记录表,预案状态 // 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo()); PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo());
if(planOperationRecord!=null){ if(planOperationRecord!=null && planOperationRecord.getStatus()==PlanRecordStatusEnum.OPERATION.getCode()){
planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode()); planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode());
planOperationRecord.setEndTime(new Date()); planOperationRecord.setEndTime(new Date());
planOperationRecordDao.save(planOperationRecord); planOperationRecordDao.save(planOperationRecord);
...@@ -670,7 +698,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -670,7 +698,10 @@ public class ContingencyAction implements CustomerAction {
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode()); planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail); planDetailDao.save(planDetail);
} }
//数字预案业务屏web端发送消息
this.sendweb("recordarea", paramObj, result);
} }
} }
...@@ -801,4 +832,44 @@ public class ContingencyAction implements CustomerAction { ...@@ -801,4 +832,44 @@ public class ContingencyAction implements CustomerAction {
RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull(); RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull();
} }
@Override
public void intreeuptPlan(String batchNo) {
ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
ArrayList records = new ArrayList<>();
HashMap map = new HashMap();
map.put("time", sdf.format(new Date()));
map.put("stepName","应急处置中断");
records.add(map);
tempmap1.put("content", records);
//数字预案结束状态
tempmap1.put("status",PlanRecordStatusEnum.INTERRUPT.getCode());
result.add(tempmap1);
//数字预案业务屏web端发送消息
this.sendweb("recordarea", contingencyRo, result);
updateNumberPlan(contingencyRo.getBatchNo());
}
/**
* 修改数字预案状态
* */
public void updateNumberPlan(String batchNo){
// 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if(planOperationRecord!=null){
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
planOperationRecord.setEndTime(new Date());
planOperationRecordDao.save(planOperationRecord);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
}
}
}
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
public interface CustomerAction { public interface CustomerAction {
/**
*数字预案中断
*/
void intreeuptPlan(String batchNo);
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.component.rule.MethodParam; 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;
...@@ -15,8 +7,14 @@ import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; ...@@ -15,8 +7,14 @@ 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;
import com.yeejoin.amos.fas.business.action.result.BubbleTipResult; import com.yeejoin.amos.fas.business.action.result.BubbleTipResult;
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.result.message.ActionResultMessage;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/** /**
* *
* <pre> * <pre>
...@@ -151,4 +149,8 @@ public class RiskSituationAction implements CustomerAction ...@@ -151,4 +149,8 @@ public class RiskSituationAction implements CustomerAction
} }
} }
@Override
public void intreeuptPlan(String batchNo) {
}
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext; import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
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;
...@@ -16,6 +8,13 @@ import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultM ...@@ -16,6 +8,13 @@ import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultM
import com.yeejoin.amos.fas.business.action.util.DataItemUtil; import com.yeejoin.amos.fas.business.action.util.DataItemUtil;
import com.yeejoin.amos.fas.business.service.intfc.IMessageService; import com.yeejoin.amos.fas.business.service.intfc.IMessageService;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
/** /**
* *
...@@ -84,6 +83,11 @@ public class SimpleTipAction implements CustomerAction ...@@ -84,6 +83,11 @@ public class SimpleTipAction implements CustomerAction
} }
} }
@Override
public void intreeuptPlan(String batchNo) {
}
// @SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")
// private void saveMessageAction(AbstractActionResult abstractActionResult,String type) // private void saveMessageAction(AbstractActionResult abstractActionResult,String type)
// { // {
......
package com.yeejoin.amos.fas.business.action.model; package com.yeejoin.amos.fas.business.action.model;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import com.yeejoin.amos.component.rule.Label; import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact; import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
@RuleFact(value = "动态预案",project = "换流站消防专项预案") @RuleFact(value = "动态预案",project = "换流站消防专项预案")
@Data @Data
public class ContingencyRo implements Serializable { public class ContingencyRo implements Serializable {
...@@ -81,10 +80,11 @@ public class ContingencyRo implements Serializable { ...@@ -81,10 +80,11 @@ public class ContingencyRo implements Serializable {
private Date createDate = new Date(); private Date createDate = new Date();
@Label("遥测数据") @Label("遥测数据")
private HashMap<String, Double> telemetryMap; private Map<String, Double> telemetryMap;
@Label("遥信数据") @Label("遥信数据")
private HashMap<String, Integer> telesignallingMap; private Map<String, Integer> telesignallingMap;
//消防炮 //消防炮
@Label("消防炮编号") @Label("消防炮编号")
......
package com.yeejoin.amos.fas.business.action.model; package com.yeejoin.amos.fas.business.action.model;
import com.yeejoin.amos.component.rule.model.RuleConstants; public enum SetpEnum {
//@Constants(value = SetpEnum.class)
public enum SetpEnum implements RuleConstants{
STEP0("0", "确认火灾", 0), STEP0("0", "确认火灾", 0),
STEP1("1", "停运换流阀、拨打报警电话", 1), STEP1("1", "停运换流阀、拨打报警电话", 1),
STEP2("2", "开启水喷雾系统", 2), STEP2("2", "开启水喷雾系统", 2),
...@@ -31,12 +28,10 @@ public enum SetpEnum implements RuleConstants{ ...@@ -31,12 +28,10 @@ public enum SetpEnum implements RuleConstants{
this.order = order; this.order = order;
} }
@Override
public String getValue() { public String getValue() {
return stepCode; return stepCode;
} }
@Override
public String getTitle() { public String getTitle() {
return stepName; return stepName;
} }
......
...@@ -166,7 +166,14 @@ public class ContingencyPlanController extends BaseController { ...@@ -166,7 +166,14 @@ public class ContingencyPlanController extends BaseController {
AgencyUserModel user = getUserInfo(); AgencyUserModel user = getUserInfo();
vo.setUserId(user.getUserId()); vo.setUserId(user.getUserId());
vo.setUserName(user.getRealName()); vo.setUserName(user.getRealName());
ContingencyPlanResponseVo result = contingencyPlanService.planStart(vo,toke); ContingencyPlanResponseVo result= null;
try {
result = contingencyPlanService.planStart(vo,toke);
}catch (Exception e){
e.printStackTrace();
return CommonResponseUtil2.failure();
}
return CommonResponseUtil2.success(result); return CommonResponseUtil2.success(result);
} }
......
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.controller; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.controller;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import com.yeejoin.amos.fas.business.dao.repository.IFmeaDao;
import com.yeejoin.amos.fas.exception.YeeException;
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;
...@@ -49,6 +51,9 @@ public class RiskModelController extends BaseController { ...@@ -49,6 +51,9 @@ public class RiskModelController extends BaseController {
@Autowired @Autowired
private IFmeaService fmeaService; private IFmeaService fmeaService;
@Autowired
private IFmeaDao iFmeaDao;
@Permission @Permission
@ApiOperation(value = "根据父类编号获取子类风险点类型", notes = "根据父类编号获取子类风险点类型") @ApiOperation(value = "根据父类编号获取子类风险点类型", notes = "根据父类编号获取子类风险点类型")
@GetMapping(value = "/riskSource/getChildTypeByPid") @GetMapping(value = "/riskSource/getChildTypeByPid")
...@@ -159,6 +164,12 @@ public class RiskModelController extends BaseController { ...@@ -159,6 +164,12 @@ public class RiskModelController extends BaseController {
@RequestMapping(value = "/fmea/editFmea", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/fmea/editFmea", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse editFmea(@ApiParam(value = "Fmea模型对象", required = true) @RequestBody List<Fmea> params) { public CommonResponse editFmea(@ApiParam(value = "Fmea模型对象", required = true) @RequestBody List<Fmea> params) {
try { try {
params.forEach(param -> {
int i = iFmeaDao.checkIdAndName(param.getRiskSourceId(), param.getRiskFactorsId());
if (i>0){
throw new YeeException("危险因素重复");
}
});
AgencyUserModel user = getUserInfo(); AgencyUserModel user = getUserInfo();
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("user_id", user.getUserId()); map.put("user_id", user.getUserId());
......
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.action.CustomerAction;
import com.yeejoin.amos.fas.business.service.impl.RiskSourceServiceImpl; import com.yeejoin.amos.fas.business.service.impl.RiskSourceServiceImpl;
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.IContingencyOriginalDataService; import com.yeejoin.amos.fas.business.service.intfc.IContingencyOriginalDataService;
...@@ -20,6 +21,7 @@ import io.swagger.annotations.ApiParam; ...@@ -20,6 +21,7 @@ import io.swagger.annotations.ApiParam;
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.Qualifier;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -36,7 +38,9 @@ public class TimeLineController extends BaseController{ ...@@ -36,7 +38,9 @@ public class TimeLineController extends BaseController{
private static final Logger log = LoggerFactory.getLogger(TimeLineController.class); private static final Logger log = LoggerFactory.getLogger(TimeLineController.class);
@Autowired @Autowired
IContingencyInstance iContingencyInstance; IContingencyInstance iContingencyInstance;
@Qualifier("contingencyAction")
@Autowired
private CustomerAction customerAction;
@Autowired @Autowired
IContingencyOriginalDataService iContingencyOriginalDataService; IContingencyOriginalDataService iContingencyOriginalDataService;
...@@ -107,6 +111,7 @@ public class TimeLineController extends BaseController{ ...@@ -107,6 +111,7 @@ public class TimeLineController extends BaseController{
equip.setStatus(NumberEnum.ONE.getValue()); equip.setStatus(NumberEnum.ONE.getValue());
equipmentService.save(equip); equipmentService.save(equip);
}); });
customerAction.intreeuptPlan(batchNo);
return CommonResponseUtil.success("SUCCESS"); return CommonResponseUtil.success("SUCCESS");
} }
......
...@@ -44,4 +44,5 @@ public interface PlanDetailMapper { ...@@ -44,4 +44,5 @@ 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<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);
String getRuleIdByEquipment(@Param("id") Long id);
} }
...@@ -28,7 +28,7 @@ public interface IContingencyPlanInstanceRepository extends BaseDao<ContingencyP ...@@ -28,7 +28,7 @@ public interface IContingencyPlanInstanceRepository extends BaseDao<ContingencyP
" t.batch_no = ?" + " t.batch_no = ?" +
" AND t.record_type = ?" + " AND t.record_type = ?" +
" ORDER BY" + " ORDER BY" +
" t.sort DESC", nativeQuery = true) " t.sort ASC", nativeQuery = true)
List<ContingencyPlanInstance> queryForCategory(String batch_no,String recordType); List<ContingencyPlanInstance> queryForCategory(String batch_no,String recordType);
@Query(value = @Query(value =
......
...@@ -48,4 +48,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> { ...@@ -48,4 +48,7 @@ public interface IFmeaDao extends BaseDao<Fmea, Long> {
@Query(value = "select * from `f_fmea` where id in ?1",nativeQuery = true) @Query(value = "select * from `f_fmea` where id in ?1",nativeQuery = true)
List<Fmea> findAllByRiskSourceIds(List<Long> ids); List<Fmea> findAllByRiskSourceIds(List<Long> ids);
@Query(value = "select count(1) from `f_fmea` where risk_source_id = ?1 and risk_factors_id = ?2",nativeQuery = true)
int checkIdAndName(Long sId,Long nId);
} }
...@@ -15,8 +15,9 @@ import java.util.List; ...@@ -15,8 +15,9 @@ import java.util.List;
@Repository @Repository
public interface IPlanDetailDao extends BaseDao<PlanDetail, Long> { public interface IPlanDetailDao extends BaseDao<PlanDetail, Long> {
@Query(value="SELECT count(*) from c_plan_detail where status in (?1) AND is_delete = 0 ", nativeQuery = true) @Query(value="SELECT * from c_plan_detail where status in (?1) AND is_delete = 0 ", nativeQuery = true)
int findByStatus(Integer[] status); List<PlanDetail> findByStatus(Integer[] status);
List<PlanDetail> getPlanDetailsByIdInAndIsDelete(List<Long> idList, Boolean isDelete); List<PlanDetail> getPlanDetailsByIdInAndIsDelete(List<Long> idList, Boolean isDelete);
} }
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PreplanPicture; import com.yeejoin.amos.fas.dao.entity.PreplanPicture;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
...@@ -11,6 +13,10 @@ public interface IPreplanPictureDao extends BaseDao<PreplanPicture, Long> { ...@@ -11,6 +13,10 @@ public interface IPreplanPictureDao extends BaseDao<PreplanPicture, Long> {
@Query(value = "select * from f_preplan_picture where equipment_id=?1 and type = ?2", nativeQuery = true) @Query(value = "select * from f_preplan_picture where equipment_id=?1 and type = ?2", nativeQuery = true)
PreplanPicture selectOne(Long id, int type); PreplanPicture selectOne(Long id, int type);
@Transactional
@Modifying
@Query(value = "delete from f_preplan_picture where equipment_id=?1", nativeQuery = true)
int deletebyEqId(Long id);
List<PreplanPicture> findByEquipmentId(Long equipmentId); List<PreplanPicture> findByEquipmentId(Long equipmentId);
......
...@@ -9,6 +9,7 @@ import com.yeejoin.amos.fas.business.action.model.SetpEnum; ...@@ -9,6 +9,7 @@ import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher; import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper; 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.ImpAndFireEquipMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanDetailMapper;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao; import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository; import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance; import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
...@@ -52,6 +53,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -52,6 +53,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired @Autowired
private FireEquipPointMapper fireEquipPointMapper; private FireEquipPointMapper fireEquipPointMapper;
...@@ -82,6 +84,8 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -82,6 +84,8 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired @Autowired
private ContingencyLogPublisher contingencyLogPublisher; private ContingencyLogPublisher contingencyLogPublisher;
@Autowired
private PlanDetailMapper planDetailMapper;
/** /**
* 创建预案执行记录 * 创建预案执行记录
...@@ -181,16 +185,19 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -181,16 +185,19 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1); telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1);
} }
contingencyRo.setTelesignallingMap(telesignallingMap); contingencyRo.setTelesignallingMap(telesignallingMap);
// 获取遥测指标 //获取遥测指标
points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE");
HashMap<String, Double> telemetryMap = new HashMap<>(); HashMap<String, Double> telemetryMap = new HashMap<>();
for (Map map : points) { for (Map map : points) {
telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString())); telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString()));
} }
contingencyRo.setTelemetryMap(telemetryMap); contingencyRo.setTelemetryMap(telemetryMap);
contingencyRo.setEquipmentCode(equipment.getCode()); contingencyRo.setEquipmentCode(equipment.getCode());
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); String plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId()));
ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan, ArrayUtils.toArray(equipment.getName()));
publisherPlanLog(stepCode, buttonCode, batchNo); publisherPlanLog(stepCode, buttonCode, batchNo);
} }
...@@ -301,4 +308,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -301,4 +308,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
public void updateStep(String step, String batchNo) { public void updateStep(String step, String batchNo) {
iContingencyOriginalDataDao.updateByButtonStep(step, batchNo); iContingencyOriginalDataDao.updateByButtonStep(step, batchNo);
} }
public String getNumberPlan(Long id) {
String ruleId = planDetailMapper.getRuleIdByEquipment(id);
return ruleId;
}
} }
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.rule.config.ClazzUtils; import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.fas.business.action.CustomerAction;
import com.yeejoin.amos.fas.business.dao.mapper.*; import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.*; import com.yeejoin.amos.fas.business.dao.repository.*;
import com.yeejoin.amos.fas.business.param.AlarmParam; import com.yeejoin.amos.fas.business.param.AlarmParam;
...@@ -14,6 +15,7 @@ import com.yeejoin.amos.fas.common.enums.ExecutionTypeEnum; ...@@ -14,6 +15,7 @@ import com.yeejoin.amos.fas.common.enums.ExecutionTypeEnum;
import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum; import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
import com.yeejoin.amos.fas.core.enums.NumberEnum; import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.enums.ReserveEnum; import com.yeejoin.amos.fas.core.enums.ReserveEnum;
import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.*; import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.exception.YeeException; import com.yeejoin.amos.fas.exception.YeeException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -23,7 +25,6 @@ import org.eclipse.paho.client.mqttv3.MqttException; ...@@ -23,7 +25,6 @@ import org.eclipse.paho.client.mqttv3.MqttException;
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.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
...@@ -60,8 +61,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -60,8 +61,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private IEquipmentHandlerService equipmentHandlerService; private IEquipmentHandlerService equipmentHandlerService;
@Autowired @Autowired
private IContingencyPlanInstanceRepository repository; private IContingencyPlanInstanceRepository repository;
@Value("${number.plan.projectName}") @Qualifier("contingencyAction")
private String projectName; @Autowired
private CustomerAction customerAction;
// @Value("${number.plan.projectName}")
// private String projectName;
private final PlanOperationRecordMapper planOperationRecordMapper; private final PlanOperationRecordMapper planOperationRecordMapper;
private final IPlanDetailDao planDetailDao; private final IPlanDetailDao planDetailDao;
private final IPlanDocDao planDocDao; private final IPlanDocDao planDocDao;
...@@ -74,7 +78,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -74,7 +78,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private final PlanDocMapper planDocMapper; private final PlanDocMapper planDocMapper;
private final EmqKeeper emqKeeper; private final EmqKeeper emqKeeper;
private final IPlanClassifyTreeService planClassifyTreeService; private final IPlanClassifyTreeService planClassifyTreeService;
@Autowired
IContingencyInstance iContingencyInstance;
@Autowired @Autowired
public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao, public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao,
IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper, IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper,
...@@ -97,10 +102,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -97,10 +102,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke) { public ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke) throws Exception {
ContingencyPlanResponseVo result = new ContingencyPlanResponseVo(); ContingencyPlanResponseVo result = new ContingencyPlanResponseVo();
//状态校验 //状态校验
ReserveEnum reserveEnum = this.runCheck(vo); ReserveEnum reserveEnum = this.runCheck(vo);
result.setMessage(reserveEnum.getText());
if (ReserveEnum.THISRUNNING.getStatus() == reserveEnum.getStatus()) { if (ReserveEnum.THISRUNNING.getStatus() == reserveEnum.getStatus()) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId())); List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
result.setMessage(ReserveEnum.THISRUNNING.getText()); result.setMessage(ReserveEnum.THISRUNNING.getText());
...@@ -158,7 +164,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -158,7 +164,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, operationRecord.getId()); String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, operationRecord.getId());
//更新模型状态 //更新模型状态
PlanDetail planDetail = PlanDetailOp.get(); PlanDetail planDetail = PlanDetailOp.get();
planDetail.setStatus(ContingencyPlanStatusEnum.SIMULATION_START.getCode()); planDetail.setStatus(vo.getStatus());
planDetailDao.save(planDetail); planDetailDao.save(planDetail);
//更新预案执行记录表的批次号 //更新预案执行记录表的批次号
operationRecord.setBatchNo(batchNo); operationRecord.setBatchNo(batchNo);
...@@ -217,27 +223,43 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -217,27 +223,43 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
//启动状态校验 //启动状态校验
public ReserveEnum runCheck(ContingencyPlanParamVo vo) { public ReserveEnum runCheck(ContingencyPlanParamVo vo) throws Exception {
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) { if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId())); List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
if (recordList.size() > 0) { if (recordList.size() > 0 && vo.getStatus()!=ContingencyPlanStatusEnum.ONGOING.getCode()) {
return ReserveEnum.THISRUNNING; return ReserveEnum.THISRUNNING;
} }
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) { if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) {
Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode(), ContingencyPlanStatusEnum.ONGOING.getCode()).toArray(); Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode(), ContingencyPlanStatusEnum.ONGOING.getCode()).toArray();
int count = planDetailDao.findByStatus(statusArray); List<PlanDetail> count = planDetailDao.findByStatus(statusArray);
if (count > NumberEnum.ZERO.getValue()) { if (count.size() > NumberEnum.ZERO.getValue()) {
return ReserveEnum.RUNNING; return ReserveEnum.RUNNING;
} }
} else if (ContingencyPlanStatusEnum.ONGOING.getCode().equals(vo.getStatus())) { } else if (ContingencyPlanStatusEnum.ONGOING.getCode().equals(vo.getStatus())) {
//自动启动 //自动启动
Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.ONGOING.getCode()).toArray(); List<PlanDetail> countZd = planDetailDao.findByStatus((Integer[]) Arrays.asList(ContingencyPlanStatusEnum.ONGOING.getCode()).toArray());
int count = planDetailDao.findByStatus(statusArray); if (countZd.size() > NumberEnum.ZERO.getValue()) {
if (count > NumberEnum.ZERO.getValue()) {
return ReserveEnum.RUNNING; return ReserveEnum.RUNNING;
} }
List<PlanDetail> countMn = planDetailDao.findByStatus((Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode()).toArray());
if (countMn.size() > NumberEnum.ZERO.getValue()) {
List<PlanOperationRecord> planOperationRecordList = planOperationRecordDao.findByPlanId1(countMn.get(0).getId());
if(planOperationRecordList.size()>0){
Optional<Equipment> equipment = iContingencyInstance.fire(planOperationRecordList.get(0).getBatchNo(),"0","","FIRE_CANCEL","CONFIRM","B");
// 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> {
equip.setStartTime(DateUtil.getDateNow());
equip.setEndTime(null);
equip.setReserveSource(NumberEnum.ONE.getValue());
equip.setStatus(NumberEnum.ONE.getValue());
equipmentService.save(equip);
});
customerAction.intreeuptPlan(planOperationRecordList.get(0).getBatchNo());
}
}
} else { } else {
return ReserveEnum.PLANSTATUSERROR; return ReserveEnum.PLANSTATUSERROR;
} }
......
...@@ -85,6 +85,9 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -85,6 +85,9 @@ public class EquipmentServiceImpl implements IEquipmentService {
@Value("${linux.img.path}") @Value("${linux.img.path}")
private String linuxImgPath; private String linuxImgPath;
@Value("${server.servlet.context-path}")
private String fireAutoSys;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
...@@ -331,6 +334,19 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -331,6 +334,19 @@ public class EquipmentServiceImpl implements IEquipmentService {
@Override @Override
public Equipment saveEquipmentAndImg(ImgParam[] imgs, Equipment equipment) { public Equipment saveEquipmentAndImg(ImgParam[] imgs, Equipment equipment) {
String path = FasConstant.UPLOAD_ROOT_PATH + File.separator + FasConstant.UPLOAD_EQUIPMENT_PATH
+ File.separator + equipment.getId();
String filePath = getRootPath() + path;
preplanPictureDao.deletebyEqId(equipment.getId());
File file1 = new File(filePath);
if (file1.exists()){
File[] files = file1.listFiles();
if (files.length >0){
for (File f: files) {
f.delete();
}
}
}
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (imgs == null || imgs.length < 1) { if (imgs == null || imgs.length < 1) {
equipment = save(equipment); equipment = save(equipment);
...@@ -369,9 +385,6 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -369,9 +385,6 @@ public class EquipmentServiceImpl implements IEquipmentService {
pp.setCreateDate(new Date()); pp.setCreateDate(new Date());
} }
String path = FasConstant.UPLOAD_ROOT_PATH + File.separator + FasConstant.UPLOAD_EQUIPMENT_PATH
+ File.separator + equipment.getId();
String filePath = getRootPath() + path;
String fileType = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."), String fileType = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."),
file.getOriginalFilename().length()); file.getOriginalFilename().length());
...@@ -390,7 +403,8 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -390,7 +403,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
throw new YeeException("上传图片失败"); throw new YeeException("上传图片失败");
} }
String picture = path + fileName; String[] split = fireAutoSys.split("/");
String picture = split[1]+"/"+path + fileName;
pp.setPicture(picture); pp.setPicture(picture);
preplanPictureDao.saveAndFlush(pp); preplanPictureDao.saveAndFlush(pp);
} }
......
...@@ -39,6 +39,7 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -39,6 +39,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.*; import java.util.*;
...@@ -330,19 +331,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -330,19 +331,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
} }
// 获取遥信指标,暂不处理 code = 设备编码iot_code-指标项name_key // 获取遥信指标,暂不处理 code = 设备编码iot_code-指标项name_key
// List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH");//物联属性指标 and 为true或false List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH");//物联属性指标 and 为true或false
// HashMap<String, Integer> telesignallingMap = new HashMap<>(); Map<String, Integer> telesignallingMap = new HashMap<>();
// for (Map map : points) { for (Map map : points) {
// telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1); telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1);
// } }
// contingencyRo.setTelesignallingMap(telesignallingMap); contingencyRo.setTelesignallingMap(telesignallingMap);
// // 获取遥测指标 // 获取遥测指标
// points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false
// HashMap<String, Double> telemetryMap = new HashMap<>(); Map<String, Double> telemetryMap = new HashMap<>();
// for (Map map : points) { for (Map map : points) {
// telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString())); telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString()));
// } }
// contingencyRo.setTelemetryMap(telemetryMap); contingencyRo.setTelemetryMap(telemetryMap);
log.debug("开始调用规则"); log.debug("开始调用规则");
Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
......
...@@ -14,6 +14,8 @@ import com.yeejoin.amos.fas.dao.entity.RiskFactor; ...@@ -14,6 +14,8 @@ import com.yeejoin.amos.fas.dao.entity.RiskFactor;
import com.yeejoin.amos.fas.exception.YeeException; import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel; import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
...@@ -44,14 +46,18 @@ public class RiskFactorServiceImpl implements IRiskFactorService { ...@@ -44,14 +46,18 @@ public class RiskFactorServiceImpl implements IRiskFactorService {
long total = riskFactorMapper.countPageData(param); long total = riskFactorMapper.countPageData(param);
List<HashMap<String, Object>> content = riskFactorMapper.queryRiskFactorPage(param); List<HashMap<String, Object>> content = riskFactorMapper.queryRiskFactorPage(param);
if(!CollectionUtils.isEmpty(content)){ if(!CollectionUtils.isEmpty(content)){
List<DictionarieValueModel> typeNameList = Systemctl.dictionarieClient.dictValues("INDUSTRY_TYPE").getResult();
Map<String, String> typeName = typeNameList.stream().collect(Collectors.toMap(DictionarieValueModel::getDictDataKey, DictionarieValueModel::getDictDataValue));
Set<String> userIds = new HashSet<>(); Set<String> userIds = new HashSet<>();
Set<String> deptIds = new HashSet<>(); Set<String> deptIds = new HashSet<>();
for(HashMap<String, Object> map : content) for(HashMap<String, Object> map : content)
{ {
map.put("typeName",typeName.get(map.get("type")));
String userId = String.valueOf(map.get("createBy")); String userId = String.valueOf(map.get("createBy"));
String deptId = String.valueOf(map.get("deptId")); String deptId = String.valueOf(map.get("deptId"));
userIds.add(userId); userIds.add(userId);
deptIds.add(deptId); deptIds.add(deptId);
} }
userIds.remove(null); userIds.remove(null);
userIds.remove(""); userIds.remove("");
......
...@@ -184,6 +184,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -184,6 +184,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired @Autowired
IEquipManageFeign iEquipManageFeign; IEquipManageFeign iEquipManageFeign;
@Autowired
private PlanDetailMapper planDetailMapper;
public static String cacheKeyForCanBeRunning() { public static String cacheKeyForCanBeRunning() {
return Redis.genKey(CacheType.ERASABLE.name(), "CONTINGENCYRUNING"); return Redis.genKey(CacheType.ERASABLE.name(), "CONTINGENCYRUNING");
...@@ -581,7 +583,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -581,7 +583,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1); telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1);
} }
contingencyRo.setTelesignallingMap(telesignallingMap); contingencyRo.setTelesignallingMap(telesignallingMap);
// 获取遥测指标 //获取遥测指标
points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false
HashMap<String, Double> telemetryMap = new HashMap<>(); HashMap<String, Double> telemetryMap = new HashMap<>();
for (Map map : points) { for (Map map : points) {
...@@ -589,6 +591,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -589,6 +591,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
contingencyRo.setTelemetryMap(telemetryMap); contingencyRo.setTelemetryMap(telemetryMap);
String plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId()));
log.debug("开始调用规则"); log.debug("开始调用规则");
Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
...@@ -1915,5 +1918,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1915,5 +1918,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return null; return null;
} }
public String getNumberPlan(Long id){
String ruleId = planDetailMapper.getRuleIdByEquipment(id);
return ruleId;
}
} }
package com.yeejoin.amos.fas.business.service.intfc; package com.yeejoin.amos.fas.business.service.intfc;
import java.util.List;
import java.util.Optional;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment; import com.yeejoin.amos.fas.dao.entity.Equipment;
import java.util.List;
import java.util.Optional;
public interface IContingencyInstance { public interface IContingencyInstance {
ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon); ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon);
......
...@@ -25,7 +25,7 @@ public interface IContingencyPlanService { ...@@ -25,7 +25,7 @@ public interface IContingencyPlanService {
String DELETE_SYNC_PLAN_RULE = "urule/package/remove"; String DELETE_SYNC_PLAN_RULE = "urule/package/remove";
String DELETE_SYNC_PLAN_EQUIP = "DELETE_SYNC_PLAN_EQUIP"; String DELETE_SYNC_PLAN_EQUIP = "DELETE_SYNC_PLAN_EQUIP";
ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke); ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke) throws Exception;
ContingencyPlanParamVo equipmentScene(Long equipmentId,String riskType ); ContingencyPlanParamVo equipmentScene(Long equipmentId,String riskType );
......
...@@ -103,4 +103,17 @@ ...@@ -103,4 +103,17 @@
ORDER BY create_date ASC ORDER BY create_date ASC
LIMIT #{start}, #{size} LIMIT #{start}, #{size}
</select> </select>
<select id="getRuleIdByEquipment" parameterType="java.lang.Long" resultType="java.lang.String">
SELECT
rule_id
FROM
c_plan_detail cpd
LEFT JOIN c_plan_rule rule ON rule.plan_id = cpd.id
LEFT JOIN c_plan_equipment equip ON equip.plan_id = cpd.id
LEFT JOIN f_equipment equipment ON equipment.id = equip.fire_equipment_id
where
equipment.id = #{id}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -63,17 +63,19 @@ ...@@ -63,17 +63,19 @@
limit #{pageNumber},#{pageSize} limit #{pageNumber},#{pageSize}
</select> </select>
<select id="getEquipmentBySpeCount" resultType="int"> <select id="getEquipmentBySpeCount" resultType="int">select
select
count(1) count(1)
from from
wl_stock_detail as sto wl_stock_detail as sto
left join wl_equipment_specific as spe on sto.qr_code = spe.qr_code left join wl_equipment_specific as spe on sto.qr_code = spe.qr_code
<if test="equipmentId != null and equipmentId!='null' ">
left join f_equipment_fire_equipment as fire on spe.id = fire.fire_equipment_id
</if>
left join wl_warehouse_structure as ware on sto.warehouse_structure_id = ware.source_id left join wl_warehouse_structure as ware on sto.warehouse_structure_id = ware.source_id
left join wl_equipment_detail as det on sto.equipment_detail_id = det.id left join wl_equipment_detail as det on sto.equipment_detail_id = det.id
left join wl_equipment as equ on det.equipment_id = equ.id left join wl_equipment as equ on det.equipment_id = equ.id
left join wl_equipment_category as cate on equ.category_id = cate.id left join wl_equipment_category as cate on equ.category_id = cate.id
left join f_equipment_fire_equipment as fire on sto.id = fire.fire_equipment_id left join f_fire_fighting_system as manage on spe.system_id = manage.id
where sto.amount <![CDATA[>]]> 0 where sto.amount <![CDATA[>]]> 0
<if test="name != null and name!='null' "> <if test="name != null and name!='null' ">
and det.name like CONCAT('%',#{name},'%' ) and det.name like CONCAT('%',#{name},'%' )
......
...@@ -165,7 +165,8 @@ ...@@ -165,7 +165,8 @@
WHEN 'false' THEN '否' WHEN 'false' THEN '否'
ELSE ind.value END 'e_value', ELSE ind.value END 'e_value',
ein.unit as eq_point_unit, ein.unit as eq_point_unit,
sce.name as source_name, str.full_name as source_name,
-- sce.name as source_name,
( (
SELECT SELECT
group_concat(DISTINCT f.`name`) group_concat(DISTINCT f.`name`)
...@@ -183,7 +184,7 @@ ...@@ -183,7 +184,7 @@
left join wl_equipment_index as ein on ind.equipment_index_id = ein.id left join wl_equipment_index as ein on ind.equipment_index_id = ein.id
left join wl_stock_detail as sto on sto.qr_code = spe.qr_code left join wl_stock_detail as sto on sto.qr_code = spe.qr_code
left join wl_warehouse_structure as str on sto.warehouse_structure_id = str.source_id left join wl_warehouse_structure as str on sto.warehouse_structure_id = str.source_id
left join f_risk_source as sce on str.source_id = sce.source_id -- left join f_risk_source as sce on str.source_id = sce.source_id
) d ) d
WHERE WHERE
1 = 1 1 = 1
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<dependency> <dependency>
<groupId>com.yeejoin</groupId> <groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId> <artifactId>amos-component-rule</artifactId>
<version>1.2.0-SNAPSHOT</version> <version>1.4.4-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
......
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