Commit efd5844a authored by KeYong's avatar KeYong

增加告警、水池液位及修改其他接口

parent b9fe2a7c
package com.yeejoin.equipmanage.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
/**
* @author keyong
* @title: AlarmStatisticController
* <pre>
* @description: TODO
* </pre>
* @date 2024/7/31 19:33
*/
@RestController
@Api(tags = "中心告警统计Api")
@RequestMapping(value = "/center/alarm", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AlarmStatisticController extends AbstractBaseController {
@Autowired
IEmergencyService iEmergencyService;
@Autowired
private IFireFightingSystemService iFireFightingSystemService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/CAFS/cannon", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取消防炮统计信息", notes = "获取消防炮统计信息")
public ResponseModel getFireCannonInfo(@RequestParam(required = false) String bizOrgCode) {
List<Map<String, Object>> list = iFireFightingSystemService.getFireCannonInfo(bizOrgCode);
return CommonResponseUtil.success(list);
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/alarmList")
@ApiOperation(httpMethod = "GET", value = "消防告警信息", notes = "消防告警信息")
public ResponseModel alarmList(@RequestParam Integer pageNumber,
@RequestParam Integer pageSize,
@RequestParam(required = false) List<String> types,
@RequestParam(required = false) List<String> emergencyLevels,
@RequestParam(required = false) String name,
@RequestParam(required = false) Integer cleanStatus,
@RequestParam(required = false) Integer handleStatus,
@RequestParam(required = false) String bizOrgCode,
@RequestParam(required = false) String systemCode,
@RequestParam(required = false) String createDate,
@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate
) {
Page<Map<String, Object>> page = new Page<>(pageNumber, pageSize);
if (StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(page);
}
}
}
return CommonResponseUtil.success(iEmergencyService.alarmList(page, bizOrgCode, systemCode, types, emergencyLevels, name, cleanStatus, handleStatus, createDate, startDate, endDate));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "报警趋势统计")
@GetMapping("/statistic/trend")
public ResponseModel getSystemAlarmTrend(@RequestParam(value = "systemCode", required = false)String systemCode,
@RequestParam(value = "updateTime", required = false)String updateTime) {
return CommonResponseUtil.success(iFireFightingSystemService.getCenterSystemAlarmTrend(systemCode, updateTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "系统告警事件数量占比")
@GetMapping("/num")
public ResponseModel getSystemAlarmNum(@RequestParam(value = "bizOrgCode", required = false)String bizOrgCode) {
return CommonResponseUtil.success(iFireFightingSystemService.getSystemAlarmNum(bizOrgCode));
}
}
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.utils.CommonPageable;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.UnitTransformUtil;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -19,14 +23,21 @@ 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.foundation.utils.DateTimeUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static org.typroject.tyboot.core.foundation.context.RequestContext.*;
import static org.typroject.tyboot.core.foundation.utils.DateTimeUtil.ISO8601_DATE_HOUR_MIN_SEC;
/**
* @author keyong
* @title: PoolStatisticController
......@@ -43,6 +54,9 @@ public class PoolStatisticController {
@Autowired
private FireFightingSystemMapper fireFightingSystemMapper;
@Autowired
private IotFeign iotFeign;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/panel/statistic", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取水池统计信息", notes = "获取水池统计信息")
......@@ -172,7 +186,7 @@ public class PoolStatisticController {
Map<String, Object> abNormalMap = new HashMap<>();
abNormalMap.put("key", "normal");
abNormalMap.put("name", "液位异常");
abNormalMap.put("value", normalList.size());
abNormalMap.put("value", abNormalList.size());
List<Map<String, Object>> res = new ArrayList<>();
res.add(normalMap);
res.add(abNormalMap);
......@@ -188,7 +202,8 @@ public class PoolStatisticController {
List<Map<String, Object>> gt4000 = new ArrayList<>();
if (!CollectionUtils.isEmpty(infoList)) {
for (Map<String, Object> m : infoList) {
if (4000 > Integer.valueOf(String.valueOf(m.get("allVolume")))) {
int result = new BigDecimal(4000).compareTo(new BigDecimal(String.valueOf(m.get("allVolume"))));
if (0 < result) {
lt4000.add(m);
} else {
gt4000.add(m);
......@@ -225,7 +240,8 @@ public class PoolStatisticController {
for (Map<String, Object> m : res) {
List<Map<String, Object>> list = infoList.stream().filter(x -> String.valueOf(x.get("bizOrgName")).equals(m.get("bizOrgName"))).collect(Collectors.toList());
String allVolume = String.valueOf(list.get(0).get("allVolume"));
m.put("eligibility", Integer.valueOf(allVolume) < 4000 ? "1" : "0");
int result = new BigDecimal(4000).compareTo(new BigDecimal(allVolume));
m.put("eligibility", result < 0 ? "1" : "0");
Map<String, Object> transResult = UnitTransformUtil.transformValues(String.valueOf(m.get("nowLevel")),
String.valueOf(m.get("unit")), String.valueOf(m.get("minLevel")), String.valueOf(m.get("maxLevel")));
m.put("nowLevel", transResult.get("nowValue"));
......@@ -265,4 +281,88 @@ public class PoolStatisticController {
}
return CommonResponseUtil.success(page1);
}
@PersonIdentify
@RequestMapping(value = "/selectWaterLevelDetail", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "水池液位详情", produces = "application/json;charset=UTF-8", notes = "水池液位详情")
public ResponseModel selectWaterLevelDetail(@RequestParam(value = "equipmentSpecificId") String equipmentSpecificId,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime
) throws ParseException {
if (!StringUtil.isNotEmpty(equipmentSpecificId)) {
return CommonResponseUtil.success();
}
Map<String, Object> map = fireFightingSystemMapper.selectEquipmentSpecificById(equipmentSpecificId);
String name = "";
String code = "";
if (String.valueOf(map.get("equipment_code")).indexOf("92011100") != -1) {
name = "水池液位";
code = "scyw";
} else {
return CommonResponseUtil.failure("不是水池设备,请检查!");
}
if (ObjectUtils.isEmpty(map) || ObjectUtils.isEmpty(map.get("iot_code"))) {
return CommonResponseUtil.success(null);
}
String iotCode = map.get("iot_code").toString();
String prefix = null;
String suffix = null;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel mounthEntity = null;
try {
mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startTime, endTime, prefix, suffix, "FHS_FirePoolDevice_WaterLevel");
} catch (Exception e) {
e.printStackTrace();
}
List<Map<String, String>> result = new ArrayList<>();
if (200 == mounthEntity.getStatus()) {
String json1 = JSON.toJSONString(mounthEntity.getResult());
List<Map<String, String>> list = (List<Map<String, String>>) JSONArray.parse(json1);
Collections.reverse(list);
if (!CollectionUtils.isEmpty(list)) {
result.addAll(list);
}
}
List<Map<String, String>> res = new ArrayList<>();
for (Map<String, String> m : result) {
Map<String, String> item = new HashMap<>();
item.put("time", change(String.valueOf(m.get("time"))));
for (String s : m.keySet()) {
if (!s.equals("time")) {
item.put("value", m.get(s));
item.remove(s);
continue;
}
}
res.add(item);
}
Map<String, Object> map1 = new HashMap<>();
map1.put("name", name);
map1.put("xData", res.stream().map(x -> x.get("time")).collect(Collectors.toList()));
map1.put("yData", res.stream().map(x -> x.get("value")).collect(Collectors.toList()));
Map<String, Object> resMap = new HashMap<>();
resMap.put(code, map1);
return CommonResponseUtil.success(resMap);
}
private String change(String time) {
//进行转化时区
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
Date date1 = null;
try {
String strDate = time.substring(0, 19);
SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
date1 = sdf.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}
return DateTimeUtil.format(date1, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
}
}
......@@ -82,4 +82,5 @@ public class SystemStatisticController extends AbstractBaseController {
Map<String, Object> map = fireFightingSystemMapper.getIotInfo(bizOrgCode);
return CommonResponseUtil.success(map);
}
}
......@@ -764,4 +764,8 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Map<String, Object> getIotInfo(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getFireCannonInfo(@Param("bizOrgCode") String bizOrgCode, @Param("list") String[] strings);
List<Map<String, Object>> getSystemAlarmNum(@Param("bizOrgCode") String bizOrgCode);
}
......@@ -350,7 +350,13 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Map<String, Object> getSystemAlarmTrend(String systemCode, String updateTime);
Map<String, Object> getCenterSystemAlarmTrend(String systemCode, String updateTime);
List<Map<String, Object>> getFireCannonInfo(String bizOrgCode);
Map<String, Object> getSystemAlarmTrendForSbpt(String systemCode, String updateTime);
List<OrgMenuDto> getSystemEquipTree(String systemCode);
List<Map<String, Object>> getSystemAlarmNum(String bizOrgCode);
}
......@@ -182,6 +182,8 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
private String equipTypeAndCount;
@Value("${auth-key-auth-enabled:}")
private String authKeyAuthEnabled;
@Value("${equipment.plan.monitor}")
String monitorCodes;
@Autowired
@Lazy
......@@ -2783,6 +2785,38 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
@Override
public Map<String, Object> getCenterSystemAlarmTrend(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("shieldNum")).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<Map<String, Object>> getFireCannonInfo(String bizOrgCode) {
String[] strings = monitorCodes.split(",");
List<Map<String, Object>> list = fireFightingSystemMapper.getFireCannonInfo(bizOrgCode, strings);
return Optional.ofNullable(list).orElse(org.apache.commons.compress.utils.Lists.newArrayList());
}
@Override
public Map<String, Object> getSystemAlarmTrendForSbpt(String systemCode, String updateTime) {
if(!StringUtil.isNotEmpty(updateTime)) {
updateTime = new SimpleDateFormat(DateUtils.DATE_PATTERN).format(new Date());
......@@ -2841,6 +2875,11 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
@Override
public List<Map<String, Object>> getSystemAlarmNum(String bizOrgCode) {
return fireFightingSystemMapper.getSystemAlarmNum(bizOrgCode);
}
@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();
......
......@@ -1415,6 +1415,7 @@
<select id="alarmList" resultType="java.util.Map">
SELECT
wlesal.id,
wlesal.biz_org_name AS bizOrgName,
concat(wlesal.equipment_specific_name, wlesal.equipment_specific_index_name) AS alamContent,
IF (wlesal.confirm_type IS NULL, '未确认', '已确认') handleStatus,
IF (wlesal.clean_time IS NOT NULL, '已消除', '未消除' ) cleanStatus,
......
......@@ -6667,9 +6667,9 @@
<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
IFNULL( s2.alarmNum, 0 ) AS alarmNum,
IFNULL( s2.faultNum, 0 ) AS shieldNum
FROM
(
SELECT
......@@ -6690,6 +6690,7 @@
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,
IFNULL(SUM(IF((r.type = 'SHIELD' AND r.`status` = 1), 1, 0)), 0) AS shieldNum,
DATE_FORMAT( r.update_date, '%Y-%m-%d') AS date
FROM
wl_equipment_specific_alarm_log r
......@@ -7000,4 +7001,41 @@
) AS indexMonitorNum
)
</select>
<select id="getFireCannonInfo" resultType="Map">
SELECT
wes.id,
wes.name,
CASE WHEN wesi.equipment_index_key = 'CAFS_GunValve_Open' AND wesi.`value` = 'true' THEN '开启'
WHEN wesi.equipment_index_key = 'CAFS_GunValve_Close' AND wesi.`value` = 'true' THEN '关闭' ELSE '关闭' END AS stateValue,
CASE WHEN wesi.equipment_index_key = 'CAFS_CAFSFireGun_FireGunPressure' THEN wesi.`value` END AS `pressureValue`
FROM
wl_equipment_specific wes
LEFT JOIN wl_equipment_specific_index wesi ON wesi.equipment_specific_id = wes.id
<where>
<if test="list != null and list.length > 0">
<foreach collection="list" item="item" index="index" open="(" close=")" separator="OR">
wes.equipment_code LIKE <![CDATA[CONCAT(#{item},'%')]]>
</foreach>
</if>
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND wes.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
</where>
</select>
<select id="getSystemAlarmNum" resultType="Map">
SELECT
wlesal.id AS `key`,
SUM(IF( wlesal.`status` = 1, 1, 0 )) AS `value`,
fs.name AS `name`
FROM
wl_equipment_specific_alarm_log wlesal
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wlesal.system_ids ) <![CDATA[<>]]> 0
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND wlesal.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
GROUP BY fs.system_type_code
</select>
</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