Commit da6374235f8282b8c03a977afa43ec4c8fedc656
1 parent
a096527a
巡查计划-初始值提交
Showing
15 changed files
with
928 additions
and
0 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/InspectionPlanController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.inspectionplan; | |
| 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.*; | |
| 12 | +import jakarta.servlet.http.*; | |
| 13 | +import java.util.*; | |
| 14 | +import java.io.IOException; | |
| 15 | + | |
| 16 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | |
| 17 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 18 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 19 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | |
| 20 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | |
| 21 | + | |
| 22 | +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | |
| 23 | + | |
| 24 | +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | |
| 25 | +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*; | |
| 26 | + | |
| 27 | +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*; | |
| 28 | +import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO; | |
| 29 | +import com.zteits.urbanops.module.garden.service.inspectionplan.InspectionPlanService; | |
| 30 | + | |
| 31 | +@Tag(name = "管理后台 - 巡检计划汇总") | |
| 32 | +@RestController | |
| 33 | +@RequestMapping("/garden/inspection-plan") | |
| 34 | +@Validated | |
| 35 | +public class InspectionPlanController { | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private InspectionPlanService inspectionPlanService; | |
| 39 | + | |
| 40 | + @PostMapping("/create") | |
| 41 | + @Operation(summary = "创建巡检计划汇总") | |
| 42 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:create')") | |
| 43 | + public CommonResult<Long> createInspectionPlan(@Valid @RequestBody InspectionPlanSaveReqVO createReqVO) { | |
| 44 | + return success(inspectionPlanService.createInspectionPlan(createReqVO)); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @PutMapping("/update") | |
| 48 | + @Operation(summary = "更新巡检计划汇总") | |
| 49 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:update')") | |
| 50 | + public CommonResult<Boolean> updateInspectionPlan(@Valid @RequestBody InspectionPlanUpdateReqVO updateReqVO) { | |
| 51 | + inspectionPlanService.updateInspectionPlan(updateReqVO); | |
| 52 | + return success(true); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @DeleteMapping("/delete") | |
| 56 | + @Operation(summary = "删除巡检计划汇总") | |
| 57 | + @Parameter(name = "id", description = "编号", required = true) | |
| 58 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:delete')") | |
| 59 | + public CommonResult<Boolean> deleteInspectionPlan(@RequestParam("id") Long id) { | |
| 60 | + inspectionPlanService.deleteInspectionPlan(id); | |
| 61 | + return success(true); | |
| 62 | + } | |
| 63 | + | |
| 64 | + @DeleteMapping("/delete-list") | |
| 65 | + @Parameter(name = "ids", description = "编号", required = true) | |
| 66 | + @Operation(summary = "批量删除巡检计划汇总") | |
| 67 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:delete')") | |
| 68 | + public CommonResult<Boolean> deleteInspectionPlanList(@RequestParam("ids") List<Long> ids) { | |
| 69 | + inspectionPlanService.deleteInspectionPlanListByIds(ids); | |
| 70 | + return success(true); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @GetMapping("/get") | |
| 74 | + @Operation(summary = "获得巡检计划汇总") | |
| 75 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 76 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:query')") | |
| 77 | + public CommonResult<InspectionPlanRespVO> getInspectionPlan(@RequestParam("id") Long id) { | |
| 78 | + InspectionPlanDO inspectionPlan = inspectionPlanService.getInspectionPlan(id); | |
| 79 | + return success(BeanUtils.toBean(inspectionPlan, InspectionPlanRespVO.class)); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @GetMapping("/page") | |
| 83 | + @Operation(summary = "获得巡检计划汇总分页") | |
| 84 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:query')") | |
| 85 | + public CommonResult<PageResult<InspectionPlanRespVO>> getInspectionPlanPage(@Valid InspectionPlanPageReqVO pageReqVO) { | |
| 86 | + PageResult<InspectionPlanDO> pageResult = inspectionPlanService.getInspectionPlanPage(pageReqVO); | |
| 87 | + return success(BeanUtils.toBean(pageResult, InspectionPlanRespVO.class)); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @GetMapping("/export-excel") | |
| 91 | + @Operation(summary = "导出巡检计划汇总 Excel") | |
| 92 | + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:export')") | |
| 93 | + @ApiAccessLog(operateType = EXPORT) | |
| 94 | + public void exportInspectionPlanExcel(@Valid InspectionPlanPageReqVO pageReqVO, | |
| 95 | + HttpServletResponse response) throws IOException { | |
| 96 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 97 | + List<InspectionPlanDO> list = inspectionPlanService.getInspectionPlanPage(pageReqVO).getList(); | |
| 98 | + // 导出 Excel | |
| 99 | + ExcelUtils.write(response, "巡检计划汇总.xls", "数据", InspectionPlanRespVO.class, | |
| 100 | + BeanUtils.toBean(list, InspectionPlanRespVO.class)); | |
| 101 | + } | |
| 102 | + | |
| 103 | +} | |
| 0 | 104 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanPageReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | |
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 巡检计划汇总分页 Request VO") | |
| 12 | +@Data | |
| 13 | +public class InspectionPlanPageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "批次号") | |
| 16 | + private String batchNo; | |
| 17 | + | |
| 18 | + @Schema(description = "计划名称", example = "张三") | |
| 19 | + private String planName; | |
| 20 | + | |
| 21 | + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政") | |
| 22 | + private String busiLine; | |
| 23 | + | |
| 24 | + @Schema(description = "计划属性:1:标准计划;2:临时计划") | |
| 25 | + private Integer planAttr; | |
| 26 | + | |
| 27 | + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", example = "24742") | |
| 28 | + private Integer planTypeId; | |
| 29 | + | |
| 30 | + @Schema(description = "归属(一级部门id)", example = "20800") | |
| 31 | + private Long companyId; | |
| 32 | + | |
| 33 | + @Schema(description = "部门ID(道路负责部门id)", example = "16445") | |
| 34 | + private Long deptId; | |
| 35 | + | |
| 36 | + @Schema(description = "道路ID", example = "15557") | |
| 37 | + private Long roadId; | |
| 38 | + | |
| 39 | + @Schema(description = "道路名称", example = "赵六") | |
| 40 | + private String roadName; | |
| 41 | + | |
| 42 | + @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", example = "8588") | |
| 43 | + private Integer levelId; | |
| 44 | + | |
| 45 | + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", example = "6415") | |
| 46 | + private Integer cycleId; | |
| 47 | + | |
| 48 | + @Schema(description = "计划次数") | |
| 49 | + private Integer planNum; | |
| 50 | + | |
| 51 | + @Schema(description = "已完成次数") | |
| 52 | + private Integer planFinishNum; | |
| 53 | + | |
| 54 | + @Schema(description = "完成状态 1:未完成;2:已完成") | |
| 55 | + private Integer finishState; | |
| 56 | + | |
| 57 | + @Schema(description = "开始时间") | |
| 58 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 59 | + private LocalDateTime[] beginTime; | |
| 60 | + | |
| 61 | + @Schema(description = "开始时间") | |
| 62 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 63 | + private LocalDateTime[] endTime; | |
| 64 | + | |
| 65 | + @Schema(description = "备注", example = "你说的对") | |
| 66 | + private String remark; | |
| 67 | + | |
| 68 | + @Schema(description = "创建时间") | |
| 69 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 70 | + private LocalDateTime[] createTime; | |
| 71 | + | |
| 72 | +} | |
| 0 | 73 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | +import cn.idev.excel.annotation.*; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 巡检计划汇总 Response VO") | |
| 9 | +@Data | |
| 10 | +@ExcelIgnoreUnannotated | |
| 11 | +public class InspectionPlanRespVO { | |
| 12 | + | |
| 13 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10938") | |
| 14 | + @ExcelProperty("ID") | |
| 15 | + private Long id; | |
| 16 | + | |
| 17 | + @Schema(description = "批次号", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 18 | + @ExcelProperty("批次号") | |
| 19 | + private String batchNo; | |
| 20 | + | |
| 21 | + @Schema(description = "计划名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") | |
| 22 | + @ExcelProperty("计划名称") | |
| 23 | + private String planName; | |
| 24 | + | |
| 25 | + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 26 | + @ExcelProperty("业务线: yl-园林;wy-物业:sz-市政") | |
| 27 | + private String busiLine; | |
| 28 | + | |
| 29 | + @Schema(description = "计划属性:1:标准计划;2:临时计划", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 30 | + @ExcelProperty("计划属性:1:标准计划;2:临时计划") | |
| 31 | + private Integer planAttr; | |
| 32 | + | |
| 33 | + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "24742") | |
| 34 | + @ExcelProperty("养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;") | |
| 35 | + private Integer planTypeId; | |
| 36 | + | |
| 37 | + @Schema(description = "归属(一级部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "20800") | |
| 38 | + @ExcelProperty("归属(一级部门id)") | |
| 39 | + private Long companyId; | |
| 40 | + | |
| 41 | + @Schema(description = "部门ID(道路负责部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "16445") | |
| 42 | + @ExcelProperty("部门ID(道路负责部门id)") | |
| 43 | + private Long deptId; | |
| 44 | + | |
| 45 | + @Schema(description = "道路ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15557") | |
| 46 | + @ExcelProperty("道路ID") | |
| 47 | + private Long roadId; | |
| 48 | + | |
| 49 | + @Schema(description = "道路名称", example = "赵六") | |
| 50 | + @ExcelProperty("道路名称") | |
| 51 | + private String roadName; | |
| 52 | + | |
| 53 | + @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "8588") | |
| 54 | + @ExcelProperty("养护级别: 10:特级;11:一级:12:二级;13:三级") | |
| 55 | + private Integer levelId; | |
| 56 | + | |
| 57 | + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "6415") | |
| 58 | + @ExcelProperty("周期ID: 1:日/次;2:周/次;3:月/次;4:年/次") | |
| 59 | + private Integer cycleId; | |
| 60 | + | |
| 61 | + @Schema(description = "计划次数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 62 | + @ExcelProperty("计划次数") | |
| 63 | + private Integer planNum; | |
| 64 | + | |
| 65 | + @Schema(description = "已完成次数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 66 | + @ExcelProperty("已完成次数") | |
| 67 | + private Integer planFinishNum; | |
| 68 | + | |
| 69 | + @Schema(description = "完成状态 1:未完成;2:已完成", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 70 | + @ExcelProperty("完成状态 1:未完成;2:已完成") | |
| 71 | + private Integer finishState; | |
| 72 | + | |
| 73 | + @Schema(description = "开始时间") | |
| 74 | + @ExcelProperty("开始时间") | |
| 75 | + private LocalDateTime beginTime; | |
| 76 | + | |
| 77 | + @Schema(description = "开始时间") | |
| 78 | + @ExcelProperty("开始时间") | |
| 79 | + private LocalDateTime endTime; | |
| 80 | + | |
| 81 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") | |
| 82 | + @ExcelProperty("备注") | |
| 83 | + private String remark; | |
| 84 | + | |
| 85 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 86 | + @ExcelProperty("创建时间") | |
| 87 | + private LocalDateTime createTime; | |
| 88 | + | |
| 89 | +} | |
| 0 | 90 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanRoadReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.inspectionplan.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 InspectionPlanRoadReqVO { | |
| 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/inspectionplan/vo/InspectionPlanSaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.Valid; | |
| 5 | +import lombok.*; | |
| 6 | + | |
| 7 | +import java.time.LocalDate; | |
| 8 | +import java.util.*; | |
| 9 | +import jakarta.validation.constraints.*; | |
| 10 | + | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - 巡检计划汇总新增/修改 Request VO") | |
| 13 | +@Data | |
| 14 | +public class InspectionPlanSaveReqVO { | |
| 15 | + | |
| 16 | + @Schema(description = "计划名称后缀", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "张三") | |
| 17 | + private String planNameSuffix; | |
| 18 | + | |
| 19 | + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + @NotEmpty(message = "业务线: yl-园林;wy-物业:sz-市政不能为空") | |
| 21 | + private String busiLine; | |
| 22 | + | |
| 23 | + @Schema(description = "计划属性:1:标准计划;2:临时计划", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 24 | + @NotNull(message = "计划属性:1:标准计划;2:临时计划不能为空") | |
| 25 | + private Integer planAttr; | |
| 26 | + | |
| 27 | + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "24742") | |
| 28 | + @NotNull(message = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;不能为空") | |
| 29 | + private Integer planTypeId; | |
| 30 | + | |
| 31 | + @Schema(description = "归属(一级部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "20800") | |
| 32 | + @NotNull(message = "归属(一级部门id)不能为空") | |
| 33 | + private Long companyId; | |
| 34 | + | |
| 35 | + @Schema(description = "道路信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "[{\"deptId\":11,\"roadId\":1,\"roadName\":\"测试\"}]") | |
| 36 | + @Size(min = 1) | |
| 37 | + @Valid | |
| 38 | + private List<InspectionPlanRoadReqVO> roadListReqVO; | |
| 39 | + | |
| 40 | + @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "8588") | |
| 41 | + @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") | |
| 42 | + private Integer levelId; | |
| 43 | + | |
| 44 | + @Schema(description = "频次值", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 45 | + @NotEmpty(message = "频次值不能为空") | |
| 46 | + private String rateValue; | |
| 47 | + | |
| 48 | + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 49 | + @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空") | |
| 50 | + @Min(1) | |
| 51 | + @Max(4) | |
| 52 | + private Integer cycleId; | |
| 53 | + | |
| 54 | + @Schema(description = "开始时间") | |
| 55 | + private LocalDate beginTime; | |
| 56 | + | |
| 57 | + @Schema(description = "开始时间") | |
| 58 | + private LocalDate endTime; | |
| 59 | + | |
| 60 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") | |
| 61 | + @NotEmpty(message = "备注不能为空") | |
| 62 | + private String remark; | |
| 63 | + | |
| 64 | + @NotNull(message = "角色Ids不能为空") | |
| 65 | + @Schema(description = "角色Ids", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2]") | |
| 66 | + @Size(min = 1) | |
| 67 | + private Set<Integer> roleIds; | |
| 68 | + | |
| 69 | +} | |
| 0 | 70 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanUpdateReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.NotEmpty; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 巡检计划汇总新增/修改 Request VO") | |
| 11 | +@Data | |
| 12 | +public class InspectionPlanUpdateReqVO { | |
| 13 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10938") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + | |
| 17 | + @Schema(description = "业务线: yl-园林;wy-物业:sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 18 | + @NotEmpty(message = "业务线: yl-园林;wy-物业:sz-市政不能为空") | |
| 19 | + private String busiLine; | |
| 20 | + | |
| 21 | + @Schema(description = "计划属性:1:标准计划;2:临时计划", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 22 | + @NotNull(message = "计划属性:1:标准计划;2:临时计划不能为空") | |
| 23 | + private Integer planAttr; | |
| 24 | + | |
| 25 | + @Schema(description = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;", requiredMode = Schema.RequiredMode.REQUIRED, example = "24742") | |
| 26 | + @NotNull(message = "养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视;不能为空") | |
| 27 | + private Integer planTypeId; | |
| 28 | + | |
| 29 | + @Schema(description = "归属(一级部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "20800") | |
| 30 | + @NotNull(message = "归属(一级部门id)不能为空") | |
| 31 | + private Long companyId; | |
| 32 | + | |
| 33 | + @Schema(description = "部门ID(道路负责部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "16445") | |
| 34 | + @NotNull(message = "部门ID(道路负责部门id)不能为空") | |
| 35 | + private Long deptId; | |
| 36 | + | |
| 37 | + @Schema(description = "道路ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15557") | |
| 38 | + @NotNull(message = "道路ID不能为空") | |
| 39 | + private Long roadId; | |
| 40 | + | |
| 41 | + @Schema(description = "道路名称", example = "赵六") | |
| 42 | + private String roadName; | |
| 43 | + | |
| 44 | + @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "8588") | |
| 45 | + @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") | |
| 46 | + private Integer levelId; | |
| 47 | + | |
| 48 | + @Schema(description = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次", requiredMode = Schema.RequiredMode.REQUIRED, example = "6415") | |
| 49 | + @NotNull(message = "周期ID: 1:日/次;2:周/次;3:月/次;4:年/次不能为空") | |
| 50 | + private Integer cycleId; | |
| 51 | + | |
| 52 | + @Schema(description = "计划次数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 53 | + @NotNull(message = "计划次数不能为空") | |
| 54 | + private Integer planNum; | |
| 55 | + | |
| 56 | + @Schema(description = "已完成次数", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 57 | + @NotNull(message = "已完成次数不能为空") | |
| 58 | + private Integer planFinishNum; | |
| 59 | + | |
| 60 | + @Schema(description = "完成状态 1:未完成;2:已完成", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 61 | + @NotNull(message = "完成状态 1:未完成;2:已完成不能为空") | |
| 62 | + private Integer finishState; | |
| 63 | + | |
| 64 | + @Schema(description = "开始时间") | |
| 65 | + private LocalDateTime beginTime; | |
| 66 | + | |
| 67 | + @Schema(description = "开始时间") | |
| 68 | + private LocalDateTime endTime; | |
| 69 | + | |
| 70 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") | |
| 71 | + @NotEmpty(message = "备注不能为空") | |
| 72 | + private String remark; | |
| 73 | + | |
| 74 | +} | |
| 0 | 75 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/inspectionplan/InspectionPlanDO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.time.LocalDateTime; | |
| 5 | +import com.baomidou.mybatisplus.annotation.*; | |
| 6 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 巡检计划汇总 DO | |
| 10 | + * | |
| 11 | + * @author 超级管理员 | |
| 12 | + */ | |
| 13 | +@TableName("garden_inspection_plan") | |
| 14 | +@KeySequence("garden_inspection_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +@Builder | |
| 19 | +@NoArgsConstructor | |
| 20 | +@AllArgsConstructor | |
| 21 | +public class InspectionPlanDO extends BaseDO { | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * ID | |
| 25 | + */ | |
| 26 | + @TableId | |
| 27 | + private Long id; | |
| 28 | + /** | |
| 29 | + * 批次号 | |
| 30 | + */ | |
| 31 | + private String batchNo; | |
| 32 | + /** | |
| 33 | + * 计划名称 | |
| 34 | + */ | |
| 35 | + private String planName; | |
| 36 | + /** | |
| 37 | + * 业务线: yl-园林;wy-物业:sz-市政 | |
| 38 | + */ | |
| 39 | + private String busiLine; | |
| 40 | + /** | |
| 41 | + * 计划属性:1:标准计划;2:临时计划 | |
| 42 | + */ | |
| 43 | + private Integer planAttr; | |
| 44 | + /** | |
| 45 | + * 养护类型:2001:浇水;2002:施肥;2003:有害生物防治;2004:修剪;2005:中耕除草;2006:打孔梳草;2007:绿地保洁;2008:园林废弃物收集运输 ;2009:补植;3001:绿地巡视; | |
| 46 | + */ | |
| 47 | + private Integer planTypeId; | |
| 48 | + /** | |
| 49 | + * 归属(一级部门id) | |
| 50 | + */ | |
| 51 | + private Long companyId; | |
| 52 | + /** | |
| 53 | + * 部门ID(道路负责部门id) | |
| 54 | + */ | |
| 55 | + private Long deptId; | |
| 56 | + /** | |
| 57 | + * 道路ID | |
| 58 | + */ | |
| 59 | + private Long roadId; | |
| 60 | + /** | |
| 61 | + * 道路名称 | |
| 62 | + */ | |
| 63 | + private String roadName; | |
| 64 | + /** | |
| 65 | + * 养护级别: 10:特级;11:一级:12:二级;13:三级 | |
| 66 | + */ | |
| 67 | + private Integer levelId; | |
| 68 | + /** | |
| 69 | + * 周期ID: 1:日/次;2:周/次;3:月/次;4:年/次 | |
| 70 | + */ | |
| 71 | + private Integer cycleId; | |
| 72 | + /** | |
| 73 | + * 计划次数 | |
| 74 | + */ | |
| 75 | + private Integer planNum; | |
| 76 | + /** | |
| 77 | + * 已完成次数 | |
| 78 | + */ | |
| 79 | + private Integer planFinishNum; | |
| 80 | + /** | |
| 81 | + * 完成状态 1:未完成;2:已完成 | |
| 82 | + */ | |
| 83 | + private Integer finishState; | |
| 84 | + /** | |
| 85 | + * 开始时间 | |
| 86 | + */ | |
| 87 | + private LocalDateTime beginTime; | |
| 88 | + /** | |
| 89 | + * 开始时间 | |
| 90 | + */ | |
| 91 | + private LocalDateTime endTime; | |
| 92 | + /** | |
| 93 | + * 备注 | |
| 94 | + */ | |
| 95 | + private String remark; | |
| 96 | + | |
| 97 | + | |
| 98 | +} | |
| 0 | 99 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/inspectionplan/InspectionPlanMapper.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.mysql.inspectionplan; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 5 | +import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | |
| 7 | +import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 巡检计划汇总 Mapper | |
| 13 | + * | |
| 14 | + * @author 超级管理员 | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface InspectionPlanMapper extends BaseMapperX<InspectionPlanDO> { | |
| 18 | + | |
| 19 | + default PageResult<InspectionPlanDO> selectPage(InspectionPlanPageReqVO reqVO) { | |
| 20 | + return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDO>() | |
| 21 | + .eqIfPresent(InspectionPlanDO::getBatchNo, reqVO.getBatchNo()) | |
| 22 | + .likeIfPresent(InspectionPlanDO::getPlanName, reqVO.getPlanName()) | |
| 23 | + .eqIfPresent(InspectionPlanDO::getBusiLine, reqVO.getBusiLine()) | |
| 24 | + .eqIfPresent(InspectionPlanDO::getPlanAttr, reqVO.getPlanAttr()) | |
| 25 | + .eqIfPresent(InspectionPlanDO::getPlanTypeId, reqVO.getPlanTypeId()) | |
| 26 | + .eqIfPresent(InspectionPlanDO::getCompanyId, reqVO.getCompanyId()) | |
| 27 | + .eqIfPresent(InspectionPlanDO::getDeptId, reqVO.getDeptId()) | |
| 28 | + .eqIfPresent(InspectionPlanDO::getRoadId, reqVO.getRoadId()) | |
| 29 | + .likeIfPresent(InspectionPlanDO::getRoadName, reqVO.getRoadName()) | |
| 30 | + .eqIfPresent(InspectionPlanDO::getLevelId, reqVO.getLevelId()) | |
| 31 | + .eqIfPresent(InspectionPlanDO::getCycleId, reqVO.getCycleId()) | |
| 32 | + .eqIfPresent(InspectionPlanDO::getPlanNum, reqVO.getPlanNum()) | |
| 33 | + .eqIfPresent(InspectionPlanDO::getPlanFinishNum, reqVO.getPlanFinishNum()) | |
| 34 | + .eqIfPresent(InspectionPlanDO::getFinishState, reqVO.getFinishState()) | |
| 35 | + .betweenIfPresent(InspectionPlanDO::getBeginTime, reqVO.getBeginTime()) | |
| 36 | + .betweenIfPresent(InspectionPlanDO::getEndTime, reqVO.getEndTime()) | |
| 37 | + .eqIfPresent(InspectionPlanDO::getRemark, reqVO.getRemark()) | |
| 38 | + .betweenIfPresent(InspectionPlanDO::getCreateTime, reqVO.getCreateTime()) | |
| 39 | + .orderByDesc(InspectionPlanDO::getId)); | |
| 40 | + } | |
| 41 | + | |
| 42 | +} | |
| 0 | 43 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
| ... | ... | @@ -52,4 +52,9 @@ public interface ErrorCodeConstants { |
| 52 | 52 | ErrorCode WASTE_RECORD_NOT_EXISTS = new ErrorCode(1-100-003-012, "园林废弃物录入不存在"); |
| 53 | 53 | |
| 54 | 54 | ErrorCode WATER_FEE_NOT_EXISTS = new ErrorCode(1-100-003-013, "水费录入信息不存在"); |
| 55 | + | |
| 56 | + // ========== 巡检计划汇总 TODO 补充编号 ========== | |
| 57 | + ErrorCode INSPECTION_PLAN_NOT_EXISTS = new ErrorCode(1-200-100-001, "巡检计划汇总不存在"); | |
| 58 | + ErrorCode INSPECTION_CYCLE_ID_ERROR = new ErrorCode(1-200-100-002, "周期id错误"); | |
| 59 | + ErrorCode INSPECTION_CYCLE_ERROR = new ErrorCode(1-200-100-003, "获取两个时间之间间隔天数错误"); | |
| 55 | 60 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/FinishStateEnum.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.enums; | |
| 2 | + | |
| 3 | + | |
| 4 | +public enum FinishStateEnum { | |
| 5 | + | |
| 6 | + /** | |
| 7 | + * 未完成 | |
| 8 | + */ | |
| 9 | + NOT_FINISHED(1), | |
| 10 | + /** | |
| 11 | + * 已完成 | |
| 12 | + */ | |
| 13 | + FINISHED(2), | |
| 14 | + ; | |
| 15 | + | |
| 16 | + FinishStateEnum(Integer status) { | |
| 17 | + this.status = status; | |
| 18 | + } | |
| 19 | + | |
| 20 | + private Integer status; | |
| 21 | + | |
| 22 | + public Integer getStatus() { | |
| 23 | + return status; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void setStatus(Integer status) { | |
| 27 | + this.status = status; | |
| 28 | + } | |
| 29 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/PlanConstants.java
0 → 100644
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.inspectionplan; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 6 | +import jakarta.validation.*; | |
| 7 | +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*; | |
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO; | |
| 9 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 巡检计划汇总 Service 接口 | |
| 13 | + * | |
| 14 | + * @author 超级管理员 | |
| 15 | + */ | |
| 16 | +public interface InspectionPlanService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建巡检计划汇总 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + CommonResult<Long> createInspectionPlan(@Valid InspectionPlanSaveReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新巡检计划汇总 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateInspectionPlan(@Valid InspectionPlanUpdateReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除巡检计划汇总 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteInspectionPlan(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 批量删除巡检计划汇总 | |
| 42 | + * | |
| 43 | + * @param ids 编号 | |
| 44 | + */ | |
| 45 | + void deleteInspectionPlanListByIds(List<Long> ids); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 获得巡检计划汇总 | |
| 49 | + * | |
| 50 | + * @param id 编号 | |
| 51 | + * @return 巡检计划汇总 | |
| 52 | + */ | |
| 53 | + InspectionPlanDO getInspectionPlan(Long id); | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 获得巡检计划汇总分页 | |
| 57 | + * | |
| 58 | + * @param pageReqVO 分页查询 | |
| 59 | + * @return 巡检计划汇总分页 | |
| 60 | + */ | |
| 61 | + PageResult<InspectionPlanDO> getInspectionPlanPage(InspectionPlanPageReqVO pageReqVO); | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 根据批次号删除 | |
| 65 | + * @param batchNo 批次号 | |
| 66 | + */ | |
| 67 | + void deleteInspectionPlanBy(String batchNo); | |
| 68 | + | |
| 69 | +} | |
| 0 | 70 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.inspectionplan; | |
| 2 | + | |
| 3 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 4 | +import com.zteits.urbanops.framework.common.util.collection.CollectionUtils; | |
| 5 | +import com.zteits.urbanops.framework.dict.core.DictFrameworkUtils; | |
| 6 | +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; | |
| 7 | +import com.zteits.urbanops.module.garden.enums.FinishStateEnum; | |
| 8 | +import com.zteits.urbanops.module.garden.enums.PlanConstants; | |
| 9 | +import com.zteits.urbanops.module.garden.util.TimeIntervalCalculatorUtil; | |
| 10 | +import lombok.extern.slf4j.Slf4j; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import jakarta.annotation.Resource; | |
| 13 | +import org.springframework.transaction.annotation.Transactional; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | + | |
| 16 | +import java.time.LocalDateTime; | |
| 17 | +import java.util.*; | |
| 18 | +import java.util.concurrent.atomic.AtomicInteger; | |
| 19 | + | |
| 20 | +import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*; | |
| 21 | +import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO; | |
| 22 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 23 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | |
| 24 | + | |
| 25 | +import com.zteits.urbanops.module.garden.dal.mysql.inspectionplan.InspectionPlanMapper; | |
| 26 | + | |
| 27 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 28 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * 巡检计划汇总 Service 实现类 | |
| 32 | + * | |
| 33 | + * @author 超级管理员 | |
| 34 | + */ | |
| 35 | +@Service | |
| 36 | +@Validated | |
| 37 | +@Slf4j | |
| 38 | +public class InspectionPlanServiceImpl implements InspectionPlanService { | |
| 39 | + | |
| 40 | + @Resource | |
| 41 | + private InspectionPlanMapper inspectionPlanMapper; | |
| 42 | + | |
| 43 | + @Transactional(rollbackFor = Exception.class) | |
| 44 | + @Override | |
| 45 | + public CommonResult<Long> createInspectionPlan(InspectionPlanSaveReqVO createReqVO) { | |
| 46 | + LocalDateTime now = LocalDateTime.now(); | |
| 47 | + String userName = SecurityFrameworkUtils.getLoginUserNickname() + "(" + SecurityFrameworkUtils.getLoginUserId() + ")"; | |
| 48 | + | |
| 49 | + Integer rateValue; | |
| 50 | + if(createReqVO.getRateValue().contains("/")){ | |
| 51 | + rateValue = Integer.parseInt(createReqVO.getRateValue().split("/")[1]); | |
| 52 | + }else{ | |
| 53 | + rateValue = Integer.parseInt(createReqVO.getRateValue()); | |
| 54 | + } | |
| 55 | + | |
| 56 | + //计算开始和计算时间 在间隔周期下每天的次数 | |
| 57 | + List<String> betweenDayList = TimeIntervalCalculatorUtil.calculateIntervals(createReqVO.getBeginTime(), createReqVO.getEndTime(), createReqVO.getCycleId(), rateValue); | |
| 58 | + if(CollectionUtils.isAnyEmpty(betweenDayList)){ | |
| 59 | + log.warn("获取两个时间之间间隔天数错误"); | |
| 60 | + return CommonResult.error(INSPECTION_CYCLE_ERROR); | |
| 61 | + } | |
| 62 | + //计算计划次数 | |
| 63 | + Integer planNum = betweenDayList.size(); | |
| 64 | + InspectionPlanDO inspectionPlan = BeanUtils.toBean(createReqVO, InspectionPlanDO.class); | |
| 65 | + AtomicInteger count = new AtomicInteger(); | |
| 66 | + | |
| 67 | + //按照道路创建计划 | |
| 68 | + createReqVO.getRoadListReqVO().forEach(roadReqVO -> { | |
| 69 | + String batchNo = "X" + UUID.randomUUID(); | |
| 70 | + inspectionPlan.setBatchNo(batchNo); | |
| 71 | + inspectionPlan.setPlanFinishNum(0); | |
| 72 | + inspectionPlan.setFinishState(FinishStateEnum.NOT_FINISHED.getStatus()); | |
| 73 | + inspectionPlan.setPlanNum(planNum); | |
| 74 | + inspectionPlan.setCreateTime(now); | |
| 75 | + inspectionPlan.setUpdateTime(now); | |
| 76 | + inspectionPlan.setCreator(userName); | |
| 77 | + inspectionPlan.setUpdater(userName); | |
| 78 | + inspectionPlan.setDeptId(roadReqVO.getDeptId()); | |
| 79 | + inspectionPlan.setRoadId(roadReqVO.getRoadId()); | |
| 80 | + inspectionPlan.setRoadName(roadReqVO.getRoadName()); | |
| 81 | + //计划属性 | |
| 82 | + String planAttrLable = DictFrameworkUtils.parseDictDataLabel(PlanConstants.GARDEN_PLAN_ATTR_REDIS_KEY, createReqVO.getPlanAttr()); | |
| 83 | + inspectionPlan.setPlanName(roadReqVO.getRoadName() + planAttrLable + createReqVO.getPlanNameSuffix()); | |
| 84 | + /*1.插入巡查计划*/ | |
| 85 | + count.addAndGet(inspectionPlanMapper.insert(inspectionPlan)); | |
| 86 | + }); | |
| 87 | + | |
| 88 | + // 返回 | |
| 89 | + return CommonResult.success(count.longValue()); | |
| 90 | + } | |
| 91 | + | |
| 92 | + | |
| 93 | + @Override | |
| 94 | + public void updateInspectionPlan(InspectionPlanUpdateReqVO updateReqVO) { | |
| 95 | + // 校验存在 | |
| 96 | + validateInspectionPlanExists(updateReqVO.getId()); | |
| 97 | + // 更新 | |
| 98 | + InspectionPlanDO updateObj = BeanUtils.toBean(updateReqVO, InspectionPlanDO.class); | |
| 99 | + inspectionPlanMapper.updateById(updateObj); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Override | |
| 103 | + public void deleteInspectionPlan(Long id) { | |
| 104 | + // 校验存在 | |
| 105 | + validateInspectionPlanExists(id); | |
| 106 | + // 删除 | |
| 107 | + inspectionPlanMapper.deleteById(id); | |
| 108 | + } | |
| 109 | + | |
| 110 | + @Override | |
| 111 | + public void deleteInspectionPlanListByIds(List<Long> ids) { | |
| 112 | + // 删除 | |
| 113 | + inspectionPlanMapper.deleteByIds(ids); | |
| 114 | + } | |
| 115 | + | |
| 116 | + | |
| 117 | + private void validateInspectionPlanExists(Long id) { | |
| 118 | + if (inspectionPlanMapper.selectById(id) == null) { | |
| 119 | + throw exception(INSPECTION_PLAN_NOT_EXISTS); | |
| 120 | + } | |
| 121 | + } | |
| 122 | + | |
| 123 | + @Override | |
| 124 | + public InspectionPlanDO getInspectionPlan(Long id) { | |
| 125 | + return inspectionPlanMapper.selectById(id); | |
| 126 | + } | |
| 127 | + | |
| 128 | + @Override | |
| 129 | + public PageResult<InspectionPlanDO> getInspectionPlanPage(InspectionPlanPageReqVO pageReqVO) { | |
| 130 | + return inspectionPlanMapper.selectPage(pageReqVO); | |
| 131 | + } | |
| 132 | + | |
| 133 | + @Override | |
| 134 | + public void deleteInspectionPlanBy(String batchNo) { | |
| 135 | + //TODO | |
| 136 | + } | |
| 137 | + | |
| 138 | +} | |
| 0 | 139 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/util/TimeIntervalCalculatorUtil.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.util; | |
| 2 | + | |
| 3 | + | |
| 4 | +import java.time.LocalDate; | |
| 5 | +import java.util.ArrayList; | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 9 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.INSPECTION_CYCLE_ID_ERROR; | |
| 10 | + | |
| 11 | +public class TimeIntervalCalculatorUtil { | |
| 12 | + enum IntervalUnit { | |
| 13 | + DAY, WEEK, MONTH, YEAR | |
| 14 | + } | |
| 15 | + | |
| 16 | + public static void main(String[] args) { | |
| 17 | + | |
| 18 | + System.out.println("请输入开始日期(yyyy-MM-dd):"); | |
| 19 | + LocalDate startDate = LocalDate.of(2025,10,1); | |
| 20 | + | |
| 21 | + System.out.println("请输入结束日期(yyyy-MM-dd):"); | |
| 22 | + LocalDate endDate = LocalDate.of(2025,10,7); | |
| 23 | + | |
| 24 | + System.out.println("请选择间隔单位(1.天 2.周 3.月 4.年):"); | |
| 25 | + IntervalUnit unit = IntervalUnit.DAY; | |
| 26 | + | |
| 27 | + System.out.println("请输入间隔数量(如2表示每2天/周/月/年):"); | |
| 28 | + int intervalCount =2; | |
| 29 | + | |
| 30 | + List<String> intervals = calculateIntervals(startDate, endDate, 1, intervalCount); | |
| 31 | + | |
| 32 | + System.out.println("\n执行周期:"); | |
| 33 | + intervals.forEach(System.out::println); | |
| 34 | + } | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 执行次数计算 | |
| 38 | + * @param start | |
| 39 | + * @param end | |
| 40 | + * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次 | |
| 41 | + * @param intervalCount | |
| 42 | + * @return | |
| 43 | + */ | |
| 44 | + public static List<String> calculateIntervals(LocalDate start, LocalDate end, Integer cycleId, int intervalCount) { | |
| 45 | + List<String> intervals = new ArrayList<>(); | |
| 46 | + LocalDate currentStart = start; | |
| 47 | + IntervalUnit unit = getIntervalUnit(cycleId); | |
| 48 | + | |
| 49 | + while (currentStart.isBefore(end) || currentStart.isEqual(end)) { | |
| 50 | + LocalDate currentEnd = calculateEndDate(currentStart, end, unit, intervalCount); | |
| 51 | + intervals.add(currentStart + "/" + currentEnd); | |
| 52 | + currentStart = currentEnd.plusDays(1); | |
| 53 | + } | |
| 54 | + | |
| 55 | + return intervals; | |
| 56 | + } | |
| 57 | + | |
| 58 | + private static LocalDate calculateEndDate(LocalDate currentStart, LocalDate endDate, | |
| 59 | + IntervalUnit unit, int intervalCount) { | |
| 60 | + switch (unit) { | |
| 61 | + case DAY: | |
| 62 | + LocalDate dayEnd = currentStart.plusDays(intervalCount - 1); | |
| 63 | + return dayEnd.isAfter(endDate) ? endDate : dayEnd; | |
| 64 | + case WEEK: | |
| 65 | + LocalDate weekEnd = currentStart.plusDays(7 * intervalCount - 1); | |
| 66 | + return weekEnd.isAfter(endDate) ? endDate : weekEnd; | |
| 67 | + case MONTH: | |
| 68 | + LocalDate monthEnd = currentStart.plusMonths(intervalCount) | |
| 69 | + .withDayOfMonth(1).minusDays(1); | |
| 70 | + return monthEnd.isAfter(endDate) ? endDate : monthEnd; | |
| 71 | + case YEAR: | |
| 72 | + LocalDate yearEnd = currentStart.plusYears(intervalCount) | |
| 73 | + .withDayOfYear(1).minusDays(1); | |
| 74 | + return yearEnd.isAfter(endDate) ? endDate : yearEnd; | |
| 75 | + default: | |
| 76 | + return endDate; | |
| 77 | + } | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * 转换枚举 | |
| 82 | + * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次 | |
| 83 | + * @return | |
| 84 | + */ | |
| 85 | + public static IntervalUnit getIntervalUnit(Integer cycleId) { | |
| 86 | + switch (cycleId) { | |
| 87 | + case 1: | |
| 88 | + return IntervalUnit.DAY; | |
| 89 | + case 2: | |
| 90 | + return IntervalUnit.WEEK; | |
| 91 | + case 3: | |
| 92 | + return IntervalUnit.MONTH; | |
| 93 | + case 4: | |
| 94 | + return IntervalUnit.YEAR; | |
| 95 | + default: | |
| 96 | + throw exception(INSPECTION_CYCLE_ID_ERROR); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanMapper.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.InspectionPlanMapper"> | |
| 4 | + | |
| 5 | + <!-- | |
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | |
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | |
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | |
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | |
| 10 | + --> | |
| 11 | + | |
| 12 | +</mapper> | |
| 0 | 13 | \ No newline at end of file | ... | ... |