Commit b3e518f4 authored by KeYong's avatar KeYong

大屏卡片接口

parent 2abef1ac
...@@ -25,6 +25,7 @@ public class OrgMenuDto { ...@@ -25,6 +25,7 @@ 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;
public Boolean getLeaf() { public Boolean getLeaf() {
return ObjectUtils.isEmpty(children); return ObjectUtils.isEmpty(children);
......
...@@ -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));
}
} }
...@@ -678,4 +678,12 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE ...@@ -678,4 +678,12 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
List<Map<String, Object>> selectPressureDetails(@Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> selectPressureDetails(@Param("bizOrgCode") String bizOrgCode);
Map<String, Object> selectEquipmentSpecificById(@Param("id") String id); Map<String, Object> selectEquipmentSpecificById(@Param("id") String id);
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);
} }
...@@ -289,6 +289,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE ...@@ -289,6 +289,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);
...@@ -317,4 +319,9 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE ...@@ -317,4 +319,9 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
*/ */
void resetMorphic(); void resetMorphic();
List<Map<String, String>> getSystemAlarmStatistic(String systemCode);
Map<String, Object> getSystemAlarmTrend(String systemCode, String updateTime);
List<OrgMenuDto> getSystemEquipTree(String systemCode);
} }
...@@ -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;
...@@ -35,6 +34,7 @@ import com.yeejoin.equipmanage.fegin.JcsFeign; ...@@ -35,6 +34,7 @@ import com.yeejoin.equipmanage.fegin.JcsFeign;
import com.yeejoin.equipmanage.mapper.*; import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.remote.RemoteSecurityService; import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*; import com.yeejoin.equipmanage.service.*;
import liquibase.pro.packaged.O;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -61,6 +61,7 @@ import java.net.InetAddress; ...@@ -61,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;
...@@ -2451,4 +2452,101 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -2451,4 +2452,101 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
} }
} }
@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) {
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(bizOrgCode, systemCode);
List<OrgMenuDto> childrenRes = systemAndEquipmentTree(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.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);
}
} }
...@@ -5891,4 +5891,167 @@ ...@@ -5891,4 +5891,167 @@
ORDER BY ORDER BY
dat.updateDate DESC dat.updateDate 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), 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.system_type_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 - 5 DAY ))), INTERVAL @s DAY ), '%Y-%m-%d' ) AS date
FROM
mysql.help_topic,
( SELECT @s := - 1 ) temp
WHERE
@s &lt; 5
) 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>
) UNION
(
SELECT
wes.id,
wes.`name`,
wes.`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>
)
)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,
detail.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