Commit 398f9230aa3dd82f524d809e2b2f6ce9975f3d18
1 parent
795d4971
道路街道提交
Showing
25 changed files
with
833 additions
and
18 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/RoadController.java
| @@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; | @@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | import io.swagger.v3.oas.annotations.Parameter; | 8 | import io.swagger.v3.oas.annotations.Parameter; |
| 9 | import io.swagger.v3.oas.annotations.Operation; | 9 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | 10 | ||
| 11 | -import jakarta.validation.constraints.*; | ||
| 12 | import jakarta.validation.*; | 11 | import jakarta.validation.*; |
| 13 | import jakarta.servlet.http.*; | 12 | import jakarta.servlet.http.*; |
| 14 | import java.util.*; | 13 | import java.util.*; |
| @@ -48,7 +47,7 @@ public class RoadController { | @@ -48,7 +47,7 @@ public class RoadController { | ||
| 48 | @PutMapping("/update") | 47 | @PutMapping("/update") |
| 49 | @Operation(summary = "更新道路管理") | 48 | @Operation(summary = "更新道路管理") |
| 50 | @PreAuthorize("@ss.hasPermission('garden:road:update')") | 49 | @PreAuthorize("@ss.hasPermission('garden:road:update')") |
| 51 | - public CommonResult<Boolean> updateRoad(@Valid @RequestBody RoadSaveReqVO updateReqVO) { | 50 | + public CommonResult<Boolean> updateRoad(@Valid @RequestBody RoadUpdateReqVO updateReqVO) { |
| 52 | roadService.updateRoad(updateReqVO); | 51 | roadService.updateRoad(updateReqVO); |
| 53 | return success(true); | 52 | return success(true); |
| 54 | } | 53 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/RoadStreetController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.road; | ||
| 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.road.vo.*; | ||
| 29 | +import com.zteits.urbanops.module.garden.dal.dataobject.road.RoadStreetDO; | ||
| 30 | +import com.zteits.urbanops.module.garden.service.road.RoadStreetService; | ||
| 31 | + | ||
| 32 | +@Tag(name = "管理后台 - 街道") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/garden/road-street") | ||
| 35 | +@Validated | ||
| 36 | +public class RoadStreetController { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private RoadStreetService roadStreetService; | ||
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建街道") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('garden:road-street:create')") | ||
| 44 | + public CommonResult<Long> createRoadStreet(@Valid @RequestBody RoadStreetSaveReqVO createReqVO) { | ||
| 45 | + return success(roadStreetService.createRoadStreet(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新街道") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('garden:road-street:update')") | ||
| 51 | + public CommonResult<Boolean> updateRoadStreet(@Valid @RequestBody RoadStreetSaveReqVO updateReqVO) { | ||
| 52 | + roadStreetService.updateRoadStreet(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:road-street:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteRoadStreet(@RequestParam("id") Long id) { | ||
| 61 | + roadStreetService.deleteRoadStreet(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:road-street:delete')") | ||
| 69 | + public CommonResult<Boolean> deleteRoadStreetList(@RequestParam("ids") List<Long> ids) { | ||
| 70 | + roadStreetService.deleteRoadStreetListByIds(ids); | ||
| 71 | + return success(true); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @GetMapping("/get") | ||
| 75 | + @Operation(summary = "获得街道") | ||
| 76 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 77 | + @PreAuthorize("@ss.hasPermission('garden:road-street:query')") | ||
| 78 | + public CommonResult<RoadStreetRespVO> getRoadStreet(@RequestParam("id") Long id) { | ||
| 79 | + RoadStreetDO roadStreet = roadStreetService.getRoadStreet(id); | ||
| 80 | + return success(BeanUtils.toBean(roadStreet, RoadStreetRespVO.class)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @GetMapping("/list") | ||
| 84 | + @Operation(summary = "获得街道列表") | ||
| 85 | + @Parameter(name = "busi_line", description = "业务线", required = true, example = "1024") | ||
| 86 | + @PreAuthorize("@ss.hasPermission('garden:road-street:query')") | ||
| 87 | + public CommonResult<List<RoadStreetRespVO>> getRoadStreet(@RequestParam("busi_line") @NotBlank String busiLine) { | ||
| 88 | + List<RoadStreetDO> roadStreet = roadStreetService.getRoadStreetList(busiLine); | ||
| 89 | + return success(BeanUtils.toBean(roadStreet, RoadStreetRespVO.class)); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @GetMapping("/page") | ||
| 93 | + @Operation(summary = "获得街道分页") | ||
| 94 | + @PreAuthorize("@ss.hasPermission('garden:road-street:query')") | ||
| 95 | + public CommonResult<PageResult<RoadStreetRespVO>> getRoadStreetPage(@Valid RoadStreetPageReqVO pageReqVO) { | ||
| 96 | + PageResult<RoadStreetDO> pageResult = roadStreetService.getRoadStreetPage(pageReqVO); | ||
| 97 | + return success(BeanUtils.toBean(pageResult, RoadStreetRespVO.class)); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @GetMapping("/export-excel") | ||
| 101 | + @Operation(summary = "导出街道 Excel") | ||
| 102 | + @PreAuthorize("@ss.hasPermission('garden:road-street:export')") | ||
| 103 | + @ApiAccessLog(operateType = EXPORT) | ||
| 104 | + public void exportRoadStreetExcel(@Valid RoadStreetPageReqVO pageReqVO, | ||
| 105 | + HttpServletResponse response) throws IOException { | ||
| 106 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 107 | + List<RoadStreetDO> list = roadStreetService.getRoadStreetPage(pageReqVO).getList(); | ||
| 108 | + // 导出 Excel | ||
| 109 | + ExcelUtils.write(response, "街道.xls", "数据", RoadStreetRespVO.class, | ||
| 110 | + BeanUtils.toBean(list, RoadStreetRespVO.class)); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | +} | ||
| 0 | \ No newline at end of file | 114 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadPageReqVO.java
| @@ -16,15 +16,24 @@ public class RoadPageReqVO extends PageParam { | @@ -16,15 +16,24 @@ public class RoadPageReqVO extends PageParam { | ||
| 16 | @Schema(description = "道路名称", example = "赵六") | 16 | @Schema(description = "道路名称", example = "赵六") |
| 17 | private String roadName; | 17 | private String roadName; |
| 18 | 18 | ||
| 19 | - @Schema(description = "街道ID", example = "30480") | 19 | + @Schema(description = "街道ID", example = "11139") |
| 20 | private String streetId; | 20 | private String streetId; |
| 21 | 21 | ||
| 22 | @Schema(description = "街道名称", example = "赵六") | 22 | @Schema(description = "街道名称", example = "赵六") |
| 23 | private String streetName; | 23 | private String streetName; |
| 24 | 24 | ||
| 25 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政") | ||
| 26 | + private String busiLine; | ||
| 27 | + | ||
| 25 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", example = "26337") | 28 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", example = "26337") |
| 26 | private Integer levelId; | 29 | private Integer levelId; |
| 27 | 30 | ||
| 31 | + @Schema(description = "道路属性") | ||
| 32 | + private String roadAttr; | ||
| 33 | + | ||
| 34 | + @Schema(description = "道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection") | ||
| 35 | + private String direction; | ||
| 36 | + | ||
| 28 | @Schema(description = "行道树绿化面积") | 37 | @Schema(description = "行道树绿化面积") |
| 29 | private String greenBeltTreeArea; | 38 | private String greenBeltTreeArea; |
| 30 | 39 |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadRespVO.java
| @@ -12,7 +12,7 @@ import cn.idev.excel.annotation.*; | @@ -12,7 +12,7 @@ import cn.idev.excel.annotation.*; | ||
| 12 | @ExcelIgnoreUnannotated | 12 | @ExcelIgnoreUnannotated |
| 13 | public class RoadRespVO { | 13 | public class RoadRespVO { |
| 14 | 14 | ||
| 15 | - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15456") | 15 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24756") |
| 16 | @ExcelProperty("ID") | 16 | @ExcelProperty("ID") |
| 17 | private Long id; | 17 | private Long id; |
| 18 | 18 | ||
| @@ -20,7 +20,7 @@ public class RoadRespVO { | @@ -20,7 +20,7 @@ public class RoadRespVO { | ||
| 20 | @ExcelProperty("道路名称") | 20 | @ExcelProperty("道路名称") |
| 21 | private String roadName; | 21 | private String roadName; |
| 22 | 22 | ||
| 23 | - @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30480") | 23 | + @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11139") |
| 24 | @ExcelProperty("街道ID") | 24 | @ExcelProperty("街道ID") |
| 25 | private String streetId; | 25 | private String streetId; |
| 26 | 26 | ||
| @@ -28,10 +28,22 @@ public class RoadRespVO { | @@ -28,10 +28,22 @@ public class RoadRespVO { | ||
| 28 | @ExcelProperty("街道名称") | 28 | @ExcelProperty("街道名称") |
| 29 | private String streetName; | 29 | private String streetName; |
| 30 | 30 | ||
| 31 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 32 | + @ExcelProperty("业务线:yl-园林;wy-物业;sz-市政") | ||
| 33 | + private String busiLine; | ||
| 34 | + | ||
| 31 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "26337") | 35 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "26337") |
| 32 | @ExcelProperty("养护级别: 10:特级;11:一级:12:二级;13:三级") | 36 | @ExcelProperty("养护级别: 10:特级;11:一级:12:二级;13:三级") |
| 33 | private Integer levelId; | 37 | private Integer levelId; |
| 34 | 38 | ||
| 39 | + @Schema(description = "道路属性") | ||
| 40 | + @ExcelProperty("道路属性") | ||
| 41 | + private String roadAttr; | ||
| 42 | + | ||
| 43 | + @Schema(description = "道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + @ExcelProperty("道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection") | ||
| 45 | + private String direction; | ||
| 46 | + | ||
| 35 | @Schema(description = "行道树绿化面积", requiredMode = Schema.RequiredMode.REQUIRED) | 47 | @Schema(description = "行道树绿化面积", requiredMode = Schema.RequiredMode.REQUIRED) |
| 36 | @ExcelProperty("行道树绿化面积") | 48 | @ExcelProperty("行道树绿化面积") |
| 37 | private String greenBeltTreeArea; | 49 | private String greenBeltTreeArea; |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadSaveReqVO.java
| @@ -9,13 +9,11 @@ import jakarta.validation.constraints.*; | @@ -9,13 +9,11 @@ import jakarta.validation.constraints.*; | ||
| 9 | @Data | 9 | @Data |
| 10 | public class RoadSaveReqVO { | 10 | public class RoadSaveReqVO { |
| 11 | 11 | ||
| 12 | - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15456") | ||
| 13 | - private Long id; | ||
| 14 | 12 | ||
| 15 | @Schema(description = "道路名称", example = "赵六") | 13 | @Schema(description = "道路名称", example = "赵六") |
| 16 | private String roadName; | 14 | private String roadName; |
| 17 | 15 | ||
| 18 | - @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30480") | 16 | + @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11139") |
| 19 | @NotEmpty(message = "街道ID不能为空") | 17 | @NotEmpty(message = "街道ID不能为空") |
| 20 | private String streetId; | 18 | private String streetId; |
| 21 | 19 | ||
| @@ -23,10 +21,21 @@ public class RoadSaveReqVO { | @@ -23,10 +21,21 @@ public class RoadSaveReqVO { | ||
| 23 | @NotEmpty(message = "街道名称不能为空") | 21 | @NotEmpty(message = "街道名称不能为空") |
| 24 | private String streetName; | 22 | private String streetName; |
| 25 | 23 | ||
| 24 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 25 | + @NotEmpty(message = "业务线:yl-园林;wy-物业;sz-市政不能为空") | ||
| 26 | + private String busiLine; | ||
| 27 | + | ||
| 26 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "26337") | 28 | @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "26337") |
| 27 | @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") | 29 | @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") |
| 28 | private Integer levelId; | 30 | private Integer levelId; |
| 29 | 31 | ||
| 32 | + @Schema(description = "道路属性") | ||
| 33 | + private String roadAttr; | ||
| 34 | + | ||
| 35 | + @Schema(description = "道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 36 | + @NotEmpty(message = "道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection不能为空") | ||
| 37 | + private String direction; | ||
| 38 | + | ||
| 30 | @Schema(description = "行道树绿化面积", requiredMode = Schema.RequiredMode.REQUIRED) | 39 | @Schema(description = "行道树绿化面积", requiredMode = Schema.RequiredMode.REQUIRED) |
| 31 | @NotEmpty(message = "行道树绿化面积不能为空") | 40 | @NotEmpty(message = "行道树绿化面积不能为空") |
| 32 | private String greenBeltTreeArea; | 41 | private String greenBeltTreeArea; |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadStreetPageReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.road.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 RoadStreetPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "街道ID", example = "8439") | ||
| 17 | + private String streetId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "街道名称", example = "芋艿") | ||
| 20 | + private String streetName; | ||
| 21 | + | ||
| 22 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政") | ||
| 23 | + private String busiLine; | ||
| 24 | + | ||
| 25 | + @Schema(description = "创建者", example = "芋艿") | ||
| 26 | + private String creatorName; | ||
| 27 | + | ||
| 28 | + @Schema(description = "创建时间") | ||
| 29 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 30 | + private LocalDateTime[] createTime; | ||
| 31 | + | ||
| 32 | + @Schema(description = "更新者", example = "王五") | ||
| 33 | + private String updaterName; | ||
| 34 | + | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadStreetRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.road.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 RoadStreetRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7534") | ||
| 16 | + @ExcelProperty("ID") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8439") | ||
| 20 | + @ExcelProperty("街道ID") | ||
| 21 | + private String streetId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "街道名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 24 | + @ExcelProperty("街道名称") | ||
| 25 | + private String streetName; | ||
| 26 | + | ||
| 27 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 28 | + @ExcelProperty("业务线:yl-园林;wy-物业;sz-市政") | ||
| 29 | + private String busiLine; | ||
| 30 | + | ||
| 31 | + @Schema(description = "创建者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 32 | + @ExcelProperty("创建者") | ||
| 33 | + private String creatorName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 36 | + @ExcelProperty("创建时间") | ||
| 37 | + private LocalDateTime createTime; | ||
| 38 | + | ||
| 39 | + @Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 40 | + @ExcelProperty("更新者") | ||
| 41 | + private String updaterName; | ||
| 42 | + | ||
| 43 | +} | ||
| 0 | \ No newline at end of file | 44 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadStreetSaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.road.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 RoadStreetSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7534") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8439") | ||
| 16 | + @NotEmpty(message = "街道ID不能为空") | ||
| 17 | + private String streetId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "街道名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 20 | + @NotEmpty(message = "街道名称不能为空") | ||
| 21 | + private String streetName; | ||
| 22 | + | ||
| 23 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | + @NotEmpty(message = "业务线:yl-园林;wy-物业;sz-市政不能为空") | ||
| 25 | + private String busiLine; | ||
| 26 | + | ||
| 27 | + @Schema(description = "创建者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 28 | + @NotEmpty(message = "创建者不能为空") | ||
| 29 | + private String creatorName; | ||
| 30 | + | ||
| 31 | + @Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 32 | + @NotEmpty(message = "更新者不能为空") | ||
| 33 | + private String updaterName; | ||
| 34 | + | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/vo/RoadUpdateReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.road.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 | +@Schema(description = "管理后台 - 道路管理新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class RoadUpdateReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15456") | ||
| 13 | + @NotNull(message = "道路id不能为空") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "道路名称", example = "赵六") | ||
| 17 | + @NotEmpty(message = "道路名称不能为空") | ||
| 18 | + private String roadName; | ||
| 19 | + | ||
| 20 | + @Schema(description = "街道ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11139") | ||
| 21 | + @NotEmpty(message = "街道ID不能为空") | ||
| 22 | + private String streetId; | ||
| 23 | + | ||
| 24 | + @Schema(description = "街道名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 25 | + @NotEmpty(message = "街道名称不能为空") | ||
| 26 | + private String streetName; | ||
| 27 | + | ||
| 28 | + @Schema(description = "业务线:yl-园林;wy-物业;sz-市政", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 29 | + @NotEmpty(message = "业务线:yl-园林;wy-物业;sz-市政不能为空") | ||
| 30 | + private String busiLine; | ||
| 31 | + | ||
| 32 | + @Schema(description = "养护级别: 10:特级;11:一级:12:二级;13:三级", requiredMode = Schema.RequiredMode.REQUIRED, example = "26337") | ||
| 33 | + @NotNull(message = "养护级别: 10:特级;11:一级:12:二级;13:三级不能为空") | ||
| 34 | + private Integer levelId; | ||
| 35 | + | ||
| 36 | + @Schema(description = "道路属性") | ||
| 37 | + private String roadAttr; | ||
| 38 | + | ||
| 39 | + @Schema(description = "道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 40 | + @NotEmpty(message = "道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection不能为空") | ||
| 41 | + private String direction; | ||
| 42 | + | ||
| 43 | + @Schema(description = "行道树绿化面积", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + @NotEmpty(message = "行道树绿化面积不能为空") | ||
| 45 | + private String greenBeltTreeArea; | ||
| 46 | + | ||
| 47 | + @Schema(description = "绿化带面积", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 48 | + @NotEmpty(message = "绿化带面积不能为空") | ||
| 49 | + private String greenBeltArea; | ||
| 50 | + | ||
| 51 | + @Schema(description = "总绿化带面积", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 52 | + @NotEmpty(message = "总绿化带面积不能为空") | ||
| 53 | + private String totalArea; | ||
| 54 | + | ||
| 55 | + @Schema(description = "行道树(棵)面积", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 56 | + @NotEmpty(message = "行道树(棵)面积不能为空") | ||
| 57 | + private String treeArea; | ||
| 58 | + | ||
| 59 | + @Schema(description = "起点经度", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 60 | + @NotEmpty(message = "起点经度不能为空") | ||
| 61 | + private String startingLatitude; | ||
| 62 | + | ||
| 63 | + @Schema(description = "起点维度", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 64 | + @NotEmpty(message = "起点维度不能为空") | ||
| 65 | + private String startingLongitude; | ||
| 66 | + | ||
| 67 | + @Schema(description = "起点描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") | ||
| 68 | + @NotEmpty(message = "起点描述不能为空") | ||
| 69 | + private String startingRemark; | ||
| 70 | + | ||
| 71 | + @Schema(description = "终点经度", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 72 | + @NotEmpty(message = "终点经度不能为空") | ||
| 73 | + private String endLatitude; | ||
| 74 | + | ||
| 75 | + @Schema(description = "终点维度", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 76 | + @NotEmpty(message = "终点维度不能为空") | ||
| 77 | + private String endLongitude; | ||
| 78 | + | ||
| 79 | + @Schema(description = "终点描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") | ||
| 80 | + @NotEmpty(message = "终点描述不能为空") | ||
| 81 | + private String endRemark; | ||
| 82 | + | ||
| 83 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") | ||
| 84 | + @NotEmpty(message = "备注不能为空") | ||
| 85 | + private String remark; | ||
| 86 | + | ||
| 87 | + @Schema(description = "归属(一级部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2323") | ||
| 88 | + @NotNull(message = "归属(一级部门id)不能为空") | ||
| 89 | + private Long companyId; | ||
| 90 | + | ||
| 91 | + @Schema(description = "部门ID(道路负责部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13872") | ||
| 92 | + @NotNull(message = "部门ID(道路负责部门id)不能为空") | ||
| 93 | + private Long deptId; | ||
| 94 | + | ||
| 95 | + @Schema(description = "创建者", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 96 | + @NotEmpty(message = "创建者不能为空") | ||
| 97 | + private String creatorName; | ||
| 98 | + | ||
| 99 | + @Schema(description = "更新者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 100 | + @NotEmpty(message = "更新者不能为空") | ||
| 101 | + private String updaterName; | ||
| 102 | + | ||
| 103 | +} | ||
| 0 | \ No newline at end of file | 104 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/road/RoadDO.java
| @@ -40,10 +40,22 @@ public class RoadDO extends BaseDO { | @@ -40,10 +40,22 @@ public class RoadDO extends BaseDO { | ||
| 40 | */ | 40 | */ |
| 41 | private String streetName; | 41 | private String streetName; |
| 42 | /** | 42 | /** |
| 43 | + * 业务线:yl-园林;wy-物业;sz-市政 | ||
| 44 | + */ | ||
| 45 | + private String busiLine; | ||
| 46 | + /** | ||
| 43 | * 养护级别: 10:特级;11:一级:12:二级;13:三级 | 47 | * 养护级别: 10:特级;11:一级:12:二级;13:三级 |
| 44 | */ | 48 | */ |
| 45 | private Integer levelId; | 49 | private Integer levelId; |
| 46 | /** | 50 | /** |
| 51 | + * 道路属性 | ||
| 52 | + */ | ||
| 53 | + private String roadAttr; | ||
| 54 | + /** | ||
| 55 | + * 道路方位 W-西 E-东 N-北 S-南 参考字典roadDirection | ||
| 56 | + */ | ||
| 57 | + private String direction; | ||
| 58 | + /** | ||
| 47 | * 行道树绿化面积 | 59 | * 行道树绿化面积 |
| 48 | */ | 60 | */ |
| 49 | private String greenBeltTreeArea; | 61 | private String greenBeltTreeArea; |
| @@ -104,8 +116,5 @@ public class RoadDO extends BaseDO { | @@ -104,8 +116,5 @@ public class RoadDO extends BaseDO { | ||
| 104 | */ | 116 | */ |
| 105 | private String updaterName; | 117 | private String updaterName; |
| 106 | 118 | ||
| 107 | - /** | ||
| 108 | - * 方向 | ||
| 109 | - */ | ||
| 110 | - private String direction; | 119 | + |
| 111 | } | 120 | } |
| 112 | \ No newline at end of file | 121 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/road/RoadStreetDO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.dataobject.road; | ||
| 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_road_street") | ||
| 16 | +@KeySequence("garden_road_street_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 RoadStreetDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * ID | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 街道ID | ||
| 32 | + */ | ||
| 33 | + private String streetId; | ||
| 34 | + /** | ||
| 35 | + * 街道名称 | ||
| 36 | + */ | ||
| 37 | + private String streetName; | ||
| 38 | + /** | ||
| 39 | + * 业务线:yl-园林;wy-物业;sz-市政 | ||
| 40 | + */ | ||
| 41 | + private String busiLine; | ||
| 42 | + /** | ||
| 43 | + * 创建者 | ||
| 44 | + */ | ||
| 45 | + private String creatorName; | ||
| 46 | + /** | ||
| 47 | + * 更新者 | ||
| 48 | + */ | ||
| 49 | + private String updaterName; | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +} | ||
| 0 | \ No newline at end of file | 53 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/road/RoadInterceptMapper.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.mysql.road; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 4 | +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import com.zteits.urbanops.module.garden.controller.admin.road.vo.RoadPageReqVO; | ||
| 7 | +import com.zteits.urbanops.module.garden.dal.dataobject.road.RoadDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 道路管理 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface RoadInterceptMapper extends BaseMapperX<RoadDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<RoadDO> selectPage(RoadPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<RoadDO>() | ||
| 20 | + .likeIfPresent(RoadDO::getRoadName, reqVO.getRoadName()) | ||
| 21 | + .eqIfPresent(RoadDO::getStreetId, reqVO.getStreetId()) | ||
| 22 | + .likeIfPresent(RoadDO::getStreetName, reqVO.getStreetName()) | ||
| 23 | + .eqIfPresent(RoadDO::getBusiLine, reqVO.getBusiLine()) | ||
| 24 | + .eqIfPresent(RoadDO::getLevelId, reqVO.getLevelId()) | ||
| 25 | + .eqIfPresent(RoadDO::getRoadAttr, reqVO.getRoadAttr()) | ||
| 26 | + .eqIfPresent(RoadDO::getDirection, reqVO.getDirection()) | ||
| 27 | + .eqIfPresent(RoadDO::getGreenBeltTreeArea, reqVO.getGreenBeltTreeArea()) | ||
| 28 | + .eqIfPresent(RoadDO::getGreenBeltArea, reqVO.getGreenBeltArea()) | ||
| 29 | + .eqIfPresent(RoadDO::getTotalArea, reqVO.getTotalArea()) | ||
| 30 | + .eqIfPresent(RoadDO::getTreeArea, reqVO.getTreeArea()) | ||
| 31 | + .eqIfPresent(RoadDO::getStartingLatitude, reqVO.getStartingLatitude()) | ||
| 32 | + .eqIfPresent(RoadDO::getStartingLongitude, reqVO.getStartingLongitude()) | ||
| 33 | + .eqIfPresent(RoadDO::getStartingRemark, reqVO.getStartingRemark()) | ||
| 34 | + .eqIfPresent(RoadDO::getEndLatitude, reqVO.getEndLatitude()) | ||
| 35 | + .eqIfPresent(RoadDO::getEndLongitude, reqVO.getEndLongitude()) | ||
| 36 | + .eqIfPresent(RoadDO::getEndRemark, reqVO.getEndRemark()) | ||
| 37 | + .eqIfPresent(RoadDO::getRemark, reqVO.getRemark()) | ||
| 38 | + .eqIfPresent(RoadDO::getCompanyId, reqVO.getCompanyId()) | ||
| 39 | + .eqIfPresent(RoadDO::getDeptId, reqVO.getDeptId()) | ||
| 40 | + .likeIfPresent(RoadDO::getCreatorName, reqVO.getCreatorName()) | ||
| 41 | + .betweenIfPresent(RoadDO::getCreateTime, reqVO.getCreateTime()) | ||
| 42 | + .likeIfPresent(RoadDO::getUpdaterName, reqVO.getUpdaterName()) | ||
| 43 | + .orderByDesc(RoadDO::getId)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | +} | ||
| 0 | \ No newline at end of file | 47 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/road/RoadMapper.java
| @@ -22,7 +22,10 @@ public interface RoadMapper extends BaseMapperX<RoadDO> { | @@ -22,7 +22,10 @@ public interface RoadMapper extends BaseMapperX<RoadDO> { | ||
| 22 | .likeIfPresent(RoadDO::getRoadName, reqVO.getRoadName()) | 22 | .likeIfPresent(RoadDO::getRoadName, reqVO.getRoadName()) |
| 23 | .eqIfPresent(RoadDO::getStreetId, reqVO.getStreetId()) | 23 | .eqIfPresent(RoadDO::getStreetId, reqVO.getStreetId()) |
| 24 | .likeIfPresent(RoadDO::getStreetName, reqVO.getStreetName()) | 24 | .likeIfPresent(RoadDO::getStreetName, reqVO.getStreetName()) |
| 25 | + .eqIfPresent(RoadDO::getBusiLine, reqVO.getBusiLine()) | ||
| 25 | .eqIfPresent(RoadDO::getLevelId, reqVO.getLevelId()) | 26 | .eqIfPresent(RoadDO::getLevelId, reqVO.getLevelId()) |
| 27 | + .eqIfPresent(RoadDO::getRoadAttr, reqVO.getRoadAttr()) | ||
| 28 | + .eqIfPresent(RoadDO::getDirection, reqVO.getDirection()) | ||
| 26 | .eqIfPresent(RoadDO::getGreenBeltTreeArea, reqVO.getGreenBeltTreeArea()) | 29 | .eqIfPresent(RoadDO::getGreenBeltTreeArea, reqVO.getGreenBeltTreeArea()) |
| 27 | .eqIfPresent(RoadDO::getGreenBeltArea, reqVO.getGreenBeltArea()) | 30 | .eqIfPresent(RoadDO::getGreenBeltArea, reqVO.getGreenBeltArea()) |
| 28 | .eqIfPresent(RoadDO::getTotalArea, reqVO.getTotalArea()) | 31 | .eqIfPresent(RoadDO::getTotalArea, reqVO.getTotalArea()) |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/road/RoadStreetMapper.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.mysql.road; | ||
| 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.road.RoadStreetDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.road.vo.*; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 街道 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 超级管理员 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface RoadStreetMapper extends BaseMapperX<RoadStreetDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<RoadStreetDO> selectPage(RoadStreetPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<RoadStreetDO>() | ||
| 22 | + .eqIfPresent(RoadStreetDO::getStreetId, reqVO.getStreetId()) | ||
| 23 | + .likeIfPresent(RoadStreetDO::getStreetName, reqVO.getStreetName()) | ||
| 24 | + .eqIfPresent(RoadStreetDO::getBusiLine, reqVO.getBusiLine()) | ||
| 25 | + .likeIfPresent(RoadStreetDO::getCreatorName, reqVO.getCreatorName()) | ||
| 26 | + .betweenIfPresent(RoadStreetDO::getCreateTime, reqVO.getCreateTime()) | ||
| 27 | + .likeIfPresent(RoadStreetDO::getUpdaterName, reqVO.getUpdaterName()) | ||
| 28 | + .orderByDesc(RoadStreetDO::getId)); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} | ||
| 0 | \ No newline at end of file | 32 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/road/RoadService.java
| @@ -27,7 +27,7 @@ public interface RoadService { | @@ -27,7 +27,7 @@ public interface RoadService { | ||
| 27 | * | 27 | * |
| 28 | * @param updateReqVO 更新信息 | 28 | * @param updateReqVO 更新信息 |
| 29 | */ | 29 | */ |
| 30 | - void updateRoad(@Valid RoadSaveReqVO updateReqVO); | 30 | + void updateRoad(@Valid RoadUpdateReqVO updateReqVO); |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * 删除道路管理 | 33 | * 删除道路管理 |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/road/RoadServiceImpl.java
| @@ -2,12 +2,15 @@ package com.zteits.urbanops.module.garden.service.road; | @@ -2,12 +2,15 @@ package com.zteits.urbanops.module.garden.service.road; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 5 | +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.mysql.road.RoadInterceptMapper; | ||
| 5 | import org.apache.commons.lang3.StringUtils; | 7 | import org.apache.commons.lang3.StringUtils; |
| 6 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
| 7 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 8 | import org.springframework.validation.annotation.Validated; | 10 | import org.springframework.validation.annotation.Validated; |
| 9 | import org.springframework.transaction.annotation.Transactional; | 11 | import org.springframework.transaction.annotation.Transactional; |
| 10 | 12 | ||
| 13 | +import java.time.LocalDateTime; | ||
| 11 | import java.util.*; | 14 | import java.util.*; |
| 12 | import com.zteits.urbanops.module.garden.controller.admin.road.vo.*; | 15 | import com.zteits.urbanops.module.garden.controller.admin.road.vo.*; |
| 13 | import com.zteits.urbanops.module.garden.dal.dataobject.road.RoadDO; | 16 | import com.zteits.urbanops.module.garden.dal.dataobject.road.RoadDO; |
| @@ -34,10 +37,22 @@ public class RoadServiceImpl implements RoadService { | @@ -34,10 +37,22 @@ public class RoadServiceImpl implements RoadService { | ||
| 34 | @Resource | 37 | @Resource |
| 35 | private RoadMapper roadMapper; | 38 | private RoadMapper roadMapper; |
| 36 | 39 | ||
| 40 | + @Resource | ||
| 41 | + private RoadInterceptMapper roadInterceptMapper; | ||
| 42 | + | ||
| 37 | @Override | 43 | @Override |
| 38 | public Long createRoad(RoadSaveReqVO createReqVO) { | 44 | public Long createRoad(RoadSaveReqVO createReqVO) { |
| 45 | + LocalDateTime now = LocalDateTime.now(); | ||
| 46 | + String userId = SecurityFrameworkUtils.getLoginUserId() + ""; | ||
| 47 | + String userName = SecurityFrameworkUtils.getLoginUserNickname(); | ||
| 39 | // 插入 | 48 | // 插入 |
| 40 | RoadDO road = BeanUtils.toBean(createReqVO, RoadDO.class); | 49 | RoadDO road = BeanUtils.toBean(createReqVO, RoadDO.class); |
| 50 | + road.setCreateTime(now); | ||
| 51 | + road.setCreator(userId); | ||
| 52 | + road.setCreatorName(userName); | ||
| 53 | + road.setUpdateTime(now); | ||
| 54 | + road.setUpdaterName(userName); | ||
| 55 | + road.setUpdater(userId); | ||
| 41 | roadMapper.insert(road); | 56 | roadMapper.insert(road); |
| 42 | 57 | ||
| 43 | // 返回 | 58 | // 返回 |
| @@ -45,9 +60,9 @@ public class RoadServiceImpl implements RoadService { | @@ -45,9 +60,9 @@ public class RoadServiceImpl implements RoadService { | ||
| 45 | } | 60 | } |
| 46 | 61 | ||
| 47 | @Override | 62 | @Override |
| 48 | - public void updateRoad(RoadSaveReqVO updateReqVO) { | 63 | + public void updateRoad(RoadUpdateReqVO updateReqVO) { |
| 49 | // 校验存在 | 64 | // 校验存在 |
| 50 | - validateRoadExists(updateReqVO.getId()); | 65 | + //validateRoadExists(updateReqVO.getId()); |
| 51 | // 更新 | 66 | // 更新 |
| 52 | RoadDO updateObj = BeanUtils.toBean(updateReqVO, RoadDO.class); | 67 | RoadDO updateObj = BeanUtils.toBean(updateReqVO, RoadDO.class); |
| 53 | roadMapper.updateById(updateObj); | 68 | roadMapper.updateById(updateObj); |
| @@ -81,7 +96,7 @@ public class RoadServiceImpl implements RoadService { | @@ -81,7 +96,7 @@ public class RoadServiceImpl implements RoadService { | ||
| 81 | 96 | ||
| 82 | @Override | 97 | @Override |
| 83 | public PageResult<RoadDO> getRoadPage(RoadPageReqVO pageReqVO) { | 98 | public PageResult<RoadDO> getRoadPage(RoadPageReqVO pageReqVO) { |
| 84 | - return roadMapper.selectPage(pageReqVO); | 99 | + return roadInterceptMapper.selectPage(pageReqVO); |
| 85 | } | 100 | } |
| 86 | 101 | ||
| 87 | @Override | 102 | @Override |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/road/RoadStreetService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.road; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | +import jakarta.validation.*; | ||
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.road.vo.*; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.dataobject.road.RoadStreetDO; | ||
| 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 RoadStreetService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建街道 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createRoadStreet(@Valid RoadStreetSaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新街道 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateRoadStreet(@Valid RoadStreetSaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除街道 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteRoadStreet(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 批量删除街道 | ||
| 41 | + * | ||
| 42 | + * @param ids 编号 | ||
| 43 | + */ | ||
| 44 | + void deleteRoadStreetListByIds(List<Long> ids); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得街道 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + * @return 街道 | ||
| 51 | + */ | ||
| 52 | + RoadStreetDO getRoadStreet(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得街道分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return 街道分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<RoadStreetDO> getRoadStreetPage(RoadStreetPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 获得街道 | ||
| 64 | + * | ||
| 65 | + * @param busiLine 编号 | ||
| 66 | + * @return 街道 | ||
| 67 | + */ | ||
| 68 | + List<RoadStreetDO> getRoadStreetList(String busiLine); | ||
| 69 | + | ||
| 70 | +} | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/road/RoadStreetServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.road; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 5 | +import org.springframework.stereotype.Service; | ||
| 6 | +import jakarta.annotation.Resource; | ||
| 7 | +import org.springframework.validation.annotation.Validated; | ||
| 8 | +import org.springframework.transaction.annotation.Transactional; | ||
| 9 | + | ||
| 10 | +import java.util.*; | ||
| 11 | + | ||
| 12 | +import com.zteits.urbanops.module.garden.controller.admin.road.vo.*; | ||
| 13 | +import com.zteits.urbanops.module.garden.dal.dataobject.road.RoadStreetDO; | ||
| 14 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 15 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 16 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 17 | + | ||
| 18 | +import com.zteits.urbanops.module.garden.dal.mysql.road.RoadStreetMapper; | ||
| 19 | + | ||
| 20 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 21 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 22 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 23 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * 街道 Service 实现类 | ||
| 27 | + * | ||
| 28 | + * @author 超级管理员 | ||
| 29 | + */ | ||
| 30 | +@Service | ||
| 31 | +@Validated | ||
| 32 | +public class RoadStreetServiceImpl implements RoadStreetService { | ||
| 33 | + | ||
| 34 | + @Resource | ||
| 35 | + private RoadStreetMapper roadStreetMapper; | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public Long createRoadStreet(RoadStreetSaveReqVO createReqVO) { | ||
| 39 | + // 插入 | ||
| 40 | + RoadStreetDO roadStreet = BeanUtils.toBean(createReqVO, RoadStreetDO.class); | ||
| 41 | + roadStreetMapper.insert(roadStreet); | ||
| 42 | + | ||
| 43 | + // 返回 | ||
| 44 | + return roadStreet.getId(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public void updateRoadStreet(RoadStreetSaveReqVO updateReqVO) { | ||
| 49 | + // 校验存在 | ||
| 50 | + validateRoadStreetExists(updateReqVO.getId()); | ||
| 51 | + // 更新 | ||
| 52 | + RoadStreetDO updateObj = BeanUtils.toBean(updateReqVO, RoadStreetDO.class); | ||
| 53 | + roadStreetMapper.updateById(updateObj); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public void deleteRoadStreet(Long id) { | ||
| 58 | + // 校验存在 | ||
| 59 | + validateRoadStreetExists(id); | ||
| 60 | + // 删除 | ||
| 61 | + roadStreetMapper.deleteById(id); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public void deleteRoadStreetListByIds(List<Long> ids) { | ||
| 66 | + // 删除 | ||
| 67 | + roadStreetMapper.deleteByIds(ids); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + private void validateRoadStreetExists(Long id) { | ||
| 72 | + if (roadStreetMapper.selectById(id) == null) { | ||
| 73 | + //throw exception(ROAD_STREET_NOT_EXISTS); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public RoadStreetDO getRoadStreet(Long id) { | ||
| 79 | + return roadStreetMapper.selectById(id); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public PageResult<RoadStreetDO> getRoadStreetPage(RoadStreetPageReqVO pageReqVO) { | ||
| 84 | + return roadStreetMapper.selectPage(pageReqVO); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + public List<RoadStreetDO> getRoadStreetList(String busiLine) { | ||
| 89 | + QueryWrapper<RoadStreetDO> sql = new QueryWrapper<>(); | ||
| 90 | + sql.lambda().eq(RoadStreetDO::getBusiLine, busiLine).eq(RoadStreetDO::getDeleted,0); | ||
| 91 | + return roadStreetMapper.selectList(sql); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | +} | ||
| 0 | \ No newline at end of file | 95 | \ No newline at end of file |
urbanops-module-garden/src/main/resources/mapper/inspectionplan/InspectionPlanCommitMapper.xml
| @@ -63,6 +63,10 @@ | @@ -63,6 +63,10 @@ | ||
| 63 | <if test="req.roadName != null and req.roadName !=''"> | 63 | <if test="req.roadName != null and req.roadName !=''"> |
| 64 | AND b.road_name LIKE CONCAT(#{req.roadName},'%') | 64 | AND b.road_name LIKE CONCAT(#{req.roadName},'%') |
| 65 | </if> | 65 | </if> |
| 66 | + <if test="req.roleName != null and req.roleName !=''"> | ||
| 67 | + AND a.role_name LIKE CONCAT(#{req.roleName},'%') | ||
| 68 | + </if> | ||
| 69 | + | ||
| 66 | <if test="req.companyId != null"> | 70 | <if test="req.companyId != null"> |
| 67 | and b.company_id = #{req.companyId} | 71 | and b.company_id = #{req.companyId} |
| 68 | </if> | 72 | </if> |
urbanops-module-garden/src/main/resources/mapper/road/RoadInterceptMapper.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.road.RoadInterceptMapper"> | ||
| 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 | \ No newline at end of file | 13 | \ No newline at end of file |
urbanops-module-garden/src/main/resources/mapper/road/RoadStreetMapper.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.road.RoadStreetMapper"> | ||
| 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 | \ No newline at end of file | 13 | \ No newline at end of file |
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/controller/admin/dept/DeptController.java
| @@ -94,12 +94,20 @@ public class DeptController { | @@ -94,12 +94,20 @@ public class DeptController { | ||
| 94 | 94 | ||
| 95 | @GetMapping("/sub-list") | 95 | @GetMapping("/sub-list") |
| 96 | @Operation(summary = "获取二级部门列表") | 96 | @Operation(summary = "获取二级部门列表") |
| 97 | - //@PreAuthorize("@ss.hasPermission('system:dept:query')") | 97 | + @PreAuthorize("@ss.hasPermission('system:dept:query')") |
| 98 | public CommonResult<List<DeptRespVO>> getSubDeptList() { | 98 | public CommonResult<List<DeptRespVO>> getSubDeptList() { |
| 99 | List<DeptDO> list = deptService.getSubDeptList(); | 99 | List<DeptDO> list = deptService.getSubDeptList(); |
| 100 | return success(BeanUtils.toBean(list, DeptRespVO.class)); | 100 | return success(BeanUtils.toBean(list, DeptRespVO.class)); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | + @GetMapping("/last-list") | ||
| 104 | + @Operation(summary = "获取最末级部门列表") | ||
| 105 | + @PreAuthorize("@ss.hasPermission('system:dept:query')") | ||
| 106 | + public CommonResult<List<DeptRespVO>> getLastDeptList(@RequestParam("id") Long id) { | ||
| 107 | + List<DeptDO> list = deptService.getLastDeptList(id); | ||
| 108 | + return success(BeanUtils.toBean(list, DeptRespVO.class)); | ||
| 109 | + } | ||
| 110 | + | ||
| 103 | @GetMapping("/sub-list-id") | 111 | @GetMapping("/sub-list-id") |
| 104 | @Operation(summary = "根据id获取子部门列表") | 112 | @Operation(summary = "根据id获取子部门列表") |
| 105 | @PreAuthorize("@ss.hasPermission('system:dept:query')") | 113 | @PreAuthorize("@ss.hasPermission('system:dept:query')") |
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/service/dept/DeptService.java
| @@ -139,4 +139,9 @@ public interface DeptService { | @@ -139,4 +139,9 @@ public interface DeptService { | ||
| 139 | */ | 139 | */ |
| 140 | List<DeptDO> getSubDeptAllList(); | 140 | List<DeptDO> getSubDeptAllList(); |
| 141 | 141 | ||
| 142 | + /** | ||
| 143 | + * 查询所有最末级部门信息 | ||
| 144 | + * @return 末级list | ||
| 145 | + */ | ||
| 146 | + List<DeptDO> getLastDeptList(Long id); | ||
| 142 | } | 147 | } |
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/service/dept/DeptServiceImpl.java
| @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.system.service.dept; | @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.system.service.dept; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.ObjectUtil; | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 5 | import com.zteits.urbanops.framework.common.enums.CommonStatusEnum; | 6 | import com.zteits.urbanops.framework.common.enums.CommonStatusEnum; |
| 6 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 7 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 7 | import com.zteits.urbanops.framework.datapermission.core.annotation.DataPermission; | 8 | import com.zteits.urbanops.framework.datapermission.core.annotation.DataPermission; |
| @@ -11,6 +12,7 @@ import com.zteits.urbanops.module.system.dal.dataobject.dept.DeptDO; | @@ -11,6 +12,7 @@ import com.zteits.urbanops.module.system.dal.dataobject.dept.DeptDO; | ||
| 11 | import com.zteits.urbanops.module.system.dal.mysql.dept.DeptMapper; | 12 | import com.zteits.urbanops.module.system.dal.mysql.dept.DeptMapper; |
| 12 | import com.zteits.urbanops.module.system.dal.redis.RedisKeyConstants; | 13 | import com.zteits.urbanops.module.system.dal.redis.RedisKeyConstants; |
| 13 | import com.google.common.annotations.VisibleForTesting; | 14 | import com.google.common.annotations.VisibleForTesting; |
| 15 | +import com.zteits.urbanops.module.system.util.DeptTreeUtil; | ||
| 14 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.springframework.cache.annotation.CacheEvict; | 17 | import org.springframework.cache.annotation.CacheEvict; |
| 16 | import org.springframework.cache.annotation.Cacheable; | 18 | import org.springframework.cache.annotation.Cacheable; |
| @@ -247,6 +249,14 @@ public class DeptServiceImpl implements DeptService { | @@ -247,6 +249,14 @@ public class DeptServiceImpl implements DeptService { | ||
| 247 | 249 | ||
| 248 | @Override | 250 | @Override |
| 249 | public List<DeptDO> getSubDeptAllList() { | 251 | public List<DeptDO> getSubDeptAllList() { |
| 250 | - return deptMapper.selectList(); | 252 | + QueryWrapper<DeptDO> sql = new QueryWrapper<>(); |
| 253 | + sql.lambda().eq(DeptDO::getDeleted, 0); | ||
| 254 | + return deptMapper.selectList(sql); | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + @Override | ||
| 258 | + public List<DeptDO> getLastDeptList(Long id) { | ||
| 259 | + List<DeptDO> allList = getSubDeptAllList(); | ||
| 260 | + return DeptTreeUtil.findLeafDeptDOs(allList, id); | ||
| 251 | } | 261 | } |
| 252 | } | 262 | } |
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/util/DeptTreeUtil.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.system.util; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.module.system.dal.dataobject.dept.DeptDO; | ||
| 4 | + | ||
| 5 | +import java.util.*; | ||
| 6 | +import java.util.stream.Collectors; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 部门树形结构工具类 | ||
| 10 | + */ | ||
| 11 | +public class DeptTreeUtil { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 预构建parentId -> 子部门列表的映射(提升查找效率) | ||
| 15 | + * @param allDeptDOs 全量部门列表 | ||
| 16 | + * @return 父ID映射表 | ||
| 17 | + */ | ||
| 18 | + private static Map<Long, List<DeptDO>> buildParentDeptDOMap(List<DeptDO> allDeptDOs) { | ||
| 19 | + return allDeptDOs.stream() | ||
| 20 | + .collect(Collectors.groupingBy(DeptDO::getParentId, Collectors.toList())); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + // ==================== 1. 查找指定部门的所有下级节点(所有层级) ==================== | ||
| 24 | + /** | ||
| 25 | + * 迭代式(广度优先)查找所有下级节点(避免递归栈溢出) | ||
| 26 | + * @param allDeptDOs 全量部门列表 | ||
| 27 | + * @param parentDeptDOId 目标父部门ID | ||
| 28 | + * @return 所有下级部门列表 | ||
| 29 | + */ | ||
| 30 | + public static List<DeptDO> findAllChildrenDeptDOs(List<DeptDO> allDeptDOs, Long parentDeptDOId) { | ||
| 31 | + if (allDeptDOs == null || allDeptDOs.isEmpty() || parentDeptDOId == null) { | ||
| 32 | + return Collections.emptyList(); | ||
| 33 | + } | ||
| 34 | + // 预构建父ID映射表 | ||
| 35 | + Map<Long, List<DeptDO>> parentDeptDOMap = buildParentDeptDOMap(allDeptDOs); | ||
| 36 | + | ||
| 37 | + List<DeptDO> result = new ArrayList<>(); | ||
| 38 | + Queue<Long> queue = new LinkedList<>(); | ||
| 39 | + queue.offer(parentDeptDOId); | ||
| 40 | + | ||
| 41 | + while (!queue.isEmpty()) { | ||
| 42 | + Long currentParentId = queue.poll(); | ||
| 43 | + // 获取当前父ID的直接子节点 | ||
| 44 | + List<DeptDO> directChildren = parentDeptDOMap.getOrDefault(currentParentId, Collections.emptyList()); | ||
| 45 | + result.addAll(directChildren); | ||
| 46 | + // 子节点ID入队,继续遍历其子节点 | ||
| 47 | + directChildren.forEach(child -> queue.offer(child.getId())); | ||
| 48 | + } | ||
| 49 | + return result; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + // ==================== 2. 查找指定部门下的最末端部门(叶子节点) ==================== | ||
| 53 | + /** | ||
| 54 | + * 迭代式查找最末端部门(无下级的部门) | ||
| 55 | + * @param allDeptDOs 全量部门列表 | ||
| 56 | + * @param parentDeptId 目标父部门ID | ||
| 57 | + * @return 所有叶子节点部门 | ||
| 58 | + */ | ||
| 59 | + public static List<DeptDO> findLeafDeptDOs(List<DeptDO> allDeptDOs, Long parentDeptId) { | ||
| 60 | + if (allDeptDOs == null || allDeptDOs.isEmpty() || parentDeptId == null) { | ||
| 61 | + return Collections.emptyList(); | ||
| 62 | + } | ||
| 63 | + // 预构建父ID映射表(判断是否有子节点的核心) | ||
| 64 | + Map<Long, List<DeptDO>> parentDeptDOMap = buildParentDeptDOMap(allDeptDOs); | ||
| 65 | + | ||
| 66 | + List<DeptDO> leafDeptDOs = new ArrayList<>(); | ||
| 67 | + Queue<Long> queue = new LinkedList<>(); | ||
| 68 | + queue.offer(parentDeptId); | ||
| 69 | + | ||
| 70 | + while (!queue.isEmpty()) { | ||
| 71 | + Long currentParentId = queue.poll(); | ||
| 72 | + List<DeptDO> directChildren = parentDeptDOMap.getOrDefault(currentParentId, Collections.emptyList()); | ||
| 73 | + | ||
| 74 | + for (DeptDO child : directChildren) { | ||
| 75 | + // 判断当前子节点是否有下级:无则为叶子节点 | ||
| 76 | + if (!parentDeptDOMap.containsKey(child.getId()) || parentDeptDOMap.get(child.getId()).isEmpty()) { | ||
| 77 | + leafDeptDOs.add(child); | ||
| 78 | + } else { | ||
| 79 | + // 有下级则继续遍历 | ||
| 80 | + queue.offer(child.getId()); | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + return leafDeptDOs; | ||
| 85 | + } | ||
| 86 | +} | ||
| 0 | \ No newline at end of file | 87 | \ No newline at end of file |