Commit 8e8b2fa2 authored by 李秀明's avatar 李秀明

fix(patrol) 巡检接口bug处理

parent ea000999
......@@ -24,8 +24,8 @@ public class FaultCaseServiceImpl extends ServiceImpl<FaultCaseMapper, FaultCase
@Override
public Page<FaultCase> listPage(Page page, FaultCase faultCase) {
Page<FaultCase> pages = this.baseMapper.listPage(page, faultCase);
if (0 < pages.getRecords().size()) {
pages.getRecords().stream().map(x -> x.setFaultLevel(EmergencyLevelEum.getNameByCode(x.getFaultLevel()))).collect(Collectors.toList());
if (!pages.getRecords().isEmpty()) {
pages.getRecords().forEach(x -> x.setFaultLevel(EmergencyLevelEum.getNameByCode(x.getFaultLevel())));
}
return pages;
}
......
......@@ -1102,8 +1102,8 @@ public class PlanTaskController extends AbstractBaseController {
@ApiParam(value = "开始日期") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
@ApiParam(value = "结束日期") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
try {
Map<String, Object> map = planTaskService.queryPatrolInfo(bizOrgCode, startDate, endDate);
return CommonPatrolResponseUtil.success(map);
List<Map<String, Object>> result = planTaskService.queryPatrolInfo(bizOrgCode, startDate, endDate);
return CommonPatrolResponseUtil.success(result);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonPatrolResponseUtil.failure("远程查询巡检信息失败!");
......
......@@ -2101,12 +2101,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
public Map<String, Object> queryPatrolInfo(String bizOrgCode, Date startDate, Date endDate) {
public List<Map<String, Object>> queryPatrolInfo(String bizOrgCode, Date startDate, Date endDate) {
List<Map<String, Object>> list = new ArrayList<>();
list = planTaskMapper.queryPatrolInfo(bizOrgCode, startDate, endDate);
Map<String, Object> map = new HashMap<>();
map.put("patrol", list);
return map;
return planTaskMapper.queryPatrolInfo(bizOrgCode, startDate, endDate);
}
public static byte[] file2byte(File file) {
......
......@@ -201,6 +201,6 @@ public interface IPlanTaskService {
Map<String,Object> queryPatrolInfoList(String bizOrgCode, Date startDate, Date endDate);
Map<String,Object> queryPatrolInfo(String bizOrgCode, Date startDate, Date endDate);
List<Map<String, Object>> queryPatrolInfo(String bizOrgCode, Date startDate, Date endDate);
}
......@@ -263,7 +263,7 @@
p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id
) a
<include refid="plan-task-app-where"/>
<if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
......@@ -514,7 +514,7 @@
ptd.route_id routeId,
ptd.plan_id planId,
ptd.user_id AS userId,
ptd.end_time AS endTime,
pptd.id as planTaskDetailId,
(select p_plan.dept_id from p_plan where p_plan.id=ptd.plan_id) depId
......@@ -1589,54 +1589,52 @@
<select id="queryPatrolInfo" resultType="Map">
SELECT
s1.date,
IFNULL(s2.`name`, '') AS `name`,
IFNULL(s2.`code`, '') AS `code`,
IFNULL(s2.`planPerson`, '') AS planPerson,
IFNULL(s2.`chargePerson`, '') AS chargePerson,
IFNULL(s2.`beginTime`, '') AS beginTime,
IFNULL(s2.`endTime`, '') AS endTime,
'patrol' AS type
s1.date,
IFNULL(s2.`name`, '') AS `name`,
IFNULL(s2.`code`, '') AS `code`,
IFNULL(s2.`planPerson`, '') AS planPerson,
IFNULL(s2.`chargePerson`, '') AS chargePerson,
IFNULL(s2.`beginTime`, '') AS beginTime,
IFNULL(s2.`endTime`, '') AS endTime,
'patrol' AS type
FROM
(
SELECT
@s := @s + 1 AS `index`,
DATE_FORMAT( DATE_ADD(( DATE( DATE_ADD(#{endDate}, INTERVAL - DATEDIFF(#{endDate}, #{startDate}) DAY ))), INTERVAL @s DAY ), '%Y-%m-%d' ) AS date
FROM
mysql.help_topic,
( SELECT @s := -1 ) temp
WHERE
@s &lt; DATEDIFF(#{endDate}, #{startDate})
SELECT
@s := @s + 1 AS `index`,
DATE_FORMAT( DATE_ADD(( DATE( DATE_ADD(#{endDate}, INTERVAL - DATEDIFF(#{endDate}, #{startDate}) DAY ))), INTERVAL @s DAY ), '%Y-%m-%d' ) AS date
FROM
mysql.help_topic,
( SELECT @s := -1 ) temp
WHERE
@s &lt; DATEDIFF(#{endDate}, #{startDate})
) s1
LEFT JOIN (
SELECT
s.*
FROM
(
SELECT
p.`name`,
pt.batch_no AS `code`,
pt.user_name AS planPerson,
pt.user_name AS chargePerson,
pt.begin_time AS beginTime,
pt.end_time AS endTime,
DATE_FORMAT(pt.check_date, '%Y-%m-%d') AS date
FROM
`p_plan_task` pt
LEFT JOIN p_plan p ON p.id = pt.plan_id
<where>
pt.finish_status=2
<if test="bizOrgCode != null">
AND p.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
</where>
GROUP BY
LEFT (pt.check_date, 10)
ORDER BY
pt.check_date
) s
) s2 ON s2.date = s1.date
LEFT JOIN (
SELECT
s.*
FROM
(
SELECT
p.`name`,
pt.batch_no AS `code`,
pt.user_name AS planPerson,
pt.user_name AS chargePerson,
pt.begin_time AS beginTime,
pt.end_time AS endTime,
DATE_FORMAT(pt.check_date, '%Y-%m-%d') AS date
FROM
`p_plan_task` pt
LEFT JOIN p_plan p ON p.id = pt.plan_id
<where>
pt.finish_status=2
<if test="bizOrgCode != null">
AND p.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
</where>
ORDER BY
pt.check_date
) s
) s2 ON s2.date = s1.date
ORDER BY
s1.date
s1.date
</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