Commit 5b76d9ce1ac43f2eee3112662dd2f9ca11a0112b
1 parent
799a221f
优化
Showing
6 changed files
with
56 additions
and
82 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/maintainplan/vo/AppMaintainPlanPagePlanTypeReqVO.java
| @@ -36,14 +36,11 @@ public class AppMaintainPlanPagePlanTypeReqVO extends PageParam { | @@ -36,14 +36,11 @@ public class AppMaintainPlanPagePlanTypeReqVO extends PageParam { | ||
| 36 | 36 | ||
| 37 | @Schema(description = "计划批次号列表") | 37 | @Schema(description = "计划批次号列表") |
| 38 | @Hidden | 38 | @Hidden |
| 39 | - private Set<String> batchNos; | 39 | + private Set<Long> roleIds; |
| 40 | 40 | ||
| 41 | @Schema(description = "业务线") | 41 | @Schema(description = "业务线") |
| 42 | @Hidden | 42 | @Hidden |
| 43 | private List<String> busiLineList; | 43 | private List<String> busiLineList; |
| 44 | 44 | ||
| 45 | - @Schema(description = "系统时间") | ||
| 46 | - @Hidden | ||
| 47 | - private LocalDateTime localDateTime; | ||
| 48 | 45 | ||
| 49 | } | 46 | } |
| 50 | \ No newline at end of file | 47 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/maintainplan/vo/AppMaintainPlanPageRoadReqVO.java
| @@ -23,23 +23,18 @@ public class AppMaintainPlanPageRoadReqVO extends PageParam { | @@ -23,23 +23,18 @@ public class AppMaintainPlanPageRoadReqVO extends PageParam { | ||
| 23 | * 完成状态 1:未完成;2:已完成;3:已失效 | 23 | * 完成状态 1:未完成;2:已完成;3:已失效 |
| 24 | * @see com.zteits.urbanops.module.garden.enums.FinishStateEnum | 24 | * @see com.zteits.urbanops.module.garden.enums.FinishStateEnum |
| 25 | */ | 25 | */ |
| 26 | - @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效") | 26 | + @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效;4:已终止") |
| 27 | @NotNull(message = "完成状态不能为空") | 27 | @NotNull(message = "完成状态不能为空") |
| 28 | @Min(value = 1, message = "状态最小为1") | 28 | @Min(value = 1, message = "状态最小为1") |
| 29 | @Max(value = 3, message = "状态不能大于4") | 29 | @Max(value = 3, message = "状态不能大于4") |
| 30 | private Integer finishState; | 30 | private Integer finishState; |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | - @Schema(description = "批次号") | 33 | + @Schema(description = "角色id列表") |
| 34 | @Hidden | 34 | @Hidden |
| 35 | - private Set<String> batchNos; | 35 | + private Set<Long> roleIds; |
| 36 | 36 | ||
| 37 | @Schema(description = "业务线") | 37 | @Schema(description = "业务线") |
| 38 | @Hidden | 38 | @Hidden |
| 39 | private List<String> busiLineList; | 39 | private List<String> busiLineList; |
| 40 | - | ||
| 41 | - @Schema(description = "系统时间") | ||
| 42 | - @Hidden | ||
| 43 | - private LocalDate localDate; | ||
| 44 | - | ||
| 45 | } | 40 | } |
| 46 | \ No newline at end of file | 41 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/maintainplan/vo/AppMaintainPlanPageRoadRespVO.java
| @@ -35,10 +35,10 @@ public class AppMaintainPlanPageRoadRespVO{ | @@ -35,10 +35,10 @@ public class AppMaintainPlanPageRoadRespVO{ | ||
| 35 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "8588") | 35 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "8588") |
| 36 | private Integer levelId; | 36 | private Integer levelId; |
| 37 | 37 | ||
| 38 | - @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效") | 38 | + @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效;4:已终止") |
| 39 | @NotNull(message = "完成状态不能为空") | 39 | @NotNull(message = "完成状态不能为空") |
| 40 | @Min(value = 1, message = "状态最小为1") | 40 | @Min(value = 1, message = "状态最小为1") |
| 41 | - @Max(value = 3, message = "状态不能大于4") | 41 | + @Max(value = 4, message = "状态不能大于5") |
| 42 | private Integer finishState; | 42 | private Integer finishState; |
| 43 | 43 | ||
| 44 | @Schema(description = "计划次数", requiredMode = Schema.RequiredMode.REQUIRED) | 44 | @Schema(description = "计划次数", requiredMode = Schema.RequiredMode.REQUIRED) |
| @@ -50,11 +50,9 @@ public class AppMaintainPlanPageRoadRespVO{ | @@ -50,11 +50,9 @@ public class AppMaintainPlanPageRoadRespVO{ | ||
| 50 | private Integer planFinishNum; | 50 | private Integer planFinishNum; |
| 51 | 51 | ||
| 52 | @Schema(description = "执行开始时间") | 52 | @Schema(description = "执行开始时间") |
| 53 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) | ||
| 54 | private LocalDate beginTime; | 53 | private LocalDate beginTime; |
| 55 | 54 | ||
| 56 | @Schema(description = "执行时间") | 55 | @Schema(description = "执行时间") |
| 57 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) | ||
| 58 | private LocalDate endTime; | 56 | private LocalDate endTime; |
| 59 | 57 | ||
| 60 | } | 58 | } |
| 61 | \ No newline at end of file | 59 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/FinishStateEnum.java
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanServiceImpl.java
| @@ -378,12 +378,12 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -378,12 +378,12 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | /*1.查询登录用户计划编码列表*/ | 380 | /*1.查询登录用户计划编码列表*/ |
| 381 | - Set<String> batchNos = this.getBatchNosByLoginUserId(); | ||
| 382 | - if(CollectionUtils.isEmpty(batchNos)){ | ||
| 383 | - return PageResult.empty(); | 381 | + /*1.查询登录用户角色*/ |
| 382 | + List<Long> roleIds = roleApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId()); | ||
| 383 | + if (CollectionUtils.isEmpty(roleIds)) { | ||
| 384 | + new PageResult<>(null, 0L); | ||
| 384 | } | 385 | } |
| 385 | - pageReqVO.setBatchNos(batchNos); | ||
| 386 | - pageReqVO.setLocalDate(LocalDate.now()); | 386 | + pageReqVO.setRoleIds(new HashSet<>(roleIds)); |
| 387 | /*2.分页*/ | 387 | /*2.分页*/ |
| 388 | IPage<AppMaintainPlanPageRoadRespVO> mpPage = MyBatisUtils.buildPage(pageReqVO); | 388 | IPage<AppMaintainPlanPageRoadRespVO> mpPage = MyBatisUtils.buildPage(pageReqVO); |
| 389 | IPage<AppMaintainPlanPageRoadRespVO> page = maintainPlanMapper.appMaintainPlanRoadPage(mpPage, pageReqVO); | 389 | IPage<AppMaintainPlanPageRoadRespVO> page = maintainPlanMapper.appMaintainPlanRoadPage(mpPage, pageReqVO); |
| @@ -421,12 +421,12 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -421,12 +421,12 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 421 | pageReqVO.setBusiLineList(Arrays.asList(busiLine.split(","))); | 421 | pageReqVO.setBusiLineList(Arrays.asList(busiLine.split(","))); |
| 422 | } | 422 | } |
| 423 | /*1.查询登录用户计划编码列表*/ | 423 | /*1.查询登录用户计划编码列表*/ |
| 424 | - Set<String> batchNos = this.getBatchNosByLoginUserId(); | ||
| 425 | - if(CollectionUtils.isEmpty(batchNos)){ | ||
| 426 | - return PageResult.empty(); | 424 | + List<Long> roleIds = roleApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId()); |
| 425 | + if (CollectionUtils.isEmpty(roleIds)) { | ||
| 426 | + return new PageResult<>(null, 0L); | ||
| 427 | } | 427 | } |
| 428 | - pageReqVO.setBatchNos(batchNos); | ||
| 429 | - pageReqVO.setLocalDateTime(LocalDateTime.now()); | 428 | + |
| 429 | + pageReqVO.setRoleIds(new HashSet<>(roleIds)); | ||
| 430 | /*2.分页*/ | 430 | /*2.分页*/ |
| 431 | IPage<AppMaintainPlanPagePlanTypeRespVO> mpPage = MyBatisUtils.buildPage(pageReqVO); | 431 | IPage<AppMaintainPlanPagePlanTypeRespVO> mpPage = MyBatisUtils.buildPage(pageReqVO); |
| 432 | IPage<AppMaintainPlanPagePlanTypeRespVO> page = maintainPlanMapper.appMaintainPlanPlanTypePage(mpPage, pageReqVO); | 432 | IPage<AppMaintainPlanPagePlanTypeRespVO> page = maintainPlanMapper.appMaintainPlanPlanTypePage(mpPage, pageReqVO); |
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanMapper.xml
| @@ -25,18 +25,21 @@ | @@ -25,18 +25,21 @@ | ||
| 25 | a.begin_time, | 25 | a.begin_time, |
| 26 | a.end_time | 26 | a.end_time |
| 27 | FROM | 27 | FROM |
| 28 | - garden_maintain_plan a | ||
| 29 | - JOIN -- 建议用显式JOIN代替隐式连接,可读性更高 | ||
| 30 | - garden_maintain_plan_detail b ON a.batch_no = b.batch_no | 28 | + garden_maintain_plan a, |
| 29 | + garden_maintain_plan_detail b, | ||
| 30 | + garden_maintain_plan_role c | ||
| 31 | + WHERE a.batch_no = b.batch_no | ||
| 32 | + AND a.batch_no = c.batch_no | ||
| 33 | + AND a.dept_id = c.dept_id | ||
| 31 | AND a.deleted = b.deleted | 34 | AND a.deleted = b.deleted |
| 32 | - WHERE a.deleted = 0 | ||
| 33 | - <if test="req.roadName != null and req.roadName !=''"> | 35 | + AND a.deleted = 0 |
| 36 | + <if test="req.roadName != null and req.roadName !=''"> | ||
| 34 | AND a.road_name LIKE CONCAT('%',#{req.roadName},'%') | 37 | AND a.road_name LIKE CONCAT('%',#{req.roadName},'%') |
| 35 | </if> | 38 | </if> |
| 36 | - <if test="req.batchNos != null and req.batchNos.size() > 0"> | ||
| 37 | - AND a.batch_no IN | ||
| 38 | - <foreach collection="req.batchNos" item="batchNo" open="(" separator="," close=")"> | ||
| 39 | - #{batchNo} | 39 | + <if test="req.roleIds != null and req.roleIds.size() > 0"> |
| 40 | + AND c.role_id IN | ||
| 41 | + <foreach collection="req.roleIds" item="roleId" open="(" separator="," close=")"> | ||
| 42 | + #{roleId} | ||
| 40 | </foreach> | 43 | </foreach> |
| 41 | </if> | 44 | </if> |
| 42 | <if test="req.busiLineList != null and req.busiLineList.size() > 0"> | 45 | <if test="req.busiLineList != null and req.busiLineList.size() > 0"> |
| @@ -46,48 +49,40 @@ | @@ -46,48 +49,40 @@ | ||
| 46 | </foreach> | 49 | </foreach> |
| 47 | </if> | 50 | </if> |
| 48 | <!--状态 1:未完成;2:已完成;3:已失效--> | 51 | <!--状态 1:未完成;2:已完成;3:已失效--> |
| 49 | - <if test="req.finishState == 3"> | ||
| 50 | - and b.finish_state = #{req.finishState} | ||
| 51 | - <![CDATA[and a.end_time < #{req.localDate}]]> | ||
| 52 | - </if> | ||
| 53 | - <if test="req.finishState == 2"> | ||
| 54 | - and b.finish_state = #{req.finishState} | ||
| 55 | - </if> | ||
| 56 | - <if test="req.finishState == 1"> | ||
| 57 | - and b.finish_state = #{req.finishState} | ||
| 58 | - <![CDATA[and b.end_time >= #{req.localDate}]]> | ||
| 59 | - <![CDATA[and b.begin_time <= #{req.localDate}]]> | ||
| 60 | - </if> | 52 | + and a.finish_state = b.finish_state |
| 53 | + and a.finish_state = #{req.finishState} | ||
| 61 | </select> | 54 | </select> |
| 62 | 55 | ||
| 63 | <select id="appMaintainPlanPlanTypePage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPagePlanTypeRespVO"> | 56 | <select id="appMaintainPlanPlanTypePage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanPagePlanTypeRespVO"> |
| 64 | SELECT | 57 | SELECT |
| 65 | - c.batch_no, | ||
| 66 | - c.plan_no, | ||
| 67 | - a.plan_name, | ||
| 68 | - a.plan_type_id, | ||
| 69 | - a.rate, | ||
| 70 | - a.cycle_id, | ||
| 71 | - c.plan_num, | ||
| 72 | - c.plan_finish_num, | ||
| 73 | - c.finish_state, | ||
| 74 | - c.begin_time, | ||
| 75 | - c.end_time | 58 | + c.batch_no, |
| 59 | + c.plan_no, | ||
| 60 | + a.plan_name, | ||
| 61 | + a.plan_type_id, | ||
| 62 | + a.rate, | ||
| 63 | + a.cycle_id, | ||
| 64 | + c.plan_num, | ||
| 65 | + c.plan_finish_num, | ||
| 66 | + c.finish_state, | ||
| 67 | + c.begin_time, | ||
| 68 | + c.end_time | ||
| 76 | FROM | 69 | FROM |
| 77 | - garden_maintain_plan a, | ||
| 78 | - garden_maintain_plan_detail c | ||
| 79 | - WHERE | ||
| 80 | - a.batch_no = c.batch_no | 70 | + garden_maintain_plan a, |
| 71 | + garden_maintain_plan_detail c, | ||
| 72 | + garden_maintain_plan_role d | ||
| 73 | + WHERE a.batch_no = c.batch_no | ||
| 74 | + AND a.batch_no = d.batch_no | ||
| 75 | + AND a.dept_id = d.dept_id | ||
| 81 | AND a.deleted=c.deleted | 76 | AND a.deleted=c.deleted |
| 82 | - AND a.deleted=0 | ||
| 83 | - AND a.plan_type_id = #{req.planTypeId} | 77 | + AND a.deleted=0 |
| 78 | + AND a.plan_type_id = #{req.planTypeId} | ||
| 84 | <if test="req.planName != null and req.planName !=''"> | 79 | <if test="req.planName != null and req.planName !=''"> |
| 85 | AND a.plan_type_id LIKE CONCAT('%',#{req.planName},'%') | 80 | AND a.plan_type_id LIKE CONCAT('%',#{req.planName},'%') |
| 86 | </if> | 81 | </if> |
| 87 | - <if test="req.batchNos != null and req.batchNos.size() > 0"> | ||
| 88 | - AND a.batch_no IN | ||
| 89 | - <foreach collection="req.batchNos" item="batchNo" open="(" separator="," close=")"> | ||
| 90 | - #{batchNo} | 82 | + <if test="req.roleIds != null and req.roleIds.size() > 0"> |
| 83 | + AND d.role_id IN | ||
| 84 | + <foreach collection="req.roleIds" item="roleId" open="(" separator="," close=")"> | ||
| 85 | + #{roleId} | ||
| 91 | </foreach> | 86 | </foreach> |
| 92 | </if> | 87 | </if> |
| 93 | <if test="req.busiLineList != null and req.busiLineList.size() > 0"> | 88 | <if test="req.busiLineList != null and req.busiLineList.size() > 0"> |
| @@ -97,19 +92,8 @@ | @@ -97,19 +92,8 @@ | ||
| 97 | </foreach> | 92 | </foreach> |
| 98 | </if> | 93 | </if> |
| 99 | <!--状态 1:未完成;2:已完成;3:已失效--> | 94 | <!--状态 1:未完成;2:已完成;3:已失效--> |
| 100 | - <if test="req.finishState == 3"> | ||
| 101 | - and c.finish_state = #{req.finishState} | ||
| 102 | - <![CDATA[and c.end_time < #{req.localDateTime}]]> | ||
| 103 | - </if> | ||
| 104 | - <if test="req.finishState == 2"> | ||
| 105 | - and c.finish_state = #{req.finishState} | ||
| 106 | - </if> | ||
| 107 | - <if test="req.finishState == 1"> | ||
| 108 | - and c.finish_state = #{req.finishState} | ||
| 109 | - <![CDATA[and c.end_time >= #{req.localDateTime}]]> | ||
| 110 | - <![CDATA[and c.begin_time <= #{req.localDateTime}]]> | ||
| 111 | - | ||
| 112 | - </if> | 95 | + and c.finish_state =a.finish_state |
| 96 | + and c.finish_state = #{req.finishState} | ||
| 113 | </select> | 97 | </select> |
| 114 | 98 | ||
| 115 | </mapper> | 99 | </mapper> |