Commit 02c35853 authored by suhuiguang's avatar suhuiguang

1.修改sql

parent ac201701
...@@ -481,8 +481,8 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -481,8 +481,8 @@ public class PlanTaskController extends AbstractBaseController {
@ApiParam(value = "维保状态") @RequestParam(value = "finishStatus", required = false) Integer finishStatus, @ApiParam(value = "维保状态") @RequestParam(value = "finishStatus", required = false) Integer finishStatus,
@ApiParam(value = "排序条件") @RequestParam(value = "orderBy") String orderBy, @ApiParam(value = "排序条件") @RequestParam(value = "orderBy") String orderBy,
@ApiParam(value = "业主单位") @RequestParam(value = "companyId", required = false) String companyId, @ApiParam(value = "业主单位") @RequestParam(value = "companyId", required = false) String companyId,
@ApiParam(value = "当前页") @RequestParam(value = "pageNumber") int current, @ApiParam(value = "当前页") @RequestParam(value = "pageNumber") int pageNumber,
@ApiParam(value = "页大小") @RequestParam(value = "pageSize") int size) throws Exception { @ApiParam(value = "页大小") @RequestParam(value = "pageSize") int pageSize) throws Exception {
HashMap<String, Object> params = new HashMap<String, Object>(); HashMap<String, Object> params = new HashMap<String, Object>();
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String loginOrgCode = getLoginOrgCode(reginParams); String loginOrgCode = getLoginOrgCode(reginParams);
...@@ -495,7 +495,7 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -495,7 +495,7 @@ public class PlanTaskController extends AbstractBaseController {
params.put("endTime", endTime); params.put("endTime", endTime);
params.put("finishStatus", finishStatus); params.put("finishStatus", finishStatus);
params.put("orderBy", OrderByEnum.getEumByCode(orderBy).getOderBy()); params.put("orderBy", OrderByEnum.getEumByCode(orderBy).getOderBy());
CommonPageable pageable = new CommonPageable(current, size); CommonPageable pageable = new CommonPageable(pageNumber, pageSize);
try { try {
return CommonResponseUtil.success(planTaskService.getPlanTasks(params, pageable)); return CommonResponseUtil.success(planTaskService.getPlanTasks(params, pageable));
} catch (Exception e) { } catch (Exception e) {
......
...@@ -171,28 +171,14 @@ ...@@ -171,28 +171,14 @@
</select> </select>
<select id="getPlanTasks" resultType="Map"> <select id="getPlanTasks" resultType="Map">
SELECT SELECT
a.planTaskId, *
a.OrgCode, FROM
a.taskName, (SELECT
a.userId,
a.beginTime,
a.endTime,
a.checkDate,
a.finishNum,
a.taskPlanNum,
a.finishStatus,
a.batchNo,
a.userId executiveName,
a.userName,
a.userDept
FROM
(
SELECT
pt.id planTaskId, pt.id planTaskId,
pt.org_code OrgCode, pt.org_code orgCode,
p. NAME taskName, p.name taskName,
pt. STATUS, pt.status,
pt.user_id userId, pt.user_id userId,
date_format( date_format(
pt.begin_time, pt.begin_time,
...@@ -202,93 +188,83 @@ ...@@ -202,93 +188,83 @@
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'
)checkDate, ) checkDate,
pt.point_num as taskPlanNum,
pt.finish_num finishNum, pt.finish_num finishNum,
(pt.point_num - pt.finish_num) as waitNum,
pt.finish_status finishStatus, pt.finish_status finishStatus,
pt.id batchNo, pt.id batchNo,
pt.route_id, pt.route_id,
pt.point_num taskPlanNum,
pt.user_name userName, pt.user_name userName,
pt.user_dept userDept r.owner_id,
R.owner_name as ownerName
FROM FROM
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
INNER JOIN p_route r on r.id = pt.route_id
) a ) a
<include refid="mobile-plan-task-where" />
limit #{offset},#{pageSize}
</select>
<sql id="mobile-plan-task-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="finishStatus != null"> and a.finishStatus = #{finishStatus}</if> <if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if>
<if test="orgCode != null and orgCode !=''" > <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
and (a.OrgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.OrgCode= #{orgCode} ) AND (
</if> (
a.beginTime <![CDATA[>=]]> #{startTime}
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' "> AND a.endTime <![CDATA[<=]]> #{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> 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>
<choose>
<when test="identityType==1">
And (a.orgCode LIKE CONCAT( #{orgCode}, '-%' ) or a.orgCode= #{orgCode} )
<if test="companyId != null"> and a.owner_id = #{companyId}</if>
</when>
<when test="identityType==2">
And a.owner_id = #{companyId}
</when>
</choose>
</where> </where>
<if test="orderBy != null and orderBy != '' "> order by ${orderBy} </if> <if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
limit #{offset},#{pageSize} </sql>
</select>
<select id="getPlanTasksCount" resultType="long"> <select id="getPlanTasksCount" resultType="long">
SELECT SELECT
count(1) tasksCount count(1) tasksCount
FROM FROM
( (
SELECT SELECT
pt.id pt.id,
FROM pt.user_id as userId,
pt.finish_status as finishStatus,
pt.org_code as orgCode,
pt.begin_time as beginTime,
pt.end_time as endTime,
r.owner_id
FROM
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
INNER JOIN p_route r on r.id = pt.route_id
) a ) a
<where> <include refid="mobile-plan-task-where" />
<if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0 </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>
<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>
</where>
</select> </select>
<select id="queryPlanTaskById" resultType="Map"> <select id="queryPlanTaskById" resultType="Map">
SELECT SELECT
......
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