Commit 9c3046935b0433d94f2eb53f266746a7c4b0d820

Authored by 颜惠青
2 parents 9ce50e30 a9ac779c

Merge branch 'dev' of http://gitlab1.renniting.cn/JCSS/urbanops into dev

Showing 19 changed files with 370 additions and 113 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/InspectionPlanController.java
1 package com.zteits.urbanops.module.garden.controller.admin.inspectionplan; 1 package com.zteits.urbanops.module.garden.controller.admin.inspectionplan;
2 2
3 -import com.zteits.urbanops.module.garden.util.StringValidateUtil; 3 +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
  4 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
  5 +import com.zteits.urbanops.framework.common.pojo.PageParam;
  6 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  7 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  8 +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;
  9 +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.InspectionPlanPageReqVO;
  10 +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.InspectionPlanRespVO;
  11 +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.InspectionPlanSaveReqVO;
  12 +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.InspectionPlanUpdateReqVO;
  13 +import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO;
  14 +import com.zteits.urbanops.module.garden.service.inspectionplan.InspectionPlanService;
  15 +import io.swagger.v3.oas.annotations.Operation;
  16 +import io.swagger.v3.oas.annotations.Parameter;
  17 +import io.swagger.v3.oas.annotations.tags.Tag;
  18 +import jakarta.annotation.Resource;
  19 +import jakarta.servlet.http.HttpServletResponse;
  20 +import jakarta.validation.Valid;
4 import jakarta.validation.constraints.NotBlank; 21 import jakarta.validation.constraints.NotBlank;
5 import lombok.extern.slf4j.Slf4j; 22 import lombok.extern.slf4j.Slf4j;
6 -import org.springframework.web.bind.annotation.*;  
7 -import jakarta.annotation.Resource;  
8 -import org.springframework.validation.annotation.Validated;  
9 import org.springframework.security.access.prepost.PreAuthorize; 23 import org.springframework.security.access.prepost.PreAuthorize;
10 -import io.swagger.v3.oas.annotations.tags.Tag;  
11 -import io.swagger.v3.oas.annotations.Parameter;  
12 -import io.swagger.v3.oas.annotations.Operation; 24 +import org.springframework.validation.annotation.Validated;
  25 +import org.springframework.web.bind.annotation.*;
13 26
14 -import jakarta.validation.*;  
15 -import jakarta.servlet.http.*;  
16 -import java.util.*;  
17 import java.io.IOException; 27 import java.io.IOException;
  28 +import java.util.List;
18 29
19 -import com.zteits.urbanops.framework.common.pojo.PageParam;  
20 -import com.zteits.urbanops.framework.common.pojo.PageResult;  
21 -import com.zteits.urbanops.framework.common.pojo.CommonResult;  
22 -import com.zteits.urbanops.framework.common.util.object.BeanUtils;  
23 -  
24 -import static com.alibaba.druid.util.FnvHash.Constants.LOG; 30 +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
25 import static com.zteits.urbanops.framework.common.pojo.CommonResult.error; 31 import static com.zteits.urbanops.framework.common.pojo.CommonResult.error;
26 import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; 32 import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
27 -  
28 -import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;  
29 -  
30 -import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;  
31 -import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*;  
32 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_VALUE_ERROR; 33 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_VALUE_ERROR;
33 -import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_VALUE_INTEGER_ERROR;  
34 -  
35 -import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*;  
36 -import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO;  
37 -import com.zteits.urbanops.module.garden.service.inspectionplan.InspectionPlanService;  
38 34
39 @Tag(name = "管理后台 - 巡检计划汇总") 35 @Tag(name = "管理后台 - 巡检计划汇总")
40 @RestController 36 @RestController
@@ -54,12 +50,12 @@ public class InspectionPlanController { @@ -54,12 +50,12 @@ public class InspectionPlanController {
54 log.warn("次数值范围:1-10或者分数格式:1/3, rateValue={}", createReqVO.getRateValue()); 50 log.warn("次数值范围:1-10或者分数格式:1/3, rateValue={}", createReqVO.getRateValue());
55 return error(PLAN_RATE_VALUE_ERROR); 51 return error(PLAN_RATE_VALUE_ERROR);
56 } 52 }
57 - //临时计划  
58 - if(createReqVO.getPlanAttr().equals(2)){  
59 - if(!StringValidateUtil.isValidNumberStr(createReqVO.getRateValue())){  
60 - return error(PLAN_RATE_VALUE_INTEGER_ERROR);  
61 - }  
62 - } 53 +// //临时计划
  54 +// if(createReqVO.getPlanAttr().equals(2)){
  55 +// if(!StringValidateUtil.isValidNumberStr(createReqVO.getRateValue())){
  56 +// return error(PLAN_RATE_VALUE_INTEGER_ERROR);
  57 +// }
  58 +// }
63 59
64 return inspectionPlanService.createInspectionPlan(createReqVO); 60 return inspectionPlanService.createInspectionPlan(createReqVO);
65 } 61 }
@@ -138,4 +134,4 @@ public class InspectionPlanController { @@ -138,4 +134,4 @@ public class InspectionPlanController {
138 list); 134 list);
139 } 135 }
140 136
141 -}  
142 \ No newline at end of file 137 \ No newline at end of file
  138 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanSaveReqVO.java
@@ -48,8 +48,8 @@ public class InspectionPlanSaveReqVO { @@ -48,8 +48,8 @@ public class InspectionPlanSaveReqVO {
48 @NotEmpty(message = "频次值不能为空") 48 @NotEmpty(message = "频次值不能为空")
49 private String rateValue; 49 private String rateValue;
50 50
51 - @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
52 - @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空") 51 + @Schema(description = "周期ID: 0:次;1:日/次;2:周/次;3:月/次;4:季/次;5:半年/次;6:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  52 + @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次;5:按次;6:季度;7:半年")
53 private Integer cycleId; 53 private Integer cycleId;
54 54
55 @Schema(description = "开始时间") 55 @Schema(description = "开始时间")
@@ -69,4 +69,4 @@ public class InspectionPlanSaveReqVO { @@ -69,4 +69,4 @@ public class InspectionPlanSaveReqVO {
69 public boolean verify(){ 69 public boolean verify(){
70 return StringValidateUtil.validate(rateValue); 70 return StringValidateUtil.validate(rateValue);
71 } 71 }
72 -}  
73 \ No newline at end of file 72 \ No newline at end of file
  73 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/MaintainPlanController.java
1 package com.zteits.urbanops.module.garden.controller.admin.maintainplan; 1 package com.zteits.urbanops.module.garden.controller.admin.maintainplan;
2 2
3 -import com.zteits.urbanops.module.garden.util.StringValidateUtil; 3 +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
  4 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
  5 +import com.zteits.urbanops.framework.common.pojo.PageParam;
  6 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  7 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  8 +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;
  9 +import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanPageReqVO;
  10 +import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanRespVO;
  11 +import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanSaveReqVO;
  12 +import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanUpdateReqVO;
  13 +import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO;
  14 +import com.zteits.urbanops.module.garden.service.maintainplan.MaintainPlanService;
  15 +import io.swagger.v3.oas.annotations.Operation;
  16 +import io.swagger.v3.oas.annotations.Parameter;
  17 +import io.swagger.v3.oas.annotations.tags.Tag;
  18 +import jakarta.annotation.Resource;
  19 +import jakarta.servlet.http.HttpServletResponse;
  20 +import jakarta.validation.Valid;
4 import jakarta.validation.constraints.NotBlank; 21 import jakarta.validation.constraints.NotBlank;
5 import lombok.extern.slf4j.Slf4j; 22 import lombok.extern.slf4j.Slf4j;
6 -import org.springframework.web.bind.annotation.*;  
7 -import jakarta.annotation.Resource;  
8 -import org.springframework.validation.annotation.Validated;  
9 import org.springframework.security.access.prepost.PreAuthorize; 23 import org.springframework.security.access.prepost.PreAuthorize;
10 -import io.swagger.v3.oas.annotations.tags.Tag;  
11 -import io.swagger.v3.oas.annotations.Parameter;  
12 -import io.swagger.v3.oas.annotations.Operation; 24 +import org.springframework.validation.annotation.Validated;
  25 +import org.springframework.web.bind.annotation.*;
13 26
14 -import jakarta.validation.*;  
15 -import jakarta.servlet.http.*;  
16 -import java.util.*;  
17 import java.io.IOException; 27 import java.io.IOException;
  28 +import java.util.List;
18 29
19 -import com.zteits.urbanops.framework.common.pojo.PageParam;  
20 -import com.zteits.urbanops.framework.common.pojo.PageResult;  
21 -import com.zteits.urbanops.framework.common.pojo.CommonResult;  
22 -import com.zteits.urbanops.framework.common.util.object.BeanUtils;  
23 - 30 +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
24 import static com.zteits.urbanops.framework.common.pojo.CommonResult.error; 31 import static com.zteits.urbanops.framework.common.pojo.CommonResult.error;
25 import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; 32 import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
26 -  
27 -import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;  
28 -  
29 -import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;  
30 -import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*;  
31 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_VALUE_ERROR; 33 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_VALUE_ERROR;
32 -import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_VALUE_INTEGER_ERROR;  
33 -  
34 -import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*;  
35 -import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO;  
36 -import com.zteits.urbanops.module.garden.service.maintainplan.MaintainPlanService;  
37 34
38 @Tag(name = "管理后台 - 养护计划汇总") 35 @Tag(name = "管理后台 - 养护计划汇总")
39 @RestController 36 @RestController
@@ -54,11 +51,11 @@ public class MaintainPlanController { @@ -54,11 +51,11 @@ public class MaintainPlanController {
54 return error(PLAN_RATE_VALUE_ERROR); 51 return error(PLAN_RATE_VALUE_ERROR);
55 } 52 }
56 //临时计划 53 //临时计划
57 - if(createReqVO.getPlanAttr().equals(2)){  
58 - if(!StringValidateUtil.isValidNumberStr(createReqVO.getRateValue())){  
59 - return error(PLAN_RATE_VALUE_INTEGER_ERROR);  
60 - }  
61 - } 54 +// if(createReqVO.getPlanAttr().equals(2)){
  55 +// if(!StringValidateUtil.isValidNumberStr(createReqVO.getRateValue())){
  56 +// return error(PLAN_RATE_VALUE_INTEGER_ERROR);
  57 +// }
  58 +// }
62 59
63 return maintainPlanService.createMaintainPlan(createReqVO); 60 return maintainPlanService.createMaintainPlan(createReqVO);
64 } 61 }
@@ -137,4 +134,4 @@ public class MaintainPlanController { @@ -137,4 +134,4 @@ public class MaintainPlanController {
137 list); 134 list);
138 } 135 }
139 136
140 -}  
141 \ No newline at end of file 137 \ No newline at end of file
  138 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanSaveReqVO.java
@@ -48,8 +48,8 @@ public class MaintainPlanSaveReqVO { @@ -48,8 +48,8 @@ public class MaintainPlanSaveReqVO {
48 @NotEmpty(message = "频次值不能为空") 48 @NotEmpty(message = "频次值不能为空")
49 private String rateValue; 49 private String rateValue;
50 50
51 - @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
52 - @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空") 51 + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次;5:按次;6:季度;7:半年", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  52 + @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次;5:按次;6:季度;7:半年")
53 private Integer cycleId; 53 private Integer cycleId;
54 54
55 @Schema(description = "开始时间") 55 @Schema(description = "开始时间")
@@ -69,4 +69,4 @@ public class MaintainPlanSaveReqVO { @@ -69,4 +69,4 @@ public class MaintainPlanSaveReqVO {
69 public boolean verify(){ 69 public boolean verify(){
70 return StringValidateUtil.validate(rateValue); 70 return StringValidateUtil.validate(rateValue);
71 } 71 }
72 -}  
73 \ No newline at end of file 72 \ No newline at end of file
  73 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/FinishStateEnum.java
@@ -11,6 +11,10 @@ public enum FinishStateEnum { @@ -11,6 +11,10 @@ public enum FinishStateEnum {
11 * 已完成 11 * 已完成
12 */ 12 */
13 FINISHED(2), 13 FINISHED(2),
  14 + /**
  15 + * 过期
  16 + */
  17 + EXPIRED(3),
14 ; 18 ;
15 19
16 FinishStateEnum(Integer status) { 20 FinishStateEnum(Integer status) {
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/MaintenanceCycleEnum.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.enums;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.Map;
  5 +
  6 +public enum MaintenanceCycleEnum {
  7 +
  8 + /**
  9 + * 字典标签与字典键值对应关系:
  10 + * 次 → 0
  11 + * 次/日 → 1
  12 + * 次/周 → 2
  13 + * 次/月 → 3
  14 + * 次/季 → 4
  15 + * 次/半年 → 5
  16 + * 次/年 → 6
  17 + */
  18 + TIME(0, "次"),
  19 + DAY(1, "次/日"),
  20 + WEEK(2, "次/周"),
  21 + MONTH(3, "次/月"),
  22 + QUARTER(4, "次/季"),
  23 + SEMIANNUAL(5, "次/半年"),
  24 + YEAR(6, "次/年");
  25 +
  26 + private final Integer key;
  27 + private final String value;
  28 +
  29 + // 用于根据key快速查找枚举
  30 + private static final Map<Integer, MaintenanceCycleEnum> KEY_MAP = new HashMap<>();
  31 +
  32 + static {
  33 + // 初始化key映射
  34 + for (MaintenanceCycleEnum cycleEnum : values()) {
  35 + KEY_MAP.put(cycleEnum.key, cycleEnum);
  36 + }
  37 + }
  38 +
  39 + /**
  40 + * 构造函数
  41 + * @param key 字典键值
  42 + * @param value 字典标签
  43 + */
  44 + MaintenanceCycleEnum(Integer key, String value) {
  45 + this.key = key;
  46 + this.value = value;
  47 + }
  48 +
  49 + /**
  50 + * 根据key获取对应的枚举
  51 + * @param key 字典键值
  52 + * @return 对应的枚举,如果不存在返回null
  53 + */
  54 + public static MaintenanceCycleEnum getByKey(Integer key) {
  55 + return KEY_MAP.get(key);
  56 + }
  57 +
  58 + /**
  59 + * 根据key获取对应的字典标签
  60 + * @param key 字典键值
  61 + * @return 对应的字典标签,如果不存在返回null
  62 + */
  63 + public static String getValueByKey(Integer key) {
  64 + MaintenanceCycleEnum cycleEnum = getByKey(key);
  65 + return cycleEnum != null ? cycleEnum.value : null;
  66 + }
  67 +
  68 + public Integer getKey() {
  69 + return key;
  70 + }
  71 +
  72 + public String getValue() {
  73 + return value;
  74 + }
  75 +}
0 \ No newline at end of file 76 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/job/plan/InspectionPlanExpiredJob.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.job.plan;
  2 +
  3 +import com.zteits.urbanops.framework.quartz.core.handler.JobHandler;
  4 +import com.zteits.urbanops.framework.tenant.core.aop.TenantIgnore;
  5 +import com.zteits.urbanops.module.garden.service.inspectionplan.InspectionPlanDetailService;
  6 +import com.zteits.urbanops.module.garden.service.inspectionplan.InspectionPlanService;
  7 +import com.zteits.urbanops.module.garden.service.maintainplan.MaintainPlanDetailService;
  8 +import jakarta.annotation.Resource;
  9 +import lombok.extern.slf4j.Slf4j;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +/**
  13 + * 巡查计划过去 修改状态
  14 + */
  15 +@Component
  16 +@Slf4j
  17 +public class InspectionPlanExpiredJob implements JobHandler {
  18 +
  19 + @Resource
  20 + private InspectionPlanDetailService inspectionPlanDetailService;
  21 +
  22 + @Resource
  23 + private InspectionPlanService inspectionPlanService ;
  24 +
  25 + /**
  26 + * 清理超过(14)天的日志
  27 + */
  28 + private static final Integer JOB_CLEAN_RETAIN_DAY = 14;
  29 +
  30 + /**
  31 + * 每次删除间隔的条数,如果值太高可能会造成数据库的压力过大
  32 + */
  33 + private static final Integer DELETE_LIMIT = 100;
  34 +
  35 + @Override
  36 + @TenantIgnore
  37 + public String execute(String param) {
  38 + // 更新过期的计划明细状态为过期(3)
  39 + inspectionPlanDetailService.updateExpiredInspectionPlanDetails(); // Fixed method name
  40 + // 更新过期的计划状态为过期(3)
  41 + inspectionPlanService.updateExpiredInspectionPlans(); // Fixed method name
  42 + return "Successfully updated expired maintain plans and plan details";
  43 + }
  44 +
  45 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/job/plan/MaintainPlanExpiredJob.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.job.plan;
  2 +
  3 +import com.zteits.urbanops.framework.quartz.core.handler.JobHandler;
  4 +import com.zteits.urbanops.framework.tenant.core.aop.TenantIgnore;
  5 +import com.zteits.urbanops.module.garden.service.maintainplan.MaintainPlanDetailService;
  6 +import com.zteits.urbanops.module.infra.service.logger.ApiAccessLogService;
  7 +import jakarta.annotation.Resource;
  8 +import lombok.extern.slf4j.Slf4j;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +/**
  12 + * 养护计划过期 修改状态
  13 + */
  14 +@Component
  15 +@Slf4j
  16 +public class MaintainPlanExpiredJob implements JobHandler {
  17 +
  18 + @Resource
  19 + private MaintainPlanDetailService maintainPlanDetailService;
  20 +
  21 + @Override
  22 + @TenantIgnore
  23 + public String execute(String param) {
  24 + // 更新过期的计划明细状态为过期(3)
  25 + maintainPlanDetailService.updateExpiredMaintainPlanDetails();
  26 + // 更新过期的计划状态为过期(3)
  27 + maintainPlanDetailService.updateExpiredMaintainPlans();
  28 + return "Successfully updated expired maintain plans and plan details";
  29 + }
  30 +
  31 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanDetailService.java
@@ -68,4 +68,7 @@ public interface InspectionPlanDetailService { @@ -68,4 +68,7 @@ public interface InspectionPlanDetailService {
68 * @return 巡检计划分页 68 * @return 巡检计划分页
69 */ 69 */
70 List<AppInspectionPlanDetailRespVO> getInspectionPlanDetailForApp(AppInspectionPlanDetailReqVO pageReqVO); 70 List<AppInspectionPlanDetailRespVO> getInspectionPlanDetailForApp(AppInspectionPlanDetailReqVO pageReqVO);
71 -}  
72 \ No newline at end of file 71 \ No newline at end of file
  72 +
  73 + void updateExpiredInspectionPlanDetails();
  74 +
  75 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanDetailServiceImpl.java
1 package com.zteits.urbanops.module.garden.service.inspectionplan; 1 package com.zteits.urbanops.module.garden.service.inspectionplan;
2 2
  3 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
3 import com.zteits.urbanops.framework.common.pojo.PageResult; 4 import com.zteits.urbanops.framework.common.pojo.PageResult;
4 import com.zteits.urbanops.framework.common.util.object.BeanUtils; 5 import com.zteits.urbanops.framework.common.util.object.BeanUtils;
5 import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; 6 import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;
@@ -8,8 +9,11 @@ import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.Insp @@ -8,8 +9,11 @@ import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.Insp
8 import com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanDetailReqVO; 9 import com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanDetailReqVO;
9 import com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanDetailRespVO; 10 import com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanDetailRespVO;
10 import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDetailDO; 11 import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDetailDO;
  12 +import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO;
  13 +import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDetailDO;
11 import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanDetailMapper; 14 import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanDetailMapper;
12 import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanRoleMapper; 15 import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanRoleMapper;
  16 +import com.zteits.urbanops.module.garden.enums.FinishStateEnum;
13 import com.zteits.urbanops.module.system.api.permission.RoleApi; 17 import com.zteits.urbanops.module.system.api.permission.RoleApi;
14 import jakarta.annotation.Resource; 18 import jakarta.annotation.Resource;
15 import org.apache.commons.lang3.StringUtils; 19 import org.apache.commons.lang3.StringUtils;
@@ -102,4 +106,17 @@ public class InspectionPlanDetailServiceImpl implements InspectionPlanDetailServ @@ -102,4 +106,17 @@ public class InspectionPlanDetailServiceImpl implements InspectionPlanDetailServ
102 return inspectionPlanDetailMapper.getInspectionPlanDetailForApp(pageReqVO); 106 return inspectionPlanDetailMapper.getInspectionPlanDetailForApp(pageReqVO);
103 } 107 }
104 108
105 -}  
106 \ No newline at end of file 109 \ No newline at end of file
  110 + @Override
  111 + public void updateExpiredInspectionPlanDetails() {
  112 + // 更新过期的计划明细状态为过期(3)
  113 + LocalDateTime now = LocalDateTime.now();
  114 + LambdaUpdateWrapper<InspectionPlanDetailDO> updateWrapper = new LambdaUpdateWrapper<>();
  115 + updateWrapper.lt(InspectionPlanDetailDO::getEndTime, now)
  116 + .ne(InspectionPlanDetailDO::getFinishState, FinishStateEnum.FINISHED.getStatus()) // 排除已完成的
  117 + .set(InspectionPlanDetailDO::getFinishState, FinishStateEnum.EXPIRED.getStatus()); // 设置为过期状态
  118 + inspectionPlanDetailMapper.update(null, updateWrapper);
  119 + }
  120 +
  121 +
  122 +
  123 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanService.java
@@ -81,4 +81,6 @@ public interface InspectionPlanService { @@ -81,4 +81,6 @@ public interface InspectionPlanService {
81 */ 81 */
82 PageResult<AppInspectionPlanRespVO> getInspectionPlanAppPage(AppInspectionPlanPageReqVO pageReqVO); 82 PageResult<AppInspectionPlanRespVO> getInspectionPlanAppPage(AppInspectionPlanPageReqVO pageReqVO);
83 83
84 -}  
85 \ No newline at end of file 84 \ No newline at end of file
  85 + void updateExpiredInspectionPlans();
  86 +
  87 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
@@ -3,6 +3,7 @@ package com.zteits.urbanops.module.garden.service.inspectionplan; @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.garden.service.inspectionplan;
3 import cn.hutool.core.thread.ThreadUtil; 3 import cn.hutool.core.thread.ThreadUtil;
4 import cn.hutool.core.util.RandomUtil; 4 import cn.hutool.core.util.RandomUtil;
5 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 import com.baomidou.mybatisplus.core.metadata.IPage; 7 import com.baomidou.mybatisplus.core.metadata.IPage;
7 import com.zteits.urbanops.framework.common.pojo.CommonResult; 8 import com.zteits.urbanops.framework.common.pojo.CommonResult;
8 import com.zteits.urbanops.framework.common.pojo.PageResult; 9 import com.zteits.urbanops.framework.common.pojo.PageResult;
@@ -23,11 +24,13 @@ import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlan @@ -23,11 +24,13 @@ import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlan
23 import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanRoleMapper; 24 import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanRoleMapper;
24 import com.zteits.urbanops.module.garden.dal.mysql.road.RoadMapper; 25 import com.zteits.urbanops.module.garden.dal.mysql.road.RoadMapper;
25 import com.zteits.urbanops.module.garden.enums.FinishStateEnum; 26 import com.zteits.urbanops.module.garden.enums.FinishStateEnum;
  27 +import com.zteits.urbanops.module.garden.enums.MaintenanceCycleEnum;
26 import com.zteits.urbanops.module.garden.enums.PlanConstants; 28 import com.zteits.urbanops.module.garden.enums.PlanConstants;
27 import com.zteits.urbanops.module.garden.util.timeinterval.PeriodResult; 29 import com.zteits.urbanops.module.garden.util.timeinterval.PeriodResult;
28 import com.zteits.urbanops.module.garden.util.timeinterval.TimeIntervalFrequencyUtil; 30 import com.zteits.urbanops.module.garden.util.timeinterval.TimeIntervalFrequencyUtil;
29 import com.zteits.urbanops.module.system.api.dept.DeptApi; 31 import com.zteits.urbanops.module.system.api.dept.DeptApi;
30 import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; 32 import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO;
  33 +import com.zteits.urbanops.module.system.api.dict.DictDataApi;
31 import com.zteits.urbanops.module.system.api.permission.RoleApi; 34 import com.zteits.urbanops.module.system.api.permission.RoleApi;
32 import com.zteits.urbanops.module.system.dal.dataobject.permission.RoleDO; 35 import com.zteits.urbanops.module.system.dal.dataobject.permission.RoleDO;
33 import jakarta.annotation.Resource; 36 import jakarta.annotation.Resource;
@@ -47,6 +50,7 @@ import java.util.stream.Collectors; @@ -47,6 +50,7 @@ import java.util.stream.Collectors;
47 50
48 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; 51 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
49 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; 52 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*;
  53 +import static com.zteits.urbanops.module.garden.enums.PlanConstants.CYCLE_ID_TYPE;
50 54
51 /** 55 /**
52 * 巡检计划汇总 Service 实现类 56 * 巡检计划汇总 Service 实现类
@@ -72,13 +76,13 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -72,13 +76,13 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
72 76
73 @Resource 77 @Resource
74 private RoadMapper roadMapper; 78 private RoadMapper roadMapper;
75 -  
76 -  
77 @Resource 79 @Resource
78 private DeptApi deptApi; 80 private DeptApi deptApi;
79 81
80 @Resource 82 @Resource
81 private RoleApi roleApi; 83 private RoleApi roleApi;
  84 + @Resource
  85 + private DictDataApi dictDataApi;
82 86
83 @Transactional(rollbackFor = Exception.class) 87 @Transactional(rollbackFor = Exception.class)
84 @Override 88 @Override
@@ -99,7 +103,8 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -99,7 +103,8 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
99 //计算计划次数 103 //计算计划次数
100 int planNum; 104 int planNum;
101 //临时计划 105 //临时计划
102 - if (createReqVO.getPlanAttr().equals(2)) { 106 + dictDataApi.validateDictDataList(CYCLE_ID_TYPE, Collections.singleton(createReqVO.getCycleId().toString().trim()));
  107 + if (createReqVO.getCycleId().equals(MaintenanceCycleEnum.TIME.getKey())) {
103 calculate = new ArrayList<>(); 108 calculate = new ArrayList<>();
104 PeriodResult periodResult = new PeriodResult(createReqVO.getBeginTime(), createReqVO.getEndTime(), Integer.parseInt(createReqVO.getRateValue())); 109 PeriodResult periodResult = new PeriodResult(createReqVO.getBeginTime(), createReqVO.getEndTime(), Integer.parseInt(createReqVO.getRateValue()));
105 calculate.add(periodResult); 110 calculate.add(periodResult);
@@ -234,6 +239,7 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -234,6 +239,7 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
234 QueryWrapper<InspectionPlanDO> sql = new QueryWrapper<>(); 239 QueryWrapper<InspectionPlanDO> sql = new QueryWrapper<>();
235 sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId()) 240 sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId())
236 .in(InspectionPlanDO::getRoadId, roadIds) 241 .in(InspectionPlanDO::getRoadId, roadIds)
  242 + .eq(InspectionPlanDO::getPlanAttr, 1) //标准计划
237 .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime 243 .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime
238 .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime 244 .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime
239 245
@@ -243,6 +249,7 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -243,6 +249,7 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
243 sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId()) 249 sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId())
244 .in(InspectionPlanDO::getRoadId, roadIds) 250 .in(InspectionPlanDO::getRoadId, roadIds)
245 .eq(InspectionPlanDO::getDeleted, 0) 251 .eq(InspectionPlanDO::getDeleted, 0)
  252 + .eq(InspectionPlanDO::getPlanAttr, 2) //临时计划
246 .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime 253 .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime
247 .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime 254 .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime
248 255
@@ -399,4 +406,15 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { @@ -399,4 +406,15 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
399 return roleList.stream().map(InspectionPlanRoleDO::getBatchNo).collect(Collectors.toSet()); 406 return roleList.stream().map(InspectionPlanRoleDO::getBatchNo).collect(Collectors.toSet());
400 } 407 }
401 408
402 -}  
403 \ No newline at end of file 409 \ No newline at end of file
  410 + @Override
  411 + public void updateExpiredInspectionPlans() {
  412 + // 更新过期的计划状态为过期(3)
  413 + LocalDateTime now = LocalDateTime.now();
  414 + LambdaUpdateWrapper<InspectionPlanDO> updateWrapper = new LambdaUpdateWrapper<>();
  415 + updateWrapper.lt(InspectionPlanDO::getEndTime, now)
  416 + .ne(InspectionPlanDO::getFinishState, FinishStateEnum.FINISHED.getStatus()) // 排除已完成的
  417 + .set(InspectionPlanDO::getFinishState, FinishStateEnum.EXPIRED.getStatus()); // 设置为过期状态
  418 + inspectionPlanMapper.update(null, updateWrapper);
  419 + }
  420 +
  421 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanDetailService.java
@@ -77,4 +77,14 @@ public interface MaintainPlanDetailService { @@ -77,4 +77,14 @@ public interface MaintainPlanDetailService {
77 */ 77 */
78 List<AppMaintainNotFinishPlanDetailRespVO> getMaintainNotFinishPlanCommitDetail(AppMaintainNotFinishPlanDetailReqVO reqVO); 78 List<AppMaintainNotFinishPlanDetailRespVO> getMaintainNotFinishPlanCommitDetail(AppMaintainNotFinishPlanDetailReqVO reqVO);
79 79
  80 + /**
  81 + * 更新过期的计划明细状态为过期(3)
  82 + */
  83 + void updateExpiredMaintainPlanDetails();
  84 +
  85 + /**
  86 + * 更新过期的计划状态为过期(3)
  87 + */
  88 + void updateExpiredMaintainPlans();
  89 +
80 } 90 }
81 \ No newline at end of file 91 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanDetailServiceImpl.java
@@ -12,10 +12,14 @@ import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaint @@ -12,10 +12,14 @@ import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaint
12 import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainNotFinishPlanDetailRespVO; 12 import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainNotFinishPlanDetailRespVO;
13 import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanDetailListByRoadPageReqVO; 13 import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanDetailListByRoadPageReqVO;
14 import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanDetailRespVO; 14 import com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanDetailRespVO;
  15 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
15 import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDetailDO; 16 import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDetailDO;
  17 +import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO;
16 import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanRoleDO; 18 import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanRoleDO;
17 import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanDetailMapper; 19 import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanDetailMapper;
  20 +import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanMapper;
18 import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanRoleMapper; 21 import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanRoleMapper;
  22 +import com.zteits.urbanops.module.garden.enums.FinishStateEnum;
19 import com.zteits.urbanops.module.system.api.permission.RoleApi; 23 import com.zteits.urbanops.module.system.api.permission.RoleApi;
20 import jakarta.annotation.Resource; 24 import jakarta.annotation.Resource;
21 import org.apache.commons.lang3.StringUtils; 25 import org.apache.commons.lang3.StringUtils;
@@ -44,6 +48,9 @@ public class MaintainPlanDetailServiceImpl implements MaintainPlanDetailService @@ -44,6 +48,9 @@ public class MaintainPlanDetailServiceImpl implements MaintainPlanDetailService
44 private MaintainPlanDetailMapper maintainPlanDetailMapper; 48 private MaintainPlanDetailMapper maintainPlanDetailMapper;
45 49
46 @Resource 50 @Resource
  51 + private MaintainPlanMapper maintainPlanMapper;
  52 +
  53 + @Resource
47 private MaintainPlanRoleMapper maintainPlanRoleMapper; 54 private MaintainPlanRoleMapper maintainPlanRoleMapper;
48 55
49 @Resource 56 @Resource
@@ -147,4 +154,26 @@ public class MaintainPlanDetailServiceImpl implements MaintainPlanDetailService @@ -147,4 +154,26 @@ public class MaintainPlanDetailServiceImpl implements MaintainPlanDetailService
147 return roleList.stream().map(MaintainPlanRoleDO::getBatchNo).collect(Collectors.toSet()); 154 return roleList.stream().map(MaintainPlanRoleDO::getBatchNo).collect(Collectors.toSet());
148 } 155 }
149 156
  157 + @Override
  158 + public void updateExpiredMaintainPlanDetails() {
  159 + // 更新过期的计划明细状态为过期(3)
  160 + LocalDateTime now = LocalDateTime.now();
  161 + LambdaUpdateWrapper<MaintainPlanDetailDO> updateWrapper = new LambdaUpdateWrapper<>();
  162 + updateWrapper.lt(MaintainPlanDetailDO::getEndTime, now)
  163 + .ne(MaintainPlanDetailDO::getFinishState, FinishStateEnum.FINISHED.getStatus()) // 排除已完成的
  164 + .set(MaintainPlanDetailDO::getFinishState, FinishStateEnum.EXPIRED.getStatus()); // 设置为过期状态
  165 + maintainPlanDetailMapper.update(null, updateWrapper);
  166 + }
  167 +
  168 + @Override
  169 + public void updateExpiredMaintainPlans() {
  170 + // 更新过期的计划状态为过期(3)
  171 + LocalDateTime now = LocalDateTime.now();
  172 + LambdaUpdateWrapper<MaintainPlanDO> updateWrapper = new LambdaUpdateWrapper<>();
  173 + updateWrapper.lt(MaintainPlanDO::getEndTime, now)
  174 + .ne(MaintainPlanDO::getFinishState, FinishStateEnum.FINISHED.getStatus()) // 排除已完成的
  175 + .set(MaintainPlanDO::getFinishState, FinishStateEnum.EXPIRED.getStatus()); // 设置为过期状态
  176 + maintainPlanMapper.update(null, updateWrapper);
  177 + }
  178 +
150 } 179 }
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanServiceImpl.java
@@ -25,11 +25,13 @@ import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanInte @@ -25,11 +25,13 @@ import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanInte
25 import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanRoleMapper; 25 import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanRoleMapper;
26 import com.zteits.urbanops.module.garden.dal.mysql.road.RoadMapper; 26 import com.zteits.urbanops.module.garden.dal.mysql.road.RoadMapper;
27 import com.zteits.urbanops.module.garden.enums.FinishStateEnum; 27 import com.zteits.urbanops.module.garden.enums.FinishStateEnum;
  28 +import com.zteits.urbanops.module.garden.enums.MaintenanceCycleEnum;
28 import com.zteits.urbanops.module.garden.enums.PlanConstants; 29 import com.zteits.urbanops.module.garden.enums.PlanConstants;
29 import com.zteits.urbanops.module.garden.util.timeinterval.PeriodResult; 30 import com.zteits.urbanops.module.garden.util.timeinterval.PeriodResult;
30 import com.zteits.urbanops.module.garden.util.timeinterval.TimeIntervalFrequencyUtil; 31 import com.zteits.urbanops.module.garden.util.timeinterval.TimeIntervalFrequencyUtil;
31 import com.zteits.urbanops.module.system.api.dept.DeptApi; 32 import com.zteits.urbanops.module.system.api.dept.DeptApi;
32 import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; 33 import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO;
  34 +import com.zteits.urbanops.module.system.api.dict.DictDataApi;
33 import com.zteits.urbanops.module.system.api.permission.RoleApi; 35 import com.zteits.urbanops.module.system.api.permission.RoleApi;
34 import com.zteits.urbanops.module.system.dal.dataobject.permission.RoleDO; 36 import com.zteits.urbanops.module.system.dal.dataobject.permission.RoleDO;
35 import jodd.util.StringUtil; 37 import jodd.util.StringUtil;
@@ -56,6 +58,8 @@ import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanMapp @@ -56,6 +58,8 @@ import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanMapp
56 58
57 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; 59 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
58 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; 60 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*;
  61 +import static com.zteits.urbanops.module.garden.enums.PlanConstants.CYCLE_ID_TYPE;
  62 +
59 63
60 /** 64 /**
61 * 养护计划汇总 Service 实现类 65 * 养护计划汇总 Service 实现类
@@ -88,6 +92,13 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { @@ -88,6 +92,13 @@ public class MaintainPlanServiceImpl implements MaintainPlanService {
88 @Resource 92 @Resource
89 private RoleApi roleApi; 93 private RoleApi roleApi;
90 94
  95 + @Resource
  96 + private DictDataApi dictDataApi;
  97 +
  98 + /**
  99 + * 字典类型:养护周期类型
  100 + */
  101 +
91 @Override 102 @Override
92 public CommonResult<Integer> createMaintainPlan(MaintainPlanSaveReqVO createReqVO) { 103 public CommonResult<Integer> createMaintainPlan(MaintainPlanSaveReqVO createReqVO) {
93 //存在性校验 104 //存在性校验
@@ -105,8 +116,9 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { @@ -105,8 +116,9 @@ public class MaintainPlanServiceImpl implements MaintainPlanService {
105 List<PeriodResult> calculate; 116 List<PeriodResult> calculate;
106 //计算计划次数 117 //计算计划次数
107 int planNum; 118 int planNum;
108 - //临时计划比较特殊  
109 - if (createReqVO.getPlanAttr().equals(2)) { 119 + //按次计划
  120 + dictDataApi.validateDictDataList(CYCLE_ID_TYPE, Collections.singleton(createReqVO.getCycleId().toString().trim()));
  121 + if (createReqVO.getCycleId().equals(MaintenanceCycleEnum.TIME.getKey())) {
110 calculate = new ArrayList<>(); 122 calculate = new ArrayList<>();
111 PeriodResult periodResult = new PeriodResult(createReqVO.getBeginTime(), createReqVO.getEndTime(), Integer.parseInt(createReqVO.getRateValue())); 123 PeriodResult periodResult = new PeriodResult(createReqVO.getBeginTime(), createReqVO.getEndTime(), Integer.parseInt(createReqVO.getRateValue()));
112 calculate.add(periodResult); 124 calculate.add(periodResult);
@@ -245,6 +257,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { @@ -245,6 +257,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService {
245 QueryWrapper<MaintainPlanDO> sql = new QueryWrapper<>(); 257 QueryWrapper<MaintainPlanDO> sql = new QueryWrapper<>();
246 sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId()) 258 sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId())
247 .in(MaintainPlanDO::getRoadId, roadIds) 259 .in(MaintainPlanDO::getRoadId, roadIds)
  260 + .eq(MaintainPlanDO::getPlanAttr, 1) //标准计划
248 .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime 261 .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime
249 .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime 262 .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime
250 263
@@ -254,6 +267,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { @@ -254,6 +267,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService {
254 sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId()) 267 sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId())
255 .in(MaintainPlanDO::getRoadId, roadIds) 268 .in(MaintainPlanDO::getRoadId, roadIds)
256 .eq(MaintainPlanDO::getDeleted, 0) 269 .eq(MaintainPlanDO::getDeleted, 0)
  270 + .eq(MaintainPlanDO::getPlanAttr, 2) //临时计划
257 .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime 271 .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime
258 .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime 272 .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime
259 273
@@ -422,4 +436,4 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { @@ -422,4 +436,4 @@ public class MaintainPlanServiceImpl implements MaintainPlanService {
422 }); 436 });
423 } 437 }
424 438
425 -}  
426 \ No newline at end of file 439 \ No newline at end of file
  440 +}
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/util/timeinterval/TimeIntervalFrequencyUtil.java
@@ -6,6 +6,7 @@ import java.util.ArrayList; @@ -6,6 +6,7 @@ import java.util.ArrayList;
6 import java.util.Collections; 6 import java.util.Collections;
7 import java.util.List; 7 import java.util.List;
8 8
  9 +import com.zteits.urbanops.framework.dict.core.DictFrameworkUtils;
9 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; 10 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
10 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.INSPECTION_CYCLE_ID_ERROR; 11 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.INSPECTION_CYCLE_ID_ERROR;
11 12
@@ -17,29 +18,16 @@ public class TimeIntervalFrequencyUtil { @@ -17,29 +18,16 @@ public class TimeIntervalFrequencyUtil {
17 18
18 private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); 19 private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
19 20
20 - public enum IntervalUnit {  
21 - DAY, WEEK, MONTH, YEAR;  
22 - } 21 +
23 22
24 /** 23 /**
25 - * 转换枚举  
26 - * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次  
27 - * @return 24 + * 根据cycleId获取对应的字典值
  25 + * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次;5:按次;6:季度;7:半年
  26 + * @return 对应的字典值
28 */ 27 */
29 - public static IntervalUnit getIntervalUnit(Integer cycleId) {  
30 - switch (cycleId) {  
31 - case 1:  
32 - return IntervalUnit.DAY;  
33 - case 2:  
34 - return IntervalUnit.WEEK;  
35 - case 3:  
36 - return IntervalUnit.MONTH;  
37 - case 4:  
38 - return IntervalUnit.YEAR;  
39 - default:  
40 - throw exception(INSPECTION_CYCLE_ID_ERROR);  
41 - }  
42 - } 28 + public static String getCycleTypeValue(Integer cycleId) {
  29 + // 使用DictFrameworkUtils从字典表获取对应的周期类型值
  30 + return String.valueOf(cycleId); }
43 31
44 /** 32 /**
45 * 计算时间段划分结果(基于固定天数换算) 33 * 计算时间段划分结果(基于固定天数换算)
@@ -47,7 +35,7 @@ public class TimeIntervalFrequencyUtil { @@ -47,7 +35,7 @@ public class TimeIntervalFrequencyUtil {
47 * @param startStr 开始日期 (yyyy-MM-dd) 35 * @param startStr 开始日期 (yyyy-MM-dd)
48 * @param endStr 结束日期 (yyyy-MM-dd) 36 * @param endStr 结束日期 (yyyy-MM-dd)
49 * @param freq 频次值,格式 "x/y" 37 * @param freq 频次值,格式 "x/y"
50 - * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次 38 + * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次;5:按次;6:季度;7:半年
51 * @return 划分结果列表 39 * @return 划分结果列表
52 */ 40 */
53 public static List<PeriodResult> calculate(String startStr, String endStr, String freq, Integer cycleId) { 41 public static List<PeriodResult> calculate(String startStr, String endStr, String freq, Integer cycleId) {
@@ -65,8 +53,7 @@ public class TimeIntervalFrequencyUtil { @@ -65,8 +53,7 @@ public class TimeIntervalFrequencyUtil {
65 int x = Integer.parseInt(parts[0]); // 每周期次数 53 int x = Integer.parseInt(parts[0]); // 每周期次数
66 int y = Integer.parseInt(parts[1]); // 周期数量 54 int y = Integer.parseInt(parts[1]); // 周期数量
67 55
68 - IntervalUnit unit = getIntervalUnit(cycleId);  
69 - long periodDays = convertToDays(y, unit); // 转为固定天数 56 + long periodDays = convertToDays(y, cycleId); // 转为固定天数
70 57
71 List<PeriodResult> results = new ArrayList<>(); 58 List<PeriodResult> results = new ArrayList<>();
72 LocalDate currentStart = start; 59 LocalDate currentStart = start;
@@ -93,19 +80,32 @@ public class TimeIntervalFrequencyUtil { @@ -93,19 +80,32 @@ public class TimeIntervalFrequencyUtil {
93 80
94 /** 81 /**
95 * 将 y 个单位转换为固定天数 82 * 将 y 个单位转换为固定天数
  83 + * TIME(0, "次"),
  84 + * DAY(1, "次/日"),
  85 + * WEEK(2, "次/周"),
  86 + * MONTH(3, "次/月"),
  87 + * QUARTER(4, "次/季"),
  88 + * SEMIANNUAL(5, "次/半年"),
  89 + * YEAR(6, "次/年");
96 */ 90 */
97 - private static long convertToDays(int y, IntervalUnit unit) {  
98 - switch (unit) {  
99 - case DAY: 91 + private static long convertToDays(int y, Integer cycleId) {
  92 + switch (cycleId) {
  93 + case 1: // DAY
100 return y; 94 return y;
101 - case WEEK: 95 + case 2: // WEEK
102 return (long) y * 7; 96 return (long) y * 7;
103 - case MONTH: 97 + case 3: // MONTH
104 return (long) y * 30; 98 return (long) y * 30;
105 - case YEAR: 99 + case 6: // YEAR
106 return (long) y * 365; 100 return (long) y * 365;
  101 + case 0: // TIME
  102 + return 1; // 按次:将整个时间段视为1个周期
  103 + case 4: // QUARTER
  104 + return (long) y * 90; // 1季度=3个月=90天
  105 + case 5: // SEMIANNUAL
  106 + return (long) y * 180; // 半年=6个月=180天
107 default: 107 default:
108 - throw new UnsupportedOperationException("不支持的单位: " + unit); 108 + throw new IllegalArgumentException("无效的周期ID: " + cycleId);
109 } 109 }
110 } 110 }
111 111
@@ -157,5 +157,18 @@ public class TimeIntervalFrequencyUtil { @@ -157,5 +157,18 @@ public class TimeIntervalFrequencyUtil {
157 System.out.println("\n=== 示例5:每1年4次(即:4/1),按年(测试)=== 2023-09-15 2025-01-31"); 157 System.out.println("\n=== 示例5:每1年4次(即:4/1),按年(测试)=== 2023-09-15 2025-01-31");
158 List<PeriodResult> r5 = calculate("2023-09-15", "2025-01-31", "4/1", 4); 158 List<PeriodResult> r5 = calculate("2023-09-15", "2025-01-31", "4/1", 4);
159 r5.forEach(System.out::println); 159 r5.forEach(System.out::println);
  160 +
  161 + // 新增示例:按次、季度、半年
  162 + System.out.println("\n=== 示例6:按次单位,整个时间段算1个周期 === 2025-01-01 2025-12-31");
  163 + List<PeriodResult> r6 = calculate("2025-01-01", "2025-12-31", "2/1", 5);
  164 + r6.forEach(System.out::println);
  165 +
  166 + System.out.println("\n=== 示例7:每1季度2次(即:2/1),按季度(90天)=== 2025-01-01 2025-12-31");
  167 + List<PeriodResult> r7 = calculate("2025-01-01", "2025-12-31", "2/1", 6);
  168 + r7.forEach(System.out::println);
  169 +
  170 + System.out.println("\n=== 示例8:每1半年3次(即:3/1),按半年(180天)=== 2025-01-01 2025-12-31");
  171 + List<PeriodResult> r8 = calculate("2025-01-01", "2025-12-31", "3/1", 7);
  172 + r8.forEach(System.out::println);
160 } 173 }
161 } 174 }
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanDetailMapper.xml
@@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
50 </if> 50 </if>
51 <!--状态 1:未完成;2:已完成;3:已失效--> 51 <!--状态 1:未完成;2:已完成;3:已失效-->
52 <if test="req.finishState == 3"> 52 <if test="req.finishState == 3">
  53 + and a.finish_state = #{req.finishState}
53 <![CDATA[and c.end_time < #{req.localDateTime}]]> 54 <![CDATA[and c.end_time < #{req.localDateTime}]]>
54 </if> 55 </if>
55 <if test="req.finishState == 2"> 56 <if test="req.finishState == 2">
@@ -86,4 +87,4 @@ @@ -86,4 +87,4 @@
86 and c.finish_state = #{req.finishState} 87 and c.finish_state = #{req.finishState}
87 <![CDATA[and c.end_time >= #{req.localDateTime}]]> 88 <![CDATA[and c.end_time >= #{req.localDateTime}]]>
88 </select> 89 </select>
89 -</mapper>  
90 \ No newline at end of file 90 \ No newline at end of file
  91 +</mapper>
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanMapper.xml
@@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
44 </if> 44 </if>
45 <!--状态 1:未完成;2:已完成;3:已失效--> 45 <!--状态 1:未完成;2:已完成;3:已失效-->
46 <if test="req.finishState == 3"> 46 <if test="req.finishState == 3">
  47 + and a.finish_state = #{req.finishState}
47 <![CDATA[and a.end_time < #{req.localDate}]]> 48 <![CDATA[and a.end_time < #{req.localDate}]]>
48 </if> 49 </if>
49 <if test="req.finishState == 2"> 50 <if test="req.finishState == 2">
@@ -93,6 +94,7 @@ @@ -93,6 +94,7 @@
93 </if> 94 </if>
94 <!--状态 1:未完成;2:已完成;3:已失效--> 95 <!--状态 1:未完成;2:已完成;3:已失效-->
95 <if test="req.finishState == 3"> 96 <if test="req.finishState == 3">
  97 + and c.finish_state = #{req.finishState}
96 <![CDATA[and c.end_time < #{req.localDateTime}]]> 98 <![CDATA[and c.end_time < #{req.localDateTime}]]>
97 </if> 99 </if>
98 <if test="req.finishState == 2"> 100 <if test="req.finishState == 2">
@@ -104,4 +106,4 @@ @@ -104,4 +106,4 @@
104 </if> 106 </if>
105 </select> 107 </select>
106 108
107 -</mapper>  
108 \ No newline at end of file 109 \ No newline at end of file
  110 +</mapper>
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/BpmGardenServiceImpl.java
@@ -465,7 +465,7 @@ public class BpmGardenServiceImpl implements BpmGardenService{ @@ -465,7 +465,7 @@ public class BpmGardenServiceImpl implements BpmGardenService{
465 String content = pageVO.getSearchContent(); 465 String content = pageVO.getSearchContent();
466 if(ObjectUtils.isNotAllEmpty(type)){ 466 if(ObjectUtils.isNotAllEmpty(type)){
467 if("1".equals(type)){ 467 if("1".equals(type)){
468 - if(ObjectUtils.isNotAllEmpty(content)){mainInfoPageReqVo.setLonLatAddress(content);} 468 + if(ObjectUtils.isNotAllEmpty(content)){mainInfoPageReqVo.setRoadName(content);}
469 } else 469 } else
470 if("2".equals(type)){ 470 if("2".equals(type)){
471 if(ObjectUtils.isNotAllEmpty(content)){mainInfoPageReqVo.setOrderName(content);} 471 if(ObjectUtils.isNotAllEmpty(content)){mainInfoPageReqVo.setOrderName(content);}