Commit 3030f80e authored by 张森's avatar 张森

中心大屏水池相关信息一一对应

parent ee155f3b
package com.yeejoin.equipmanage.controller; package com.yeejoin.equipmanage.controller;
import cn.hutool.core.util.StrUtil;
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;
...@@ -231,8 +232,7 @@ public class PoolStatisticController { ...@@ -231,8 +232,7 @@ public class PoolStatisticController {
sortOrder = sorter.split("@")[1]; sortOrder = sorter.split("@")[1];
} }
Page<Map<String, Object>> page1 = fireFightingSystemMapper.getWaterInfoList(page, bizOrgCode, sortField, sortOrder, status); List<Map<String, Object>> res = fireFightingSystemMapper.getWaterInfoList(bizOrgCode, sortField, sortOrder);
List<Map<String, Object>> res = page1.getRecords();
if (!res.isEmpty()) { if (!res.isEmpty()) {
for (Map<String, Object> m : res) { for (Map<String, Object> m : res) {
Map<String, Object> transResult = UnitTransformUtil.transformValues(String.valueOf(m.get("nowLevel")), Map<String, Object> transResult = UnitTransformUtil.transformValues(String.valueOf(m.get("nowLevel")),
...@@ -263,9 +263,19 @@ public class PoolStatisticController { ...@@ -263,9 +263,19 @@ public class PoolStatisticController {
m.put("status", "0"); m.put("status", "0");
} }
} }
page1.setRecords(res);
if (StrUtil.isNotEmpty(status)) {
String finalStatus = status;
res = res.stream().filter(item -> finalStatus.equals(item.get("status").toString())).collect(Collectors.toList());
}
page.setTotal(res.size());
List<Map<String, Object>> collect = res.stream()
.skip((long) (commonPageable.getPageNumber() - 1) * commonPageable.getPageSize())
.limit(commonPageable.getPageSize())
.collect(Collectors.toList());
page.setRecords(collect);
} }
return CommonResponseUtil.success(page1); return CommonResponseUtil.success(page);
} }
@RequestMapping(value = "/selectWaterLevelDetail", method = RequestMethod.GET) @RequestMapping(value = "/selectWaterLevelDetail", method = RequestMethod.GET)
......
...@@ -356,7 +356,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE ...@@ -356,7 +356,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
* @param bizOrgCode * @param bizOrgCode
* @return * @return
*/ */
Page<Map<String, Object>> getWaterInfoList(Page page, @Param("bizOrgCode") String bizOrgCode, @Param("sortField") String sortField, @Param("sortOrder") String sortOrder, @Param("status") String status); List<Map<String, Object>> getWaterInfoList(@Param("bizOrgCode") String bizOrgCode, @Param("sortField") String sortField, @Param("sortOrder") String sortOrder);
/** /**
* 水源信息统计 * 水源信息统计
......
...@@ -343,10 +343,7 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -343,10 +343,7 @@ public interface PlanTaskMapper extends BaseMapper {
List<Map<String, Object>> queryPatrolInfo(@Param(value="bizOrgCode") String bizOrgCode, @Param(value="startDate") Date startDate, @Param(value="endDate") Date endDate); List<Map<String, Object>> queryPatrolInfo(@Param(value="bizOrgCode") String bizOrgCode, @Param(value="startDate") Date startDate, @Param(value="endDate") Date endDate);
List<HashMap<String, Object>> selectPatrolRecordPage( List<HashMap<String, Object>> selectPatrolRecordPage(
@Param(value="offset") long offset,
@Param(value="pageSize") long pageSize,
@Param(value="bizOrgCode") String bizOrgCode, @Param(value="bizOrgCode") String bizOrgCode,
@Param(value="missStatus") String missStatus,
@Param(value="date") String date @Param(value="date") String date
); );
Long selectPatrolRecordTotal( Long selectPatrolRecordTotal(
...@@ -359,4 +356,10 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -359,4 +356,10 @@ public interface PlanTaskMapper extends BaseMapper {
@Param(value="bizOrgCode") String bizOrgCode, @Param(value="bizOrgCode") String bizOrgCode,
@Param(value="date") String date @Param(value="date") String date
); );
Integer getDoneNum(@Param(value="bizOrgCode") String bizOrgCode,
@Param(value="date") String date);
List<Map<String, Object>> getDoneList(@Param(value="bizOrgCode") String bizOrgCode,
@Param(value="date") String date);
} }
package com.yeejoin.amos.patrol.business.service.impl; package com.yeejoin.amos.patrol.business.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.StrUtil;
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;
...@@ -2173,7 +2175,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2173,7 +2175,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
throw new RuntimeException("获取idx服务异常"); throw new RuntimeException("获取idx服务异常");
} }
List<Map<String, Object>> stations = response.getResult(); List<Map<String, Object>> stations = response.getResult();
AtomicInteger doneNum = new AtomicInteger(); // 已开展
AtomicInteger missNum = new AtomicInteger(); // 有漏检 AtomicInteger missNum = new AtomicInteger(); // 有漏检
List<Map<String, String>> queryMaps = planTaskMapper.selectPatrolActivityStats(bizOrgCode, date); List<Map<String, String>> queryMaps = planTaskMapper.selectPatrolActivityStats(bizOrgCode, date);
for (Map<String, String> queryMap : queryMaps) { for (Map<String, String> queryMap : queryMaps) {
...@@ -2181,11 +2182,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2181,11 +2182,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if (Objects.equals(missStatus, "有漏检")) { if (Objects.equals(missStatus, "有漏检")) {
missNum.incrementAndGet(); missNum.incrementAndGet();
} }
doneNum.incrementAndGet();
} }
Integer doneNum = planTaskMapper.getDoneNum(bizOrgCode, date);
return new HashMap<String, Number>() {{ return new HashMap<String, Number>() {{
this.put("done", doneNum.intValue()); this.put("done", doneNum);
this.put("undone", stations.size() - doneNum.intValue()); this.put("undone", stations.size() - doneNum);
this.put("miss", missNum); this.put("miss", missNum);
this.put("noMiss", stations.size() - missNum.intValue()); this.put("noMiss", stations.size() - missNum.intValue());
}}; }};
...@@ -2193,7 +2194,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2193,7 +2194,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Override @Override
public Page<HashMap<String, Object>> getPatrolRecordPage(Integer pageNumber, Integer pageSize, String bizOrgCode, String patrolStatus, String missStatus, String date, String sorter) { public Page<HashMap<String, Object>> getPatrolRecordPage(Integer pageNumber, Integer pageSize, String bizOrgCode, String patrolStatus, String missStatus, String date, String sorter) {
long offset = (long) (pageNumber - 1) * pageSize; if (StrUtil.isEmpty(sorter)) {
sorter = "patrolStatus@ascend";
}
if (StringUtils.isEmpty(date)) { if (StringUtils.isEmpty(date)) {
date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
} }
...@@ -2202,18 +2205,32 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2202,18 +2205,32 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
throw new RuntimeException("获取idx服务异常"); throw new RuntimeException("获取idx服务异常");
} }
List<Map<String, Object>> stations = response.getResult(); List<Map<String, Object>> stations = response.getResult();
List<HashMap<String, Object>> records = new ArrayList<>(pageSize); List<HashMap<String, Object>> records = new ArrayList<>();
long total = 0;
if (Objects.equals(patrolStatus, "undone")) { // 未开展
// 未开展 & (有漏检 || 无漏检) 直接返回空 List<HashMap<String, Object>> queryMaps = planTaskMapper.selectPatrolRecordPage(bizOrgCode, date);
if (Objects.nonNull(missStatus)) { Map<String, HashMap<String, Object>> hasDataMapInfo = queryMaps.stream().collect(Collectors.toMap(t -> t.get("bizOrgCode").toString(), t -> t));
return new PageImpl<>(records, new CommonPageable(), total); for (Map<String, Object> station : stations) {
} if (hasDataMapInfo.containsKey(station.get("bizOrgCode").toString())) {
// 未开展 HashMap<String, Object> queryMap = hasDataMapInfo.get(station.get("bizOrgCode").toString());
List<HashMap<String, Object>> queryMaps = planTaskMapper.selectPatrolRecordPage(offset, pageSize, bizOrgCode, missStatus, date); if (Integer.parseInt(queryMap.get("finishPointCount").toString()) > 0) {
List<String> doneStations = queryMaps.stream().map(record -> record.get("bizOrgCode").toString()).collect(Collectors.toList()); queryMap.put("patrolStatus", "已开展");
stations = stations.stream().filter(station -> !doneStations.contains(station.get("bizOrgCode").toString())).collect(Collectors.toList()); } else {
for (Map<String, Object> station : stations) { queryMap.put("patrolStatus", "未开展");
}
int totalValue = Integer.parseInt(queryMap.getOrDefault("allCount", "0").toString());
int missPointCount = Integer.parseInt(queryMap.getOrDefault("missPointCount", "0").toString());
int finishPointCount = Integer.parseInt(queryMap.getOrDefault("finishPointCount", "0").toString());
// 获取漏检率:missPointCount / totalValue
queryMap.put("missPointRate", getPercent((float) missPointCount, (float) totalValue));
// 执行进度:finishCount / totalValue
queryMap.put("finishRate", getPercent((float) finishPointCount, (float) totalValue));
String realStartTime = queryMap.getOrDefault("realStartTime", cn.hutool.core.date.DateUtil.now()).toString();
String realEndTime = queryMap.getOrDefault("realEndTime", cn.hutool.core.date.DateUtil.now()).toString();
long minutesBetween = this.getMinutesBetween(realStartTime, realEndTime);
queryMap.put("totalTime", minutesBetween);
records.add(queryMap);
} else {
HashMap<String, Object> record = new HashMap<>(); HashMap<String, Object> record = new HashMap<>();
record.put("bizOrgCode", station.get("bizOrgCode")); record.put("bizOrgCode", station.get("bizOrgCode"));
record.put("bizOrgName", station.get("bizOrgName")); record.put("bizOrgName", station.get("bizOrgName"));
...@@ -2226,52 +2243,26 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2226,52 +2243,26 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
record.put("missPointRate", 0); record.put("missPointRate", 0);
record.put("finishRate", 0); record.put("finishRate", 0);
record.put("totalTime", 0); record.put("totalTime", 0);
record.put("finishPointCount", 0);
records.add(record); records.add(record);
total++;
} }
} else { }
List<HashMap<String, Object>> queryMaps = planTaskMapper.selectPatrolRecordPage(offset, pageSize, bizOrgCode, missStatus, date);
List<String> doneStations = new ArrayList<>(queryMaps.size());
for (HashMap<String, Object> queryMap : queryMaps) {
queryMap.put("patrolStatus", "已开展");
int totalValue = Integer.parseInt(queryMap.getOrDefault("allCount", "0").toString());
int missPointCount = Integer.parseInt(queryMap.getOrDefault("missPointCount", "0").toString());
int finishPointCount = Integer.parseInt(queryMap.getOrDefault("finishPointCount", "0").toString());
// 获取漏检率:missPointCount / totalValue
queryMap.put("missPointRate", getPercent((float) missPointCount, (float) totalValue));
// 执行进度:finishCount / totalValue
queryMap.put("finishRate", getPercent((float) finishPointCount, (float) totalValue));
String realStartTime = queryMap.getOrDefault("realStartTime", cn.hutool.core.date.DateUtil.now()).toString();
String realEndTime = queryMap.getOrDefault("realEndTime", cn.hutool.core.date.DateUtil.now()).toString();
long minutesBetween = this.getMinutesBetween(realStartTime, realEndTime);
queryMap.put("totalTime", minutesBetween);
doneStations.add(queryMap.get("bizOrgCode").toString()); if (StrUtil.isNotEmpty(patrolStatus)) {
} if("undone".equals(patrolStatus)) {
records.addAll(queryMaps); records = records.stream().filter(item -> Integer.parseInt(item.get("finishPointCount").toString()) == 0).collect(Collectors.toList());
total = queryMaps.size(); } else {
if (!Objects.equals(patrolStatus, "done")) { records = records.stream().filter(item -> Integer.parseInt(item.get("finishPointCount").toString()) > 0).collect(Collectors.toList());
List<Map<String, Object>> undoneStations = stations.stream().filter(station -> !doneStations.contains(station.get("bizOrgCode").toString())).collect(Collectors.toList());
for (Map<String, Object> station : undoneStations) {
HashMap<String, Object> record = new HashMap<>();
record.put("bizOrgCode", station.get("bizOrgCode"));
record.put("bizOrgName", station.get("bizOrgName"));
record.put("time", date);
record.put("beginTime", '-');
record.put("endTime", '-');
record.put("patrolStatus", "未开展");
record.put("allCount", 0);
record.put("missPointCount", 0);
record.put("missPointRate", 0);
record.put("finishRate", 0);
record.put("totalTime", 0);
records.add(record);
total++;
}
} }
} }
if (StrUtil.isNotEmpty(missStatus)) {
if("miss".equals(missStatus)) {
records = records.stream().filter(item -> Integer.parseInt(item.get("missPointCount").toString()) > 0).collect(Collectors.toList());
} else {
records = records.stream().filter(item -> Integer.parseInt(item.get("missPointCount").toString()) == 0).collect(Collectors.toList());
}
}
// 排序 // 排序
if (org.springframework.util.StringUtils.hasText(sorter)) { if (org.springframework.util.StringUtils.hasText(sorter)) {
String sortField = sorter.split("@")[0]; String sortField = sorter.split("@")[0];
...@@ -2288,7 +2279,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2288,7 +2279,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
int size = Math.min(pageSize, records.size()); int size = Math.min(pageSize, records.size());
int endIndex = Math.min(startIndex + size, records.size()); int endIndex = Math.min(startIndex + size, records.size());
List<HashMap<String, Object>> finalRecords = records.subList(startIndex, endIndex); List<HashMap<String, Object>> finalRecords = records.subList(startIndex, endIndex);
return new PageImpl<>(finalRecords, new CommonPageable(), total); return new PageImpl<>(finalRecords, new CommonPageable(), records.size());
} }
@Override @Override
......
...@@ -5273,11 +5273,7 @@ ...@@ -5273,11 +5273,7 @@
) a1 ) a1
)) b1 )) b1
) c1 GROUP BY bizOrgName1) d ON d.bizOrgName1 = c.bizOrgName ) c1 GROUP BY bizOrgName1) d ON d.bizOrgName1 = c.bizOrgName
<where>
<if test="status != null and status != ''">
c.`status` = #{status}
</if>
</where>
<if test="sortField == 'bizOrgName'"> <if test="sortField == 'bizOrgName'">
<choose> <choose>
<when test="sortOrder == 'ascend'"> <when test="sortOrder == 'ascend'">
......
...@@ -1533,7 +1533,8 @@ ...@@ -1533,7 +1533,8 @@
FROM FROM
p_plan_task p_plan_task
<where> <where>
(finish_status = 2 OR finish_status = 3) <!-- (finish_status = 2 OR finish_status = 3)-->
finish_num > 0
AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE () AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE ()
<if test="bizOrgCode != null and bizOrgCode != ''"> <if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%') AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
...@@ -1782,10 +1783,8 @@ ...@@ -1782,10 +1783,8 @@
s1.date s1.date
</select> </select>
<select id="selectPatrolRecordPage" resultType="Map"> <select id="selectPatrolRecordPage" resultType="java.util.HashMap">
SELECT
*
FROM (
SELECT LEFT SELECT LEFT
( t.org_code, 18 ) AS bizOrgCode, ( t.org_code, 18 ) AS bizOrgCode,
u.biz_org_name AS bizOrgName, u.biz_org_name AS bizOrgName,
...@@ -1810,15 +1809,7 @@ ...@@ -1810,15 +1809,7 @@
</where> </where>
GROUP BY GROUP BY
LEFT ( t.org_code, 18 ),t.id LEFT ( t.org_code, 18 ),t.id
) t
<where>
<if test="missStatus == 'miss'">
AND missPointCount > 0
</if>
<if test="missStatus == 'noMiss'">
AND missPointCount = 0
</if>
</where>
</select> </select>
<select id="selectPatrolRecordTotal" resultType="long"> <select id="selectPatrolRecordTotal" resultType="long">
...@@ -1865,4 +1856,34 @@ ...@@ -1865,4 +1856,34 @@
GROUP BY GROUP BY
LEFT(t.org_code, 18) LEFT(t.org_code, 18)
</select> </select>
<select id="getDoneNum" resultType="java.lang.Integer">
SELECT
COUNT(DISTINCT LEFT(p_plan_task.org_code, 18)) AS value
FROM
p_plan_task
<where>
finish_num > 0
AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = #{date}
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
</where>
</select>
<select id="getDoneList" resultType="java.util.Map">
SELECT
COUNT( 1 ) AS num,
LEFT ( p_plan_task.org_code, 18 ) AS `code`
FROM
p_plan_task
<where>
finish_num > 0
AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = #{date}
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
</where>
GROUP BY LEFT ( p_plan_task.org_code, 18 )
</select>
</mapper> </mapper>
\ No newline at end of file
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