Commit a57f56bc authored by KeYong's avatar KeYong

应急接口

parent 8803d6eb
package com.yeejoin.equipmanage.controller; package com.yeejoin.equipmanage.controller;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.entity.publics.CommonResponse;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.common.utils.ResponseUtils;
import com.yeejoin.equipmanage.common.vo.UnitAreaTreeVo; import com.yeejoin.equipmanage.common.vo.UnitAreaTreeVo;
import com.yeejoin.equipmanage.service.IAreaService; import com.yeejoin.equipmanage.service.IEmergencyService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.tomcat.util.http.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -12,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List; import java.util.List;
...@@ -27,18 +32,30 @@ import java.util.List; ...@@ -27,18 +32,30 @@ import java.util.List;
public class EmergencyController extends AbstractBaseController { public class EmergencyController extends AbstractBaseController {
@Autowired @Autowired
IAreaService iAreaService; IEmergencyService iEmergencyService;
/** /**
* 通过bizOrgCode过滤 * 通过bizOrgCode过滤
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("xxxx") @ApiOperation("系统状态")
@GetMapping(value = "/getAll") @GetMapping(value = "/system/state")
public List<UnitAreaTreeVo> getAll() { public ResponseModel getSystemState() {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode(); String bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
return null; return CommonResponseUtil.success(iEmergencyService.getSystemState(bizOrgCode));
}
/**
* CAFS-消防水箱信息
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("CAFS-消防水箱信息")
@GetMapping(value = "/cafs-tank")
public ResponseModel getCAFSWaterTankInfo() {
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
return CommonResponseUtil.success(iEmergencyService.getCAFSWaterTankInfo(bizOrgCode));
} }
} }
package com.yeejoin.equipmanage.mapper; package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import liquibase.pro.packaged.M;
import com.yeejoin.equipmanage.common.entity.CarInfo; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/** /**
* Mapper 接口 * Mapper 接口
...@@ -9,4 +12,8 @@ import com.yeejoin.equipmanage.common.entity.CarInfo; ...@@ -9,4 +12,8 @@ import com.yeejoin.equipmanage.common.entity.CarInfo;
*/ */
public interface EmergencyMapper { public interface EmergencyMapper {
List<Map<String, Object>> getSystemState(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getCAFSWaterTankInfo(@Param("bizOrgCode") String bizOrgCode);
} }
package com.yeejoin.equipmanage.service; package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.vo.UnitAreaTreeVo;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
...@@ -15,5 +13,10 @@ public interface IEmergencyService { ...@@ -15,5 +13,10 @@ public interface IEmergencyService {
/** /**
* @return * @return
*/ */
List getAll(); List<Map<String, Object>> getSystemState(String bizOrgCode);
/**
* @return
*/
List<Map<String, Object>> getCAFSWaterTankInfo(String bizOrgCode);
} }
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.vo.UnitAreaTreeVo;
import com.yeejoin.equipmanage.mapper.EmergencyMapper; import com.yeejoin.equipmanage.mapper.EmergencyMapper;
import com.yeejoin.equipmanage.service.IEmergencyService; import com.yeejoin.equipmanage.service.IEmergencyService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
/** /**
* *
...@@ -22,7 +23,13 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -22,7 +23,13 @@ public class EmergencyServiceImpl implements IEmergencyService {
private EmergencyMapper emergencyMapper; private EmergencyMapper emergencyMapper;
@Override @Override
public List getAll() { public List<Map<String, Object>> getSystemState(String bizOrgCode) {
return null; return emergencyMapper.getSystemState(bizOrgCode);
}
@Override
public List<Map<String, Object>> getCAFSWaterTankInfo(String bizOrgCode) {
List<Map<String, Object>> list = emergencyMapper.getCAFSWaterTankInfo(bizOrgCode);
return Optional.ofNullable(list).orElse(Lists.newArrayList());
} }
} }
...@@ -52,7 +52,7 @@ public class FormInstanceEquipServiceImpl extends ServiceImpl<FormInstanceEquipM ...@@ -52,7 +52,7 @@ public class FormInstanceEquipServiceImpl extends ServiceImpl<FormInstanceEquipM
@Autowired @Autowired
private Sequence sequence; private Sequence sequence;
final static String[] list = {"92031900", "92011000", "92010700"}; final static String[] list = {"92031900", "92011000", "92010700", "92032000"};
private final String CODE = "code"; private final String CODE = "code";
......
...@@ -462,4 +462,28 @@ ...@@ -462,4 +462,28 @@
ALTER TABLE `wl_equipment_specific_alarm_log` ADD COLUMN `station_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '换流站编码'; ALTER TABLE `wl_equipment_specific_alarm_log` ADD COLUMN `station_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '换流站编码';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="keyong" id="1670919999">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="wl_form_group_equip"/>
</not>
</preConditions>
<comment>新增CAFS水箱属性字段</comment>
<sql>
INSERT INTO `wl_form_group_equip`(`id`, `group_name`, `group_code`, `group_type`, `allow_operation`, `creator_id`, `create_date`) VALUES (132828674828, 'CAFS-水箱', '92032000', 'equip', 'edit,delete', 2581805, '2022-12-12 03:36:44');
</sql>
</changeSet>
<changeSet author="keyong" id="1670919999-1">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="wl_form_group_column_equip"/>
</not>
</preConditions>
<comment>新增CAFS水箱属性字段</comment>
<sql>
INSERT INTO `wl_form_group_column_equip`(`id`, `field_name`, `field_label`, `data_type`, `group_id`, `query_strategy`, `not_null`, `group_code`, `creator_id`, `create_date`) VALUES (133000000357, 'minLevel', '最低报警液位(m)', 'inputNumber', 132828674828, 'eq', b'0', '92032000', 2581805, '2022-12-12 09:24:35');
INSERT INTO `wl_form_group_column_equip`(`id`, `field_name`, `field_label`, `data_type`, `group_id`, `query_strategy`, `not_null`, `group_code`, `creator_id`, `create_date`) VALUES (133000000358, 'maxLevel', '最高报警液位(m)', 'inputNumber', 132828674828, 'eq', b'0', '92032000', 2581805, '2022-12-12 09:24:36');
INSERT INTO `wl_form_group_column_equip`(`id`, `field_name`, `field_label`, `data_type`, `group_id`, `query_strategy`, `not_null`, `group_code`, `creator_id`, `create_date`) VALUES (133000000359, 'volume', '泡沫液罐容积(m³)', 'inputNumber', 132828674828, 'eq', b'0', '92032000', 2581805, '2022-12-12 09:24:37');
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -2,5 +2,86 @@ ...@@ -2,5 +2,86 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.equipmanage.mapper.EmergencyMapper"> <mapper namespace="com.yeejoin.equipmanage.mapper.EmergencyMapper">
<select id="getSystemState" resultType="Map">
SELECT
`fs`.`id` AS `id`,
`fs`.`name` AS `name`,
IF
(((
SELECT
count( `eqlog`.`equipment_specific_id` )
FROM
`wl_equipment_specific_alarm_log` `eqlog`
WHERE
( 0 <![CDATA[<>]]> find_in_set( `fs`.`id`, `eqlog`.`system_ids` )
AND `eqlog`.`status` = 1 AND `eqlog`.clean_time IS NULL)) > 0
),
'异常',
'正常'
) AS `stateDesc`
FROM
`f_fire_fighting_system` `fs`
<where>
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND fs.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</where>
GROUP BY
`fs`.`id`
</select>
<select id="getCAFSWaterTankInfo" resultType="Map">
SELECT
wes.id AS specificId,
wes.`name`,
a.statusDesc,
a.sxyl,
a.`value`
FROM
wl_equipment_specific wes
LEFT JOIN (
SELECT
wlesi.equipment_specific_id,
IFNULL(wlesi.`value`, '--') AS `value`,
CASE
WHEN wlesi.`value` IS NULL THEN
'--'
WHEN wlesi.`value` - ( SELECT IFNULL( wfie.field_value, 0 ) FROM wl_form_instance_equip wfie WHERE wfie.instance_id = wlesi.equipment_specific_id AND field_name = 'maxLevel' ) &gt; 0 THEN
'液位高'
WHEN wlesi.`value` - ( SELECT IFNULL( wfie.field_value, 0 ) FROM wl_form_instance_equip wfie WHERE wfie.instance_id = wlesi.equipment_specific_id AND field_name = 'minLevel' ) &lt; 0 THEN
'液位低' ELSE '正常'
END AS statusDesc,
CASE
WHEN wlesi.`value` IS NULL THEN
'--' ELSE
IF
(
wlesi.`value` - ( SELECT IFNULL( field_value, 0 ) FROM wl_form_instance_equip wfie WHERE wfie.instance_id = wlesi.equipment_specific_id AND field_name = 'maxLevel' ) &gt; 0,
100,
ROUND(abs(
(
wlesi.`value` /
IF
(
( SELECT IFNULL( field_value, 0 ) FROM wl_form_instance_equip wfie WHERE wfie.instance_id = wlesi.equipment_specific_id AND field_name = 'maxLevel' ) = 0,
1,
( SELECT IFNULL( field_value, 0 ) FROM wl_form_instance_equip wfie WHERE wfie.instance_id = wlesi.equipment_specific_id AND field_name = 'maxLevel' )
)
)
) * 100, 2)
)
END AS sxyl
FROM
wl_equipment_specific_index wlesi
WHERE
wlesi.equipment_index_key = 'CAFS_WaterTank_WaterTankLevel'
) a ON a.equipment_specific_id = wes.id
WHERE
-- 因为此处属于确定查询条件,所以此处写入常量
wes.equipment_code LIKE CONCAT( '92032000', '%' )
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND wes.biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</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