Commit 43845f6a88aa7f983e14c9bfcc1aa11050bca16d

Authored by 王富生
1 parent ce393c88

养护频次增删改查提交

Showing 29 changed files with 755 additions and 88 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanSaveReqVO.java
... ... @@ -33,6 +33,7 @@ public class InspectionPlanSaveReqVO {
33 33 private Long companyId;
34 34  
35 35 @Schema(description = "道路信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "[{\"deptId\":11,\"roadId\":1,\"roadName\":\"测试\"}]")
  36 + @NotNull
36 37 @Size(min = 1)
37 38 @Valid
38 39 private List<InspectionPlanRoadReqVO> roadListReqVO;
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/PlanRateController.java
... ... @@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
8 8 import io.swagger.v3.oas.annotations.Parameter;
9 9 import io.swagger.v3.oas.annotations.Operation;
10 10  
11   -import jakarta.validation.constraints.*;
12 11 import jakarta.validation.*;
13 12 import jakarta.servlet.http.*;
14 13 import java.util.*;
... ... @@ -18,12 +17,15 @@ import com.zteits.urbanops.framework.common.pojo.PageParam;
18 17 import com.zteits.urbanops.framework.common.pojo.PageResult;
19 18 import com.zteits.urbanops.framework.common.pojo.CommonResult;
20 19 import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  20 +
  21 +import static com.zteits.urbanops.framework.common.pojo.CommonResult.error;
21 22 import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
22 23  
23 24 import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;
24 25  
25 26 import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
26 27 import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*;
  28 +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PLAN_RATE_LEVEL_ID_DUPLICATE;
27 29  
28 30 import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
29 31 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
... ... @@ -48,17 +50,20 @@ public class PlanRateController {
48 50 @PutMapping("/update")
49 51 @Operation(summary = "更新计划频次")
50 52 @PreAuthorize("@ss.hasPermission('garden:plan-rate:update')")
51   - public CommonResult<Boolean> updatePlanRate(@Valid @RequestBody PlanRateSaveReqVO updateReqVO) {
  53 + public CommonResult<Boolean> updatePlanRate(@Valid @RequestBody PlanRateUpdateReqVO updateReqVO) {
  54 + if(updateReqVO.verify()){
  55 + return error(PLAN_RATE_LEVEL_ID_DUPLICATE);
  56 + }
52 57 planRateService.updatePlanRate(updateReqVO);
53 58 return success(true);
54 59 }
55 60  
56   - @DeleteMapping("/delete")
  61 + @DeleteMapping("/delete-rate-no")
57 62 @Operation(summary = "删除计划频次")
58   - @Parameter(name = "id", description = "编号", required = true)
  63 + @Parameter(name = "rateNo", description = "频次编号", required = true)
59 64 @PreAuthorize("@ss.hasPermission('garden:plan-rate:delete')")
60   - public CommonResult<Boolean> deletePlanRate(@RequestParam("id") Long id) {
61   - planRateService.deletePlanRate(id);
  65 + public CommonResult<Boolean> deletePlanRate(@RequestParam("rateNo") String rateNo) {
  66 + planRateService.deletePlanRateByRateNo(rateNo);
62 67 return success(true);
63 68 }
64 69  
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/PlanRateDetailController.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.planrate;
  2 +
  3 +import org.springframework.web.bind.annotation.*;
  4 +import jakarta.annotation.Resource;
  5 +import org.springframework.validation.annotation.Validated;
  6 +import org.springframework.security.access.prepost.PreAuthorize;
  7 +import io.swagger.v3.oas.annotations.tags.Tag;
  8 +import io.swagger.v3.oas.annotations.Parameter;
  9 +import io.swagger.v3.oas.annotations.Operation;
  10 +
  11 +import jakarta.validation.constraints.*;
  12 +import jakarta.validation.*;
  13 +import jakarta.servlet.http.*;
  14 +import java.util.*;
  15 +import java.io.IOException;
  16 +
  17 +import com.zteits.urbanops.framework.common.pojo.PageParam;
  18 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  19 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
  20 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  21 +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
  22 +
  23 +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;
  24 +
  25 +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
  26 +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*;
  27 +
  28 +import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
  29 +import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
  30 +import com.zteits.urbanops.module.garden.service.planrate.PlanRateDetailService;
  31 +
  32 +@Tag(name = "管理后台 - 计划频次明细")
  33 +@RestController
  34 +@RequestMapping("/garden/plan-rate-detail")
  35 +@Validated
  36 +public class PlanRateDetailController {
  37 +
  38 + @Resource
  39 + private PlanRateDetailService planRateDetailService;
  40 +
  41 + @PostMapping("/create")
  42 + @Operation(summary = "创建计划频次明细")
  43 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:create')")
  44 + public CommonResult<Long> createPlanRateDetail(@Valid @RequestBody PlanRateDetailSaveReqVO createReqVO) {
  45 + return success(planRateDetailService.createPlanRateDetail(createReqVO));
  46 + }
  47 +
  48 + @PutMapping("/update")
  49 + @Operation(summary = "更新计划频次明细")
  50 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:update')")
  51 + public CommonResult<Boolean> updatePlanRateDetail(@Valid @RequestBody PlanRateDetailSaveReqVO updateReqVO) {
  52 + planRateDetailService.updatePlanRateDetail(updateReqVO);
  53 + return success(true);
  54 + }
  55 +
  56 + @DeleteMapping("/delete")
  57 + @Operation(summary = "删除计划频次明细")
  58 + @Parameter(name = "id", description = "编号", required = true)
  59 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:delete')")
  60 + public CommonResult<Boolean> deletePlanRateDetail(@RequestParam("id") Long id) {
  61 + planRateDetailService.deletePlanRateDetail(id);
  62 + return success(true);
  63 + }
  64 +
  65 + @DeleteMapping("/delete-list")
  66 + @Parameter(name = "ids", description = "编号", required = true)
  67 + @Operation(summary = "批量删除计划频次明细")
  68 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:delete')")
  69 + public CommonResult<Boolean> deletePlanRateDetailList(@RequestParam("ids") List<Long> ids) {
  70 + planRateDetailService.deletePlanRateDetailListByIds(ids);
  71 + return success(true);
  72 + }
  73 +
  74 + @GetMapping("/get-rateNo")
  75 + @Operation(summary = "获得计划频次明细")
  76 + @Parameter(name = "rateNo", description = "编号", required = true, example = "1024")
  77 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:query')")
  78 + public CommonResult<List<PlanRateDetailRespVO>> getPlanRateDetail(@RequestParam("rateNo") @NotBlank String rateNo) {
  79 + List<PlanRateDetailDO> detailList = planRateDetailService.getPlanRateDetailByRateNo(rateNo);
  80 + return success(BeanUtils.toBean(detailList, PlanRateDetailRespVO.class));
  81 + }
  82 +
  83 + @GetMapping("/page")
  84 + @Operation(summary = "获得计划频次明细分页")
  85 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:query')")
  86 + public CommonResult<PageResult<PlanRateDetailRespVO>> getPlanRateDetailPage(@Valid PlanRateDetailPageReqVO pageReqVO) {
  87 + PageResult<PlanRateDetailDO> pageResult = planRateDetailService.getPlanRateDetailPage(pageReqVO);
  88 + return success(BeanUtils.toBean(pageResult, PlanRateDetailRespVO.class));
  89 + }
  90 +
  91 + @GetMapping("/export-excel")
  92 + @Operation(summary = "导出计划频次明细 Excel")
  93 + @PreAuthorize("@ss.hasPermission('garden:plan-rate-detail:export')")
  94 + @ApiAccessLog(operateType = EXPORT)
  95 + public void exportPlanRateDetailExcel(@Valid PlanRateDetailPageReqVO pageReqVO,
  96 + HttpServletResponse response) throws IOException {
  97 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  98 + List<PlanRateDetailDO> list = planRateDetailService.getPlanRateDetailPage(pageReqVO).getList();
  99 + // 导出 Excel
  100 + ExcelUtils.write(response, "计划频次明细.xls", "数据", PlanRateDetailRespVO.class,
  101 + BeanUtils.toBean(list, PlanRateDetailRespVO.class));
  102 + }
  103 +
  104 +}
0 105 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateDetailPageReqVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import com.zteits.urbanops.framework.common.pojo.PageParam;
  7 +import org.springframework.format.annotation.DateTimeFormat;
  8 +import java.time.LocalDateTime;
  9 +
  10 +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  11 +
  12 +@Schema(description = "管理后台 - 计划频次明细分页 Request VO")
  13 +@Data
  14 +public class PlanRateDetailPageReqVO extends PageParam {
  15 +
  16 + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政")
  17 + private String busiLine;
  18 +
  19 + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", example = "7693")
  20 + private Integer planTypeId;
  21 +
  22 + @Schema(description = "级别: 10:特级;11:一级:12:二级;13:三级", example = "26893")
  23 + private Integer levelId;
  24 +
  25 + @Schema(description = "次数 如:1/3等")
  26 + private String rate;
  27 +
  28 + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", example = "11235")
  29 + private Integer cycleId;
  30 +
  31 + @Schema(description = "创建时间")
  32 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  33 + private LocalDateTime[] createTime;
  34 +
  35 +}
0 36 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateDetailRespVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import org.springframework.format.annotation.DateTimeFormat;
  7 +import java.time.LocalDateTime;
  8 +import cn.idev.excel.annotation.*;
  9 +
  10 +@Schema(description = "管理后台 - 计划频次明细 Response VO")
  11 +@Data
  12 +@ExcelIgnoreUnannotated
  13 +public class PlanRateDetailRespVO {
  14 +
  15 + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6428")
  16 + @ExcelProperty("ID")
  17 + private Long id;
  18 +
  19 + /**
  20 + * 频次编号
  21 + */
  22 + @Schema(description = "频次编号", requiredMode = Schema.RequiredMode.REQUIRED)
  23 + @ExcelProperty("频次编号")
  24 + private String rateNo;
  25 +
  26 + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED)
  27 + @ExcelProperty("业务线: yl-园林;wy-物业:sz-市政")
  28 + private String busiLine;
  29 +
  30 + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "7693")
  31 + @ExcelProperty("养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;")
  32 + private Integer planTypeId;
  33 +
  34 + @Schema(description = "级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "26893")
  35 + @ExcelProperty("级别: 10:特级;11:一级:12:二级;13:三级")
  36 + private Integer levelId;
  37 +
  38 + @Schema(description = "次数 如:1/3等")
  39 + @ExcelProperty("次数 如:1/3等")
  40 + private String rate;
  41 +
  42 + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "11235")
  43 + @ExcelProperty("周期ID: 1:日/次;2:周/次;3:月/次;4:年/次")
  44 + private Integer cycleId;
  45 +
  46 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  47 + @ExcelProperty("创建时间")
  48 + private LocalDateTime createTime;
  49 +
  50 +}
0 51 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateDetailSaveReqVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import jakarta.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 计划频次明细新增/修改 Request VO")
  9 +@Data
  10 +public class PlanRateDetailSaveReqVO {
  11 +
  12 +
  13 + @Schema(description = "级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  14 + @NotNull(message = "级别: 10:特级;11:一级:12:二级;13:三级不能为空")
  15 + private Integer levelId;
  16 +
  17 + @Schema(description = "次数 如:1/3等")
  18 + @NotEmpty(message = "次数不能为空")
  19 + private String rate;
  20 +
  21 + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  22 + @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空")
  23 + private Integer cycleId;
  24 +
  25 +}
0 26 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRatePageReqVO.java
... ... @@ -13,26 +13,16 @@ import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YE
13 13 @Data
14 14 public class PlanRatePageReqVO extends PageParam {
15 15  
  16 + @Schema(description = "频次编号")
  17 + private String rateNo;
  18 +
16 19 @Schema(description = "业务线: yl-园林;wy-物业:sz-市政")
17 20 private String busiLine;
18 21  
19   - @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", example = "13649")
  22 + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", example = "16546")
20 23 private Integer planTypeId;
21 24  
22   - @Schema(description = "级别: 10:特级;11:一级:12:二级;13:三级", example = "14661")
23   - private Integer levelId;
24   -
25   - @Schema(description = "次数 如:1/3等")
26   - private String rate;
27   -
28   - @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", example = "17826")
29   - private Integer cycleId;
30   -
31 25 @Schema(description = "是否为标准计划: 1:是;2:否")
32 26 private Integer stdPlan;
33 27  
34   - @Schema(description = "创建时间")
35   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
36   - private LocalDateTime[] createTime;
37   -
38 28 }
39 29 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateRespVO.java
... ... @@ -12,30 +12,22 @@ import cn.idev.excel.annotation.*;
12 12 @ExcelIgnoreUnannotated
13 13 public class PlanRateRespVO {
14 14  
15   - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11435")
  15 + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18948")
16 16 @ExcelProperty("ID")
17 17 private Long id;
18 18  
  19 + @Schema(description = "频次编号", requiredMode = Schema.RequiredMode.REQUIRED)
  20 + @ExcelProperty("频次编号")
  21 + private String rateNo;
  22 +
19 23 @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED)
20 24 @ExcelProperty("业务线: yl-园林;wy-物业:sz-市政")
21 25 private String busiLine;
22 26  
23   - @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "13649")
  27 + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "16546")
24 28 @ExcelProperty("养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;")
25 29 private Integer planTypeId;
26 30  
27   - @Schema(description = "级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "14661")
28   - @ExcelProperty("级别: 10:特级;11:一级:12:二级;13:三级")
29   - private Integer levelId;
30   -
31   - @Schema(description = "次数 如:1/3等")
32   - @ExcelProperty("次数 如:1/3等")
33   - private String rate;
34   -
35   - @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "17826")
36   - @ExcelProperty("周期ID: 1:日/次;2:周/次;3:月/次;4:年/次")
37   - private Integer cycleId;
38   -
39 31 @Schema(description = "是否为标准计划: 1:是;2:否", requiredMode = Schema.RequiredMode.REQUIRED)
40 32 @ExcelProperty("是否为标准计划: 1:是;2:否")
41 33 private Integer stdPlan;
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateSaveReqVO.java
1 1 package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
2 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.Valid;
4 5 import lombok.*;
5 6 import java.util.*;
6 7 import jakarta.validation.constraints.*;
... ... @@ -9,30 +10,22 @@ import jakarta.validation.constraints.*;
9 10 @Data
10 11 public class PlanRateSaveReqVO {
11 12  
12   - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11435")
13   - private Long id;
14 13  
15 14 @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED)
16 15 @NotEmpty(message = "业务线: yl-园林;wy-物业:sz-市政不能为空")
17 16 private String busiLine;
18 17  
19   - @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "13649")
  18 + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "16546")
20 19 @NotNull(message = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;不能为空")
21 20 private Integer planTypeId;
22 21  
23   - @Schema(description = "级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "14661")
24   - @NotNull(message = "级别: 10:特级;11:一级:12:二级;13:三级不能为空")
25   - private Integer levelId;
26   -
27   - @Schema(description = "次数 如:1/3等")
28   - private String rate;
29   -
30   - @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "17826")
31   - @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空")
32   - private Integer cycleId;
33   -
34 22 @Schema(description = "是否为标准计划: 1:是;2:否", requiredMode = Schema.RequiredMode.REQUIRED)
35 23 @NotNull(message = "是否为标准计划: 1:是;2:否不能为空")
36 24 private Integer stdPlan;
37 25  
  26 + @NotNull@NotNull(message = "频次明细不能为空")
  27 + @Size(min = 1)
  28 + @Valid
  29 + private List<PlanRateDetailSaveReqVO> details;
  30 +
38 31 }
39 32 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/planrate/vo/PlanRateUpdateReqVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.planrate.vo;
  2 +
  3 +import com.zteits.urbanops.module.garden.util.FieldDuplicateCheckerUtil;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import jakarta.validation.Valid;
  6 +import jakarta.validation.constraints.NotEmpty;
  7 +import jakarta.validation.constraints.NotNull;
  8 +import jakarta.validation.constraints.Size;
  9 +import lombok.Data;
  10 +
  11 +import java.util.List;
  12 +import java.util.Set;
  13 +import java.util.stream.Collectors;
  14 +
  15 +@Schema(description = "管理后台 - 计划频次新增/修改 Request VO")
  16 +@Data
  17 +public class PlanRateUpdateReqVO {
  18 + /**
  19 + * 频次编号
  20 + */
  21 + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED)
  22 + @NotEmpty(message = "频次编号不能为空")
  23 + private String rateNo;
  24 +
  25 + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED)
  26 + @NotEmpty(message = "业务线: yl-园林;wy-物业:sz-市政不能为空")
  27 + private String busiLine;
  28 +
  29 + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "16546")
  30 + @NotNull(message = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;不能为空")
  31 + private Integer planTypeId;
  32 +
  33 + @Schema(description = "是否为标准计划: 1:是;2:否", requiredMode = Schema.RequiredMode.REQUIRED)
  34 + @NotNull(message = "是否为标准计划: 1:是;2:否不能为空")
  35 + private Integer stdPlan;
  36 +
  37 + @NotNull@NotNull(message = "频次明细不能为空")
  38 + @Size(min = 1)
  39 + @Valid
  40 + private List<PlanRateDetailSaveReqVO> details;
  41 +
  42 + public boolean verify() {
  43 + return FieldDuplicateCheckerUtil.hasDuplicate(details, PlanRateDetailSaveReqVO::getLevelId);
  44 + }
  45 +
  46 +
  47 +
  48 +}
0 49 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/planrate/PlanRateDO.java
... ... @@ -28,6 +28,10 @@ public class PlanRateDO extends BaseDO {
28 28 @TableId
29 29 private Long id;
30 30 /**
  31 + * 频次编号
  32 + */
  33 + private String rateNo;
  34 + /**
31 35 * 业务线: yl-园林;wy-物业:sz-市政
32 36 */
33 37 private String busiLine;
... ... @@ -36,18 +40,6 @@ public class PlanRateDO extends BaseDO {
36 40 */
37 41 private Integer planTypeId;
38 42 /**
39   - * 级别: 10:特级;11:一级:12:二级;13:三级
40   - */
41   - private Integer levelId;
42   - /**
43   - * 次数 如:1/3等
44   - */
45   - private String rate;
46   - /**
47   - * 周期ID: 1:日/次;2:周/次;3:月/次;4:年/次
48   - */
49   - private Integer cycleId;
50   - /**
51 43 * 是否为标准计划: 1:是;2:否
52 44 */
53 45 private Integer stdPlan;
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/planrate/PlanRateDetailDO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.dal.dataobject.planrate;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.*;
  8 +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO;
  9 +
  10 +/**
  11 + * 计划频次明细 DO
  12 + *
  13 + * @author 超级管理员
  14 + */
  15 +@TableName("garden_plan_rate_detail")
  16 +@KeySequence("garden_plan_rate_detail_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class PlanRateDetailDO extends BaseDO {
  24 +
  25 + /**
  26 + * ID
  27 + */
  28 + @TableId
  29 + private Long id;
  30 + /**
  31 + * 频次编号
  32 + */
  33 + private String rateNo;
  34 + /**
  35 + * 业务线: yl-园林;wy-物业:sz-市政
  36 + */
  37 + private String busiLine;
  38 + /**
  39 + * 养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;
  40 + */
  41 + private Integer planTypeId;
  42 + /**
  43 + * 级别: 10:特级;11:一级:12:二级;13:三级
  44 + */
  45 + private Integer levelId;
  46 + /**
  47 + * 次数 如:1/3等
  48 + */
  49 + private String rate;
  50 + /**
  51 + * 周期ID: 1:日/次;2:周/次;3:月/次;4:年/次
  52 + */
  53 + private Integer cycleId;
  54 +
  55 +
  56 +}
0 57 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/inspectionplan/InspectionPlanDetailMapper.java
... ... @@ -8,6 +8,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
8 8 import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDetailDO;
9 9 import org.apache.ibatis.annotations.Mapper;
10 10 import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*;
  11 +import org.apache.ibatis.annotations.Param;
11 12  
12 13 /**
13 14 * 巡检计划 Mapper
... ... @@ -33,4 +34,6 @@ public interface InspectionPlanDetailMapper extends BaseMapperX&lt;InspectionPlanDe
33 34 .orderByDesc(InspectionPlanDetailDO::getId));
34 35 }
35 36  
  37 + int deleteByBatchNo(@Param("batchNo") String batchNo);
  38 +
36 39 }
37 40 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/inspectionplan/InspectionPlanMapper.java
... ... @@ -7,6 +7,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
7 7 import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO;
8 8 import org.apache.ibatis.annotations.Mapper;
9 9 import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*;
  10 +import org.apache.ibatis.annotations.Param;
10 11  
11 12 /**
12 13 * 巡检计划汇总 Mapper
... ... @@ -30,4 +31,6 @@ public interface InspectionPlanMapper extends BaseMapperX&lt;InspectionPlanDO&gt; {
30 31 .orderByDesc(InspectionPlanDO::getId));
31 32 }
32 33  
  34 + int deleteByBatchNo(@Param("batchNo") String batchNo);
  35 +
33 36 }
34 37 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/inspectionplan/InspectionPlanRoleMapper.java
1 1 package com.zteits.urbanops.module.garden.dal.mysql.inspectionplan;
2 2  
3   -import java.util.*;
4 3  
5 4 import com.zteits.urbanops.framework.common.pojo.PageResult;
6 5 import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX;
... ... @@ -8,6 +7,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
8 7 import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.InspectionPlanRolePageReqVO;
9 8 import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanRoleDO;
10 9 import org.apache.ibatis.annotations.Mapper;
  10 +import org.apache.ibatis.annotations.Param;
11 11  
12 12 /**
13 13 * 巡检计划角色 Mapper
... ... @@ -27,4 +27,6 @@ public interface InspectionPlanRoleMapper extends BaseMapperX&lt;InspectionPlanRole
27 27 .orderByDesc(InspectionPlanRoleDO::getId));
28 28 }
29 29  
  30 + int deleteByBatchNo(@Param("batchNo") String batchNo);
  31 +
30 32 }
31 33 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/planrate/PlanRateDetailMapper.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.dal.mysql.planrate;
  2 +
  3 +import java.util.*;
  4 +
  5 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  6 +import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
  8 +import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
  11 +import org.apache.ibatis.annotations.Param;
  12 +
  13 +/**
  14 + * 计划频次明细 Mapper
  15 + *
  16 + * @author 超级管理员
  17 + */
  18 +@Mapper
  19 +public interface PlanRateDetailMapper extends BaseMapperX<PlanRateDetailDO> {
  20 +
  21 + default PageResult<PlanRateDetailDO> selectPage(PlanRateDetailPageReqVO reqVO) {
  22 + return selectPage(reqVO, new LambdaQueryWrapperX<PlanRateDetailDO>()
  23 + .eqIfPresent(PlanRateDetailDO::getBusiLine, reqVO.getBusiLine())
  24 + .eqIfPresent(PlanRateDetailDO::getPlanTypeId, reqVO.getPlanTypeId())
  25 + .eqIfPresent(PlanRateDetailDO::getLevelId, reqVO.getLevelId())
  26 + .eqIfPresent(PlanRateDetailDO::getRate, reqVO.getRate())
  27 + .eqIfPresent(PlanRateDetailDO::getCycleId, reqVO.getCycleId())
  28 + .betweenIfPresent(PlanRateDetailDO::getCreateTime, reqVO.getCreateTime())
  29 + .orderByDesc(PlanRateDetailDO::getId));
  30 + }
  31 +
  32 + int deleteByRateNo(@Param("rateNo") String rateNo);
  33 +
  34 +}
0 35 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/planrate/PlanRateMapper.java
... ... @@ -8,6 +8,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
8 8 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
9 9 import org.apache.ibatis.annotations.Mapper;
10 10 import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
  11 +import org.apache.ibatis.annotations.Param;
11 12  
12 13 /**
13 14 * 计划频次 Mapper
... ... @@ -19,14 +20,13 @@ public interface PlanRateMapper extends BaseMapperX&lt;PlanRateDO&gt; {
19 20  
20 21 default PageResult<PlanRateDO> selectPage(PlanRatePageReqVO reqVO) {
21 22 return selectPage(reqVO, new LambdaQueryWrapperX<PlanRateDO>()
  23 + .eqIfPresent(PlanRateDO::getRateNo, reqVO.getRateNo())
22 24 .eqIfPresent(PlanRateDO::getBusiLine, reqVO.getBusiLine())
23 25 .eqIfPresent(PlanRateDO::getPlanTypeId, reqVO.getPlanTypeId())
24   - .eqIfPresent(PlanRateDO::getLevelId, reqVO.getLevelId())
25   - .eqIfPresent(PlanRateDO::getRate, reqVO.getRate())
26   - .eqIfPresent(PlanRateDO::getCycleId, reqVO.getCycleId())
27 26 .eqIfPresent(PlanRateDO::getStdPlan, reqVO.getStdPlan())
28   - .betweenIfPresent(PlanRateDO::getCreateTime, reqVO.getCreateTime())
29 27 .orderByDesc(PlanRateDO::getId));
30 28 }
31 29  
  30 + int deleteByRateNo(@Param("rateNo") String rateNo);
  31 +
32 32 }
33 33 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
... ... @@ -58,4 +58,9 @@ public interface ErrorCodeConstants {
58 58 ErrorCode INSPECTION_CYCLE_ID_ERROR = new ErrorCode(1-200-100-002, "周期id错误");
59 59 ErrorCode INSPECTION_CYCLE_ERROR = new ErrorCode(1-200-100-003, "获取两个时间之间间隔天数错误");
60 60 ErrorCode INSPECTION_PLAN_EXISTS = new ErrorCode(1-200-100-004, "道路对应类型已存在记录");
  61 +
  62 + //========== 频次 TODO 补充编号 ==========
  63 + ErrorCode PLAN_RATE_EXISTS = new ErrorCode(1-200-200-001, "养护频次已存在");
  64 + ErrorCode PLAN_RATE_LEVEL_ID_DUPLICATE = new ErrorCode(1-200-200-002, "养护等级重复");
  65 +
61 66 }
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
... ... @@ -174,7 +174,8 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
174 174 QueryWrapper<InspectionPlanDO> sql = new QueryWrapper<>();
175 175 sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId())
176 176 .in(InspectionPlanDO::getRoadId, roadIds)
177   - .between(InspectionPlanDO::getBeginTime, req.getBeginTime(), req.getEndTime());
  177 + .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime
  178 + .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime
178 179  
179 180 Long count = inspectionPlanMapper.selectCount(sql);
180 181 if (count > 0) {
... ... @@ -201,9 +202,9 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
201 202  
202 203 @Override
203 204 public void deleteInspectionPlanByBatchNo(String batchNo) {
204   - inspectionPlanMapper.delete(InspectionPlanDO::getBatchNo, batchNo);
205   - inspectionPlanDetailMapper.delete(InspectionPlanDetailDO::getBatchNo, batchNo);
206   - inspectionPlanRoleMapper.delete(InspectionPlanRoleDO::getBatchNo, batchNo);
  205 + inspectionPlanMapper.deleteByBatchNo(batchNo);
  206 + inspectionPlanDetailMapper.deleteByBatchNo(batchNo);
  207 + inspectionPlanRoleMapper.deleteByBatchNo(batchNo);
207 208 }
208 209  
209 210 }
210 211 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateDetailService.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.service.planrate;
  2 +
  3 +import java.util.*;
  4 +import jakarta.validation.*;
  5 +import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
  6 +import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
  7 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  8 +import com.zteits.urbanops.framework.common.pojo.PageParam;
  9 +
  10 +/**
  11 + * 计划频次明细 Service 接口
  12 + *
  13 + * @author 超级管理员
  14 + */
  15 +public interface PlanRateDetailService {
  16 +
  17 + /**
  18 + * 创建计划频次明细
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createPlanRateDetail(@Valid PlanRateDetailSaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 更新计划频次明细
  27 + *
  28 + * @param updateReqVO 更新信息
  29 + */
  30 + void updatePlanRateDetail(@Valid PlanRateDetailSaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除计划频次明细
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deletePlanRateDetail(Long id);
  38 +
  39 + /**
  40 + * 批量删除计划频次明细
  41 + *
  42 + * @param ids 编号
  43 + */
  44 + void deletePlanRateDetailListByIds(List<Long> ids);
  45 +
  46 + /**
  47 + * 获得计划频次明细
  48 + *
  49 + * @param id 编号
  50 + * @return 计划频次明细
  51 + */
  52 + PlanRateDetailDO getPlanRateDetail(Long id);
  53 +
  54 + /**
  55 + * 获得计划频次明细分页
  56 + *
  57 + * @param pageReqVO 分页查询
  58 + * @return 计划频次明细分页
  59 + */
  60 + PageResult<PlanRateDetailDO> getPlanRateDetailPage(PlanRateDetailPageReqVO pageReqVO);
  61 +
  62 + /**
  63 + * 获得计划频次明细
  64 + *
  65 + * @param rateNo 编号
  66 + * @return 计划频次明细列表
  67 + */
  68 + List<PlanRateDetailDO> getPlanRateDetailByRateNo(String rateNo);
  69 +
  70 +}
0 71 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateDetailServiceImpl.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.service.planrate;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4 +import org.springframework.stereotype.Service;
  5 +import jakarta.annotation.Resource;
  6 +import org.springframework.validation.annotation.Validated;
  7 +
  8 +import java.util.*;
  9 +import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
  10 +import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
  11 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  12 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  13 +
  14 +import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateDetailMapper;
  15 +
  16 +/**
  17 + * 计划频次明细 Service 实现类
  18 + *
  19 + * @author 超级管理员
  20 + */
  21 +@Service
  22 +@Validated
  23 +public class PlanRateDetailServiceImpl implements PlanRateDetailService {
  24 +
  25 + @Resource
  26 + private PlanRateDetailMapper planRateDetailMapper;
  27 +
  28 + @Override
  29 + public Long createPlanRateDetail(PlanRateDetailSaveReqVO createReqVO) {
  30 + // 插入
  31 + PlanRateDetailDO planRateDetail = BeanUtils.toBean(createReqVO, PlanRateDetailDO.class);
  32 + planRateDetailMapper.insert(planRateDetail);
  33 +
  34 + // 返回
  35 + return planRateDetail.getId();
  36 + }
  37 +
  38 + @Override
  39 + public void updatePlanRateDetail(PlanRateDetailSaveReqVO updateReqVO) {
  40 + // 校验存在
  41 + //validatePlanRateDetailExists(updateReqVO.getId());
  42 + // 更新
  43 + PlanRateDetailDO updateObj = BeanUtils.toBean(updateReqVO, PlanRateDetailDO.class);
  44 + planRateDetailMapper.updateById(updateObj);
  45 + }
  46 +
  47 + @Override
  48 + public void deletePlanRateDetail(Long id) {
  49 + // 校验存在
  50 + validatePlanRateDetailExists(id);
  51 + // 删除
  52 + planRateDetailMapper.deleteById(id);
  53 + }
  54 +
  55 + @Override
  56 + public void deletePlanRateDetailListByIds(List<Long> ids) {
  57 + // 删除
  58 + planRateDetailMapper.deleteByIds(ids);
  59 + }
  60 +
  61 +
  62 + private void validatePlanRateDetailExists(Long id) {
  63 + if (planRateDetailMapper.selectById(id) == null) {
  64 + //throw exception("");
  65 + }
  66 + }
  67 +
  68 + @Override
  69 + public PlanRateDetailDO getPlanRateDetail(Long id) {
  70 + return planRateDetailMapper.selectById(id);
  71 + }
  72 +
  73 + @Override
  74 + public PageResult<PlanRateDetailDO> getPlanRateDetailPage(PlanRateDetailPageReqVO pageReqVO) {
  75 + return planRateDetailMapper.selectPage(pageReqVO);
  76 + }
  77 +
  78 + @Override
  79 + public List<PlanRateDetailDO> getPlanRateDetailByRateNo(String rateNo) {
  80 + QueryWrapper<PlanRateDetailDO> sql = new QueryWrapper<>();
  81 + sql.lambda().eq(PlanRateDetailDO::getRateNo, rateNo);
  82 + return planRateDetailMapper.selectList(sql);
  83 + }
  84 +
  85 +}
0 86 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateService.java
... ... @@ -27,7 +27,7 @@ public interface PlanRateService {
27 27 *
28 28 * @param updateReqVO 更新信息
29 29 */
30   - void updatePlanRate(@Valid PlanRateSaveReqVO updateReqVO);
  30 + void updatePlanRate(@Valid PlanRateUpdateReqVO updateReqVO);
31 31  
32 32 /**
33 33 * 删除计划频次
... ... @@ -44,6 +44,13 @@ public interface PlanRateService {
44 44 void deletePlanRateListByIds(List<Long> ids);
45 45  
46 46 /**
  47 + * 批量删除计划频次
  48 + *
  49 + * @param rateNo 编号
  50 + */
  51 + void deletePlanRateByRateNo(String rateNo);
  52 +
  53 + /**
47 54 * 获得计划频次
48 55 *
49 56 * @param id 编号
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/planrate/PlanRateServiceImpl.java
1 1 package com.zteits.urbanops.module.garden.service.planrate;
2 2  
3   -import cn.hutool.core.collection.CollUtil;
  3 +import cn.hutool.core.date.DateUtil;
  4 +import cn.hutool.core.util.RandomUtil;
  5 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6 +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  7 +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;
  8 +import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDetailDO;
  9 +import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateDetailMapper;
4 10 import org.springframework.stereotype.Service;
5 11 import jakarta.annotation.Resource;
6 12 import org.springframework.validation.annotation.Validated;
7 13 import org.springframework.transaction.annotation.Transactional;
8 14  
  15 +import java.time.LocalDateTime;
9 16 import java.util.*;
  17 +
10 18 import com.zteits.urbanops.module.garden.controller.admin.planrate.vo.*;
11 19 import com.zteits.urbanops.module.garden.dal.dataobject.planrate.PlanRateDO;
12 20 import com.zteits.urbanops.framework.common.pojo.PageResult;
13   -import com.zteits.urbanops.framework.common.pojo.PageParam;
14   -import com.zteits.urbanops.framework.common.util.object.BeanUtils;
15 21  
16 22 import com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateMapper;
17 23  
18 24 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
19   -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList;
20   -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList;
21 25 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*;
22 26  
23 27 /**
... ... @@ -32,43 +36,111 @@ public class PlanRateServiceImpl implements PlanRateService {
32 36 @Resource
33 37 private PlanRateMapper planRateMapper;
34 38  
  39 + @Resource
  40 + private PlanRateDetailMapper planRateDetailMapper;
  41 +
  42 + @Transactional(rollbackFor = Exception.class)
35 43 @Override
36 44 public Long createPlanRate(PlanRateSaveReqVO createReqVO) {
37   - // 插入
38   - PlanRateDO planRate = BeanUtils.toBean(createReqVO, PlanRateDO.class);
  45 + // 校验存在
  46 + validatePlanRateExists(createReqVO.getPlanTypeId(), createReqVO.getBusiLine());
  47 + LocalDateTime now = LocalDateTime.now();
  48 + String userName = SecurityFrameworkUtils.getLoginUserId() + "";
  49 + String rateNo = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS") + RandomUtil.randomInt(1000);
  50 + PlanRateDO planRate = new PlanRateDO();
  51 + planRate.setRateNo(rateNo);
  52 + planRate.setStdPlan(createReqVO.getStdPlan());
  53 + planRate.setBusiLine(createReqVO.getBusiLine());
  54 + planRate.setPlanTypeId(createReqVO.getPlanTypeId());
  55 + planRate.setCreator(userName);
  56 + planRate.setCreateTime(now);
  57 + planRate.setUpdater(userName);
  58 + planRate.setUpdateTime(now);
  59 + /*1.插入频次主表*/
39 60 planRateMapper.insert(planRate);
40 61  
  62 + List<PlanRateDetailDO> list = new ArrayList<>();
  63 + createReqVO.getDetails().forEach(detail -> {
  64 + PlanRateDetailDO detailDO = new PlanRateDetailDO();
  65 + detailDO.setRateNo(rateNo);
  66 + detailDO.setBusiLine(createReqVO.getBusiLine());
  67 + detailDO.setPlanTypeId(createReqVO.getPlanTypeId());
  68 + detailDO.setLevelId(detail.getLevelId());
  69 + detailDO.setRate(detail.getRate());
  70 + detailDO.setCycleId(detail.getCycleId());
  71 + detailDO.setCreator(userName);
  72 + detailDO.setCreateTime(now);
  73 + detailDO.setUpdater(userName);
  74 + detailDO.setUpdateTime(now);
  75 + list.add(detailDO);
  76 + });
  77 + /*2.插入频次明细*/
  78 + planRateDetailMapper.insertBatch(list);
41 79 // 返回
42 80 return planRate.getId();
43 81 }
44 82  
  83 + @Transactional(rollbackFor = Exception.class)
45 84 @Override
46   - public void updatePlanRate(PlanRateSaveReqVO updateReqVO) {
47   - // 校验存在
48   - validatePlanRateExists(updateReqVO.getId());
  85 + public void updatePlanRate(PlanRateUpdateReqVO updateReqVO) {
  86 + /*1.删除明细*/
  87 + int count = planRateDetailMapper.deleteByRateNo(updateReqVO.getRateNo());
  88 + LocalDateTime now = LocalDateTime.now();
  89 + String userName = SecurityFrameworkUtils.getLoginUserId() + "";
  90 + UpdateWrapper<PlanRateDO> updateSql = new UpdateWrapper<>();
  91 + updateSql.lambda()
  92 + .set(PlanRateDO::getStdPlan, updateReqVO.getStdPlan())
  93 + .set(PlanRateDO::getUpdater, userName)
  94 + .set(PlanRateDO::getUpdateTime, now)
  95 + .eq(PlanRateDO::getRateNo, updateReqVO.getRateNo());
  96 + /*2.更新主表*/
  97 + planRateMapper.update(updateSql);
49 98 // 更新
50   - PlanRateDO updateObj = BeanUtils.toBean(updateReqVO, PlanRateDO.class);
51   - planRateMapper.updateById(updateObj);
  99 + List<PlanRateDetailDO> list = new ArrayList<>();
  100 + updateReqVO.getDetails().forEach(detail -> {
  101 + PlanRateDetailDO detailDO = new PlanRateDetailDO();
  102 + detailDO.setRateNo(updateReqVO.getRateNo());
  103 + detailDO.setBusiLine(updateReqVO.getBusiLine());
  104 + detailDO.setPlanTypeId(updateReqVO.getPlanTypeId());
  105 + detailDO.setLevelId(detail.getLevelId());
  106 + detailDO.setRate(detail.getRate());
  107 + detailDO.setCycleId(detail.getCycleId());
  108 + detailDO.setCreator(userName);
  109 + detailDO.setCreateTime(now);
  110 + detailDO.setUpdater(userName);
  111 + detailDO.setUpdateTime(now);
  112 + list.add(detailDO);
  113 + });
  114 + /*3.插入频次明细*/
  115 + planRateDetailMapper.insertBatch(list);
52 116 }
53 117  
54 118 @Override
55 119 public void deletePlanRate(Long id) {
56 120 // 校验存在
57   - validatePlanRateExists(id);
  121 + //validatePlanRateExists(id);
58 122 // 删除
59 123 planRateMapper.deleteById(id);
60 124 }
61 125  
62 126 @Override
63   - public void deletePlanRateListByIds(List<Long> ids) {
  127 + public void deletePlanRateListByIds(List<Long> ids) {
64 128 // 删除
65 129 planRateMapper.deleteByIds(ids);
66   - }
  130 + }
  131 +
  132 + @Override
  133 + public void deletePlanRateByRateNo(String rateNo) {
  134 + planRateMapper.deleteByRateNo(rateNo);
  135 + planRateDetailMapper.deleteByRateNo(rateNo);
  136 + }
67 137  
68 138  
69   - private void validatePlanRateExists(Long id) {
70   - if (planRateMapper.selectById(id) == null) {
71   - //throw exception(PLAN_RATE_NOT_EXISTS);
  139 + private void validatePlanRateExists(Integer planTypeId, String busiLine) {
  140 + QueryWrapper<PlanRateDO> sql = new QueryWrapper<>();
  141 + sql.lambda().eq(PlanRateDO::getPlanTypeId, planTypeId).eq(PlanRateDO::getBusiLine, busiLine);
  142 + if (planRateMapper.selectCount(sql) > 0) {
  143 + throw exception(PLAN_RATE_EXISTS);
72 144 }
73 145 }
74 146  
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/util/FieldDuplicateCheckerUtil.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.util;
  2 +import java.util.LinkedHashSet;
  3 +import java.util.List;
  4 +import java.util.Set;
  5 +import java.util.function.Function;
  6 +
  7 +public class FieldDuplicateCheckerUtil {
  8 +
  9 + /**
  10 + * 通用判断:指定字段是否存在重复值
  11 + * @param list 目标列表(可为 null/空)
  12 + * @param fieldExtractor 字段提取器(如 User::getId、User::getName)
  13 + * @param <T> 列表元素类型
  14 + * @param <R> 字段类型(需重写 equals/hashCode,如 Long、String、自定义类)
  15 + * @return true=存在重复,false=无重复
  16 + */
  17 + public static <T, R> boolean hasDuplicate(List<T> list, Function<T, R> fieldExtractor) {
  18 + // 边界条件:空列表或仅1个元素,直接返回无重复
  19 + if (list == null || list.size() <= 1) {
  20 + return false;
  21 + }
  22 +
  23 + Set<R> fieldSet = new LinkedHashSet<>(); // 用于存储已出现的字段值
  24 + for (T item : list) {
  25 + R fieldValue = fieldExtractor.apply(item); // 提取当前对象的字段值
  26 +
  27 + // 处理 null 值:多个 null 视为重复
  28 + if (fieldValue == null) {
  29 + // 统计 null 出现次数,>1 则返回重复
  30 + long nullCount = list.stream().filter(t -> fieldExtractor.apply(t) == null).count();
  31 + return nullCount > 1;
  32 + }
  33 +
  34 + // 非 null 值:添加到 Set 失败(已存在)→ 存在重复,短路返回
  35 + if (!fieldSet.add(fieldValue)) {
  36 + return true;
  37 + }
  38 + }
  39 +
  40 + // 遍历完成无重复
  41 + return false;
  42 + }
  43 +}
... ...
urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanDetailMapper.xml
... ... @@ -8,5 +8,8 @@
8 8 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
9 9 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
10 10 -->
  11 + <delete id="deleteByBatchNo">
  12 + delete from garden_inspection_plan_detail where batch_no =#{batchNo}
  13 + </delete>
11 14  
12 15 </mapper>
13 16 \ No newline at end of file
... ...
urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanMapper.xml
... ... @@ -9,4 +9,8 @@
9 9 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
10 10 -->
11 11  
  12 + <delete id="deleteByBatchNo">
  13 + delete from garden_inspection_plan where batch_no =#{batchNo}
  14 + </delete>
  15 +
12 16 </mapper>
13 17 \ No newline at end of file
... ...
urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanRoleMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanRoleMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 + <delete id="deleteByBatchNo">
  12 + delete from garden_inspection_plan_role where batch_no =#{batchNo}
  13 + </delete>
  14 +
  15 +</mapper>
0 16 \ No newline at end of file
... ...
urbanops-module-garden/src/main/resources/mapper/planrate/PlanRateDetailMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateDetailMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 + <delete id="deleteByRateNo">
  13 + delete from garden_plan_rate_detail where rate_no=#{rateNo}
  14 + </delete>
  15 +</mapper>
0 16 \ No newline at end of file
... ...
urbanops-module-garden/src/main/resources/mapper/planrate/PlanRateMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.zteits.urbanops.module.garden.dal.mysql.planrate.PlanRateMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 + <delete id="deleteByRateNo">
  12 + delete from garden_plan_rate_detail where rate_no=#{rateNo}
  13 + </delete>
  14 +</mapper>
0 15 \ No newline at end of file
... ...