Commit 919dbdff authored by suhuiguang's avatar suhuiguang

1.巡检接口格式化 删除无用代码

2.排除日期
parent 7514ca4f
...@@ -69,7 +69,7 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -69,7 +69,7 @@ public interface PlanTaskMapper extends BaseMapper {
* @param params * @param params
* @return * @return
*/ */
List<HashMap<String, Object>> getPlanTasks(HashMap<String, Object> params); List<Map<String, Object>> getPlanTasks(HashMap<String, Object> params);
/** /**
* 通过计划任务Id获得计划任务信息 * 通过计划任务Id获得计划任务信息
* @param planTaskId * @param planTaskId
...@@ -121,6 +121,12 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -121,6 +121,12 @@ public interface PlanTaskMapper extends BaseMapper {
* @return * @return
*/ */
List<CheckChkExListBo> getChkExList(CheckPtListPageParam param); List<CheckChkExListBo> getChkExList(CheckPtListPageParam param);
/**
* 任务分页查询数量
* @param params 参数
* @return long
*/
long getPlanTasksCount(HashMap<String, Object> params); long getPlanTasksCount(HashMap<String, Object> params);
Map<String, Object> getPlanTaskStatisticsForApp(HashMap<String, Object> params); Map<String, Object> getPlanTaskStatisticsForApp(HashMap<String, Object> params);
......
...@@ -79,7 +79,7 @@ public interface IPlanTaskService { ...@@ -79,7 +79,7 @@ public interface IPlanTaskService {
* @param params * @param params
* @return * @return
*/ */
Page<HashMap<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params); Page<Map<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params);
/** /**
* 根据计划任务Id获取计划任务信息 * 根据计划任务Id获取计划任务信息
......
package com.yeejoin.amos.patrol.business.util; package com.yeejoin.amos.patrol.business.util;
import java.util.HashMap;
import java.util.List;
import org.springframework.util.ObjectUtils;
import com.yeejoin.amos.patrol.business.param.PlanTaskPageParam; import com.yeejoin.amos.patrol.business.param.PlanTaskPageParam;
import com.yeejoin.amos.patrol.core.common.request.CommonPageable; import com.yeejoin.amos.patrol.core.common.request.CommonPageable;
import com.yeejoin.amos.patrol.core.common.request.CommonRequest; import com.yeejoin.amos.patrol.core.common.request.CommonRequest;
import com.yeejoin.amos.patrol.core.enums.QueryOperatorEnum; import com.yeejoin.amos.patrol.core.enums.QueryOperatorEnum;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.List;
public class PlanTaskPageParamUtil { public class PlanTaskPageParamUtil {
public static PlanTaskPageParam fillChkInfoParam(List<CommonRequest> queryRequests, CommonPageable commonPageable, public static PlanTaskPageParam fillChkInfoParam(List<CommonRequest> queryRequests, CommonPageable commonPageable,
PlanTaskPageParam param, HashMap<String, Object> paramMap) { PlanTaskPageParam param, HashMap<String, Object> paramMap) {
for(int i=0;i<queryRequests.size();i++){ for (int i = 0; i < queryRequests.size(); i++) {
String name = queryRequests.get(i).getName(); String name = queryRequests.get(i).getName();
if("pointNo".equals(name)){ if ("pointNo".equals(name)) {
param.setPointNo(toString(queryRequests.get(i).getValue())); param.setPointNo(toString(queryRequests.get(i).getValue()));
}else if("pointName".equals(name)){ } else if ("pointName".equals(name)) {
param.setPointName(toString(queryRequests.get(i).getValue())); param.setPointName(toString(queryRequests.get(i).getValue()));
}else if("beginDate".equals(name)){ } else if ("beginDate".equals(name)) {
param.setBeginDate(toString(queryRequests.get(i).getValue())); param.setBeginDate(toString(queryRequests.get(i).getValue()));
}else if("endDate".equals(name)){ } else if ("endDate".equals(name)) {
param.setEndDate(toString(queryRequests.get(i).getValue())); param.setEndDate(toString(queryRequests.get(i).getValue()));
}else if("status".equals(name)){ } else if ("status".equals(name)) {
param.setStatus(toString(queryRequests.get(i).getValue())); param.setStatus(toString(queryRequests.get(i).getValue()));
}else if("planId".equals(name)){ } else if ("planId".equals(name)) {
param.setPlanId(toString(queryRequests.get(i).getValue())); param.setPlanId(toString(queryRequests.get(i).getValue()));
}else if("routeId".equals(name)){ } else if ("routeId".equals(name)) {
param.setRouteId(toString(queryRequests.get(i).getValue())); param.setRouteId(toString(queryRequests.get(i).getValue()));
} }
} }
param.setOrgCode(paramMap.get("orgCode") == null ? null:paramMap.get("orgCode").toString()); param.setOrgCode(paramMap.get("orgCode") == null ? null : paramMap.get("orgCode").toString());
param.setUserId(paramMap.get("userId") == null ? null:paramMap.get("userId").toString()); param.setUserId(paramMap.get("userId") == null ? null : paramMap.get("userId").toString());
if (!ObjectUtils.isEmpty(commonPageable)) { if (!ObjectUtils.isEmpty(commonPageable)) {
param.setPageNumber(commonPageable.getPageNumber()); param.setPageNumber(commonPageable.getPageNumber());
param.setPageSize(commonPageable.getPageSize()); param.setPageSize(commonPageable.getPageSize());
} }
return param; return param;
} }
private static String toString(Object value) { private static String toString(Object value) {
if(null ==value || value ==""){ if (null == value || value == "") {
return null; return null;
}else{ } else {
return value.toString(); return value.toString();
} }
} }
public static HashMap<String, Object> fillPlanTask(List<CommonRequest> queryRequests, public static void fillPlanTask(List<CommonRequest> queryRequests,
HashMap<String, Object> params) { HashMap<String, Object> params) {
if (ObjectUtils.isEmpty(queryRequests)) { if (ObjectUtils.isEmpty(queryRequests)) {
return params; return;
} }
String order = ""; StringBuilder order = new StringBuilder();
for(int i=0;i<queryRequests.size();i++){ for (CommonRequest queryRequest : queryRequests) {
String name = queryRequests.get(i).getName(); String name = queryRequest.getName();
String type = queryRequests.get(i).getType(); String type = queryRequest.getType();
if(type!=null && type!=""){ if (type != null && !"".equals(type)) {
if (!QueryOperatorEnum.ORDER_BY.getName().equals(type)) { if (!QueryOperatorEnum.ORDER_BY.getName().equals(type)) {
params.put(name, queryRequests.get(i).getValue()); params.put(name, queryRequest.getValue());
} else if (QueryOperatorEnum.ORDER_BY.getName().equals(type)) { } else {
order +=name + " " + queryRequests.get(i).getValue(); order.append(name).append(" ").append(queryRequest.getValue());
} }
}else{ } else {
if(name.equals("orderBy") && queryRequests.get(i).getValue()!=null){ if ("orderBy".equals(name) && queryRequest.getValue() != null) {
order += queryRequests.get(i).getValue(); order.append(queryRequest.getValue());
} }
params.put(name, queryRequests.get(i).getValue()); params.put(name, queryRequest.getValue());
} }
}
if (!ObjectUtils.isEmpty(order.toString())) {
} params.put("orderBy", order.toString());
if (!ObjectUtils.isEmpty(order)) { } else {
params.put("orderBy", order); params.put("orderBy", "beginTime ASC");
}else{ }
params.put("orderBy", "beginTime ASC"); }
}
return params;
}
} }
...@@ -26,6 +26,8 @@ mybatis.mapper-locations = classpath:db/mapper/*.xml ...@@ -26,6 +26,8 @@ mybatis.mapper-locations = classpath:db/mapper/*.xml
mybatis-plus.mapper-locations=classpath:db/mapper/*.xml mybatis-plus.mapper-locations=classpath:db/mapper/*.xml
mybatis.type-aliases-package = com.yeejoin.amos.maintenance.business.entity.mybatis mybatis.type-aliases-package = com.yeejoin.amos.maintenance.business.entity.mybatis
mybatis.configuration.mapUnderscoreToCamelCase=true mybatis.configuration.mapUnderscoreToCamelCase=true
#null值也返回
mybatis-plus.configuration.call-setters-on-nulls=true
spring.liquibase.changeLog=classpath:db/changelog/changelog-master.xml spring.liquibase.changeLog=classpath:db/changelog/changelog-master.xml
spring.liquibase.enabled=true spring.liquibase.enabled=true
......
package com.yeejoin.amos; package com.yeejoin.amos;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -19,15 +14,21 @@ import org.springframework.cloud.openfeign.EnableFeignClients; ...@@ -19,15 +14,21 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.config.JsonSerializerManage;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler; import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
/** /**
*
* <pre> * <pre>
* 服务启动类 * 服务启动类
* </pre> * </pre>
...@@ -44,42 +45,40 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler; ...@@ -44,42 +45,40 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
@EnableFeignClients @EnableFeignClients
@EnableAsync @EnableAsync
@EnableEurekaClient @EnableEurekaClient
@ComponentScan({"org.typroject","com.yeejoin.amos"}) @ComponentScan(value = {"org.typroject", "com.yeejoin.amos"}, excludeFilters = {
@MapperScan(basePackages = { "com.yeejoin.amos.patrol.business.dao.mapper","org.typroject.tyboot.core.auth.face.orm.dao","com.yeejoin.amos.boot.biz.common.dao.mapper" }) @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {JsonSerializerManage.class})})
public class PatrolApplication @MapperScan(basePackages = {"com.yeejoin.amos.patrol.business.dao.mapper", "org.typroject.tyboot.core.auth.face.orm.dao", "com.yeejoin.amos.boot.biz.common.dao.mapper"})
{ public class PatrolApplication {
private static final Logger logger = LoggerFactory.getLogger(PatrolApplication.class);
private static final Logger logger = LoggerFactory.getLogger(PatrolApplication.class);
@Bean @Bean
@LoadBalanced @LoadBalanced
RestTemplate initRestTemplate() { RestTemplate initRestTemplate() {
return new RestTemplate(); return new RestTemplate();
} }
/** /**
* 启动amosop-server * 启动amosop-server
* *
* @param args * @param args
* @throws IOException * @throws IOException
* @throws URISyntaxException * @throws URISyntaxException
*/ */
public static void main(String[] args) throws UnknownHostException public static void main(String[] args) throws UnknownHostException {
{ logger.info("start Service..........");
logger.info("start Service.........."); ConfigurableApplicationContext context = SpringApplication.run(PatrolApplication.class, args);
ConfigurableApplicationContext context = SpringApplication.run(PatrolApplication.class, args); GlobalExceptionHandler.setAlwaysOk(true);
GlobalExceptionHandler.setAlwaysOk(true); Environment env = context.getEnvironment();
Environment env = context.getEnvironment(); String ip = InetAddress.getLocalHost().getHostAddress();
String ip = InetAddress.getLocalHost().getHostAddress(); String port = env.getProperty("server.port");
String port = env.getProperty("server.port"); String path = env.getProperty("server.servlet.context-path");
String path = env.getProperty("server.servlet.context-path"); GlobalExceptionHandler.setAlwaysOk(true);
GlobalExceptionHandler.setAlwaysOk(true); logger.info("\n----------------------------------------------------------\n\t" +
logger.info("\n----------------------------------------------------------\n\t" + "Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" + "----------------------------------------------------------");
"----------------------------------------------------------"); }
}
} }
\ No newline at end of file
...@@ -168,7 +168,6 @@ ...@@ -168,7 +168,6 @@
and SYSDATE() <![CDATA[>=]]> pt.begin_time and SYSDATE() <![CDATA[>=]]> pt.begin_time
and SYSDATE() <![CDATA[<]]> pt.end_time and SYSDATE() <![CDATA[<]]> pt.end_time
</select> </select>
<select id="getPlanTasks" resultType="Map"> <select id="getPlanTasks" resultType="Map">
SELECT SELECT
a.planTaskId, a.planTaskId,
...@@ -185,7 +184,6 @@ ...@@ -185,7 +184,6 @@
a.userId executiveName, a.userId executiveName,
a.userName, a.userName,
a.userDept a.userDept
<!-- (SELECT GROUP_CONCAT(`name`) FROM s_user where find_in_set(id,a.userId)>0 ORDER BY `id`) AS executiveName -->
FROM FROM
( (
SELECT SELECT
...@@ -202,7 +200,6 @@ ...@@ -202,7 +200,6 @@
pt.end_time, pt.end_time,
'%Y-%m-%d %H:%i:%s' '%Y-%m-%d %H:%i:%s'
) endTime, ) endTime,
date_format( date_format(
pt.check_date, pt.check_date,
'%Y-%m-%d %H:%i:%s' '%Y-%m-%d %H:%i:%s'
...@@ -219,79 +216,10 @@ ...@@ -219,79 +216,10 @@
p_plan_task pt p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id INNER JOIN p_plan p ON pt.plan_id = p.id
) a ) a
<where> <include refid="plan-task-app-where"/>
<if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0</if> <if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
<if test="routeId != null and userId > 0 "> and a.route_id = #{routeId} </if>
<if test="checkDate != null and checkDate != '' "> and a.beginTime <![CDATA[<=]]> #{checkDate} and a.endTime <![CDATA[>=]]> #{checkDate} </if>
<if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if>
<if test="orgCode != null and orgCode !=''" >
and (a.OrgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.OrgCode= #{orgCode} )
</if>
<choose>
<when test="departmentId != null and departmentId != 0 ">and a.userDept like concat('%', #{departmentId}, '%')</when>
<!-- <when test="departmentId == -1 and ids != null">and a.userId in-->
<!-- <foreach item="item" collection="ids" separator="," open="(" close=")" index="index">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
AND (
(
a.beginTime <![CDATA[>=]]> #{startTime}
AND a.endTime <![CDATA[<=]]> #{endTime}
)
OR (
a.beginTime <![CDATA[<=]]> #{endTime}
AND a.endTime <![CDATA[>=]]> #{endTime}
)
OR (
a.beginTime <![CDATA[<=]]> #{startTime}
AND a.endTime <![CDATA[>]]> #{startTime}
)
OR (
a.beginTime <![CDATA[<=]]> #{startTime}
AND a.endTime <![CDATA[>=]]> #{endTime}
)
)
</if>
<if test="query != null and query != '' ">
<if test="queryType != null and queryType != 'executiveName' and queryType != 'plan' ">
AND EXISTS (
SELECT
1
FROM
p_point pp
LEFT JOIN p_route_point rp ON rp.point_id = pp.id
LEFT JOIN p_route r ON r.id = rp.route_id
where a.route_id = r.id
<if test="queryType == null or queryType == '' or queryType == 'all' ">
AND CONCAT(pp.name, ',',r.name, ',', pp.point_no,a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'route' ">
AND r.name LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'point' ">
AND CONCAT(pp.name, ',', pp.point_no) LIKE concat('%', #{query}, '%')
</if>
)
</if>
<if test="queryType != null and queryType == 'executiveName' ">
AND a.userName LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'plan' ">
AND CONCAT(a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
</if>
</where>
<if test="orderBy != null and orderBy != '' "> order by ${orderBy} </if>
limit #{offset},#{pageSize} limit #{offset},#{pageSize}
</select> </select>
<select id="getPlanTasksCount" resultType="long"> <select id="getPlanTasksCount" resultType="long">
SELECT SELECT
count(1) tasksCount count(1) tasksCount
...@@ -324,78 +252,68 @@ ...@@ -324,78 +252,68 @@
p_plan_task pt p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id INNER JOIN p_plan p ON pt.plan_id = p.id
) a ) a
<include refid="plan-task-app-where"/>
</select>
<sql id="plan-task-app-where">
<where> <where>
<if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0 </if> <if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0</if>
<if test="routeId != null and userId > 0 "> and a.route_id = #{routeId} </if> <if test="routeId != null and routeId > 0 "> and a.route_id = #{routeId} </if>
<if test="checkDate != null and checkDate != '' "> and a.beginTime <![CDATA[<=]]> #{checkDate} and a.endTime <![CDATA[>=]]> #{checkDate} </if> <if test="checkDate != null and checkDate != '' "> and a.beginTime <![CDATA[<=]]> #{checkDate} and a.endTime <![CDATA[>=]]> #{checkDate} </if>
<if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if> <if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if>
<if test="orgCode != null and orgCode !=''" > <if test="orgCode != null and orgCode !=''" >
and (a.OrgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.OrgCode= #{orgCode} ) and (a.OrgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.OrgCode= #{orgCode} )
</if> </if>
<choose> <if test="departmentId != null and departmentId != 0 ">and a.userDept like concat('%', #{departmentId}, '%')</if>
<when test="departmentId != null and departmentId!= 0 ">and a.userDept like concat('%', #{departmentId}, '%') </when> <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
<!-- <when test="departmentId == -1 and ids != null">and a.userId in--> AND (
<!-- <foreach item="item" collection="ids" separator="," open="(" close=")" index="index">--> (
<!-- #{item}--> a.beginTime <![CDATA[>=]]> #{startTime}
<!-- </foreach>--> AND a.endTime <![CDATA[<=]]> #{endTime}
<!-- </when>--> )
</choose> OR (
a.beginTime <![CDATA[<=]]> #{endTime}
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' "> AND a.endTime <![CDATA[>=]]> #{endTime}
AND ( )
( OR (
a.beginTime <![CDATA[>=]]> #{startTime} a.beginTime <![CDATA[<=]]> #{startTime}
AND a.endTime <![CDATA[<=]]> #{endTime} AND a.endTime <![CDATA[>]]> #{startTime}
) )
OR ( OR (
a.beginTime <![CDATA[<=]]> #{endTime} a.beginTime <![CDATA[<=]]> #{startTime}
AND a.endTime <![CDATA[>=]]> #{endTime} AND a.endTime <![CDATA[>=]]> #{endTime}
)
OR (
a.beginTime <![CDATA[<=]]> #{startTime}
AND a.endTime <![CDATA[>]]> #{startTime}
)
OR (
a.beginTime <![CDATA[<=]]> #{startTime}
AND a.endTime <![CDATA[>=]]> #{endTime}
)
) )
</if>
<if test="query != null and query != '' ">
<if test="queryType != null and queryType != 'executiveName' and queryType != 'plan' ">
AND EXISTS (
SELECT
1
FROM
p_point pp
LEFT JOIN p_route_point rp ON rp.point_id = pp.id
LEFT JOIN p_route r ON r.id = rp.route_id
where a.route_id = r.id
<if test="queryType == null or queryType == '' or queryType == 'all' ">
AND CONCAT(pp.name, ',',r.name, ',', pp.point_no,a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'route' ">
AND r.name LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'point' ">
AND CONCAT(pp.name, ',', pp.point_no) LIKE concat('%', #{query}, '%')
</if>
) )
</if> </if>
<if test="query != null and query != '' ">
<if test="queryType != null and queryType == 'executiveName' "> <if test="queryType != null and queryType != 'executiveName' and queryType != 'plan' ">
AND EXISTS (
SELECT
1
FROM
p_point pp
LEFT JOIN p_route_point rp ON rp.point_id = pp.id
LEFT JOIN p_route r ON r.id = rp.route_id
where a.route_id = r.id
<if test="queryType == null or queryType == '' or queryType == 'all' ">
AND CONCAT(pp.name, ',',r.name, ',', pp.point_no,a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'route' ">
AND r.name LIKE concat('%', #{query}, '%')
</if>
<if test="queryType != null and queryType == 'point' ">
AND CONCAT(pp.name, ',', pp.point_no) LIKE concat('%', #{query}, '%')
</if>
)
</if>
<if test="queryType != null and queryType == 'executiveName' ">
AND a.userName LIKE concat('%', #{query}, '%') AND a.userName LIKE concat('%', #{query}, '%')
</if> </if>
<if test="queryType != null and queryType == 'plan' "> <if test="queryType != null and queryType == 'plan' ">
AND CONCAT(a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%') AND CONCAT(a.taskName, ',', a.batchNo) LIKE concat('%', #{query}, '%')
</if>
</if> </if>
</if>
</where> </where>
</select> </sql>
<select id="queryPlanTaskById" resultType="Map"> <select id="queryPlanTaskById" resultType="Map">
......
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