Commit 04ee424b7cb48e0cfe412e57a195d7e6ee0c217a
1 parent
669cf0a6
养护计划提交
Showing
16 changed files
with
268 additions
and
103 deletions
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 jakarta.validation.constraints.NotBlank; | ||
| 3 | import org.springframework.web.bind.annotation.*; | 4 | import org.springframework.web.bind.annotation.*; |
| 4 | import jakarta.annotation.Resource; | 5 | import jakarta.annotation.Resource; |
| 5 | import org.springframework.validation.annotation.Validated; | 6 | import org.springframework.validation.annotation.Validated; |
| @@ -41,7 +42,7 @@ public class MaintainPlanController { | @@ -41,7 +42,7 @@ public class MaintainPlanController { | ||
| 41 | @Operation(summary = "创建养护计划汇总") | 42 | @Operation(summary = "创建养护计划汇总") |
| 42 | @PreAuthorize("@ss.hasPermission('garden:maintain-plan:create')") | 43 | @PreAuthorize("@ss.hasPermission('garden:maintain-plan:create')") |
| 43 | public CommonResult<Long> createMaintainPlan(@Valid @RequestBody MaintainPlanSaveReqVO createReqVO) { | 44 | public CommonResult<Long> createMaintainPlan(@Valid @RequestBody MaintainPlanSaveReqVO createReqVO) { |
| 44 | - return success(maintainPlanService.createMaintainPlan(createReqVO)); | 45 | + return maintainPlanService.createMaintainPlan(createReqVO); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | @PutMapping("/update") | 48 | @PutMapping("/update") |
| @@ -70,6 +71,24 @@ public class MaintainPlanController { | @@ -70,6 +71,24 @@ public class MaintainPlanController { | ||
| 70 | return success(true); | 71 | return success(true); |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 74 | + @DeleteMapping("/delete-batch_no") | ||
| 75 | + @Parameter(name = "batchNo", description = "批次号", required = true) | ||
| 76 | + @Operation(summary = "根据batch_no删除养护计划汇总") | ||
| 77 | + @PreAuthorize("@ss.hasPermission('garden:maintain-plan:delete')") | ||
| 78 | + public CommonResult<Boolean> deleteInspectionPlanByBatchNo(@RequestParam("batch_no") @NotBlank String batchNo) { | ||
| 79 | + maintainPlanService.deleteInspectionPlanByBatchNo(batchNo); | ||
| 80 | + return success(true); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @DeleteMapping("/delete-stop-plan") | ||
| 84 | + @Parameter(name = "batchNo", description = "批次号", required = true) | ||
| 85 | + @Operation(summary = "根据batch_no删除养护计划汇总") | ||
| 86 | + @PreAuthorize("@ss.hasPermission('garden:maintain-plan:delete')") | ||
| 87 | + public CommonResult<Boolean> stopPlanInspectionPlan(@RequestParam("batch_no") @NotBlank String batchNo) { | ||
| 88 | + maintainPlanService.stopPlanInspectionPlan(batchNo); | ||
| 89 | + return success(true); | ||
| 90 | + } | ||
| 91 | + | ||
| 73 | @GetMapping("/get") | 92 | @GetMapping("/get") |
| 74 | @Operation(summary = "获得养护计划汇总") | 93 | @Operation(summary = "获得养护计划汇总") |
| 75 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 94 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanDetailPageReqVO.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo; | 1 | package com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo; |
| 2 | 2 | ||
| 3 | +import jakarta.validation.constraints.NotEmpty; | ||
| 3 | import lombok.*; | 4 | import lombok.*; |
| 4 | 5 | ||
| 5 | import java.time.LocalDate; | 6 | import java.time.LocalDate; |
| @@ -15,6 +16,7 @@ import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YE | @@ -15,6 +16,7 @@ import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YE | ||
| 15 | public class MaintainPlanDetailPageReqVO extends PageParam { | 16 | public class MaintainPlanDetailPageReqVO extends PageParam { |
| 16 | 17 | ||
| 17 | @Schema(description = "批次号") | 18 | @Schema(description = "批次号") |
| 19 | + @NotEmpty(message = "批次号不能为空") | ||
| 18 | private String batchNo; | 20 | private String batchNo; |
| 19 | 21 | ||
| 20 | @Schema(description = "计划编码") | 22 | @Schema(description = "计划编码") |
| @@ -56,7 +58,5 @@ public class MaintainPlanDetailPageReqVO extends PageParam { | @@ -56,7 +58,5 @@ public class MaintainPlanDetailPageReqVO extends PageParam { | ||
| 56 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 58 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 57 | private LocalDateTime[] createTime; | 59 | private LocalDateTime[] createTime; |
| 58 | 60 | ||
| 59 | - @Schema(description = "更新者", example = "芋艿") | ||
| 60 | - private String updaterName; | ||
| 61 | 61 | ||
| 62 | } | 62 | } |
| 63 | \ No newline at end of file | 63 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanDetailRespVO.java
| @@ -60,6 +60,10 @@ public class MaintainPlanDetailRespVO { | @@ -60,6 +60,10 @@ public class MaintainPlanDetailRespVO { | ||
| 60 | @ExcelProperty("完成状态 1:未完成;2:进行中;3:已完成") | 60 | @ExcelProperty("完成状态 1:未完成;2:进行中;3:已完成") |
| 61 | private Integer finishState; | 61 | private Integer finishState; |
| 62 | 62 | ||
| 63 | + @Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "ZIEITS") | ||
| 64 | + @ExcelProperty("创建人ID") | ||
| 65 | + private String creator; | ||
| 66 | + | ||
| 63 | @Schema(description = "创建者", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | 67 | @Schema(description = "创建者", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") |
| 64 | @ExcelProperty("创建者") | 68 | @ExcelProperty("创建者") |
| 65 | private String creatorName; | 69 | private String creatorName; |
| @@ -67,9 +71,4 @@ public class MaintainPlanDetailRespVO { | @@ -67,9 +71,4 @@ public class MaintainPlanDetailRespVO { | ||
| 67 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 71 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 68 | @ExcelProperty("创建时间") | 72 | @ExcelProperty("创建时间") |
| 69 | private LocalDateTime createTime; | 73 | private LocalDateTime createTime; |
| 70 | - | ||
| 71 | - @Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 72 | - @ExcelProperty("更新者") | ||
| 73 | - private String updaterName; | ||
| 74 | - | ||
| 75 | } | 74 | } |
| 76 | \ No newline at end of file | 75 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanPageReqVO.java
| @@ -20,8 +20,6 @@ public class MaintainPlanPageReqVO extends PageParam { | @@ -20,8 +20,6 @@ public class MaintainPlanPageReqVO extends PageParam { | ||
| 20 | @Schema(description = "计划名称", example = "王五") | 20 | @Schema(description = "计划名称", example = "王五") |
| 21 | private String planName; | 21 | private String planName; |
| 22 | 22 | ||
| 23 | - @Schema(description = "业务线: yl-园林;wy-物业:sz-市政") | ||
| 24 | - private String busiLine; | ||
| 25 | 23 | ||
| 26 | @Schema(description = "计划属性:1:标准计划;2:临时计划") | 24 | @Schema(description = "计划属性:1:标准计划;2:临时计划") |
| 27 | private Integer planAttr; | 25 | private Integer planAttr; |
| @@ -32,30 +30,12 @@ public class MaintainPlanPageReqVO extends PageParam { | @@ -32,30 +30,12 @@ public class MaintainPlanPageReqVO extends PageParam { | ||
| 32 | @Schema(description = "归属(一级部门id)", example = "1713") | 30 | @Schema(description = "归属(一级部门id)", example = "1713") |
| 33 | private Long companyId; | 31 | private Long companyId; |
| 34 | 32 | ||
| 35 | - @Schema(description = "部门ID(道路负责部门id)", example = "12055") | ||
| 36 | - private Long deptId; | ||
| 37 | - | ||
| 38 | - @Schema(description = "道路ID", example = "19114") | ||
| 39 | - private Long roadId; | ||
| 40 | - | ||
| 41 | @Schema(description = "道路名称", example = "王五") | 33 | @Schema(description = "道路名称", example = "王五") |
| 42 | private String roadName; | 34 | private String roadName; |
| 43 | 35 | ||
| 44 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", example = "16420") | 36 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", example = "16420") |
| 45 | private Integer levelId; | 37 | private Integer levelId; |
| 46 | 38 | ||
| 47 | - @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", example = "28220") | ||
| 48 | - private Integer cycleId; | ||
| 49 | - | ||
| 50 | - @Schema(description = "计划次数") | ||
| 51 | - private Integer planNum; | ||
| 52 | - | ||
| 53 | - @Schema(description = "已完成次数") | ||
| 54 | - private Integer planFinishNum; | ||
| 55 | - | ||
| 56 | - @Schema(description = "完成状态 : 1:未完成;2:已完成") | ||
| 57 | - private Integer finishState; | ||
| 58 | - | ||
| 59 | @Schema(description = "开始时间") | 39 | @Schema(description = "开始时间") |
| 60 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 40 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 61 | private LocalDate[] beginTime; | 41 | private LocalDate[] beginTime; |
| @@ -64,17 +44,4 @@ public class MaintainPlanPageReqVO extends PageParam { | @@ -64,17 +44,4 @@ public class MaintainPlanPageReqVO extends PageParam { | ||
| 64 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 44 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 65 | private LocalDate[] endTime; | 45 | private LocalDate[] endTime; |
| 66 | 46 | ||
| 67 | - @Schema(description = "备注", example = "你猜") | ||
| 68 | - private String remark; | ||
| 69 | - | ||
| 70 | - @Schema(description = "创建人", example = "赵六") | ||
| 71 | - private String creatorName; | ||
| 72 | - | ||
| 73 | - @Schema(description = "创建时间") | ||
| 74 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 75 | - private LocalDateTime[] createTime; | ||
| 76 | - | ||
| 77 | - @Schema(description = "更新者", example = "芋艿") | ||
| 78 | - private String updaterName; | ||
| 79 | - | ||
| 80 | } | 47 | } |
| 81 | \ No newline at end of file | 48 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanRespVO.java
| @@ -86,6 +86,10 @@ public class MaintainPlanRespVO { | @@ -86,6 +86,10 @@ public class MaintainPlanRespVO { | ||
| 86 | @ExcelProperty("备注") | 86 | @ExcelProperty("备注") |
| 87 | private String remark; | 87 | private String remark; |
| 88 | 88 | ||
| 89 | + @Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "ZIEITS") | ||
| 90 | + @ExcelProperty("创建人ID") | ||
| 91 | + private String creator; | ||
| 92 | + | ||
| 89 | @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | 93 | @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") |
| 90 | @ExcelProperty("创建人") | 94 | @ExcelProperty("创建人") |
| 91 | private String creatorName; | 95 | private String creatorName; |
| @@ -94,8 +98,5 @@ public class MaintainPlanRespVO { | @@ -94,8 +98,5 @@ public class MaintainPlanRespVO { | ||
| 94 | @ExcelProperty("创建时间") | 98 | @ExcelProperty("创建时间") |
| 95 | private LocalDateTime createTime; | 99 | private LocalDateTime createTime; |
| 96 | 100 | ||
| 97 | - @Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 98 | - @ExcelProperty("更新者") | ||
| 99 | - private String updaterName; | ||
| 100 | 101 | ||
| 101 | } | 102 | } |
| 102 | \ No newline at end of file | 103 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanRoadReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotNull; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - 养护计划汇总新增/修改 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class MaintainPlanRoadReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "部门ID(道路负责部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "16445") | ||
| 12 | + @NotNull(message = "部门ID(道路负责部门id)不能为空") | ||
| 13 | + private Long deptId; | ||
| 14 | + | ||
| 15 | + @Schema(description = "道路ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15557") | ||
| 16 | + @NotNull(message = "道路ID不能为空") | ||
| 17 | + private Long roadId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "道路名称", example = "赵六") | ||
| 20 | + private String roadName; | ||
| 21 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanSaveReqVO.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo; | 1 | package com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo; |
| 2 | 2 | ||
| 3 | +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.InspectionPlanRoadReqVO; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | +import jakarta.validation.Valid; | ||
| 4 | import lombok.*; | 6 | import lombok.*; |
| 5 | 7 | ||
| 6 | import java.time.LocalDate; | 8 | import java.time.LocalDate; |
| @@ -11,16 +13,8 @@ import jakarta.validation.constraints.*; | @@ -11,16 +13,8 @@ import jakarta.validation.constraints.*; | ||
| 11 | @Data | 13 | @Data |
| 12 | public class MaintainPlanSaveReqVO { | 14 | public class MaintainPlanSaveReqVO { |
| 13 | 15 | ||
| 14 | - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2058") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | - @Schema(description = "批次号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 18 | - @NotEmpty(message = "批次号不能为空") | ||
| 19 | - private String batchNo; | ||
| 20 | - | ||
| 21 | - @Schema(description = "计划名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 22 | - @NotEmpty(message = "计划名称不能为空") | ||
| 23 | - private String planName; | 16 | + @Schema(description = "计划名称后缀", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "张三") |
| 17 | + private String planNameSuffix; | ||
| 24 | 18 | ||
| 25 | @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | 19 | @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) |
| 26 | @NotEmpty(message = "业务线: yl-园林;wy-物业:sz-市政不能为空") | 20 | @NotEmpty(message = "业务线: yl-园林;wy-物业:sz-市政不能为空") |
| @@ -53,21 +47,19 @@ public class MaintainPlanSaveReqVO { | @@ -53,21 +47,19 @@ public class MaintainPlanSaveReqVO { | ||
| 53 | @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") | 47 | @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") |
| 54 | private Integer levelId; | 48 | private Integer levelId; |
| 55 | 49 | ||
| 50 | + @Schema(description = "频次值", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 51 | + @NotEmpty(message = "频次值不能为空") | ||
| 52 | + private String rateValue; | ||
| 53 | + | ||
| 56 | @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "28220") | 54 | @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "28220") |
| 57 | @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空") | 55 | @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空") |
| 58 | private Integer cycleId; | 56 | private Integer cycleId; |
| 59 | 57 | ||
| 60 | - @Schema(description = "计划次数", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 61 | - @NotNull(message = "计划次数不能为空") | ||
| 62 | - private Integer planNum; | ||
| 63 | - | ||
| 64 | - @Schema(description = "已完成次数", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 65 | - @NotNull(message = "已完成次数不能为空") | ||
| 66 | - private Integer planFinishNum; | ||
| 67 | - | ||
| 68 | - @Schema(description = "完成状态 : 1:未完成;2:已完成", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 69 | - @NotNull(message = "完成状态 : 1:未完成;2:已完成不能为空") | ||
| 70 | - private Integer finishState; | 58 | + @Schema(description = "道路信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "[{\"deptId\":11,\"roadId\":1,\"roadName\":\"测试\"}]") |
| 59 | + @NotNull | ||
| 60 | + @Size(min = 1) | ||
| 61 | + @Valid | ||
| 62 | + private List<MaintainPlanRoadReqVO> roadListReqVO; | ||
| 71 | 63 | ||
| 72 | @Schema(description = "开始时间") | 64 | @Schema(description = "开始时间") |
| 73 | private LocalDate beginTime; | 65 | private LocalDate beginTime; |
| @@ -79,12 +71,9 @@ public class MaintainPlanSaveReqVO { | @@ -79,12 +71,9 @@ public class MaintainPlanSaveReqVO { | ||
| 79 | @NotEmpty(message = "备注不能为空") | 71 | @NotEmpty(message = "备注不能为空") |
| 80 | private String remark; | 72 | private String remark; |
| 81 | 73 | ||
| 82 | - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 83 | - @NotEmpty(message = "创建人不能为空") | ||
| 84 | - private String creatorName; | ||
| 85 | - | ||
| 86 | - @Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 87 | - @NotEmpty(message = "更新者不能为空") | ||
| 88 | - private String updaterName; | 74 | + @NotNull(message = "角色Ids不能为空") |
| 75 | + @Schema(description = "角色Ids", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2]") | ||
| 76 | + @Size(min = 1) | ||
| 77 | + private Set<Long> roleIds; | ||
| 89 | 78 | ||
| 90 | } | 79 | } |
| 91 | \ No newline at end of file | 80 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/maintainplan/MaintainPlanDetailMapper.java
| @@ -7,6 +7,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | @@ -7,6 +7,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 7 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDetailDO; | 7 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDetailDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; | 9 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; |
| 10 | +import org.apache.ibatis.annotations.Param; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * 养护计划 Mapper | 13 | * 养护计划 Mapper |
| @@ -31,8 +32,9 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail | @@ -31,8 +32,9 @@ public interface MaintainPlanDetailMapper extends BaseMapperX<MaintainPlanDetail | ||
| 31 | .eqIfPresent(MaintainPlanDetailDO::getFinishState, reqVO.getFinishState()) | 32 | .eqIfPresent(MaintainPlanDetailDO::getFinishState, reqVO.getFinishState()) |
| 32 | .likeIfPresent(MaintainPlanDetailDO::getCreatorName, reqVO.getCreatorName()) | 33 | .likeIfPresent(MaintainPlanDetailDO::getCreatorName, reqVO.getCreatorName()) |
| 33 | .betweenIfPresent(MaintainPlanDetailDO::getCreateTime, reqVO.getCreateTime()) | 34 | .betweenIfPresent(MaintainPlanDetailDO::getCreateTime, reqVO.getCreateTime()) |
| 34 | - .likeIfPresent(MaintainPlanDetailDO::getUpdaterName, reqVO.getUpdaterName()) | ||
| 35 | .orderByDesc(MaintainPlanDetailDO::getId)); | 35 | .orderByDesc(MaintainPlanDetailDO::getId)); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | + int deleteByBatchNo(@Param("batchNo") String batchNo); | ||
| 39 | + | ||
| 38 | } | 40 | } |
| 39 | \ No newline at end of file | 41 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/maintainplan/MaintainPlanMapper.java
| @@ -7,6 +7,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | @@ -7,6 +7,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 7 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO; | 7 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; | 9 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; |
| 10 | +import org.apache.ibatis.annotations.Param; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * 养护计划汇总 Mapper | 13 | * 养护计划汇总 Mapper |
| @@ -20,25 +21,16 @@ public interface MaintainPlanMapper extends BaseMapperX<MaintainPlanDO> { | @@ -20,25 +21,16 @@ public interface MaintainPlanMapper extends BaseMapperX<MaintainPlanDO> { | ||
| 20 | return selectPage(reqVO, new LambdaQueryWrapperX<MaintainPlanDO>() | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<MaintainPlanDO>() |
| 21 | .eqIfPresent(MaintainPlanDO::getBatchNo, reqVO.getBatchNo()) | 22 | .eqIfPresent(MaintainPlanDO::getBatchNo, reqVO.getBatchNo()) |
| 22 | .likeIfPresent(MaintainPlanDO::getPlanName, reqVO.getPlanName()) | 23 | .likeIfPresent(MaintainPlanDO::getPlanName, reqVO.getPlanName()) |
| 23 | - .eqIfPresent(MaintainPlanDO::getBusiLine, reqVO.getBusiLine()) | ||
| 24 | .eqIfPresent(MaintainPlanDO::getPlanAttr, reqVO.getPlanAttr()) | 24 | .eqIfPresent(MaintainPlanDO::getPlanAttr, reqVO.getPlanAttr()) |
| 25 | .eqIfPresent(MaintainPlanDO::getPlanTypeId, reqVO.getPlanTypeId()) | 25 | .eqIfPresent(MaintainPlanDO::getPlanTypeId, reqVO.getPlanTypeId()) |
| 26 | .eqIfPresent(MaintainPlanDO::getCompanyId, reqVO.getCompanyId()) | 26 | .eqIfPresent(MaintainPlanDO::getCompanyId, reqVO.getCompanyId()) |
| 27 | - .eqIfPresent(MaintainPlanDO::getDeptId, reqVO.getDeptId()) | ||
| 28 | - .eqIfPresent(MaintainPlanDO::getRoadId, reqVO.getRoadId()) | ||
| 29 | .likeIfPresent(MaintainPlanDO::getRoadName, reqVO.getRoadName()) | 27 | .likeIfPresent(MaintainPlanDO::getRoadName, reqVO.getRoadName()) |
| 30 | .eqIfPresent(MaintainPlanDO::getLevelId, reqVO.getLevelId()) | 28 | .eqIfPresent(MaintainPlanDO::getLevelId, reqVO.getLevelId()) |
| 31 | - .eqIfPresent(MaintainPlanDO::getCycleId, reqVO.getCycleId()) | ||
| 32 | - .eqIfPresent(MaintainPlanDO::getPlanNum, reqVO.getPlanNum()) | ||
| 33 | - .eqIfPresent(MaintainPlanDO::getPlanFinishNum, reqVO.getPlanFinishNum()) | ||
| 34 | - .eqIfPresent(MaintainPlanDO::getFinishState, reqVO.getFinishState()) | ||
| 35 | .betweenIfPresent(MaintainPlanDO::getBeginTime, reqVO.getBeginTime()) | 29 | .betweenIfPresent(MaintainPlanDO::getBeginTime, reqVO.getBeginTime()) |
| 36 | .betweenIfPresent(MaintainPlanDO::getEndTime, reqVO.getEndTime()) | 30 | .betweenIfPresent(MaintainPlanDO::getEndTime, reqVO.getEndTime()) |
| 37 | - .eqIfPresent(MaintainPlanDO::getRemark, reqVO.getRemark()) | ||
| 38 | - .likeIfPresent(MaintainPlanDO::getCreatorName, reqVO.getCreatorName()) | ||
| 39 | - .betweenIfPresent(MaintainPlanDO::getCreateTime, reqVO.getCreateTime()) | ||
| 40 | - .likeIfPresent(MaintainPlanDO::getUpdaterName, reqVO.getUpdaterName()) | ||
| 41 | .orderByDesc(MaintainPlanDO::getId)); | 31 | .orderByDesc(MaintainPlanDO::getId)); |
| 42 | } | 32 | } |
| 43 | 33 | ||
| 34 | + int deleteByBatchNo(@Param("batchNo") String batchNo); | ||
| 35 | + | ||
| 44 | } | 36 | } |
| 45 | \ No newline at end of file | 37 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/maintainplan/MaintainPlanRoleMapper.java
| @@ -8,6 +8,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | @@ -8,6 +8,7 @@ import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanRoleDO; | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanRoleDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; | 10 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; |
| 11 | +import org.apache.ibatis.annotations.Param; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * 养护计划角色 Mapper | 14 | * 养护计划角色 Mapper |
| @@ -28,4 +29,5 @@ public interface MaintainPlanRoleMapper extends BaseMapperX<MaintainPlanRoleDO> | @@ -28,4 +29,5 @@ public interface MaintainPlanRoleMapper extends BaseMapperX<MaintainPlanRoleDO> | ||
| 28 | .orderByDesc(MaintainPlanRoleDO::getId)); | 29 | .orderByDesc(MaintainPlanRoleDO::getId)); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 32 | + int deleteByBatchNo(@Param("batchNo") String batchNo); | ||
| 31 | } | 33 | } |
| 32 | \ No newline at end of file | 34 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
| @@ -59,12 +59,15 @@ public interface ErrorCodeConstants { | @@ -59,12 +59,15 @@ public interface ErrorCodeConstants { | ||
| 59 | ErrorCode WATER_FEE_NOT_EXISTS = new ErrorCode(1-100-003-013, "水费录入信息不存在"); | 59 | ErrorCode WATER_FEE_NOT_EXISTS = new ErrorCode(1-100-003-013, "水费录入信息不存在"); |
| 60 | 60 | ||
| 61 | // ========== 巡检计划汇总 TODO 补充编号 ========== | 61 | // ========== 巡检计划汇总 TODO 补充编号 ========== |
| 62 | - ErrorCode INSPECTION_PLAN_NOT_EXISTS = new ErrorCode(1-200-100-001, "巡检计划汇总不存在"); | ||
| 63 | - ErrorCode INSPECTION_CYCLE_ID_ERROR = new ErrorCode(1-200-100-002, "周期id错误"); | 62 | + ErrorCode INSPECTION_PLAN_NOT_EXISTS = new ErrorCode(1-100-100-001, "巡检计划汇总不存在"); |
| 63 | + ErrorCode INSPECTION_CYCLE_ID_ERROR = new ErrorCode(1-100-100-002, "周期id错误"); | ||
| 64 | ErrorCode INSPECTION_CYCLE_ERROR = new ErrorCode(1-200-100-003, "获取两个时间之间间隔天数错误"); | 64 | ErrorCode INSPECTION_CYCLE_ERROR = new ErrorCode(1-200-100-003, "获取两个时间之间间隔天数错误"); |
| 65 | ErrorCode INSPECTION_PLAN_EXISTS = new ErrorCode(1-200-100-004, "道路对应类型已存在记录"); | 65 | ErrorCode INSPECTION_PLAN_EXISTS = new ErrorCode(1-200-100-004, "道路对应类型已存在记录"); |
| 66 | ErrorCode INSPECTION_PLAN_NOT_ALLOW_DELETE = new ErrorCode(1-200-100-005, "计划已开始执行不能删除"); | 66 | ErrorCode INSPECTION_PLAN_NOT_ALLOW_DELETE = new ErrorCode(1-200-100-005, "计划已开始执行不能删除"); |
| 67 | 67 | ||
| 68 | + // ========== 养护计划汇总 TODO 补充编号 ========== | ||
| 69 | + ErrorCode MAINTAIN_PLAN_NOT_EXISTS = new ErrorCode(1-200-200-001, "养护计划汇总不存在"); | ||
| 70 | + | ||
| 68 | //========== 频次 TODO 补充编号 ========== | 71 | //========== 频次 TODO 补充编号 ========== |
| 69 | ErrorCode PLAN_RATE_EXISTS = new ErrorCode(1-200-200-001, "养护频次已存在"); | 72 | ErrorCode PLAN_RATE_EXISTS = new ErrorCode(1-200-200-001, "养护频次已存在"); |
| 70 | ErrorCode PLAN_RATE_LEVEL_ID_DUPLICATE = new ErrorCode(1-200-200-002, "养护等级重复"); | 73 | ErrorCode PLAN_RATE_LEVEL_ID_DUPLICATE = new ErrorCode(1-200-200-002, "养护等级重复"); |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanService.java
| 1 | package com.zteits.urbanops.module.garden.service.maintainplan; | 1 | package com.zteits.urbanops.module.garden.service.maintainplan; |
| 2 | 2 | ||
| 3 | import java.util.*; | 3 | import java.util.*; |
| 4 | + | ||
| 5 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 4 | import jakarta.validation.*; | 6 | import jakarta.validation.*; |
| 5 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; | 7 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; |
| 6 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO; | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO; |
| @@ -20,7 +22,7 @@ public interface MaintainPlanService { | @@ -20,7 +22,7 @@ public interface MaintainPlanService { | ||
| 20 | * @param createReqVO 创建信息 | 22 | * @param createReqVO 创建信息 |
| 21 | * @return 编号 | 23 | * @return 编号 |
| 22 | */ | 24 | */ |
| 23 | - Long createMaintainPlan(@Valid MaintainPlanSaveReqVO createReqVO); | 25 | + CommonResult<Long> createMaintainPlan(@Valid MaintainPlanSaveReqVO createReqVO); |
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 26 | * 更新养护计划汇总 | 28 | * 更新养护计划汇总 |
| @@ -59,4 +61,15 @@ public interface MaintainPlanService { | @@ -59,4 +61,15 @@ public interface MaintainPlanService { | ||
| 59 | */ | 61 | */ |
| 60 | PageResult<MaintainPlanDO> getMaintainPlanPage(MaintainPlanPageReqVO pageReqVO); | 62 | PageResult<MaintainPlanDO> getMaintainPlanPage(MaintainPlanPageReqVO pageReqVO); |
| 61 | 63 | ||
| 64 | + /** | ||
| 65 | + * 根据批次号删除 | ||
| 66 | + * @param batchNo 批次号 | ||
| 67 | + */ | ||
| 68 | + void deleteInspectionPlanByBatchNo(String batchNo); | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 终止计划 | ||
| 72 | + * @param batchNo | ||
| 73 | + */ | ||
| 74 | + void stopPlanInspectionPlan(String batchNo); | ||
| 62 | } | 75 | } |
| 63 | \ No newline at end of file | 76 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanServiceImpl.java
| 1 | package com.zteits.urbanops.module.garden.service.maintainplan; | 1 | package com.zteits.urbanops.module.garden.service.maintainplan; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.date.DateUtil; | ||
| 5 | +import cn.hutool.core.util.RandomUtil; | ||
| 6 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 7 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 8 | +import com.zteits.urbanops.framework.common.util.collection.CollectionUtils; | ||
| 9 | +import com.zteits.urbanops.framework.dict.core.DictFrameworkUtils; | ||
| 10 | +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; | ||
| 11 | +import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDetailDO; | ||
| 12 | +import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanRoleDO; | ||
| 13 | +import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanDetailMapper; | ||
| 14 | +import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanRoleMapper; | ||
| 15 | +import com.zteits.urbanops.module.garden.enums.FinishStateEnum; | ||
| 16 | +import com.zteits.urbanops.module.garden.enums.PlanConstants; | ||
| 17 | +import com.zteits.urbanops.module.garden.util.TimeIntervalCalculatorUtil; | ||
| 18 | +import lombok.extern.slf4j.Slf4j; | ||
| 4 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 5 | import jakarta.annotation.Resource; | 20 | import jakarta.annotation.Resource; |
| 6 | import org.springframework.validation.annotation.Validated; | 21 | import org.springframework.validation.annotation.Validated; |
| 7 | -import org.springframework.transaction.annotation.Transactional; | ||
| 8 | 22 | ||
| 23 | +import java.time.LocalDate; | ||
| 24 | +import java.time.LocalDateTime; | ||
| 25 | +import java.time.format.DateTimeFormatter; | ||
| 9 | import java.util.*; | 26 | import java.util.*; |
| 27 | +import java.util.concurrent.atomic.AtomicInteger; | ||
| 28 | +import java.util.stream.Collectors; | ||
| 29 | + | ||
| 10 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; | 30 | import com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.*; |
| 11 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO; | 31 | import com.zteits.urbanops.module.garden.dal.dataobject.maintainplan.MaintainPlanDO; |
| 12 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 32 | 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; | 33 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 15 | 34 | ||
| 16 | import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanMapper; | 35 | import com.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanMapper; |
| 17 | 36 | ||
| 18 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | 37 | 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 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | 38 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; |
| 22 | 39 | ||
| 23 | /** | 40 | /** |
| @@ -27,25 +44,118 @@ import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | @@ -27,25 +44,118 @@ import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | ||
| 27 | */ | 44 | */ |
| 28 | @Service | 45 | @Service |
| 29 | @Validated | 46 | @Validated |
| 47 | +@Slf4j | ||
| 30 | public class MaintainPlanServiceImpl implements MaintainPlanService { | 48 | public class MaintainPlanServiceImpl implements MaintainPlanService { |
| 31 | 49 | ||
| 32 | @Resource | 50 | @Resource |
| 33 | private MaintainPlanMapper maintainPlanMapper; | 51 | private MaintainPlanMapper maintainPlanMapper; |
| 34 | 52 | ||
| 53 | + | ||
| 54 | + @Resource | ||
| 55 | + private MaintainPlanDetailMapper maintainPlanDetailMapper; | ||
| 56 | + | ||
| 57 | + @Resource | ||
| 58 | + private MaintainPlanRoleMapper maintainPlanRoleMapper; | ||
| 59 | + | ||
| 35 | @Override | 60 | @Override |
| 36 | - public Long createMaintainPlan(MaintainPlanSaveReqVO createReqVO) { | ||
| 37 | - // 插入 | ||
| 38 | - MaintainPlanDO maintainPlan = BeanUtils.toBean(createReqVO, MaintainPlanDO.class); | ||
| 39 | - maintainPlanMapper.insert(maintainPlan); | 61 | + public CommonResult<Long> createMaintainPlan(MaintainPlanSaveReqVO createReqVO) { |
| 62 | + //存在性校验 | ||
| 63 | + validateMaintainPlanExists(createReqVO); | ||
| 64 | + LocalDateTime now = LocalDateTime.now(); | ||
| 65 | + String userId = SecurityFrameworkUtils.getLoginUserId()+""; | ||
| 66 | + String userName = SecurityFrameworkUtils.getLoginUserNickname(); | ||
| 67 | + int rateValue; | ||
| 68 | + if (createReqVO.getRateValue().contains("/")) { | ||
| 69 | + rateValue = Integer.parseInt(createReqVO.getRateValue().split("/")[1]); | ||
| 70 | + } else { | ||
| 71 | + rateValue = Integer.parseInt(createReqVO.getRateValue()); | ||
| 72 | + } | ||
| 73 | + //计算开始和计算时间 在间隔周期下每天的次数 | ||
| 74 | + List<String> betweenDayList = TimeIntervalCalculatorUtil.calculateIntervals(createReqVO.getBeginTime(), createReqVO.getEndTime(), createReqVO.getCycleId(), rateValue); | ||
| 75 | + if (CollectionUtils.isAnyEmpty(betweenDayList)) { | ||
| 76 | + log.warn("获取两个时间之间间隔天数错误"); | ||
| 77 | + return CommonResult.error(INSPECTION_CYCLE_ERROR); | ||
| 78 | + } | ||
| 79 | + //计算计划次数 | ||
| 80 | + Integer planNum = betweenDayList.size(); | ||
| 81 | + MaintainPlanDO maintainPlanDO = BeanUtils.toBean(createReqVO, MaintainPlanDO.class); | ||
| 82 | + AtomicInteger count = new AtomicInteger(); | ||
| 83 | + | ||
| 84 | + //按照道路创建计划 | ||
| 85 | + createReqVO.getRoadListReqVO().forEach(roadReqVO -> { | ||
| 86 | + String batchNo = "BN" + DateUtil.format(new Date(), "yyyyMMddHHmmssSSS") + RandomUtil.randomInt(1000); | ||
| 87 | + maintainPlanDO.setBatchNo(batchNo); | ||
| 88 | + maintainPlanDO.setPlanFinishNum(0); | ||
| 89 | + maintainPlanDO.setFinishState(FinishStateEnum.NOT_FINISHED.getStatus()); | ||
| 90 | + maintainPlanDO.setPlanNum(planNum); | ||
| 91 | + maintainPlanDO.setCreateTime(now); | ||
| 92 | + maintainPlanDO.setUpdateTime(now); | ||
| 93 | + maintainPlanDO.setCreator(userId); | ||
| 94 | + maintainPlanDO.setCreatorName(userName); | ||
| 95 | + maintainPlanDO.setUpdater(userId); | ||
| 96 | + maintainPlanDO.setUpdaterName(userName); | ||
| 97 | + maintainPlanDO.setDeptId(roadReqVO.getDeptId()); | ||
| 98 | + maintainPlanDO.setRoadId(roadReqVO.getRoadId()); | ||
| 99 | + maintainPlanDO.setRoadName(roadReqVO.getRoadName()); | ||
| 100 | + //计划属性label | ||
| 101 | + String planAttrLabel = DictFrameworkUtils.parseDictDataLabel(PlanConstants.GARDEN_PLAN_ATTR_REDIS_KEY, createReqVO.getPlanAttr()); | ||
| 102 | + maintainPlanDO.setPlanName(roadReqVO.getRoadName() + planAttrLabel + createReqVO.getPlanNameSuffix()); | ||
| 103 | + /*1.插入巡查计划*/ | ||
| 104 | + count.addAndGet(maintainPlanMapper.insert(maintainPlanDO)); | ||
| 105 | + /*2.插入角色*/ | ||
| 106 | + createReqVO.getRoleIds().forEach(roleId -> { | ||
| 107 | + MaintainPlanRoleDO maintainPlanRoleDO = new MaintainPlanRoleDO(); | ||
| 108 | + maintainPlanRoleDO.setBatchNo(batchNo); | ||
| 109 | + maintainPlanRoleDO.setCompanyId(createReqVO.getCompanyId()); | ||
| 110 | + maintainPlanRoleDO.setDeptId(roadReqVO.getDeptId()); | ||
| 111 | + maintainPlanRoleDO.setCreateTime(now); | ||
| 112 | + maintainPlanRoleDO.setUpdateTime(now); | ||
| 113 | + maintainPlanRoleDO.setCreator(userId); | ||
| 114 | + maintainPlanRoleDO.setUpdater(userId); | ||
| 115 | + maintainPlanRoleDO.setRoleId(roleId); | ||
| 116 | + maintainPlanRoleMapper.insert(maintainPlanRoleDO); | ||
| 117 | + }); | ||
| 118 | + /*3.插入巡查计划明细*/ | ||
| 119 | + for (int i = 0; i < betweenDayList.size(); i++) { | ||
| 120 | + String[] dateStr = betweenDayList.get(i).split("/"); | ||
| 121 | + MaintainPlanDetailDO entity = getMaintainPlanDetailDO(batchNo, createReqVO, roadReqVO, now); | ||
| 122 | + entity.setSortNum(i+1); | ||
| 123 | + entity.setBeginTime(LocalDate.parse(dateStr[0], DateTimeFormatter.ofPattern("yyyy-MM-dd"))); | ||
| 124 | + entity.setEndTime(LocalDate.parse(dateStr[1], DateTimeFormatter.ofPattern("yyyy-MM-dd"))); | ||
| 125 | + | ||
| 126 | + maintainPlanDetailMapper.insert(entity); | ||
| 127 | + } | ||
| 128 | + }); | ||
| 40 | 129 | ||
| 41 | // 返回 | 130 | // 返回 |
| 42 | - return maintainPlan.getId(); | 131 | + return CommonResult.success(count.longValue()); |
| 132 | + } | ||
| 133 | + | ||
| 134 | + private MaintainPlanDetailDO getMaintainPlanDetailDO(String batchNo, MaintainPlanSaveReqVO saveReqVO, | ||
| 135 | + MaintainPlanRoadReqVO roadReqVO, LocalDateTime now) { | ||
| 136 | + String userId = SecurityFrameworkUtils.getLoginUserId()+""; | ||
| 137 | + String userName = SecurityFrameworkUtils.getLoginUserNickname(); | ||
| 138 | + MaintainPlanDetailDO entity = new MaintainPlanDetailDO(); | ||
| 139 | + entity.setBatchNo(batchNo); | ||
| 140 | + entity.setPlanNo("Y" + DateUtil.format(new Date(), "yyyyMMddHHmmssSSS") + RandomUtil.randomInt(1000)); | ||
| 141 | + entity.setBusiLine(saveReqVO.getBusiLine()); | ||
| 142 | + entity.setCompanyId(saveReqVO.getCompanyId()); | ||
| 143 | + entity.setDeptId(roadReqVO.getDeptId()); | ||
| 144 | + entity.setRoadId(roadReqVO.getRoadId()); | ||
| 145 | + entity.setFinishState(FinishStateEnum.NOT_FINISHED.getStatus()); | ||
| 146 | + entity.setCreator(userId); | ||
| 147 | + entity.setCreatorName(userName); | ||
| 148 | + entity.setUpdater(userId); | ||
| 149 | + entity.setUpdaterName(userName); | ||
| 150 | + entity.setCreateTime(now); | ||
| 151 | + entity.setUpdateTime(now); | ||
| 152 | + return entity; | ||
| 43 | } | 153 | } |
| 44 | 154 | ||
| 45 | @Override | 155 | @Override |
| 46 | public void updateMaintainPlan(MaintainPlanSaveReqVO updateReqVO) { | 156 | public void updateMaintainPlan(MaintainPlanSaveReqVO updateReqVO) { |
| 47 | // 校验存在 | 157 | // 校验存在 |
| 48 | - validateMaintainPlanExists(updateReqVO.getId()); | 158 | + //validateMaintainPlanExists(updateReqVO.getId()); |
| 49 | // 更新 | 159 | // 更新 |
| 50 | MaintainPlanDO updateObj = BeanUtils.toBean(updateReqVO, MaintainPlanDO.class); | 160 | MaintainPlanDO updateObj = BeanUtils.toBean(updateReqVO, MaintainPlanDO.class); |
| 51 | maintainPlanMapper.updateById(updateObj); | 161 | maintainPlanMapper.updateById(updateObj); |
| @@ -54,7 +164,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -54,7 +164,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 54 | @Override | 164 | @Override |
| 55 | public void deleteMaintainPlan(Long id) { | 165 | public void deleteMaintainPlan(Long id) { |
| 56 | // 校验存在 | 166 | // 校验存在 |
| 57 | - validateMaintainPlanExists(id); | 167 | + //validateMaintainPlanExists(id); |
| 58 | // 删除 | 168 | // 删除 |
| 59 | maintainPlanMapper.deleteById(id); | 169 | maintainPlanMapper.deleteById(id); |
| 60 | } | 170 | } |
| @@ -66,9 +176,31 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -66,9 +176,31 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 66 | } | 176 | } |
| 67 | 177 | ||
| 68 | 178 | ||
| 69 | - private void validateMaintainPlanExists(Long id) { | ||
| 70 | - if (maintainPlanMapper.selectById(id) == null) { | ||
| 71 | - // throw exception(MAINTAIN_PLAN_NOT_EXISTS); | 179 | + private void validateMaintainPlanExists(MaintainPlanSaveReqVO req) { |
| 180 | + Set<Long> roadIds = req.getRoadListReqVO().stream().map(MaintainPlanRoadReqVO::getRoadId).collect(Collectors.toSet()); | ||
| 181 | + Long count =0L; | ||
| 182 | + //标准计划 | ||
| 183 | + if(req.getPlanAttr().equals(1)){ | ||
| 184 | + QueryWrapper<MaintainPlanDO> sql = new QueryWrapper<>(); | ||
| 185 | + sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId()) | ||
| 186 | + .in(MaintainPlanDO::getRoadId, roadIds) | ||
| 187 | + .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime | ||
| 188 | + .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | ||
| 189 | + | ||
| 190 | + count = maintainPlanMapper.selectCount(sql); | ||
| 191 | + }else{ | ||
| 192 | + QueryWrapper<MaintainPlanDO> sql = new QueryWrapper<>(); | ||
| 193 | + sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId()) | ||
| 194 | + .in(MaintainPlanDO::getRoadId, roadIds) | ||
| 195 | + .eq(MaintainPlanDO::getDeleted, 0) | ||
| 196 | + .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime | ||
| 197 | + .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | ||
| 198 | + | ||
| 199 | + count = maintainPlanMapper.selectCount(sql); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + if (count > 0) { | ||
| 203 | + throw exception(INSPECTION_PLAN_EXISTS); | ||
| 72 | } | 204 | } |
| 73 | } | 205 | } |
| 74 | 206 | ||
| @@ -82,4 +214,22 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -82,4 +214,22 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 82 | return maintainPlanMapper.selectPage(pageReqVO); | 214 | return maintainPlanMapper.selectPage(pageReqVO); |
| 83 | } | 215 | } |
| 84 | 216 | ||
| 217 | + @Override | ||
| 218 | + public void deleteInspectionPlanByBatchNo(String batchNo) { | ||
| 219 | + MaintainPlanDO inspectionPlanDO = maintainPlanMapper.selectOne(MaintainPlanDO::getBatchNo, batchNo); | ||
| 220 | + if(inspectionPlanDO !=null && inspectionPlanDO.getPlanFinishNum() >0){ | ||
| 221 | + throw exception(INSPECTION_PLAN_NOT_ALLOW_DELETE); | ||
| 222 | + } | ||
| 223 | + maintainPlanMapper.deleteByBatchNo(batchNo); | ||
| 224 | + maintainPlanDetailMapper.deleteByBatchNo(batchNo); | ||
| 225 | + maintainPlanRoleMapper.deleteByBatchNo(batchNo); | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + @Override | ||
| 229 | + public void stopPlanInspectionPlan(String batchNo) { | ||
| 230 | + maintainPlanMapper.delete(MaintainPlanDO::getBatchNo, batchNo); | ||
| 231 | + maintainPlanDetailMapper.delete(MaintainPlanDetailDO::getBatchNo,batchNo); | ||
| 232 | + maintainPlanRoleMapper.delete(MaintainPlanRoleDO::getBatchNo, batchNo); | ||
| 233 | + } | ||
| 234 | + | ||
| 85 | } | 235 | } |
| 86 | \ No newline at end of file | 236 | \ No newline at end of file |
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanDetailMapper.xml
| @@ -9,4 +9,7 @@ | @@ -9,4 +9,7 @@ | ||
| 9 | 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | 9 | 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
| 10 | --> | 10 | --> |
| 11 | 11 | ||
| 12 | + <delete id="deleteByBatchNo"> | ||
| 13 | + delete from garden_maintain_plan_detail where batch_no =#{batchNo} | ||
| 14 | + </delete> | ||
| 12 | </mapper> | 15 | </mapper> |
| 13 | \ No newline at end of file | 16 | \ No newline at end of file |
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanMapper.xml
| @@ -8,5 +8,7 @@ | @@ -8,5 +8,7 @@ | ||
| 8 | 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | 8 | 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
| 9 | 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | 9 | 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
| 10 | --> | 10 | --> |
| 11 | - | 11 | + <delete id="deleteByBatchNo"> |
| 12 | + delete from garden_maintain_plan where batch_no =#{batchNo} | ||
| 13 | + </delete> | ||
| 12 | </mapper> | 14 | </mapper> |
| 13 | \ No newline at end of file | 15 | \ No newline at end of file |
urbanops-module-garden/src/main/resources/mapper/maintainplan/MaintainPlanRoleMapper.xml
| @@ -8,5 +8,7 @@ | @@ -8,5 +8,7 @@ | ||
| 8 | 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | 8 | 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
| 9 | 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | 9 | 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
| 10 | --> | 10 | --> |
| 11 | - | 11 | + <delete id="deleteByBatchNo"> |
| 12 | + delete from garden_maintain_plan_role where batch_no =#{batchNo} | ||
| 13 | + </delete> | ||
| 12 | </mapper> | 14 | </mapper> |
| 13 | \ No newline at end of file | 15 | \ No newline at end of file |