Commit 02c35853 authored by suhuiguang's avatar suhuiguang

1.修改sql

parent ac201701
......@@ -481,8 +481,8 @@ public class PlanTaskController extends AbstractBaseController {
@ApiParam(value = "维保状态") @RequestParam(value = "finishStatus", required = false) Integer finishStatus,
@ApiParam(value = "排序条件") @RequestParam(value = "orderBy") String orderBy,
@ApiParam(value = "业主单位") @RequestParam(value = "companyId", required = false) String companyId,
@ApiParam(value = "当前页") @RequestParam(value = "pageNumber") int current,
@ApiParam(value = "页大小") @RequestParam(value = "pageSize") int size) throws Exception {
@ApiParam(value = "当前页") @RequestParam(value = "pageNumber") int pageNumber,
@ApiParam(value = "页大小") @RequestParam(value = "pageSize") int pageSize) throws Exception {
HashMap<String, Object> params = new HashMap<String, Object>();
ReginParams reginParams = getSelectedOrgInfo();
String loginOrgCode = getLoginOrgCode(reginParams);
......@@ -495,7 +495,7 @@ public class PlanTaskController extends AbstractBaseController {
params.put("endTime", endTime);
params.put("finishStatus", finishStatus);
params.put("orderBy", OrderByEnum.getEumByCode(orderBy).getOderBy());
CommonPageable pageable = new CommonPageable(current, size);
CommonPageable pageable = new CommonPageable(pageNumber, pageSize);
try {
return CommonResponseUtil.success(planTaskService.getPlanTasks(params, pageable));
} catch (Exception e) {
......
......@@ -172,27 +172,13 @@
<select id="getPlanTasks" resultType="Map">
SELECT
a.planTaskId,
a.OrgCode,
a.taskName,
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
(SELECT
pt.id planTaskId,
pt.org_code OrgCode,
p. NAME taskName,
pt. STATUS,
pt.org_code orgCode,
p.name taskName,
pt.status,
pt.user_id userId,
date_format(
pt.begin_time,
......@@ -202,29 +188,31 @@
pt.end_time,
'%Y-%m-%d %H:%i:%s'
) endTime,
date_format(
pt.check_date,
'%Y-%m-%d %H:%i:%s'
)checkDate,
) checkDate,
pt.point_num as taskPlanNum,
pt.finish_num finishNum,
(pt.point_num - pt.finish_num) as waitNum,
pt.finish_status finishStatus,
pt.id batchNo,
pt.route_id,
pt.point_num taskPlanNum,
pt.user_name userName,
pt.user_dept userDept
r.owner_id,
R.owner_name as ownerName
FROM
p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id
INNER JOIN p_route r on r.id = pt.route_id
) a
<include refid="mobile-plan-task-where" />
limit #{offset},#{pageSize}
</select>
<sql id="mobile-plan-task-where">
<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 (
(
......@@ -245,11 +233,18 @@
)
)
</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>
<if test="orderBy != null and orderBy != '' "> order by ${orderBy} </if>
limit #{offset},#{pageSize}
</select>
<if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
</sql>
<select id="getPlanTasksCount" resultType="long">
SELECT
......@@ -257,38 +252,19 @@
FROM
(
SELECT
pt.id
pt.id,
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
INNER JOIN p_plan p ON pt.plan_id = p.id
INNER JOIN p_route r on r.id = pt.route_id
) a
<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>
<include refid="mobile-plan-task-where" />
</select>
<select id="queryPlanTaskById" resultType="Map">
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