Commit be7d8aae authored by 李秀明's avatar 李秀明

巡检接口

parent e417adb1
package com.yeejoin.amos.patrol.business.controller; package com.yeejoin.amos.patrol.business.controller;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.component.feign.model.Page;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService; import com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.patrol.business.util.CommonResponse; import com.yeejoin.amos.patrol.business.util.CommonResponse;
import com.yeejoin.amos.patrol.business.util.CommonResponseUtil; import com.yeejoin.amos.patrol.business.util.CommonResponseUtil;
...@@ -71,4 +72,37 @@ public class ControlScreenController extends AbstractBaseController { ...@@ -71,4 +72,37 @@ public class ControlScreenController extends AbstractBaseController {
} }
return CommonResponseUtil.success(iPlanTaskService.getStationStatics(bizOrgCode)); return CommonResponseUtil.success(iPlanTaskService.getStationStatics(bizOrgCode));
} }
@GetMapping("/patrol-activity/stats")
@ApiOperation(value = "消防巡检统计")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public CommonResponse getPatrolActivityStats(
@RequestParam(value = "date", required = false) String date,
@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode
) {
if (StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
bizOrgCode = reginParams.getPersonIdentity().getCompanyBizOrgCode();
}
return CommonResponseUtil.success(iPlanTaskService.getPatrolActivityStats( bizOrgCode, date));
}
@GetMapping("/patrol-record/page")
@ApiOperation(value = "消防巡检列表")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public CommonResponse getPatrolRecordPage(
@RequestParam("pageNumber") Integer pageNumber,
@RequestParam("pageSize") Integer pageSize,
@RequestParam(value = "date", required = false) String date,
@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode,
@RequestParam(value = "patrolStatus", required = false) String patrolStatus,
@RequestParam(value = "missStatus", required = false) String missStatus,
@RequestParam(value = "sorter", required = false) String sorter
) {
if (StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
bizOrgCode = reginParams.getPersonIdentity().getCompanyBizOrgCode();
}
return CommonResponseUtil.success(iPlanTaskService.getPatrolRecordPage(pageNumber, pageSize, bizOrgCode, patrolStatus, missStatus, date, sorter));
}
} }
...@@ -341,4 +341,28 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -341,4 +341,28 @@ public interface PlanTaskMapper extends BaseMapper {
Map<String, Object> queryPatrolEquipInfo(@Param(value="bizOrgCode") String bizOrgCode, @Param(value="startDate") Date startDate, @Param(value="endDate") Date endDate); Map<String, Object> queryPatrolEquipInfo(@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<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="patrolStatus") String patrolStatus,
@Param(value="missStatus") String missStatus,
@Param(value="date") String date,
@Param(value="sortField") String sortField,
@Param(value="sortOrder") String sortOrder
);
Long selectPatrolRecordTotal(
@Param(value="bizOrgCode") String bizOrgCode,
@Param(value="patrolStatus") String patrolStatus,
@Param(value="missStatus") String missStatus,
@Param(value="date") String date,
@Param(value="sortField") String sortField,
@Param(value="sortOrder") String sortOrder
);
Map<String, Number> selectPatrolActivityStats(
@Param(value="bizOrgCode") String bizOrgCode,
@Param(value="date") String date
);
} }
...@@ -60,7 +60,7 @@ public interface JcsFeignClient { ...@@ -60,7 +60,7 @@ public interface JcsFeignClient {
FeignClientResult<List<Map<String, Object>>> selectByIdList(@RequestBody List<String> id); FeignClientResult<List<Map<String, Object>>> selectByIdList(@RequestBody List<String> id);
@GetMapping(value = "/org-usr/getCompanyInfo") @GetMapping(value = "/org-usr/getCompanyInfo")
ResponseModel<Object> getCompanyInfo(@RequestParam(value = "companyId") String companyId); ResponseModel<Object> getCompanyInfo(@RequestParam(value = "companyId") String companyId);
@PostMapping (value = "/org-usr/selectByIdDeptList") @PostMapping (value = "/org-usr/selectByIdDeptList")
...@@ -73,6 +73,6 @@ public interface JcsFeignClient { ...@@ -73,6 +73,6 @@ public interface JcsFeignClient {
FeignClientResult<List<Map<String, Object>>> getDetByCompanyId(); FeignClientResult<List<Map<String, Object>>> getDetByCompanyId();
@GetMapping(value = "/org-person/listCompany/{bizOrgCode}") @GetMapping(value = "/org-person/listCompany/{bizOrgCode}")
Object listCompany(@PathVariable(value="bizOrgCode") String bizOrgCode) ; Object listCompany(@PathVariable(value="bizOrgCode") String bizOrgCode) ;
} }
...@@ -2149,6 +2149,33 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -2149,6 +2149,33 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return resultMap; return resultMap;
} }
/**
*
* @param bizOrgCode
* @param date
* @return
*/
@Override
public Map<String, Number> getPatrolActivityStats(String bizOrgCode, String date) {
return planTaskMapper.selectPatrolActivityStats(bizOrgCode, date);
}
@Override
public Page<HashMap<String, Object>> getPatrolRecordPage(Integer pageNumber, Integer pageSize, String bizOrgCode, String patrolStatus, String missStatus, String date, String sorter) {
long offset = pageNumber - 1;
if (StringUtils.isEmpty(date)) {
date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
String sortField = "", sortOrder = "";
if (org.springframework.util.StringUtils.hasText(sorter)) {
sortField = sorter.split("@")[0];
sortOrder = sorter.split("@")[1];
}
List<HashMap<String, Object>> maps = planTaskMapper.selectPatrolRecordPage(offset, pageSize, bizOrgCode, patrolStatus, missStatus, date, sortField, sortOrder);
Long total = planTaskMapper.selectPatrolRecordTotal(bizOrgCode, patrolStatus, missStatus, date, sortField, sortOrder);
return new PageImpl<>(maps, new CommonPageable(), total);
}
@Override @Override
public List<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<Map<String, Object>> list = new ArrayList<>();
......
...@@ -206,4 +206,8 @@ public interface IPlanTaskService { ...@@ -206,4 +206,8 @@ public interface IPlanTaskService {
Map<String,Number> getCenterStatics(String bizOrgCode); Map<String,Number> getCenterStatics(String bizOrgCode);
Map<String,Number> getStationStatics(String bizOrgCode); Map<String,Number> getStationStatics(String bizOrgCode);
Map<String,Number> getPatrolActivityStats(String bizOrgCode, String date);
Page<HashMap<String, Object>> getPatrolRecordPage(Integer pageNumber, Integer pageSize, String bizOrgCode, String patrolStatus, String missStatus, String date, String sorter);
} }
...@@ -1774,4 +1774,134 @@ ...@@ -1774,4 +1774,134 @@
ORDER BY ORDER BY
s1.date s1.date
</select> </select>
<select id="selectPatrolRecordPage" resultType="Map">
SELECT
*
FROM (
SELECT
LEFT(t.org_code, 18) AS bizOrgCode,
u.biz_org_name bizOrgName,
DATE_FORMAT( t.check_date, '%Y-%m-%d' ) AS time,
IF(SUM(IF(t.finish_status = 2 , 1, 0)) > 0, '已开展', '未开展') AS patrolStatus,
IFNULL(SUM( t.point_num ), 0) AS allCount,
IFNULL(SUM(IF(t.finish_status = 3, t.point_num, 0)), 0) AS missPointCount,
IFNULL(SUM(IF(t.finish_status = 2, t.point_num, 0)), 0) AS finishCount,
-- 漏查率 missPointCount / allCount
CONCAT(ROUND(IFNULL(SUM(IF(t.finish_status = 3, t.point_num, 0)), 0) / IFNULL(SUM( t.point_num ), 0), 2), '%') AS missPointRate,
-- 执行进度 finishCount / allCount
CONCAT(ROUND(IFNULL(SUM(IF(t.finish_status = 2, t.point_num, 0)), 0) / IFNULL(SUM( t.point_num ), 0), 2), '%') AS finishRate,
-- 总耗时
SUM(TIMESTAMPDIFF(MINUTE, t.begin_time, d.executor_date)) AS totalTime
FROM p_plan_task t
LEFT JOIN p_plan_task_detail d on t.id = d.task_no
LEFT JOIN cb_org_usr u on u.biz_org_code = left(t.org_code, 18)
WHERE
DATE_FORMAT( t.check_date, '%Y-%m-%d' ) = #{date}
<if test="bizOrgCode != null and bizOrgCode != ''">
AND u.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
GROUP BY
LEFT(t.org_code, 18)
) t
<where>
<if test="patrolStatus == 'done'">
AND patrolStatus = '已开展'
</if>
<if test="patrolStatus == 'undone'">
AND patrolStatus = '未开展'
</if>
<if test="missStatus == 'true'">
AND missPointCount > 0
</if>
<if test="missStatus == 'false'">
AND missPointCount = 0
</if>
</where>
ORDER BY
<if test="sortField != null and sortField != ''">
<choose>
<when test="sortOrder == 'ascend'">
${sortField} ASC
</when>
<otherwise>
${sortField} DESC
</otherwise>
</choose>
</if>
<if test="sortField == null or sortField == ''">
time DESC
</if>
LIMIT #{offset}, #{pageSize}
</select>
<select id="selectPatrolRecordTotal" resultType="long">
SELECT
COUNT(t.bizOrgCode)
FROM (
SELECT
LEFT(t.org_code, 18) AS bizOrgCode,
u.biz_org_name bizOrgName,
DATE_FORMAT( t.check_date, '%Y-%m-%d' ) AS time,
IF(SUM(IF(t.finish_status = 2 , 1, 0)) > 0, '已开展', '未开展') AS patrolStatus,
IFNULL(SUM( t.point_num ), 0) AS allCount,
IFNULL(SUM(IF(t.finish_status = 3, t.point_num, 0)), 0) AS missPointCount,
IFNULL(SUM(IF(t.finish_status = 2, t.point_num, 0)), 0) AS finishCount,
-- 漏查率 missPointCount / allCount
CONCAT(ROUND(IFNULL(SUM(IF(t.finish_status = 3, t.point_num, 0)), 0) / IFNULL(SUM( t.point_num ), 0), 2), '%') AS missPointRate,
-- 执行进度 finishCount / allCount
CONCAT(ROUND(IFNULL(SUM(IF(t.finish_status = 2, t.point_num, 0)), 0) / IFNULL(SUM( t.point_num ), 0), 2), '%') AS finishRate,
-- 总耗时
SUM(TIMESTAMPDIFF(MINUTE, t.begin_time, d.executor_date)) AS totalTime
FROM p_plan_task t
LEFT JOIN p_plan_task_detail d on t.id = d.task_no
LEFT JOIN cb_org_usr u on u.biz_org_code = left(t.org_code, 18)
WHERE
DATE_FORMAT( t.check_date, '%Y-%m-%d' ) = #{date}
<if test="bizOrgCode != null and bizOrgCode != ''">
AND u.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
GROUP BY
LEFT(t.org_code, 18)
) t
<where>
<if test="patrolStatus == 'done'">
AND patrolStatus = '已开展'
</if>
<if test="patrolStatus == 'undone'">
AND patrolStatus = '未开展'
</if>
<if test="missStatus == 'true'">
AND missPointCount > 0
</if>
<if test="missStatus == 'false'">
AND missPointCount = 0
</if>
</where>
</select>
<select id="selectPatrolActivityStats" resultType="Map">
SELECT
IFNULL(SUM(IF(patrolStatus = '已开展', 1, 0)), 0) AS done,
IFNULL(SUM(IF(patrolStatus = '未开展', 1, 0)), 0) AS undone,
IFNULL(SUM(IF(missStatus = '无漏检', 1, 0)), 0) AS noMiss,
IFNULL(SUM(IF(missStatus = '有漏检', 1, 0)), 0) AS miss
FROM (
SELECT
IF(SUM(IF(t.finish_status = 2 , 1, 0)) > 0, '已开展', '未开展') AS patrolStatus,
IF(SUM(IF(t.finish_status = 3, t.point_num, 0)) > 0, '有漏检', '无漏检') AS missStatus
FROM
p_plan_task t
<where>
<if test="date != null and date != ''">
AND DATE_FORMAT( t.check_date, '%Y-%m-%d' ) = #{date}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND t.org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
</where>
GROUP BY
LEFT(t.org_code, 18)
) t
</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