Commit 7ee0d0f4 authored by 张森's avatar 张森

29048 关键数据---排油系统后端开发

parent 2929f340
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.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 = "/keyWordsInfo", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class KeyWordsInfoController extends AbstractBaseController {
@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);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "查询已绑定排油阀的换流变信息", notes = "查询已绑定排油阀的换流变信息")
@RequestMapping(value = "/getFEquipInfoList", method = RequestMethod.GET)
public ResponseModel getFEquipInfoList(@RequestParam(required = false) String bizOrgCode) {
List<Map<String, Object>> resultList = iFireFightingSystemService.getFEquipInfoList(bizOrgCode);
return CommonResponseUtil.success(resultList);
}
}
......@@ -733,4 +733,11 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Page<Map<String, Object>> getEquipmentsBySystemInfo(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("systemCode") String systemCode, @Param("equipmentCode") String equipmentCode);
Map<String, Object> getEquipStats(@Param("bizOrgCode") String bizOrgCode, @Param("list") List<String> list);
List<Map<String, Object>> getFireCannonInfo(@Param("bizOrgCode") String bizOrgCode, @Param("list") String[] strings);
List<Map<String, Object>> getFEquipInfoList(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getEquipIndexList(@Param("collect") List<String> collect);
}
......@@ -353,4 +353,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Map<String, Object> getSystemAlarmTrendForSbpt(String systemCode, String updateTime);
List<OrgMenuDto> getSystemEquipTree(String systemCode);
List<Map<String, Object>> getFireCannonInfo(String bizOrgCode);
List<Map<String, Object>> getFEquipInfoList(String bizOrgCode);
}
package com.yeejoin.equipmanage.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -181,6 +184,8 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
@Lazy
IWlCarMileageService iWlCarMileageService;
@Value("${equipment.plan.monitor}")
String monitorCodes;
@Autowired
private UnitMapper unitMapper;
......@@ -2873,4 +2878,59 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
});
return result;
}
@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 List<Map<String, Object>> getFEquipInfoList(String bizOrgCode) {
List<Map<String, Object>> list = this.baseMapper.getFEquipInfoList(bizOrgCode);
ArrayList<String> strings = new ArrayList<>();
list.forEach(item -> {
String equipIds = item.get("equipIds").toString();
strings.addAll(Arrays.asList(equipIds.split(",")));
});
List<String> collect = strings.stream().distinct().collect(Collectors.toList());
List<Map<String, Object>> equipIndexList = this.baseMapper.getEquipIndexList(collect);
Map<String, Map<String, Object>> equipmentSpecificId = equipIndexList.stream().collect(Collectors.toMap(item -> item.get("equipmentSpecificId").toString(), item -> item));
List<Map<String, Object>> resultList = new ArrayList<>();
list.forEach(item -> {
int isOpen = 0;
Date updateDate = null;
String equipIds = item.get("equipIds").toString();
String[] equipIdList = equipIds.split(",");
for (String index : equipIdList) {
if (ObjectUtil.isNotEmpty(equipmentSpecificId)
&& equipmentSpecificId.containsKey(index)
&& equipmentSpecificId.get(index).containsKey("equipmentIndexKey")
&& equipmentSpecificId.get(index).get("equipmentIndexKey").toString().equals("ONL_DrainOilValve_Open")) {
Map<String, Object> map = equipmentSpecificId.get(index);
isOpen = 1;
if (updateDate == null) {
updateDate = DateUtil.parse(map.get("updateDate").toString(), DatePattern.UTC_SIMPLE_PATTERN);
} else {
int comparisonResult = DateUtil.compare(updateDate, DateUtil.parse(map.get("updateDate").toString(), DatePattern.UTC_SIMPLE_PATTERN));
updateDate = comparisonResult < 0 ? DateUtil.parse(map.get("updateDate").toString(), DatePattern.UTC_SIMPLE_PATTERN) : updateDate;
}
}
}
HashMap<String, Object> resultMap = new HashMap<>();
if (isOpen == 1) {
resultMap.put("startStatus", item.get("name").toString() + "开启");
resultMap.put("drainDuration", item.get("drainDuration"));
resultMap.put("updateDate", updateDate);
resultList.add(resultMap);
}
});
HashMap<String, Object> closeMap = new HashMap<>();
closeMap.put("startStatus", "关闭");
closeMap.put("updateDate", "--");
closeMap.put("drainDuration", "");
List<Map<String, Object>> closeList = Collections.singletonList(closeMap);
return CollUtil.isNotEmpty(resultList) ? resultList : closeList;
}
}
......@@ -6630,4 +6630,69 @@
AND wed.equipment_name is not null
</where>
</select>
<select id="getFireCannonInfo" resultType="Map">
SELECT
DISTINCT 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,
IFNULL(CASE WHEN wesi.equipment_index_key = 'CAFS_CAFSFireGun_FireGunPressure' THEN IFNULL(wesi.`value`, 0) END, 0) 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="getFEquipInfoList" resultType="java.util.Map">
SELECT
a.id,
a.drain_duration AS drainDuration,
a.`code` AS `code`,
a.`name` AS `name`,
GROUP_CONCAT( c.id ) AS equipIds
FROM
f_equipment a
LEFT JOIN f_equipment_fire_equipment b ON b.equipment_id = a.id
LEFT JOIN wl_equipment_specific c ON b.fire_equipment_id = c.id and LEFT ( c.equipment_code, 8 ) = '92100400'
<where>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND c.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</where>
GROUP BY
a.id
HAVING
equipIds IS NOT NULL
AND equipIds != ''
</select>
<select id="getEquipIndexList" resultType="java.util.Map">
SELECT
equipment_specific_id AS equipmentSpecificId,
update_date AS updateDate,
equipment_index_key AS equipmentIndexKey
FROM
wl_equipment_specific_index
WHERE
equipment_index_key IN ( 'ONL_DrainOilValve_Open', 'ONL_DrainOilValve_Close' )
AND `value` = 'true'
AND equipment_specific_id in
<foreach collection="collect" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY
equipment_specific_id
ORDER BY
update_date DESC
</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