Commit a730ef3d authored by KeYong's avatar KeYong

更新消防系统运行状态

parent 37db670d
package com.yeejoin.equipmanage.common.dto;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
import java.io.Serializable;
/**
* @author keyong
* @title: EquipIndexDto
* <pre>
* @description: TODO
* </pre>
* @date 2023/10/11 18:11
*/
@RuleFact(value = "测点指标数据", project = "换流站消防专项预案")
@Data
public class EquipIndexDto implements Serializable {
private static final long serialVersionUID = 7404825884689318992L;
@Label("指标key")
private String indexKey;
@Label("值")
private String indexValue;
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.equipmanage.common.vo.FileUploadVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.context.annotation.Configuration;
......@@ -141,4 +142,13 @@ public class FireFightingSystemEntity {
@ApiModelProperty(value = "主要设计人员")
private String leadDesigner;
@ApiModelProperty("系统运行状态")
private String systemRunState;
@TableField(exist = false)
private Integer isAlarm;
@TableField(exist = false)
private String uUID;
}
......@@ -14,7 +14,8 @@ import java.util.List;
@AllArgsConstructor
public enum ConfigPageTopicEnum {
INTEGRATE("INTEGRATE_TOPIC/#", "集成页面统配主题");
INTEGRATE("INTEGRATE_TOPIC/#", "集成页面统配主题"),
SYSTEMDETAIL("EQUIP_INDEX_ON_SYSTEM_DETAIL", "系统详情页面大屏初始化主题");
private String topic;
......
......@@ -21,7 +21,8 @@ public enum TopicEnum {
EQXXTJ("fasReportInsertOrUpdate", "设备信号消息统计列表"),
ALARM_LOG_INSERT("alarm/log/insert","告警日志插入"),
IOT_SYSTEM__AlARM("iot-system-alarm", "确警消息"),
SHBZYCXH("fasNormalIndexInsertOrUpdate", "四横八纵遥测信号");
SHBZYCXH("fasNormalIndexInsertOrUpdate", "四横八纵遥测信号"),
XFXTYXZT("fasFireSystemRunStateUpdate", "站端消防系统运行状态更新主题");
private String topic;
......
......@@ -9,7 +9,7 @@ package com.yeejoin.equipmanage.common.enums;
* @date 2020/11/4 19:34
*/
public enum TrueOrFalseEnum {
real(0, "true", "是", "进口"),fake(1, "false", "否", "国产");
real(0, "true", "是", "进口", "0"),fake(1, "false", "否", "国产", "1");
public final int name;
......@@ -19,10 +19,23 @@ public enum TrueOrFalseEnum {
public final String desc;
TrueOrFalseEnum(int name, String value, String flag, String desc) {
public final String stringValue;
TrueOrFalseEnum(int name, String value, String flag, String desc, String stringValue) {
this.name = name;
this.value = value;
this.flag = flag;
this.desc = desc;
this.stringValue = stringValue;
}
public static String reverseObj(String str) {
if (str.equalsIgnoreCase(TrueOrFalseEnum.real.stringValue)) {
return TrueOrFalseEnum.fake.stringValue;
} else if (str.equalsIgnoreCase(TrueOrFalseEnum.fake.stringValue)) {
return TrueOrFalseEnum.real.stringValue;
} else {
return null;
}
}
}
......@@ -15,6 +15,7 @@ import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO;
import com.yeejoin.equipmanage.common.entity.dto.RequestBaseDto;
import com.yeejoin.equipmanage.common.entity.vo.*;
import com.yeejoin.equipmanage.common.enums.TrueOrFalseEnum;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.*;
......@@ -788,8 +789,14 @@ public class FireFightingSystemController extends AbstractBaseController {
map1.put("highLight", "true");
ite.addAll(list1);
ite.add(map1);
Map<String, String> map2 = new HashMap<>();
map2.put("key", "系统运行状态");
map2.put("value", "1".equals(fireFightingSystem.getSystemRunState()) ? "运行" : "停止");
map2.put("highLight", "true");
res.put("items", ite);
res.put("title", "基本信息");
ite.add(map2);
fireFightingSystem.setSystemRunState("1".equals(fireFightingSystem.getSystemRunState()) ? "运行" : "停止");
Map<String, Object> fireSystem = Bean.BeantoMap(fireFightingSystem);
fireSystem.put("detailId", fireFightingSystem.getId());
Map<String, Object> state = new HashMap<>();
......
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.component.rule.RuleTrigger;
import com.yeejoin.equipmanage.common.dto.EquipIndexDto;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.common.entity.FireFightingSystemEntity;
import com.yeejoin.equipmanage.common.enums.TopicEnum;
import com.yeejoin.equipmanage.common.enums.TrueOrFalseEnum;
import com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce;
import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import org.apache.commons.io.IOUtils;
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.core.io.Resource;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author keyong
* @title: FireSystemAction
* <pre>
* @description: 消防系统运行状态
* </pre>
* @date 2023/10/11 16:50
*/
@Component
@RuleActionBean(beanLabel = "消防系统运行状态")
public class FireSystemAction {
public static final Logger log = LoggerFactory.getLogger(FireSystemAction.class);
@Autowired
protected EmqKeeper emqKeeper;
@Autowired
private IFireFightingSystemService systemService;
@Autowired
private IEquipmentSpecificIndexSerivce specificIndexSerivce;
@Value("classpath:/json/systemStateIndex.json")
private Resource systemStateIndex;
/**
*
* @param code
* @param systemTypeCode
* @param runStateCode
* @description methodLabel是配置的方法名label,project是规则调用的文件夹名称,方法配置在预案文件夹中
*/
@RuleMethod(methodLabel = "更新消防系统运行状态", project = "换流站消防专项预案")
public void changeFireSystemRunState(@MethodParam(paramLabel = "系统编码") String code,
@MethodParam(paramLabel = "系统类型编码") String systemTypeCode,
@MethodParam(paramLabel = "系统运行状态") String runStateCode,
@MethodParam(paramLabel = "多指标复合判断") String boolValue,
@MethodParam(paramLabel = "测点指标数据") Object paramObj) throws Exception {
boolean bool = Boolean.FALSE;
LambdaQueryWrapper<FireFightingSystemEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FireFightingSystemEntity::getCode, code).eq(FireFightingSystemEntity::getSystemTypeCode, systemTypeCode);
FireFightingSystemEntity entity = systemService.getOne(queryWrapper);
if (TrueOrFalseEnum.real.value.equalsIgnoreCase(boolValue)) {
// 此方法只针对多条件 与 的逻辑
EquipIndexDto dto = JSONObject.parseObject(paramObj.toString(), EquipIndexDto.class);
String json = null;
try {
json = IOUtils.toString(systemStateIndex.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<Map> mapList = JSONObject.parseArray(json, Map.class);
List<Map> resultList = mapList.stream().filter(x -> systemTypeCode.equalsIgnoreCase(String.valueOf(x.get("typeCode")))).collect(Collectors.toList());
List<EquipIndexDto> indexDtos = new ArrayList<>();
resultList.forEach(x -> {
List<EquipIndexDto> list = JSONArray.parseArray(String.valueOf(x.get("indexVo")), EquipIndexDto.class);
indexDtos.addAll(list);
});
List<EquipIndexDto> list = indexDtos.stream().filter(x -> !dto.getIndexKey().equalsIgnoreCase(String.valueOf(x.getIndexKey()))).collect(Collectors.toList());
boolean flag = Boolean.TRUE;
for (EquipIndexDto o : list) {
// 此处由于测点装备可能不跟系统绑定,所以此处默认取第一个
EquipmentSpecificIndex index = specificIndexSerivce.getOne(new QueryWrapper<EquipmentSpecificIndex>().eq("equipment_index_key", o.getIndexKey()).last("limit 1"));
if(!(o.getIndexKey().equalsIgnoreCase(index.getEquipmentIndexKey()) && o.getIndexValue().equalsIgnoreCase(index.getValue()))) {
flag = Boolean.FALSE;
break;
}
}
if (flag) {
entity.setSystemRunState(runStateCode);
bool = systemService.saveOrUpdate(entity);
}
} else {
entity.setSystemRunState(runStateCode);
bool = systemService.saveOrUpdate(entity);
}
if (bool) {
entity.setIsAlarm(1);
entity.setUUID(UUID.randomUUID().toString());
emqKeeper.getMqttClient().publish(TopicEnum.XFXTYXZT.getTopic(), JSON.toJSONString(entity).getBytes(), 1, false);
}
}
}
package com.yeejoin.equipmanage.listener;
import com.alibaba.fastjson.JSON;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce;
import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage;
......@@ -8,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqxListener;
import java.util.List;
import java.util.Map;
/**
......@@ -20,6 +23,9 @@ public class IntegratePageDataListener extends EmqxListener {
@Autowired
IFireFightingSystemService fireFightingSystemService;
@Autowired
IEquipmentSpecificIndexSerivce equipmentSpecificIndexSerivce;
@Override
public void processMessage(String topic, MqttMessage message) throws Exception {
if(log.isInfoEnabled()){
......@@ -32,7 +38,9 @@ public class IntegratePageDataListener extends EmqxListener {
String code = topic.substring(topic.indexOf(split) + 1);
fireFightingSystemService.integrationPageSysData(code, false);
}
} else if ("EQUIP_INDEX_ON_SYSTEM_DETAIL".equalsIgnoreCase(topic)) {
log.warn(msg.toString());
// List<EquipmentSpecificIndex> list = equipmentSpecificIndexSerivce.listByIds();
}
}
}
......@@ -63,5 +63,6 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
maintenanceResourceDataService.subscribeTopic();
emqKeeper.subscript(ConfigPageTopicEnum.INTEGRATE.getTopic(), 2, integratePageDataListener);
emqKeeper.subscript(ConfigPageTopicEnum.SYSTEMDETAIL.getTopic(), 2, integratePageDataListener);
}
}
......@@ -8,10 +8,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFaultAlarm;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFireAlarm;
import com.yeejoin.equipmanage.common.dto.EquipIndexDto;
import com.yeejoin.equipmanage.common.dto.TemperatureAlarmDto;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
......@@ -30,11 +33,13 @@ import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.utils.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
......@@ -43,13 +48,16 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -154,6 +162,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private IEquipmentService equipmentService;
@Autowired
private IPressurePumpService pressurePumpService;
@Autowired
private RuleTrigger ruleTrigger;
// @Autowired
// private AmosRequestContext amosAuth;
@Value("${equipManage.name}")
private String serverName;
@Value("${state.code:code}")
......@@ -182,6 +194,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private String pressurePumpStart;
@Value("${emergency.disposal.indicators}")
private String emergencyDisposalIndicators;
@Value("classpath:/json/systemStateIndex.json")
private Resource systemStateIndex;
public static List<EquipmentSpecificAlarmLog> upAlarmLogStatus(String iotCode, String equipmentSpecificIndexKey,
String traceId, IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService,
......@@ -1057,6 +1071,27 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
e.printStackTrace();
}
}
//根据指标数据处理预案按钮
String json = null;
try {
json = IOUtils.toString(systemStateIndex.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<Map> mapList = JSONObject.parseArray(json, Map.class);
List<EquipIndexDto> indexDtos = new ArrayList<>();
mapList.forEach(x -> {
List<EquipIndexDto> list = JSONArray.parseArray(String.valueOf(x.get("indexVo")), EquipIndexDto.class);
indexDtos.addAll(list);
});
List<EquipIndexDto> list = indexDtos.stream().filter(x -> iotDataVO.getKey().equalsIgnoreCase(String.valueOf(x.getIndexKey()))).collect(Collectors.toList());
if(0 < list.size()){
EquipIndexDto indexDto = new EquipIndexDto();
indexDto.setIndexKey(iotDataVO.getKey());
indexDto.setIndexValue(value);
systemStateExec(indexDto);
}
}
}
});
......@@ -1167,6 +1202,19 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
}
// 触发规则调用,修改消防系统运行状态
private void systemStateExec(EquipIndexDto indexDto) {
String autoExecPath = "换流站消防专项预案/autoExecuteSystemState";
try {
// RequestContext.setAppKey(amosAuth.getAppKey());
// RequestContext.setProduct(amosAuth.getProduct());
// RequestContext.setToken(amosAuth.getToken());
ruleTrigger.publish(indexDto, autoExecPath, new String[] {});
} catch (Exception e) {
e.printStackTrace();
}
}
private void handlingAlarms(EquipmentSpecificIndex equipmentSpecificIndex, boolean alarmFlag) {
equipmentSpecificIndex.setIsAlarm(1);
equipmentSpecificIndex.setValue(String.valueOf(alarmFlag));
......
......@@ -928,4 +928,15 @@
UPDATE wl_equipment_specific_index esi SET esi.type_code = ( SELECT type_code FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id );
</sql>
</changeSet>
<changeSet author="keyong" id="1697017798">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_fire_fighting_system" columnName="system_run_state"/>
</not>
</preConditions>
<comment>f_fire_fighting_system表新增属性字段system_run_state</comment>
<sql>
ALTER TABLE `f_fire_fighting_system` ADD COLUMN `system_run_state` VARCHAR (10) DEFAULT '1' COMMENT '站端消防系统运行状态 0-停止 1-运行';
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
[
{
"name": "火灾自动报警系统",
"typeCode": "fireAlarmSys",
"code": "011023306003010000000013",
"indexVo": [
{
"indexKey": "FAS_SmokeAlarm_FireAlarm",
"indexValue": "true"
}
]
},
{
"name": "消防给水系统",
"typeCode": "fireWaterSys",
"code": "011023306003010000000068",
"indexVo": [
{
"indexKey": "FAS_SmokeAlarm_Fault",
"indexValue": "true"
},
{
"indexKey": "FAS_SmokeAlarm_Shield",
"indexValue": "true"
}
]
}
]
\ No newline at end of file
......@@ -8,6 +8,12 @@
`fs`.`name` AS `name`,
`fs`.system_type_code AS systemTypeCode,
`fs`.`code` AS code,
CASE
WHEN `fs`.system_run_state = '0' THEN
'停止'
WHEN `fs`.system_run_state = '1' THEN
'运行'
END AS systemRunState,
IF
(((
SELECT
......
......@@ -5896,7 +5896,7 @@
SELECT
COUNT(wlesal.id) AS totalNum,
IFNULL((select COUNT(DISTINCT wl.equipment_specific_id) from wl_equipment_specific_alarm_log wl where
wl.`status` = 1), 0) AS alarmEquipNum,
wl.`status` = 1 AND system_codes LIKE CONCAT('%', #{systemCode}, '%')), 0) AS alarmEquipNum,
IFNULL(SUM(IF(wlesal.clean_time IS NULL,1,0)), 0) AS unClearNum,
IFNULL(SUM(IF(wlesal.confirm_type IS NOT NULL,1,0)), 0) AS handledNum
FROM
......@@ -5904,7 +5904,7 @@
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wlesal.system_ids )
<where>
<if test="systemCode != null and systemCode != ''">
fs.system_type_code = #{systemCode}
fs.code = #{systemCode}
</if>
</where>
</select>
......
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