Commit 18ccbad9 authored by KeYong's avatar KeYong

提交巡查报表

parent 409c5167
......@@ -1079,4 +1079,19 @@ public class PlanTaskController extends AbstractBaseController {
planTaskService.download(request, response, taskDetailId);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "idx消防巡查报表调用", notes = "idx消防巡查报表调用")
@RequestMapping(value = "/report/info", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getPlanTaskInfoList(@ApiParam(value = "站编码") @RequestParam String bizOrgCode,
@ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
@ApiParam(value = "结束日期", required = true) @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
try {
Map<String, Object> map = planTaskService.queryPatrolInfoList(bizOrgCode, startDate, endDate);
return CommonResponseUtil.success(map);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("远程查询巡检信息失败!");
}
}
}
......@@ -220,4 +220,8 @@ public interface PlanTaskMapper extends BaseMapper {
List<Map<String, Object>> getCheckNotQualifiedEquipInfo(@Param(value="taskDetailId") String taskDetailId);
String getCheckIdByDetailId(@Param(value="taskDetailId") String taskDetailId);
Map<String, Object> queryPatrolInfoList(@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);
}
......@@ -1846,6 +1846,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return resultMap;
}
@Override
public Map<String, Object> queryPatrolInfoList(String bizOrgCode, Date startDate, Date endDate) {
Map<String, Object> map = new HashMap<>();
map = planTaskMapper.queryPatrolInfoList(bizOrgCode, startDate, endDate);
Map<String, Object> map1 = new HashMap<>();
map1 = planTaskMapper.queryPatrolEquipInfo(bizOrgCode, startDate, endDate);
map.put("equipment_count", map1.get("equipment_count"));
map.put("checked_equipment_count", map1.get("checked_equipment_count"));
map.put("unchecked_equipment_count", map1.get("unchecked_equipment_count"));
return map;
}
@Override
public void download(HttpServletRequest request, HttpServletResponse response, String taskDetailId) throws UnsupportedEncodingException {
......
......@@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -197,4 +198,6 @@ public interface IPlanTaskService {
Map<String, String> preview(String taskDetailId);
void download(HttpServletRequest request, HttpServletResponse response, String taskDetailId) throws UnsupportedEncodingException;
Map<String,Object> queryPatrolInfoList(String bizOrgCode, Date startDate, Date endDate);
}
......@@ -1431,4 +1431,136 @@
AND code = #{companyCode}
</if>
</select>
<select id="queryPatrolInfoList" resultType="Map">
SELECT
IFNULL(COUNT(temp.plan_task_id), 0) AS task_count,
IFNULL(SUM(IF(finish_status=2, 1, 0)), 0) AS complete_task_count,
IFNULL(SUM(IF((finish_status=0 OR finish_status=1 OR finish_status=3), 1, 0)), 0) AS uncomplete_task_count,
temp.person_count AS person_count,
temp.certified_person_count AS certified_person_count,
IFNULL(SUM(temp.point_num), 0) AS checked_point_count
FROM
(
SELECT
pt.id AS task_id,
r.`name` route_name,
pt.route_id,
p.`name` plan_name,
pt.plan_id,
pt.id AS plan_task_id,
pt.begin_time,
pt.end_time,
pt.user_name,
pt.user_id,
IF
(
pt.user_id IS NOT NULL,(
LENGTH( pt.user_id ) - LENGTH(
REPLACE ( pt.user_id, ',', '' )) + 1
),
0
) AS person_count,
(
SELECT
IF
(
SUM( is_certificate ) IS NULL,
0,
SUM( is_certificate ))
FROM
`cb_org_usr`
WHERE
FIND_IN_SET( amos_org_id, pt.user_id ) > 0
) AS certified_person_count,
pt.point_num,
pt.finish_num,
pt.finish_status,
p.org_code,
p.biz_org_code AS biz_org_code,
p.biz_org_name AS biz_org_name,
pt.end_time AS `date`
FROM
`p_plan_task` pt
LEFT JOIN p_plan p ON p.id = pt.plan_id
LEFT JOIN p_route r ON r.id = pt.route_id
<where>
<if test="bizOrgCode != null">
pt.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
<if test="startDate != null">
AND DATE_FORMAT(pt.end_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null">
AND DATE_FORMAT(pt.end_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
</where>
) temp
</select>
<select id="queryPatrolEquipInfo" resultType="Map">
SELECT
IFNULL(COUNT(temp.eq_id IS NOT NULL), 0) AS equipment_count,
IFNULL(SUM(IF((temp.check_status=2 OR temp.check_status=1 AND temp.eq_id IS NOT NULL), 1, 0)), 0) AS checked_equipment_count,
IFNULL(SUM(IF((temp.check_status=3 AND temp.eq_id IS NOT NULL), 1, 0)), 0) AS unchecked_equipment_count
FROM
(
SELECT
ci.id,
es.org_code,
pp.biz_org_code AS biz_org_code,
pp.biz_org_name AS biz_org_name,
c.point_id,
c.point_name,
ci.input_name,
ci.input_value,
c.check_time,
pt.end_time AS `date`,
c.plan_id,
c.plan_name,
c.route_id,
c.route_name,
ci.is_ok AS check_status,
c.user_id,
c.user_name,
c.dep_id,
c.dep_name,
es.id AS eq_id,
es.NAME eq_name,
es.`code` eq_code,
( SELECT GROUP_CONCAT( ffs.NAME ) FROM f_fire_fighting_system ffs WHERE find_in_set( ffs.id, es.system_id ) ) AS system_name,
CONCAT( pt.id, '' ) AS plan_task_id,
pt.end_time AS plan_completion_time,
c.id AS check_id,
p.point_no,
cou.`code` AS company_code,
es.equipment_code AS equipment_type_code,
pii.item_no AS input_code,
p.point_no AS pointCode,
wws.`code` AS buildCode,
wws.full_name AS buildName
FROM
p_check_input ci
LEFT JOIN p_input_item pii ON pii.id = ci.input_id
LEFT JOIN p_check c ON c.id = ci.check_id
LEFT JOIN p_plan_task pt ON pt.id = c.plan_task_id
left join p_plan pp on pp.id = pt.plan_id
LEFT JOIN p_point_classify pc ON pc.id = ci.point_classify_id
LEFT JOIN wl_equipment_specific es ON es.id = pc.equipment_id
LEFT JOIN p_point p ON c.point_id = p.id
LEFT JOIN wl_warehouse_structure wws ON wws.id = p.risk_source_id
left join cb_org_usr cou on cou.biz_org_code = pp.biz_org_code and cou.is_delete = 0
<where>
<if test="bizOrgCode != null">
biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
<if test="startDate != null">
AND DATE_FORMAT(`date`, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null">
AND DATE_FORMAT(`date`, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
</where>
) temp
</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