Commit 44c58f79 authored by zhengjiawei's avatar zhengjiawei

Merge branch 'dev_upgrade' of G:\AAA-mypro\java\YeeAmosFireAutoSysRoot with conflicts.

parent e3cf5c9a
package com.yeejoin.amos.fas.dao.entity; package com.yeejoin.amos.fas.dao.entity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
/** /**
* The persistent class for the alarm database table. * The persistent class for the alarm database table.
*/ */
@Entity @Entity
@Table(name = "f_station_info") @Table(name = "f_station_info")
@NamedQuery(name = "StationInfo.findAll", query = "SELECT a FROM StationInfo a") @NamedQuery(name = "StationInfo.findAll", query = "SELECT a FROM StationInfo a")
public class StationInfo extends BasicEntity{ public class StationInfo extends BasicEntity{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 名称 * 名称
*/ */
private String name; private String name;
/** /**
* 环流站编码 * 环流站编码
*/ */
@Column(name="station_code") @Column(name="station_code")
private String stationCode; private String stationCode;
/** /**
* 后三位编码 * 后三位编码
*/ */
private String code; private String code;
/** /**
* 换流站类型:1-发电类型;2-收电类型 * 换流站类型:1-发电类型;2-收电类型
*/ */
@Column(name="elec_type") @Column(name="elec_type")
private Integer elecType; private Integer elecType;
/** /**
* 用途类型:1-电厂升压变电站;2-公用普通变电站;3-公用换流变电站;4-企业自备变电站;5-其他 * 用途类型:1-电厂升压变电站;2-公用普通变电站;3-公用换流变电站;4-企业自备变电站;5-其他
*/ */
@Column(name="use_type") @Column(name="use_type")
private Integer useType; private Integer useType;
/** /**
* 省份编码 * 省份编码
*/ */
@Column(name="province_code") @Column(name="province_code")
private String provinceCode; private String provinceCode;
/** /**
* 市区编码 * 市区编码
*/ */
@Column(name="city_code") @Column(name="city_code")
private String cityCode; private String cityCode;
/** /**
* 区县编码 * 区县编码
*/ */
@Column(name="district_code") @Column(name="district_code")
private String districtCode; private String districtCode;
/** /**
* 省份编码 * 省份编码
*/ */
private String regionCode; private String regionCode;
/** /**
* 详细地址 * 详细地址
*/ */
private String address; private String address;
/** /**
* '0-启用;1-停用 * '0-启用;1-停用
*/ */
private Integer status; private Integer status;
/** /**
* 经度 * 经度
*/ */
private Double longitude; private Double longitude;
/** /**
* 纬度 * 纬度
*/ */
private Double latitude; private Double latitude;
/** /**
* 换流站负责人 * 换流站负责人
*/ */
@Column(name="station_charge_user_id") @Column(name="station_charge_user_id")
private String stationChargeUserId; private String stationChargeUserId;
/** /**
* 安全负责人 * 安全负责人
*/ */
@Column(name="safety_charge_user_id") @Column(name="safety_charge_user_id")
private String safetyChargeUserId; private String safetyChargeUserId;
/** /**
* 创建人 * 创建人
*/ */
@Column(name="create_by") @Column(name="create_by")
private String createBy; private String createBy;
/** /**
* 创建日期 * 创建日期
*/ */
@Column(name="create_date") @Column(name="create_date")
private Date createDate; private Date createDate;
/** /**
* 备注 * 备注
*/ */
private String remark; private String remark;
/** /**
* 换流站负责人姓名 * 换流站负责人姓名
*/ */
@Column(name="station_charge_user_name") @Column(name="station_charge_user_name")
private String stationChargeUserName; private String stationChargeUserName;
/** /**
* 安全负责人姓名 * 安全负责人姓名
*/ */
@Column(name="safety_charge_user_name") @Column(name="safety_charge_user_name")
private String safetyChargeUserName; private String safetyChargeUserName;
/** /**
* 创建人姓名 * 创建人姓名
*/ */
@Column(name="create_user_name") @Column(name="create_user_name")
private String createUserName; private String createUserName;
/** /**
* 创建人联系方式 * 创建人联系方式
*/ */
@Column(name="create_user_phone_num") @Column(name="create_user_phone_num")
private String createUserPhoneNum; private String createUserPhoneNum;
/** /**
* 换流站负责人联系方式 * 换流站负责人联系方式
*/ */
@Column(name="station_user_phone_num") @Column(name="station_user_phone_num")
private String stationChargeUserPhoneNum; private String stationChargeUserPhoneNum;
/** /**
* 安全负责人联系方式 * 安全负责人联系方式
*/ */
@Column(name="safety_user_phone_num") @Column(name="safety_user_phone_num")
private String safetyChargeUserPhoneNum; private String safetyChargeUserPhoneNum;
public String getCreateUserPhoneNum() { public String getCreateUserPhoneNum() {
return createUserPhoneNum; return createUserPhoneNum;
} }
public String getStationChargeUserPhoneNum() { public String getStationChargeUserPhoneNum() {
return stationChargeUserPhoneNum; return stationChargeUserPhoneNum;
} }
public String getSafetyChargeUserPhoneNum() { public String getSafetyChargeUserPhoneNum() {
return safetyChargeUserPhoneNum; return safetyChargeUserPhoneNum;
} }
public void setCreateUserPhoneNum(String createUserPhoneNum) { public void setCreateUserPhoneNum(String createUserPhoneNum) {
this.createUserPhoneNum = createUserPhoneNum; this.createUserPhoneNum = createUserPhoneNum;
} }
public void setStationChargeUserPhoneNum(String stationChargeUserPhoneNum) { public void setStationChargeUserPhoneNum(String stationChargeUserPhoneNum) {
this.stationChargeUserPhoneNum = stationChargeUserPhoneNum; this.stationChargeUserPhoneNum = stationChargeUserPhoneNum;
} }
public void setSafetyChargeUserPhoneNum(String safetyChargeUserPhoneNum) { public void setSafetyChargeUserPhoneNum(String safetyChargeUserPhoneNum) {
this.safetyChargeUserPhoneNum = safetyChargeUserPhoneNum; this.safetyChargeUserPhoneNum = safetyChargeUserPhoneNum;
} }
public void setCreateUserName(String createUserName) { public void setCreateUserName(String createUserName) {
this.createUserName = createUserName; this.createUserName = createUserName;
} }
public String getCreateUserName() { public String getCreateUserName() {
return createUserName; return createUserName;
} }
public String getStationChargeUserName() { public String getStationChargeUserName() {
return stationChargeUserName; return stationChargeUserName;
} }
public String getSafetyChargeUserName() { public String getSafetyChargeUserName() {
return safetyChargeUserName; return safetyChargeUserName;
} }
public void setStationChargeUserName(String stationChargeUserName) { public void setStationChargeUserName(String stationChargeUserName) {
this.stationChargeUserName = stationChargeUserName; this.stationChargeUserName = stationChargeUserName;
} }
public void setSafetyChargeUserName(String safetyChargeUserName) { public void setSafetyChargeUserName(String safetyChargeUserName) {
this.safetyChargeUserName = safetyChargeUserName; this.safetyChargeUserName = safetyChargeUserName;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getStationCode() { public String getStationCode() {
return stationCode; return stationCode;
} }
public void setStationCode(String stationCode) { public void setStationCode(String stationCode) {
this.stationCode = stationCode; this.stationCode = stationCode;
} }
public String getCode() { public String getCode() {
return code; return code;
} }
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
public Integer getElecType() { public Integer getElecType() {
return elecType; return elecType;
} }
public void setElecType(Integer elecType) { public void setElecType(Integer elecType) {
this.elecType = elecType; this.elecType = elecType;
} }
public Integer getUseType() { public Integer getUseType() {
return useType; return useType;
} }
public void setUseType(Integer useType) { public void setUseType(Integer useType) {
this.useType = useType; this.useType = useType;
} }
public String getProvinceCode() { public String getProvinceCode() {
return provinceCode; return provinceCode;
} }
public void setProvinceCode(String provinceCode) { public void setProvinceCode(String provinceCode) {
this.provinceCode = provinceCode; this.provinceCode = provinceCode;
} }
public String getCityCode() { public String getCityCode() {
return cityCode; return cityCode;
} }
public void setCityCode(String cityCode) { public void setCityCode(String cityCode) {
this.cityCode = cityCode; this.cityCode = cityCode;
} }
public String getDistrictCode() { public String getDistrictCode() {
return districtCode; return districtCode;
} }
public void setDistrictCode(String districtCode) { public void setDistrictCode(String districtCode) {
this.districtCode = districtCode; this.districtCode = districtCode;
} }
public String getAddress() { public String getAddress() {
return address; return address;
} }
public void setAddress(String address) { public void setAddress(String address) {
this.address = address; this.address = address;
} }
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }
public void setStatus(Integer status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
public Double getLongitude() { public Double getLongitude() {
return longitude; return longitude;
} }
public void setLongitude(Double longitude) { public void setLongitude(Double longitude) {
this.longitude = longitude; this.longitude = longitude;
} }
public Double getLatitude() { public Double getLatitude() {
return latitude; return latitude;
} }
public void setLatitude(Double latitude) { public void setLatitude(Double latitude) {
this.latitude = latitude; this.latitude = latitude;
} }
public String getStationChargeUserId() { public String getStationChargeUserId() {
return stationChargeUserId; return stationChargeUserId;
} }
public void setStationChargeUserId(String stationChargeUserId) { public void setStationChargeUserId(String stationChargeUserId) {
this.stationChargeUserId = stationChargeUserId; this.stationChargeUserId = stationChargeUserId;
} }
public String getSafetyChargeUserId() { public String getSafetyChargeUserId() {
return safetyChargeUserId; return safetyChargeUserId;
} }
public void setSafetyChargeUserId(String safetyChargeUserId) { public void setSafetyChargeUserId(String safetyChargeUserId) {
this.safetyChargeUserId = safetyChargeUserId; this.safetyChargeUserId = safetyChargeUserId;
} }
public String getCreateBy() { public String getCreateBy() {
return createBy; return createBy;
} }
public void setCreateBy(String createBy) { public void setCreateBy(String createBy) {
this.createBy = createBy; this.createBy = createBy;
} }
public String getRemark() { public String getRemark() {
return remark; return remark;
} }
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark; this.remark = remark;
} }
@Override @Override
public Date getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;
} }
@Override @Override
public void setCreateDate(Date createDate) { public void setCreateDate(Date createDate) {
this.createDate = createDate; this.createDate = createDate;
} }
@Transient @Transient
public String getRegionCode() { public String getRegionCode() {
return regionCode; return regionCode;
} }
public void setRegionCode(String regionCode) { public void setRegionCode(String regionCode) {
this.regionCode = regionCode; this.regionCode = regionCode;
} }
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; 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.ConcurrentHashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
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.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 org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
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;
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.model.ContingencyEvent; 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.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo; 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;
import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult; 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.ContingencyLogPublisher; import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
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.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.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap; import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.vo.Toke; import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
@Component @Component
@RuleActionBean(beanLabel = "动态预案" ) @RuleActionBean(beanLabel = "动态预案" )
public class ContingencyAction implements CustomerAction { public class ContingencyAction implements CustomerAction {
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message."; private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
public static final Logger log = LoggerFactory.getLogger(ContingencyAction.class); public static final Logger log = LoggerFactory.getLogger(ContingencyAction.class);
@Autowired @Autowired
private WebMqttComponent webMqttComponent; private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}") @Value("${auto-sys.push.type}")
private String pushType; private String pushType;
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String serviceName; private String serviceName;
@Value("${station.name}") @Value("${station.name}")
private String stationName; private String stationName;
@Autowired @Autowired
private IContingencyInstance iContingencyInstance; private IContingencyInstance iContingencyInstance;
@Autowired @Autowired
private FireStengthService fireStrengthService; private FireStengthService fireStrengthService;
@Autowired @Autowired
private ContingencyLogPublisher contingencyLogPublisher; private ContingencyLogPublisher contingencyLogPublisher;
@Autowired @Autowired
private IRiskSourceService riskSourceService; private IRiskSourceService riskSourceService;
@Autowired @Autowired
private IDutyModeServer dutyModeServer; private IDutyModeServer dutyModeServer;
@Autowired @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<>();
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<>(); public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>();
private static CacheMap cacheMap = CacheFactory.newChacheMap(); private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE"; private static final String TOKE = "TOKE";
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
//当值值班长(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>() {{
put("S1", "S1"); put("S1", "S1");
put("S2", "S2"); put("S2", "S2");
put("A1", "A1"); put("A1", "A1");
put("A2", "A2"); put("A2", "A2");
put("A3", "A3"); put("A3", "A3");
put("F1", "F1"); put("F1", "F1");
}}; }};
*/ */
/** /**
* 预案文件中值为和数据字典中的对应关系 * 预案文件中值为和数据字典中的对应关系
* 消防 * 消防
* F1 消防队长 fireLeader * F1 消防队长 fireLeader
* F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6 * F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
* FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6 * FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6
* 运维 * 运维
* S1 值班长 dutyLeader * S1 值班长 dutyLeader
* S2 副值班长 deputyDutyLeader * S2 副值班长 deputyDutyLeader
* B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6 * B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6
* A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6 * A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
*/ */
public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) { public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) {
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String orgCode = contingencyRo.getEquipmentOrgCode(); String orgCode = contingencyRo.getEquipmentOrgCode();
Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo()); Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo());
if (CollectionUtils.isEmpty(returnMap)) { if (CollectionUtils.isEmpty(returnMap)) {
stringStringMap = new HashMap<>(); stringStringMap = new HashMap<>();
returnMap = new HashMap<>(); returnMap = new HashMap<>();
Date curDate = new Date(); Date curDate = new Date();
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("dutyDate", curDate); param.put("dutyDate", curDate);
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString()); CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString());
// String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString()); // String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result); // JSONObject jsonObject = JSONObject.parseObject(result);
// JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString()); // JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString());
String JSONStr = JSON.toJSONString(commonResponse.getDataList()); String JSONStr = JSON.toJSONString(commonResponse.getDataList());
JSONArray dataList = JSONObject.parseArray(JSONStr); JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList)); log.info(String.format("请求值班系统返回dataList:%s", dataList));
if (!ObjectUtils.isEmpty(dataList)) { if (!ObjectUtils.isEmpty(dataList)) {
Map<String, String> finalReturnMap = returnMap; Map<String, String> finalReturnMap = returnMap;
dataList.forEach( dataList.forEach(
x -> { x -> {
JSONObject obj = (JSONObject) x; JSONObject obj = (JSONObject) x;
String name = obj.getString("position"); String name = obj.getString("position");
finalReturnMap.put(name, obj.getString("dutyName")); finalReturnMap.put(name, obj.getString("dutyName"));
} }
); );
} }
stringStringMap.put(batchNo, returnMap); stringStringMap.put(batchNo, returnMap);
} }
log.info(String.format("returnMap:【 %s 】", returnMap)); log.info(String.format("returnMap:【 %s 】", returnMap));
return returnMap; return returnMap;
} }
public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) { public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency; ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null); ro.setTelemetryMap(null);
ro.setTelesignallingMap(null); ro.setTelesignallingMap(null);
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName( constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message") PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this); ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr()); event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic); event.setTopic(topic);
event.setMsgType(msgType); event.setMsgType(msgType);
event.setContingency(contingency); event.setContingency(contingency);
contingencyLogPublisher.publish(event); contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){ } else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency); action.execute(msgType, contingency);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
* @param stepName 当前步骤名称 * @param stepName 当前步骤名称
* @param state 当前步骤状态 * @param state 当前步骤状态
* @param nextStepCode 下一步编号 * @param nextStepCode 下一步编号
* @param nextStepName 下一步名称 * @param nextStepName 下一步名称
* @param stepType 步骤类型,总览步骤、详细步骤 * @param stepType 步骤类型,总览步骤、详细步骤
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案") @RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案")
public void stepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, public void stepInfo(@MethodParam(paramLabel = "当前编号") String stepCode,
// @MethodParam(paramLabel = "步骤类型") String stepType, // @MethodParam(paramLabel = "步骤类型") String stepType,
@MethodParam(paramLabel = "对象") Object paramObj) { @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
SetpEnum[] stepArr = SetpEnum.values(); SetpEnum[] stepArr = SetpEnum.values();
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); Arrays.sort(stepArr, comparator);
boolean flage = false; boolean flage = false;
SetpEnum pstep = null; 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)) { if (!ObjectUtils.isEmpty(pstep)) {
preStep.put("stepCode", pstep.getValue()); preStep.put("stepCode", pstep.getValue());
preStep.put("stepName", pstep.getTitle()); preStep.put("stepName", pstep.getTitle());
} }
flage = true; flage = true;
} }
if (flage) { 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);
} }
pstep = step; pstep = step;
} }
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)); log.info("巡检消息发送规则" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result); this.sendcmd("steparea", contingencyRo, result);
} }
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案") @RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案")
public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) { public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo()); iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
} }
/** /**
* @param content 消息内容 * @param content 消息内容
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案") @RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) { public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换content中的变量 //转换content中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", ""); iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
try { try {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>(); ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> { list.forEach(action -> {
HashMap map = new HashMap(); HashMap map = new HashMap();
map.put("time", sdf.format(action.getCreateDate())); map.put("time", sdf.format(action.getCreateDate()));
map.put("stepName", action.getContent()); map.put("stepName", action.getContent());
records.add(map); records.add(map);
}); });
} }
tempmap1.put("content", records); tempmap1.put("content", records);
} 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);
this.sendcmd("recordarea", paramObj, result); this.sendcmd("recordarea", paramObj, result);
} }
/** /**
* <pre> * <pre>
* 智能辅助 * 智能辅助
* </pre> * </pre>
* *
* @param step 当前步骤 * @param step 当前步骤
* @param icon 图标 * @param icon 图标
* @param title 标题 * @param title 标题
* @param image 图片集合 * @param image 图片集合
* @param table 表格 * @param table 表格
* @param content 内容 * @param content 内容
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案") @RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案")
public void help(@MethodParam(paramLabel = "当前步骤") String step, public void help(@MethodParam(paramLabel = "当前步骤") String step,
@MethodParam(paramLabel = "图标")String icon, @MethodParam(paramLabel = "图标")String icon,
@MethodParam(paramLabel = "标题")String title, @MethodParam(paramLabel = "标题")String title,
@MethodParam(paramLabel = "图片集") String image, @MethodParam(paramLabel = "图片集") String image,
@MethodParam(paramLabel = "表格数据") String table, @MethodParam(paramLabel = "表格数据") String table,
@MethodParam(paramLabel = "文本内容") String content, @MethodParam(paramLabel = "文本内容") String content,
@MethodParam(paramLabel = "对象") Object paramObj) { @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换智能辅助中的变量 //转换智能辅助中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("icon", icon); tempmap1.put("icon", icon);
tempmap1.put("step", step); tempmap1.put("step", step);
tempmap1.put("title", title); tempmap1.put("title", title);
tempmap1.put("content", content); tempmap1.put("content", content);
tempmap1.put("image", image); tempmap1.put("image", image);
tempmap1.put("table", table); tempmap1.put("table", table);
// tempmap1.put("batchNo", contingencyRo.getBatchNo()); // tempmap1.put("batchNo", contingencyRo.getBatchNo());
// tempmap1.put("contingencyRo", contingencyRo); // tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("helparea", paramObj, result); this.sendcmd("helparea", paramObj, result);
} }
private String instedParams(String content, ContingencyRo contingencyRo) { private String instedParams(String content, ContingencyRo contingencyRo) {
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo); Map<String, String> strengthMap = this.getStrengthMap(contingencyRo);
for (String key : strengthMap.keySet()) for (String key : strengthMap.keySet())
content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key)); content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
Field[] fields = contingencyRo.getClass().getDeclaredFields(); Field[] fields = contingencyRo.getClass().getDeclaredFields();
Method getMethod = null; Method getMethod = null;
try { try {
for (Field field : fields) { for (Field field : fields) {
if (field.getName().equals("serialVersionUID")) if (field.getName().equals("serialVersionUID"))
continue; continue;
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1); String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod); getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
String value = String.valueOf(getMethod.invoke(contingencyRo)); String value = String.valueOf(getMethod.invoke(contingencyRo));
content = content.replaceAll("\\$\\{" + field.getName() + "}", value); content = content.replaceAll("\\$\\{" + field.getName() + "}", value);
} }
content = getNative(content); content = getNative(content);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return content; return content;
} }
public String getNative(String str) public String getNative(String str)
{ {
Pattern p = Pattern.compile("\\$\\{(.*?)\\}"); Pattern p = Pattern.compile("\\$\\{(.*?)\\}");
Matcher m = p.matcher(str); Matcher m = p.matcher(str);
while (m.find()) while (m.find())
{ {
String parameter = m.group(); String parameter = m.group();
Object parametervalue = ELEvaluationContext Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1)); .getValue(parameter.substring(1, parameter.length() - 1));
if(parametervalue != null) if(parametervalue != null)
str = str.replace(parameter, str = str.replace(parameter,
parametervalue != null ? parametervalue.toString() : null); parametervalue != null ? parametervalue.toString() : null);
} }
return str; return str;
} }
/** /**
* 交互动作 * 交互动作
* *
* @param actionName 动作名称 * @param actionName 动作名称
* @param icon 图标 * @param icon 图标
* @param tips 提示信息 * @param tips 提示信息
* @param buttonJson 按钮json字符串 * @param buttonJson 按钮json字符串
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案") @RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
public void operation(@MethodParam(paramLabel = "动作名称") String actionName, public void operation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips, @MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "预案对象") Object paramObj) { @MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换content中的变量 //转换content中的变量
tips = instedParams(tips, contingencyRo); tips = instedParams(tips, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson); String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
tempmap1.put("actionName", actionName); tempmap1.put("actionName", actionName);
tempmap1.put("icon", icon); tempmap1.put("icon", icon);
tempmap1.put("tips", tips); tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson); tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId); tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("optionarea", paramObj, result); this.sendcmd("optionarea", paramObj, result);
} }
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) { private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
/** /**
* batchNo * batchNo
* stepCode * stepCode
* buttonCode * buttonCode
* confirm * confirm
* contingencyPlanId * contingencyPlanId
* stepState * stepState
*/ */
try { try {
Map button = objectMapper.readValue(buttonJson, Map.class); Map button = objectMapper.readValue(buttonJson, Map.class);
Map operateInstance = (Map) ((List) button.get("operate")).get(0); Map operateInstance = (Map) ((List) button.get("operate")).get(0);
ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus(); ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus();
contingencyDeviceStatus.setActionName(actionName); contingencyDeviceStatus.setActionName(actionName);
contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code"))); contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code")));
contingencyDeviceStatus.setConfirm("CONFIRM"); contingencyDeviceStatus.setConfirm("CONFIRM");
contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId); contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId);
contingencyDeviceStatus.setEquipmentId(equipmentId); contingencyDeviceStatus.setEquipmentId(equipmentId);
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode"))); contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState"))); contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus); riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
/** /**
* 保存交互动作 * 保存交互动作
* *
* @param actionName 动作名称 * @param actionName 动作名称
* @param icon 图标 * @param icon 图标
* @param tips 提示信息 * @param tips 提示信息
* @param buttonJson 按钮json字符串 * @param buttonJson 按钮json字符串
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案") @RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案")
public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName, public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips, @MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "对象") Object paramObj) { @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换content中的变量 //转换content中的变量
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
try { try {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>(); ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> { list.forEach(action -> {
HashMap map = new HashMap(); HashMap map = new HashMap();
map.put("time", sdf.format(action.getCreateDate())); map.put("time", sdf.format(action.getCreateDate()));
map.put("stepName", action.getContent()); map.put("stepName", action.getContent());
records.add(map); records.add(map);
}); });
} }
tempmap1.put("content", records); tempmap1.put("content", records);
} 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);
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) {
String cacheKey = batchNo + actionName; String cacheKey = batchNo + actionName;
String contingencyPlanId = null; String contingencyPlanId = null;
ContingencyPlanInstance contingencyPlanInstance = null; ContingencyPlanInstance contingencyPlanInstance = null;
if (OPERATE_RECORD_ID.get(cacheKey) == null) { if (OPERATE_RECORD_ID.get(cacheKey) == null) {
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon); contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon);
contingencyPlanId = contingencyPlanInstance.getId(); contingencyPlanId = contingencyPlanInstance.getId();
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId); OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
} else { } else {
contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey); contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey);
OPERATE_RECORD_ID.remove(cacheKey); OPERATE_RECORD_ID.remove(cacheKey);
} }
return contingencyPlanId; return contingencyPlanId;
} }
/** /**
* 地图动作推送 * 地图动作推送
* *
* @param actionName 动作名称标识 * @param actionName 动作名称标识
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案") @RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案")
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) { public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("======================================================================================="); log.error("=======================================================================================");
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName); tempmap1.put("key", actionName);
tempmap1.put("content",paramJSON); tempmap1.put("content",paramJSON);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
} }
@RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案") @RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案")
public void mapCartoonAction( public void mapCartoonAction(
@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "动作名称标识") String actionName,
@MethodParam(paramLabel = "动作类型") String actionType, @MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON, @MethodParam(paramLabel = "动作类型参数") String paramJSON,
@MethodParam(paramLabel = "对象") Object paramObj) { @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("======================================================================================="); log.error("=======================================================================================");
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo); String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName); tempmap1.put("key", actionName);
tempmap1.put("content",actionType); tempmap1.put("content",actionType);
tempmap1.put("parameter",parameter); tempmap1.put("parameter",parameter);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
} }
/** /**
* 顶部消息提示 * 顶部消息提示
* *
* @param content 消息内容 * @param content 消息内容
* @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE * @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案") @RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案")
public void topMessage( public void topMessage(
@MethodParam(paramLabel = "标题") String title, @MethodParam(paramLabel = "标题") String title,
@MethodParam(paramLabel = "内容") String content, @MethodParam(paramLabel = "内容") String content,
@MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "类型") String messageType, @MethodParam(paramLabel = "类型") String messageType,
@MethodParam(paramLabel = "对象") Object paramObj) { @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
//转换content中的变量 //转换content中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
tempmap1.put("content", content); tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title); tempmap1.put("title", title);
tempmap1.put("icon", icon); tempmap1.put("icon", icon);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
} }
/** /**
* 启动预案 * 启动预案
* *
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "启动预案", project = "换流站消防专项预案") @RuleMethod(methodLabel = "启动预案", project = "换流站消防专项预案")
public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) { public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event"); tempmap1.put("type", "event");
tempmap1.put("content", "startPlan"); tempmap1.put("content", "startPlan");
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
redisTemplate.opsForValue().set("contingencyRo", contingencyRo); redisTemplate.opsForValue().set("contingencyRo", contingencyRo);
} }
/** /**
* 启动预案 * 启动预案
* *
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "结束预案", project = "换流站消防专项预案") @RuleMethod(methodLabel = "结束预案", project = "换流站消防专项预案")
public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) { public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event"); tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan"); tempmap1.put("content", "stopPlan");
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo"); redisTemplate.delete("contingencyRo");
} }
@RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案") @RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案")
public void autoExecute( public void autoExecute(
@MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "步骤状态") String stepState, @MethodParam(paramLabel = "步骤状态") String stepState,
@MethodParam(paramLabel = "预案对象") Object paramObj) { @MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", ""); ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
// Toke toke = cacheMap.getValue(TOKE); // Toke toke = cacheMap.getValue(TOKE);
// if (toke == null) { // if (toke == null) {
// toke = remoteSecurityService.come(); // toke = remoteSecurityService.come();
// Long times = (long) (20 * 24 * 60 * 60); // Long times = (long) (20 * 24 * 60 * 60);
// cacheMap.setex(TOKE, toke, times); // cacheMap.setex(TOKE, toke, times);
// } // }
RequestContext.setToken(toke.getToke()); RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct()); RequestContext.setProduct(toke.getProduct());
try { try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM"); iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM");
iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState); iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案") @RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
public void addExecute( public void addExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) { @MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode); content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode); content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj; DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId()); Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) { if (ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints = new HashMap<>(); equipemtnPoints = new HashMap<>();
} }
equipemtnPoints.put(stepCode+"-"+buttonCode, content); equipemtnPoints.put(stepCode+"-"+buttonCode, content);
tempmap1.put("type", "buttonCache"); tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values()); tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", ro, result); this.sendcmd("message", ro, result);
} }
@RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案") @RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案")
public void clearExecute( public void clearExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) { @MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode); content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode); content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj; DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId()); Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (!ObjectUtils.isEmpty(equipemtnPoints)) { if (!ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints.remove(stepCode+"-"+buttonCode); equipemtnPoints.remove(stepCode+"-"+buttonCode);
} }
tempmap1.put("type", "buttonCache"); tempmap1.put("type", "buttonCache");
if (!ObjectUtils.isEmpty(equipemtnPoints)) { if (!ObjectUtils.isEmpty(equipemtnPoints)) {
tempmap1.put("content", equipemtnPoints.values()); tempmap1.put("content", equipemtnPoints.values());
} else { } else {
tempmap1.put("content", new ArrayList()); tempmap1.put("content", new ArrayList());
} }
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", ro, result); this.sendcmd("message", ro, result);
} }
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案") @RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) { public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId()); Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache"); tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values()); tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
} }
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) { public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) {
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName( constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message") PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this); ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr()); event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic); event.setTopic(topic);
event.setMsgType(msgType); event.setMsgType(msgType);
event.setContingency(deviceRo); event.setContingency(deviceRo);
contingencyLogPublisher.publish(event); contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){ } else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, deviceRo); action.execute(msgType, deviceRo);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
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; package com.yeejoin.amos.fas.business.action;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService; import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent; import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService; import com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService;
@Component @Component
public class ContingencyLogListener implements ApplicationListener<ContingencyEvent>{ public class ContingencyLogListener implements ApplicationListener<ContingencyEvent>{
@Autowired @Autowired
IRuleRunningSnapshotService ruleRunningSnapshotService; IRuleRunningSnapshotService ruleRunningSnapshotService;
// @Autowired // @Autowired
// @Lazy // @Lazy
// IEquipmentHandlerService equipmentHandlerService; // IEquipmentHandlerService equipmentHandlerService;
@Override @Override
public void onApplicationEvent(ContingencyEvent event) { public void onApplicationEvent(ContingencyEvent event) {
ruleRunningSnapshotService.reacordPlan(event.getTopic(), event.getMsgType(), event.getMsgBody(), event.getContingency()); ruleRunningSnapshotService.reacordPlan(event.getTopic(), event.getMsgType(), event.getMsgBody(), event.getContingency());
// equipmentHandlerService.subscribeTopic(); // equipmentHandlerService.subscribeTopic();
} }
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
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.stereotype.Component; 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;
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;
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.action.result.message.ActionResultMessage;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
/** /**
* *
* <pre> * <pre>
* 风险态势图动作 * 风险态势图动作
* </pre> * </pre>
* *
* @author amos * @author amos
* @version $Id: RiskSituationAction.java, v 0.1 2019年5月16日 下午5:26:27 amos Exp $ * @version $Id: RiskSituationAction.java, v 0.1 2019年5月16日 下午5:26:27 amos Exp $
*/ */
@Component @Component
@RuleActionBean(beanLabel = "动态预案") @RuleActionBean(beanLabel = "动态预案")
public class RiskSituationAction implements CustomerAction public class RiskSituationAction implements CustomerAction
{ {
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message."; private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
@Autowired @Autowired
private WebMqttComponent webMqttComponent; private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}") @Value("${auto-sys.push.type}")
private String pushType; private String pushType;
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String serviceName; private String serviceName;
@Value("${station.name}") @Value("${station.name}")
private String stationName; private String stationName;
@RuleMethod(methodLabel = "气泡提示", project = "换流站消防专项预案") @RuleMethod(methodLabel = "气泡提示", project = "换流站消防专项预案")
public void sendBubbleTip(@MethodParam(paramLabel = "bizobj对象") Object bizobj, public void sendBubbleTip(@MethodParam(paramLabel = "bizobj对象") Object bizobj,
@MethodParam(paramLabel = "是否显示名称") Boolean showInfo, @MethodParam(paramLabel = "是否显示名称") Boolean showInfo,
@MethodParam(paramLabel = "标题") String title) @MethodParam(paramLabel = "标题") String title)
{ {
BubbleTipResult result = new BubbleTipResult(); BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj); tempmap1.put("bizobj", bizobj);
result.add(tempmap1); result.add(tempmap1);
//是否显示气泡 //是否显示气泡
Map<String, Object> tempmap2 = new HashMap<>(); Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("showInfo", showInfo); tempmap2.put("showInfo", showInfo);
result.add(tempmap2); result.add(tempmap2);
//显示title提示 //显示title提示
Map<String, Object> tempmap3 = new HashMap<>(); Map<String, Object> tempmap3 = new HashMap<>();
tempmap3.put("title", title); tempmap3.put("title", title);
result.add(tempmap3); result.add(tempmap3);
Constructor<?> constructor; Constructor<?> constructor;
try try
{ {
constructor = Class.forName( constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message") PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "bubbleTip"; String msgType = "bubbleTip";
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result); ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"rule"); String topic = String.format("/%s/%s/%s", serviceName, stationName,"rule");
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
} else { } else {
Object obj = action.execute(msgType, bizobj); Object obj = action.execute(msgType, bizobj);
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
@RuleMethod(methodLabel = "区域颜色改变", project = "换流站消防专项预案") @RuleMethod(methodLabel = "区域颜色改变", project = "换流站消防专项预案")
public void regionChange(@MethodParam(paramLabel = "bizobj对象") Object bizobj, @MethodParam(paramLabel = "颜色") String colour) public void regionChange(@MethodParam(paramLabel = "bizobj对象") Object bizobj, @MethodParam(paramLabel = "颜色") String colour)
{ {
BubbleTipResult result = new BubbleTipResult(); BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("bizobj", bizobj); tempmap1.put("bizobj", bizobj);
result.add(tempmap1); result.add(tempmap1);
//更改颜色 //更改颜色
Map<String, Object> tempmap2 = new HashMap<>(); Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("colour", colour); tempmap2.put("colour", colour);
result.add(tempmap2); result.add(tempmap2);
Constructor<?> constructor; Constructor<?> constructor;
try try
{ {
constructor = Class.forName( constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message") PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "changeColor"; String msgType = "changeColor";
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result); ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
webMqttComponent.publish("", toipResponse.toJsonStr()); webMqttComponent.publish("", toipResponse.toJsonStr());
} else { } else {
action.execute(msgType, bizobj); action.execute(msgType, bizobj);
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
//@ExposeAction(value = "区域闪烁",snapshot = false) //@ExposeAction(value = "区域闪烁",snapshot = false)
@RuleMethod(methodLabel = "区域闪烁", project = "换流站消防专项预案") @RuleMethod(methodLabel = "区域闪烁", project = "换流站消防专项预案")
public void regionFlicker(@MethodParam(paramLabel = "bizobj对象") Object bizobj, @MethodParam(paramLabel = "闪烁频率") Integer frequency) public void regionFlicker(@MethodParam(paramLabel = "bizobj对象") Object bizobj, @MethodParam(paramLabel = "闪烁频率") Integer frequency)
{ {
BubbleTipResult result = new BubbleTipResult(); BubbleTipResult result = new BubbleTipResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
result.add(tempmap1); result.add(tempmap1);
//更改颜色 //更改颜色
Map<String, Object> tempmap2 = new HashMap<>(); Map<String, Object> tempmap2 = new HashMap<>();
tempmap2.put("frequency", frequency); tempmap2.put("frequency", frequency);
result.add(tempmap2); result.add(tempmap2);
Constructor<?> constructor; Constructor<?> constructor;
try try
{ {
constructor = Class.forName( constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message") PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "message"; String msgType = "message";
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result); ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
webMqttComponent.publish("", toipResponse.toJsonStr()); webMqttComponent.publish("", toipResponse.toJsonStr());
} else { } else {
action.execute(msgType, null); action.execute(msgType, null);
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
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.stereotype.Component; 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;
import com.yeejoin.amos.fas.business.action.result.TipResult; import com.yeejoin.amos.fas.business.action.result.TipResult;
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.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;
/** /**
* *
* <pre> * <pre>
* 消息提示动作 * 消息提示动作
* </pre> * </pre>
* *
* @author amos * @author amos
* @version $Id: SimpleTipAction.java, v 0.1 2019年4月24日 下午2:47:37 amos Exp $ * @version $Id: SimpleTipAction.java, v 0.1 2019年4月24日 下午2:47:37 amos Exp $
*/ */
@Component @Component
public class SimpleTipAction implements CustomerAction public class SimpleTipAction implements CustomerAction
{ {
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message."; private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
@Autowired @Autowired
private IMessageService messageService; private IMessageService messageService;
@Autowired @Autowired
private WebMqttComponent webMqttComponent; private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}") @Value("${auto-sys.push.type}")
private String pushType; private String pushType;
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String serviceName; private String serviceName;
@Value("${station.name}") @Value("${station.name}")
private String stationName; private String stationName;
//@ExposeAction("消息提示") //@ExposeAction("消息提示")
public void sendMessageTip(Object bizobj, String title, String content, String type) public void sendMessageTip(Object bizobj, String title, String content, String type)
{ {
try try
{ {
ELEvaluationContext.setVariable("bizobj",bizobj); ELEvaluationContext.setVariable("bizobj",bizobj);
TipResult result = new TipResult(); TipResult result = new TipResult();
result.add(bizobj); result.add(bizobj);
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("title", title); tempmap1.put("title", title);
result.add(tempmap1); result.add(tempmap1);
Map<String, Object> tempmap2 = new HashMap<>(); Map<String, Object> tempmap2 = new HashMap<>();
content =DataItemUtil.getNative(content); content =DataItemUtil.getNative(content);
tempmap2.put("content", content); tempmap2.put("content", content);
result.add(tempmap2); result.add(tempmap2);
Constructor<?> constructor; Constructor<?> constructor;
constructor = Class.forName( constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message") PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); .getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
String msgType = "message"; String msgType = "message";
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result); ToipResponse toipResponse = action.buildResponse(msgType, bizobj, result);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"rule"); String topic = String.format("/%s/%s/%s", serviceName, stationName,"rule");
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
} else { } else {
action.execute(msgType, bizobj); action.execute(msgType, bizobj);
} }
} }
catch (Exception e) catch (Exception e)
{ {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
// @SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")
// private void saveMessageAction(AbstractActionResult abstractActionResult,String type) // private void saveMessageAction(AbstractActionResult abstractActionResult,String type)
// { // {
// Message message = new Message(); // Message message = new Message();
// List<Map<String, Object>> list = (List<Map<String, Object>>) abstractActionResult.getData(); // List<Map<String, Object>> list = (List<Map<String, Object>>) abstractActionResult.getData();
// for(Map<String, Object> map : list) { // for(Map<String, Object> map : list) {
// for(String str: map.keySet()) { // for(String str: map.keySet()) {
// if(str.equals("content")) { // if(str.equals("content")) {
// message.setContent(map.get("content").toString()); // message.setContent(map.get("content").toString());
// }else // }else
// if (str.equals("title")) // if (str.equals("title"))
// { // {
// message.setTitle(map.get("title").toString()); // message.setTitle(map.get("title").toString());
// } // }
// } // }
// if(!StringUtil.isNotEmpty(message.getContent())){ // if(!StringUtil.isNotEmpty(message.getContent())){
// continue; // continue;
// } // }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof MessageRo) { // if (abstractActionResult.getToipResponse().getBizObj() instanceof MessageRo) {
// MessageRo messageRo = (MessageRo)abstractActionResult.getToipResponse().getBizObj(); // MessageRo messageRo = (MessageRo)abstractActionResult.getToipResponse().getBizObj();
// message.setTime(messageRo.getDateTime()); // message.setTime(messageRo.getDateTime());
// message.setBizId(messageRo.getId()); // message.setBizId(messageRo.getId());
// } // }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof RiskSourceRuleRo) { // if (abstractActionResult.getToipResponse().getBizObj() instanceof RiskSourceRuleRo) {
// RiskSourceRuleRo riskSourceRuleRo = (RiskSourceRuleRo) abstractActionResult.getToipResponse().getBizObj(); // RiskSourceRuleRo riskSourceRuleRo = (RiskSourceRuleRo) abstractActionResult.getToipResponse().getBizObj();
// message.setTime(DateUtil.getNow()); // message.setTime(DateUtil.getNow());
// message.setBizId(StringUtil.isNotEmpty(riskSourceRuleRo.getId()) ? // message.setBizId(StringUtil.isNotEmpty(riskSourceRuleRo.getId()) ?
// String.valueOf(riskSourceRuleRo.getId()) : ""); // String.valueOf(riskSourceRuleRo.getId()) : "");
// } // }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof ProtalDataRo) { // if (abstractActionResult.getToipResponse().getBizObj() instanceof ProtalDataRo) {
// ProtalDataRo protalDataRo = (ProtalDataRo) abstractActionResult.getToipResponse().getBizObj(); // ProtalDataRo protalDataRo = (ProtalDataRo) abstractActionResult.getToipResponse().getBizObj();
// message.setTime(DateUtil.getNow()); // message.setTime(DateUtil.getNow());
// message.setBizId(StringUtil.isNotEmpty(protalDataRo.getId()) ? String.valueOf(protalDataRo.getId()) : ""); // message.setBizId(StringUtil.isNotEmpty(protalDataRo.getId()) ? String.valueOf(protalDataRo.getId()) : "");
// } // }
// if (abstractActionResult.getToipResponse().getBizObj() instanceof FireEquimentDataRo) { // if (abstractActionResult.getToipResponse().getBizObj() instanceof FireEquimentDataRo) {
// FireEquimentDataRo fireEquimentDataRo = (FireEquimentDataRo) abstractActionResult.getToipResponse().getBizObj(); // FireEquimentDataRo fireEquimentDataRo = (FireEquimentDataRo) abstractActionResult.getToipResponse().getBizObj();
// message.setTime(DateUtil.getNow()); // message.setTime(DateUtil.getNow());
// message.setBizId(StringUtil.isNotEmpty(fireEquimentDataRo.getId()) ? String.valueOf(fireEquimentDataRo.getId()) : ""); // message.setBizId(StringUtil.isNotEmpty(fireEquimentDataRo.getId()) ? String.valueOf(fireEquimentDataRo.getId()) : "");
// } // }
// message.setBizclassName(abstractActionResult.getToipResponse().getBizObj().getClass().toString()); // message.setBizclassName(abstractActionResult.getToipResponse().getBizObj().getClass().toString());
// message.setType(type); // message.setType(type);
// message.setId(UUID.randomUUID().toString()); // message.setId(UUID.randomUUID().toString());
// messageService.save(message); // messageService.save(message);
// } // }
// } // }
} }
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import java.util.ArrayList; import java.util.ArrayList;
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.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
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.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
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.param.AlarmParam; import com.yeejoin.amos.fas.business.param.AlarmParam;
import com.yeejoin.amos.fas.business.param.FmeaBindParam; import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.intfc.IRiskFactorService; import com.yeejoin.amos.fas.business.service.intfc.IRiskFactorService;
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.vo.ReginParams; import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.config.Permission; import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.common.request.CommonPageable; import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse; import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@RestController @RestController
@RequestMapping("/api/risksource") @RequestMapping("/api/risksource")
@Api(tags = "风险点API") @Api(tags = "风险点API")
public class RiskSourceController extends BaseController { public class RiskSourceController extends BaseController {
private final Logger log = LoggerFactory.getLogger(RiskSourceController.class); private final Logger log = LoggerFactory.getLogger(RiskSourceController.class);
private final static String IS_RISK_AREA = "TRUE"; private final static String IS_RISK_AREA = "TRUE";
@Autowired @Autowired
IRiskFactorService iRiskFactorService; IRiskFactorService iRiskFactorService;
@Autowired @Autowired
IRiskSourceService riskSourceService; IRiskSourceService riskSourceService;
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "查询风险点子项", notes = "查询风险点子项") @ApiOperation(httpMethod = "GET", value = "查询风险点子项", notes = "查询风险点子项")
@RequestMapping(value = "/children/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/children/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryRiskSourceByPage() { public CommonResponse queryRiskSourceByPage() {
return CommonResponseUtil.success(riskSourceService.queryForRegion()); return CommonResponseUtil.success(riskSourceService.queryForRegion());
} }
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "三维图统计", notes = "三维图统计") @ApiOperation(httpMethod = "GET", value = "三维图统计", notes = "三维图统计")
@RequestMapping(value = "/collection3d", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/collection3d", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse collection3d() { public CommonResponse collection3d() {
return CommonResponseUtil.success(riskSourceService.queryFor3DStatistics()); return CommonResponseUtil.success(riskSourceService.queryFor3DStatistics());
} }
/** /**
* 查询风险点RPN统计 * 查询风险点RPN统计
* *
* @return * @return
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "查询风险点RPN统计", notes = "查询风险点RPN统计") @ApiOperation(httpMethod = "GET", value = "查询风险点RPN统计", notes = "查询风险点RPN统计")
@RequestMapping(value = "/rpn/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/rpn/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryRPNReport() { public CommonResponse queryRPNReport() {
return CommonResponseUtil.success(riskSourceService.queryRPNReport()); return CommonResponseUtil.success(riskSourceService.queryRPNReport());
} }
/** /**
* 风险上升率 * 风险上升率
* *
* @return * @return
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "风险上升率", notes = "风险上升率") @ApiOperation(httpMethod = "GET", value = "风险上升率", notes = "风险上升率")
@RequestMapping(value = "/riseuprate", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/riseuprate", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryForRiseUp() throws Exception { public CommonResponse queryForRiseUp() throws Exception {
return CommonResponseUtil.success(riskSourceService.queryForRiseUp()); return CommonResponseUtil.success(riskSourceService.queryForRiseUp());
} }
/** /**
* 发生率严重度矩阵 * 发生率严重度矩阵
* *
* @return * @return
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "发生率严重度矩阵", notes = "发生率严重度矩阵") @ApiOperation(httpMethod = "GET", value = "发生率严重度矩阵", notes = "发生率严重度矩阵")
@RequestMapping(value = "/matrix", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/matrix", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryForMatrix() throws Exception { public CommonResponse queryForMatrix() throws Exception {
return CommonResponseUtil.success(riskSourceService.queryForMatrix()); return CommonResponseUtil.success(riskSourceService.queryForMatrix());
} }
/** /**
* 获取风险点树型结构 * 获取风险点树型结构
* *
* @return * @return
*/ */
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "获取风险点树型结构", notes = "获取风险点树型结构") @ApiOperation(httpMethod = "GET", value = "获取风险点树型结构", notes = "获取风险点树型结构")
@RequestMapping(value = "/riskSourceTress", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/riskSourceTress", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getRiskSourceTress() { public CommonResponse getRiskSourceTress() {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams); String compCode = getOrgCode(reginParams);
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode); List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode);
return CommonResponseUtil.success(getRiskSourcesTree(riskSources)); return CommonResponseUtil.success(getRiskSourcesTree(riskSources));
} }
@Permission @Permission
@ApiOperation(value = "远程同步", notes = "将本地 风险模型推送到远程同步") @ApiOperation(value = "远程同步", notes = "将本地 风险模型推送到远程同步")
@PutMapping(value = "/synToEquipManage") @PutMapping(value = "/synToEquipManage")
public CommonResponse synToEquipManage() { public CommonResponse synToEquipManage() {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams); String compCode = getOrgCode(reginParams);
if (!riskSourceService.isSynEquipManage()) { if (!riskSourceService.isSynEquipManage()) {
return CommonResponseUtil.failure("同步功能未开启"); return CommonResponseUtil.failure("同步功能未开启");
} }
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode).stream().filter(source -> IS_RISK_AREA.equalsIgnoreCase(source.getIsRegion())).collect(Collectors.toList()); List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode).stream().filter(source -> IS_RISK_AREA.equalsIgnoreCase(source.getIsRegion())).collect(Collectors.toList());
String synMsg = riskSourceService.synToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS, getRiskSourcesTree(riskSources)); String synMsg = riskSourceService.synToEquipManage(getAppKey(), getProduct(), getToken(), SUCCESS, getRiskSourcesTree(riskSources));
if (synMsg != null) { if (synMsg != null) {
return CommonResponseUtil.failure(synMsg); return CommonResponseUtil.failure(synMsg);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
/** /**
* 获取区域树型结构 * 获取区域树型结构
* *
* @return * @return
*/ */
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "获取区域树型结构", notes = "获取区域树型结构") @ApiOperation(httpMethod = "GET", value = "获取区域树型结构", notes = "获取区域树型结构")
@RequestMapping(value = "/regionTress", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/regionTress", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getRegionTress() { public CommonResponse getRegionTress() {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams); String compCode = getOrgCode(reginParams);
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode); List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode);
return CommonResponseUtil.success(getRegionTree(riskSources)); return CommonResponseUtil.success(getRegionTree(riskSources));
} }
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面", notes = "获取风险点树型结构") @ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面", notes = "获取风险点树型结构")
@RequestMapping(value = "/query3DStatistics/{markerType}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/query3DStatistics/{markerType}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse query3DStatistics(@PathVariable(value = "markerType", required = true) String markerType) throws Exception { public CommonResponse query3DStatistics(@PathVariable(value = "markerType", required = true) String markerType) throws Exception {
if ("riskSource".equals(markerType)) { if ("riskSource".equals(markerType)) {
return riskSourceStatistics(); return riskSourceStatistics();
} else if ("risk".equals(markerType)) { } else if ("risk".equals(markerType)) {
return riskStatistics(); return riskStatistics();
} else if ("impEquipment".equals(markerType)) { } else if ("impEquipment".equals(markerType)) {
return equipStatistics(); return equipStatistics();
} else if ("fireResource".equals(markerType)) { } else if ("fireResource".equals(markerType)) {
String[] type = {"4", "3"}; String[] type = {"4", "3"};
return equipStatistics(type); return equipStatistics(type);
} else if ("monitorEquipment".equals(markerType)) { } else if ("monitorEquipment".equals(markerType)) {
String[] type = {"0"}; String[] type = {"0"};
return equipStatistics(type); return equipStatistics(type);
} else if ("video".equals(markerType)) { } else if ("video".equals(markerType)) {
String[] type = {"2"}; String[] type = {"2"};
return equipStatistics(type); return equipStatistics(type);
} }
return CommonResponseUtil.failure("未定义类型"); return CommonResponseUtil.failure("未定义类型");
} }
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面", notes = "获取风险点树型结构") @ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面", notes = "获取风险点树型结构")
@RequestMapping(value = "/riskSourceStatistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/riskSourceStatistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse riskSourceStatistics() throws Exception { public CommonResponse riskSourceStatistics() throws Exception {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams); String compCode = getOrgCode(reginParams);
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode); List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceTrees(compCode);
List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesTree(riskSources); List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesTree(riskSources);
return CommonResponseUtil.success(riskSourceStatistics(treeRiskSources)); return CommonResponseUtil.success(riskSourceStatistics(treeRiskSources));
} }
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面设备统计", notes = "统计级别为1的风险点下面设备统计") @ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面设备统计", notes = "统计级别为1的风险点下面设备统计")
@RequestMapping(value = "/equipStatistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/equipStatistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse equipStatistics() throws Exception { public CommonResponse equipStatistics() throws Exception {
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceEquipStatistics(); List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceEquipStatistics();
List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesEquipTree(riskSources); List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesEquipTree(riskSources);
return CommonResponseUtil.success(riskSourceEquipStatistics(treeRiskSources, true, 0)); return CommonResponseUtil.success(riskSourceEquipStatistics(treeRiskSources, true, 0));
} }
@Permission @Permission
//@Authorization(ingore = true) //@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "统计级别为1的巡检点统计", notes = "统计级别为1的巡检点统计") @ApiOperation(httpMethod = "GET", value = "统计级别为1的巡检点统计", notes = "统计级别为1的巡检点统计")
@RequestMapping(value = "/checkPointStatistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/checkPointStatistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse riskStatistics() throws Exception { public CommonResponse riskStatistics() throws Exception {
List<RiskSourceTreeResponse> riskSources = riskSourceService.getCheckPointRiskSources(); List<RiskSourceTreeResponse> riskSources = riskSourceService.getCheckPointRiskSources();
List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesEquipTree(riskSources); List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesEquipTree(riskSources);
return CommonResponseUtil.success(checkPointEquipStatistics(treeRiskSources, false, 0)); return CommonResponseUtil.success(checkPointEquipStatistics(treeRiskSources, false, 0));
} }
private Object checkPointEquipStatistics(List<RiskSourceTreeResponse> list, boolean isLevel, int level) { private Object checkPointEquipStatistics(List<RiskSourceTreeResponse> list, boolean isLevel, int level) {
List<Map<String, Object>> treeList = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> treeList = new ArrayList<Map<String, Object>>();
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// List<RiskSourceTreeResponse> firstChildrens = list.get(0).getChildren(); // List<RiskSourceTreeResponse> firstChildrens = list.get(0).getChildren();
list.forEach(item -> { list.forEach(item -> {
// if (!ObjectUtils.isEmpty(item.getPosition3d())) { // if (!ObjectUtils.isEmpty(item.getPosition3d())) {
Map<String, Object> itemMap = (Map<String, Object>) map.get(item.getId()); Map<String, Object> itemMap = (Map<String, Object>) map.get(item.getId());
if (ObjectUtils.isEmpty(itemMap)) { if (ObjectUtils.isEmpty(itemMap)) {
itemMap = new HashMap<>(); itemMap = new HashMap<>();
itemMap.put("id", item.getId()); itemMap.put("id", item.getId());
itemMap.put("key", "key" + item.getId()); itemMap.put("key", "key" + item.getId());
itemMap.put("name", item.getName()); itemMap.put("name", item.getName());
if (isLevel) { if (isLevel) {
itemMap.put("level", level); itemMap.put("level", level);
} else { } else {
itemMap.put("level", item.getLevel()); itemMap.put("level", item.getLevel());
} }
Map<String, Object> position = new HashMap<>(); Map<String, Object> position = new HashMap<>();
if (!ObjectUtils.isEmpty(item.getPosition3d())) { if (!ObjectUtils.isEmpty(item.getPosition3d())) {
String[] pos = item.getPosition3d().split(","); String[] pos = item.getPosition3d().split(",");
position.put("x", pos[0]); position.put("x", pos[0]);
position.put("y", pos[1]); position.put("y", pos[1]);
position.put("z", pos[2]); position.put("z", pos[2]);
} }
Map<String, Object> rotation = new HashMap<>(); Map<String, Object> rotation = new HashMap<>();
rotation.put("x", 0); rotation.put("x", 0);
rotation.put("y", 0); rotation.put("y", 0);
rotation.put("z", 0); rotation.put("z", 0);
Map<String, Object> scale = new HashMap<>(); Map<String, Object> scale = new HashMap<>();
scale.put("x", 1); scale.put("x", 1);
scale.put("y", 1); scale.put("y", 1);
scale.put("z", 1); scale.put("z", 1);
itemMap.put("position", position); itemMap.put("position", position);
itemMap.put("scale", scale); itemMap.put("scale", scale);
itemMap.put("rotation", rotation); itemMap.put("rotation", rotation);
} }
List<Map> itemCountList = new ArrayList<>(); List<Map> itemCountList = new ArrayList<>();
Map<String, Object> ItemCount = new HashMap<>(); Map<String, Object> ItemCount = new HashMap<>();
ItemCount.put("name", "合格"); ItemCount.put("name", "合格");
ItemCount.put("count", getPointChildrenCount(item, "Qualified")); ItemCount.put("count", getPointChildrenCount(item, "Qualified"));
itemCountList.add(ItemCount); itemCountList.add(ItemCount);
Map<String, Object> ItemCount1 = new HashMap<>(); Map<String, Object> ItemCount1 = new HashMap<>();
ItemCount1.put("name", "不合格"); ItemCount1.put("name", "不合格");
ItemCount1.put("count", getPointChildrenCount(item, "Unqualified")); ItemCount1.put("count", getPointChildrenCount(item, "Unqualified"));
itemCountList.add(ItemCount1); itemCountList.add(ItemCount1);
Map<String, Object> ItemCount2 = new HashMap<>(); Map<String, Object> ItemCount2 = new HashMap<>();
ItemCount2.put("name", "漏检"); ItemCount2.put("name", "漏检");
ItemCount2.put("count", getPointChildrenCount(item, "Omission")); ItemCount2.put("count", getPointChildrenCount(item, "Omission"));
itemCountList.add(ItemCount2); itemCountList.add(ItemCount2);
// Map<String, Object> ItemCount3 = new HashMap<>(); // Map<String, Object> ItemCount3 = new HashMap<>();
// ItemCount.put("name", "合格"); // ItemCount.put("name", "合格");
// ItemCount3.put("count", getPointChildrenCount(item, "Unplan")); // ItemCount3.put("count", getPointChildrenCount(item, "Unplan"));
// itemCountList.add(ItemCount3); // itemCountList.add(ItemCount3);
itemMap.put("statisticsData", itemCountList); itemMap.put("statisticsData", itemCountList);
map.put(item.getId() + "", itemMap); map.put(item.getId() + "", itemMap);
// } // }
}); });
for (String key : map.keySet()) { for (String key : map.keySet()) {
treeList.add((Map<String, Object>) map.get(key)); treeList.add((Map<String, Object>) map.get(key));
} }
} }
return treeList; return treeList;
} }
private static int getPointChildrenCount(RiskSourceTreeResponse riskSource, String status) { private static int getPointChildrenCount(RiskSourceTreeResponse riskSource, String status) {
if (ObjectUtils.isEmpty(riskSource.getChildren())) { if (ObjectUtils.isEmpty(riskSource.getChildren())) {
return 0; return 0;
} }
int count = 0; int count = 0;
if (status.equals("Qualified")) { if (status.equals("Qualified")) {
count += riskSource.getQualified(); count += riskSource.getQualified();
} else if (status.equals("Unqualified")) { } else if (status.equals("Unqualified")) {
count += riskSource.getUnqualified(); count += riskSource.getUnqualified();
} else if (status.equals("Omission")) { } else if (status.equals("Omission")) {
count += riskSource.getOmission(); count += riskSource.getOmission();
} else if (status.equals("Unplan")) { } else if (status.equals("Unplan")) {
count += riskSource.getUnplan(); count += riskSource.getUnplan();
} }
for (RiskSourceTreeResponse action : riskSource.getChildren()) { for (RiskSourceTreeResponse action : riskSource.getChildren()) {
if (ObjectUtils.isEmpty(action.getPosition3d())) { if (ObjectUtils.isEmpty(action.getPosition3d())) {
continue; continue;
} }
count = count + getPointChildrenCount(action, status); count = count + getPointChildrenCount(action, status);
if (status.equals("Qualified")) { if (status.equals("Qualified")) {
count += action.getQualified(); count += action.getQualified();
} else if (status.equals("Unqualified")) { } else if (status.equals("Unqualified")) {
count += action.getUnqualified(); count += action.getUnqualified();
} else if (status.equals("Omission")) { } else if (status.equals("Omission")) {
count += action.getOmission(); count += action.getOmission();
} else if (status.equals("Unplan")) { } else if (status.equals("Unplan")) {
count += action.getUnplan(); count += action.getUnplan();
} }
} }
return count; return count;
} }
@Permission @Permission
// @Authorization(ingore = true) // @Authorization(ingore = true)
@ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面设备统计", notes = "统计级别为1的风险点下面设备统计") @ApiOperation(httpMethod = "GET", value = "统计级别为1的风险点下面设备统计", notes = "统计级别为1的风险点下面设备统计")
@RequestMapping(value = "/equipStatistics/{type}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/equipStatistics/{type}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse equipStatistics(@PathVariable(value = "type", required = true) String[] type) throws Exception { public CommonResponse equipStatistics(@PathVariable(value = "type", required = true) String[] type) throws Exception {
List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceEquipStatistics(type); List<RiskSourceTreeResponse> riskSources = riskSourceService.findRiskSourceEquipStatistics(type);
List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesEquipTree(riskSources); List<RiskSourceTreeResponse> treeRiskSources = getRiskSourcesEquipTree(riskSources);
return CommonResponseUtil.success(riskSourceEquipStatistics(treeRiskSources, true, 0)); return CommonResponseUtil.success(riskSourceEquipStatistics(treeRiskSources, true, 0));
} }
private static List<RiskSourceTreeResponse> getRiskSourcesEquipTree(List<RiskSourceTreeResponse> list) { private static List<RiskSourceTreeResponse> getRiskSourcesEquipTree(List<RiskSourceTreeResponse> list) {
List<RiskSourceTreeResponse> treeList = new ArrayList<RiskSourceTreeResponse>(); List<RiskSourceTreeResponse> treeList = new ArrayList<RiskSourceTreeResponse>();
for (RiskSourceTreeResponse tree : list) { for (RiskSourceTreeResponse tree : list) {
if (tree.getParentId() != null && tree.getParentId() == 1) { if (tree.getParentId() != null && tree.getParentId() == 1) {
treeList.add(tree); treeList.add(tree);
} }
for (RiskSourceTreeResponse treeNode : list) { for (RiskSourceTreeResponse treeNode : list) {
if (treeNode.getParentId().longValue() == tree.getId()) { if (treeNode.getParentId().longValue() == tree.getId()) {
if (tree.getChildren() == null) { if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<RiskSourceTreeResponse>()); tree.setChildren(new ArrayList<RiskSourceTreeResponse>());
} }
tree.getChildren().add(treeNode); tree.getChildren().add(treeNode);
} }
} }
} }
return treeList; return treeList;
} }
private Object riskSourceEquipStatistics(List<RiskSourceTreeResponse> list, Boolean isLevel, int level) { private Object riskSourceEquipStatistics(List<RiskSourceTreeResponse> list, Boolean isLevel, int level) {
List<Map<String, Object>> treeList = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> treeList = new ArrayList<Map<String, Object>>();
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// List<RiskSourceTreeResponse> firstChildrens = list.get(0).getChildren(); // List<RiskSourceTreeResponse> firstChildrens = list.get(0).getChildren();
list.forEach(item -> { list.forEach(item -> {
// if (!ObjectUtils.isEmpty(item.getPosition3d())) { // if (!ObjectUtils.isEmpty(item.getPosition3d())) {
Map<String, Object> itemMap = (Map<String, Object>) map.get(item.getId()); Map<String, Object> itemMap = (Map<String, Object>) map.get(item.getId());
if (ObjectUtils.isEmpty(itemMap)) { if (ObjectUtils.isEmpty(itemMap)) {
itemMap = new HashMap<>(); itemMap = new HashMap<>();
itemMap.put("id", item.getId()); itemMap.put("id", item.getId());
itemMap.put("key", "key" + item.getId()); itemMap.put("key", "key" + item.getId());
itemMap.put("name", item.getName()); itemMap.put("name", item.getName());
if (isLevel) { if (isLevel) {
itemMap.put("level", level); itemMap.put("level", level);
} else { } else {
itemMap.put("level", item.getLevel()); itemMap.put("level", item.getLevel());
} }
Map<String, Object> position = new HashMap<>(); Map<String, Object> position = new HashMap<>();
if (!ObjectUtils.isEmpty(item.getPosition3d())) { if (!ObjectUtils.isEmpty(item.getPosition3d())) {
String[] pos = item.getPosition3d().split(","); String[] pos = item.getPosition3d().split(",");
position.put("x", pos[0]); position.put("x", pos[0]);
position.put("y", pos[1]); position.put("y", pos[1]);
position.put("z", pos[2]); position.put("z", pos[2]);
} }
Map<String, Object> rotation = new HashMap<>(); Map<String, Object> rotation = new HashMap<>();
rotation.put("x", 0); rotation.put("x", 0);
rotation.put("y", 0); rotation.put("y", 0);
rotation.put("z", 0); rotation.put("z", 0);
Map<String, Object> scale = new HashMap<>(); Map<String, Object> scale = new HashMap<>();
scale.put("x", 1); scale.put("x", 1);
scale.put("y", 1); scale.put("y", 1);
scale.put("z", 1); scale.put("z", 1);
itemMap.put("position", position); itemMap.put("position", position);
itemMap.put("scale", scale); itemMap.put("scale", scale);
itemMap.put("rotation", rotation); itemMap.put("rotation", rotation);
} }
List<Map> itemCountList = new ArrayList<>(); List<Map> itemCountList = new ArrayList<>();
Map<String, Object> ItemCount = new HashMap<>(); Map<String, Object> ItemCount = new HashMap<>();
itemCountList.add(ItemCount); itemCountList.add(ItemCount);
ItemCount.put("count", getRiskSourceEquipChildrenCount(item)); ItemCount.put("count", getRiskSourceEquipChildrenCount(item));
itemMap.put("statisticsData", itemCountList); itemMap.put("statisticsData", itemCountList);
map.put(item.getId() + "", itemMap); map.put(item.getId() + "", itemMap);
// } // }
}); });
for (String key : map.keySet()) { for (String key : map.keySet()) {
treeList.add((Map<String, Object>) map.get(key)); treeList.add((Map<String, Object>) map.get(key));
} }
} }
return treeList; return treeList;
} }
private static int getRiskSourceEquipChildrenCount(RiskSourceTreeResponse item) { private static int getRiskSourceEquipChildrenCount(RiskSourceTreeResponse item) {
if (ObjectUtils.isEmpty(item.getChildren())) { if (ObjectUtils.isEmpty(item.getChildren())) {
return item.getCount(); return item.getCount();
} }
int count = item.getCount(); int count = item.getCount();
for (RiskSourceTreeResponse action : item.getChildren()) { for (RiskSourceTreeResponse action : item.getChildren()) {
count = count + getRiskSourceChildrenCount(action, null); count = count + getRiskSourceChildrenCount(action, null);
count += action.getCount(); count += action.getCount();
} }
return count; return count;
} }
private static List<Map<String, Object>> riskSourceStatistics(List<RiskSourceTreeResponse> list) { private static List<Map<String, Object>> riskSourceStatistics(List<RiskSourceTreeResponse> list) {
List<Map<String, Object>> treeList = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> treeList = new ArrayList<Map<String, Object>>();
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<RiskSourceTreeResponse> firstChildrens = list.get(0).getChildren(); List<RiskSourceTreeResponse> firstChildrens = list.get(0).getChildren();
firstChildrens.forEach(item -> { firstChildrens.forEach(item -> {
// if (!ObjectUtils.isEmpty(item.getPosition3d())) { // if (!ObjectUtils.isEmpty(item.getPosition3d())) {
Map<String, Object> itemMap = (Map<String, Object>) map.get(item.getId()); Map<String, Object> itemMap = (Map<String, Object>) map.get(item.getId());
if (ObjectUtils.isEmpty(itemMap)) { if (ObjectUtils.isEmpty(itemMap)) {
itemMap = new HashMap<>(); itemMap = new HashMap<>();
itemMap.put("id", item.getId()); itemMap.put("id", item.getId());
itemMap.put("key", "key" + item.getId()); itemMap.put("key", "key" + item.getId());
itemMap.put("name", item.getName()); itemMap.put("name", item.getName());
itemMap.put("level", item.getLevel()); itemMap.put("level", item.getLevel());
Map<String, Object> position = new HashMap<>(); Map<String, Object> position = new HashMap<>();
if (!ObjectUtils.isEmpty(item.getPosition3d())) { if (!ObjectUtils.isEmpty(item.getPosition3d())) {
String[] pos = item.getPosition3d().split(","); String[] pos = item.getPosition3d().split(",");
position.put("x", pos[0]); position.put("x", pos[0]);
position.put("y", pos[1]); position.put("y", pos[1]);
position.put("z", pos[2]); position.put("z", pos[2]);
} }
Map<String, Object> rotation = new HashMap<>(); Map<String, Object> rotation = new HashMap<>();
rotation.put("x", 0); rotation.put("x", 0);
rotation.put("y", 0); rotation.put("y", 0);
rotation.put("z", 0); rotation.put("z", 0);
Map<String, Object> scale = new HashMap<>(); Map<String, Object> scale = new HashMap<>();
scale.put("x", 1); scale.put("x", 1);
scale.put("y", 1); scale.put("y", 1);
scale.put("z", 1); scale.put("z", 1);
itemMap.put("position", position); itemMap.put("position", position);
itemMap.put("scale", scale); itemMap.put("scale", scale);
itemMap.put("rotation", rotation); itemMap.put("rotation", rotation);
} }
List<Map> itemCountList = new ArrayList<>(); List<Map> itemCountList = new ArrayList<>();
Map<String, Object> ItemCount = new HashMap<>(); Map<String, Object> ItemCount = new HashMap<>();
ItemCount.put("name", "告警"); ItemCount.put("name", "告警");
ItemCount.put("count", getRiskSourceChildrenCount(item, "ANOMALY")); ItemCount.put("count", getRiskSourceChildrenCount(item, "ANOMALY"));
itemCountList.add(ItemCount); itemCountList.add(ItemCount);
Map<String, Object> ItemCount1 = new HashMap<>(); Map<String, Object> ItemCount1 = new HashMap<>();
ItemCount1.put("name", "风险点"); ItemCount1.put("name", "风险点");
ItemCount1.put("count", getRiskSourceChildrenCount(item, null)); ItemCount1.put("count", getRiskSourceChildrenCount(item, null));
itemCountList.add(ItemCount1); itemCountList.add(ItemCount1);
itemMap.put("statisticsData", itemCountList); itemMap.put("statisticsData", itemCountList);
map.put(item.getId() + "", itemMap); map.put(item.getId() + "", itemMap);
// } // }
}); });
for (String key : map.keySet()) { for (String key : map.keySet()) {
treeList.add((Map<String, Object>) map.get(key)); treeList.add((Map<String, Object>) map.get(key));
} }
} }
return treeList; return treeList;
} }
private static int getRiskSourceChildrenCount(RiskSourceTreeResponse riskSource, String status) { private static int getRiskSourceChildrenCount(RiskSourceTreeResponse riskSource, String status) {
if (ObjectUtils.isEmpty(riskSource.getChildren())) { if (ObjectUtils.isEmpty(riskSource.getChildren())) {
return 0; return 0;
} }
int count = 0; int count = 0;
if ("ANOMALY".equals(status)) { if ("ANOMALY".equals(status)) {
count += (riskSource.getQualified() == null ? 0 : riskSource.getQualified()); count += (riskSource.getQualified() == null ? 0 : riskSource.getQualified());
} else { } else {
count += (riskSource.getUnplan() == null ? 0 : riskSource.getUnplan()); count += (riskSource.getUnplan() == null ? 0 : riskSource.getUnplan());
} }
for (RiskSourceTreeResponse action : riskSource.getChildren()) { for (RiskSourceTreeResponse action : riskSource.getChildren()) {
if (ObjectUtils.isEmpty(action.getPosition3d())) { if (ObjectUtils.isEmpty(action.getPosition3d())) {
continue; continue;
} }
count = count + getRiskSourceChildrenCount(action, status); count = count + getRiskSourceChildrenCount(action, status);
if (status != null) { if (status != null) {
if (status.equals(action.getStatus())) { if (status.equals(action.getStatus())) {
count++; count++;
} }
} else { } else {
count++; count++;
} }
} }
return count; return count;
} }
private static List<RiskSourceTreeResponse> getRiskSourcesTree(List<RiskSourceTreeResponse> list) { private static List<RiskSourceTreeResponse> getRiskSourcesTree(List<RiskSourceTreeResponse> list) {
List<RiskSourceTreeResponse> treeList = new ArrayList<RiskSourceTreeResponse>(); List<RiskSourceTreeResponse> treeList = new ArrayList<RiskSourceTreeResponse>();
for (RiskSourceTreeResponse tree : list) { for (RiskSourceTreeResponse tree : list) {
if (tree.getParentId() != null && tree.getParentId() == 0) { if (tree.getParentId() != null && tree.getParentId() == 0) {
treeList.add(tree); treeList.add(tree);
} }
for (RiskSourceTreeResponse treeNode : list) { for (RiskSourceTreeResponse treeNode : list) {
if (treeNode.getParentId().longValue() == tree.getId()) { if (treeNode.getParentId().longValue() == tree.getId()) {
if (tree.getChildren() == null) { if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<>()); tree.setChildren(new ArrayList<>());
} }
tree.getChildren().add(treeNode); tree.getChildren().add(treeNode);
} }
} }
} }
return treeList; return treeList;
} }
private static List<RiskSourceTreeResponse> getRegionTree(List<RiskSourceTreeResponse> list) { private static List<RiskSourceTreeResponse> getRegionTree(List<RiskSourceTreeResponse> list) {
List<RiskSourceTreeResponse> treeList = new ArrayList<RiskSourceTreeResponse>(); List<RiskSourceTreeResponse> treeList = new ArrayList<RiskSourceTreeResponse>();
for (RiskSourceTreeResponse tree : list) { for (RiskSourceTreeResponse tree : list) {
if (tree.getParentId() != null && tree.getParentId() == 0) { if (tree.getParentId() != null && tree.getParentId() == 0) {
treeList.add(tree); treeList.add(tree);
} }
for (RiskSourceTreeResponse treeNode : list) { for (RiskSourceTreeResponse treeNode : list) {
if (treeNode.getParentId().longValue() == tree.getId() && "TRUE".equals(treeNode.getIsRegion())) { if (treeNode.getParentId().longValue() == tree.getId() && "TRUE".equals(treeNode.getIsRegion())) {
if (tree.getChildren() == null) { if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<>()); tree.setChildren(new ArrayList<>());
} }
tree.getChildren().add(treeNode); tree.getChildren().add(treeNode);
} }
} }
} }
return treeList; return treeList;
} }
/** /**
* 根据风险点查询关联巡检点 * 根据风险点查询关联巡检点
*/ */
@Permission @Permission
@ApiOperation(value = "根据风险点查询关联巡检点", notes = "根据风险点查询关联巡检点") @ApiOperation(value = "根据风险点查询关联巡检点", notes = "根据风险点查询关联巡检点")
@GetMapping(value = "/getBindPoints", produces = "application/json;charset=UTF-8") @GetMapping(value = "/getBindPoints", produces = "application/json;charset=UTF-8")
public CommonResponse listFmeaPointInputitem(@ApiParam(value = "fmeaId", required = true) @RequestParam Long fmeaId, public CommonResponse listFmeaPointInputitem(@ApiParam(value = "fmeaId", required = true) @RequestParam Long fmeaId,
@ApiParam(value = "分页参数", required = true) @RequestParam Integer pageNumber, @ApiParam(value = "分页参数", required = true) @RequestParam Integer pageNumber,
@ApiParam(value = "分页参数", required = true) @RequestParam Integer pageSize) { @ApiParam(value = "分页参数", required = true) @RequestParam Integer pageSize) {
try { try {
Page<Map<String, Object>> list = riskSourceService.listFmeaPointInputitem(getToken(), getProduct(), getAppKey(), fmeaId, pageNumber, pageSize); Page<Map<String, Object>> list = riskSourceService.listFmeaPointInputitem(getToken(), getProduct(), getAppKey(), fmeaId, pageNumber, pageSize);
return CommonResponseUtil.success(list); return CommonResponseUtil.success(list);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return CommonResponseUtil.failure("查询巡检点信息失败"); return CommonResponseUtil.failure("查询巡检点信息失败");
} }
} }
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "查询指定风险点绑定关系", notes = "查询指定风险点绑定关系") @ApiOperation(httpMethod = "GET", value = "查询指定风险点绑定关系", notes = "查询指定风险点绑定关系")
@RequestMapping(value = "/{fmeaId}/fireequiment/relations", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/{fmeaId}/fireequiment/relations", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryBoundRelation(@PathVariable Long fmeaId, public CommonResponse queryBoundRelation(@PathVariable Long fmeaId,
@RequestParam int pageNumber, @RequestParam int pageNumber,
@RequestParam int pageSize) { @RequestParam int pageSize) {
return CommonResponseUtil.success(riskSourceService.listFeamEquipmentPoint(fmeaId, pageNumber, pageSize)); return CommonResponseUtil.success(riskSourceService.listFeamEquipmentPoint(fmeaId, pageNumber, pageSize));
} }
@Permission @Permission
@ApiOperation(value = "绑定巡检点检查项", notes = "绑定巡检点检查项") @ApiOperation(value = "绑定巡检点检查项", notes = "绑定巡检点检查项")
@PostMapping(value = "/bindFmea/pointInputitem") @PostMapping(value = "/bindFmea/pointInputitem")
public CommonResponse bindFmeaPointInputitem(@RequestBody FmeaBindParam pointInputitems) { public CommonResponse bindFmeaPointInputitem(@RequestBody FmeaBindParam pointInputitems) {
return CommonResponseUtil.success(riskSourceService.bindPointInputitem(pointInputitems)); return CommonResponseUtil.success(riskSourceService.bindPointInputitem(pointInputitems));
} }
@Permission @Permission
@ApiOperation(value = "绑定消防设备指标", notes = "绑定消防设备指标") @ApiOperation(value = "绑定消防设备指标", notes = "绑定消防设备指标")
@PostMapping(value = "/bingFmea/equimentPoint") @PostMapping(value = "/bingFmea/equimentPoint")
public CommonResponse bindFmeaEquimentPoint(@RequestBody FmeaBindParam fmeaBindParam) { public CommonResponse bindFmeaEquimentPoint(@RequestBody FmeaBindParam fmeaBindParam) {
return CommonResponseUtil.success(riskSourceService.bindFireEquiment(fmeaBindParam)); return CommonResponseUtil.success(riskSourceService.bindFireEquiment(fmeaBindParam));
} }
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "查询绑定关系设备", notes = "查询绑定关系包含已绑定和未绑定") @ApiOperation(httpMethod = "GET", value = "查询绑定关系设备", notes = "查询绑定关系包含已绑定和未绑定")
@RequestMapping(value = "/fireequiment/relation/all", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/fireequiment/relation/all", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryRelationWithNoBound( public CommonResponse queryRelationWithNoBound(
@RequestParam String equimentId, @RequestParam String equimentId,
@RequestParam(value = "fname", required = false) String fname, @RequestParam(value = "fname", required = false) String fname,
@RequestParam int pageNumber, @RequestParam int pageNumber,
@RequestParam int pageSize) throws Exception { @RequestParam int pageSize) throws Exception {
CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize); CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize);
fname = StringUtils.trimToNull(fname); fname = StringUtils.trimToNull(fname);
return CommonResponseUtil.success(riskSourceService.queryEquimentRelation(commonPageable, equimentId, fname)); return CommonResponseUtil.success(riskSourceService.queryEquimentRelation(commonPageable, equimentId, fname));
} }
@Permission @Permission
@ApiOperation(value = "查询设备指标", notes = "查询设备指标") @ApiOperation(value = "查询设备指标", notes = "查询设备指标")
@GetMapping(value = "/listEquipmentPointById") @GetMapping(value = "/listEquipmentPointById")
public CommonResponse listEquipmentPointById(@RequestParam Long fmeaId, public CommonResponse listEquipmentPointById(@RequestParam Long fmeaId,
@RequestParam Long importantEquipId, @RequestParam Long importantEquipId,
@RequestParam Long equimentId, @RequestParam Long equimentId,
@RequestParam(required = false) String equipmentPointName) { @RequestParam(required = false) String equipmentPointName) {
return CommonResponseUtil.success(riskSourceService.listEquipmentPointById(fmeaId, importantEquipId, equimentId, equipmentPointName)); return CommonResponseUtil.success(riskSourceService.listEquipmentPointById(fmeaId, importantEquipId, equimentId, equipmentPointName));
} }
@Permission @Permission
@ApiOperation(httpMethod = "PUT", value = "上传消防设备数据", notes = "上传消防设备数据") @ApiOperation(httpMethod = "PUT", value = "上传消防设备数据", notes = "上传消防设备数据")
@RequestMapping(value = "/data/fireqeuiment", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT) @RequestMapping(value = "/data/fireqeuiment", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse postFireEqumentData(@RequestBody FireEquimentDataRo deviceData) throws Exception { public CommonResponse postFireEqumentData(@RequestBody FireEquimentDataRo deviceData) throws Exception {
return CommonResponseUtil.success(riskSourceService.processFireEqumtData(deviceData)); return CommonResponseUtil.success(riskSourceService.processFireEqumtData(deviceData));
} }
@ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据") @ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据")
@RequestMapping(value = "/data/fireqeuiment/soe", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/data/fireqeuiment/soe", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse postFireEqumentData(@RequestBody AlarmParam alarm) throws Exception { public CommonResponse postFireEqumentData(@RequestBody AlarmParam alarm) throws Exception {
log.debug("pointCode=soe=" + alarm.getPointCode() + " InformationAddress=soe=" + alarm.getInformationAddress()); log.debug("pointCode=soe=" + alarm.getPointCode() + " InformationAddress=soe=" + alarm.getInformationAddress());
riskSourceService.processFireEqumtData(alarm); riskSourceService.processFireEqumtData(alarm);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
@ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据") @ApiOperation(httpMethod = "POST", value = "上传消防设备数据", notes = "上传消防设备数据")
@RequestMapping(value = "/data/fireqeuiment/all", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/data/fireqeuiment/all", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse postFireEqumentData(@RequestBody List<AlarmParam> deviceDatas) throws Exception { public CommonResponse postFireEqumentData(@RequestBody List<AlarmParam> deviceDatas) throws Exception {
riskSourceService.saveData(deviceDatas, "all"); riskSourceService.saveData(deviceDatas, "all");
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
// @Permission // @Permission
// @Authorization(ingore = true) // @Authorization(ingore = true)
@ApiOperation(httpMethod = "PUT", value = "上传巡检数据", notes = "上传巡检数据") @ApiOperation(httpMethod = "PUT", value = "上传巡检数据", notes = "上传巡检数据")
@RequestMapping(value = "/data/patroldata", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT) @RequestMapping(value = "/data/patroldata", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse postPatrolData(@RequestBody ProtalDataRo protalData) throws Exception { public CommonResponse postPatrolData(@RequestBody ProtalDataRo protalData) throws Exception {
log.info("上传巡检数据" + JSONObject.toJSONString(protalData)); log.info("上传巡检数据" + JSONObject.toJSONString(protalData));
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams); String compCode = getOrgCode(reginParams);
riskSourceService.processProtalData(getToken(), getProduct(), getAppKey(), protalData, compCode); riskSourceService.processProtalData(getToken(), getProduct(), getAppKey(), protalData, compCode);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
@Permission @Permission
@ApiOperation(httpMethod = "PUT", value = "上传巡检任务数据", notes = "上传巡检任务数据") @ApiOperation(httpMethod = "PUT", value = "上传巡检任务数据", notes = "上传巡检任务数据")
@RequestMapping(value = "/data/task", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT) @RequestMapping(value = "/data/task", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse postTaskData(@RequestBody ProtalDataRo taskData) throws Exception { public CommonResponse postTaskData(@RequestBody ProtalDataRo taskData) throws Exception {
return CommonResponseUtil.success(riskSourceService.processTaskData(taskData)); return CommonResponseUtil.success(riskSourceService.processTaskData(taskData));
} }
/** /**
* 查询风险点明细 * 查询风险点明细
* *
* @param id * @param id
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Permission @Permission
@ApiOperation(value = "查询风险点明细", notes = "查询风险点明细") @ApiOperation(value = "查询风险点明细", notes = "查询风险点明细")
@GetMapping(value = "/detailById/{id}", produces = "application/json;charset=UTF-8") @GetMapping(value = "/detailById/{id}", produces = "application/json;charset=UTF-8")
public CommonResponse queryRiskSourceDetailById(@PathVariable Long id) { public CommonResponse queryRiskSourceDetailById(@PathVariable Long id) {
RiskSourceTreeResponse det = riskSourceService.queryRiskSourceDetailById(id); RiskSourceTreeResponse det = riskSourceService.queryRiskSourceDetailById(id);
return CommonResponseUtil.success(det); return CommonResponseUtil.success(det);
} }
@Permission @Permission
@ApiOperation(value = "风险预警详情", notes = "风险预警详情") @ApiOperation(value = "风险预警详情", notes = "风险预警详情")
@GetMapping(value = "/warning/detail", produces = "application/json;charset=UTF-8") @GetMapping(value = "/warning/detail", produces = "application/json;charset=UTF-8")
public CommonResponse earlyWarning(@RequestParam Long riskSourceId) { public CommonResponse earlyWarning(@RequestParam Long riskSourceId) {
Map map = riskSourceService.earlyWarning(riskSourceId); Map map = riskSourceService.earlyWarning(riskSourceId);
return CommonResponseUtil.success(map); return CommonResponseUtil.success(map);
} }
/** /**
* 获取厂区下所有区域的风险点的rpn值 * 获取厂区下所有区域的风险点的rpn值
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "获取厂区下所有区域的风险点的rpn值", notes = "获取厂区下所有区域的风险点的rpn值") @ApiOperation(httpMethod = "GET", value = "获取厂区下所有区域的风险点的rpn值", notes = "获取厂区下所有区域的风险点的rpn值")
@RequestMapping(value = "/queryRiskAreaRpn", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/queryRiskAreaRpn", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryRiskAreaRpn() { public CommonResponse queryRiskAreaRpn() {
return CommonResponseUtil.success(riskSourceService.queryRiskAreaRpn()); return CommonResponseUtil.success(riskSourceService.queryRiskAreaRpn());
} }
/** /**
* @return * @return
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "POST", value = "设置预案节点自动执行", notes = "设置预案节点自动执行") @ApiOperation(httpMethod = "POST", value = "设置预案节点自动执行", notes = "设置预案节点自动执行")
@RequestMapping(value = "/contingency/setup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/contingency/setup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryRiskSourceSecondLevel(@RequestBody ContingencyDeviceStatus contingencyDeviceStatus) { public CommonResponse queryRiskSourceSecondLevel(@RequestBody ContingencyDeviceStatus contingencyDeviceStatus) {
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus); riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "初始化預案水資源", notes = "初始化預案水資源") @ApiOperation(httpMethod = "GET", value = "初始化預案水資源", notes = "初始化預案水資源")
@RequestMapping(value = "/contingency/water", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/contingency/water", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryContingencyWater() { public CommonResponse queryContingencyWater() {
return CommonResponseUtil.success(riskSourceService.queryContingencyWater()); return CommonResponseUtil.success(riskSourceService.queryContingencyWater());
} }
/** /**
* 获取危险因素树二级节点 * 获取危险因素树二级节点
* *
* @return * @return
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "获取危险因素树二级节点", notes = "获取危险因素树二级节点") @ApiOperation(httpMethod = "GET", value = "获取危险因素树二级节点", notes = "获取危险因素树二级节点")
@RequestMapping(value = "/riskSourceSecondLevel", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/riskSourceSecondLevel", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryRiskSourceSecondLevel() { public CommonResponse queryRiskSourceSecondLevel() {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams); String compCode = getOrgCode(reginParams);
return CommonResponseUtil.success(riskSourceService.queryRiskSourceSecondLevel(compCode)); return CommonResponseUtil.success(riskSourceService.queryRiskSourceSecondLevel(compCode));
} }
/** /**
* 获取巡检点FMEA * 获取巡检点FMEA
* *
* @return * @return
*/ */
@Permission @Permission
@ApiOperation(httpMethod = "GET", value = "获取危险因素树二级节点", notes = "获取危险因素树二级节点") @ApiOperation(httpMethod = "GET", value = "获取危险因素树二级节点", notes = "获取危险因素树二级节点")
@RequestMapping(value = "/queryFmea/point/{pointId}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/queryFmea/point/{pointId}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryFmeaByPointId(@PathVariable Long pointId) { public CommonResponse queryFmeaByPointId(@PathVariable Long pointId) {
return CommonResponseUtil.success(riskSourceService.queryFmeaByPointId(pointId)); return CommonResponseUtil.success(riskSourceService.queryFmeaByPointId(pointId));
} }
} }
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.service.intfc.IStationMaintenService; import com.yeejoin.amos.fas.business.service.intfc.IStationMaintenService;
import com.yeejoin.amos.fas.config.Permission; import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.StationInfo; import com.yeejoin.amos.fas.dao.entity.StationInfo;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
@RestController @RestController
@RequestMapping(value = "/api/stationMainten") @RequestMapping(value = "/api/stationMainten")
@Api(tags="站端api") @Api(tags="站端api")
public class StationMaintenController extends BaseController{ public class StationMaintenController extends BaseController{
@Autowired @Autowired
private IStationMaintenService stationMaintenService; private IStationMaintenService stationMaintenService;
/** /**
* 保存站端信息 * 保存站端信息
*/ */
@Permission @Permission
@ApiOperation(value = "保存录入站端信息", notes = "保存录入站端信息") @ApiOperation(value = "保存录入站端信息", notes = "保存录入站端信息")
@PostMapping(value = "/save") @PostMapping(value = "/save")
public CommonResponse saveStation(@RequestBody StationInfo stationParams) { public CommonResponse saveStation(@RequestBody StationInfo stationParams) {
AgencyUserModel userModel = getUserInfo(); AgencyUserModel userModel = getUserInfo();
stationParams.setCreateBy(getUserId()); stationParams.setCreateBy(getUserId());
stationParams.setCreateDate(new Date()); stationParams.setCreateDate(new Date());
stationParams.setCreateUserName(userModel.getUserName()); stationParams.setCreateUserName(userModel.getUserName());
stationParams.setCreateUserPhoneNum(userModel.getMobile()); stationParams.setCreateUserPhoneNum(userModel.getMobile());
stationMaintenService.save(stationParams); stationMaintenService.save(stationParams);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
/** /**
* 获取站端信息 * 获取站端信息
*/ */
@Permission @Permission
@ApiOperation(value = "获取站端信息", notes = "获取站端信息") @ApiOperation(value = "获取站端信息", notes = "获取站端信息")
@PostMapping(value = "/detail") @PostMapping(value = "/detail")
public CommonResponse detail() { public CommonResponse detail() {
StationInfo stationInfo = stationMaintenService.detail(); StationInfo stationInfo = stationMaintenService.detail();
return CommonResponseUtil.success(stationInfo); return CommonResponseUtil.success(stationInfo);
} }
} }
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import java.util.Date; 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.Optional; import java.util.Optional;
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;
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.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
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.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.rule.RuleTrigger; import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.ContingencyAction; 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.ContingencyEvent;
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.SetpEnum; 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.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;
import com.yeejoin.amos.fas.business.service.model.Operate; import com.yeejoin.amos.fas.business.service.model.Operate;
import com.yeejoin.amos.fas.business.service.model.OperateGroup; import com.yeejoin.amos.fas.business.service.model.OperateGroup;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData; 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;
@Service @Service
public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPlanInstance, String>*/ implements IContingencyInstance { public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPlanInstance, String>*/ implements IContingencyInstance {
private static final Logger log = LoggerFactory.getLogger(ContingencyInstanceImpl.class); private static final Logger log = LoggerFactory.getLogger(ContingencyInstanceImpl.class);
@Autowired @Autowired
private IContingencyPlanInstanceRepository repository; private IContingencyPlanInstanceRepository repository;
@Autowired @Autowired
IContingencyOriginalDataDao iContingencyOriginalDataDao; IContingencyOriginalDataDao iContingencyOriginalDataDao;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Autowired @Autowired
private ImpAndFireEquipMapper impAndFireEquipMapper; private ImpAndFireEquipMapper impAndFireEquipMapper;
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired @Autowired
private FireEquipPointMapper fireEquipPointMapper; private FireEquipPointMapper fireEquipPointMapper;
@Value("${params.remoteRuleUrl}") @Value("${params.remoteRuleUrl}")
private String remoteRuleUrl; private String remoteRuleUrl;
@Autowired @Autowired
private IContingencyInstance iContingencyInstance; private IContingencyInstance iContingencyInstance;
@Value("${station.name}") @Value("${station.name}")
private String stationName; private String stationName;
private static Map<String, String> stepMap = new HashMap<>(); private static Map<String, String> stepMap = new HashMap<>();
@Autowired @Autowired
private RuleTrigger ruleTrigger; private RuleTrigger ruleTrigger;
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String serviceName; private String serviceName;
/* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) { /* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) {
super(repository); super(repository);
this.repository = repository; this.repository = repository;
}*/ }*/
@Autowired @Autowired
ContingencyAction contingencyAction; ContingencyAction contingencyAction;
@Autowired @Autowired
private ContingencyLogPublisher contingencyLogPublisher; private ContingencyLogPublisher contingencyLogPublisher;
/** /**
* 创建预案执行记录 * 创建预案执行记录
* *
* @param category 一级分类 * @param category 一级分类
* @param subCategory 二级分类 * @param subCategory 二级分类
* @param content 信息内容 * @param content 信息内容
* @param recordType 信息分类 * @param recordType 信息分类
* @param icon 信息显示图标 * @param icon 信息显示图标
*/ */
public ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon) { public ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon) {
ContingencyPlanInstance planInstance = new ContingencyPlanInstance(); ContingencyPlanInstance planInstance = new ContingencyPlanInstance();
planInstance.setContent(content); planInstance.setContent(content);
planInstance.setIcon(icon); planInstance.setIcon(icon);
planInstance.setRecordType(recordType); planInstance.setRecordType(recordType);
planInstance.setCategory(category); planInstance.setCategory(category);
planInstance.setBatchNo(instanceNo); planInstance.setBatchNo(instanceNo);
planInstance.setCreateDate(new Date()); planInstance.setCreateDate(new Date());
//计算序号 //计算序号
int count = repository.countByBatchNo(instanceNo); int count = repository.countByBatchNo(instanceNo);
planInstance.setSort(++count); planInstance.setSort(++count);
return this.repository.save(planInstance); return this.repository.save(planInstance);
} }
/** /**
* 查询时间轴 * 查询时间轴
* *
* @param instanceNo * @param instanceNo
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<ContingencyPlanInstance> queryForTimeLine(String instanceNo, String recordType) throws Exception { public List<ContingencyPlanInstance> queryForTimeLine(String instanceNo, String recordType) throws Exception {
List<ContingencyPlanInstance> categorys = repository.queryForCategory(instanceNo, recordType); List<ContingencyPlanInstance> categorys = repository.queryForCategory(instanceNo, recordType);
return categorys; return categorys;
} }
public void fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton) throws Exception { public void fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton) throws Exception {
//火灾误报 //火灾误报
ContingencyOriginalData contingencyOriginalData = iContingencyOriginalDataDao.findByBatchNo(batchNo); ContingencyOriginalData contingencyOriginalData = iContingencyOriginalDataDao.findByBatchNo(batchNo);
String stepKey = batchNo + "_" + stepCode; String stepKey = batchNo + "_" + stepCode;
if (stepMap.get(stepKey) == null) if (stepMap.get(stepKey) == null)
stepMap.put(stepKey, ""); stepMap.put(stepKey, "");
if (contingencyOriginalData != null) { if (contingencyOriginalData != null) {
log.info("数据库中的stepcode:" + contingencyOriginalData.getStep()); log.info("数据库中的stepcode:" + contingencyOriginalData.getStep());
contingencyOriginalData.setConfirm(buttonState); contingencyOriginalData.setConfirm(buttonState);
contingencyOriginalData.setRunstep(false); contingencyOriginalData.setRunstep(false);
if (contingencyOriginalData.getStepState() == null) if (contingencyOriginalData.getStepState() == null)
contingencyOriginalData.setStepState(""); contingencyOriginalData.setStepState("");
if ("CONFIRM".equals(buttonState) if ("CONFIRM".equals(buttonState)
&& !contingencyOriginalData.getStepState().contains(stepStateOnbutton) && !contingencyOriginalData.getStepState().contains(stepStateOnbutton)
&& stepCode.equals(contingencyOriginalData.getStep())) && stepCode.equals(contingencyOriginalData.getStep()))
contingencyOriginalData.setStepState(contingencyOriginalData.getStepState() + stepStateOnbutton); contingencyOriginalData.setStepState(contingencyOriginalData.getStepState() + stepStateOnbutton);
//请求中的步骤小于以保存的步骤 //请求中的步骤小于以保存的步骤
if (Integer.parseInt(stepCode) < Integer.parseInt(contingencyOriginalData.getStep())) { if (Integer.parseInt(stepCode) < Integer.parseInt(contingencyOriginalData.getStep())) {
contingencyOriginalData.setRunstep(true); contingencyOriginalData.setRunstep(true);
} }
if (Integer.parseInt(stepCode) > Integer.parseInt(contingencyOriginalData.getStep())) { if (Integer.parseInt(stepCode) > Integer.parseInt(contingencyOriginalData.getStep())) {
contingencyOriginalData.setStepState(stepStateOnbutton); contingencyOriginalData.setStepState(stepStateOnbutton);
} }
iContingencyOriginalDataDao.updateByButton( iContingencyOriginalDataDao.updateByButton(
contingencyOriginalData.getConfirm(), contingencyOriginalData.getConfirm(),
contingencyOriginalData.getRunstep(), contingencyOriginalData.getRunstep(),
contingencyOriginalData.getStepState(), contingencyOriginalData.getStepState(),
contingencyOriginalData.getBatchNo()); contingencyOriginalData.getBatchNo());
//使用原始数据触发规则 //使用原始数据触发规则
if ("CONFIRM".equals(buttonState) if ("CONFIRM".equals(buttonState)
&& !stepMap.get(stepKey).contains(stepStateOnbutton)) && !stepMap.get(stepKey).contains(stepStateOnbutton))
stepMap.put(stepKey, stepMap.get(stepKey) + stepStateOnbutton); stepMap.put(stepKey, stepMap.get(stepKey) + stepStateOnbutton);
ContingencyRo contingencyRo = new ContingencyRo(); ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setButtonCode(buttonCode); contingencyRo.setButtonCode(buttonCode);
contingencyRo.setButtonState(buttonState); contingencyRo.setButtonState(buttonState);
BeanUtils.copyProperties(contingencyOriginalData, contingencyRo); BeanUtils.copyProperties(contingencyOriginalData, contingencyRo);
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); // contingencyRo.setStep(stepCode);
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()));
// 获取重点设备胚胎指标 // 获取重点设备胚胎指标
// 获取遥信指标 // 获取遥信指标
List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH"); List<Map> points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "SWITCH");
HashMap<String, Integer> telesignallingMap = new HashMap<>(); HashMap<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"); 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())); ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
publisherPlanLog(stepCode, buttonCode, batchNo); publisherPlanLog(stepCode, buttonCode, batchNo);
} else { } else {
throw new Exception("数据异常,请联系管理员."); throw new Exception("数据异常,请联系管理员.");
} }
} }
private void publisherPlanLog(String stepCode, String buttonCode, String batchNo) { private void publisherPlanLog(String stepCode, String buttonCode, String batchNo) {
ContingencyEvent event = new ContingencyEvent(this); ContingencyEvent event = new ContingencyEvent(this);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
JSONObject msgContext = new JSONObject(); JSONObject msgContext = new JSONObject();
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
content.put("stepCode", stepCode); content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode); content.put("buttonCode", buttonCode);
msgContext.put("type", "clickEvent"); msgContext.put("type", "clickEvent");
msgContext.put("content", content); msgContext.put("content", content);
json.put("msgType", "message"); json.put("msgType", "message");
json.put("msgContext", msgContext); json.put("msgContext", msgContext);
event.setMsgBody(json.toJSONString()); event.setMsgBody(json.toJSONString());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
event.setTopic(topic); event.setTopic(topic);
event.setMsgType("clickEvent"); event.setMsgType("clickEvent");
event.setContingency(batchNo); event.setContingency(batchNo);
contingencyLogPublisher.publish(event); contingencyLogPublisher.publish(event);
} }
public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState) throws Exception { public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState) throws Exception {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId); Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId);
ContingencyPlanInstance contingencyPlanInstance=contingencyPlanInstance1.get(); ContingencyPlanInstance contingencyPlanInstance=contingencyPlanInstance1.get();
if(contingencyPlanInstance1.isPresent()){ if(contingencyPlanInstance1.isPresent()){
if (contingencyPlanInstance != null && "OPERATE".equals(contingencyPlanInstance.getRecordType())) { if (contingencyPlanInstance != null && "OPERATE".equals(contingencyPlanInstance.getRecordType())) {
String operateJson = contingencyPlanInstance.getContent(); String operateJson = contingencyPlanInstance.getContent();
OperateGroup operateGroup = objectMapper.readValue(operateJson, OperateGroup.class); OperateGroup operateGroup = objectMapper.readValue(operateJson, OperateGroup.class);
List<Operate> operates = operateGroup.getOperate(); List<Operate> operates = operateGroup.getOperate();
if (!CollectionUtils.isEmpty(operates)) { if (!CollectionUtils.isEmpty(operates)) {
for (Operate operate : operates) { for (Operate operate : operates) {
if (code.equals(operate.getCode()) && ("executed".equals(operate.getState()) || "disable".equals(operate.getState()))){ if (code.equals(operate.getCode()) && ("executed".equals(operate.getState()) || "disable".equals(operate.getState()))){
if("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code)){ if("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code)){
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning()); redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
} }
throw new Exception("请勿重复操作."); throw new Exception("请勿重复操作.");
} }
if ("CONFIRM".equals(buttonState)) { if ("CONFIRM".equals(buttonState)) {
if (code.equals(operate.getCode())) { if (code.equals(operate.getCode())) {
operate.setState("executed"); operate.setState("executed");
if("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code)) if("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code))
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning()); redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
} else { } else {
operate.setState("disable"); operate.setState("disable");
} }
} }
} }
} }
if (buttonState.equals("CONFIRM")) if (buttonState.equals("CONFIRM"))
contingencyPlanInstance.setRunstate(true); contingencyPlanInstance.setRunstate(true);
operateJson = objectMapper.writeValueAsString(operateGroup); operateJson = objectMapper.writeValueAsString(operateGroup);
contingencyPlanInstance.setContent(operateJson); contingencyPlanInstance.setContent(operateJson);
repository.save(contingencyPlanInstance); repository.save(contingencyPlanInstance);
} }
} }
} }
public void setButtonWait(String batchNo, String contingencyPlanId, String buttonState) throws Exception { public void setButtonWait(String batchNo, String contingencyPlanId, String buttonState) throws Exception {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId); Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId);
ContingencyPlanInstance contingencyPlanInstance=null; ContingencyPlanInstance contingencyPlanInstance=null;
if(contingencyPlanInstance1.isPresent()){ if(contingencyPlanInstance1.isPresent()){
contingencyPlanInstance=contingencyPlanInstance1.get(); contingencyPlanInstance=contingencyPlanInstance1.get();
} }
if (contingencyPlanInstance != null && "OPERATE".equals(contingencyPlanInstance.getRecordType())) { if (contingencyPlanInstance != null && "OPERATE".equals(contingencyPlanInstance.getRecordType())) {
String operateJson = contingencyPlanInstance.getContent(); String operateJson = contingencyPlanInstance.getContent();
OperateGroup operateGroup = objectMapper.readValue(operateJson, OperateGroup.class); OperateGroup operateGroup = objectMapper.readValue(operateJson, OperateGroup.class);
List<Operate> operates = operateGroup.getOperate(); List<Operate> operates = operateGroup.getOperate();
if (!CollectionUtils.isEmpty(operates)) { if (!CollectionUtils.isEmpty(operates)) {
for (Operate operate : operates) { for (Operate operate : operates) {
if ("CONFIRM".equals(buttonState)) { if ("CONFIRM".equals(buttonState)) {
operate.setState("executed"); operate.setState("executed");
} }
} }
} }
if (buttonState.equals("CONFIRM")) if (buttonState.equals("CONFIRM"))
contingencyPlanInstance.setRunstate(true); contingencyPlanInstance.setRunstate(true);
operateJson = objectMapper.writeValueAsString(operateGroup); operateJson = objectMapper.writeValueAsString(operateGroup);
contingencyPlanInstance.setContent(operateJson); contingencyPlanInstance.setContent(operateJson);
repository.save(contingencyPlanInstance); repository.save(contingencyPlanInstance);
} }
} }
@Override @Override
public void updateStep(String step, String batchNo) { public void updateStep(String step, String batchNo) {
iContingencyOriginalDataDao.updateByButtonStep(step,batchNo); iContingencyOriginalDataDao.updateByButtonStep(step,batchNo);
} }
} }
...@@ -333,7 +333,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -333,7 +333,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
if (ids.size() > 0) { if (ids.size() > 0) {
fmeaEquipmentPointMapper.updateStateByIds(state, ids); fmeaEquipmentPointMapper.updateStateByIds(state, ids);
} }
final Integer st = state; final Integer st = state;
String monitor = equipmentSpecificMapper.findEquipNameById(equipmentSpecificIndex.getEquipmentSpecificId()); String monitor = equipmentSpecificMapper.findEquipNameById(equipmentSpecificIndex.getEquipmentSpecificId());
RsDataQueue rsDataQueue = RsDataQueue.getInstance(); RsDataQueue rsDataQueue = RsDataQueue.getInstance();
......
package com.yeejoin.amos.fas.business.service.intfc; package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.business.vo.ReginParams; import com.yeejoin.amos.fas.business.vo.ReginParams;
/** /**
* @author keyong * @author keyong
* @title: IEquipmentHandler * @title: IEquipmentHandler
* <pre> * <pre>
* @description: 站端接受装备信息系统数据处理流程 * @description: 站端接受装备信息系统数据处理流程
* </pre> * </pre>
* @date 2020/11/10 18:01 * @date 2020/11/10 18:01
*/ */
public interface IEquipmentHandlerService { public interface IEquipmentHandlerService {
void handlerMqttMessage(String topic, String message); void handlerMqttMessage(String topic, String message);
// void subscribeTopic(ReginParams reginParams); // void subscribeTopic(ReginParams reginParams);
void subscribeTopic(); void subscribeTopic();
} }
package com.yeejoin.amos.fas.business.vo; package com.yeejoin.amos.fas.business.vo;
import lombok.Data; import lombok.Data;
@Data @Data
public class EquipmentSpecificVo { public class EquipmentSpecificVo {
private String id; private String id;
//装备码 //装备码
private String code; private String code;
//装备名称 //装备名称
private String name; private String name;
//装备分类 //装备分类
private String type; private String type;
//是否绑定 //是否绑定
private String isbind; private String isbind;
//地址 //地址
private String address; private String address;
//库存 //库存
private Integer amount; private Integer amount;
//是否单件管理(1是多件) //是否单件管理(1是多件)
private Integer single; private Integer single;
//IOT编码 //IOT编码
private String iotCode; private String iotCode;
//装备编码 //装备编码
private String specificCode; private String specificCode;
//系统名称 //系统名称
private String systemName; private String systemName;
} }
package com.yeejoin.amos.fas.config; package com.yeejoin.amos.fas.config;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe; import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.vo.DepartmentBo; import com.yeejoin.amos.fas.business.vo.DepartmentBo;
import com.yeejoin.amos.fas.business.vo.RoleBo; import com.yeejoin.amos.fas.business.vo.RoleBo;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel; import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; 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.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.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; 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;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.config.TokenOperation; import com.yeejoin.amos.component.feign.config.TokenOperation;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.vo.CompanyBo; import com.yeejoin.amos.fas.business.vo.CompanyBo;
import com.yeejoin.amos.fas.business.vo.ReginParams; import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.exception.PermissionException; import com.yeejoin.amos.fas.exception.PermissionException;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
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.Set; import java.util.Set;
@Aspect @Aspect
@Component @Component
@ResponseBody @ResponseBody
public class PermissionAspect { public class PermissionAspect {
private static final Logger logger = LoggerFactory.getLogger(PermissionAspect.class); private static final Logger logger = LoggerFactory.getLogger(PermissionAspect.class);
@Autowired @Autowired
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
// 前置通知,在方法执行之前 // 前置通知,在方法执行之前
@Before(value = "@annotation(Permission)") @Before(value = "@annotation(Permission)")
public void PermissionCheck(JoinPoint joinPoint) throws PermissionException { public void PermissionCheck(JoinPoint joinPoint) throws PermissionException {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest(); .getRequestAttributes()).getRequest();
logger.info("======开始权限校验======"); logger.info("======开始权限校验======");
// 用户token // 用户token
String token = (String) request.getHeader("token"); String token = (String) request.getHeader("token");
token = ObjectUtils.isEmpty(token) ? (String) request.getHeader("X-Access-Token") : token; token = ObjectUtils.isEmpty(token) ? (String) request.getHeader("X-Access-Token") : token;
String product = (String) request.getHeader("product"); String product = (String) request.getHeader("product");
String appKey = (String) request.getHeader("appKey"); String appKey = (String) request.getHeader("appKey");
logger.info("用户token:" + token); logger.info("用户token:" + token);
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setProduct(product); RequestContext.setProduct(product);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
if (!TokenOperation.refresh(token)) { if (!TokenOperation.refresh(token)) {
throw new PermissionException("登录信息失效,请重新登录"); throw new PermissionException("登录信息失效,请重新登录");
} }
if (joinPoint.getSignature().getName().equals("saveCurCompany")) { if (joinPoint.getSignature().getName().equals("saveCurCompany")) {
return; return;
} }
FeignClientResult feignClientResult; FeignClientResult feignClientResult;
AgencyUserModel userModel=null; AgencyUserModel userModel=null;
try { try {
feignClientResult = Privilege.agencyUserClient.getme(); feignClientResult = Privilege.agencyUserClient.getme();
userModel = (AgencyUserModel) feignClientResult.getResult(); userModel = (AgencyUserModel) feignClientResult.getResult();
} catch (InnerInvokException e) { } catch (InnerInvokException e) {
e.printStackTrace(); e.printStackTrace();
} }
String userId = null; String userId = null;
ReginParams regionParam = new ReginParams(); ReginParams regionParam = new ReginParams();
if(userModel != null){ if(userModel != null){
userId = userModel.getUserId(); userId = userModel.getUserId();
ReginParams reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userModel.getUserId(), token)), ReginParams.class); ReginParams reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userModel.getUserId(), token)), ReginParams.class);
if(reginParams == null && userModel.getCompanys().size() > 0){ if(reginParams == null && userModel.getCompanys().size() > 0){
CompanyModel companyModel = userModel.getCompanys().get(0); CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(token, product, appKey, companyModel.getSequenceNbr().toString()); List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(token, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){ if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel); CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0)); DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
regionParam.setCompany(companyBo); regionParam.setCompany(companyBo);
regionParam.setDepartment(departmentBo); regionParam.setDepartment(departmentBo);
} }
Map<Long, List<RoleModel>> orgRoles = userModel.getOrgRoles(); Map<Long, List<RoleModel>> orgRoles = userModel.getOrgRoles();
List<RoleModel> roleModels = null; List<RoleModel> roleModels = null;
if(!ObjectUtils.isEmpty(orgRoles)) { if(!ObjectUtils.isEmpty(orgRoles)) {
for (Map.Entry<Long, List<RoleModel>> entry : orgRoles.entrySet()) { for (Map.Entry<Long, List<RoleModel>> entry : orgRoles.entrySet()) {
roleModels = entry.getValue(); roleModels = entry.getValue();
break; break;
} }
} }
if(!ObjectUtils.isEmpty(roleModels)){ if(!ObjectUtils.isEmpty(roleModels)){
regionParam.setRole(convertRoleModelToBo(roleModels.get(0))); regionParam.setRole(convertRoleModelToBo(roleModels.get(0)));
} }
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(regionParam)); redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(regionParam));
} }
} }
} }
private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){ private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){
DepartmentBo departmentBo = new DepartmentBo(); DepartmentBo departmentBo = new DepartmentBo();
if(departmentModel != null) { if(departmentModel != null) {
departmentBo.setCompanySeq(departmentModel.getCompanySeq().toString()); departmentBo.setCompanySeq(departmentModel.getCompanySeq().toString());
departmentBo.setDepartmentDesc(departmentModel.getDepartmentDesc()); departmentBo.setDepartmentDesc(departmentModel.getDepartmentDesc());
departmentBo.setDepartmentName(departmentModel.getDepartmentName()); departmentBo.setDepartmentName(departmentModel.getDepartmentName());
departmentBo.setLevel(departmentModel.getLevel()); departmentBo.setLevel(departmentModel.getLevel());
departmentBo.setOrgCode(departmentModel.getOrgCode()); departmentBo.setOrgCode(departmentModel.getOrgCode());
departmentBo.setParentId(departmentModel.getParentId().toString()); departmentBo.setParentId(departmentModel.getParentId().toString());
departmentBo.setDeptOrgCode(departmentModel.getDeptOrgCode().toString()); departmentBo.setDeptOrgCode(departmentModel.getDeptOrgCode().toString());
departmentBo.setSequenceNbr(departmentModel.getSequenceNbr().toString()); departmentBo.setSequenceNbr(departmentModel.getSequenceNbr().toString());
} }
return departmentBo; return departmentBo;
} }
/** /**
* Model 转 Bo * Model 转 Bo
*/ */
private CompanyBo convertCompanyModelToBo(CompanyModel companyModel){ private CompanyBo convertCompanyModelToBo(CompanyModel companyModel){
CompanyBo companyBo = new CompanyBo(); CompanyBo companyBo = new CompanyBo();
if(companyModel != null) { if(companyModel != null) {
companyBo.setAddress(companyModel.getAddress()); companyBo.setAddress(companyModel.getAddress());
companyBo.setCompanyName(companyModel.getCompanyName()); companyBo.setCompanyName(companyModel.getCompanyName());
companyBo.setCompanyOrgCode(Long.parseLong(companyModel.getCompanyOrgCode().toString())); companyBo.setCompanyOrgCode(Long.parseLong(companyModel.getCompanyOrgCode().toString()));
companyBo.setEmail(companyModel.getEmail()); companyBo.setEmail(companyModel.getEmail());
companyBo.setLandlinePhone(companyModel.getLandlinePhone()); companyBo.setLandlinePhone(companyModel.getLandlinePhone());
companyBo.setLongitude(companyModel.getLongitude()); companyBo.setLongitude(companyModel.getLongitude());
companyBo.setLatitude(companyModel.getLatitude()); companyBo.setLatitude(companyModel.getLatitude());
companyBo.setLevel(companyModel.getLevel()); companyBo.setLevel(companyModel.getLevel());
companyBo.setOrgCode(companyModel.getOrgCode()); companyBo.setOrgCode(companyModel.getOrgCode());
companyBo.setSequenceNbr(companyModel.getSequenceNbr().toString()); companyBo.setSequenceNbr(companyModel.getSequenceNbr().toString());
companyBo.setParentId(companyModel.getParentId().toString()); companyBo.setParentId(companyModel.getParentId().toString());
} }
return companyBo; return companyBo;
} }
private RoleBo convertRoleModelToBo(RoleModel roleModel) { private RoleBo convertRoleModelToBo(RoleModel roleModel) {
RoleBo roleBo = new RoleBo(); RoleBo roleBo = new RoleBo();
if(roleModel != null){ if(roleModel != null){
roleBo.setRoleName(roleModel.getRoleName()); roleBo.setRoleName(roleModel.getRoleName());
roleBo.setRoleType(roleModel.getRoleType()); roleBo.setRoleType(roleModel.getRoleType());
roleBo.setSequenceNbr(roleModel.getSequenceNbr().toString()); roleBo.setSequenceNbr(roleModel.getSequenceNbr().toString());
} }
return roleBo; return roleBo;
} }
//redi缓存选择的用户信息 //redi缓存选择的用户信息
private String buildKey(String userId, String token) { private String buildKey(String userId, String token) {
return "region_" + userId + "_" + token; return "region_" + userId + "_" + token;
} }
} }
security.password=a1234560 security.password=a1234560
security.loginId=fas_autosys security.loginId=fas_autosys
security.productWeb=CONVERTER_STATION_WEB security.productWeb=CONVERTER_STATION_WEB
security.appKeyWeb=CONVERTER_STATION security.appKeyWeb=CONVERTER_STATION
#environment #environment
#spring.profiles.active = dev #spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/ eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
eureka.client.register-with-eureka = true eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true eureka.client.fetch-registry = true
eureka.client.healthcheck.enabled = true 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-36?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.datasource.url=jdbc:mysql://172.16.11.33:3306/safety-business-2.0-36?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.datasource.hikari.maxLifetime = 1765000 spring.datasource.hikari.maxLifetime = 1765000
spring.datasource.hikari.maximum-pool-size = 10 spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1 spring.datasource.validationQuery = SELECT 1
#mongodb #mongodb
spring.data.mongodb.uri = mongodb://172.16.11.33:27017/iecmonitor spring.data.mongodb.uri = mongodb://172.16.11.33:27017/iecmonitor
#rule #rule
#params.remoteRuleUrl=http://172.16.3.3:8080/ #params.remoteRuleUrl=http://172.16.3.3:8080/
params.remoteRuleUrl=http://magintursh.xicp.net:18080/ params.remoteRuleUrl=http://magintursh.xicp.net:18080/
params.remoteWebsocketUrl=http://172.16.11.36:10600/ params.remoteWebsocketUrl=http://172.16.11.36:10600/
spring.redis.database=0 spring.redis.database=0
spring.redis.host=172.16.10.85 spring.redis.host=172.16.10.85
spring.redis.port=6379 spring.redis.port=6379
spring.redis.password=amos2019Redis spring.redis.password=amos2019Redis
spring.redis.jedis.pool.max-active=200 spring.redis.jedis.pool.max-active=200
spring.redis.jedis.pool.max-wait=-1 spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=10 spring.redis.jedis.pool.max-idle=10
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
spring.redis.timeout=1000 spring.redis.timeout=1000
#picture upload #picture upload
file.uploadUrl=F:\\upload\\files\\ file.uploadUrl=F:\\upload\\files\\
#picture read #picture read
file.readUrl=http://172.16.3.89:8083/file/getFile?in= file.readUrl=http://172.16.3.89:8083/file/getFile?in=
params.isPush=true params.isPush=true
## emqx ## emqx
emqx.clean-session=true emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]} emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.85:1883 emqx.broker=tcp://172.16.10.85:1883
emqx.user-name=super emqx.user-name=super
emqx.password=a123456 emqx.password=a123456
# 只用于初始化 # 只用于初始化
emqx.defaultTopic=mqtt_topic emqx.defaultTopic=mqtt_topic
Push.fegin.name=APPMESSAGEPUSHSERVICE-36 Push.fegin.name=APPMESSAGEPUSHSERVICE-36
dutyMode.fegin.name=AMOSDUTYMODE dutyMode.fegin.name=AMOSDUTYMODE
##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF ##\u89C4\u5219\u5BF9\u8C61\u81EA\u52A8\u626B\u63CF
rule.definition.load=true rule.definition.load=true
rule.definition.model-package=com.yeejoin.amos.fas.business.action.model rule.definition.model-package=com.yeejoin.amos.fas.business.action.model
rule.definition.default-agency=STATE_GRID rule.definition.default-agency=STATE_GRID
#Fegin service config #Fegin service config
amos.feign.gennerator.use-gateway=true amos.feign.gennerator.use-gateway=true
autoSys.push.type=mqtt autoSys.push.type=mqtt
#����� #�����
file.downLoad.url=http://39.98.246.31:8888/ file.downLoad.url=http://39.98.246.31:8888/
#站端名称使用全拼 #站端名称使用全拼
station.name = yinan station.name = yinan
spring.application.name = AMOS-AUTOSYS spring.application.name = AMOS-AUTOSYS-ZJW
server.port = 8083 server.port = 8083
spring.profiles.active=dev spring.profiles.active=dev
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog <databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"> http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<changeSet author="suhuiguang" id="1587349916716-1"> <changeSet author="suhuiguang" id="1587349916716-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_risk_source" columnName="ue4_location"/> <columnExists tableName="f_risk_source" columnName="ue4_location"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_risk_source add column ue4_location</comment> <comment>f_risk_source add column ue4_location</comment>
<sql> <sql>
alter table `f_risk_source` add column `ue4_location` text default null comment 'ue4位置' after `position3d`; alter table `f_risk_source` add column `ue4_location` text default null comment 'ue4位置' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587349916716-2"> <changeSet author="suhuiguang" id="1587349916716-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_risk_source" columnName="ue4_rotation"/> <columnExists tableName="f_risk_source" columnName="ue4_rotation"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_risk_source add column ue4_rotation</comment> <comment>f_risk_source add column ue4_rotation</comment>
<sql> <sql>
alter table `f_risk_source` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`; alter table `f_risk_source` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587349916716-3"> <changeSet author="suhuiguang" id="1587349916716-3">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_risk_source" columnName="ue4_extent"/> <columnExists tableName="f_risk_source" columnName="ue4_extent"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_risk_source add column ue4_extent</comment> <comment>f_risk_source add column ue4_extent</comment>
<sql> <sql>
alter table `f_risk_source` add column `ue4_extent` text default null comment 'ue4缩放' after `position3d`; alter table `f_risk_source` add column `ue4_extent` text default null comment 'ue4缩放' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587351415717-1"> <changeSet author="suhuiguang" id="1587351415717-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_equipment" columnName="ue4_location"/> <columnExists tableName="f_equipment" columnName="ue4_location"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_equipment add column ue4_location</comment> <comment>f_equipment add column ue4_location</comment>
<sql> <sql>
alter table `f_equipment` add column `ue4_location` text default null comment 'ue4位置' after `position3d`; alter table `f_equipment` add column `ue4_location` text default null comment 'ue4位置' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587351415717-2"> <changeSet author="suhuiguang" id="1587351415717-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_equipment" columnName="ue4_rotation"/> <columnExists tableName="f_equipment" columnName="ue4_rotation"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_equipment add column ue4_rotation</comment> <comment>f_equipment add column ue4_rotation</comment>
<sql> <sql>
alter table `f_equipment` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`; alter table `f_equipment` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350445716-1"> <changeSet author="suhuiguang" id="1587350445716-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_fire_car" columnName="ue4_location"/> <columnExists tableName="f_fire_car" columnName="ue4_location"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_fire_car add column ue4_location</comment> <comment>f_fire_car add column ue4_location</comment>
<sql> <sql>
alter table `f_fire_car` add column `ue4_location` text default null comment 'ue4位置' after `position3d`; alter table `f_fire_car` add column `ue4_location` text default null comment 'ue4位置' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350445716-2"> <changeSet author="suhuiguang" id="1587350445716-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_fire_car" columnName="ue4_rotation"/> <columnExists tableName="f_fire_car" columnName="ue4_rotation"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_fire_car add column ue4_rotation</comment> <comment>f_fire_car add column ue4_rotation</comment>
<sql> <sql>
alter table `f_fire_car` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`; alter table `f_fire_car` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350552716-1"> <changeSet author="suhuiguang" id="1587350552716-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_fire_equipment" columnName="ue4_location"/> <columnExists tableName="f_fire_equipment" columnName="ue4_location"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_fire_equipment add column ue4_location</comment> <comment>f_fire_equipment add column ue4_location</comment>
<sql> <sql>
alter table `f_fire_equipment` add column `ue4_location` text default null comment 'ue4位置' after `position3d`; alter table `f_fire_equipment` add column `ue4_location` text default null comment 'ue4位置' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350552716-2"> <changeSet author="suhuiguang" id="1587350552716-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_fire_equipment" columnName="ue4_rotation"/> <columnExists tableName="f_fire_equipment" columnName="ue4_rotation"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_fire_equipment add column ue4_rotation</comment> <comment>f_fire_equipment add column ue4_rotation</comment>
<sql> <sql>
alter table `f_fire_equipment` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`; alter table `f_fire_equipment` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350593716-1"> <changeSet author="suhuiguang" id="1587350593716-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_fire_station" columnName="ue4_location"/> <columnExists tableName="f_fire_station" columnName="ue4_location"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_fire_station add column ue4_location</comment> <comment>f_fire_station add column ue4_location</comment>
<sql> <sql>
alter table `f_fire_station` add column `ue4_location` text default null comment 'ue4位置' after `position3d`; alter table `f_fire_station` add column `ue4_location` text default null comment 'ue4位置' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350593716-2"> <changeSet author="suhuiguang" id="1587350593716-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_fire_station" columnName="ue4_rotation"/> <columnExists tableName="f_fire_station" columnName="ue4_rotation"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_fire_station add column ue4_rotation</comment> <comment>f_fire_station add column ue4_rotation</comment>
<sql> <sql>
alter table `f_fire_station` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`; alter table `f_fire_station` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350759717-1"> <changeSet author="suhuiguang" id="1587350759717-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_water_resource" columnName="ue4_location"/> <columnExists tableName="f_water_resource" columnName="ue4_location"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_water_resource add column ue4_location</comment> <comment>f_water_resource add column ue4_location</comment>
<sql> <sql>
alter table `f_water_resource` add column `ue4_location` text default null comment 'ue4位置' after `position3d`; alter table `f_water_resource` add column `ue4_location` text default null comment 'ue4位置' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350759717-2"> <changeSet author="suhuiguang" id="1587350759717-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_water_resource" columnName="ue4_rotation"/> <columnExists tableName="f_water_resource" columnName="ue4_rotation"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_water_resource add column ue4_rotation</comment> <comment>f_water_resource add column ue4_rotation</comment>
<sql> <sql>
alter table `f_water_resource` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`; alter table `f_water_resource` add column `ue4_rotation` text default null comment 'ue4旋转' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1587350860716-1"> <changeSet author="suhuiguang" id="1587350860716-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<tableExists tableName="f_safety_index_change_log"/> <tableExists tableName="f_safety_index_change_log"/>
</not> </not>
</preConditions> </preConditions>
<comment>create f_safety_index_change_log</comment> <comment>create f_safety_index_change_log</comment>
<sql> <sql>
create table f_safety_index_change_log create table f_safety_index_change_log
( (
id bigint(20) not null auto_increment comment '物理主键', id bigint(20) not null auto_increment comment '物理主键',
safety_index decimal(4,1) comment '安全指数', safety_index decimal(4,1) comment '安全指数',
collect_date date comment '统计日期', collect_date date comment '统计日期',
org_code varchar(100) comment '机构', org_code varchar(100) comment '机构',
remark varchar(255) comment '备注', remark varchar(255) comment '备注',
primary key (id) primary key (id)
); );
alter table f_safety_index_change_log comment '安全指数日流水'; alter table f_safety_index_change_log comment '安全指数日流水';
create index Index_org_code on f_safety_index_change_log create index Index_org_code on f_safety_index_change_log
( (
org_code org_code
); );
</sql> </sql>
</changeSet> </changeSet>
<changeSet id="1587882668719-1" author="suhuiguang"> <changeSet id="1587882668719-1" author="suhuiguang">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<indexExists indexName="idx_type"/> <indexExists indexName="idx_type"/>
</not> </not>
</preConditions> </preConditions>
<createIndex <createIndex
indexName="idx_type" indexName="idx_type"
tableName="f_fire_station" tableName="f_fire_station"
tablespace="A String" tablespace="A String"
unique="false"> unique="false">
<column name="type"/> <column name="type"/>
</createIndex> </createIndex>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1588067351000-1"> <changeSet author="shanqiyun" id="1588067351000-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_risk_source" columnName="route_path"/> <columnExists tableName="f_risk_source" columnName="route_path"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_risk_source add column route_path </comment> <comment>f_risk_source add column route_path </comment>
<sql> <sql>
alter table f_risk_source add column `route_path` varchar(2000) DEFAULT NULL COMMENT '路径坐标' after `position3d`; alter table f_risk_source add column `route_path` varchar(2000) DEFAULT NULL COMMENT '路径坐标' after `position3d`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1588140925893-1"> <changeSet author="suhuiguang" id="1588140925893-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_safety_index_change_log" columnName="create_date"/> <columnExists tableName="f_safety_index_change_log" columnName="create_date"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_safety_index_change_log add column create_date</comment> <comment>f_safety_index_change_log add column create_date</comment>
<sql> <sql>
alter table `f_safety_index_change_log` add column `create_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间'; alter table `f_safety_index_change_log` add column `create_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1588990926789-1"> <changeSet author="suhuiguang" id="1588990926789-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_risk_level " columnName="manage_level"/> <columnExists tableName="f_risk_level " columnName="manage_level"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_risk_level add column manage_level 管控级别</comment> <comment>f_risk_level add column manage_level 管控级别</comment>
<sql> <sql>
ALTER TABLE `f_risk_level` ALTER TABLE `f_risk_level`
add COLUMN `manage_level` tinyint(4) DEFAULT NULL COMMENT '管控级别'; add COLUMN `manage_level` tinyint(4) DEFAULT NULL COMMENT '管控级别';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1589165258908-1"> <changeSet author="suhuiguang" id="1589165258908-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_rpn_change_log " columnName="trigger_type"/> <columnExists tableName="f_rpn_change_log " columnName="trigger_type"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_rpn_change_log add column trigger_type 触发类型</comment> <comment>f_rpn_change_log add column trigger_type 触发类型</comment>
<sql> <sql>
ALTER TABLE `f_rpn_change_log` ALTER TABLE `f_rpn_change_log`
add COLUMN `trigger_type` varchar(20) DEFAULT NULL COMMENT '触发类型:巡检、告警、评价、删除' after `trigger_by`; add COLUMN `trigger_type` varchar(20) DEFAULT NULL COMMENT '触发类型:巡检、告警、评价、删除' after `trigger_by`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1589165258908-2"> <changeSet author="suhuiguang" id="1589165258908-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_risk_source " columnName="flicker_frequency"/> <columnExists tableName="f_risk_source " columnName="flicker_frequency"/>
</not> </not>
</preConditions> </preConditions>
<comment>f_risk_source add column flicker_frequency 闪烁频率</comment> <comment>f_risk_source add column flicker_frequency 闪烁频率</comment>
<sql> <sql>
ALTER TABLE `f_risk_source` ALTER TABLE `f_risk_source`
add COLUMN `flicker_frequency` int(11) DEFAULT 0 COMMENT '闪烁频率' after `status`; add COLUMN `flicker_frequency` int(11) DEFAULT 0 COMMENT '闪烁频率' after `status`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="maoying" id="1589444792914-1"> <changeSet author="maoying" id="1589444792914-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="f_alarm"/> <tableExists tableName="f_alarm"/>
</preConditions> </preConditions>
<comment>create table f_alarm</comment> <comment>create table f_alarm</comment>
<sql> <sql>
DROP TABLE IF EXISTS f_alarm; DROP TABLE IF EXISTS f_alarm;
CREATE TABLE `f_alarm` ( CREATE TABLE `f_alarm` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`org_code` varchar(100) NOT NULL COMMENT '机构编号', `org_code` varchar(100) NOT NULL COMMENT '机构编号',
`fire_equipment_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '消防设备id', `fire_equipment_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '消防设备id',
`fire_equipment_code` varchar(255) NOT NULL COMMENT '设备编码', `fire_equipment_code` varchar(255) NOT NULL COMMENT '设备编码',
`fire_equipment_name` varchar(255) NOT NULL COMMENT '设备名称', `fire_equipment_name` varchar(255) NOT NULL COMMENT '设备名称',
`fire_equipment_point_id` bigint(20) NOT NULL COMMENT '消防点位id', `fire_equipment_point_id` bigint(20) NOT NULL COMMENT '消防点位id',
`fire_equipment_point_code` varchar(255) NOT NULL COMMENT '消防点位名称', `fire_equipment_point_code` varchar(255) NOT NULL COMMENT '消防点位名称',
`fire_equipment_point_name` varchar(255) NOT NULL, `fire_equipment_point_name` varchar(255) NOT NULL,
`fire_equipment_point_value` varchar(500) DEFAULT NULL COMMENT '报警值', `fire_equipment_point_value` varchar(500) DEFAULT NULL COMMENT '报警值',
`frequency` int(10) NOT NULL DEFAULT '1' COMMENT '发生频次', `frequency` int(10) NOT NULL DEFAULT '1' COMMENT '发生频次',
`status` bit(1) DEFAULT b'1' COMMENT '报警状态:1报警0恢复', `status` bit(1) DEFAULT b'1' COMMENT '报警状态:1报警0恢复',
`type` varchar(50) NOT NULL COMMENT '报警类型:alarm_type_fire(火灾报警)/alarm_type_trouble(故障告警)', `type` varchar(50) NOT NULL COMMENT '报警类型:alarm_type_fire(火灾报警)/alarm_type_trouble(故障告警)',
`create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `update_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`recovery_date` datetime DEFAULT NULL COMMENT '告警恢复时间', `recovery_date` datetime DEFAULT NULL COMMENT '告警恢复时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='报警信息表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='报警信息表';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="zhouyi" id="1589444792916-1"> <changeSet author="zhouyi" id="1589444792916-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="f_station_info"/> <tableExists tableName="f_station_info"/>
</preConditions> </preConditions>
<comment>create table f_station_info</comment> <comment>create table f_station_info</comment>
<sql> <sql>
DROP TABLE IF EXISTS f_station_info; DROP TABLE IF EXISTS f_station_info;
CREATE TABLE `f_station_info` ( CREATE TABLE `f_station_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(20) DEFAULT NULL COMMENT '名称', `name` varchar(20) DEFAULT NULL COMMENT '名称',
`station_code` varchar(32) NOT NULL COMMENT '环流站编码', `station_code` varchar(32) NOT NULL COMMENT '环流站编码',
`code` varchar(10) DEFAULT NULL COMMENT '后三位编码', `code` varchar(10) DEFAULT NULL COMMENT '后三位编码',
`elec_type` tinyint(4) DEFAULT NULL COMMENT '换流站类型:1-发电类型;2-收电类型', `elec_type` tinyint(4) DEFAULT NULL COMMENT '换流站类型:1-发电类型;2-收电类型',
`use_type` tinyint(4) NOT NULL COMMENT '用途类型:1-电厂升压变电站;2-公用普通变电站;3-公用换流变电站;4-企业自备变电站;5-其他', `use_type` tinyint(4) NOT NULL COMMENT '用途类型:1-电厂升压变电站;2-公用普通变电站;3-公用换流变电站;4-企业自备变电站;5-其他',
`province_code` varchar(32) DEFAULT NULL COMMENT '省份编码', `province_code` varchar(32) DEFAULT NULL COMMENT '省份编码',
`city_code` varchar(32) DEFAULT NULL COMMENT '市区编码', `city_code` varchar(32) DEFAULT NULL COMMENT '市区编码',
`district_code` varchar(32) DEFAULT NULL COMMENT '区县编码', `district_code` varchar(32) DEFAULT NULL COMMENT '区县编码',
`address` varchar(255) DEFAULT NULL COMMENT '详细地址', `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
`status` bit(1) NOT NULL DEFAULT b'0' COMMENT '0-启用;1-停用', `status` bit(1) NOT NULL DEFAULT b'0' COMMENT '0-启用;1-停用',
`longitude` double DEFAULT NULL COMMENT '经度', `longitude` double DEFAULT NULL COMMENT '经度',
`latitude` double DEFAULT NULL COMMENT '纬度', `latitude` double DEFAULT NULL COMMENT '纬度',
`station_charge_user_id` varchar(50) DEFAULT NULL COMMENT '换流站负责人', `station_charge_user_id` varchar(50) DEFAULT NULL COMMENT '换流站负责人',
`safety_charge_user_id` varchar(50) DEFAULT NULL COMMENT '安全负责人', `safety_charge_user_id` varchar(50) DEFAULT NULL COMMENT '安全负责人',
`create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建日期', `create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建日期',
`create_by` varchar(255) DEFAULT NULL COMMENT '创建人', `create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
`remark` varchar(255) DEFAULT NULL COMMENT '备注', `remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `f_station_info_uniq` (`station_code`) UNIQUE KEY `f_station_info_uniq` (`station_code`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COMMENT='站端信息表'; ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COMMENT='站端信息表';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="suhuiguang" id="1589769364577-1"> <changeSet author="suhuiguang" id="1589769364577-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<columnExists tableName="f_risk_level " columnName="manage_level"/> <columnExists tableName="f_risk_level " columnName="manage_level"/>
</preConditions> </preConditions>
<comment>f_risk_level 增加管控级别 初始化数据</comment> <comment>f_risk_level 增加管控级别 初始化数据</comment>
<sql> <sql>
update f_risk_level set manage_level = 1 where level = '1'; update f_risk_level set manage_level = 1 where level = '1';
update f_risk_level set manage_level = 2 where level = '2'; update f_risk_level set manage_level = 2 where level = '2';
update f_risk_level set manage_level = 3 where level = '3'; update f_risk_level set manage_level = 3 where level = '3';
update f_risk_level set manage_level = 4 where level = '4'; update f_risk_level set manage_level = 4 where level = '4';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="maoying" id="11590390304001-1"> <changeSet author="maoying" id="11590390304001-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<columnExists tableName="f_fire_equipment_point " columnName="fire_equipment_id"/> <columnExists tableName="f_fire_equipment_point " columnName="fire_equipment_id"/>
</preConditions> </preConditions>
<comment>修改fire_equipment_id可为空</comment> <comment>修改fire_equipment_id可为空</comment>
<sql> <sql>
ALTER TABLE `f_fire_equipment_point` ALTER TABLE `f_fire_equipment_point`
MODIFY COLUMN `fire_equipment_id` bigint(20) NULL COMMENT '消防装备id' AFTER `code`; MODIFY COLUMN `fire_equipment_id` bigint(20) NULL COMMENT '消防装备id' AFTER `code`;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1591672147780-1"> <changeSet author="shanqiyun" id="1591672147780-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<viewExists viewName="toip_biz_message"/> <viewExists viewName="toip_biz_message"/>
</preConditions> </preConditions>
<comment>create view toip_biz_message</comment> <comment>create view toip_biz_message</comment>
<sql> <sql>
DROP VIEW IF EXISTS toip_biz_message; DROP VIEW IF EXISTS toip_biz_message;
CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `toip_biz_message` AS SELECT CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `toip_biz_message` AS SELECT
`m`.`id` AS `id`, `m`.`id` AS `id`,
`m`.`time` AS `time`, `m`.`time` AS `time`,
`m`.`content` AS `content`, `m`.`content` AS `content`,
`m`.`title` AS `title`, `m`.`title` AS `title`,
`m`.`type` AS `type`, `m`.`type` AS `type`,
`m`.`sender` AS `sender`, `m`.`sender` AS `sender`,
`m`.`receiver` AS `receiver`, `m`.`receiver` AS `receiver`,
`m`.`reader` AS `reader`, `m`.`reader` AS `reader`,
`m`.`biz_id` AS `biz_id`, `m`.`biz_id` AS `biz_id`,
`m`.`bizclass_name` AS `bizclass_name`, `m`.`bizclass_name` AS `bizclass_name`,
`n`.`org_code` AS `org_code` `n`.`org_code` AS `org_code`
FROM FROM
( `toip_sys_message` `m` JOIN `f_equipment` `n` ) ( `toip_sys_message` `m` JOIN `f_equipment` `n` )
WHERE WHERE
( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.FireEquimentDataRo' ) ) UNION ALL ( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.FireEquimentDataRo' ) ) UNION ALL
SELECT SELECT
`m`.`id` AS `id`, `m`.`id` AS `id`,
`m`.`time` AS `time`, `m`.`time` AS `time`,
`m`.`content` AS `content`, `m`.`content` AS `content`,
`m`.`title` AS `title`, `m`.`title` AS `title`,
`m`.`type` AS `type`, `m`.`type` AS `type`,
`m`.`sender` AS `sender`, `m`.`sender` AS `sender`,
`m`.`receiver` AS `receiver`, `m`.`receiver` AS `receiver`,
`m`.`reader` AS `reader`, `m`.`reader` AS `reader`,
`m`.`biz_id` AS `biz_id`, `m`.`biz_id` AS `biz_id`,
`m`.`bizclass_name` AS `bizclass_name`, `m`.`bizclass_name` AS `bizclass_name`,
`n`.`org_code` AS `org_code` `n`.`org_code` AS `org_code`
FROM FROM
( `toip_sys_message` `m` JOIN `p_point` `n` ) ( `toip_sys_message` `m` JOIN `p_point` `n` )
WHERE WHERE
( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.ProtalDataRo' ) ) UNION ALL ( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.ProtalDataRo' ) ) UNION ALL
SELECT SELECT
`m`.`id` AS `id`, `m`.`id` AS `id`,
`m`.`time` AS `time`, `m`.`time` AS `time`,
`m`.`content` AS `content`, `m`.`content` AS `content`,
`m`.`title` AS `title`, `m`.`title` AS `title`,
`m`.`type` AS `type`, `m`.`type` AS `type`,
`m`.`sender` AS `sender`, `m`.`sender` AS `sender`,
`m`.`receiver` AS `receiver`, `m`.`receiver` AS `receiver`,
`m`.`reader` AS `reader`, `m`.`reader` AS `reader`,
`m`.`biz_id` AS `biz_id`, `m`.`biz_id` AS `biz_id`,
`m`.`bizclass_name` AS `bizclass_name`, `m`.`bizclass_name` AS `bizclass_name`,
`n`.`org_code` AS `org_code` `n`.`org_code` AS `org_code`
FROM FROM
( `toip_sys_message` `m` JOIN `f_risk_source` `n` ) ( `toip_sys_message` `m` JOIN `f_risk_source` `n` )
WHERE WHERE
( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.RiskSourceRuleRo' ) ); ( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.RiskSourceRuleRo' ) );
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1593309428780-1"> <changeSet author="shanqiyun" id="1593309428780-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<tableExists tableName="contingency_original_data" /> <tableExists tableName="contingency_original_data" />
</not> </not>
</preConditions> </preConditions>
<comment>create table contingency_original_data</comment> <comment>create table contingency_original_data</comment>
<sql> <sql>
DROP TABLE IF EXISTS contingency_original_data; DROP TABLE IF EXISTS contingency_original_data;
CREATE TABLE `contingency_original_data` ( CREATE TABLE `contingency_original_data` (
`id` varchar(36) NOT NULL COMMENT 'rule', `id` varchar(36) NOT NULL COMMENT 'rule',
`fire_Equipment_Name` varchar(32) NOT NULL COMMENT '记录类型:消息MESSAGE,操作OPERATE', `fire_Equipment_Name` varchar(32) NOT NULL COMMENT '记录类型:消息MESSAGE,操作OPERATE',
`fire_Equipment_Id` varchar(500) NOT NULL COMMENT '记录内容:文本信息或者json数据', `fire_Equipment_Id` varchar(500) NOT NULL COMMENT '记录内容:文本信息或者json数据',
`layer` int(11) NOT NULL COMMENT '一级分类', `layer` int(11) NOT NULL COMMENT '一级分类',
`fire_Equipment_Layer` int(11) NOT NULL COMMENT '二级分类', `fire_Equipment_Layer` int(11) NOT NULL COMMENT '二级分类',
`fire_Equipment_Position` varchar(255) DEFAULT NULL COMMENT '图标,url,或者文件名', `fire_Equipment_Position` varchar(255) DEFAULT NULL COMMENT '图标,url,或者文件名',
`equipment_Id` int(11) NOT NULL COMMENT '排序', `equipment_Id` int(11) NOT NULL COMMENT '排序',
`equipment_Name` varchar(255) DEFAULT NULL, `equipment_Name` varchar(255) DEFAULT NULL,
`mobile` varchar(255) DEFAULT NULL, `mobile` varchar(255) DEFAULT NULL,
`admin_Name` varchar(255) DEFAULT NULL, `admin_Name` varchar(255) DEFAULT NULL,
`camera_Codes` varchar(255) DEFAULT NULL, `camera_Codes` varchar(255) DEFAULT NULL,
`camera_Ids` varchar(255) DEFAULT NULL, `camera_Ids` varchar(255) DEFAULT NULL,
`fire_Count` int(11) DEFAULT NULL, `fire_Count` int(11) DEFAULT NULL,
`confirm` varchar(255) DEFAULT NULL, `confirm` varchar(255) DEFAULT NULL,
`create_date` datetime DEFAULT NULL, `create_date` datetime DEFAULT NULL,
`create_user` varchar(50) DEFAULT NULL, `create_user` varchar(50) DEFAULT NULL,
`update_date` datetime DEFAULT NULL, `update_date` datetime DEFAULT NULL,
`update_user` varchar(50) DEFAULT NULL, `update_user` varchar(50) DEFAULT NULL,
`is_delete` bit(1) DEFAULT NULL, `is_delete` bit(1) DEFAULT NULL,
`batch_No` varchar(36) NOT NULL, `batch_No` varchar(36) NOT NULL,
`picture1` varchar(255) DEFAULT NULL, `picture1` varchar(255) DEFAULT NULL,
`picture2` varchar(255) DEFAULT NULL, `picture2` varchar(255) DEFAULT NULL,
`picture4` varchar(255) DEFAULT NULL, `picture4` varchar(255) DEFAULT NULL,
`picture3` varchar(255) DEFAULT NULL, `picture3` varchar(255) DEFAULT NULL,
`fire_Truck_Route` varchar(2000) DEFAULT NULL, `fire_Truck_Route` varchar(2000) DEFAULT NULL,
`runstep` bit(1) DEFAULT NULL, `runstep` bit(1) DEFAULT NULL,
`step_state` varchar(255) DEFAULT NULL, `step_state` varchar(255) DEFAULT NULL,
`step` varchar(255) DEFAULT NULL, `step` varchar(255) DEFAULT NULL,
`equipment_position3d` varchar(255) DEFAULT NULL, `equipment_position3d` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `INDEX_BATCH_NO` (`batch_No`) UNIQUE KEY `INDEX_BATCH_NO` (`batch_No`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案信息节点定义'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案信息节点定义';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1593309428780-2"> <changeSet author="shanqiyun" id="1593309428780-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<tableExists tableName="contingency_plan" /> <tableExists tableName="contingency_plan" />
</not> </not>
</preConditions> </preConditions>
<comment>create table contingency_plan</comment> <comment>create table contingency_plan</comment>
<sql> <sql>
DROP TABLE IF EXISTS contingency_plan; DROP TABLE IF EXISTS contingency_plan;
CREATE TABLE `contingency_plan` ( CREATE TABLE `contingency_plan` (
`id` varchar(36) NOT NULL COMMENT 'rule', `id` varchar(36) NOT NULL COMMENT 'rule',
`record_type` varchar(32) NOT NULL COMMENT '记录类型:消息MESSAGE,操作OPERATE', `record_type` varchar(32) NOT NULL COMMENT '记录类型:消息MESSAGE,操作OPERATE',
`content` varchar(500) NOT NULL COMMENT '记录内容:文本信息或者json数据', `content` varchar(500) NOT NULL COMMENT '记录内容:文本信息或者json数据',
`category` varchar(36) NOT NULL COMMENT '一级分类', `category` varchar(36) NOT NULL COMMENT '一级分类',
`sub_category` varchar(36) NOT NULL COMMENT '二级分类', `sub_category` varchar(36) NOT NULL COMMENT '二级分类',
`icon` varchar(255) DEFAULT NULL COMMENT '图标,url,或者文件名', `icon` varchar(255) DEFAULT NULL COMMENT '图标,url,或者文件名',
`sort` int(11) NOT NULL COMMENT '排序', `sort` int(11) NOT NULL COMMENT '排序',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案信息节点定义'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案信息节点定义';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shanqiyun" id="1593309428780-3"> <changeSet author="shanqiyun" id="1593309428780-3">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<tableExists tableName="contingency_plan_instance" /> <tableExists tableName="contingency_plan_instance" />
</not> </not>
</preConditions> </preConditions>
<comment>create table contingency_plan_instance</comment> <comment>create table contingency_plan_instance</comment>
<sql> <sql>
DROP TABLE IF EXISTS contingency_plan_instance; DROP TABLE IF EXISTS contingency_plan_instance;
CREATE TABLE `contingency_plan_instance` ( CREATE TABLE `contingency_plan_instance` (
`id` varchar(36) NOT NULL COMMENT 'rule', `id` varchar(36) NOT NULL COMMENT 'rule',
`record_type` varchar(32) NOT NULL COMMENT '记录类型:消息MESSAGE,操作OPERATE', `record_type` varchar(32) NOT NULL COMMENT '记录类型:消息MESSAGE,操作OPERATE',
`category` varchar(36) DEFAULT NULL COMMENT '一级分类', `category` varchar(36) DEFAULT NULL COMMENT '一级分类',
`content` varchar(2000) NOT NULL COMMENT '记录内容:文本信息或者json数据', `content` varchar(2000) NOT NULL COMMENT '记录内容:文本信息或者json数据',
`icon` varchar(255) DEFAULT NULL COMMENT '图标,url,或者文件名', `icon` varchar(255) DEFAULT NULL COMMENT '图标,url,或者文件名',
`sort` int(11) DEFAULT NULL COMMENT '所有节点一起的排序号', `sort` int(11) DEFAULT NULL COMMENT '所有节点一起的排序号',
`sequence_num` int(11) DEFAULT NULL COMMENT '用于显示的序号', `sequence_num` int(11) DEFAULT NULL COMMENT '用于显示的序号',
`batch_no` varchar(36) NOT NULL COMMENT '预案实例编号,暂时无法区分多个火灾,暂时存储报警设备id', `batch_no` varchar(36) NOT NULL COMMENT '预案实例编号,暂时无法区分多个火灾,暂时存储报警设备id',
`create_date` datetime DEFAULT NULL, `create_date` datetime DEFAULT NULL,
`create_user` varchar(50) DEFAULT NULL, `create_user` varchar(50) DEFAULT NULL,
`update_date` datetime DEFAULT NULL, `update_date` datetime DEFAULT NULL,
`update_user` varchar(50) DEFAULT NULL, `update_user` varchar(50) DEFAULT NULL,
`is_delete` bit(1) DEFAULT NULL, `is_delete` bit(1) DEFAULT NULL,
`tips` varchar(255) DEFAULT NULL, `tips` varchar(255) DEFAULT NULL,
`runstate` bit(1) DEFAULT NULL, `runstate` bit(1) DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案执行记录实例'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案执行记录实例';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1605924681-1"> <changeSet author="keyong" id="1605924681-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_station_info" columnName="station_charge_user_name" /> <columnExists tableName="f_station_info" columnName="station_charge_user_name" />
</not> </not>
</preConditions> </preConditions>
<comment>修改f_station_info表结构</comment> <comment>修改f_station_info表结构</comment>
<sql> <sql>
ALTER TABLE `f_station_info` ADD COLUMN `station_charge_user_name` varchar(20) NULL COMMENT '换流站负责人姓名'; ALTER TABLE `f_station_info` ADD COLUMN `station_charge_user_name` varchar(20) NULL COMMENT '换流站负责人姓名';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1605924681-2"> <changeSet author="keyong" id="1605924681-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_station_info" columnName="safety_charge_user_name" /> <columnExists tableName="f_station_info" columnName="safety_charge_user_name" />
</not> </not>
</preConditions> </preConditions>
<comment>修改f_station_info表结构</comment> <comment>修改f_station_info表结构</comment>
<sql> <sql>
ALTER TABLE `f_station_info` ADD COLUMN `safety_charge_user_name` varchar(20) NULL COMMENT '安全负责人姓名'; ALTER TABLE `f_station_info` ADD COLUMN `safety_charge_user_name` varchar(20) NULL COMMENT '安全负责人姓名';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1605924681-3"> <changeSet author="keyong" id="1605924681-3">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_station_info" columnName="create_user_name" /> <columnExists tableName="f_station_info" columnName="create_user_name" />
</not> </not>
</preConditions> </preConditions>
<comment>修改f_station_info表结构</comment> <comment>修改f_station_info表结构</comment>
<sql> <sql>
ALTER TABLE `f_station_info` ADD COLUMN `create_user_name` varchar(20) NULL COMMENT '创建人姓名'; ALTER TABLE `f_station_info` ADD COLUMN `create_user_name` varchar(20) NULL COMMENT '创建人姓名';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1606290088-1"> <changeSet author="keyong" id="1606290088-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_station_info" columnName="create_user_phone_num" /> <columnExists tableName="f_station_info" columnName="create_user_phone_num" />
</not> </not>
</preConditions> </preConditions>
<comment>修改f_station_info表结构</comment> <comment>修改f_station_info表结构</comment>
<sql> <sql>
ALTER TABLE `f_station_info` ADD COLUMN `create_user_phone_num` varchar(20) NULL COMMENT '创建人联系方式'; ALTER TABLE `f_station_info` ADD COLUMN `create_user_phone_num` varchar(20) NULL COMMENT '创建人联系方式';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1606290088-2"> <changeSet author="keyong" id="1606290088-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_station_info" columnName="station_user_phone_num" /> <columnExists tableName="f_station_info" columnName="station_user_phone_num" />
</not> </not>
</preConditions> </preConditions>
<comment>修改f_station_info表结构</comment> <comment>修改f_station_info表结构</comment>
<sql> <sql>
ALTER TABLE `f_station_info` ADD COLUMN `station_user_phone_num` varchar(20) NULL COMMENT '换流站负责人联系方式'; ALTER TABLE `f_station_info` ADD COLUMN `station_user_phone_num` varchar(20) NULL COMMENT '换流站负责人联系方式';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1606290088-3"> <changeSet author="keyong" id="1606290088-3">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
<columnExists tableName="f_station_info" columnName="safety_user_phone_num" /> <columnExists tableName="f_station_info" columnName="safety_user_phone_num" />
</not> </not>
</preConditions> </preConditions>
<comment>修改f_station_info表结构</comment> <comment>修改f_station_info表结构</comment>
<sql> <sql>
ALTER TABLE `f_station_info` ADD COLUMN `safety_user_phone_num` varchar(20) NULL COMMENT '安全负责人联系方式'; ALTER TABLE `f_station_info` ADD COLUMN `safety_user_phone_num` varchar(20) NULL COMMENT '安全负责人联系方式';
</sql> </sql>
</changeSet> </changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -86,14 +86,14 @@ ...@@ -86,14 +86,14 @@
</select> </select>
<select id="getFireEquiments" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpeVo"> <select id="getFireEquiments" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpeVo">
select select
sto.equipment_specific_id as id , sto.id as id ,
equ.code as f_code, equ.code as f_code,
det.name as f_name det.name as f_name
from from
wl_stock_detail as sto wl_stock_detail as sto
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 f_equipment_fire_equipment as fire on sto.equipment_specific_id = fire.fire_equipment_id left join f_equipment_fire_equipment as fire on sto.id = fire.fire_equipment_id
where sto.amount <![CDATA[>]]> 0 where sto.amount <![CDATA[>]]> 0
<if test="fname != null and fname!='null' "> <if test="fname != null and fname!='null' ">
and det.name like CONCAT('%',#{fname},'%' ) and det.name like CONCAT('%',#{fname},'%' )
...@@ -119,9 +119,9 @@ ...@@ -119,9 +119,9 @@
d.important_equipment_id = #{importantEquipId} ) isBound d.important_equipment_id = #{importantEquipId} ) isBound
from from
f_equipment_fire_equipment as fire f_equipment_fire_equipment as fire
left join wl_stock_detail as sto on fire.fire_equipment_id = sto.equipment_specific_id left join wl_stock_detail as sto on fire.fire_equipment_id = sto.id
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
left join wl_equipment_specific_index as speind on sto.equipment_specific_id = speind.equipment_specific_id left join wl_equipment_specific_index as speind on spe.id = speind.equipment_specific_id
left join wl_equipment_index as equindex on speind.equipment_index_id = equindex.id left join wl_equipment_index as equindex on speind.equipment_index_id = equindex.id
where equindex.type_code ='BREAKDOWN' where equindex.type_code ='BREAKDOWN'
<if test="importantEquipId != null "> <if test="importantEquipId != null ">
......
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper"> <mapper namespace="com.yeejoin.amos.fas.business.dao.mapper.RiskSourceMapper">
<!--统计--> <!--统计-->
<select id="countPageData" resultType="long"> <select id="countPageData" resultType="long">
SELECT SELECT
COUNT(1) AS total_num COUNT(1) AS total_num
FROM FROM
f_risk_source rs f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
<trim prefix="WHERE" prefixOverrides="AND "> <trim prefix="WHERE" prefixOverrides="AND ">
<if test="name!=null"> and rs.name like concat(concat("%",#{name}),"%")</if> <if test="name!=null"> and rs.name like concat(concat("%",#{name}),"%")</if>
</trim> </trim>
</select> </select>
<!--分页查询 --> <!--分页查询 -->
<select id="queryRiskSourceByPage" resultType="java.util.HashMap"> <select id="queryRiskSourceByPage" resultType="java.util.HashMap">
SELECT SELECT
rs.*, rl.`name` riskLevelName rs.*, rl.`name` riskLevelName
FROM FROM
f_risk_source rs f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
<trim prefix="WHERE" prefixOverrides="AND "> <trim prefix="WHERE" prefixOverrides="AND ">
<if test="name!=null"> and rs.name like concat(concat("%",#{name}),"%")</if> <if test="name!=null"> and rs.name like concat(concat("%",#{name}),"%")</if>
</trim> </trim>
order by rs.id desc order by rs.id desc
<choose> <choose>
<when test="pageSize==-1"></when> <when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when> <when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
</choose> </choose>
</select> </select>
<select id="queryForRegion" resultType="java.util.Map"> <select id="queryForRegion" resultType="java.util.Map">
SELECT SELECT
rs.id, rs.id,
rs.`code`, rs.`code`,
rs.`name`, rs.`name`,
(select rl.color from f_risk_level rl where rl.id = rs.risk_level_id) color, (select rl.color from f_risk_level rl where rl.id = rs.risk_level_id) color,
(select rl.`level` from f_risk_level rl where rl.id = rs.risk_level_id) level, (select rl.`level` from f_risk_level rl where rl.id = rs.risk_level_id) level,
rs.parent_id parentId rs.parent_id parentId
FROM FROM
f_risk_source rs f_risk_source rs
where rs.is_region = 'TRUE'; where rs.is_region = 'TRUE';
</select> </select>
<select id="queryRPNReport" resultType="java.util.Map"> <select id="queryRPNReport" resultType="java.util.Map">
<!-- SELECT <!-- SELECT
rs.`code`, rs.`code`,
rs.id, rs.id,
rs.`name`, rs.`name`,
IFNULL(rs.rpn, 0) rpn, IFNULL(rs.rpn, 0) rpn,
IFNULL( IFNULL(
( (
SELECT SELECT
sum(ff.rpni) sum(ff.rpni)
FROM FROM
f_fmea ff f_fmea ff
WHERE WHERE
ff.risk_source_id = rs.id ff.risk_source_id = rs.id
GROUP BY GROUP BY
ff.risk_source_id ff.risk_source_id
), ),
0 0
) rpni ) rpni
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
rs.parent_id &gt; 0 rs.parent_id &gt; 0
ORDER BY rpni DESC ORDER BY rpni DESC
LIMIT 10 --> LIMIT 10 -->
SELECT SELECT
rs.`code`, rs.`code`,
rs.id, rs.id,
rs.`name`, rs.`name`,
IFNULL(rs.rpn, 0) rpn, IFNULL(rs.rpn, 0) rpn,
IFNULL(rs.rpni, 0) rpni IFNULL(rs.rpni, 0) rpni
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
rs.parent_id &gt; 0 rs.parent_id &gt; 0
ORDER BY ORDER BY
rpni DESC, rpn DESC rpni DESC, rpn DESC
LIMIT 10 LIMIT 10
</select> </select>
<select id="queryForRiseUp" resultType="java.util.Map"> <select id="queryForRiseUp" resultType="java.util.Map">
select select
d.countOfType0, d.countOfType0,
d.countOfSource, d.countOfSource,
CONCAT(ROUND(IFNULL(d.countOfType0/d.countOfSource,0)*100,2),'%')type0Rate CONCAT(ROUND(IFNULL(d.countOfType0/d.countOfSource,0)*100,2),'%')type0Rate
from from
(SELECT (SELECT
count(DISTINCT cl.risk_source_id) countOfType0, count(DISTINCT cl.risk_source_id) countOfType0,
(select count(1) from f_risk_source rs )countOfSource (select count(1) from f_risk_source rs )countOfSource
FROM FROM
f_rpn_change_log cl f_rpn_change_log cl
WHERE WHERE
cl.type = 0 cl.type = 0
and cl.create_date BETWEEN '${startTime}' and '${endTime}' and cl.create_date BETWEEN '${startTime}' and '${endTime}'
)d )d
</select> </select>
<select id="queryForMatrix" resultType="java.util.Map"> <select id="queryForMatrix" resultType="java.util.Map">
<!-- SELECT <!-- SELECT
ff1.risk_source_id riskSourceId, ff1.risk_source_id riskSourceId,
ff1.evaluation_oid evaluationOid, ff1.evaluation_oid evaluationOid,
ff1.evaluation_sid evaluationSid, ff1.evaluation_sid evaluationSid,
d.mutiby, d.mutiby,
rs.`name` rs.`name`
FROM FROM
f_fmea ff1 f_fmea ff1
JOIN ( JOIN (
SELECT SELECT
ff.risk_source_id sourceId, ff.risk_source_id sourceId,
MAX( MAX(
ff.evaluation_oid * ff.evaluation_sid ff.evaluation_oid * ff.evaluation_sid
) mutiby ) mutiby
FROM FROM
f_fmea ff f_fmea ff
GROUP BY GROUP BY
ff.risk_source_id ff.risk_source_id
LIMIT 20 LIMIT 20
) d ON ( ) d ON (
ff1.risk_source_id = d.sourceId ff1.risk_source_id = d.sourceId
AND ff1.evaluation_oid * ff1.evaluation_sid AND ff1.evaluation_oid * ff1.evaluation_sid
) )
LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id
GROUP BY ff1.risk_source_id --> GROUP BY ff1.risk_source_id -->
SELECT SELECT
ff1.risk_source_id riskSourceId, ff1.risk_source_id riskSourceId,
d.ovalue evaluationOid, d.ovalue evaluationOid,
d.svalue evaluationSid, d.svalue evaluationSid,
d.mutiby, d.mutiby,
rs.`name` rs.`name`
FROM FROM
f_fmea ff1 f_fmea ff1
JOIN ( JOIN (
SELECT SELECT
o.risk_source_id sourceId, o.risk_source_id sourceId,
o.ovalue, o.ovalue,
s.svalue, s.svalue,
MAX(o.ovalue * s.svalue) mutiby MAX(o.ovalue * s.svalue) mutiby
FROM FROM
( (
SELECT SELECT
ff.risk_source_id, ff.risk_source_id,
fem.coefficient ovalue fem.coefficient ovalue
FROM FROM
f_fmea ff f_fmea ff
LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_oid LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_oid
) o ) o
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
ff.risk_source_id, ff.risk_source_id,
fem.coefficient svalue fem.coefficient svalue
FROM FROM
f_fmea ff f_fmea ff
LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_sid LEFT JOIN f_evaluation_model fem ON fem.id = ff.evaluation_sid
) s ON s.risk_source_id = o.risk_source_id ) s ON s.risk_source_id = o.risk_source_id
GROUP BY GROUP BY
o.risk_source_id o.risk_source_id
LIMIT 20 LIMIT 20
) d ON ( ) d ON (
ff1.risk_source_id = d.sourceId ff1.risk_source_id = d.sourceId
) )
LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id LEFT JOIN f_risk_source rs ON rs.id = ff1.risk_source_id
GROUP BY GROUP BY
ff1.risk_source_id; ff1.risk_source_id;
</select> </select>
<resultMap id="riskSourceMap" type="com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse"> <resultMap id="riskSourceMap" type="com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id" />
<result property="code" column="code" /> <result property="code" column="code" />
<result property="name" column="name" /> <result property="name" column="name" />
<result property="level" column="level" /> <result property="level" column="level" />
<result property="riskLevelId" column="risk_level_id" /> <result property="riskLevelId" column="risk_level_id" />
<result property="rpn" column="rpn" /> <result property="rpn" column="rpn" />
<result property="rpni" column="rpni" /> <result property="rpni" column="rpni" />
<result property="isRegion" column="is_region" /> <result property="isRegion" column="is_region" />
<result property="isIndoor" column="is_indoor" /> <result property="isIndoor" column="is_indoor" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="count" column="ccount" /> <result property="count" column="ccount" />
<result property="qualified" column="qualified" /> <result property="qualified" column="qualified" />
<result property="unqualified" column="unqualified" /> <result property="unqualified" column="unqualified" />
<result property="omission" column="omission" /> <result property="omission" column="omission" />
<result property="unplan" column="unplan" /> <result property="unplan" column="unplan" />
</resultMap> </resultMap>
<select id="getRiskSources" resultMap="riskSourceMap"> <select id="getRiskSources" resultMap="riskSourceMap">
SELECT SELECT
rs.id, rs.id,
rs.`code`, rs.`code`,
rs.parent_id, rs.parent_id,
rs.`name`, rs.`name`,
rl.`level`, rl.`level`,
rs.risk_level_id, rs.risk_level_id,
rs.rpn, rs.rpn,
rs.rpni, rs.rpni,
rs.is_region, rs.is_region,
rs.position3d, rs.position3d,
rs.floor3d, rs.floor3d,
rs.status, rs.status,
rs.is_indoor rs.is_indoor
FROM FROM
`f_risk_source` rs `f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
where rs.org_code = #{compCode} where rs.org_code = #{compCode}
ORDER BY rs.sort_num,rs.id ASC ORDER BY rs.sort_num,rs.id ASC
</select> </select>
<select id="getRiskSourcesEquipment" resultMap="riskSourceMap"> <select id="getRiskSourcesEquipment" resultMap="riskSourceMap">
SELECT SELECT
sum(a.cc) ccount, sum(a.cc) ccount,
a.`name`, a.`name`,
a.position3d, a.position3d,
a.parent_id, a.parent_id,
min(a.level) level, min(a.level) level,
a.id a.id
FROM FROM
( (
SELECT SELECT
IF (E.ID, 1, 0) cc, IF (E.ID, 1, 0) cc,
s.`name`, s.`name`,
s.position3d, s.position3d,
s.parent_id, s.parent_id,
s.risk_level_id level, s.risk_level_id level,
s.id s.id
FROM FROM
f_equipment e f_equipment e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id
) a ) a
GROUP BY GROUP BY
a.`name`, a.`name`,
a.position3d, a.position3d,
a.parent_id, a.parent_id,
a.id a.id
</select> </select>
<select id="getCheckPointRiskSource" resultMap="riskSourceMap"> <select id="getCheckPointRiskSource" resultMap="riskSourceMap">
SELECT SELECT
sum(a.cc) ccount, sum(a.cc) ccount,
a.`name`, a.`name`,
a.position3d, a.position3d,
a.parent_id, a.parent_id,
min(a.level) level, min(a.level) level,
sum(a.qualified) qualified, sum(a.qualified) qualified,
sum(a.unqualified) unqualified, sum(a.unqualified) unqualified,
sum(a.omission) omission, sum(a.omission) omission,
sum(a.unplan) unplan, sum(a.unplan) unplan,
a.id a.id
FROM FROM
( (
SELECT SELECT
IF (E.ID, 1, 0) cc, IF (E.ID, 1, 0) cc,
s.`name`, s.`name`,
s.position3d, s.position3d,
s.parent_id, s.parent_id,
IFNULL(e.`level`,0) level, IFNULL(e.`level`,0) level,
IF (E.`status` = '1', 1, 0) qualified, IF (E.`status` = '1', 1, 0) qualified,
IF (E.`status` = '2', 1, 0) unqualified, IF (E.`status` = '2', 1, 0) unqualified,
IF (E.`status` = '3', 1, 0) omission, IF (E.`status` = '3', 1, 0) omission,
IF (E.`status` = '0', 1, 0) unplan, IF (E.`status` = '0', 1, 0) unplan,
e.`status`, e.`status`,
s.id s.id
FROM FROM
p_point e p_point e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id and e.is_delete = 0 RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id and e.is_delete = 0
) a ) a
GROUP BY GROUP BY
a.`name`, a.`name`,
a.position3d, a.position3d,
a.parent_id, a.parent_id,
a.id a.id
</select> </select>
<select id="getRiskSourcesFireEquipmentByType" resultMap="riskSourceMap"> <select id="getRiskSourcesFireEquipmentByType" resultMap="riskSourceMap">
SELECT SELECT
sum(a.cc) ccount, sum(a.cc) ccount,
a.`name`, a.`name`,
a.position3d, a.position3d,
a.parent_id, a.parent_id,
min(a.level) level, min(a.level) level,
a.id a.id
FROM FROM
( (
SELECT SELECT
IF (E.ID, 1, 0) cc, IF (E.ID, 1, 0) cc,
s.`name`, s.`name`,
s.position3d, s.position3d,
s.parent_id, s.parent_id,
s.risk_level_id level, s.risk_level_id level,
s.id s.id
FROM FROM
f_fire_equipment e f_fire_equipment e
RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id RIGHT JOIN f_risk_source s ON s.id = e.risk_source_id
where e.equip_classify in where e.equip_classify in
<foreach collection="type" open="(" separator="," close=")" item="classify"> <foreach collection="type" open="(" separator="," close=")" item="classify">
#{classify} #{classify}
</foreach> </foreach>
) a ) a
GROUP BY GROUP BY
a.`name`, a.`name`,
a.position3d, a.position3d,
a.parent_id, a.parent_id,
a.id a.id
</select> </select>
<select id="getRiskSourcePointCount" resultType="long"> <select id="getRiskSourcePointCount" resultType="long">
SELECT SELECT
count(DISTINCT(pp.id)) count(DISTINCT(pp.id))
FROM FROM
`f_risk_source_point_inputitem` rspi `f_risk_source_point_inputitem` rspi
LEFT JOIN p_point pp ON pp.id = rspi.point_id LEFT JOIN p_point pp ON pp.id = rspi.point_id
WHERE WHERE
1 = 1 1 = 1
AND rspi.risk_source_id = #{riskSourceId} AND rspi.risk_source_id = #{riskSourceId}
</select> </select>
<select id="getRiskSourcePoints" resultType="java.util.HashMap"> <select id="getRiskSourcePoints" resultType="java.util.HashMap">
SELECT SELECT
rspi.risk_source_id riskId, rspi.risk_source_id riskId,
pp.id pointId, pp.id pointId,
pp.point_no pointNo, pp.point_no pointNo,
pp.`name` pointName, pp.`name` pointName,
pp.charge_person_id userId, pp.charge_person_id userId,
pp.charge_dept_id deptId, pp.charge_dept_id deptId,
GROUP_CONCAT(pii.`name`) inputItems GROUP_CONCAT(pii.`name`) inputItems
FROM FROM
`f_risk_source_point_inputitem` rspi `f_risk_source_point_inputitem` rspi
LEFT JOIN p_point pp ON pp.id = rspi.point_id LEFT JOIN p_point pp ON pp.id = rspi.point_id
LEFT JOIN p_input_item pii ON pii.id = rspi.point_inputitem_id LEFT JOIN p_input_item pii ON pii.id = rspi.point_inputitem_id
WHERE pii.`name` is not NULL WHERE pii.`name` is not NULL
AND rspi.risk_source_id = #{riskSourceId} AND rspi.risk_source_id = #{riskSourceId}
GROUP BY riskId,pointId,pointNo,pointName,depName,username,telephone GROUP BY riskId,pointId,pointNo,pointName,depName,username,telephone
<choose> <choose>
<when test="pageSize==-1"></when> <when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when> <when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
</choose> </choose>
</select> </select>
<select id="queryByFireEqument" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource"> <select id="queryByFireEqument" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">
SELECT SELECT
* *
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
EXISTS ( EXISTS (
SELECT SELECT
1 1
FROM FROM
f_risk_source_equipment se f_risk_source_equipment se
WHERE WHERE
se.fire_equipment_id = ${fireEquipmentId} se.fire_equipment_id = ${fireEquipmentId}
AND se.risk_source_id = rs.id AND se.risk_source_id = rs.id
) )
</select> </select>
<select id="queryByPoint" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource"> <select id="queryByPoint" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">
SELECT SELECT
* *
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
id in ( id in (
SELECT SELECT
pi.risk_source_id pi.risk_source_id
FROM FROM
f_risk_source_point_inputitem pi f_risk_source_point_inputitem pi
WHERE WHERE
pi.point_id = ${pointId} pi.point_id = ${pointId}
AND rs.id = pi.risk_source_id AND rs.id = pi.risk_source_id
) )
</select> </select>
<select id="findRiskSourceDetatil" resultMap="riskSourceMap"> <select id="findRiskSourceDetatil" resultMap="riskSourceMap">
SELECT SELECT
rs.id, rs.id,
rs.`code`, rs.`code`,
rs.parent_id, rs.parent_id,
rs.`name`, rs.`name`,
rl.`name` as level, rl.`name` as level,
rs.risk_level_id, rs.risk_level_id,
rs.rpni, rs.rpni,
rs.rpn, rs.rpn,
rs.is_region, rs.is_region,
rs.floor3d, rs.floor3d,
rs.is_indoor, rs.is_indoor,
rs.position3d rs.position3d
FROM FROM
`f_risk_source` rs `f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
where rs.id = #{id} where rs.id = #{id}
</select> </select>
<select id="statistics3dCount" resultType="map"> <select id="statistics3dCount" resultType="map">
SELECT SELECT
( (
SELECT SELECT
f.rpn f.rpn
FROM FROM
f_risk_source f f_risk_source f
WHERE WHERE
f.parent_id = 0 f.parent_id = 0
) factoryRpn, ) factoryRpn,
( (
SELECT SELECT
CASE CASE
WHEN f.increment &gt; 0 THEN WHEN f.increment &gt; 0 THEN
'UP' 'UP'
WHEN f.increment = 0 THEN WHEN f.increment = 0 THEN
'NOCHANGE' 'NOCHANGE'
WHEN f.increment &lt; 0 THEN WHEN f.increment &lt; 0 THEN
'DOWN' 'DOWN'
END END
FROM FROM
f_risk_source f f_risk_source f
WHERE WHERE
f.parent_id = 0 f.parent_id = 0
) rpnUpOrDown, ) rpnUpOrDown,
( (
SELECT SELECT
count(1) count(1)
FROM FROM
f_equipment f_equipment
) equipmentCount, ) equipmentCount,
( (
SELECT SELECT
count(1) count(1)
FROM FROM
f_risk_source f_risk_source
) riskSourceCount, ) riskSourceCount,
(SELECT count(1) FROM p_point p) pointCount; (SELECT count(1) FROM p_point p) pointCount;
SELECT SELECT
f.rpn f.rpn
FROM FROM
f_risk_source f f_risk_source f
WHERE WHERE
f.parent_id = 0; f.parent_id = 0;
</select> </select>
<select id="statisticsEquipClassify" resultType="map"> <select id="statisticsEquipClassify" resultType="map">
SELECT SELECT
fe.equip_classify, fe.equip_classify,
count(1) classifyCount count(1) classifyCount
FROM FROM
f_fire_equipment fe f_fire_equipment fe
GROUP BY GROUP BY
fe.equip_classify fe.equip_classify
</select> </select>
<select id="statisticsRiskLevel" resultType="map"> <select id="statisticsRiskLevel" resultType="map">
SELECT SELECT
IFNULL(d.riskLevel,'') riskLevel, IFNULL(d.riskLevel,'') riskLevel,
IFNULL(count(1),0) levelRiskCount IFNULL(count(1),0) levelRiskCount
FROM FROM
( (
SELECT SELECT
rs.id, rs.id,
( (
SELECT SELECT
fl.`level` fl.`level`
FROM FROM
f_risk_level fl f_risk_level fl
WHERE WHERE
fl.id = rs.risk_level_id fl.id = rs.risk_level_id
) riskLevel ) riskLevel
FROM FROM
f_risk_source rs f_risk_source rs
) d ) d
GROUP BY GROUP BY
d.riskLevel; d.riskLevel;
</select> </select>
<select id="statisticsPointStatus" resultType="map"> <select id="statisticsPointStatus" resultType="map">
SELECT SELECT
sum( sum(
CASE CASE
WHEN p.`status` = 1 THEN WHEN p.`status` = 1 THEN
1 1
ELSE ELSE
0 0
END END
) qualifiedCount, ) qualifiedCount,
sum( sum(
CASE CASE
WHEN p.`status` = 2 THEN WHEN p.`status` = 2 THEN
1 1
ELSE ELSE
0 0
END END
) unqualifiedCount, ) unqualifiedCount,
sum( sum(
CASE CASE
WHEN p.`status` = 3 THEN WHEN p.`status` = 3 THEN
1 1
ELSE ELSE
0 0
END END
) omitCount ) omitCount
FROM FROM
p_point p; p_point p;
</select> </select>
<select id="queryForRiskSourceLevel" resultType="map"> <select id="queryForRiskSourceLevel" resultType="map">
SELECT SELECT
rs.`code`, rs.`code`,
rs.`name`, rs.`name`,
(select rl.`name` from f_risk_level rl where rl.id = rs.risk_level_id)level (select rl.`name` from f_risk_level rl where rl.id = rs.risk_level_id)level
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
rs.id = ${riskSourceId}; rs.id = ${riskSourceId};
</select> </select>
<select id="queryForRiskSourceRpni" resultType="map"> <select id="queryForRiskSourceRpni" resultType="map">
SELECT SELECT
rs.`rpni` rpni rs.`rpni` rpni
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
rs.parent_id = ${parentId}; rs.parent_id = ${parentId};
</select> </select>
<select id="queryForUnqualified" resultType="map"> <select id="queryForUnqualified" resultType="map">
SELECT SELECT
( (
SELECT SELECT
i.`name` i.`name`
FROM FROM
p_input_item i p_input_item i
WHERE WHERE
i.id = ppi.input_item_id i.id = ppi.input_item_id
) inputItemName, ) inputItemName,
( (
SELECT SELECT
p.`name` p.`name`
FROM FROM
p_point p p_point p
WHERE WHERE
p.id = ppi.point_id p.id = ppi.point_id
) pointName ) pointName
FROM FROM
f_fmea_point_inputitem pi f_fmea_point_inputitem pi
LEFT JOIN p_point_inputitem ppi ON ppi.id = pi.point_inputitem_id LEFT JOIN p_point_inputitem ppi ON ppi.id = pi.point_inputitem_id
LEFT JOIN f_fmea fm ON fm.id = pi.fmea_id LEFT JOIN f_fmea fm ON fm.id = pi.fmea_id
WHERE WHERE
pi.`state` = 1 pi.`state` = 1
AND fm.risk_source_id = #{riskSourceId}; AND fm.risk_source_id = #{riskSourceId};
</select> </select>
<select id="queryForFmeaEquipAlarm" resultType="map"> <select id="queryForFmeaEquipAlarm" resultType="map">
SELECT SELECT
ed.`name` as 'fireEquipmentName', ed.`name` as 'fireEquipmentName',
ei.`name` as 'name' ei.`name` as 'name'
FROM FROM
`f_fmea_equipment_point` AS fmep `f_fmea_equipment_point` AS fmep
LEFT JOIN wl_equipment_specific_index fep ON fep.id = fmep.equipment_point_id LEFT JOIN wl_equipment_specific_index fep ON fep.id = fmep.equipment_point_id
LEFT JOIN wl_equipment_index ei ON ei.id = fep.equipment_index_id LEFT JOIN wl_equipment_index ei ON ei.id = fep.equipment_index_id
LEFT JOIN wl_equipment_specific fe ON fe.id = fep.equipment_specific_id LEFT JOIN wl_equipment_specific fe ON fe.id = fep.equipment_specific_id
LEFT JOIN wl_equipment_detail ed ON ed.id = fe.equipment_detail_id LEFT JOIN wl_equipment_detail ed ON ed.id = fe.equipment_detail_id
LEFT JOIN f_fmea fm ON fm.id = fmep.fmea_id LEFT JOIN f_fmea fm ON fm.id = fmep.fmea_id
WHERE WHERE
fmep.state = 1 fmep.state = 1
AND fm.risk_source_id = #{riskSourceId} AND fm.risk_source_id = #{riskSourceId}
GROUP BY fireEquipmentName,name GROUP BY fireEquipmentName,name
</select> </select>
<select id="queryRiskAreaRpn" resultType="java.util.HashMap"> <select id="queryRiskAreaRpn" resultType="java.util.HashMap">
SELECT SELECT
rs.id, rs.id,
rs.name, rs.name,
rs.rpn, rs.rpn,
rs.rpni, rs.rpni,
rs.risk_level_id as riskLevelId, rs.risk_level_id as riskLevelId,
rl.`name` as riskLevelName, rl.`name` as riskLevelName,
rl.level, rl.level,
rl.color rl.color
FROM FROM
f_risk_source rs f_risk_source rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
WHERE rs.parent_id &gt; 0 WHERE rs.parent_id &gt; 0
order by rs.sort_num,rs.id order by rs.sort_num,rs.id
</select> </select>
<select id="queryByFactor" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource"> <select id="queryByFactor" resultType="com.yeejoin.amos.fas.dao.entity.RiskSource">
SELECT SELECT
* *
FROM FROM
f_risk_source rs f_risk_source rs
WHERE WHERE
rs.id IN ( rs.id IN (
SELECT SELECT
ff.risk_source_id ff.risk_source_id
FROM FROM
f_fmea ff f_fmea ff
JOIN f_risk_factor rf ON ff.risk_factors_id = rf.id JOIN f_risk_factor rf ON ff.risk_factors_id = rf.id
WHERE WHERE
rf.id = ${factorId} rf.id = ${factorId}
) )
</select> </select>
<select id="queryRiskSourceSecondLevel" resultType="java.util.HashMap"> <select id="queryRiskSourceSecondLevel" resultType="java.util.HashMap">
SELECT SELECT
rs.id, rs.id,
rs.`code`, rs.`code`,
rs.`name`, rs.`name`,
rl.`level`, rl.`level`,
rs.rpn rs.rpn
FROM FROM
`f_risk_source` rs `f_risk_source` rs
LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id LEFT JOIN f_risk_level rl ON rl.id = rs.risk_level_id
WHERE WHERE
rs.parent_id = ( rs.parent_id = (
SELECT SELECT
id id
FROM FROM
f_risk_source f_risk_source
WHERE WHERE
parent_id = 0 and org_code = #{compCode} parent_id = 0 and org_code = #{compCode}
) )
ORDER BY sort_num,id ORDER BY sort_num,id
</select> </select>
<select id="queryContingencyWater" resultType="java.util.HashMap"> <select id="queryContingencyWater" resultType="java.util.HashMap">
<!-- SELECT <!-- SELECT
wr.alarm_level, wr.alarm_level,
wr.max_level, wr.max_level,
wr.area, wr.area,
ep.CODE, ep.CODE,
wr.`name`, wr.`name`,
ep.value ep.value
FROM FROM
f_fire_equipment_point ep f_fire_equipment_point ep
INNER JOIN f_water_resource_equipment wre ON wre.fire_equipment_id = ep.fire_equipment_id AND ep.type = 'ANALOGUE' INNER JOIN f_water_resource_equipment wre ON wre.fire_equipment_id = ep.fire_equipment_id AND ep.type = 'ANALOGUE'
RIGHT JOIN f_water_resource wr ON wr.id = wre.water_resource_id RIGHT JOIN f_water_resource wr ON wr.id = wre.water_resource_id
LEFT JOIN f_dict d ON d.id = ep.alarm_type AND d.dict_value = 'analogue_water_level' LEFT JOIN f_dict d ON d.id = ep.alarm_type AND d.dict_value = 'analogue_water_level'
WHERE wr.type = 2 WHERE wr.type = 2
GROUP BY GROUP BY
wr.alarm_level, wr.alarm_level,
wr.max_level, wr.max_level,
wr.area, wr.area,
wr.`name` --> wr.`name` -->
</select> </select>
<select id="queryFmeaByPointId" resultType="java.util.HashMap"> <select id="queryFmeaByPointId" resultType="java.util.HashMap">
SELECT SELECT
frf.`name` riskFactors, frf.`name` riskFactors,
fem1.influence level, fem1.influence level,
fem2.influence faultFrequency, fem2.influence faultFrequency,
fem3.influence detectivity, fem3.influence detectivity,
ff.engineering, ff.engineering,
ff.management, ff.management,
ff.train, ff.train,
ff.protection, ff.protection,
ff.disposal ff.disposal
FROM FROM
f_fmea ff f_fmea ff
LEFT JOIN f_risk_source frs ON frs.id = ff.risk_source_id LEFT JOIN f_risk_source frs ON frs.id = ff.risk_source_id
LEFT JOIN f_risk_factor frf ON frf.id = ff.risk_factors_id LEFT JOIN f_risk_factor frf ON frf.id = ff.risk_factors_id
LEFT JOIN f_evaluation_model fem1 ON fem1.id = ff.evaluation_sid LEFT JOIN f_evaluation_model fem1 ON fem1.id = ff.evaluation_sid
LEFT JOIN f_evaluation_model fem2 ON fem2.id = ff.evaluation_oid LEFT JOIN f_evaluation_model fem2 ON fem2.id = ff.evaluation_oid
LEFT JOIN f_evaluation_model fem3 ON fem3.id = ff.evaluation_did LEFT JOIN f_evaluation_model fem3 ON fem3.id = ff.evaluation_did
WHERE WHERE
EXISTS ( SELECT 1 FROM f_risk_source_point_inputitem frspi WHERE frspi.risk_source_id = frs.id AND frspi.point_id = ${pointId} ) EXISTS ( SELECT 1 FROM f_risk_source_point_inputitem frspi WHERE frspi.risk_source_id = frs.id AND frspi.point_id = ${pointId} )
</select> </select>
<select id="countByParentIdAndIsRegion" resultType="long"> <select id="countByParentIdAndIsRegion" resultType="long">
select select
count(1) count(1)
from from
f_risk_source f_risk_source
where where
is_region = #{isRegion} is_region = #{isRegion}
and and
parent_id = #{riskSourceId} parent_id = #{riskSourceId}
</select> </select>
<update id="updateRpn"> <update id="updateRpn">
update f_risk_source update f_risk_source
<set> <set>
<if test="rpn != null"> <if test="rpn != null">
rpn = #{rpn}, rpn = #{rpn},
</if> </if>
<if test="rpni != null"> <if test="rpni != null">
rpni = #{rpni}, rpni = #{rpni},
</if> </if>
<if test="riskLevelId != null"> <if test="riskLevelId != null">
risk_level_id = #{riskLevelId}, risk_level_id = #{riskLevelId},
</if> </if>
<if test="flickerFrequency != null"> <if test="flickerFrequency != null">
flicker_frequency = #{flickerFrequency} flicker_frequency = #{flickerFrequency}
</if> </if>
</set> </set>
where id = #{id} where id = #{id}
</update> </update>
<select id="getRegionList" parameterType="string" resultType="com.yeejoin.amos.fas.core.common.response.RegionTreeResponse"> <select id="getRegionList" parameterType="string" resultType="com.yeejoin.amos.fas.core.common.response.RegionTreeResponse">
select select
rs.id,rs.name,rs.code,rs.parent_id,rs.ue4_location,rs.ue4_rotation,rs.ue4_extent, rs.id,rs.name,rs.code,rs.parent_id,rs.ue4_location,rs.ue4_rotation,rs.ue4_extent,
<choose> <choose>
<when test="channelType == '3dpage'"> <when test="channelType == '3dpage'">
IF(ISNULL(rs.route_path) || LENGTH(trim(rs.route_path)) <![CDATA[ <]]> 1,0,1) as is_bind, IF(ISNULL(rs.route_path) || LENGTH(trim(rs.route_path)) <![CDATA[ <]]> 1,0,1) as is_bind,
</when> </when>
<otherwise> <otherwise>
IF(ISNULL(IF(replace(trim(rs.ue4_rotation),'[]','')='',NULL,rs.ue4_rotation)) IF(ISNULL(IF(replace(trim(rs.ue4_rotation),'[]','')='',NULL,rs.ue4_rotation))
AND ISNULL(IF(replace(trim(rs.ue4_location),'[]','')='',NULL,rs.ue4_location)),0,1) as is_bind, AND ISNULL(IF(replace(trim(rs.ue4_location),'[]','')='',NULL,rs.ue4_location)),0,1) as is_bind,
</otherwise> </otherwise>
</choose> </choose>
IF(rs.is_region = 'TRUE',1,0) as is_region, IF(rs.is_region = 'TRUE',1,0) as is_region,
rs.route_path, rs.route_path,
rl.level, rl.level,
CONCAT('level_',rl.level) as level_str, CONCAT('level_',rl.level) as level_str,
'riskSource' as type 'riskSource' as type
from f_risk_source rs from f_risk_source rs
left join f_risk_level rl ON rs.risk_level_id = rl.id left join f_risk_level rl ON rs.risk_level_id = rl.id
where is_region = 'TRUE' AND (rs.org_code = #{orgCode} OR rs.org_code like CONCAT(#{orgCode},'-%')) where is_region = 'TRUE' AND (rs.org_code = #{orgCode} OR rs.org_code like CONCAT(#{orgCode},'-%'))
</select> </select>
<select id="findRegionById" resultType="java.util.HashMap"> <select id="findRegionById" resultType="java.util.HashMap">
select select
id,name,code,parent_id as parentId,ue4_location as ue4Location,ue4_rotation as ue4Rotation,ue4_extent as ue4Extent,route_path as routePath, id,name,code,parent_id as parentId,ue4_location as ue4Location,ue4_rotation as ue4Rotation,ue4_extent as ue4Extent,route_path as routePath,
<choose> <choose>
<when test="channelType == '3dpage'"> <when test="channelType == '3dpage'">
IF(ISNULL(route_path) || LENGTH(trim(route_path)) <![CDATA[ <]]> 1,0,1) as isBind, IF(ISNULL(route_path) || LENGTH(trim(route_path)) <![CDATA[ <]]> 1,0,1) as isBind,
</when> </when>
<otherwise> <otherwise>
IF(ISNULL(IF(replace(trim(ue4_rotation),'[]','')='',NULL,ue4_rotation)) IF(ISNULL(IF(replace(trim(ue4_rotation),'[]','')='',NULL,ue4_rotation))
AND ISNULL(IF(replace(trim(ue4_location),'[]','')='',NULL,ue4_location)),0,1) as isBind, AND ISNULL(IF(replace(trim(ue4_location),'[]','')='',NULL,ue4_location)),0,1) as isBind,
</otherwise> </otherwise>
</choose> </choose>
IF(is_region = 'TRUE',1,0) as isRegion, IF(is_region = 'TRUE',1,0) as isRegion,
(select name from f_risk_level where level = r.risk_level_id) as riskLevel (select name from f_risk_level where level = r.risk_level_id) as riskLevel
from f_risk_source r from f_risk_source r
where id=#{id} AND (org_code = #{orgCode} OR org_code like CONCAT(#{orgCode},'-%')) where id=#{id} AND (org_code = #{orgCode} OR org_code like CONCAT(#{orgCode},'-%'))
</select> </select>
<update id="batchSaveRegionUe4" parameterType="java.util.List"> <update id="batchSaveRegionUe4" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";"> <foreach collection="list" item="item" index="index" open="" close="" separator=";">
update f_risk_source update f_risk_source
<set > <set >
<if test="item.ue4Location != null" > <if test="item.ue4Location != null" >
ue4_location = #{item.ue4Location,jdbcType=VARCHAR}, ue4_location = #{item.ue4Location,jdbcType=VARCHAR},
</if> </if>
<if test="item.ue4Rotation != null" > <if test="item.ue4Rotation != null" >
ue4_rotation = #{item.ue4Rotation,jdbcType=VARCHAR}, ue4_rotation = #{item.ue4Rotation,jdbcType=VARCHAR},
</if> </if>
<if test="item.ue4Extent != null" > <if test="item.ue4Extent != null" >
ue4_extent = #{item.ue4Extent,jdbcType=VARCHAR}, ue4_extent = #{item.ue4Extent,jdbcType=VARCHAR},
</if> </if>
<if test="item.routePath != null" > <if test="item.routePath != null" >
route_path = #{item.routePath,jdbcType=VARCHAR}, route_path = #{item.routePath,jdbcType=VARCHAR},
</if> </if>
</set> </set>
where id = #{item.riskSourceId,jdbcType=BIGINT} where id = #{item.riskSourceId,jdbcType=BIGINT}
</foreach> </foreach>
</update> </update>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment