Commit fc8d08e8 authored by KeYong's avatar KeYong

Merge branch 'develop_dl_plan6' into develop_dl_plan6_temp

parents 89605d6e efcfbd62
......@@ -17,7 +17,8 @@ public enum UnitEnum {
M("m", "米", ""),
DM("dm", "分米", ""),
CM("cm", "厘米", "");
CM("cm", "厘米", ""),
MM("mm", "毫米", "");
private String key;
......
......@@ -20,7 +20,37 @@ public class UnitTransformUtil {
public static Map<String, Object> transformValues(String currentValue, String currentUnit, String minValue, String maxValue) {
Map<String, Object> map = new HashMap<>();
if (UnitEnum.CM.getKey().equalsIgnoreCase(currentUnit) || UnitEnum.CM.getName().equals(currentUnit)){
if (UnitEnum.MM.getKey().equalsIgnoreCase(currentUnit) || UnitEnum.MM.getName().equals(currentUnit)){
BigDecimal divide = new BigDecimal(1000);
if (StringUtil.isNotEmpty(currentValue) && !"--".equals(currentValue)){
BigDecimal nowLevel = new BigDecimal(currentValue);
map.put("nowValue", nowLevel.divide(divide,2,BigDecimal.ROUND_HALF_UP));
BigDecimal nowVal = new BigDecimal(currentValue).divide(divide,2,BigDecimal.ROUND_HALF_UP);
// status 中 0 表示过低;1 表示正常;2 表示过高
if (StringUtil.isNotEmpty(minValue) && !"--".equals(minValue) && StringUtil.isNotEmpty(maxValue)
&& !"--".equals(maxValue) && !"null".equalsIgnoreCase(minValue)&& !"--".equals(maxValue) && !"null".equalsIgnoreCase(maxValue)) {
if (nowVal.compareTo(new BigDecimal(minValue)) < 0) {
map.put("status", "0");
map.put("abs", nowVal.divide(new BigDecimal(maxValue),2,BigDecimal.ROUND_HALF_UP).movePointRight(2));
} else if (nowVal.compareTo(new BigDecimal(maxValue)) == 1) {
map.put("status", "2");
map.put("abs", 100);
} else {
map.put("status", "1");
map.put("abs", nowVal.divide(new BigDecimal(maxValue),2,BigDecimal.ROUND_HALF_UP).movePointRight(2));
}
} else {
map.put("status", "--");
map.put("abs", "--");
}
} else {
map.put("nowValue", "--");
map.put("status", "--");
map.put("abs", "--");
}
} else if (UnitEnum.CM.getKey().equalsIgnoreCase(currentUnit) || UnitEnum.CM.getName().equals(currentUnit)){
BigDecimal divide = new BigDecimal(100);
if (StringUtil.isNotEmpty(currentValue) && !"--".equals(currentValue)){
BigDecimal nowLevel = new BigDecimal(currentValue);
......@@ -81,7 +111,7 @@ public class UnitTransformUtil {
}
} else {
BigDecimal nowVal = new BigDecimal(0);
if (StringUtil.isNotEmpty(currentValue)) {
if (StringUtil.isNotEmpty(currentValue) && !"--".equals(currentValue)) {
nowVal = new BigDecimal(currentValue);
map.put("nowValue", nowVal);
} else {
......
......@@ -273,17 +273,27 @@ public class ConfigureController extends AbstractBaseController {
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
Page<Map<String, Object>> waterInfo = fireFightingSystemMapper.getWaterInfo(page, bizOrgCode, null);
Map<String, Object> unit = fireFightingSystemMapper.getWaterlevelUnit();
if ("CM".equals(unit.get("unit")) || "cm".equals(unit.get("unit")) || "厘米".equals(unit.get("unit"))){
for (Map<String, Object> record : waterInfo.getRecords()) {
for (Map<String, Object> record : waterInfo.getRecords()) {
Map<String, Object> unit = null;
String deviceId = String.valueOf(record.get("level_device_id"));
String[] split = deviceId.split(",");
if (!ObjectUtils.isEmpty(split) && !ObjectUtils.isEmpty(split[0])) {
String s = split[0];
if ("pool".equals(record.get("resource_type"))) {
unit = fireFightingSystemMapper.getWaterlevelUnit(s, "FHS_FirePoolDevice_WaterLevel");
} else {
unit = fireFightingSystemMapper.getWaterlevelUnit(s, "FHS_WirelessliquidDetector_WaterLevel");
}
}
if (!ObjectUtils.isEmpty(unit) && "CM".equals(unit.get("unit")) || "cm".equals(unit.get("unit")) || "厘米".equals(unit.get("unit"))){
BigDecimal divide = new BigDecimal(100);
if (!ObjectUtils.isEmpty(record.get("nowLevel")) && !"--".equals(record.get("nowLevel"))){
BigDecimal nowLevel = new BigDecimal(String.valueOf(record.get("nowLevel")));
record.put("nowLevel",nowLevel.divide(divide,2,BigDecimal.ROUND_HALF_UP));
record.put("nowLevel", nowLevel.divide(divide, 2, BigDecimal.ROUND_HALF_UP));
}
if (!ObjectUtils.isEmpty(record.get("levelAbs")) && !"--".equals(record.get("nowLevel"))){
BigDecimal levelAbs = new BigDecimal(String.valueOf(record.get("levelAbs")));
record.put("levelAbs",levelAbs.divide(divide,2,BigDecimal.ROUND_HALF_UP));
record.put("levelAbs", levelAbs.divide(divide, 2, BigDecimal.ROUND_HALF_UP));
}
}
}
......
......@@ -641,7 +641,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
String selectEquipSystemType(String code);
Map<String, Object> getWaterlevelUnit();
Map<String, Object> getWaterlevelUnit(@Param("equipmentSpecificId") String equipmentSpecificId, @Param("equipmentIndexKey") String equipmentIndexKey);
Map<String, Object> getStationConnectStatus();
......
......@@ -2394,7 +2394,7 @@
WHEN max( CASE WHEN ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel' THEN ei.`value` END ) &lt; IFNULL( rp.min_water_level, 0 )
AND rp.max_water_level IS NULL THEN
'--' ELSE IFNULL((
FORMAT(
abs(
IFNULL(
max( CASE WHEN ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel' THEN ei.`value` END ),
......@@ -2403,9 +2403,7 @@
(
IFNULL( rp.max_water_level, 0 ) = 0,
1,
IFNULL( rp.max_water_level, 0 ))) * 100,
2
)
IFNULL( rp.max_water_level, 0 ))) * 100
),
0
)
......@@ -2428,6 +2426,7 @@
ec.image,
r.resource_type,
r.sequence_nbr,
rp.level_device_id,
fs.`code` AS systemCode
FROM
cb_water_resource r
......@@ -2466,7 +2465,7 @@
WHEN IFNULL( a.minLevel, 0 ) > a.nowLevel
AND a.maxLevel IS NULL THEN
'--' ELSE IFNULL((
FORMAT(
abs(
IFNULL(
a.nowLevel,
......@@ -2475,9 +2474,7 @@
(
IFNULL( a.maxLevel, 0 ) = 0,
1,
IFNULL( a.maxLevel, 0 ))) * 100,
2
)
IFNULL( a.maxLevel, 0 ))) * 100
),
0
)
......@@ -2500,6 +2497,7 @@
a.image,
a.resource_type,
a.sequence_nbr,
a.level_device_id,
a.`code` AS systemCode
FROM
(
......@@ -2509,7 +2507,7 @@
IFNULL( rp.min_water_level, 0 ) AS minLevel,
IFNULL( rp.max_water_level, 0 ) AS maxLevel,
(select
FORMAT(avg(IFNULL(ei.`value`,0)), 2)
avg(IFNULL(ei.`value`,0))
from
wl_equipment_specific_index ei
where
......@@ -4973,6 +4971,7 @@
AND
</if>
i.equipment_index_key in ('FHS_PressurePump_Start')
and i.value = 'true'
ORDER BY
i.update_date DESC
limit 1
......@@ -4993,6 +4992,7 @@
AND
</if>
i.equipment_index_key in ('FHS_PressurePump_Stop')
and i.value = 'true'
ORDER BY
i.update_date DESC
limit 1
......@@ -5409,7 +5409,14 @@
<select id="getWaterlevelUnit" resultType="java.util.Map">
SELECT unit FROM `wl_equipment_index` WHERE name_key = 'FHS_FirePoolDevice_WaterLevel'
SELECT
wes.unit
FROM
wl_equipment_specific_index wes
WHERE
wes.equipment_index_key = #{equipmentIndexKey}
AND wes.equipment_specific_id = #{equipmentSpecificId}
LIMIT 1
</select>
<select id="getStationConnectStatus" resultType="java.util.Map">
......
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