Commit 47ec6628 authored by 李秀明's avatar 李秀明

Merge remote-tracking branch 'origin/develop_dl_bugfix_0723' into develop_dl_bugfix_0723

parents 0c2be6c1 3030f80e
package com.yeejoin.equipmanage.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -231,8 +232,7 @@ public class PoolStatisticController {
sortOrder = sorter.split("@")[1];
}
Page<Map<String, Object>> page1 = fireFightingSystemMapper.getWaterInfoList(page, bizOrgCode, sortField, sortOrder, status);
List<Map<String, Object>> res = page1.getRecords();
List<Map<String, Object>> res = fireFightingSystemMapper.getWaterInfoList(bizOrgCode, sortField, sortOrder);
if (!res.isEmpty()) {
for (Map<String, Object> m : res) {
Map<String, Object> transResult = UnitTransformUtil.transformValues(String.valueOf(m.get("nowLevel")),
......@@ -263,9 +263,19 @@ public class PoolStatisticController {
m.put("status", "0");
}
}
page1.setRecords(res);
}
return CommonResponseUtil.success(page1);
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(page);
}
@RequestMapping(value = "/selectWaterLevelDetail", method = RequestMethod.GET)
......
......@@ -356,7 +356,7 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
* @param bizOrgCode
* @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 {
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(
@Param(value="offset") long offset,
@Param(value="pageSize") long pageSize,
@Param(value="bizOrgCode") String bizOrgCode,
@Param(value="missStatus") String missStatus,
@Param(value="date") String date
);
Long selectPatrolRecordTotal(
......@@ -359,4 +356,10 @@ public interface PlanTaskMapper extends BaseMapper {
@Param(value="bizOrgCode") String bizOrgCode,
@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;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -2173,7 +2175,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
throw new RuntimeException("获取idx服务异常");
}
List<Map<String, Object>> stations = response.getResult();
AtomicInteger doneNum = new AtomicInteger(); // 已开展
AtomicInteger missNum = new AtomicInteger(); // 有漏检
List<Map<String, String>> queryMaps = planTaskMapper.selectPatrolActivityStats(bizOrgCode, date);
for (Map<String, String> queryMap : queryMaps) {
......@@ -2181,11 +2182,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if (Objects.equals(missStatus, "有漏检")) {
missNum.incrementAndGet();
}
doneNum.incrementAndGet();
}
Integer doneNum = planTaskMapper.getDoneNum(bizOrgCode, date);
return new HashMap<String, Number>() {{
this.put("done", doneNum.intValue());
this.put("undone", stations.size() - doneNum.intValue());
this.put("done", doneNum);
this.put("undone", stations.size() - doneNum);
this.put("miss", missNum);
this.put("noMiss", stations.size() - missNum.intValue());
}};
......@@ -2193,7 +2194,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Override
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)) {
date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
......@@ -2202,38 +2205,19 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
throw new RuntimeException("获取idx服务异常");
}
List<Map<String, Object>> stations = response.getResult();
List<HashMap<String, Object>> records = new ArrayList<>(pageSize);
long total = 0;
if (Objects.equals(patrolStatus, "undone")) {
// 未开展 & (有漏检 || 无漏检) 直接返回空
if (Objects.nonNull(missStatus)) {
return new PageImpl<>(records, new CommonPageable(), total);
}
List<HashMap<String, Object>> records = new ArrayList<>();
// 未开展
List<HashMap<String, Object>> queryMaps = planTaskMapper.selectPatrolRecordPage(offset, pageSize, bizOrgCode, missStatus, date);
List<String> doneStations = queryMaps.stream().map(record -> record.get("bizOrgCode").toString()).collect(Collectors.toList());
stations = stations.stream().filter(station -> !doneStations.contains(station.get("bizOrgCode").toString())).collect(Collectors.toList());
List<HashMap<String, Object>> queryMaps = planTaskMapper.selectPatrolRecordPage(bizOrgCode, date);
Map<String, HashMap<String, Object>> hasDataMapInfo = queryMaps.stream().collect(Collectors.toMap(t -> t.get("bizOrgCode").toString(), t -> t));
for (Map<String, Object> station : stations) {
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++;
}
} 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) {
if (hasDataMapInfo.containsKey(station.get("bizOrgCode").toString())) {
HashMap<String, Object> queryMap = hasDataMapInfo.get(station.get("bizOrgCode").toString());
if (Integer.parseInt(queryMap.get("finishPointCount").toString()) > 0) {
queryMap.put("patrolStatus", "已开展");
} else {
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());
......@@ -2241,20 +2225,12 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
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());
}
records.addAll(queryMaps);
total = queryMaps.size();
if (!Objects.equals(patrolStatus, "done")) {
List<Map<String, Object>> undoneStations = stations.stream().filter(station -> !doneStations.contains(station.get("bizOrgCode").toString())).collect(Collectors.toList());
for (Map<String, Object> station : undoneStations) {
records.add(queryMap);
} else {
HashMap<String, Object> record = new HashMap<>();
record.put("bizOrgCode", station.get("bizOrgCode"));
record.put("bizOrgName", station.get("bizOrgName"));
......@@ -2267,11 +2243,26 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
record.put("missPointRate", 0);
record.put("finishRate", 0);
record.put("totalTime", 0);
record.put("finishPointCount", 0);
records.add(record);
total++;
}
}
if (StrUtil.isNotEmpty(patrolStatus)) {
if("undone".equals(patrolStatus)) {
records = records.stream().filter(item -> Integer.parseInt(item.get("finishPointCount").toString()) == 0).collect(Collectors.toList());
} else {
records = records.stream().filter(item -> Integer.parseInt(item.get("finishPointCount").toString()) > 0).collect(Collectors.toList());
}
}
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)) {
String sortField = sorter.split("@")[0];
......@@ -2288,7 +2279,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
int size = Math.min(pageSize, records.size());
int endIndex = Math.min(startIndex + size, records.size());
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
......
......@@ -5273,11 +5273,7 @@
) a1
)) b1
) 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'">
<choose>
<when test="sortOrder == 'ascend'">
......
......@@ -1533,7 +1533,8 @@
FROM
p_plan_task
<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 ()
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
......@@ -1782,10 +1783,8 @@
s1.date
</select>
<select id="selectPatrolRecordPage" resultType="Map">
SELECT
*
FROM (
<select id="selectPatrolRecordPage" resultType="java.util.HashMap">
SELECT LEFT
( t.org_code, 18 ) AS bizOrgCode,
u.biz_org_name AS bizOrgName,
......@@ -1810,15 +1809,7 @@
</where>
GROUP BY
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 id="selectPatrolRecordTotal" resultType="long">
......@@ -1865,4 +1856,34 @@
GROUP BY
LEFT(t.org_code, 18)
</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>
\ 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