Commit b27b1f36 authored by KeYong's avatar KeYong

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

# Conflicts: # YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
parents d7de83d4 6c3f38a9
package com.yeejoin.amos.fas.common.enums;
/**
* @ProjectName: YeeFireDataProcessRoot
* @Package: com.yeejoin.dataprocess.common.enums
* @ClassName: TopicName
* @Author: Jianqiang Gao
* @Description: TopicName
* @Date: 2021/3/23 15:55
* @Version: 1.0
*/
public enum AstDataSyncTopic {
AST_REGION_SAVE(10, "ast_save"),
AST_REGION_SAVE_ALL(11, "ast_save_all"),
AST_REGION_DELETE_BY_ID(12, "ast_delete_by_id");
private final Integer key;
private final String value;
private AstDataSyncTopic(Integer key, String value) {
this.key = key;
this.value = value;
}
public Integer getKey() {
return key;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return this.value;
}
}
\ No newline at end of file
......@@ -7,8 +7,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
......@@ -22,7 +24,7 @@ import java.util.List;
@Accessors(chain = true)
@TableName("wl_equipment_category")
@ApiModel(value="EquipmentCategory装备分类实体", description="装备分类")
public class EquipmentCategory extends BaseEntity {
public class EquipmentCategory extends BaseEntity implements TreeNode<EquipmentCategory, Long> {
private static final long serialVersionUID = 1L;
......@@ -56,5 +58,24 @@ public class EquipmentCategory extends BaseEntity {
@TableField(exist=false)
private List<EquipmentCategory> children = new ArrayList<>(); //子集
@Override
public Long getMyParentId() {
return parentId;
}
@Override
public Long getMyId() {
return getId();
}
@Override
public void setChildren(Collection<EquipmentCategory> collection) {
this.children = new ArrayList<>(collection);
}
@Override
public int compareTo(EquipmentCategory o) {
return this.getId().compareTo(o.getId());
}
}
package com.yeejoin.amos.fas.dao.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
@Data
public class EquipmentExcelData {
@Excel(name = "设备编号", orderNum = "1", width = 36)
private String equipCode;
@Excel(name = "设备名称", orderNum = "2", width = 24)
private String equipName;
@Excel(name = "所属区域", orderNum = "3", width = 24)
private String areaCode;
@Excel(name = "位置", orderNum = "4", width = 50)
private String position;
}
\ No newline at end of file
......@@ -102,21 +102,6 @@
</exclusion>
</exclusions>
</dependency> -->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
......
package com.yeejoin.amos.fas.business.action;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
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.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo;
import com.yeejoin.amos.fas.business.action.model.SetpEnum;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
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.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import com.yeejoin.amos.fas.business.feign.IDutyModeServer;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
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.ToipResponse;
import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
//import com.yeejoin.amos.fas.business.service.intfc.FireStengthService;
@Component
@RuleActionBean(beanLabel = "动态预案" )
public class ContingencyAction implements CustomerAction {
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
public static final Logger log = LoggerFactory.getLogger(ContingencyAction.class);
@Autowired
private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}")
private String pushType;
@Value("${spring.application.name}")
private String serviceName;
@Value("${station.name}")
private String stationName;
@Autowired
private IContingencyInstance iContingencyInstance;
// @Autowired
// private FireStengthService fireStrengthService;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher;
@Autowired
private IRiskSourceService riskSourceService;
@Autowired
private IDutyModeServer dutyModeServer;
@Autowired
private IEquipmentService equipmentService;
@Autowired
private RedisTemplate redisTemplate;
private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>();
private static Map<String, Map<String, String>> stringStringMap = new HashMap<>();
static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>();
private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE";
@Autowired
private RemoteSecurityService remoteSecurityService;
@Autowired
private IPlanDetailDao planDetailDao;
@Autowired
private IPlanOperationRecordDao planOperationRecordDao;
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{
put("S1", "S1");
put("S2", "S2");
put("A1", "A1");
put("A2", "A2");
put("A3", "A3");
put("F1", "F1");
}};
*/
/**
* 预案文件中值为和数据字典中的对应关系
* 消防
* F1 消防队长 fireLeader
* F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
* FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6
* 运维
* S1 值班长 dutyLeader
* S2 副值班长 deputyDutyLeader
* B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6
* A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
*/
public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) {
String batchNo = contingencyRo.getBatchNo();
String orgCode = contingencyRo.getEquipmentOrgCode();
Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo());
if (CollectionUtils.isEmpty(returnMap)) {
stringStringMap = new HashMap<>();
returnMap = new HashMap<>();
Date curDate = new Date();
JSONObject param = new JSONObject();
param.put("dutyDate", curDate);
Toke toke = remoteSecurityService.getServerToken();
CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString());
// String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result);
// JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString());
String JSONStr = JSON.toJSONString(commonResponse.getDataList());
JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList));
if (!ObjectUtils.isEmpty(dataList)) {
Map<String, String> finalReturnMap = returnMap;
dataList.forEach(
x -> {
JSONObject obj = (JSONObject) x;
String name = obj.getString("position");
finalReturnMap.put(name, obj.getString("dutyName"));
}
);
}
stringStringMap.put(batchNo, returnMap);
}
log.info(String.format("returnMap:【 %s 】", returnMap));
return returnMap;
}
/**
* @param stepCode 当前步骤编号
* @param stepName 当前步骤名称
* @param nextStepCode 下一步编号
* @param nextStepName 下一步名称
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新(新)", project = "换流站消防专项预案")
public void stepInfoNew(@MethodParam(paramLabel = "当前步骤编号") String stepCode,
@MethodParam(paramLabel = "当前步骤名称") String stepName,
@MethodParam(paramLabel = "下一步编号") String nextStepCode,
@MethodParam(paramLabel = "下一步名称") String nextStepName,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ArrayList list = new ArrayList();
HashMap step = new HashMap();
step.put("stepCode", stepCode);
step.put("stepName", stepName);
HashMap nextmap = new HashMap();
nextmap.put("stepCode", nextStepCode);
nextmap.put("stepName", nextStepName);
list.add(step);
list.add(nextmap);
tempmap1.put("step", list);
tempmap1.put("preStep", new HashMap());
result.add(tempmap1);
log.info("步骤更新(new)" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
}
/**
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案")
public void stepInfo(@MethodParam(paramLabel = "当前编号") String stepCode,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
// Map<String, Object> tempmap1 = new HashMap<>();
// SetpEnum[] stepArr = SetpEnum.values();
// ArrayList list = new ArrayList();
// HashMap preStep = new HashMap();
// StepComparator comparator = new StepComparator();
// Arrays.sort(stepArr, comparator);
//
// boolean flage = false;
// SetpEnum pstep = null;
// for (SetpEnum step : stepArr) {
// if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode)) {
// if (!ObjectUtils.isEmpty(pstep)) {
// preStep.put("stepCode", pstep.getValue());
// preStep.put("stepName", pstep.getTitle());
// }
// flage = true;
// }
// if (flage) {
// HashMap map = new HashMap();
// map.put("stepCode", step.getValue());
// map.put("stepName", step.getTitle());
// list.add(map);
// }
// pstep = step;
// }
//
// tempmap1.put("step", list);
// tempmap1.put("preStep", preStep);
// result.add(tempmap1);
// log.info("巡检消息发送规则" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
}
public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendweb(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"numberPlan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案")
public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
}
/**
* @param content 消息内容
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
map.put("time", sdf.format(action.getCreateDate()));
map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
tempmap1.put("status",PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------"+result);
this.sendcmd("recordarea", paramObj, result);
this.sendweb("recordarea", paramObj, result);
}
/**
* <pre>
* 智能辅助
* </pre>
*
* @param step 当前步骤
* @param icon 图标
* @param title 标题
* @param image 图片集合
* @param table 表格
* @param content 内容
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案")
public void help(@MethodParam(paramLabel = "当前步骤") String step,
@MethodParam(paramLabel = "图标")String icon,
@MethodParam(paramLabel = "标题")String title,
@MethodParam(paramLabel = "图片集") String image,
@MethodParam(paramLabel = "表格数据") String table,
@MethodParam(paramLabel = "文本内容") String content,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换智能辅助中的变量
content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("icon", icon);
tempmap1.put("step", step);
tempmap1.put("title", title);
tempmap1.put("content", content);
tempmap1.put("image", image);
tempmap1.put("table", table);
// tempmap1.put("batchNo", contingencyRo.getBatchNo());
// tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1);
this.sendcmd("helparea", paramObj, result);
}
private String instedParams(String content, ContingencyRo contingencyRo) {
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo);
for (String key : strengthMap.keySet())
content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
Field[] fields = contingencyRo.getClass().getDeclaredFields();
Method getMethod = null;
try {
for (Field field : fields) {
if (field.getName().equals("serialVersionUID"))
continue;
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
String value = String.valueOf(getMethod.invoke(contingencyRo));
content = content.replaceAll("\\$\\{" + field.getName() + "}", value);
}
content = getNative(content);
} catch (Exception e) {
e.printStackTrace();
}
return content;
}
public String getNative(String str)
{
Pattern p = Pattern.compile("\\$\\{(.*?)\\}");
Matcher m = p.matcher(str);
while (m.find())
{
String parameter = m.group();
Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1));
if(parametervalue != null)
str = str.replace(parameter,
parametervalue != null ? parametervalue.toString() : null);
}
return str;
}
/**
* 交互动作
*
* @param actionName 动作名称
* @param icon 图标
* @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
public void operation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
tips = instedParams(tips, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
tempmap1.put("actionName", actionName);
tempmap1.put("icon", icon);
tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
this.sendcmd("optionarea", paramObj, result);
}
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
ObjectMapper objectMapper = new ObjectMapper();
/**
* batchNo
* stepCode
* buttonCode
* confirm
* contingencyPlanId
* stepState
*/
try {
Map button = objectMapper.readValue(buttonJson, Map.class);
Map operateInstance = (Map) ((List) button.get("operate")).get(0);
ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus();
contingencyDeviceStatus.setActionName(actionName);
contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code")));
contingencyDeviceStatus.setConfirm("CONFIRM");
contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId);
contingencyDeviceStatus.setEquipmentId(equipmentId);
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
/**
* 保存交互动作
*
* @param actionName 动作名称
* @param icon 图标
* @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案")
public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
map.put("time", sdf.format(action.getCreateDate()));
map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.add(tempmap1);
System.out.println("--------------------saveOperation----------------------"+result);
this.sendcmd("recordarea", paramObj, result);
}
private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) {
String cacheKey = batchNo + actionName;
String contingencyPlanId = null;
ContingencyPlanInstance contingencyPlanInstance = null;
if (OPERATE_RECORD_ID.get(cacheKey) == null) {
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon);
contingencyPlanId = contingencyPlanInstance.getId();
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
} else {
contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey);
OPERATE_RECORD_ID.remove(cacheKey);
}
return contingencyPlanId;
}
/**
* 地图动作推送
*
* @param actionName 动作名称标识
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案")
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content",paramJSON);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
@RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案")
public void mapCartoonAction(
@MethodParam(paramLabel = "动作名称标识") String actionName,
@MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content",actionType);
tempmap1.put("parameter",parameter);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
/**
* 顶部消息提示
*
* @param content 消息内容
* @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案")
public void topMessage(
@MethodParam(paramLabel = "标题") String title,
@MethodParam(paramLabel = "内容") String content,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "类型") String messageType,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
//转换content中的变量
content = instedParams(content, contingencyRo);
tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title);
tempmap1.put("icon", icon);
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
/**
* 启动预案
*
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "启动预案", project = "换流站消防专项预案")
public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "startPlan");
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.opsForValue().set("contingencyRo", contingencyRo);
}
/**
* 启动预案
*
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "结束预案", project = "换流站消防专项预案")
public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan");
//数字预案结束状态
tempmap1.put("status",PlanRecordStatusEnum.COMPLETE.getCode());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo");
// 结束预案,更新设备重点设备参数
if (contingencyRo != null) {
Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
if (equipment != null) {
equipment.setEndTime(DateUtil.getDateNow());
equipment.setReserveSource(NumberEnum.ZERO.getValue());
equipment.setStatus(NumberEnum.ZERO.getValue());
equipmentService.save(equipment);
}
}
// 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo());
if(planOperationRecord!=null && planOperationRecord.getStatus()==PlanRecordStatusEnum.OPERATION.getCode()){
planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode());
planOperationRecord.setEndTime(new Date());
planOperationRecordDao.save(planOperationRecord);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
}
//数字预案业务屏web端发送消息
this.sendweb("recordarea", paramObj, result);
}
}
@RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案")
public void autoExecute(
@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "步骤状态") String stepState,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM");
iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState);
} catch (Exception e) {
e.printStackTrace();
}
}
@RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
public void addExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints = new HashMap<>();
}
equipemtnPoints.put(stepCode+"-"+buttonCode, content);
tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", ro, result);
}
@RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案")
public void clearExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints.remove(stepCode+"-"+buttonCode);
}
tempmap1.put("type", "buttonCache");
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
tempmap1.put("content", equipemtnPoints.values());
} else {
tempmap1.put("content", new ArrayList());
}
result.add(tempmap1);
this.sendcmd("message", ro, result);
}
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache");
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) {
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(deviceRo);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, deviceRo);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void stopSnapshop(ContingencyRo contingencyRo) {
if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo()))
RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull();
}
@Override
public void intreeuptPlan(String batchNo) {
ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
ArrayList records = new ArrayList<>();
HashMap map = new HashMap();
map.put("time", sdf.format(new Date()));
map.put("stepName","应急处置中断");
records.add(map);
tempmap1.put("content", records);
//数字预案结束状态
tempmap1.put("status",PlanRecordStatusEnum.INTERRUPT.getCode());
result.add(tempmap1);
//数字预案业务屏web端发送消息
this.sendweb("recordarea", contingencyRo, result);
updateNumberPlan(contingencyRo.getBatchNo());
}
/**
* 修改数字预案状态
* */
public void updateNumberPlan(String batchNo){
// 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if(planOperationRecord!=null){
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
planOperationRecord.setEndTime(new Date());
planOperationRecordDao.save(planOperationRecord);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
}
}
}
}
package com.yeejoin.amos.fas.business.action;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
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.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo;
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.SafteyPlanResult;
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.dao.repository.IPlanDetailDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import com.yeejoin.amos.fas.business.feign.IDutyModeServer;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
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.ToipResponse;
import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.yeejoin.amos.fas.business.util.CacheMap;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//import com.yeejoin.amos.fas.business.service.intfc.FireStengthService;
@Component
@RuleActionBean(beanLabel = "动态预案" )
public class ContingencyAction implements CustomerAction {
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
public static final Logger log = LoggerFactory.getLogger(ContingencyAction.class);
@Autowired
private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}")
private String pushType;
@Value("${spring.application.name}")
private String serviceName;
@Value("${station.name}")
private String stationName;
@Autowired
private IContingencyInstance iContingencyInstance;
// @Autowired
// private FireStengthService fireStrengthService;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher;
@Autowired
private IRiskSourceService riskSourceService;
@Autowired
private IDutyModeServer dutyModeServer;
@Autowired
private IEquipmentService equipmentService;
@Autowired
private RedisTemplate redisTemplate;
private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>();
private static Map<String, Map<String, String>> stringStringMap = new HashMap<>();
static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>();
private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE";
@Autowired
private RemoteSecurityService remoteSecurityService;
@Autowired
private IPlanDetailDao planDetailDao;
@Autowired
private IPlanOperationRecordDao planOperationRecordDao;
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{
put("S1", "S1");
put("S2", "S2");
put("A1", "A1");
put("A2", "A2");
put("A3", "A3");
put("F1", "F1");
}};
*/
/**
* 预案文件中值为和数据字典中的对应关系
* 消防
* F1 消防队长 fireLeader
* F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
* FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6
* 运维
* S1 值班长 dutyLeader
* S2 副值班长 deputyDutyLeader
* B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6
* A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
*/
public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) {
String batchNo = contingencyRo.getBatchNo();
String orgCode = contingencyRo.getEquipmentOrgCode();
Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo());
if (CollectionUtils.isEmpty(returnMap)) {
stringStringMap = new HashMap<>();
returnMap = new HashMap<>();
Date curDate = new Date();
JSONObject param = new JSONObject();
param.put("dutyDate", curDate);
Toke toke = remoteSecurityService.getServerToken();
CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString());
// String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result);
// JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString());
String JSONStr = JSON.toJSONString(commonResponse.getDataList());
JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList));
if (!ObjectUtils.isEmpty(dataList)) {
Map<String, String> finalReturnMap = returnMap;
dataList.forEach(
x -> {
JSONObject obj = (JSONObject) x;
String name = obj.getString("position");
finalReturnMap.put(name, obj.getString("dutyName"));
}
);
}
stringStringMap.put(batchNo, returnMap);
}
log.info(String.format("returnMap:【 %s 】", returnMap));
return returnMap;
}
/**
* @param stepCode 当前步骤编号
* @param stepName 当前步骤名称
* @param nextStepCode 下一步编号
* @param nextStepName 下一步名称
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新(新)", project = "换流站消防专项预案")
public void stepInfoNew(@MethodParam(paramLabel = "当前步骤编号") String stepCode,
@MethodParam(paramLabel = "当前步骤名称") String stepName,
@MethodParam(paramLabel = "下一步编号") String nextStepCode,
@MethodParam(paramLabel = "下一步名称") String nextStepName,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ArrayList list = new ArrayList();
HashMap step = new HashMap();
step.put("stepCode", stepCode);
step.put("stepName", stepName);
HashMap nextmap = new HashMap();
nextmap.put("stepCode", nextStepCode);
nextmap.put("stepName", nextStepName);
list.add(step);
list.add(nextmap);
tempmap1.put("step", list);
tempmap1.put("preStep", new HashMap());
result.add(tempmap1);
log.info("步骤更新(new)" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
}
/**
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案")
public void stepInfo(@MethodParam(paramLabel = "当前编号") String stepCode,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
// Map<String, Object> tempmap1 = new HashMap<>();
// SetpEnum[] stepArr = SetpEnum.values();
// ArrayList list = new ArrayList();
// HashMap preStep = new HashMap();
// StepComparator comparator = new StepComparator();
// Arrays.sort(stepArr, comparator);
//
// boolean flage = false;
// SetpEnum pstep = null;
// for (SetpEnum step : stepArr) {
// if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode)) {
// if (!ObjectUtils.isEmpty(pstep)) {
// preStep.put("stepCode", pstep.getValue());
// preStep.put("stepName", pstep.getTitle());
// }
// flage = true;
// }
// if (flage) {
// HashMap map = new HashMap();
// map.put("stepCode", step.getValue());
// map.put("stepName", step.getTitle());
// list.add(map);
// }
// pstep = step;
// }
//
// tempmap1.put("step", list);
// tempmap1.put("preStep", preStep);
// result.add(tempmap1);
// log.info("巡检消息发送规则" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
}
public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendweb(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"numberPlan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案")
public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
}
/**
* @param content 消息内容
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
tempmap1.put("status",PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------"+result);
this.sendcmd("recordarea", paramObj, result);
this.sendweb("recordarea", paramObj, result);
}
/**
* <pre>
* 智能辅助
* </pre>
*
* @param step 当前步骤
* @param icon 图标
* @param title 标题
* @param image 图片集合
* @param table 表格
* @param content 内容
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案")
public void help(@MethodParam(paramLabel = "当前步骤") String step,
@MethodParam(paramLabel = "图标")String icon,
@MethodParam(paramLabel = "标题")String title,
@MethodParam(paramLabel = "图片集") String image,
@MethodParam(paramLabel = "表格数据") String table,
@MethodParam(paramLabel = "文本内容") String content,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换智能辅助中的变量
content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("icon", icon);
tempmap1.put("step", step);
tempmap1.put("title", title);
tempmap1.put("content", content);
tempmap1.put("image", image);
tempmap1.put("table", table);
// tempmap1.put("batchNo", contingencyRo.getBatchNo());
// tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1);
this.sendcmd("helparea", paramObj, result);
}
private String instedParams(String content, ContingencyRo contingencyRo) {
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo);
for (String key : strengthMap.keySet())
content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
Field[] fields = contingencyRo.getClass().getDeclaredFields();
Method getMethod = null;
try {
for (Field field : fields) {
if (field.getName().equals("serialVersionUID"))
continue;
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
String value = String.valueOf(getMethod.invoke(contingencyRo));
content = content.replaceAll("\\$\\{" + field.getName() + "}", value);
}
content = getNative(content);
} catch (Exception e) {
e.printStackTrace();
}
return content;
}
public String getNative(String str)
{
Pattern p = Pattern.compile("\\$\\{(.*?)\\}");
Matcher m = p.matcher(str);
while (m.find())
{
String parameter = m.group();
Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1));
if(parametervalue != null)
str = str.replace(parameter,
parametervalue != null ? parametervalue.toString() : null);
}
return str;
}
/**
* 交互动作
*
* @param actionName 动作名称
* @param icon 图标
* @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
public void operation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
tips = instedParams(tips, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
tempmap1.put("actionName", actionName);
tempmap1.put("icon", icon);
tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
this.sendcmd("optionarea", paramObj, result);
}
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
ObjectMapper objectMapper = new ObjectMapper();
/**
* batchNo
* stepCode
* buttonCode
* confirm
* contingencyPlanId
* stepState
*/
try {
Map button = objectMapper.readValue(buttonJson, Map.class);
Map operateInstance = (Map) ((List) button.get("operate")).get(0);
ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus();
contingencyDeviceStatus.setActionName(actionName);
contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code")));
contingencyDeviceStatus.setConfirm("CONFIRM");
contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId);
contingencyDeviceStatus.setEquipmentId(equipmentId);
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
/**
* 保存交互动作
*
* @param actionName 动作名称
* @param icon 图标
* @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案")
public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
// map.put("time", sdf.format(action.getCreateDate()));
map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.add(tempmap1);
System.out.println("--------------------saveOperation----------------------"+result);
this.sendcmd("recordarea", paramObj, result);
}
private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) {
String cacheKey = batchNo + actionName;
String contingencyPlanId = null;
ContingencyPlanInstance contingencyPlanInstance = null;
if (OPERATE_RECORD_ID.get(cacheKey) == null) {
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon);
contingencyPlanId = contingencyPlanInstance.getId();
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
} else {
contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey);
OPERATE_RECORD_ID.remove(cacheKey);
}
return contingencyPlanId;
}
/**
* 地图动作推送
*
* @param actionName 动作名称标识
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案")
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content",paramJSON);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
@RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案")
public void mapCartoonAction(
@MethodParam(paramLabel = "动作名称标识") String actionName,
@MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content",actionType);
tempmap1.put("parameter",parameter);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
/**
* 顶部消息提示
*
* @param content 消息内容
* @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案")
public void topMessage(
@MethodParam(paramLabel = "标题") String title,
@MethodParam(paramLabel = "内容") String content,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "类型") String messageType,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
//转换content中的变量
content = instedParams(content, contingencyRo);
tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title);
tempmap1.put("icon", icon);
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
/**
* 启动预案
*
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "启动预案", project = "换流站消防专项预案")
public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "startPlan");
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.opsForValue().set("contingencyRo", contingencyRo);
}
/**
* 启动预案
*
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "结束预案", project = "换流站消防专项预案")
public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan");
//数字预案结束状态
tempmap1.put("status",PlanRecordStatusEnum.COMPLETE.getCode());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo");
// 结束预案,更新设备重点设备参数
if (contingencyRo != null) {
Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
if (equipment != null) {
equipment.setEndTime(DateUtil.getDateNow());
equipment.setReserveSource(NumberEnum.ZERO.getValue());
equipment.setStatus(NumberEnum.ZERO.getValue());
equipmentService.save(equipment);
}
}
// 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo());
if(planOperationRecord!=null && planOperationRecord.getStatus()==PlanRecordStatusEnum.OPERATION.getCode()){
planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode());
planOperationRecord.setEndTime(new Date());
planOperationRecordDao.save(planOperationRecord);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
}
//数字预案业务屏web端发送消息
this.sendweb("recordarea", paramObj, result);
}
}
@RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案")
public void autoExecute(
@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "步骤状态") String stepState,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM");
iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState);
} catch (Exception e) {
e.printStackTrace();
}
}
@RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
public void addExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints = new HashMap<>();
}
equipemtnPoints.put(stepCode+"-"+buttonCode, content);
tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", ro, result);
}
@RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案")
public void clearExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo)paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints.remove(stepCode+"-"+buttonCode);
}
tempmap1.put("type", "buttonCache");
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
tempmap1.put("content", equipemtnPoints.values());
} else {
tempmap1.put("content", new ArrayList());
}
result.add(tempmap1);
this.sendcmd("message", ro, result);
}
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache");
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) {
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(deviceRo);
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, deviceRo);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void stopSnapshop(ContingencyRo contingencyRo) {
if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo()))
RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull();
}
@Override
public void intreeuptPlan(String batchNo) {
ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
ArrayList records = new ArrayList<>();
HashMap map = new HashMap();
map.put("time", sdf.format(new Date()));
map.put("stepName","应急处置中断");
records.add(map);
tempmap1.put("content", records);
//数字预案结束状态
tempmap1.put("status",PlanRecordStatusEnum.INTERRUPT.getCode());
result.add(tempmap1);
//数字预案业务屏web端发送消息
this.sendweb("recordarea", contingencyRo, result);
updateNumberPlan(contingencyRo.getBatchNo());
}
/**
* 修改数字预案状态
* */
public void updateNumberPlan(String batchNo){
// 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if(planOperationRecord!=null){
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
planOperationRecord.setEndTime(new Date());
planOperationRecordDao.save(planOperationRecord);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
}
}
}
}
......@@ -16,7 +16,7 @@ public class ContingencyRo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1863437780244849215L;
private static final long serialVersionUID = -6721135143373410586L;
@Label("消防设备名称")
private String fireEquipmentName;//消防设备名称
@Label("消防设备id")
......
package com.yeejoin.amos.fas.business.controller;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import com.yeejoin.amos.fas.business.util.ExcelUtils;
import com.yeejoin.amos.fas.core.util.*;
import com.yeejoin.amos.fas.dao.entity.EquipmentExcelData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.CollectionUtils;
......@@ -31,6 +34,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(value = "/api/impEquip")
@Api(tags = "重点设备api")
......@@ -319,4 +324,29 @@ public class EquipmentController extends BaseController {
return CommonResponseUtil.success(iEquipService.findFireEquipDataByPointCode(code));
}
/**
* 模板下载
*
* @return
*/
@Permission
@RequestMapping(value = "/downTemplate")
@ApiOperation(httpMethod = "GET", value = "下载模板", notes = "下载模板")
public void downTemplate(HttpServletResponse response) {
ExcelUtils.exportExcel(new ArrayList<EquipmentExcelData>(), "电力设备信息", "导入模板", EquipmentExcelData.class, "电力设备模板.xls", response);
}
/**
* 电力设备信息导入
*
* @return
*/
@RequestMapping(value = "/uploadList")
@ApiOperation(httpMethod = "POST", value = "导入", notes = "导入")
public Object uploadList(MultipartFile file) {
List<EquipmentExcelData> list = ExcelUtils.importExcel(file, 1, 1, EquipmentExcelData.class);
iEquipService.uploadList(list, getOrgCode(getSelectedOrgInfo()));
return CommonResponseUtil.success();
}
}
......@@ -88,7 +88,19 @@ public class EquipmentSpecificController extends BaseController{
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpe(name, code, pageNumber, pageSize,equipmentId));
}
@GetMapping(value = "/getEquipmentBySpeV2")
@ApiOperation(httpMethod = "GET", value = "获取装备台账信息", notes = "获取装备台账信息")
public CommonResponse getEquipmentBySpeV2(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "pageNumber",required = false) int pageNumber,
@RequestParam(value = "pageSize",required = false) int pageSize,
@RequestParam(value = "equipmentId",required = false) String equipmentId ) {
Long aLong = null;
if (!"null".equals(equipmentId) && equipmentId != null && !"".equals(equipmentId.trim())){
aLong = Long.valueOf(equipmentId);
}
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpeV2(name, pageNumber, pageSize,aLong));
}
@GetMapping(value = "/list-tree", produces = "application/json;charset=UTF-8")
@ApiOperation(httpMethod = "GET", value = "全量数据树形结构返回", notes = "全量数据树形结构返回")
......
package com.yeejoin.amos.fas.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.feign.OutTokenLoginFeign;
import com.yeejoin.amos.fas.business.feign.PrivilegeFeign;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.vo.CompanyBo;
import com.yeejoin.amos.fas.business.vo.DepartmentBo;
import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.business.vo.RoleBo;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author zjw
* @date 2020-03-30
*/
@RestController
@RequestMapping(value = "/api/loginBytoken")
@Api(tags = "外部token登录Api")
public class TokenLoginController {
private static final Logger logger = LoggerFactory.getLogger(TokenLoginController.class);
@Autowired
private OutTokenLoginFeign outTokenLoginFeign;
@Autowired
private PrivilegeFeign privilegeFeign;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Autowired
private RemoteSecurityService remoteSecurityService;
@Value("${outSystem.user.password}")
private String password;
@Value("${security.productWeb}")
private String product;
@Value("${security.appKeyWeb}")
private String appKey;
@ApiOperation(value = "外部token登錄", notes = "查询设备指标")
@GetMapping(value = "/{token}")
synchronized public ReginParams getBindEquipment(@PathVariable("token") String outToken) throws Exception {
if ( ObjectUtils.isEmpty(outToken)) {
throw new Exception("token异常");
}
String userId = "wk";
// String userId = outTokenLoginFeign.getUserName(outToken);
if (ObjectUtils.isEmpty(userId)){
throw new Exception("用户信息不存在");
}
ReginParams reginParams;
reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId, outToken)), ReginParams.class);
if(reginParams == null){
reginParams = new ReginParams();
Map<String, String> param = new HashMap<>();
param.put("loginId",userId);
param.put("password",password);
Object result = privilegeFeign.login(appKey, product, outToken, param).getResult();
if (ObjectUtils.isEmpty(result)){
throw new Exception("缺失登录信息");
}
Map<String ,String > re = (Map<String ,String >) result;
String token = re.get("token");
privilegeFeign.warrant(appKey,product,token);
RequestContext.setToken(token);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel userModel = (AgencyUserModel) Privilege.agencyUserClient.getme().getResult();
CompanyModel companyModel = userModel.getCompanys().get(0);
List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(token, product, appKey, companyModel.getSequenceNbr().toString());
if(deptList.size() > 0){
CompanyBo companyBo = convertCompanyModelToBo(companyModel);
DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
reginParams.setDepartment(departmentBo);
reginParams.setCompany(companyBo);
}
reginParams.setToken(token);
reginParams.setUserModel(userModel);
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(reginParams));
redisTemplate.opsForValue().set(buildKey(userId, outToken), JSONObject.toJSONString(reginParams));
}
return reginParams;
}
private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel){
DepartmentBo departmentBo = new DepartmentBo();
if(departmentModel != null) {
departmentBo.setCompanySeq(departmentModel.getCompanySeq().toString());
departmentBo.setDepartmentDesc(departmentModel.getDepartmentDesc());
departmentBo.setDepartmentName(departmentModel.getDepartmentName());
departmentBo.setLevel(departmentModel.getLevel());
departmentBo.setOrgCode(departmentModel.getOrgCode());
departmentBo.setParentId(departmentModel.getParentId().toString());
departmentBo.setDeptOrgCode(departmentModel.getDeptOrgCode().toString());
departmentBo.setSequenceNbr(departmentModel.getSequenceNbr().toString());
}
return departmentBo;
}
/**
* Model 转 Bo
*/
private CompanyBo convertCompanyModelToBo(CompanyModel companyModel){
CompanyBo companyBo = new CompanyBo();
if(companyModel != null) {
companyBo.setAddress(companyModel.getAddress());
companyBo.setCompanyName(companyModel.getCompanyName());
companyBo.setCompanyOrgCode(Long.parseLong(companyModel.getCompanyOrgCode().toString()));
companyBo.setEmail(companyModel.getEmail());
companyBo.setLandlinePhone(companyModel.getLandlinePhone());
companyBo.setLongitude(companyModel.getLongitude());
companyBo.setLatitude(companyModel.getLatitude());
companyBo.setLevel(companyModel.getLevel());
companyBo.setOrgCode(companyModel.getOrgCode());
companyBo.setSequenceNbr(companyModel.getSequenceNbr().toString());
companyBo.setParentId(companyModel.getParentId().toString());
}
return companyBo;
}
private RoleBo convertRoleModelToBo(RoleModel roleModel) {
RoleBo roleBo = new RoleBo();
if(roleModel != null){
roleBo.setRoleName(roleModel.getRoleName());
roleBo.setRoleType(roleModel.getRoleType());
roleBo.setSequenceNbr(roleModel.getSequenceNbr().toString());
}
return roleBo;
}
private String buildKey(String userId, String token) {
return "region_" + userId + "_" + token;
}
}
......@@ -45,8 +45,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecificVo>
* @param equipmentId
* @return
*/
List<EquipmentSpecificVo> getEquipmentBySpe(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId);
int getEquipmentBySpeCount( @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId);
List<EquipmentSpecificVo> getEquipmentBySpe(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId, @Param("equipmentIdList") List<Long> equipmentIdList);
int getEquipmentBySpeCount( @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId, @Param("equipmentIdList") List<Long> equipmentIdList);
/**
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.dao.mapper;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yeejoin.amos.fas.dao.dto.EquipmentDTO;
import org.apache.ibatis.annotations.Param;
......@@ -21,4 +22,6 @@ public interface ImpEquipMapper extends BaseMapper {
Long reservePageCount();
List<EquipmentDTO> reservePage(@Param("start") long start,@Param("length") int length);
Set<String> getAllCode();
}
......@@ -23,4 +23,6 @@ public interface IEquipmentDao extends BaseDao<Equipment, Long> {
@Query(value = "SELECT ss.equipment_specific_id FROM(SELECT si.equipment_specific_id, si.equipment_index_id FROM wl_equipment_specific_index si WHERE si.equipment_specific_id IN ( SELECT fe.fire_equipment_id FROM f_equipment_fire_equipment fe WHERE fe.equipment_id = ?1 ) ) ss LEFT JOIN wl_equipment_index ei ON ss.equipment_index_id = ei.id WHERE ei.type_code = ?2", nativeQuery = true)
List<Object> getReserveEquipById(Long id, String typeCode);
Optional<Equipment> findFirstByCodeIs(String code);
}
package com.yeejoin.amos.fas.business.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -15,4 +16,10 @@ public interface IEquipManageFeign {
*/
@PutMapping(value = "/equip/building/unbind/region")
void unbindRelation(@RequestParam(value ="instanceId") Long instanceId);
/**
* 查询建筑位置全路径
*/
@GetMapping(value = "/equip/building/getBuildingCodeKeyMap")
Object getBuildingCodeKey();
}
package com.yeejoin.amos.fas.business.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "${outSystem.fegin.name}", configuration = {MultipartSupportConfig.class})
public interface OutTokenLoginFeign {
@RequestMapping(value = "/getUserName", method = RequestMethod.GET)
String getUserName(@RequestParam String token);
}
package com.yeejoin.amos.fas.business.feign;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
@FeignClient(name = "${privilege.fegin.name}", configuration = {MultipartSupportConfig.class})
public interface PrivilegeFeign {
@RequestMapping(value = "privilege/v1/auth/idpassword", method = RequestMethod.POST)
FeignClientResult login(
@RequestHeader(name = "appKey", required = true) String appKey,
@RequestHeader(name = "product", required = true) String product,
@RequestHeader(name = "token", required = true) String token,
@RequestBody Map person);
@RequestMapping(value = "privilege/v1/application/list/user/service", method = RequestMethod.GET)
FeignClientResult warrant(
@RequestHeader(name = "appKey", required = true) String appKey,
@RequestHeader(name = "product", required = true) String product,
@RequestHeader(name = "token", required = true) String token);
}
......@@ -412,6 +412,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
}
PlanDetail planEntity = new PlanDetail();
BeanUtils.copyProperties(planDetail, planEntity);
planEntity.setOrgCode(oldPlan.getOrgCode());
planEntity.setCreator(oldPlan.getCreator());
planDetailDao.saveAndFlush(planEntity);
planDoc.setPlanId(planId);
......
......@@ -5,7 +5,11 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.TreeBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
......@@ -25,4 +29,19 @@ public class EquipmentCategoryServiceImpl implements IEquipmentCategoryService
public List<EquipmentCategory> list( ) {
return equipmentCategoryMapper.list();
}
@Override
public List<EquipmentCategory> getAllTree(Long root) {
List<EquipmentCategory> list = equipmentCategoryMapper.list();
if (list.isEmpty()) {
return Collections.emptyList();
}
Long root123 = -1L;
list.forEach(eq -> { if(eq.getParentId() == null) { eq.setParentId(root123);}});
if (root == null) {
root = root123;
}
Collection<EquipmentCategory> bulid = TreeBuilder.bulid(list, root);
return new ArrayList<>(bulid);
}
}
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.IEquipmentDao;
import com.yeejoin.amos.fas.business.dao.repository.IEquipmentFireEquipmentDao;
import com.yeejoin.amos.fas.business.dao.repository.IPreplanPictureDao;
import com.yeejoin.amos.fas.business.feign.IEquipManageFeign;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.param.ImgParam;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
......@@ -16,12 +17,16 @@ import com.yeejoin.amos.fas.core.util.DaoCriteria;
import com.yeejoin.amos.fas.core.util.query.BaseQuerySpecification;
import com.yeejoin.amos.fas.dao.dto.EquipmentDTO;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.EquipmentExcelData;
import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment;
import com.yeejoin.amos.fas.dao.entity.PreplanPicture;
import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,9 +39,13 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
@Service("equipService")
......@@ -44,6 +53,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
private final Logger log = LoggerFactory.getLogger(EquipmentServiceImpl.class);
private final String[] docxTitle = {"设备编号", "设备名称", "所属区域", "位置"};
@Autowired
ImpEquipMapper impEquipMapper;
......@@ -72,6 +83,9 @@ public class EquipmentServiceImpl implements IEquipmentService {
@Autowired
private PlanEquipmentMapper planEquipmentMapper;
@Autowired
IEquipManageFeign iEquipManageFeign;
// @Autowired
// private IFmeaEquipmentPointDao iFmeaEquipmentPointDao;
......@@ -515,4 +529,68 @@ public class EquipmentServiceImpl implements IEquipmentService {
return iEquipmentDao.getReserveEquipById(id, typeCode);
}
@Override
public void downTemplate(HttpServletResponse response) {
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet();
Row row = sheet.createRow(0);
for (int i = 0; i < docxTitle.length; i++) {
Cell cell = row.createCell(i);
cell.setCellValue(docxTitle[i]);
}
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=" + URLEncoder.encode("电力设备批量导入模板.xls", "UTF-8"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
workbook.write(response.getOutputStream());
} catch (IOException e) {
//throw new NormalException(e.getMessage());
}
}
@Override
public void uploadList(List<EquipmentExcelData> list, String orgCode) {
if (!list.isEmpty()) {
List<Equipment> equipmentList = new LinkedList<>();
// 获取所有的区域编码
Map<String, Object> res = (Map<String, Object>) iEquipManageFeign.getBuildingCodeKey();
if (((int)res.get("status")) != 200) {
throw new YeeException("解析位置编码失败");
}
Map<String, String> areaCodeIdMap = (Map<String, String>) res.getOrDefault("result", new HashMap<String, String>());
// 获取所有存在的重点设备编码
Set<String> equipCodeSet = impEquipMapper.getAllCode();
for (int i = 0; i < list.size(); i++) {
int row = i + 3;
EquipmentExcelData x = list.get(i);
String equipCode = x.getEquipCode();
String equipName = x.getEquipName();
String areaCode = x.getAreaCode();
String position = x.getPosition();
if (ValidationUtil.isEmpty(equipCode) || ValidationUtil.isEmpty(equipName) || ValidationUtil.isEmpty(areaCode)) {
throw new YeeException("错误行" + row + ":检查非空字段");
}
if (equipCodeSet.contains(equipCode.trim())) {
throw new YeeException("错误行" + row + ":重复的设备编号");
}
if (!areaCodeIdMap.containsKey(areaCode.trim())) {
throw new YeeException("错误行" + row + ":所属区域编号有误");
}
equipCodeSet.add(equipCode.trim());
Equipment equipment = new Equipment();
equipment.setName(equipName.trim());
equipment.setCode(equipCode.trim());
equipment.setRiskSourceId(Long.valueOf(areaCodeIdMap.get(areaCode.trim())));
if (!ValidationUtil.isEmpty(position)) {
equipment.setAddress(position);
}
equipment.setIsIndoor(false);
equipment.setOrgCode(orgCode);
equipmentList.add(equipment);
}
iEquipmentDao.saveAll(equipmentList);
}
}
}
......@@ -3,19 +3,18 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper;
import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.business.util.TreeUtil;
import com.yeejoin.amos.fas.business.vo.AssoEquipsVo;
import com.yeejoin.amos.fas.business.vo.EquipmentPointVo;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificVo;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 装备配置 服务实现类
......@@ -28,7 +27,8 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
@Autowired
EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired
IEquipmentCategoryService categoryService;
@Override
public List<FmeaEquipmentPoint> upDateEquimentPoint(FmeaBindParam fmeaBindParam) {
......@@ -71,15 +71,33 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
return map;
}
@Override
public Map<String, Object> getEquipmentBySpeV2(String name, int pageNumber, int pageSize, Long equipmentId) {
Map<String, Object> map = new HashMap<>();
List<Long> equipmentIdList = null;
if (equipmentId != null) {
List<EquipmentCategory> allChildren = TreeUtil.getAllChildren(categoryService.getAllTree(equipmentId));
equipmentIdList = new LinkedList<>();
equipmentIdList.add(equipmentId);
if(!allChildren.isEmpty()){
List<Long> finalEquipmentIdList = equipmentIdList;
allChildren.forEach(cate -> finalEquipmentIdList.add(cate.getId()));
}
}
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber * pageSize, pageSize, name, null,null, equipmentIdList);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, null,null, equipmentIdList);
map.put("content",equipmentBySpe);
map.put("totalElements",equipmentBySpeCount);
return map;
}
@Override
public Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize ,String equipmentId) {
Map<String, Object> map = new HashMap<>();
pageNumber = pageNumber*pageSize;
code = checkid(code);
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId);
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId, null);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId, null);
map.put("content",equipmentBySpe);
map.put("totalElements",equipmentBySpeCount);
return map;
......@@ -113,6 +131,6 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
substring = id.substring(0, 1);
}
return substring;
return substring+"%";
}
}
......@@ -6,7 +6,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe;
import com.yeejoin.amos.fas.business.dao.mapper.*;
......@@ -27,7 +26,6 @@ import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.business.vo.TopicEntityVo;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum;
import com.yeejoin.amos.fas.common.enums.View3dRefreshAreaEum;
import com.yeejoin.amos.fas.core.util.StringUtil;
import com.yeejoin.amos.fas.dao.entity.*;
import org.apache.commons.lang3.ArrayUtils;
......@@ -42,6 +40,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
......@@ -113,7 +112,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Autowired
private IEvaluationModelDao iEvaluationModelDao;
@Autowired
private FmeaMapper fmeaMapper;
......@@ -140,6 +139,8 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(eqSpecId);
// 三维屏指标状态推送
String specificIndexType = equipmentSpecificIndex.getType();
//
String typeCode = equipmentSpecificIndex.getTypeCode();
if (nameKey !=null && nameKeys.contains(nameKey)) {
if (equipmentSpecific != null) {
equipmentSpecificIndex.setId(equipmentSpecific.getId());
......@@ -157,8 +158,8 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
deviceData.setId(String.valueOf(equipmentSpecific.getId()));
deviceData.setCode(equipmentSpecific.getCode());
//设备告警处理逻辑
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(specificIndexType)) {
log.info("(报警)Message type is: " + specificIndexType);
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(typeCode)) {
log.info("(报警)Message typeCode is: " + typeCode);
/**
* 推送告警数据
* 影响区域:消防安全=>火灾告警
......@@ -168,9 +169,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
// 报警触发调用规则服务
//注释自动触发预案
//executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke,topicEntity.getRecordId());
} else if (EquipmentRiskTypeEnum.GZ.getCode().equals(specificIndexType)) {
} else if (EquipmentRiskTypeEnum.GZ.getCode().equals(typeCode)) {
// 设备故障处理逻辑
log.info("(故障)Message type is: " +specificIndexType);
log.info("(故障)Message typeCode is: " +typeCode);
final String stateTrue = "true";
final String stateFalse = "false";
String state = equipmentSpecificIndex.getValue();
......@@ -197,7 +198,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
fireEquipRuleMessagePush(deviceData, toke);
}
}
} else {
// 监测数据逻辑
log.info("(监测)Message type is: " + specificIndexType);
......@@ -255,7 +256,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
}
@Override
public void subscribeTopic() {
// 若登录系统则订阅装备数据
......@@ -305,7 +306,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
* @Date 2020/11/16 15:25
*/
private void notifyAlarm(EquipmentSpecificIndexVo equipmentSpecificIndex, int state) {
List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper.listByEquipmentPointId(equipmentSpecificIndex.getId());
List<FmeaEquipmentPoint> fmeaEquipmentPoints = fmeaEquipmentPointMapper.listByEquipmentPointId(equipmentSpecificIndex.getEquipmentIndexId());
Set<Long> fmeaIds = Sets.newHashSet();
List<Long> ids = Lists.newArrayList();
fmeaEquipmentPoints.forEach(fmeaEquipmentPoint -> {
......@@ -432,9 +433,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
}
contingencyRo.setTelemetryMap(telemetryMap);
log.debug("开始调用规则");
log.info("开始调用规则 参数 contingencyRo{},reservePlan{},equipmentNames"+contingencyRo.toString()+","+equipment.getReservePlan()+","+ ArrayUtils.toArray(equipment.getName()));
Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
log.debug("规则调用返回==",result);
log.info("规则调用返回==",result);
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
......
......@@ -3,12 +3,14 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.repository.IPlanClassifyTreeDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao;
import com.yeejoin.amos.fas.business.service.intfc.IPlanClassifyTreeService;
import com.yeejoin.amos.fas.business.util.TreeUtil;
import com.yeejoin.amos.fas.business.vo.PlanClassifyTreeVo;
import com.yeejoin.amos.fas.dao.entity.PlanClassifyTree;
import com.yeejoin.amos.fas.exception.YeeException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.TreeBuilder;
......@@ -37,14 +39,13 @@ public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
}
@Override
@Transactional(rollbackFor = {YeeException.class, Exception.class})
public Boolean delete(String ids) {
List<Long> seqs = StringUtil.String2LongList(ids);
Set<Long> allIds = new HashSet<>(seqs);
Set allIds = new HashSet<>(seqs);
for (Long seq : seqs) {
PlanClassifyTree planClassifyTree = planClassifyTreeDao.findById(seq).orElse(null);
//所有子分类
List<PlanClassifyTree> childGroupSequenceList = getChildSequenceList(planClassifyTree);
allIds.addAll(new HashSet(Bean.listToMap(childGroupSequenceList, "id", "id", PlanClassifyTree.class).keySet()));
List<PlanClassifyTreeVo> allChildIncludeMe = getAllChildIncludeMe(seq);
allIds.addAll(Bean.listToMap(TreeUtil.getAllChildren(allChildIncludeMe), "id", "id", PlanClassifyTreeVo.class).keySet());
}
// 查询分类下是否有预案
if (planDetailDao.existsByClassifyIdInAndIsDelete(allIds, false)) {
......@@ -95,39 +96,8 @@ public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
return completeList;
}
/**
* 预案分类的子id
*
* @param planClassifyTree
* @return
*/
public List<PlanClassifyTree> getChildSequenceList(PlanClassifyTree planClassifyTree) {
List<Long> sequenceList = new ArrayList<>();
List<PlanClassifyTree> childList = new ArrayList<>();
this.getAllChildList(planClassifyTree, childList);
// for (KnowledgeDocCategoryModel tagGroupModel : childList) {
// sequenceList.add(tagGroupModel.getSequenceNbr());
// }
return childList;
}
private void getAllChildList(PlanClassifyTree currentPlanClassifyTree, List<PlanClassifyTree> resList) {
if (null == currentPlanClassifyTree) {
return;
}
Long parentId = currentPlanClassifyTree.getId();
List<PlanClassifyTree> childList = planClassifyTreeDao.findByParentId(parentId);
if (!childList.isEmpty()) {
for (PlanClassifyTree tagPlanClassifyTree : childList) {
this.getAllChildList(tagPlanClassifyTree, resList);
}
}
resList.add(currentPlanClassifyTree);
}
@Override
public Collection<PlanClassifyTreeVo> getAllChildIncludeMe(Long root) {
public List<PlanClassifyTreeVo> getAllChildIncludeMe(Long root) {
List<PlanClassifyTreeVo> treeDaoAll = Bean.toModels(planClassifyTreeDao.getAll(), PlanClassifyTreeVo.class);
Collection<PlanClassifyTreeVo> treeList = TreeBuilder.bulid(treeDaoAll, root);
if (!ROOT.equals(root)) {
......@@ -138,7 +108,7 @@ public class PlanClassifyTreeServiceImpl implements IPlanClassifyTreeService {
return Arrays.asList(classifyTreeVo);
}
}
return treeList;
return new ArrayList<>(treeList);
}
@Override
......
......@@ -22,6 +22,8 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.fas.business.util.*;
import com.yeejoin.amos.fas.common.enums.AstDataSyncTopic;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -46,7 +48,6 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
......@@ -96,9 +97,6 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.business.vo.Toke;
......@@ -225,7 +223,10 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
IEquipManageFeign iEquipManageFeign;
@Autowired
private PlanDetailMapper planDetailMapper;
private PlanDetailMapper planDetailMapper;
@Autowired
private DataSyncUtil dataSyncUtil;
public static String cacheKeyForCanBeRunning() {
return Redis.genKey(CacheType.ERASABLE.name(), "CONTINGENCYRUNING");
......@@ -234,6 +235,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Autowired
private IDataRefreshService iDataRefreshService;
@Autowired
private WebMqttComponent webMqttComponent;
@Override
public RiskSource editRiskSource(HashMap<String, Object> map) throws Exception {
RiskSource riskSource = (RiskSource) map.get("param");
......@@ -260,10 +264,12 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setStatus(oldRiskSource.getStatus());
}
iRiskSourceDao.saveAndFlush(riskSource);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
return riskSource;
}
@Override
@Transactional
public void deleteRiskSource(String appKey, String product, String token, String success, Long[] riskSourceId) throws Exception {
Set<Long> parentIds = new LinkedHashSet<>();
for (Long rId : riskSourceId) {
......@@ -279,16 +285,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
//1、删除风险点
iRiskSourceDao.deleteById(rId);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_DELETE_BY_ID.getValue(), String.valueOf(rId)), String.valueOf(rId));
//2.删除关联建筑关系,防止对站服务有问题,捕获异常,不影响业务正常秩序
try {
rs.ifPresent(r->{
if(r.getSourceId() != null){
rs.ifPresent(r -> {
if (r.getSourceId() != null) {
iEquipManageFeign.unbindRelation(r.getSourceId());
}
});
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
}
}
//3.重新计算rpn
......@@ -303,6 +310,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public void deleteById(Long id) {
iRiskSourceDao.deleteById(id);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_DELETE_BY_ID.getValue(), String.valueOf(id)), String.valueOf(id));
}
@Override
......@@ -311,7 +319,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Optional<RiskSource> op = iRiskSourceDao.findBySourceId(synBo.getId());
RiskSource riskSource;
//1.同步上级
if(op.isPresent()){
if (op.isPresent()) {
//有就更新,业务只能调整上级
riskSource = op.get();
riskSource.setParentId(synBo.getParentId());
......@@ -319,21 +327,23 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} else {
//无则插入
riskSource = new RiskSource();
Bean.copyExistPropertis(synBo,riskSource);
Bean.copyExistPropertis(synBo, riskSource);
fillBasicParams(userId, orgCode, synBo.getId(), riskSource);
riskSource = iRiskSourceDao.save(riskSource);
}
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
//2.同步下级(只有一级)
if(!CollectionUtils.isEmpty(synBo.getChildren())){
if (!CollectionUtils.isEmpty(synBo.getChildren())) {
RiskSource finalRiskSource = riskSource;
List<RiskSource> children = synBo.getChildren().stream().map(s->{
List<RiskSource> children = synBo.getChildren().stream().map(s -> {
RiskSource t = new RiskSource();
Bean.copyExistPropertis(s,t);
Bean.copyExistPropertis(s, t);
fillBasicParams(userId, orgCode, s.getId(), t);
t.setParentId(finalRiskSource.getId());
return t;
}).collect(Collectors.toList());
iRiskSourceDao.saveAll(children);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE_ALL.getValue(), RandomUtil.buildNo()), JSON.toJSONString(children));
}
return riskSource;
}
......@@ -351,10 +361,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
public Boolean removeBind(Long instanceId) {
Optional<RiskSource> exist = iRiskSourceDao.findBySourceId(instanceId);
if(exist.isPresent()){
if (exist.isPresent()) {
RiskSource riskSource = exist.get();
riskSource.setSourceId(null);
iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
}
return exist.isPresent();
}
......@@ -623,7 +634,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1);
}
contingencyRo.setTelesignallingMap(telesignallingMap);
//获取遥测指标
//获取遥测指标
points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false
HashMap<String, Double> telemetryMap = new HashMap<>();
for (Map map : points) {
......@@ -632,7 +643,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setTelemetryMap(telemetryMap);
List<String> plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId()));
if(plan.size()>0){
if (plan.size() > 0) {
log.debug("开始调用规则");
Object result = ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(equipment.getName()));
log.debug("规则调用返回==", result);
......@@ -787,40 +798,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getStatisticsCheck(orgCode)));
}
/**
* <pre>
* @Description: 隐患治理更新State、rpn值
* </pre>
*
* @Throws
* @Author keyong
* @Date 2021/2/1 19:50
*/
@Override
public void processProtalDataFromDanger(DangerResultBo dangerResultBo) {
List<FmeaPointInputitem> fmeaPointInputitems = fmeaPointInputitemMapper.listByPointInputItemId(dangerResultBo.getInputItemId());
if (0 < fmeaPointInputitems.size()) {
Set<Long> fmeaIds = Sets.newHashSet();
List<Long> list = Lists.newArrayList();
fmeaPointInputitems.forEach(x -> {
list.add(x.getId());
fmeaIds.add(x.getFmeaId());
});
fmeaPointInputitemMapper.updateStateByIds(0, list);
RsDataQueue rsDataQueue = RsDataQueue.getInstance();
fmeaIds.forEach(fmeaId -> rsDataQueue.addPatrolMessage(fmeaId, dangerResultBo.getUserName(), null, "1"));
iDataRefreshService.refreshViewData(DataRefreshTypeEum.handleDanger.getCode());
// 今日安全
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(new Date());
String topicOne = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "todaySafetyIndex");
webMqttComponent.publish(topicOne, JSON.toJSONString(view3dService.getSafetyIndexInfoByDate(dangerResultBo.getOrgCode(), dateString)));
// 一周安全趋势
String topicThree = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "weekSafetyIndex");
webMqttComponent.publish(topicThree, JSON.toJSONString(view3dService.getSafetyIndexWeek(dangerResultBo.getOrgCode())));
}
}
/**
* 巡检消息规则推送
......@@ -1031,13 +1008,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override
@javax.transaction.Transactional
public String processFireEqumtData(AlarmParam deviceData) throws Exception {
EquipmentSpecificIndexVo equipmentSpecificIndexVo = impAndFireEquipMapper.findFireEqupmentByCode(deviceData.getPointCode());
EquipmentSpecificIndexVo equipmentSpecificIndexVo = impAndFireEquipMapper.findFireEqupmentByCode(deviceData.getPointCode());
Optional.ofNullable(equipmentSpecificIndexVo).orElseThrow(() -> new Exception("未查询到相关装备"));
TopicEntityVo topicEntity = new TopicEntityVo();
topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo));
String data = JSON.toJSONString(topicEntity);
System.out.println(data);
iEquipmentHandlerService.handlerMqttMessage("",data );
TopicEntityVo topicEntity = new TopicEntityVo();
topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo));
String data = JSON.toJSONString(topicEntity);
System.out.println(data);
iEquipmentHandlerService.handlerMqttMessage("", data);
return "SUCCESS";
}
......@@ -1058,9 +1035,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
TopicEntityVo topicEntity = new TopicEntityVo();
Equipment equipment = equipmentService.queryOne(id);
topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo));
topicEntity.setEquipment(equipment);
topicEntity.setEquipment(equipment);
String data = JSON.toJSONString(topicEntity);
iEquipmentHandlerService.handlerMqttMessage("",data );
iEquipmentHandlerService.handlerMqttMessage("", data);
if (equipment != null) {
equipment.setStartTime(DateUtil.getDateNow());
equipment.setEndTime(null);
......@@ -1328,8 +1305,6 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
// }
// }
@Autowired
private WebMqttComponent webMqttComponent;
@Value("${autoSys.push.type}")
private String pushType;
@Value("${spring.application.name}")
......@@ -1853,6 +1828,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setRpni(null);
riskSource.setRiskLevelId(null);
iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
return;
}
BigDecimal rpn = rpnValueBo.getRpn();
......@@ -1866,6 +1842,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
}
}
iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
this.updateParentRpn(riskSource.getParentId());
}
}
......@@ -2006,8 +1983,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return null;
}
public List<String> getNumberPlan(Long id){
List<String> ruleId = planDetailMapper.getRuleIdByEquipment(id);
public List<String> getNumberPlan(Long id) {
List<String> ruleId = planDetailMapper.getRuleIdByEquipment(id);
return ruleId;
}
}
......
......@@ -16,6 +16,8 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.yeejoin.amos.fas.business.util.DataSyncUtil;
import com.yeejoin.amos.fas.common.enums.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -55,14 +57,6 @@ import com.yeejoin.amos.fas.business.vo.ExceptionRegionVo;
import com.yeejoin.amos.fas.business.vo.SafetyIndexDetailVo;
import com.yeejoin.amos.fas.business.vo.TodaySafetyIndexVo;
import com.yeejoin.amos.fas.business.vo.View3dNodeVo;
import com.yeejoin.amos.fas.common.enums.CheckStatusEnum;
import com.yeejoin.amos.fas.common.enums.DataRefreshTypeEum;
import com.yeejoin.amos.fas.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.fas.common.enums.ResourceTypeDefEnum;
import com.yeejoin.amos.fas.common.enums.RiskSourceLevelEum;
import com.yeejoin.amos.fas.common.enums.RiskSourceRegionEum;
import com.yeejoin.amos.fas.common.enums.RpnChangeTypeEum;
import com.yeejoin.amos.fas.common.enums.StatisticsErrorTypeEum;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.DateUtil;
import com.yeejoin.amos.fas.core.common.response.CoordDTO;
......@@ -118,6 +112,9 @@ public class View3dServiceImpl implements IView3dService {
@Autowired
private RemoteSecurityService remoteSecurityService;
@Autowired
private DataSyncUtil dataSyncUtil;
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResponse setPoint3dPosition(List<BindPointBo> pointBoList) {
......@@ -248,6 +245,7 @@ public class View3dServiceImpl implements IView3dService {
if(ue4Rotation != null) riskSource.setUe4Rotation(pointBo.getUe4Rotation());
if(position3d != null) riskSource.setPosition3d(position3d);
iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
}
}
......
......@@ -53,4 +53,6 @@ public interface EquipmentSpecificService {
* @return
*/
Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize, String equipmentId);
Map<String ,Object> getEquipmentBySpeV2(String name, int pageNumber, int pageSize, Long equipmentId);
}
......@@ -17,4 +17,9 @@ public interface IEquipmentCategoryService {
*/
List<EquipmentCategory> list( );
/**
* 获取装备树
* @return
*/
List<EquipmentCategory> getAllTree(Long root);
}
package com.yeejoin.amos.fas.business.service.intfc;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.fas.business.param.ImgParam;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.EquipDetailsResponse;
import com.yeejoin.amos.fas.core.util.DaoCriteria;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.EquipmentExcelData;
import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment;
import com.yeejoin.amos.fas.dao.entity.PreplanPicture;
import org.springframework.data.domain.Page;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
......@@ -113,8 +113,19 @@ public interface IEquipmentService {
/**
* 获取重点设备绑定设备
* @param id
* @param firealarm
* @param typeCode
* @return
*/
List<Object> getReserveEquipById(Long id, String typeCode);
/**
* 下载导入模板
* @param response
*/
void downTemplate(HttpServletResponse response);
/**
* 导入数据
*/
void uploadList(List<EquipmentExcelData> list, String orgCode);
}
package com.yeejoin.amos.fas.business.util;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
/**
* @ProjectName: YeeAmosFireAutoSysRoot
* @Package: com.yeejoin.amos.fas.business.util
* @ClassName: DataSyncUtil
* @Author: Jianqiang Gao
* @Description: 数据同步工具类
* @Date: 2021/3/24 15:31
* @Version: 1.0
*/
@Component
public class DataSyncUtil {
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private WebMqttComponent webMqttComponent;
public void astDataSync(String topic, String message) {
redisTemplate.opsForValue().set(topic, message);
webMqttComponent.publish(topic.substring(0, topic.lastIndexOf("_")), message);
}
}
\ No newline at end of file
package com.yeejoin.amos.fas.business.util;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* @description: easyPoi工具类
* @author: duanwei
* @create: 2020-05-28 13:57
**/
public class ExcelUtils {
/**
* excel 导出
*
* @param list 数据
* @param title 标题
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param isCreateHeader 是否创建表头
* @param response
*/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass,
String fileName, boolean isCreateHeader, HttpServletResponse response) {
ExportParams exportParams = new ExportParams(title, sheetName);
exportParams.setCreateHeadRows(isCreateHeader);
defaultExport(list, pojoClass, fileName, response, exportParams);
}
/**
* excel 导出
*
* @param list 数据
* @param title 标题
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param response
*/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
HttpServletResponse response) {
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
}
/**
* excel 导出
*
* @param list 数据
* @param fileName 文件名称
* @param response
*/
public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
defaultExport(list, fileName, response);
}
/**
* 默认的 excel 导出
*
* @param list 数据
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param response
* @param exportParams 导出参数
*/
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName,
HttpServletResponse response, ExportParams exportParams) {
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
if (workbook != null){
downLoadExcel(fileName, response, workbook);
};
}
/**
* 下载
*
* @param fileName 文件名称
* @param response
* @param workbook excel数据
*/
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
workbook.write(response.getOutputStream());
} catch (IOException e) {
//throw new NormalException(e.getMessage());
}
}
/**
* 默认的 excel 导出
*
* @param list 数据
* @param fileName 文件名称
* @param response
*/
private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
if (workbook != null) {
downLoadExcel(fileName, response, workbook);}
}
/**
* excel 导入
*
* @param filePath excel文件路径
* @param titleRows 标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
if (StringUtils.isBlank(filePath)) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
List<T> list = null;
try {
list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) {
//throw new NormalException("模板不能为空");
} catch (Exception e) {
e.printStackTrace();
//throw new NormalException(e.getMessage());
}
return list;
}
/**
* excel 导入
*
* @param file 上传的文件
* @param titleRows 标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
if (file == null) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
List<T> list = null;
try {
list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
} catch (NoSuchElementException e) {
// throw new NormalException("excel文件不能为空");
} catch (Exception e) {
//throw new NormalException(e.getMessage());
System.out.println(e.getMessage());
}
return list;
}
}
package com.yeejoin.amos.fas.business.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class RandomUtil {
private static ThreadLocalRandom threadLocalRandom;
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
}
return newDate + result;
}
/**
* @param resourceType 资源类型
* @param companyCode 单位编号
* @Description Random存在性能问题可能造成线程阻塞问题,使
* 用性能更加卓越的threadLocalRandom(线程安全的单例模式)生成随机数
* 四位随机数无法保证不可重复性,如果对不可重复要求高,请使用其他工具
* @Author songLei
* @Return String
* @Date 2020/12/18 11:49
*/
public static String buildNo(String resourceType, String companyCode) {
threadLocalRandom = ThreadLocalRandom.current();
int num = threadLocalRandom.nextInt(1000, 9999);
return resourceType + companyCode + num;
}
public static String buildNo() {
threadLocalRandom = ThreadLocalRandom.current();
int num = threadLocalRandom.nextInt(1000, 9999);
return String.valueOf(num);
}
}
......@@ -28,7 +28,7 @@ public class EquipmentSpecificIndexVo {
private String name;
private String equipmentIndexName;
private String equipmentIndexUnitName;
// 性能指标name key
......@@ -43,6 +43,16 @@ public class EquipmentSpecificIndexVo {
// 订阅类型
private String type;
private String typeCode;
public String getTypeCode() {
return typeCode;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public void setId(long id) {
this.id = id;
}
......
......@@ -3,6 +3,8 @@ package com.yeejoin.amos.fas.business.vo;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import java.io.Serializable;
public class ReginParams implements Serializable {
......@@ -12,6 +14,25 @@ public class ReginParams implements Serializable {
private CompanyBo company;
private RoleBo role;
private DepartmentBo department;
private String token;
private AgencyUserModel userModel;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public AgencyUserModel getUserModel() {
return userModel;
}
public void setUserModel(AgencyUserModel userModel) {
this.userModel = userModel;
}
public CompanyBo getCompany() {
return company;
}
......
package com.yeejoin.amos.fas.config;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe;
import com.yeejoin.amos.component.feign.config.TokenOperation;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.vo.CompanyBo;
import com.yeejoin.amos.fas.business.vo.DepartmentBo;
import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.business.vo.RoleBo;
import com.yeejoin.amos.fas.exception.PermissionException;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.aspectj.lang.JoinPoint;
......@@ -15,9 +22,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
......@@ -26,21 +31,9 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.config.TokenOperation;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.vo.CompanyBo;
import com.yeejoin.amos.fas.business.vo.ReginParams;
import com.yeejoin.amos.fas.exception.PermissionException;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Aspect
@Component
......
......@@ -3,7 +3,7 @@ security.password=a1234560
security.loginId=fas_autosys
#environment
#spring.profiles.active = dev
eureka.client.serviceUrl.defaultZone=http://172.16.3.100:10001/eureka/
eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true
eureka.client.healthcheck.enabled = true
......@@ -19,11 +19,13 @@ spring.datasource.hikari.maxLifetime = 1765000
spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
#ws
params.remoteWebsocketUrl=http://172.16.11.36:10600/
#redis
spring.redis.database=0
spring.redis.host=172.16.3.100
spring.redis.host=172.16.10.85
spring.redis.port=6379
spring.redis.password=1234560
spring.redis.password=amos2019Redis
spring.redis.jedis.pool.max-active=200
spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=10
......@@ -39,9 +41,9 @@ params.isPush=true
## emqx
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.100:1883
emqx.user-name=admin
emqx.password=admin
emqx.broker=tcp://172.16.10.85:1883
emqx.user-name=super
emqx.password=a123456
#�����
file.downLoad.url=http://39.98.246.31:8888/
#站端名称使用全拼
......
spring.application.name = AMOS-AUTOSYS
server.servlet.context-path=/fireAutoSys
server.port = 8083
server.port = 8085
spring.profiles.active=dev
#应用product appkey
security.productWeb=STUDIO_APP_WEB
......@@ -50,7 +50,7 @@ visual.fegin.name=maas-visual
#值班系统
dutyMode.fegin.name=AMOS-DUTYMODE
#队站装备管理名称,主要用于风险区域同步至仓库货位和订阅装备信息系统
equipManage.fegin.name=AMOS-EQUIPMANAGE
equipManage.fegin.name=AMOS-EQUIPMANAGE-TT
#feginName
number.plan.projectName=换流站消防专项预案
......@@ -99,5 +99,10 @@ data.type.extinguisher=3104
data.type.hydrant=3105
outSystem.fegin.name=unKnow
outSystem.user.password=a1234560
privilege.fegin.name=AMOS-API-PRIVILEGE
......@@ -105,7 +105,7 @@
END AS type,
wlesa.update_date as createDate,
wlesa.recovery_date as recoveryDate,
wws.full_name as warehouseStructureName,
CONCAT(IFNULL(wws.full_name,''),' ',IFNULL(wlsd.description,'')) as warehouseStructureName,
(
SELECT
group_concat(DISTINCT f.`name`)
......
......@@ -32,7 +32,7 @@
equ.code as code,
det.name as name,
cate.name as type,
ware.full_name as address,
concat_ws('-',ware.full_name, det.area) as address,
spe.single as single,
sto.amount as amount,
spe.iot_code,
......@@ -40,8 +40,14 @@
spe.system_id,
manage.name as system_name
from
wl_stock_detail as sto
left join wl_equipment_specific as spe on sto.qr_code = spe.qr_code
(
SELECT amount,
(SELECT equipment_specific_id FROM wl_stock_detail WHERE stock_id = stk.id limit 1) AS equipment_specific_id,
(SELECT warehouse_structure_id FROM wl_stock_detail WHERE stock_id = stk.id limit 1) AS warehouse_structure_id,
(SELECT equipment_detail_id FROM wl_stock_detail WHERE stock_id = stk.id limit 1) AS equipment_detail_id
FROM wl_stock stk
) AS sto
left join wl_equipment_specific as spe on sto.equipment_specific_id = spe.id
<if test="equipmentId != null and equipmentId!='null' ">
left join f_equipment_fire_equipment as fire on spe.id = fire.fire_equipment_id
</if>
......@@ -51,23 +57,36 @@
left join wl_equipment_category as cate on equ.category_id = cate.id
left join f_fire_fighting_system as manage on spe.system_id = manage.id
where sto.amount <![CDATA[>]]> 0
and spe.id is not null
<if test="name != null and name!='null' ">
and (det.name like CONCAT('%',#{name},'%') or ware.full_name like CONCAT('%',#{name},'%') or spe.iot_code like CONCAT('%',#{name},'%') or spe.code like CONCAT('%',#{name},'%'))
</if>
<if test="code != null and code!='null' ">
and cate.code like CONCAT('%',#{code},'%' )
and cate.code like #{code}
</if>
<if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId}
</if>
<if test="equipmentIdList != null and equipmentIdList.size > 0 ">
and equ.category_id in
<foreach collection="equipmentIdList" item="equipmentId" open="(" close=")" separator=",">
#{equipmentId}
</foreach>
</if>
limit #{pageNumber},#{pageSize}
</select>
<select id="getEquipmentBySpeCount" resultType="int">select
count(1)
from
wl_stock_detail as sto
left join wl_equipment_specific as spe on sto.qr_code = spe.qr_code
(
SELECT amount,
(SELECT equipment_specific_id FROM wl_stock_detail WHERE stock_id = stk.id limit 1) AS equipment_specific_id,
(SELECT warehouse_structure_id FROM wl_stock_detail WHERE stock_id = stk.id limit 1) AS warehouse_structure_id,
(SELECT equipment_detail_id FROM wl_stock_detail WHERE stock_id = stk.id limit 1) AS equipment_detail_id
FROM wl_stock stk
) AS sto
left join wl_equipment_specific as spe on sto.equipment_specific_id = spe.id
<if test="equipmentId != null and equipmentId!='null' ">
left join f_equipment_fire_equipment as fire on spe.id = fire.fire_equipment_id
</if>
......@@ -77,15 +96,22 @@
left join wl_equipment_category as cate on equ.category_id = cate.id
left join f_fire_fighting_system as manage on spe.system_id = manage.id
where sto.amount <![CDATA[>]]> 0
and spe.id is not null
<if test="name != null and name!='null' ">
and (det.name like CONCAT('%',#{name},'%') or ware.full_name like CONCAT('%',#{name},'%') or spe.iot_code like CONCAT('%',#{name},'%') or spe.code like CONCAT('%',#{name},'%'))
</if>
<if test="code != null and code!='null' ">
and cate.code like CONCAT('%',#{code},'%' )
and cate.code like #{code}
</if>
<if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId}
</if>
<if test="equipmentIdList != null and equipmentIdList.size > 0 ">
and equ.category_id in
<foreach collection="equipmentIdList" item="equipmentId" open="(" close=")" separator=",">
#{equipmentId}
</foreach>
</if>
</select>
<select id="getFireEquiments" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpeVo">
select
......
......@@ -164,7 +164,7 @@
WHEN 'false' THEN '否'
ELSE ind.value END 'e_value',
ein.unit as eq_point_unit,
str.full_name as source_name,
CONCAT(IFNULL(str.full_name,''),' ',IFNULL(sto.description,'')) as source_name,
(
SELECT
group_concat(DISTINCT f.`name`)
......
......@@ -101,12 +101,16 @@
</select>
<select id="listByEquipmentPointId" resultType="com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint">
select
id,fmea_id as fmeaId,equipment_point_id as equipmentPointId,state
from
f_fmea_equipment_point
where
equipment_point_id = #{equipmentPointId}
SELECT
point.id,
point.fmea_id AS fmeaId,
point.equipment_point_id AS equipmentPointId,
point.state
FROM
f_fmea_equipment_point point
LEFT JOIN wl_equipment_specific_index equipment ON equipment.id = point.equipment_point_id
where
equipment.equipment_index_id = #{equipmentPointId}
</select>
<select id="listEquipmentPoint" resultType="java.util.Map">
......
......@@ -89,4 +89,8 @@
a.reserve_plan IS NOT NULL
AND a.reserve_plan != ''
</select>
<select id="getAllCode" resultType="string">
select distinct code from f_equipment
</select>
</mapper>
\ No newline at end of file
......@@ -199,6 +199,21 @@
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mqtt</artifactId>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>
<dependencyManagement>
......
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