Commit a9e71634 authored by 高建强's avatar 高建强

item:新增预案状态、时间、来源

parent a47db4b3
package com.yeejoin.amos.fas.dao.entity; package com.yeejoin.amos.fas.dao.entity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date;
/** /**
...@@ -122,6 +123,24 @@ public class Equipment extends BasicEntity { ...@@ -122,6 +123,24 @@ public class Equipment extends BasicEntity {
private Integer status; private Integer status;
/**
* 预案开始时间
*/
@Column(name="start_time")
private Date startTime;
/**
* 预案结束时间
*/
@Column(name="end_time")
private Date endTime;
/**
* 预案来源:1-手动触发,0-自动触发(默认)
*/
@Column(name="reserve_source")
private Integer reserveSource;
public Equipment() { public Equipment() {
} }
...@@ -255,4 +274,28 @@ public class Equipment extends BasicEntity { ...@@ -255,4 +274,28 @@ public class Equipment extends BasicEntity {
public void setStatus(Integer status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Integer getReserveSource() {
return reserveSource;
}
public void setReserveSource(Integer reserveSource) {
this.reserveSource = reserveSource;
}
} }
\ No newline at end of file
...@@ -16,6 +16,11 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -16,6 +16,11 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.enums.ReserveEnum;
import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.Equipment;
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;
...@@ -93,6 +98,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -93,6 +98,9 @@ public class ContingencyAction implements CustomerAction {
private IDutyModeServer dutyModeServer; private IDutyModeServer dutyModeServer;
@Autowired @Autowired
private IEquipmentService equipmentService;
@Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>(); private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>();
...@@ -640,6 +648,17 @@ public class ContingencyAction implements CustomerAction { ...@@ -640,6 +648,17 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo"); redisTemplate.delete("contingencyRo");
// 结束预案,更新设备重点设备参数
if (contingencyRo != null) {
Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
if (equipment != null) {
equipment.setEndTime(DateUtil.getDateNow());
equipment.setReserveSource(NumberEnum.ZERO.getValue());
equipment.setStatus(NumberEnum.ZERO.getValue());
equipmentService.save(equipment);
}
}
} }
......
...@@ -6,6 +6,9 @@ import java.util.List; ...@@ -6,6 +6,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.util.DateUtil;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -61,6 +64,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -61,6 +64,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired @Autowired
private IContingencyInstance iContingencyInstance; private IContingencyInstance iContingencyInstance;
@Autowired
private IEquipmentService equipmentService;
@Value("${station.name}") @Value("${station.name}")
private String stationName; private String stationName;
...@@ -175,26 +181,34 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla ...@@ -175,26 +181,34 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
log.info("stepstate:" + contingencyRo.getStepState()); log.info("stepstate:" + contingencyRo.getStepState());
log.info("stepCode:" + stepCode); log.info("stepCode:" + stepCode);
Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId())); Equipment equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId()));
// 获取重点设备胚胎指标 if (equipment != null) {
// 获取遥信指标 // 获取重点设备胚胎指标
List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH"); // 获取遥信指标
HashMap<String, Integer> telesignallingMap = new HashMap<>(); List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH");
for (Map map : points) { HashMap<String, Integer> telesignallingMap = new HashMap<>();
telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1); 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); }
// 获取遥测指标 contingencyRo.setTelesignallingMap(telesignallingMap);
points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); // 获取遥测指标
HashMap<String, Double> telemetryMap = new HashMap<>(); points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE");
for (Map map : points) { HashMap<String, Double> telemetryMap = new HashMap<>();
telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString())); for (Map map : points) {
telemetryMap.put(map.get("code") + "", Double.valueOf(ObjectUtils.isEmpty(map.get("value")) ? "0" : map.get("value").toString()));
}
contingencyRo.setTelemetryMap(telemetryMap);
contingencyRo.setEquipmentCode(equipment.getCode());
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
publisherPlanLog(stepCode, buttonCode, batchNo);
// 结束预案,更新设备重点设备参数
equipment.setEndTime(DateUtil.getDateNow());
equipment.setReserveSource(NumberEnum.ZERO.getValue());
equipment.setStatus(NumberEnum.ZERO.getValue());
equipmentService.save(equipment);
} }
contingencyRo.setTelemetryMap(telemetryMap);
contingencyRo.setEquipmentCode(equipment.getCode());
ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
publisherPlanLog(stepCode, buttonCode, batchNo);
} else { } else {
throw new Exception("数据异常,请联系管理员."); throw new Exception("数据异常,请联系管理员.");
} }
......
...@@ -22,7 +22,9 @@ import java.util.stream.Collectors; ...@@ -22,7 +22,9 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
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 org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -1044,15 +1046,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1044,15 +1046,16 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
@Override @Override
@Transactional
public ReserveEnum startEquipReserve(Long id, String typeCode) { public ReserveEnum startEquipReserve(Long id, String typeCode) {
int count = equipmentService.countByStatus(1); int count = equipmentService.countByStatus(NumberEnum.ONE.getValue());
if (count > 0) { if (count > NumberEnum.ZERO.getValue()) {
return ReserveEnum.RUN; return ReserveEnum.RUNNING;
} else { } else {
List<EquipmentSpecificIndexVo> list = equipmentService.getReserveEquipById(id, typeCode); List<EquipmentSpecificIndexVo> list = equipmentService.getReserveEquipById(id, typeCode);
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
EquipmentSpecificIndexVo equipmentSpecificIndexVo = new EquipmentSpecificIndexVo(); EquipmentSpecificIndexVo equipmentSpecificIndexVo = new EquipmentSpecificIndexVo();
equipmentSpecificIndexVo.setEquipmentSpecificId(list.get(0).getEquipmentSpecificId()); equipmentSpecificIndexVo.setEquipmentSpecificId(list.get(NumberEnum.ZERO.getValue()).getEquipmentSpecificId());
equipmentSpecificIndexVo.setType(typeCode); equipmentSpecificIndexVo.setType(typeCode);
TopicEntityVo topicEntity = new TopicEntityVo(); TopicEntityVo topicEntity = new TopicEntityVo();
...@@ -1061,9 +1064,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1061,9 +1064,19 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
String data = JSON.toJSONString(topicEntity); String data = JSON.toJSONString(topicEntity);
System.out.println(data); System.out.println(data);
iEquipmentHandlerService.handlerMqttMessage("",data ); iEquipmentHandlerService.handlerMqttMessage("",data );
return ReserveEnum.RUNNING;
} else { Equipment equipment = equipmentService.queryOne(id);
if (equipment != null) {
equipment.setStartTime(DateUtil.getDateNow());
equipment.setEndTime(null);
equipment.setReserveSource(NumberEnum.ONE.getValue());
equipment.setStatus(NumberEnum.ONE.getValue());
equipmentService.save(equipment);
return ReserveEnum.RUN;
}
return ReserveEnum.NOEQUIP; return ReserveEnum.NOEQUIP;
} else {
return ReserveEnum.NOFIRE;
} }
} }
} }
......
package com.yeejoin.amos.fas.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 整数统一枚举
*/
@Getter
@AllArgsConstructor
public enum NumberEnum {
ZERO("zero", 0),
ONE("one", 1),
TWO("two", 2),
THREE("three", 3),
FOUR("four", 4),
FIVE("five", 5);
private String name;
private Integer value;
}
...@@ -12,7 +12,8 @@ package com.yeejoin.amos.fas.core.enums; ...@@ -12,7 +12,8 @@ package com.yeejoin.amos.fas.core.enums;
public enum ReserveEnum { public enum ReserveEnum {
RUN(1, "启动成功"), RUN(1, "启动成功"),
RUNNING(2, "已有预案正在启动"), RUNNING(2, "已有预案正在启动"),
NOEQUIP(3, " 该电力设备未安装火灾探测器"); NOFIRE(3, "该电力设备未安装火灾探测器"),
NOEQUIP(4, "未找到该电力设备");
private Integer status; private Integer status;
private String text; private String text;
......
...@@ -42,6 +42,15 @@ public class DateUtil ...@@ -42,6 +42,15 @@ public class DateUtil
} }
/** /**
* 获取当前时间
*
* @return 当前日期时间
*/
public static Date getDateNow() {
return new Date();
}
/**
* *
* <pre> * <pre>
* 获取当前北京时间 * 获取当前北京时间
......
...@@ -587,7 +587,7 @@ ...@@ -587,7 +587,7 @@
ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_user_id` varchar(20) NULL COMMENT '驻站消防队队长'; ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_user_id` varchar(20) NULL COMMENT '驻站消防队队长';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="gaojianqiang" id="1609989450-1"> <changeSet author="gaojianqiang" id="1609989888-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_equipment" columnName="status" /> <columnExists tableName="f_equipment" columnName="status" />
...@@ -595,7 +595,10 @@ ...@@ -595,7 +595,10 @@
</preConditions> </preConditions>
<comment>修改f_equipment表结构</comment> <comment>修改f_equipment表结构</comment>
<sql> <sql>
ALTER TABLE `f_equipment` ADD COLUMN `status` tinyint(4) NULL DEFAULT NULL COMMENT '预案状态:1-启动,0-未启动'; ALTER TABLE `f_equipment` ADD COLUMN `status` tinyint(4) NULL DEFAULT NULL COMMENT '预案状态:1-启动,0-未启动',
ALTER TABLE `f_equipment` ADD COLUMN `start_time` datetime(0) NULL DEFAULT NULL COMMENT '预案开始时间',
ALTER TABLE `f_equipment` ADD COLUMN `end_time` datetime(0) NULL DEFAULT NULL COMMENT '预案结束时间',
ALTER TABLE `f_equipment` ADD COLUMN `reserve_source` tinyint(4) NULL DEFAULT 0 COMMENT '预案来源:1-手动触发,0-自动触发(默认)';
</sql> </sql>
</changeSet> </changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment