Commit 0feb06f1 authored by tangwei's avatar tangwei

巡检统计首页增加接口

parent 7b799d41
package com.yeejoin.amos.patrol.business.controller;
import com.yeejoin.amos.component.robot.BadRequest;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.service.impl.TaskServiceImpl;
import com.yeejoin.amos.patrol.business.util.CommonResponse;
import com.yeejoin.amos.patrol.business.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Case;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: tw
* @createDate: 2024/8/20
*/
@RestController
@RequestMapping(value = "/api/inspection/statistics")
@Api(tags = "巡检统计页面")
public class InspectionStatisticsController extends AbstractBaseController {
@Autowired
TaskServiceImpl taskServiceImpl;
@ApiOperation(value = "巡查点统计饼状图,已巡检未巡检", notes = "巡查点统计饼状图,已巡检未巡检")
@GetMapping(value = "/point/statistics/xj")
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth=false)
public CommonResponse detailxj(
@ApiParam(value = "线路关键字", required = false) @RequestParam String name,
@ApiParam(value = "统计分类", required = true) @RequestParam String type) {
String timeType="";
switch (type) {
case "日":
timeType="d";
name= ( name!=null&&!"".equals(name)? "-日-"+name:null);
break;
case "月":
timeType="m";
name= ( name!=null&&!"".equals(name)? "-月-"+name:null);
break;
case "季":
timeType="j";
name= ( name!=null&&!"".equals(name)? "-季-"+name:null);
break;
case "年":
timeType="yr";
name= ( name!=null&&!"".equals(name)? "-年-"+name:null);
break;
default:
throw new BadRequest("类型错误.");
}
List<Map<String, Object>> data= taskServiceImpl.getStatisticsByTypeXJ( name, timeType);
return CommonResponseUtil.success(data);
}
@ApiOperation(value = "巡查点统计饼状图,合格不合格", notes = "巡查点统计饼状图,合格不合格")
@GetMapping(value = "/point/statistics/hg")
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth=false)
public CommonResponse detailhg(
@ApiParam(value = "线路关键字", required = false) @RequestParam String name,
@ApiParam(value = "统计分类", required = true) @RequestParam String type) {
String timeType="";
switch (type) {
case "日":
timeType="d";
name= ( name!=null&&!"".equals(name)? "-日-"+name:null);
break;
case "月":
timeType="m";
name= ( name!=null&&!"".equals(name)? "-月-"+name:null);
break;
case "季":
timeType="j";
name= ( name!=null&&!"".equals(name)? "-季-"+name:null);
break;
case "年":
timeType="yr";
name= ( name!=null&&!"".equals(name)? "-年-"+name:null);
break;
default:
throw new BadRequest("类型错误.");
}
List<Map<String, Object>> data= taskServiceImpl.getStatisticsByTypeHG( name, timeType);
return CommonResponseUtil.success(data);
}
@ApiOperation(value = "日巡检线路区域", notes = "日巡检线路区域")
@GetMapping(value = "/point/statistics/qy")
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth=false)
public CommonResponse detailqy(
@ApiParam(value = "统计分类", required = true) @RequestParam String type) {
String name="";
switch (type) {
case "日":
name="-日-";
break;
case "月":
name="-月-";
break;
case "季":
name="-季-";
break;
case "年":
name="-年-";
break;
default:
throw new BadRequest("类型错误.");
}
List<Map<String, Object>> data= taskServiceImpl.getLinetype( name);
return CommonResponseUtil.success(data);
}
@ApiOperation(value = "巡检不合格", notes = "巡检不合格")
@GetMapping(value = "/point/statistics/xjbhg")
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth=false)
public CommonResponse detailxjbhg(
@ApiParam(value = "线路关键字", required = false) @RequestParam String name,
@ApiParam(value = "统计分类", required = true) @RequestParam String type,
@ApiParam(value = "线路关键字", required = true) @RequestParam int pageNumber,
@ApiParam(value = "统计分类", required = true) @RequestParam int pageSize) {
String timeType="";
switch (type) {
case "日":
timeType="d";
name= ( name!=null&&!"".equals(name)? "-日-"+name:null);
break;
case "月":
timeType="m";
name= ( name!=null&&!"".equals(name)? "-月-"+name:null);
break;
case "季":
timeType="j";
name= ( name!=null&&!"".equals(name)? "-季-"+name:null);
break;
case "年":
timeType="yr";
name= ( name!=null&&!"".equals(name)? "-年-"+name:null);
break;
default:
throw new BadRequest("类型错误.");
}
Page<Map<String, Object>> data= taskServiceImpl.getLinetypeUnqualified( pageNumber, pageSize, name, timeType);
return CommonResponseUtil.success(data);
}
@ApiOperation(value = "未巡检", notes = "未巡检")
@GetMapping(value = "/point/statistics/wxj")
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth=false)
public CommonResponse detailwxj(
@ApiParam(value = "线路关键字", required = false) @RequestParam String name,
@ApiParam(value = "统计分类", required = true) @RequestParam String type,
@ApiParam(value = "线路关键字", required = true) @RequestParam int pageNumber,
@ApiParam(value = "统计分类", required = true) @RequestParam int pageSize) {
String timeType="";
switch (type) {
case "日":
timeType="d";
name= ( name!=null&&!"".equals(name)? "-日-"+name:null);
break;
case "月":
timeType="m";
name= ( name!=null&&!"".equals(name)? "-月-"+name:null);
break;
case "季":
timeType="j";
name= ( name!=null&&!"".equals(name)? "-季-"+name:null);
break;
case "年":
timeType="yr";
name= ( name!=null&&!"".equals(name)? "-年-"+name:null);
break;
default:
throw new BadRequest("类型错误.");
}
Page<Map<String, Object>> data= taskServiceImpl.getLinetypeNotInspected( pageNumber, pageSize, name, timeType);
return CommonResponseUtil.success(data);
}
}
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.yeejoin.amos.patrol.dao.entity.Plan; import com.yeejoin.amos.patrol.dao.entity.Plan;
import liquibase.pro.packaged.M;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo; import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo;
...@@ -198,4 +199,29 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -198,4 +199,29 @@ public interface PlanTaskMapper extends BaseMapper {
PlanTask getById(@Param("planTaskId") Long planTaskId); PlanTask getById(@Param("planTaskId") Long planTaskId);
void updateStatusById(@Param("planTaskId") Long planTaskId, @Param("status") int status); void updateStatusById(@Param("planTaskId") Long planTaskId, @Param("status") int status);
//巡检统计页面=====================================================================
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 已巡检,未巡检
Map<String,Object> getStatisticsByTypeXJ(@Param("name") String name,@Param("timeType") String timeType);
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 合格,不合格
Map<String,Object> getStatisticsByTypeHG(@Param("name") String name,@Param("timeType") String timeType);
//根据日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 获取线路关键区域
List<Map<String,Object>> getLinetype(@Param("nameType") String nameType);
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 不合格
List<Map<String,Object>> getLinetypeUnqualified(@Param("offset") Long offset,@Param("pageSize") int pageSize,@Param("name") String name,@Param("timeType") String timeType);
long countLinetypeUnqualified(@Param("name") String name,@Param("timeType") String timeType);
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 未巡检
List<Map<String,Object>> getLinetypeNotInspected(@Param("offset") Long offset,@Param("pageSize") int pageSize,@Param("name") String name,@Param("timeType") String timeType);
long countLinetypeNotInspected(@Param("name") String name,@Param("timeType") String timeType);
//巡检统计页面=====================================================================
} }
...@@ -19,6 +19,8 @@ import javax.persistence.criteria.Predicate; ...@@ -19,6 +19,8 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.core.common.request.CommonPageable;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.quartz.JobDataMap; import org.quartz.JobDataMap;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -102,6 +104,8 @@ public class TaskServiceImpl implements ITaskService { ...@@ -102,6 +104,8 @@ public class TaskServiceImpl implements ITaskService {
@Autowired @Autowired
private CheckMapper checkMapper; private CheckMapper checkMapper;
@Autowired
PlanTaskMapper planTaskMapper;
// @Value("${LatentDanger.flow.photoUrls}") // @Value("${LatentDanger.flow.photoUrls}")
// private String photoUrl; // private String photoUrl;
...@@ -599,4 +603,58 @@ public class TaskServiceImpl implements ITaskService { ...@@ -599,4 +603,58 @@ public class TaskServiceImpl implements ITaskService {
List<Map<String, Object>> taskList = taskMapper.synchronizedOfflineTasks(request); List<Map<String, Object>> taskList = taskMapper.synchronizedOfflineTasks(request);
return taskList; return taskList;
} }
@Override
public List<Map<String, Object>> getStatisticsByTypeXJ(String name, String timeType) {
Map<String, Object> map= planTaskMapper.getStatisticsByTypeXJ(name,timeType);
List<Map<String, Object>> data=new ArrayList<>();
Map<String, Object> yx=new HashMap<>();
yx.put("name","已巡检");
yx.put("value",map.get("yxj"));
Map<String, Object> wx=new HashMap<>();
wx.put("name","未巡检");
wx.put("value",map.get("wxj"));
data.add(wx);
data.add(yx);
return data;
}
@Override
public List<Map<String, Object>> getStatisticsByTypeHG(String name, String timeType) {
Map<String, Object> map= planTaskMapper.getStatisticsByTypeHG(name,timeType);
List<Map<String, Object>> data=new ArrayList<>();
Map<String, Object> yx=new HashMap<>();
yx.put("name","合格");
yx.put("value",map.get("hg"));
Map<String, Object> wx=new HashMap<>();
wx.put("name","不合格");
wx.put("value",map.get("bhg"));
data.add(wx);
data.add(yx);
return data;
}
@Override
public List<Map<String, Object>> getLinetype(String nameType) {
return planTaskMapper.getLinetype(nameType);
}
@Override
public Page<Map<String, Object>> getLinetypeUnqualified(int pageNumber,int pageSize,String nameType, String timeType) {
CommonPageable commonPageable=new CommonPageable(pageNumber, pageSize);
Long total= planTaskMapper.countLinetypeUnqualified(nameType,timeType);
List<Map<String,Object>> content=planTaskMapper.getLinetypeUnqualified(commonPageable.getOffset(), pageSize, nameType, timeType);
Page<Map<String, Object>> result = new PageImpl<Map<String, Object>>(content, commonPageable, total);
return result;
}
@Override
public Page<Map<String, Object>> getLinetypeNotInspected(int pageNumber,int pageSize,String nameType, String timeType) {
CommonPageable commonPageable=new CommonPageable(pageNumber, pageSize);
Long total= planTaskMapper.countLinetypeNotInspected(nameType,timeType);
List<Map<String,Object>> content=planTaskMapper.getLinetypeNotInspected(commonPageable.getOffset(), pageSize, nameType, timeType);
Page<Map<String, Object>> result = new PageImpl<Map<String, Object>>(content, commonPageable, total);
return result;
}
} }
...@@ -4,6 +4,7 @@ import java.util.HashMap; ...@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.quartz.JobDataMap; import org.quartz.JobDataMap;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -167,4 +168,26 @@ public interface ITaskService { ...@@ -167,4 +168,26 @@ public interface ITaskService {
* @return * @return
*/ */
public List<Map<String, Object>> synchronizedOfflineTasks(AgencyUserModel user, ReginParams reginParams); public List<Map<String, Object>> synchronizedOfflineTasks(AgencyUserModel user, ReginParams reginParams);
//巡检统计页面=====================================================================
List<Map<String, Object>> getStatisticsByTypeXJ( String name, String timeType);
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 合格,不合格
List<Map<String, Object>> getStatisticsByTypeHG( String name, String timeType);
//根据日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 获取线路关键区域
List<Map<String,Object>> getLinetype( String nameType);
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 不合格
Page <Map<String,Object>> getLinetypeUnqualified(int offset,int pageSize, String nameType,String timeType);
//根据线路关键字过滤,日线路(今日),月线路(当月)。季度线路(本季度),年线路(本年) 未巡检
Page<Map<String,Object>> getLinetypeNotInspected( int offset,int pageSize,String nameType, String timeType);
//巡检统计页面=====================================================================
} }
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
SELECT INSTANCE_ID SELECT INSTANCE_ID
<if test="extraFields != null and extraFields.size > 0"> <if test="extraFields != null and extraFields.size > 0">
<foreach collection="extraFields" item="_field" > <foreach collection="extraFields" item="_field" >
, MAX(CASE FIELD_NAME WHEN #{_field} THEN FIELD_VALUE ELSE NULL END) AS ${_field} , MAX( FIELD_NAME WHEN #{_field} THEN FIELD_VALUE ELSE NULL END) AS ${_field}
</foreach> </foreach>
</if> </if>
FROM knowledge_dynamics_value FROM knowledge_dynamics_value
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
</if> </if>
</where> </where>
</select> </select>
<select id="getAllPublishedDocIds" resultType="long"> <select id="getAllPublishedDocIds" resultType="long">
SELECT SEQUENCE_NBR FROM knowledge_doc_content WHERE DOC_STATUS = "PUBLISHED" SELECT SEQUENCE_NBR FROM knowledge_doc_content WHERE DOC_STATUS = "PUBLISHED"
</select> </select>
......
...@@ -1147,4 +1147,247 @@ ...@@ -1147,4 +1147,247 @@
<update id="updateStatusById"> <update id="updateStatusById">
update p_plan_task set finish_status = #{status} where id = #{planTaskId} update p_plan_task set finish_status = #{status} where id = #{planTaskId}
</update> </update>
<!-- 巡检统计页面 -->
<select id="getStatisticsByTypeXJ" resultType="java.util.Map">
select
ifnull( sum(p_plan_task.`finish_num` ), 0 ) AS `yxj`,
( ifnull( sum( p_plan_task.`point_num` ), 0 ) - ifnull( sum( p_plan_task.`finish_num` ), 0 ) ) AS `wxj`
from p_plan_task left join p_plan
on p_plan_task.plan_id=p_plan.id
where
<choose>
<when test="timeType == 'd'">
to_days(p_plan_task.begin_time) = to_days(curdate())
</when>
<when test="timeType == 'm'">
month(p_plan_task.begin_time) =month(curdate()) and year(p_plan_task.begin_time) = year(curdate())
</when>
<when test="timeType == 'j'">
QUARTER(p_plan_task.begin_time) =QUARTER(curdate())
</when>
<when test="timeType == 'yr'">
year( p_plan_task.begin_time ) = year( curdate( ))
</when>
</choose>
<if test="name != null and name!=''">
SUBSTRING_INDEX( p_plan.`name`,'-',-1)=#{name}
</if>
</select>
<select id="getStatisticsByTypeHG" resultType="java.util.Map">
select
count( ( ( `p_plan_task_detail`.`status` = 1 ) OR ( 0 = NULL ) ) ) AS `hg`,
count( ( ( `p_plan_task_detail`.`status` = 2 ) OR ( 0 = NULL ) ) ) AS `bhg`
from p_plan_task left join p_plan
on p_plan_task.plan_id=p_plan.id
LEFT JOIN p_plan_task_detail
ON p_plan_task_detail.task_no=p_plan_task.id
where
<choose>
<when test="timeType == 'd'">
to_days(p_plan_task.begin_time) = to_days(curdate())
</when>
<when test="timeType == 'm'">
month(p_plan_task.begin_time) =month(curdate()) and year(p_plan_task.begin_time) = year(curdate())
</when>
<when test="timeType == 'j'">
QUARTER(p_plan_task.begin_time) =QUARTER(curdate())
</when>
<when test="timeType == 'yr'">
year( p_plan_task.begin_time ) = year( curdate( ))
</when>
</choose>
<if test="name != null and name!=''">
SUBSTRING_INDEX( p_plan.`name`,'-',-1)=#{name}
</if>
</select>
<select id="getLinetype" resultType="java.util.Map">
select SUBSTRING_INDEX(p_plan.name,'-',-1) as `name` from p_plan
<if test="name != null and name!=''">
SUBSTRING_INDEX( p_plan.`name`,'-',-1)=#{name}
</if>
</select>
<select id="countLinetypeUnqualified" resultType="long">
SELECT
COUNT(1) AS num
FROM
(
SELECT
ppo.point_no pointNum,
ppo.`name`,
ppo.biz_org_name bizOrgName,
pptd.executor_name AS actor,
pptd.create_date
FROM
p_plan_task ppt
RIGHT JOIN p_plan_task_detail pptd ON ppt.ID = pptd.TASK_NO
LEFT JOIN p_plan pp ON ppt.plan_id = pp.id
LEFT JOIN p_point ppo ON ppo.id = pptd.point_id
WHERE
pptd.`status` = 2
<if test="name != null and name !=''">
SUBSTRING_INDEX( p_plan.`name`,'-',-1)=#{name}
</if>
ORDER BY
pptd.create_date DESC
) a
GROUP BY
pointNum
having
<choose>
<when test="timeType == 'd'">
to_days(create_date) = to_days(curdate())
</when>
<when test="timeType == 'm'">
month(create_date) =month(curdate()) and year(create_date) = year(curdate())
</when>
<when test="timeType == 'j'">
QUARTER(create_date) =QUARTER(curdate())
</when>
<when test="timeType == 'yr'">
year( create_date ) = year( curdate( ))
</when>
</choose>
</select>
<select id="getLinetypeUnqualified" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
ppo.point_no pointNum,
ppo.`name`,
ppo.biz_org_name bizOrgName,
pptd.executor_name AS actor,
pptd.create_date
FROM
p_plan_task ppt
RIGHT JOIN p_plan_task_detail pptd ON ppt.ID = pptd.TASK_NO
LEFT JOIN p_plan pp ON ppt.plan_id = pp.id
LEFT JOIN p_point ppo ON ppo.id = pptd.point_id
WHERE
pptd.`status` = 2
<if test="name != null and name !=''">
SUBSTRING_INDEX( p_plan.`name`,'-',-1)=#{name}
</if>
ORDER BY
pptd.create_date DESC
) a
GROUP BY
pointNum
having
<choose>
<when test="timeType == 'd'">
to_days(create_date) = to_days(curdate())
</when>
<when test="timeType == 'm'">
month(create_date) =month(curdate()) and year(create_date) = year(curdate())
</when>
<when test="timeType == 'j'">
QUARTER(create_date) =QUARTER(curdate())
</when>
<when test="timeType == 'yr'">
year( create_date ) = year( curdate( ))
</when>
</choose>
limit #{offset},#{pageSize}
</select>
<select id="countLinetypeNotInspected" resultType="long">
SELECT
COUNT(1) AS num
FROM
p_plan_task ppt
RIGHT JOIN p_plan_task_detail pptd ON ppt.ID = pptd.TASK_NO
LEFT JOIN p_plan pp ON ppt.plan_id = pp.id
LEFT JOIN p_point ppo ON ppo.id = pptd.point_id
LEFT JOIN p_check pc ON pptd.id = pc.plan_task_detail_id
LEFT JOIN p_route pr ON pr.id = ppt.route_id
WHERE
pptd.`is_finish` != 1
<choose>
<when test="timeType == 'd'">
to_days(ppt.begin_time) = to_days(curdate())
</when>
<when test="timeType == 'm'">
month(ppt.begin_time) =month(curdate()) and year(ppt.begin_time) = year(curdate())
</when>
<when test="timeType == 'j'">
QUARTER(ppt.begin_time) =QUARTER(curdate())
</when>
<when test="timeType == 'yr'">
year( ppt.begin_time ) = year( curdate( ))
</when>
</choose>
<if test="name != null and name !=''">
SUBSTRING_INDEX( pp.`name`,'-',-1)=#{name}
</if>
</select>
<select id="getLinetypeNotInspected" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
ppo.point_no pointNum,
ppo.route_name routeName,
ppo.`name`,
ppo.biz_org_name bizOrgName,
pr.boss_name AS actor,
pc.create_date checkDate
FROM
p_plan_task ppt
RIGHT JOIN p_plan_task_detail pptd ON ppt.ID = pptd.TASK_NO
LEFT JOIN p_plan pp ON ppt.plan_id = pp.id
LEFT JOIN p_point ppo ON ppo.id = pptd.point_id
LEFT JOIN p_check pc ON pptd.id = pc.plan_task_detail_id
LEFT JOIN p_route pr ON pr.id = ppt.route_id
WHERE
pptd.`is_finish` != 1
<choose>
<when test="timeType == 'd'">
to_days(ppt.begin_time) = to_days(curdate())
</when>
<when test="timeType == 'm'">
month(ppt.begin_time) =month(curdate()) and year(ppt.begin_time) = year(curdate())
</when>
<when test="timeType == 'j'">
QUARTER(ppt.begin_time) =QUARTER(curdate())
</when>
<when test="timeType == 'yr'">
year( ppt.begin_time ) = year( curdate( ))
</when>
</choose>
<if test="name != null and name !=''">
SUBSTRING_INDEX( pp.`name`,'-',-1)=#{name}
</if>
ORDER BY
pptd.create_date DESC
) a
GROUP BY
pointNum
limit #{offset},#{pageSize}
</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