Commit b51b18c5 authored by 李秀明's avatar 李秀明

Merge branch 'develop_dl_3.7.0.9_huaian' into develop_dl

# Conflicts: # amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/FireFightingSystemEntity.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/mapper/FireFightingSystemMapper.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IFireFightingSystemService.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/FireFightingSystemServiceImpl.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java # amos-boot-system-equip/src/main/resources/mapper/FireFightingSystemMapper.xml
parents c7cc8cc3 2b8bd32f
...@@ -25,6 +25,8 @@ public class OrgMenuDto { ...@@ -25,6 +25,8 @@ public class OrgMenuDto {
private List<OrgMenuDto> children; private List<OrgMenuDto> children;
private String bizOrgType; private String bizOrgType;
private String bizOrgCode; private String bizOrgCode;
private Integer num;
private String code;
public Boolean getLeaf() { public Boolean getLeaf() {
return ObjectUtils.isEmpty(children); return ObjectUtils.isEmpty(children);
...@@ -60,6 +62,16 @@ public class OrgMenuDto { ...@@ -60,6 +62,16 @@ public class OrgMenuDto {
this.leaf = leaf; this.leaf = leaf;
} }
public OrgMenuDto(Long key, String title, Long parentId, boolean leaf, String bizOrgCode, String code) {
super();
this.key = key;
this.title = title;
this.parentId = parentId;
this.leaf = leaf;
this.bizOrgCode = bizOrgCode;
this.code = code;
}
public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType) { public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType) {
this.key = key; this.key = key;
this.title = title; this.title = title;
......
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;
}
...@@ -144,4 +144,13 @@ public class FireFightingSystemEntity { ...@@ -144,4 +144,13 @@ public class FireFightingSystemEntity {
@ApiModelProperty(value = "系统状态") @ApiModelProperty(value = "系统状态")
private String systemStatus; private String systemStatus;
@ApiModelProperty("系统运行状态")
private String systemRunState;
@TableField(exist = false)
private Integer isAlarm;
@TableField(exist = false)
private String uUID;
} }
...@@ -14,7 +14,8 @@ import java.util.List; ...@@ -14,7 +14,8 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
public enum ConfigPageTopicEnum { public enum ConfigPageTopicEnum {
INTEGRATE("INTEGRATE_TOPIC/#", "集成页面统配主题"); INTEGRATE("INTEGRATE_TOPIC/#", "集成页面统配主题"),
SYSTEMDETAIL("EQUIP_INDEX_ON_SYSTEM_DETAIL", "系统详情页面大屏初始化主题");
private String topic; private String topic;
......
...@@ -21,7 +21,8 @@ public enum TopicEnum { ...@@ -21,7 +21,8 @@ public enum TopicEnum {
EQXXTJ("fasReportInsertOrUpdate", "设备信号消息统计列表"), EQXXTJ("fasReportInsertOrUpdate", "设备信号消息统计列表"),
ALARM_LOG_INSERT("alarm/log/insert","告警日志插入"), ALARM_LOG_INSERT("alarm/log/insert","告警日志插入"),
IOT_SYSTEM__AlARM("iot-system-alarm", "确警消息"), IOT_SYSTEM__AlARM("iot-system-alarm", "确警消息"),
SHBZYCXH("fasNormalIndexInsertOrUpdate", "四横八纵遥测信号"); SHBZYCXH("fasNormalIndexInsertOrUpdate", "四横八纵遥测信号"),
XFXTYXZT("fasFireSystemRunStateUpdate", "站端消防系统运行状态更新主题");
private String topic; private String topic;
......
...@@ -9,7 +9,7 @@ package com.yeejoin.equipmanage.common.enums; ...@@ -9,7 +9,7 @@ package com.yeejoin.equipmanage.common.enums;
* @date 2020/11/4 19:34 * @date 2020/11/4 19:34
*/ */
public enum TrueOrFalseEnum { public enum TrueOrFalseEnum {
real(0, "true", "是", "进口"),fake(1, "false", "否", "国产"); real(0, "true", "是", "进口", "0"),fake(1, "false", "否", "国产", "1");
public final int name; public final int name;
...@@ -19,10 +19,23 @@ public enum TrueOrFalseEnum { ...@@ -19,10 +19,23 @@ public enum TrueOrFalseEnum {
public final String desc; 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.name = name;
this.value = value; this.value = value;
this.flag = flag; this.flag = flag;
this.desc = desc; 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;
}
} }
} }
...@@ -3,6 +3,7 @@ package com.yeejoin.equipmanage.controller; ...@@ -3,6 +3,7 @@ package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto;
import com.yeejoin.equipmanage.common.utils.CommonPageable; import com.yeejoin.equipmanage.common.utils.CommonPageable;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil; import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.DateUtils; import com.yeejoin.equipmanage.common.utils.DateUtils;
...@@ -150,4 +151,39 @@ public class BigScreenController extends AbstractBaseController { ...@@ -150,4 +151,39 @@ public class BigScreenController extends AbstractBaseController {
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize()); Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(iFireFightingSystemService.getSystemInfo(page, companyCode, null)); return CommonResponseUtil.success(iFireFightingSystemService.getSystemInfo(page, companyCode, null));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "卡片BigSystem报警处理情况统计")
@GetMapping("/statistic/alarm")
public ResponseModel getSystemAlarmStatistic(@RequestParam(value = "systemCode", required = false)String systemCode) {
return CommonResponseUtil.success(iFireFightingSystemService.getSystemAlarmStatistic(systemCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "卡片BigSystem报警趋势统计")
@GetMapping("/statistic/trend")
public ResponseModel getSystemAlarmTrend(@RequestParam(value = "systemCode", required = false)String systemCode,
@RequestParam(value = "updateTime", required = false)String updateTime) {
return CommonResponseUtil.success(iFireFightingSystemService.getSystemAlarmTrend(systemCode, updateTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "卡片BigSystem树接口")
@GetMapping("/system/tree")
public List<OrgMenuDto> getSystemEquipTree(@RequestParam(value = "systemCode")String systemCode) {
return iFireFightingSystemService.getSystemEquipTree(systemCode);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "卡片BigSystem点击树查对应设备")
@GetMapping("/system/equip/page")
public ResponseModel getEquipmentsBySystemInfo(CommonPageable commonPageable, @RequestParam(value = "systemCode",required = false)String systemCode,
@RequestParam(value = "equipmentCode", required = false)String equipmentCode) {
if (commonPageable.getPageNumber() == 0) {
commonPageable.setPageNumber(1);
}
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
return CommonResponseUtil.success(iFireFightingSystemService.getEquipmentsBySystemInfo(page, systemCode, equipmentCode));
}
} }
package com.yeejoin.equipmanage.controller;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
@Slf4j
@RestController
@Api(tags = "装备性能指标API")
@RequestMapping(value = "/equipSpecificIndex")
public class EquipmentSpecificIndexController {
@Autowired
private IEquipmentSpecificIndexSerivce equipmentSpecificIndexService;
@RequestMapping(value = "/detail", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "获取性能指标", notes = "获取性能指标")
public EquipmentSpecificIndex getEquipSpecificIndexDetail(@RequestParam("id") String id) {
return equipmentSpecificIndexService.getById(id);
}
}
...@@ -15,6 +15,7 @@ import com.yeejoin.equipmanage.common.entity.*; ...@@ -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.EquipTypeAmountPageDTO;
import com.yeejoin.equipmanage.common.entity.dto.RequestBaseDto; import com.yeejoin.equipmanage.common.entity.dto.RequestBaseDto;
import com.yeejoin.equipmanage.common.entity.vo.*; 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.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.*; import com.yeejoin.equipmanage.common.vo.*;
...@@ -806,8 +807,14 @@ public class FireFightingSystemController extends AbstractBaseController { ...@@ -806,8 +807,14 @@ public class FireFightingSystemController extends AbstractBaseController {
map1.put("highLight", "true"); map1.put("highLight", "true");
ite.addAll(list1); ite.addAll(list1);
ite.add(map1); 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("items", ite);
res.put("title", "基本信息"); res.put("title", "基本信息");
ite.add(map2);
fireFightingSystem.setSystemRunState("1".equals(fireFightingSystem.getSystemRunState()) ? "运行" : "停止");
Map<String, Object> fireSystem = Bean.BeantoMap(fireFightingSystem); Map<String, Object> fireSystem = Bean.BeantoMap(fireFightingSystem);
fireSystem.put("detailId", fireFightingSystem.getId()); fireSystem.put("detailId", fireFightingSystem.getId());
Map<String, Object> state = new HashMap<>(); 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; package com.yeejoin.equipmanage.listener;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex;
import com.yeejoin.equipmanage.common.enums.ConfigPageTopicEnum;
import com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce;
import com.yeejoin.equipmanage.service.IFireFightingSystemService; import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.sis.util.Static;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.json.JSONString;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener; import org.typroject.tyboot.component.emq.EmqxListener;
import java.util.Map; import java.sql.Time;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/** /**
* @author DELL * @author DELL
...@@ -18,21 +34,54 @@ import java.util.Map; ...@@ -18,21 +34,54 @@ import java.util.Map;
public class IntegratePageDataListener extends EmqxListener { public class IntegratePageDataListener extends EmqxListener {
@Autowired @Autowired
IFireFightingSystemService fireFightingSystemService; IFireFightingSystemService fireFightingSystemService;
@Autowired
IEquipmentSpecificIndexSerivce equipmentSpecificIndexSerivce;
@Autowired
EmqKeeper emqKeeper;
@Override private boolean initialized = Boolean.TRUE;
@Override
public void processMessage(String topic, MqttMessage message) throws Exception { public void processMessage(String topic, MqttMessage message) throws Exception {
if(log.isInfoEnabled()){ if(log.isInfoEnabled()){
log.info("收到消息主题:{},消息内容:{}",topic, message.toString()); log.info("收到消息主题:{},消息内容:{}",topic, message.toString());
} }
Map msg = JSON.parseObject(message.toString()); Map msg = JSON.parseObject(message.toString());
Timer timer = new Timer();
if(msg.containsKey("request")){ if(msg.containsKey("request")){
String split = "/"; String split = "/";
if(topic.contains(split)){ if(topic.contains(split)){
String code = topic.substring(topic.indexOf(split) + 1); String code = topic.substring(topic.indexOf(split) + 1);
fireFightingSystemService.integrationPageSysData(code, false); fireFightingSystemService.integrationPageSysData(code, false);
} }
} else if (ConfigPageTopicEnum.SYSTEMDETAIL.getTopic().equalsIgnoreCase(topic) && initialized) {
if (!ObjectUtils.isEmpty(msg.get("codes"))) {
List<String> list = JSON.parseArray(String.valueOf(msg.get("codes")), String.class);
list.parallelStream().forEach(x -> {
EquipmentSpecificIndex indexEntity = equipmentSpecificIndexSerivce.getById(x);
Map<String, String> map = new HashMap<>();
map.put("code", String.valueOf(indexEntity.getId()));
map.put("value", indexEntity.getValue());
map.put("status", indexEntity.getValue());
try {
emqKeeper.getMqttClient().publish(topic, JSON.toJSONString(map).getBytes(), 1, false);
} catch (MqttException e) {
e.printStackTrace();
}
});
}
initialized = Boolean.FALSE;
} }
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
initialized = Boolean.TRUE;
}
};
timer.schedule(timerTask, 3000);
} }
} }
...@@ -701,4 +701,12 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE ...@@ -701,4 +701,12 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Map<String, Object> getFireWaterInfo(@Param("bizOrgCode") String bizOrgCode); Map<String, Object> getFireWaterInfo(@Param("bizOrgCode") String bizOrgCode);
Page<Map<String, Object>> getWaterInfoPage(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("type") String type, @Param("status") String status); Page<Map<String, Object>> getWaterInfoPage(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("type") String type, @Param("status") String status);
Map<String, String> getSystemAlarmStatistic(@Param("systemCode") String systemCode);
List<Map<String, Object>> getSystemAlarmTrend(@Param("systemCode") String systemCode, @Param("updateTime") String updateTime);
List<Map<String, Object>> getEquipmentAndEquipSpeTree(@Param("bizOrgCode")String bizOrgCode, @Param("systemCode") String systemCode);
Page<Map<String, Object>> getEquipmentsBySystemInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode, @Param("equipmentCode") String equipmentCode);
} }
...@@ -297,6 +297,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE ...@@ -297,6 +297,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Page<Map<String, Object>> getSystemInfo(Page page, String companyCode, String systemCode); Page<Map<String, Object>> getSystemInfo(Page page, String companyCode, String systemCode);
Page<Map<String, Object>> getEquipmentsBySystemInfo(Page page, String companyCode, String systemCode);
List<Map<String, Object>> getEquipExpiryStatistics(String bizOrgCode, Integer expiryDayNum); List<Map<String, Object>> getEquipExpiryStatistics(String bizOrgCode, Integer expiryDayNum);
Page<Map<String, String>> getEquipExpiryListByPage(String bizOrgCode, Integer expiryDayNum, Page page); Page<Map<String, String>> getEquipExpiryListByPage(String bizOrgCode, Integer expiryDayNum, Page page);
...@@ -318,7 +320,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE ...@@ -318,7 +320,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Map<String, Object> getStationConnectStatus(); Map<String, Object> getStationConnectStatus();
List<Map<String, Object>> getStationStatusStatistics(); List<Map<String, Object>> getStationStatusStatistics();
/** /**
* 重置画布 * 重置画布
* *
...@@ -332,4 +334,9 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE ...@@ -332,4 +334,9 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Page<Map<String, Object>> getWaterInfoPage(Page<Map<String, Object>> page, String bizOrgCode, String type, String status); Page<Map<String, Object>> getWaterInfoPage(Page<Map<String, Object>> page, String bizOrgCode, String type, String status);
List<Map<String, String>> getSystemAlarmStatistic(String systemCode);
Map<String, Object> getSystemAlarmTrend(String systemCode, String updateTime);
List<OrgMenuDto> getSystemEquipTree(String systemCode);
} }
...@@ -63,5 +63,6 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -63,5 +63,6 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
maintenanceResourceDataService.subscribeTopic(); maintenanceResourceDataService.subscribeTopic();
emqKeeper.subscript(ConfigPageTopicEnum.INTEGRATE.getTopic(), 2, integratePageDataListener); emqKeeper.subscript(ConfigPageTopicEnum.INTEGRATE.getTopic(), 2, integratePageDataListener);
emqKeeper.subscript(ConfigPageTopicEnum.SYSTEMDETAIL.getTopic(), 2, integratePageDataListener);
} }
} }
...@@ -3,7 +3,6 @@ package com.yeejoin.equipmanage.service.impl; ...@@ -3,7 +3,6 @@ package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -62,6 +61,7 @@ import java.net.InetAddress; ...@@ -62,6 +61,7 @@ import java.net.InetAddress;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -2494,4 +2494,135 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -2494,4 +2494,135 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
public Page<Map<String, Object>> getWaterInfoPage(Page<Map<String, Object>> page, String bizOrgCode, String type, String status) { public Page<Map<String, Object>> getWaterInfoPage(Page<Map<String, Object>> page, String bizOrgCode, String type, String status) {
return fireFightingSystemMapper.getWaterInfoPage(page, bizOrgCode, type, status); return fireFightingSystemMapper.getWaterInfoPage(page, bizOrgCode, type, status);
} }
@Override
public List<Map<String, String>> getSystemAlarmStatistic(String systemCode) {
Map<String, String> map = fireFightingSystemMapper.getSystemAlarmStatistic(systemCode);
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> entryMap = new HashMap<>();
entryMap.put("key", "1");
entryMap.put("type", "unClear");
entryMap.put("name", "未消除");
entryMap.put("value", map.get("unClearNum"));
entryMap.put("unit", "");
list.add(entryMap);
Map<String, String> entryMap1 = new HashMap<>();
entryMap1.put("key", "2");
entryMap1.put("type", "handled");
entryMap1.put("name", "已处理");
entryMap1.put("value", map.get("handledNum"));
entryMap1.put("unit", "");
list.add(entryMap1);
Map<String, String> entryMap2 = new HashMap<>();
entryMap2.put("key", "3");
entryMap2.put("type", "alarmTotal");
entryMap2.put("name", "报警总数");
entryMap2.put("value", map.get("totalNum"));
entryMap2.put("unit", "");
list.add(entryMap2);
Map<String, String> entryMap3 = new HashMap<>();
entryMap3.put("key", "4");
entryMap3.put("type", "faultEquip");
entryMap3.put("name", "故障设备");
entryMap3.put("value", map.get("alarmEquipNum"));
entryMap3.put("unit", "");
list.add(entryMap3);
return list;
}
@Override
public Map<String, Object> getSystemAlarmTrend(String systemCode, String updateTime) {
if(!StringUtil.isNotEmpty(updateTime)) {
updateTime = new SimpleDateFormat(DateUtils.DATE_PATTERN).format(new Date());
}
List<Map<String, Object>> result = fireFightingSystemMapper.getSystemAlarmTrend(systemCode, updateTime);
Map<String, Object> resMap = new HashMap<>();
resMap.put("xAxisData", result.stream().map(x -> x.get("date")).collect(Collectors.toList()));
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> entryMap1 = new HashMap<>();
entryMap1.put("name", "正常");
entryMap1.put("data", result.stream().map(x -> x.get("normalNum")).collect(Collectors.toList()));
list.add(entryMap1);
Map<String, Object> entryMap2 = new HashMap<>();
entryMap2.put("name", "故障");
entryMap2.put("data", result.stream().map(x -> x.get("faultNum")).collect(Collectors.toList()));
list.add(entryMap2);
Map<String, Object> entryMap3 = new HashMap<>();
entryMap3.put("name", "告警");
entryMap3.put("data", result.stream().map(x -> x.get("alarmNum")).collect(Collectors.toList()));
list.add(entryMap3);
resMap.put("yAxisData", list);
return resMap;
}
@Override
public List<OrgMenuDto> getSystemEquipTree(String systemCode) {
// 此卡片在站端使用,由于远程调用jcs耗时,所以暂注释掉
// FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(authKey, "COMPANY", "dl");
// String bizOrgCode = feignClientResult.getResult().get(0).getBizOrgCode();
List<OrgMenuDto> resList = new ArrayList<>();
List<Map<String, Object>> list = fireFightingSystemMapper.getEquipmentAndEquipSpeTree(null, systemCode);
List<OrgMenuDto> childrenRes = systemAndEquipmentTreeNew(list);
OrgMenuDto dto = new OrgMenuDto();
FireFightingSystemEntity entity = fireFightingSystemMapper.selectOne(new QueryWrapper<FireFightingSystemEntity>().eq("code", systemCode));
dto.setKey(entity.getId());
dto.setValue(entity.getId());
dto.setTitle(entity.getName());
dto.setName(entity.getName());
dto.setParentId(0L);
dto.setIsLeaf(false);
dto.setLeaf(false);
dto.setBizOrgCode(entity.getBizOrgCode());
dto.setBizOrgType(systemCode);
if (0 < list.size()) {
childrenRes = childrenRes.stream().map(x -> {
x.setParentId(entity.getId());
x.setIsLeaf(true);
x.setLeaf(true);
x.setNum(x.getChildren().size() > 0 ? x.getChildren().size() : 0);
return x;
}).collect(Collectors.toList());
}
dto.setChildren(childrenRes);
resList.add(dto);
return resList;
}
@Override
public Page<Map<String, Object>> getEquipmentsBySystemInfo(Page page, String systemCode, String equipmentCode) {
// FeignClientResult<List<OrgUsrDto>> feignClientResult = jcsFeignClient.getCompanyDeptListWithAuth(authKey, "COMPANY", "dl");
// String bizOrgCode = feignClientResult.getResult().get(0).getBizOrgCode();
return fireFightingSystemMapper.getEquipmentsBySystemInfo(page, null, systemCode, equipmentCode);
}
public static List<OrgMenuDto> systemAndEquipmentTreeNew(List<Map<String,Object>> list) {
List<OrgMenuDto> menuList = list.stream()
.map(o -> new OrgMenuDto(Long.parseLong(o.get("id").toString()), o.get("name").toString(),
ObjectUtils.isEmpty(o.get("parentId")) ? 0L : Long.parseLong(o.get("parentId").toString()),
false, o.get("bizOrgCode").toString(), ObjectUtils.isEmpty(o.get("code")) ? "": o.get("code").toString()))
.collect(Collectors.toList());
List<OrgMenuDto> result = new ArrayList<>();
Map<Long, OrgMenuDto> map = new HashMap<>(menuList.size());
menuList.forEach(e -> map.put(e.getKey(), e));
Set<? extends Map.Entry<Long, ? extends OrgMenuDto>> entries = map.entrySet();
// 此处多线程,会value 出现null 的情况
// entries.parallelStream().forEach(entry -> {
entries.forEach(entry -> {
OrgMenuDto value = entry.getValue();
if (value != null) {
OrgMenuDto treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<OrgMenuDto> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
result.add(value);
}
}
});
return result;
}
} }
...@@ -14,6 +14,7 @@ import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm; ...@@ -14,6 +14,7 @@ import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFaultAlarm; import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFaultAlarm;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFireAlarm; import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentFireAlarm;
import com.yeejoin.equipmanage.common.dto.TemperatureAlarmDto; import com.yeejoin.equipmanage.common.dto.TemperatureAlarmDto;
import com.yeejoin.equipmanage.common.dto.EquipIndexDto;
import com.yeejoin.equipmanage.common.entity.*; import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.EquipQrDateDto; import com.yeejoin.equipmanage.common.entity.dto.EquipQrDateDto;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity; import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
...@@ -32,12 +33,14 @@ import com.yeejoin.equipmanage.remote.RemoteSecurityService; ...@@ -32,12 +33,14 @@ import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*; import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.utils.BeanUtil; import com.yeejoin.equipmanage.utils.BeanUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronization;
...@@ -46,13 +49,16 @@ import org.springframework.util.CollectionUtils; ...@@ -46,13 +49,16 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; 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.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -168,7 +174,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -168,7 +174,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Autowired @Autowired
private ManufacturerInfoMapper manufacturerInfoMapper; private ManufacturerInfoMapper manufacturerInfoMapper;
// @Autowired
// private AmosRequestContext amosAuth;
@Value("${equipManage.name}") @Value("${equipManage.name}")
private String serverName; private String serverName;
@Value("${state.code:code}") @Value("${state.code:code}")
...@@ -207,6 +214,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -207,6 +214,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private String pressurePumpStart; private String pressurePumpStart;
@Value("${emergency.disposal.indicators}") @Value("${emergency.disposal.indicators}")
private String emergencyDisposalIndicators; private String emergencyDisposalIndicators;
@Value("classpath:/json/systemStateIndex.json")
private Resource systemStateIndex;
public static List<EquipmentSpecificAlarmLog> upAlarmLogStatus(String iotCode, String equipmentSpecificIndexKey, public static List<EquipmentSpecificAlarmLog> upAlarmLogStatus(String iotCode, String equipmentSpecificIndexKey,
String traceId, IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService, String traceId, IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService,
...@@ -1030,6 +1039,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1030,6 +1039,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
indexStateList.add(createIndexStateVo(equipmentSpeIndex)); indexStateList.add(createIndexStateVo(equipmentSpeIndex));
// 推送数据到组态大屏
pushDataToIntegrationPage(equipmentSpecificIndexList);
// 添加指标报告 // 添加指标报告
saveEquipmentAlarmReportDay(equipmentSpeIndex); saveEquipmentAlarmReportDay(equipmentSpeIndex);
...@@ -1110,6 +1122,27 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1110,6 +1122,27 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
e.printStackTrace(); 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);
}
} }
} }
}); });
...@@ -1224,6 +1257,19 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1224,6 +1257,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) { private void handlingAlarms(EquipmentSpecificIndex equipmentSpecificIndex, boolean alarmFlag) {
equipmentSpecificIndex.setIsAlarm(1); equipmentSpecificIndex.setIsAlarm(1);
equipmentSpecificIndex.setValue(String.valueOf(alarmFlag)); equipmentSpecificIndex.setValue(String.valueOf(alarmFlag));
...@@ -2602,4 +2648,15 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -2602,4 +2648,15 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
} }
} }
private void pushDataToIntegrationPage(List<EquipmentSpecificIndex> specificIndices) {
for (EquipmentSpecificIndex specificIndex : specificIndices) {
JSONObject message = new JSONObject() {{
put("code", String.valueOf(specificIndex.getId()));
put("status", specificIndex.getValue());
put("value", specificIndex.getValue());
}};
mqttSendGateway.sendToMqtt(ConfigPageTopicEnum.SYSTEMDETAIL.getTopic(), message.toJSONString());
}
}
} }
...@@ -1000,4 +1000,15 @@ ...@@ -1000,4 +1000,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 ); 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> </sql>
</changeSet> </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> </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 @@ ...@@ -8,6 +8,12 @@
`fs`.`name` AS `name`, `fs`.`name` AS `name`,
`fs`.system_type_code AS systemTypeCode, `fs`.system_type_code AS systemTypeCode,
`fs`.`code` AS code, `fs`.`code` AS code,
CASE
WHEN `fs`.system_run_state = '0' THEN
'停止'
WHEN `fs`.system_run_state = '1' THEN
'运行'
END AS systemRunState,
IF IF
((( (((
SELECT SELECT
......
...@@ -6072,4 +6072,169 @@ ...@@ -6072,4 +6072,169 @@
ORDER BY ORDER BY
spe.equip_status desc spe.equip_status desc
</select> </select>
<select id="getSystemAlarmStatistic" resultType="Map">
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 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
wl_equipment_specific_alarm_log wlesal
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wlesal.system_ids )
<where>
<if test="systemCode != null and systemCode != ''">
fs.code = #{systemCode}
</if>
</where>
</select>
<select id="getSystemAlarmTrend" resultType="Map">
SELECT
s1.date,
IFNULL( s2.normalNum, 0 ) AS normalNum,
IFNULL( s2.faultNum, 0 ) AS faultNum,
IFNULL( s2.alarmNum, 0 ) AS alarmNum
FROM
(
SELECT
@s := @s + 1 AS `index`,
DATE_FORMAT( DATE_ADD(( DATE( DATE_ADD(#{updateTime}, INTERVAL - 6 DAY ))), INTERVAL @s DAY ), '%Y-%m-%d' ) AS date
FROM
mysql.help_topic,
( SELECT @s := - 1 ) temp
WHERE
@s &lt; 6
) s1
LEFT JOIN (
SELECT
s.*
FROM
(
SELECT
IFNULL(SUM(IF(r.`status` = 0, 1, 0)), 0) AS normalNum,
IFNULL(SUM(IF((r.type = 'BREAKDOWN' AND r.`status` = 1), 1, 0)), 0) AS faultNum,
IFNULL(SUM(IF((r.type = 'FIREALARM' AND r.`status` = 1), 1, 0)), 0) AS alarmNum,
DATE_FORMAT( r.update_date, '%Y-%m-%d') AS date
FROM
wl_equipment_specific_alarm_log r
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, r.system_ids )
<where>
r.update_date BETWEEN date_sub( now(), INTERVAL 6 MONTH ) AND now()
<if test="systemCode != null and systemCode != ''">
AND fs.system_type_code = #{systemCode}
</if>
</where>
GROUP BY
LEFT ( r.update_date, 10 )
ORDER BY
r.update_date
) s
) s2 ON s2.date = s1.date
GROUP BY
s1.date
ORDER BY
s1.date
</select>
<select id="getEquipmentAndEquipSpeTree" resultType="java.util.Map">
SELECT
a.id,
a.`name`,
a.code,
a.sort,
substring_index(
substring_index(
a.parentId,
',',
b.help_topic_id + 1
),
',' ,- 1
) AS parentId,
a.bizOrgCode
FROM
(
(
SELECT
wle.`id`,
wle.`name`,
wle.`code`,
sort,
'' parentId,
wes.biz_org_code bizOrgCode
FROM
wl_equipment_specific wes
JOIN wl_equipment_detail AS det ON wes.equipment_detail_id = det.id
JOIN wl_equipment AS wle ON wle.id = det.equipment_id
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET(fs.id, wes.system_id)
<where>
<if test="bizOrgCode!=null and bizOrgCode!=''">
wes.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
<if test="systemCode != null and systemCode != ''">
AND fs.`code` = #{systemCode}
</if>
</where>
) UNION
(
SELECT
wes.id,
wes.`name`,
wle.`code`,
0,
wle.id AS parentId,
wes.biz_org_code bizOrgCode
FROM
wl_equipment_specific wes
LEFT JOIN wl_equipment_detail AS det ON wes.equipment_detail_id = det.id
LEFT JOIN wl_equipment AS wle ON wle.id = det.equipment_id
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET(fs.id, wes.system_id)
<where>
<if test="bizOrgCode!=null and bizOrgCode!=''">
wes.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
<if test="systemCode != null and systemCode != ''">
AND fs.`code` = #{systemCode}
</if>
</where>
)
)a
JOIN mysql.help_topic b ON b.help_topic_id &lt; (
length(a.parentId) - length(
REPLACE (a.parentId, ',', '')
) + 1
)
ORDER BY parentId, sort
</select>
<select id="getEquipmentsBySystemInfo" resultType="java.util.Map">
SELECT
spec.id,
spec.`name`,
spec.position,
CASE
spec.equip_status
WHEN '0' THEN
'正常'
ELSE '异常'
END AS equipStatus,
IFNULL(detail.standard, '') AS standard
FROM
wl_equipment_specific spec
JOIN wl_equipment_detail detail ON spec.equipment_detail_id = detail.id
JOIN wl_equipment equipment ON equipment.id =detail.equipment_id
LEFT JOIN f_fire_fighting_system s on FIND_IN_SET(s.id, spec.system_id)
<where>
<if test="bizOrgCode!=null and bizOrgCode!=''">
wes.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
<if test="systemCode != null and systemCode != ''">
AND s.`code` = #{systemCode}
</if>
<if test="equipmentCode != null and equipmentCode != ''">
AND spec.equipment_code = #{equipmentCode}
</if>
</where>
</select>
</mapper> </mapper>
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