Commit 6ed00c91 authored by KeYong's avatar KeYong

提交水喷雾和消防泡沫系统后台接口

parent efb99e5e
package com.yeejoin.equipmanage.common.dto;
import lombok.Data;
/**
* @author keyong
* @title: EquipIndexDto
* <pre>
* @description: TODO
* </pre>
* @date 2023/11/21 18:11
*/
@Data
public class SystemInfoDto {
private String name;
private String code;
private String typeCode;
private String equipmentCodeForStart;
private String indexKeyForStart;
private String nameForSpecialEquip;
private String equipmentCodeForSpecialEquip;
private String indexKeyForSpecialEquip;
private String linkedEquipmentCode;
private String linkedEquipmentIndexKey;
}
......@@ -1252,5 +1252,36 @@ public class FireFightingSystemController extends AbstractBaseController {
fireFightingSystemService.resetMorphic();
}
/**
* 应急4.0泡沫消防系统
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "获取泡沫消防系统信息", notes = "获取泡沫消防系统信息")
@GetMapping(value = "/foam/info")
public Object getFoamSystemInfo() throws Exception {
String bizOrgCode = null;
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getCompanyBizOrgCode();
}
return fireFightingSystemService.getFoamSystemInfoList(bizOrgCode);
}
/**
* 应急4.0水喷雾灭火系统
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "获取水喷雾灭火系统状态信息", notes = "获取水喷雾灭火系统状态信息")
@GetMapping(value = "/water/info")
public Object getWaterSystemInfo() throws Exception {
String bizOrgCode = null;
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getCompanyBizOrgCode();
}
return fireFightingSystemService.getWaterSystemInfo(bizOrgCode);
}
}
......@@ -791,5 +791,16 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
List<LinkedHashMap<String, Object>> getOtherFireEquipStatistic(@Param("collect") List<String> collect, @Param("bizOrgCode")String bizOrgCode);
List<EquipCountBySystemVO> getFireEquipConfigInfo(@Param("codes") List<String> codes, @Param("bizOrgCode")String bizOrgCode);
Map<String, String> getSystemStateByIndexKey(@Param("code")String code, @Param("typeCode")String typeCode, @Param("equipmentCodeForStart")String equipmentCodeForStart,
@Param("indexKeyForStart")String indexKeyForStart, @Param("bizOrgCode")String bizOrgCode);
List<Map<String, Object>> getWaterSystemLinkedEquip(@Param("code")String code, @Param("typeCode")String typeCode,
@Param("linkedEquipmentCode")String linkedEquipmentCode, @Param("linkedEquipmentIndexKey")String linkedEquipmentIndexKey,
@Param("bizOrgCode")String bizOrgCode);
List<Map<String, Object>> getSystemFoamTankInfoListByIndexKey(@Param("code")String code, @Param("typeCode")String typeCode,
@Param("linkedEquipmentCode")String linkedEquipmentCode, @Param("linkedEquipmentIndexKey")String linkedEquipmentIndexKey,
@Param("bizOrgCode")String bizOrgCode);
}
......@@ -377,4 +377,10 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
List<Map<String, Object>> getSystemAlarmNum(String bizOrgCode, String startDate, String endDate);
Map<String, Object> getFoamSystemInfoList(String bizOrgCode);
Map<String, Object> getWaterSystemInfo(String bizOrgCode);
}
......@@ -31,6 +31,7 @@ import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.equipmanage.common.datasync.entity.FireFightingSystem;
import com.yeejoin.equipmanage.common.dto.FireFightingSystemDto;
import com.yeejoin.equipmanage.common.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.dto.SystemInfoDto;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO;
import com.yeejoin.equipmanage.common.entity.vo.*;
......@@ -43,6 +44,7 @@ import com.yeejoin.equipmanage.fegin.JcsFeign;
import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*;
import liquibase.pro.packaged.O;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.io.IOUtils;
......@@ -65,7 +67,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
......@@ -127,6 +128,9 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
@Value("classpath:/json/systemCode.json")
private Resource systemCode;
@Value("classpath:/json/systemMainInfoForYJ.json")
private Resource systemMainInfoForYJ;
@Autowired
JcsFeign jcsFeignClient;
@Autowired
......@@ -2889,6 +2893,96 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
@Override
public Map<String, Object> getWaterSystemInfo(String bizOrgCode) {
Map<String, Object> resMap = new HashMap<>();
String json = null;
try {
json = IOUtils.toString(systemMainInfoForYJ.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<SystemInfoDto> infoDtos = JSONObject.parseArray(json, SystemInfoDto.class);
SystemInfoDto dto = infoDtos.stream().filter(x -> "水喷雾灭火系统".equals(x.getName())).collect(Collectors.toList()).get(0);
Map<String, String> systemState = fireFightingSystemMapper.getSystemStateByIndexKey(dto.getCode(), dto.getTypeCode(), dto.getEquipmentCodeForStart(),
dto.getIndexKeyForStart(), bizOrgCode);
resMap.put("system", ObjectUtils.isEmpty(systemState) ? "--" : systemState.get("status"));
List<Map<String, Object>> systemEquipInfoList = fireFightingSystemMapper.getWaterSystemLinkedEquip(dto.getCode(), dto.getTypeCode(), dto.getLinkedEquipmentCode(), dto.getLinkedEquipmentIndexKey(), bizOrgCode);
List<Map<String, Object>> resList = new ArrayList<>();
int i = 1;
if (0 < systemEquipInfoList.size()) {
for (Map<String, Object> m : systemEquipInfoList) {
Map<String, Object> map = new HashMap<>();
map.put("key", i);
map.put("name", m.get("name"));
map.put("code", m.get("code"));
map.put("systemTypeCode", systemCode);
map.put("img", m.get("shbzImg"));
map.put("type", m.get("type"));
map.put("status", m.get("status"));
map.put("fullName", m.get("fullName"));
map.put("updateDate", m.get("updateDate").toString().replace("T", " "));
map.put("realtimeValue", String.valueOf(m.get("realtimeValue")));
resList.add(map);
i++;
}
}
resMap.put("equipListInfo", systemEquipInfoList);
return resMap;
}
@Override
public Map<String, Object> getFoamSystemInfoList(String bizOrgCode) {
Map<String, Object> resMap = new HashMap<>();
String json = null;
try {
json = IOUtils.toString(systemMainInfoForYJ.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
List<SystemInfoDto> infoDtos = JSONObject.parseArray(json, SystemInfoDto.class);
SystemInfoDto dto = infoDtos.stream().filter(x -> "泡沫消防系统".equals(x.getName())).collect(Collectors.toList()).get(0);
Map<String, String> systemState = fireFightingSystemMapper.getSystemStateByIndexKey(dto.getCode(), dto.getTypeCode(), dto.getEquipmentCodeForStart(),
dto.getIndexKeyForStart(), bizOrgCode);
resMap.put("status", ObjectUtils.isEmpty(systemState) ? "--" : systemState.get("status"));
Map<String, String> systemSpecialEquipState = fireFightingSystemMapper.getSystemStateByIndexKey(dto.getCode(), dto.getTypeCode(),
dto.getEquipmentCodeForSpecialEquip(), dto.getIndexKeyForSpecialEquip(), bizOrgCode);
resMap.put("cabinet", ObjectUtils.isEmpty(systemSpecialEquipState) ? "--" : systemSpecialEquipState.get("status"));
List<Map<String, Object>> systemEquipInfoList = fireFightingSystemMapper.getSystemFoamTankInfoListByIndexKey(dto.getCode(), dto.getTypeCode(), dto.getLinkedEquipmentCode(), dto.getLinkedEquipmentIndexKey(), bizOrgCode);
if (0 < systemEquipInfoList.size()) {
for (Map<String, Object> m : systemEquipInfoList) {
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")));
if (UnitEnum.LFM.getKey().equalsIgnoreCase(String.valueOf(m.get("unit"))) || UnitEnum.LFM.getName().equals(String.valueOf(m.get("unit")))) {
transResult = UnitTransformUtil.transformValuesLFM(String.valueOf(m.get("nowLevel")),
String.valueOf(m.get("unit")), String.valueOf(m.get("minLevel")), String.valueOf(m.get("maxLevel")));
}
if (StringUtil.isNotEmpty(IndexStatusEnum.getEnumByKey(String.valueOf(transResult.get("status"))))) {
m.put("status", IndexStatusEnum.getEnumByKey(String.valueOf(transResult.get("status"))).getDescribe1());
} else {
m.put("status", "--");
}
if (!String.valueOf(transResult.get("abs")).equals("--") && !ObjectUtils.isEmpty(m.get("volume"))) {
BigDecimal divide = new BigDecimal(100);
BigDecimal bigDecimal = new BigDecimal(String.valueOf(m.get("volume"))).multiply(new BigDecimal(String.valueOf(transResult.get("abs")))).divide(divide, 0, BigDecimal.ROUND_HALF_UP);
m.put("abs", bigDecimal + "m³ " + " (" + transResult.get("abs") + "%)");
} else {
m.put("abs", transResult.get("abs"));
}
if (UnitEnum.LFM.getKey().equalsIgnoreCase(String.valueOf(m.get("unit"))) || UnitEnum.LFM.getName().equals(String.valueOf(m.get("unit")))) {
m.put("abs", transResult.get("abs") + "%");
}
m.put("unit", transResult.get("unit").toString());
m.put("nowLevel", transResult.get("nowValue").toString());
}
}
resMap.put("equipListInfo", systemEquipInfoList);
return resMap;
}
@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();
......
[
{
"name": "水喷雾灭火系统",
"typeCode": "fireAlarmSys",
"code": "527",
"equipmentCodeForStart": "92100300",
"indexKeyForStart": "ONL_DCPower_Fault",
"nameForSpecialEquip": "",
"equipmentCodeForSpecialEquip": "",
"indexKeyForSpecialEquip": "",
"linkedEquipmentCode": "92041000",
"linkedEquipmentIndexKey": ""
},
{
"name": "泡沫消防系统",
"typeCode": "fireCAFSSys",
"code": "943",
"equipmentCodeForStart": "92130700",
"indexKeyForStart": "WSS_Host_RunStatus",
"nameForSpecialEquip": "泡沫消防控制柜",
"equipmentCodeForSpecialEquip": "92040700",
"indexKeyForSpecialEquip": "FAS_TemperatureCable_Fault",
"linkedEquipmentCode": "92031900",
"linkedEquipmentIndexKey": ""
}
]
\ No newline at end of file
......@@ -7741,4 +7741,122 @@
ORDER BY
update_date DESC
</select>
<select id="getSystemStateByIndexKey" resultType="java.util.Map">
SELECT
IFNULL(systemStatus, '--') AS status
FROM
(
SELECT
wesi.equipment_specific_id,
CASE
WHEN wesi.value = 'true' THEN
'开启'
WHEN (wesi.value = 'false' OR wesi.value IS NULL) THEN
'关闭'
ELSE
wesi.equipment_index_name
END AS systemStatus,
wesi.update_date,
ROW_NUMBER() OVER ( PARTITION BY wesi.equipment_specific_id ORDER BY wesi.update_date DESC ) AS rn
FROM
wl_equipment_specific_index wesi
JOIN wl_equipment_specific wes ON wes.id = wesi.equipment_specific_id
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wes.system_id )
<where>
fs.system_type_code IS NOT NULL
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wes.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
<if test="code != null and code != ''">
AND fs.code = #{code}
</if>
<if test="typeCode != null and typeCode != ''">
AND fs.system_type_code = #{typeCode}
</if>
<if test="indexKeyForStart != null and indexKeyForStart != ''">
AND wesi.equipment_index_key = #{indexKeyForStart}
</if>
<if test="equipmentCodeForStart != null and equipmentCodeForStart != ''">
AND LOCATE(#{equipmentCodeForStart}, wes.equipment_code) > 0
</if>
</where>
) t
WHERE
t.rn = 1
GROUP BY
equipment_specific_id
ORDER BY
update_date DESC
</select>
<select id="getWaterSystemLinkedEquip" resultType="java.util.Map">
SELECT
spe.id,
spe.`name`,
spe.`code`,
CASE when 'false' = spe.realtime_iot_index_value or spe.realtime_iot_index_value is null or spe.realtime_iot_index_value = '' then '正常' ELSE spe.realtime_iot_index_name END as status,
wle.shbz_img shbzImg,
ei.is_alarm AS type,
IFNULL( spe.realtime_iot_index_value, '--' ) AS realtimeValue,
CASE when ei.is_alarm = 1 and spe.realtime_iot_index_value = 'true' then 1 else 0 END as orderNo,
IFNULL( ws.full_name, '--' ) AS fullName,
IFNULL( spe.realtime_iot_index_update_date, '--' ) AS updateDate
FROM
wl_equipment_specific AS spe
LEFT JOIN wl_equipment_index ei ON spe.realtime_iot_index_id = ei.id
LEFT JOIN wl_warehouse_structure ws ON spe.warehouse_structure_id = ws.id
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, spe.system_id )
LEFT JOIN wl_equipment_detail AS det ON spe.equipment_detail_id = det.id
LEFT JOIN wl_equipment AS wle ON wle.id = det.equipment_id
WHERE
fs.system_type_code IS NOT NULL
<if test="bizOrgCode != null and bizOrgCode != ''">
AND spe.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
<if test="code != null and code != ''">
AND fs.code = #{code}
</if>
<if test="typeCode != null and typeCode != ''">
AND fs.system_type_code = #{typeCode}
</if>
<if test="linkedEquipmentIndexKey != null and linkedEquipmentIndexKey != ''">
AND ei.name_key = #{linkedEquipmentIndexKey}
</if>
<if test="linkedEquipmentCode != null and linkedEquipmentCode != ''">
AND LOCATE(#{linkedEquipmentCode}, det.`code`) > 0
</if>
GROUP BY spe.id
ORDER BY orderNo desc
</select>
<select id="getSystemFoamTankInfoListByIndexKey" resultType="java.util.Map">
SELECT
temp.id,
temp.name,
temp.code,
temp.nowLevel,
temp.volume,
temp.unit,
temp.minLevel,
temp.maxLevel
FROM
(
SELECT
wes.id,
wes.name,
wes.code,
IFNULL( ( SELECT value FROM wl_equipment_specific_index wesi WHERE wesi.equipment_specific_id = wes.id AND equipment_index_key = 'CAFS_FoamTank_FoamTankLevel' ), '--' ) AS nowLevel,
IFNULL( ( SELECT unit FROM wl_equipment_specific_index wesi WHERE wesi.equipment_specific_id = wes.id AND equipment_index_key = 'CAFS_FoamTank_FoamTankLevel' ), '--' ) AS unit,
IFNULL(( SELECT field_value FROM wl_form_instance_equip WHERE instance_id = wes.id AND field_name = 'maxLevel' ) , 0 )AS maxLevel,
IFNULL( ( SELECT field_value FROM wl_form_instance_equip WHERE instance_id = wes.id AND field_name = 'minLevel' ), 0 ) AS minLevel,
IFNULL( ( SELECT field_value FROM wl_form_instance_equip WHERE instance_id = wes.id AND field_name = 'volume' ), 0 ) AS volume
FROM
wl_equipment_specific wes
WHERE
wes.equipment_code LIKE concat( '920319', '%' )
) temp
ORDER BY temp.nowLevel 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