Commit b7151b2523034cccd4a4a902bb02a29d984b0e74

Authored by 王富生
1 parent 5b76d9ce

优化

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/inspectionplan/vo/AppInspectionPlanPageReqVO.java
@@ -8,7 +8,6 @@ import jakarta.validation.constraints.Min; @@ -8,7 +8,6 @@ import jakarta.validation.constraints.Min;
8 import jakarta.validation.constraints.NotNull; 8 import jakarta.validation.constraints.NotNull;
9 import lombok.Data; 9 import lombok.Data;
10 10
11 -import java.time.LocalDate;  
12 import java.util.List; 11 import java.util.List;
13 import java.util.Set; 12 import java.util.Set;
14 13
@@ -19,22 +18,19 @@ public class AppInspectionPlanPageReqVO extends PageParam { @@ -19,22 +18,19 @@ public class AppInspectionPlanPageReqVO extends PageParam {
19 @Schema(description = "道路名称", example = "赵六") 18 @Schema(description = "道路名称", example = "赵六")
20 private String roadName; 19 private String roadName;
21 20
22 - @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效") 21 + @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效;4:已终止")
23 @NotNull(message = "完成状态不能为空") 22 @NotNull(message = "完成状态不能为空")
24 @Min(value = 1, message = "状态最小为1") 23 @Min(value = 1, message = "状态最小为1")
25 - @Max(value = 3, message = "状态不能大于4") 24 + @Max(value = 4, message = "状态不能大于4")
26 private Integer finishState; 25 private Integer finishState;
27 26
28 27
29 @Schema(description = "批次号列表") 28 @Schema(description = "批次号列表")
30 @Hidden 29 @Hidden
31 - private Set<String> batchNos; 30 + private Set<Long> roleIds;
32 31
33 @Schema(description = "业务线") 32 @Schema(description = "业务线")
34 @Hidden 33 @Hidden
35 private List<String> busiLineList; 34 private List<String> busiLineList;
36 35
37 - @Schema(description = "系统时间")  
38 - @Hidden  
39 - private LocalDate localDate;  
40 } 36 }
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/maintainplan/vo/AppMaintainPlanPageRoadReqVO.java
@@ -26,7 +26,7 @@ public class AppMaintainPlanPageRoadReqVO extends PageParam { @@ -26,7 +26,7 @@ public class AppMaintainPlanPageRoadReqVO extends PageParam {
26 @Schema(description = "完成状态 1:未完成;2:已完成;3:已失效;4:已终止") 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 = 4, message = "状态不能大于4")
30 private Integer finishState; 30 private Integer finishState;
31 31
32 32
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanCommitServiceImpl.java
@@ -273,11 +273,5 @@ public class InspectionPlanCommitServiceImpl implements InspectionPlanCommitServ @@ -273,11 +273,5 @@ public class InspectionPlanCommitServiceImpl implements InspectionPlanCommitServ
273 }); 273 });
274 } 274 }
275 275
276 -// private List<InspectionPlanCommitRespVO> imgProcess(List<InspectionPlanCommitRespVO> list) {  
277 -// list.forEach(e -> {  
278 -// e.setImgList(StrUtils.imgProcess(e.getImg(), ""));  
279 -// });  
280 -// return list;  
281 -// }  
282 276
283 } 277 }
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
@@ -52,7 +52,6 @@ import java.util.stream.Collectors; @@ -52,7 +52,6 @@ import java.util.stream.Collectors;
52 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; 52 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
53 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; 53 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*;
54 import static com.zteits.urbanops.module.garden.enums.PlanConstants.CYCLE_ID_TYPE; 54 import static com.zteits.urbanops.module.garden.enums.PlanConstants.CYCLE_ID_TYPE;
55 -import static javax.management.Query.eq;  
56 55
57 /** 56 /**
58 * 巡检计划汇总 Service 实现类 57 * 巡检计划汇总 Service 实现类
@@ -365,13 +364,12 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -365,13 +364,12 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
365 } 364 }
366 365
367 /*1.查询登录用户角色*/ 366 /*1.查询登录用户角色*/
368 - Set<String> batchNos = this.getBatchNosByLoginUserId();  
369 - if(CollectionUtils.isEmpty(batchNos)){  
370 - return PageResult.empty(); 367 + List<Long> roleIds = roleApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());
  368 + if (CollectionUtils.isEmpty(roleIds)) {
  369 + return new PageResult<>(null, 0L);
371 } 370 }
372 371
373 - pageReqVO.setBatchNos(batchNos);  
374 - pageReqVO.setLocalDate(LocalDate.now()); 372 + pageReqVO.setRoleIds(new HashSet<>(roleIds));
375 /*2.分页*/ 373 /*2.分页*/
376 IPage<AppInspectionPlanRespVO> mpPage = MyBatisUtils.buildPage(pageReqVO); 374 IPage<AppInspectionPlanRespVO> mpPage = MyBatisUtils.buildPage(pageReqVO);
377 IPage<AppInspectionPlanRespVO> page = inspectionPlanMapper.getInspectionPlanAppPage(mpPage, pageReqVO); 375 IPage<AppInspectionPlanRespVO> page = inspectionPlanMapper.getInspectionPlanAppPage(mpPage, pageReqVO);
@@ -400,29 +398,6 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -400,29 +398,6 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
400 }); 398 });
401 } 399 }
402 400
403 - /**  
404 - * 获取登录用户批次号List  
405 - */  
406 - private Set<String> getBatchNosByLoginUserId() {  
407 - Long companyId = SecurityFrameworkUtils.getCompanyId();  
408 - Long deptId = SecurityFrameworkUtils.getDeptId();  
409 - /*1.查询登录用户角色*/  
410 - List<Long> roleIds = roleApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());  
411 - if (CollectionUtils.isEmpty(roleIds)) {  
412 - return Collections.emptySet();  
413 - }  
414 - QueryWrapper<InspectionPlanRoleDO> roleSql = new QueryWrapper<>();  
415 - roleSql.select("batch_no");  
416 - roleSql.lambda().in(InspectionPlanRoleDO::getRoleId, roleIds).  
417 - eq(InspectionPlanRoleDO::getCompanyId, companyId)  
418 - .eq(InspectionPlanRoleDO::getDeptId, deptId);  
419 - List<InspectionPlanRoleDO> roleList = inspectionPlanRoleMapper.selectList(roleSql);  
420 - if (CollectionUtils.isEmpty(roleList)) {  
421 - return Collections.emptySet();  
422 - }  
423 - return roleList.stream().map(InspectionPlanRoleDO::getBatchNo).collect(Collectors.toSet());  
424 - }  
425 -  
426 @Override 401 @Override
427 public void updateExpiredInspectionPlans() { 402 public void updateExpiredInspectionPlans() {
428 // 更新过期的计划状态为过期(3) 403 // 更新过期的计划状态为过期(3)
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanServiceImpl.java
@@ -391,29 +391,6 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { @@ -391,29 +391,6 @@ public class MaintainPlanServiceImpl implements MaintainPlanService {
391 return new PageResult<>(page.getRecords(), page.getTotal()); 391 return new PageResult<>(page.getRecords(), page.getTotal());
392 } 392 }
393 393
394 - /**  
395 - * 获取登录用户批次号List  
396 - */  
397 - private Set<String> getBatchNosByLoginUserId() {  
398 - Long companyId = SecurityFrameworkUtils.getCompanyId();  
399 - Long deptId = SecurityFrameworkUtils.getDeptId();  
400 - /*1.查询登录用户角色*/  
401 - List<Long> roleIds = roleApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());  
402 - if (CollectionUtils.isEmpty(roleIds)) {  
403 - return Collections.emptySet();  
404 - }  
405 - QueryWrapper<MaintainPlanRoleDO> roleSql = new QueryWrapper<>();  
406 - roleSql.select("batch_no");  
407 - roleSql.lambda().in(MaintainPlanRoleDO::getRoleId, roleIds).  
408 - eq(MaintainPlanRoleDO::getCompanyId, companyId)  
409 - .eq(MaintainPlanRoleDO::getDeptId, deptId);  
410 - List<MaintainPlanRoleDO> roleList = maintainPlanRoleMapper.selectList(roleSql);  
411 - if (CollectionUtils.isEmpty(roleList)) {  
412 - return Collections.emptySet();  
413 - }  
414 - return roleList.stream().map(MaintainPlanRoleDO::getBatchNo).collect(Collectors.toSet());  
415 - }  
416 -  
417 @Override 394 @Override
418 public PageResult<AppMaintainPlanPagePlanTypeRespVO> appMaintainPlanPlanTypePage(AppMaintainPlanPagePlanTypeReqVO pageReqVO) { 395 public PageResult<AppMaintainPlanPagePlanTypeRespVO> appMaintainPlanPlanTypePage(AppMaintainPlanPagePlanTypeReqVO pageReqVO) {
419 String busiLine = SecurityFrameworkUtils.getBusiLine(); 396 String busiLine = SecurityFrameworkUtils.getBusiLine();
urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanMapper.xml
@@ -15,27 +15,30 @@ @@ -15,27 +15,30 @@
15 15
16 <select id="getInspectionPlanAppPage" resultType="com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanRespVO"> 16 <select id="getInspectionPlanAppPage" resultType="com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanRespVO">
17 SELECT 17 SELECT
18 - a.batch_no,  
19 - a.road_id,  
20 - a.road_name,  
21 - a.busi_line,  
22 - a.plan_type_id,  
23 - a.level_id,  
24 - a.finish_state,  
25 - a.begin_time,  
26 - a.end_time  
27 - FROM garden_inspection_plan a JOIN -- 建议用显式JOIN代替隐式连接,可读性更高  
28 - garden_inspection_plan_detail b ON  
29 - a.batch_no = b.batch_no  
30 - AND a.deleted = b.deleted  
31 - WHERE a.deleted = 0  
32 - <if test="req.roadName != null and req.roadName !=''"> 18 + a.batch_no,
  19 + a.road_id,
  20 + a.road_name,
  21 + a.busi_line,
  22 + a.plan_type_id,
  23 + a.level_id,
  24 + a.finish_state,
  25 + a.begin_time,
  26 + a.end_time
  27 + FROM garden_inspection_plan a,
  28 + garden_inspection_plan_detail b,
  29 + garden_maintain_plan_role c
  30 + WHERE a.batch_no = b.batch_no
  31 + AND a.batch_no = c.batch_no
  32 + AND a.dept_id = c.dept_id
  33 + AND a.deleted = b.deleted
  34 + AND a.deleted = 0
  35 + <if test="req.roadName != null and req.roadName !=''">
33 AND a.road_name LIKE CONCAT('%',#{req.roadName},'%') 36 AND a.road_name LIKE CONCAT('%',#{req.roadName},'%')
34 - </if>  
35 - <if test="req.batchNos != null and req.batchNos.size() > 0">  
36 - AND a.batch_no IN  
37 - <foreach collection="req.batchNos" item="batchNo" open="(" separator="," close=")">  
38 - #{batchNo} 37 + </if>
  38 + <if test="req.roleIds != null and req.roleIds.size() > 0">
  39 + AND c.role_id IN
  40 + <foreach collection="req.roleIds" item="roleId" open="(" separator="," close=")">
  41 + #{roleId}
39 </foreach> 42 </foreach>
40 </if> 43 </if>
41 <if test="req.busiLineList != null and req.busiLineList.size() > 0"> 44 <if test="req.busiLineList != null and req.busiLineList.size() > 0">
@@ -44,18 +47,9 @@ @@ -44,18 +47,9 @@
44 #{busiLine} 47 #{busiLine}
45 </foreach> 48 </foreach>
46 </if> 49 </if>
47 - <!--状态 1:未完成;2:已完成;3:已失效-->  
48 - <if test="req.finishState == 3">  
49 - and b.finish_state = #{req.finishState}  
50 - <![CDATA[and a.end_time < #{req.localDate}]]>  
51 - </if>  
52 - <if test="req.finishState == 2">  
53 - and b.finish_state = #{req.finishState}  
54 - </if>  
55 - <if test="req.finishState == 1">  
56 - and b.finish_state = #{req.finishState}  
57 - <![CDATA[and b.end_time >= #{req.localDate}]]>  
58 - <![CDATA[and b.begin_time <= #{req.localDate}]]>  
59 - </if> 50 + <!--状态 1:未完成;2:已完成;3:已失效 4:终止-->
  51 + and b.finish_state = a.finish_state
  52 + and b.finish_state = #{req.finishState}
  53 +
60 </select> 54 </select>
61 </mapper> 55 </mapper>