Commit 75729b30d207fb9c2112533376bc42318b46325c

Authored by wangqian
1 parent 00a1a559

耗材基础迁移

Showing 18 changed files with 642 additions and 387 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/MaterialTypeController.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.material;
  2 +
  3 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypePageReqVO;
  4 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypeRespVO;
  5 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypeSaveReqVO;
  6 +import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
  7 +import com.zteits.urbanops.module.garden.service.material.MaterialTypeService;
  8 +import org.springframework.web.bind.annotation.*;
  9 +import jakarta.annotation.Resource;
  10 +import org.springframework.validation.annotation.Validated;
  11 +import org.springframework.security.access.prepost.PreAuthorize;
  12 +import io.swagger.v3.oas.annotations.tags.Tag;
  13 +import io.swagger.v3.oas.annotations.Parameter;
  14 +import io.swagger.v3.oas.annotations.Operation;
  15 +
  16 +import jakarta.validation.*;
  17 +import jakarta.servlet.http.*;
  18 +import java.util.*;
  19 +import java.io.IOException;
  20 +
  21 +import com.zteits.urbanops.framework.common.pojo.PageParam;
  22 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  23 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
  24 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  25 +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
  26 +
  27 +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;
  28 +
  29 +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
  30 +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*;
  31 +
  32 +@Tag(name = "管理后台 - 物料类型")
  33 +@RestController
  34 +@RequestMapping("/garden/material-type")
  35 +@Validated
  36 +public class MaterialTypeController {
  37 +
  38 + @Resource
  39 + private MaterialTypeService materialTypeService;
  40 +
  41 + @PostMapping("/create")
  42 + @Operation(summary = "创建物料类型")
  43 + @PreAuthorize("@ss.hasPermission('garden:material-type:create')")
  44 + public CommonResult<Long> createMaterialType(@Valid @RequestBody MaterialTypeSaveReqVO createReqVO) {
  45 + return success(materialTypeService.createMaterialType(createReqVO));
  46 + }
  47 +
  48 + @PutMapping("/update")
  49 + @Operation(summary = "更新物料类型")
  50 + @PreAuthorize("@ss.hasPermission('garden:material-type:update')")
  51 + public CommonResult<Boolean> updateMaterialType(@Valid @RequestBody MaterialTypeSaveReqVO updateReqVO) {
  52 + materialTypeService.updateMaterialType(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:material-type:delete')")
  60 + public CommonResult<Boolean> deleteMaterialType(@RequestParam("id") Long id) {
  61 + materialTypeService.deleteMaterialType(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:material-type:delete')")
  69 + public CommonResult<Boolean> deleteMaterialTypeList(@RequestParam("ids") List<Long> ids) {
  70 + materialTypeService.deleteMaterialTypeListByIds(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:material-type:query')")
  78 + public CommonResult<MaterialTypeRespVO> getMaterialType(@RequestParam("id") Long id) {
  79 + MaterialTypeDO materialType = materialTypeService.getMaterialType(id);
  80 + return success(BeanUtils.toBean(materialType, MaterialTypeRespVO.class));
  81 + }
  82 +
  83 + @GetMapping("/page")
  84 + @Operation(summary = "获得物料类型分页")
  85 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  86 + public CommonResult<PageResult<MaterialTypeRespVO>> getMaterialTypePage(@Valid MaterialTypePageReqVO pageReqVO) {
  87 + PageResult<MaterialTypeDO> pageResult = materialTypeService.getMaterialTypePage(pageReqVO);
  88 + return success(BeanUtils.toBean(pageResult, MaterialTypeRespVO.class));
  89 + }
  90 +
  91 + @GetMapping("/export-excel")
  92 + @Operation(summary = "导出物料类型 Excel")
  93 + @PreAuthorize("@ss.hasPermission('garden:material-type:export')")
  94 + @ApiAccessLog(operateType = EXPORT)
  95 + public void exportMaterialTypeExcel(@Valid MaterialTypePageReqVO pageReqVO,
  96 + HttpServletResponse response) throws IOException {
  97 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  98 + List<MaterialTypeDO> list = materialTypeService.getMaterialTypePage(pageReqVO).getList();
  99 + // 导出 Excel
  100 + ExcelUtils.write(response, "物料类型.xls", "数据", MaterialTypeRespVO.class,
  101 + BeanUtils.toBean(list, MaterialTypeRespVO.class));
  102 + }
  103 +
  104 +
  105 + /**
  106 + * 获取物料类型详细信息
  107 + */
  108 + @Operation(summary ="物料类型基础表-耗材类型List")
  109 + @GetMapping(value = "/getMaterialBigTypeList")
  110 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  111 + public CommonResult getInfo() {
  112 + return success(materialTypeService.queryMaterialBigType(null));
  113 + }
  114 +
  115 + /**
  116 + * 获取物料类型详细信息
  117 + */
  118 + @Operation(summary ="物料类型基础表-类别List")
  119 + @GetMapping(value = "/getMaterialMidTypeList")
  120 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  121 + public CommonResult getMaterialMidTypeList(@RequestParam("material_type_id") Long materialTypeId) {
  122 + return success(materialTypeService.queryMaterialMidType(materialTypeId));
  123 + }
  124 +
  125 + /**
  126 + * 获取物料类型详细信息
  127 + */
  128 + @Operation(summary ="物料类型基础表-类别List")
  129 + @GetMapping(value = "/getMaterialDetailTypeList")
  130 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  131 + public CommonResult getMaterialDetailTypeList(@RequestParam("parent_type_id") Long parentTypeId) {
  132 + return success(materialTypeService.queryMaterialDetailType(parentTypeId));
  133 + }
  134 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialTypePageReqVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.material.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 MaterialTypePageReqVO extends PageParam {
  15 +
  16 + @Schema(description = "物料类型ID", example = "31914")
  17 + private Long materialTypeId;
  18 +
  19 + @Schema(description = "耗材类型名称:工具", example = "赵六")
  20 + private String materialTypeName;
  21 +
  22 + @Schema(description = "类别ID", example = "13166")
  23 + private Long typeId;
  24 +
  25 + @Schema(description = "类别名称:药品", example = "李四")
  26 + private String typeName;
  27 +
  28 + @Schema(description = "付物料类型ID", example = "4908")
  29 + private Long materialParentTypeId;
  30 +
  31 + @Schema(description = "类别明细ID", example = "2459")
  32 + private Long typeDetailId;
  33 +
  34 + @Schema(description = "类别明细", example = "赵六")
  35 + private String typeDetailName;
  36 +
  37 + @Schema(description = "父类别ID", example = "6341")
  38 + private Long parentTypeId;
  39 +
  40 + @Schema(description = "备注", example = "你猜")
  41 + private String remark;
  42 +
  43 + @Schema(description = "状态(0正常 1停用)", example = "2")
  44 + private String status;
  45 +
  46 + @Schema(description = "创建者")
  47 + private String createBy;
  48 +
  49 + @Schema(description = "创建时间")
  50 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  51 + private LocalDateTime[] createTime;
  52 +
  53 + @Schema(description = "更新者")
  54 + private String updateBy;
  55 +
  56 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialTypeResp.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.material.vo;
  2 +
  3 +/**
  4 + * Copyright: Copyright (c) 2017 zteits
  5 + *
  6 + * @ClassName: MaterialTypeManagerResp.java
  7 + * @Description:
  8 + * @version: v1.0.0
  9 + * @author: wangfs
  10 + * @date: 2024-11-10 13:50
  11 + * Modification History:
  12 + * Date Author Version Description
  13 + * ---------------------------------------------------------*
  14 + * 2024-11-10 wangfs v1.0.0 创建
  15 + */
  16 +
  17 +public class MaterialTypeResp {
  18 +
  19 + private Long value;
  20 +
  21 + private String label;
  22 +
  23 + public Long getValue() {
  24 + return value;
  25 + }
  26 +
  27 + public void setValue(Long value) {
  28 + this.value = value;
  29 + }
  30 +
  31 + public String getLabel() {
  32 + return label;
  33 + }
  34 +
  35 + public void setLabel(String label) {
  36 + this.label = label;
  37 + }
  38 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialTypeRespVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.material.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 MaterialTypeRespVO {
  14 +
  15 + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "23621")
  16 + @ExcelProperty("物料ID")
  17 + private Long id;
  18 +
  19 + @Schema(description = "物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31914")
  20 + @ExcelProperty("物料类型ID")
  21 + private Long materialTypeId;
  22 +
  23 + @Schema(description = "耗材类型名称:工具", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  24 + @ExcelProperty("耗材类型名称:工具")
  25 + private String materialTypeName;
  26 +
  27 + @Schema(description = "类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13166")
  28 + @ExcelProperty("类别ID")
  29 + private Long typeId;
  30 +
  31 + @Schema(description = "类别名称:药品", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  32 + @ExcelProperty("类别名称:药品")
  33 + private String typeName;
  34 +
  35 + @Schema(description = "付物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4908")
  36 + @ExcelProperty("付物料类型ID")
  37 + private Long materialParentTypeId;
  38 +
  39 + @Schema(description = "类别明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2459")
  40 + @ExcelProperty("类别明细ID")
  41 + private Long typeDetailId;
  42 +
  43 + @Schema(description = "类别明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  44 + @ExcelProperty("类别明细")
  45 + private String typeDetailName;
  46 +
  47 + @Schema(description = "父类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6341")
  48 + @ExcelProperty("父类别ID")
  49 + private Long parentTypeId;
  50 +
  51 + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
  52 + @ExcelProperty("备注")
  53 + private String remark;
  54 +
  55 + @Schema(description = "状态(0正常 1停用)", example = "2")
  56 + @ExcelProperty("状态(0正常 1停用)")
  57 + private String status;
  58 +
  59 + @Schema(description = "创建者")
  60 + @ExcelProperty("创建者")
  61 + private String createBy;
  62 +
  63 + @Schema(description = "创建时间")
  64 + @ExcelProperty("创建时间")
  65 + private LocalDateTime createTime;
  66 +
  67 + @Schema(description = "更新者")
  68 + @ExcelProperty("更新者")
  69 + private String updateBy;
  70 +
  71 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialTypeSaveReqVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.garden.controller.admin.material.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 MaterialTypeSaveReqVO {
  11 +
  12 + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "23621")
  13 + private Long id;
  14 +
  15 + @Schema(description = "物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31914")
  16 + @NotNull(message = "物料类型ID不能为空")
  17 + private Long materialTypeId;
  18 +
  19 + @Schema(description = "耗材类型名称:工具", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  20 + @NotEmpty(message = "耗材类型名称:工具不能为空")
  21 + private String materialTypeName;
  22 +
  23 + @Schema(description = "类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13166")
  24 + @NotNull(message = "类别ID不能为空")
  25 + private Long typeId;
  26 +
  27 + @Schema(description = "类别名称:药品", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  28 + @NotEmpty(message = "类别名称:药品不能为空")
  29 + private String typeName;
  30 +
  31 + @Schema(description = "付物料类型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4908")
  32 + private Long materialParentTypeId;
  33 +
  34 + @Schema(description = "类别明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2459")
  35 + private Long typeDetailId;
  36 +
  37 + @Schema(description = "类别明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  38 + @NotEmpty(message = "类别明细不能为空")
  39 + private String typeDetailName;
  40 +
  41 + @Schema(description = "父类别ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6341")
  42 + private Long parentTypeId;
  43 +
  44 + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
  45 + private String remark;
  46 +
  47 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialtype/MaterialTypeAdminController.java deleted
1   -package com.zteits.urbanops.module.garden.controller.admin.materialtype;
2   -
3   -import com.zteits.urbanops.framework.common.pojo.CommonResult;
4   -import com.zteits.urbanops.framework.common.pojo.PageParam;
5   -import com.zteits.urbanops.framework.common.pojo.PageResult;
6   -import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
7   -import com.zteits.urbanops.module.garden.dal.mysql.material.MaterialTypeMapper;
8   -import io.swagger.v3.oas.annotations.Operation;
9   -import io.swagger.v3.oas.annotations.tags.Tag;
10   -import jakarta.annotation.Resource;
11   -import org.springframework.security.access.prepost.PreAuthorize;
12   -import org.springframework.web.bind.annotation.*;
13   -
14   -import java.util.List;
15   -
16   -import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
17   -
18   -@Tag(name = "管理后台 - 物料类型")
19   -@RestController
20   -@RequestMapping("/materialType/type")
21   -public class MaterialTypeAdminController {
22   -
23   - @Resource
24   - private MaterialTypeMapper mapper;
25   -
26   - @GetMapping("/getMaterialBigTypeList")
27   - @Operation(summary = "物料类型-大类列表")
28   - @PreAuthorize("@ss.hasPermission('material:type:list')")
29   - public CommonResult<List<MaterialTypeDO>> getMaterialBigTypeList() {
30   - return success(mapper.selectBigTypeList());
31   - }
32   -
33   - @PostMapping("/listForPage")
34   - @Operation(summary = "物料类型-分页")
35   - @PreAuthorize("@ss.hasPermission('material:type:list')")
36   - public CommonResult<PageResult<MaterialTypeDO>> listForPage(@RequestBody MaterialTypeDO where,
37   - @RequestParam(value = "pageNum", required = false) Integer pageNum,
38   - @RequestParam(value = "pageSize", required = false) Integer pageSize) {
39   - PageParam page = new PageParam();
40   - page.setPageNo(pageNum == null ? 1 : pageNum);
41   - page.setPageSize(pageSize == null ? 10 : pageSize);
42   - return success(mapper.selectPage(page, where));
43   - }
44   -}
45 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/app/AppMaterialTypeController.java deleted
1   -package com.zteits.urbanops.module.garden.controller.app;
2   -
3   -import com.zteits.urbanops.framework.common.pojo.CommonResult;
4   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypeManagerRespVO;
5   -import com.zteits.urbanops.module.garden.service.material.MaterialTypeService;
6   -import io.swagger.v3.oas.annotations.Operation;
7   -import io.swagger.v3.oas.annotations.tags.Tag;
8   -import jakarta.annotation.Resource;
9   -import org.springframework.web.bind.annotation.GetMapping;
10   -import org.springframework.web.bind.annotation.RequestMapping;
11   -import org.springframework.web.bind.annotation.RequestParam;
12   -import org.springframework.web.bind.annotation.RestController;
13   -
14   -import java.util.List;
15   -
16   -import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
17   -
18   -@Tag(name = "APP - 物料类型")
19   -@RestController
20   -@RequestMapping("/app/materialType/type")
21   -public class AppMaterialTypeController {
22   -
23   - @Resource
24   - private MaterialTypeService materialTypeService;
25   -
26   - @GetMapping("/getMaterialBigTypeList")
27   - @Operation(summary = "物料类型基础表-耗材类型List")
28   - public CommonResult<List<MaterialTypeManagerRespVO>> getMaterialBigTypeList() {
29   - return success(materialTypeService.queryMaterialBigType(30000L));
30   - }
31   -
32   - @GetMapping("/getMaterialMidTypeList")
33   - @Operation(summary = "物料类型基础表-类别List")
34   - public CommonResult<List<MaterialTypeManagerRespVO>> getMaterialMidTypeList(@RequestParam("material_type_id") Long materialTypeId) {
35   - return success(materialTypeService.queryMaterialMidType(materialTypeId));
36   - }
37   -
38   - @GetMapping("/getMaterialDetailTypeList")
39   - @Operation(summary = "物料类型基础表-类别明细List")
40   - public CommonResult<List<MaterialTypeManagerRespVO>> getMaterialDetailTypeList(@RequestParam("parent_type_id") Long parentTypeId) {
41   - return success(materialTypeService.queryMaterialDetailType(parentTypeId));
42   - }
43   -}
44 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/business/MaterialTypeController.java deleted
1   -package com.zteits.urbanops.module.garden.controller.business;
2   -
3   -import cn.hutool.core.bean.BeanUtil;
4   -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5   -import com.zteits.urbanops.framework.common.pojo.CommonResult;
6   -import com.zteits.urbanops.framework.common.pojo.PageResult;
7   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypeAddReqVO;
8   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypeEditReqVO;
9   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypeManagerRespVO;
10   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypePageReqVO;
11   -import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
12   -import com.zteits.urbanops.module.garden.service.material.MaterialTypeService;
13   -import io.swagger.v3.oas.annotations.Operation;
14   -import io.swagger.v3.oas.annotations.tags.Tag;
15   -import jakarta.annotation.Resource;
16   -import jakarta.validation.Valid;
17   -import org.springframework.web.bind.annotation.*;
18   -
19   -import java.time.LocalDateTime;
20   -import java.util.List;
21   -
22   -import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
23   -
24   -@Tag(name = "园林养护 - 物料类型")
25   -@RestController
26   -@RequestMapping("/materialType/type")
27   -public class MaterialTypeController {
28   -
29   - @Resource
30   - private MaterialTypeService materialTypeService;
31   -
32   - @GetMapping("/getMaterialBigTypeList")
33   - @Operation(summary = "物料类型基础表-耗材类型List")
34   - public CommonResult<List<MaterialTypeManagerRespVO>> getMaterialBigTypeList() {
35   - return success(materialTypeService.queryMaterialBigType(null));
36   - }
37   -
38   - @GetMapping("/getMaterialMidTypeList")
39   - @Operation(summary = "物料类型基础表-类别List")
40   - public CommonResult<List<MaterialTypeManagerRespVO>> getMaterialMidTypeList(@RequestParam("material_type_id") Long materialTypeId) {
41   - return success(materialTypeService.queryMaterialMidType(materialTypeId));
42   - }
43   -
44   - @GetMapping("/getMaterialDetailTypeList")
45   - @Operation(summary = "物料类型基础表-类别明细List")
46   - public CommonResult<List<MaterialTypeManagerRespVO>> getMaterialDetailTypeList(@RequestParam("parent_type_id") Long parentTypeId) {
47   - return success(materialTypeService.queryMaterialDetailType(parentTypeId));
48   - }
49   -
50   - @PostMapping("/listForPage")
51   - @Operation(summary = "耗材基础-分页")
52   - public CommonResult<PageResult<MaterialTypeDO>> listForPage(@Valid @RequestBody MaterialTypePageReqVO reqVO) {
53   - MaterialTypeDO where = new MaterialTypeDO();
54   - String keyword = reqVO.getTypeName();
55   - if (keyword == null || keyword.isEmpty()) {
56   - keyword = reqVO.getMaterialTypeName();
57   - }
58   - if (keyword == null || keyword.isEmpty()) {
59   - keyword = reqVO.getTypeDetailName();
60   - }
61   - where.setTypeName(keyword);
62   - Page<MaterialTypeDO> page = materialTypeService.selectPage(new Page<>(reqVO.getPageNum(), reqVO.getPageSize()), where);
63   - return success(new PageResult<>(page.getRecords(), page.getTotal()));
64   - }
65   -
66   - @PostMapping("/add")
67   - @Operation(summary = "耗材基础-添加")
68   - public CommonResult<Boolean> add(@Valid @RequestBody MaterialTypeAddReqVO reqVO) {
69   - MaterialTypeDO entity = new MaterialTypeDO();
70   - entity.setTypeName(reqVO.getTypeDetailName());
71   - entity.setParentId(reqVO.getTypeId());
72   - entity.setLevel(3);
73   - entity.setCreator("system");
74   - entity.setUpdater("system");
75   - return success(materialTypeService.insert(entity));
76   - }
77   -
78   - @PostMapping("/edit")
79   - @Operation(summary = "耗材基础-修改")
80   - public CommonResult<Boolean> edit(@Valid @RequestBody MaterialTypeEditReqVO reqVO) {
81   - MaterialTypeDO entity = new MaterialTypeDO();
82   - BeanUtil.copyProperties(reqVO, entity, true);
83   - return success(materialTypeService.update(entity));
84   - }
85   -
86   - @GetMapping("/deleteById")
87   - @Operation(summary = "耗材基础-删除")
88   - public CommonResult<Boolean> deleteById(@RequestParam("id") Long id) {
89   - return success(materialTypeService.deleteById(id));
90   - }
91   -}
92 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/business/vo/MaterialTypeAddReqVO.java deleted
1   -package com.zteits.urbanops.module.garden.controller.business.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   -@Data
9   -public class MaterialTypeAddReqVO {
10   - @Schema(description = "物料类型ID")
11   - @NotNull
12   - private Long materialTypeId;
13   -
14   - @Schema(description = "耗材类型名称")
15   - @NotEmpty
16   - private String materialTypeName;
17   -
18   - @Schema(description = "类别ID")
19   - @NotNull
20   - private Long typeId;
21   -
22   - @Schema(description = "类别名称")
23   - @NotEmpty
24   - private String typeName;
25   -
26   - @Schema(description = "类别明细")
27   - @NotEmpty
28   - private String typeDetailName;
29   -}
30 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/business/vo/MaterialTypeEditReqVO.java deleted
1   -package com.zteits.urbanops.module.garden.controller.business.vo;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import jakarta.validation.constraints.NotNull;
5   -import lombok.Data;
6   -
7   -@Data
8   -public class MaterialTypeEditReqVO {
9   - @NotNull
10   - private Long id;
11   -
12   - @Schema(description = "物料类型ID")
13   - private Long materialTypeId;
14   -
15   - @Schema(description = "耗材类型名称")
16   - private String materialTypeName;
17   -
18   - @Schema(description = "类别ID")
19   - private Long typeId;
20   -
21   - @Schema(description = "类别名称")
22   - private String typeName;
23   -
24   - @Schema(description = "类别明细ID")
25   - private Long typeDetailId;
26   -
27   - @Schema(description = "类别明细")
28   - private String typeDetailName;
29   -
30   - private Long materialParentTypeId;
31   -
32   - private Long parentTypeId;
33   -
34   - private String status;
35   -
36   - private String remark;
37   -}
38 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/business/vo/MaterialTypeManagerRespVO.java deleted
1   -package com.zteits.urbanops.module.garden.controller.business.vo;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class MaterialTypeManagerRespVO {
7   - private Long value;
8   - private String label;
9   - private Long materialParentTypeId;
10   - private Long parentTypeId;
11   -}
12 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/business/vo/MaterialTypePageReqVO.java deleted
1   -package com.zteits.urbanops.module.garden.controller.business.vo;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -
6   -@Data
7   -public class MaterialTypePageReqVO {
8   -
9   - @Schema(description = "页码")
10   - private Integer pageNum = 1;
11   -
12   - @Schema(description = "每页数量")
13   - private Integer pageSize = 10;
14   -
15   - private String materialTypeName;
16   - private String typeName;
17   - private String typeDetailName;
18   -}
19 0 \ No newline at end of file
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/material/MaterialTypeDO.java
1 1 package com.zteits.urbanops.module.garden.dal.dataobject.material;
2 2  
3   -import com.baomidou.mybatisplus.annotation.TableId;
4   -import com.baomidou.mybatisplus.annotation.TableName;
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.*;
5 8 import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO;
6   -import lombok.Data;
7 9  
  10 +/**
  11 + * 物料类型 DO
  12 + *
  13 + * @author 超级管理员
  14 + */
8 15 @TableName("garden_material_type")
  16 +@KeySequence("garden_material_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
9 17 @Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
10 23 public class MaterialTypeDO extends BaseDO {
  24 +
  25 + /**
  26 + * 物料ID
  27 + */
11 28 @TableId
12 29 private Long id;
  30 + /**
  31 + * 物料类型ID
  32 + */
  33 + private Long materialTypeId;
  34 + /**
  35 + * 耗材类型名称:工具
  36 + */
  37 + private String materialTypeName;
  38 + /**
  39 + * 类别ID
  40 + */
  41 + private Long typeId;
  42 + /**
  43 + * 类别名称:药品
  44 + */
13 45 private String typeName;
14   - private Long parentId;
15   - private Integer level;
16   -}
17 46 \ No newline at end of file
  47 + /**
  48 + * 付物料类型ID
  49 + */
  50 + private Long materialParentTypeId;
  51 + /**
  52 + * 类别明细ID
  53 + */
  54 + private Long typeDetailId;
  55 + /**
  56 + * 类别明细
  57 + */
  58 + private String typeDetailName;
  59 + /**
  60 + * 父类别ID
  61 + */
  62 + private Long parentTypeId;
  63 + /**
  64 + * 备注
  65 + */
  66 + private String remark;
  67 + /**
  68 + * 状态(0正常 1停用)
  69 + */
  70 + private String status;
  71 + /**
  72 + * 创建者
  73 + */
  74 + private String creator;
  75 + /**
  76 + * 更新者
  77 + */
  78 + private String updater;
  79 +
  80 +
  81 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/material/MaterialTypeMapper.java
1 1 package com.zteits.urbanops.module.garden.dal.mysql.material;
2 2  
3   -import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
  3 +import com.zteits.urbanops.framework.common.pojo.PageResult;
4 4 import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX;
  5 +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX;
  6 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypePageReqVO;
5 7 import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
6 8 import org.apache.ibatis.annotations.Mapper;
7 9  
8   -import java.util.List;
9   -
  10 +/**
  11 + * 物料类型 Mapper
  12 + *
  13 + * @author 超级管理员
  14 + */
10 15 @Mapper
11 16 public interface MaterialTypeMapper extends BaseMapperX<MaterialTypeDO> {
12   - default List<MaterialTypeDO> selectBigTypeList() {
13   - return selectList(new LambdaQueryWrapperX<MaterialTypeDO>().eq(MaterialTypeDO::getLevel, 1).orderByAsc(MaterialTypeDO::getTypeName));
14   - }
15 17  
16   - default com.zteits.urbanops.framework.common.pojo.PageResult<MaterialTypeDO> selectPage(com.zteits.urbanops.framework.common.pojo.PageParam pageParam, MaterialTypeDO where) {
17   - return selectPage(pageParam, null, new LambdaQueryWrapperX<MaterialTypeDO>()
18   - .likeIfPresent(MaterialTypeDO::getTypeName, where.getTypeName())
19   - .eqIfPresent(MaterialTypeDO::getParentId, where.getParentId())
20   - .orderByAsc(MaterialTypeDO::getTypeName));
  18 + default PageResult<MaterialTypeDO> selectPage(MaterialTypePageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MaterialTypeDO>()
  20 + .likeIfPresent(MaterialTypeDO::getTypeName, reqVO.getTypeName())
  21 + .orderByDesc(MaterialTypeDO::getTypeName));
21 22 }
22   -}
23 23 \ No newline at end of file
  24 +
  25 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
... ... @@ -72,4 +72,5 @@ public interface ErrorCodeConstants {
72 72 ErrorCode PLAN_RATE_EXISTS = new ErrorCode(1-200-200-001, "养护频次已存在");
73 73 ErrorCode PLAN_RATE_LEVEL_ID_DUPLICATE = new ErrorCode(1-200-200-002, "养护等级重复");
74 74  
  75 + ErrorCode MATERIAL_TYPE_NOT_EXISTS = new ErrorCode(1-100-004-001, "物料类型不存在");
75 76 }
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/material/MaterialTypeService.java
1 1 package com.zteits.urbanops.module.garden.service.material;
2 2  
3   -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypeManagerRespVO;
5   -import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
  3 +import java.util.*;
6 4  
7   -import java.util.List;
  5 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypePageReqVO;
  6 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypeResp;
  7 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypeSaveReqVO;
  8 +import jakarta.validation.*;
  9 +import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
  10 +import com.zteits.urbanops.framework.common.pojo.PageResult;
8 11  
  12 +/**
  13 + * 物料类型 Service 接口
  14 + *
  15 + * @author 超级管理员
  16 + */
9 17 public interface MaterialTypeService {
10 18  
11   - MaterialTypeDO get(Long id);
  19 + /**
  20 + * 创建物料类型
  21 + *
  22 + * @param createReqVO 创建信息
  23 + * @return 编号
  24 + */
  25 + Long createMaterialType(@Valid MaterialTypeSaveReqVO createReqVO);
12 26  
13   - List<MaterialTypeDO> selectList(MaterialTypeDO req);
  27 + /**
  28 + * 更新物料类型
  29 + *
  30 + * @param updateReqVO 更新信息
  31 + */
  32 + void updateMaterialType(@Valid MaterialTypeSaveReqVO updateReqVO);
14 33  
15   - Page<MaterialTypeDO> selectPage(Page<MaterialTypeDO> page, MaterialTypeDO req);
  34 + /**
  35 + * 删除物料类型
  36 + *
  37 + * @param id 编号
  38 + */
  39 + void deleteMaterialType(Long id);
16 40  
17   - boolean insert(MaterialTypeDO entity);
  41 + /**
  42 + * 批量删除物料类型
  43 + *
  44 + * @param ids 编号
  45 + */
  46 + void deleteMaterialTypeListByIds(List<Long> ids);
18 47  
19   - boolean update(MaterialTypeDO entity);
  48 + /**
  49 + * 获得物料类型
  50 + *
  51 + * @param id 编号
  52 + * @return 物料类型
  53 + */
  54 + MaterialTypeDO getMaterialType(Long id);
20 55  
21   - boolean deleteById(Long id);
  56 + /**
  57 + * 获得物料类型分页
  58 + *
  59 + * @param pageReqVO 分页查询
  60 + * @return 物料类型分页
  61 + */
  62 + PageResult<MaterialTypeDO> getMaterialTypePage(MaterialTypePageReqVO pageReqVO);
22 63  
23   - List<MaterialTypeManagerRespVO> queryMaterialBigType(Long materialTypeId);
  64 + List<MaterialTypeResp> queryMaterialBigType(Long materialTypeId);
24 65  
25   - List<MaterialTypeManagerRespVO> queryMaterialMidType(Long materialTypeId);
  66 + List<MaterialTypeResp> queryMaterialMidType(Long materialTypeId);
26 67  
27   - List<MaterialTypeManagerRespVO> queryMaterialDetailType(Long parentTypeId);
  68 + List<MaterialTypeResp> queryMaterialDetailType(Long parentTypeId);
28 69  
29 70 Long selectMaxTypeDetailId(Long materialTypeId, Long typeId);
30   -}
31 71 \ No newline at end of file
  72 +
  73 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/material/MaterialTypeServiceImpl.java
1 1 package com.zteits.urbanops.module.garden.service.material;
2 2  
3 3 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4   -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5   -import com.zteits.urbanops.module.garden.controller.business.vo.MaterialTypeManagerRespVO;
  4 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypePageReqVO;
  5 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypeResp;
  6 +import com.zteits.urbanops.module.garden.controller.admin.material.vo.MaterialTypeSaveReqVO;
  7 +import org.apache.commons.collections4.CollectionUtils;
  8 +import org.springframework.stereotype.Service;
  9 +import jakarta.annotation.Resource;
  10 +import org.springframework.validation.annotation.Validated;
  11 +
  12 +import java.util.*;
  13 +import java.util.stream.Collectors;
  14 +
6 15 import com.zteits.urbanops.module.garden.dal.dataobject.material.MaterialTypeDO;
  16 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  17 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  18 +
7 19 import com.zteits.urbanops.module.garden.dal.mysql.material.MaterialTypeMapper;
8   -import jakarta.annotation.Resource;
9   -import org.springframework.stereotype.Service;
10 20  
11   -import java.util.List;
  21 +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
  22 +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
  23 +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0;
  24 +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList;
  25 +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserDeptId;
  26 +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*;
12 27  
  28 +/**
  29 + * 物料类型 Service 实现类
  30 + *
  31 + * @author 超级管理员
  32 + */
13 33 @Service
  34 +@Validated
14 35 public class MaterialTypeServiceImpl implements MaterialTypeService {
15 36  
16 37 @Resource
17   - private MaterialTypeMapper mapper;
  38 + private MaterialTypeMapper materialTypeMapper;
18 39  
19 40 @Override
20   - public MaterialTypeDO get(Long id) {
21   - return mapper.selectById(id);
  41 + public Long createMaterialType(MaterialTypeSaveReqVO createReqVO) {
  42 + // 插入
  43 + QueryWrapper<MaterialTypeDO> sql = new QueryWrapper<>();
  44 + sql.lambda().eq(MaterialTypeDO::getMaterialTypeId, createReqVO.getMaterialTypeId())
  45 + .eq(MaterialTypeDO::getTypeId, createReqVO.getTypeId())
  46 + .eq(MaterialTypeDO::getTypeDetailName, createReqVO.getTypeDetailName());
  47 + List<MaterialTypeDO> materialTypes = materialTypeMapper.selectList(sql);
  48 + if (null != materialTypes && !materialTypes.isEmpty()) {
  49 + MaterialTypeDO materialType1 = materialTypes.get(0);
  50 + throw exception0(BAD_REQUEST.getCode(), "耗材类型:"+materialType1.getMaterialTypeName()+",类别:"+materialType1.getTypeName()+",类别明细:"+materialType1.getTypeDetailName() + " 的配置已存在");
  51 + }
  52 + Long selectMaxTypeDetailId = selectMaxTypeDetailId(createReqVO.getMaterialTypeId(), createReqVO.getTypeId());
  53 + createReqVO.setTypeDetailId(selectMaxTypeDetailId + 1);
  54 + MaterialTypeDO materialType = BeanUtils.toBean(createReqVO, MaterialTypeDO.class);
  55 + materialType.setParentTypeId(createReqVO.getTypeId());
  56 + materialType.setMaterialParentTypeId(createReqVO.getMaterialTypeId());
  57 + materialType.setStatus("0");
  58 + materialType.setCreator(String.valueOf(getLoginUserDeptId()));
  59 + materialType.setUpdater(materialType.getCreator());
  60 + materialTypeMapper.insert(materialType);
  61 +
  62 + // 返回
  63 + return materialType.getId();
22 64 }
23 65  
24 66 @Override
25   - public List<MaterialTypeDO> selectList(MaterialTypeDO req) {
26   - com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO> wrapper =
27   - new com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO>()
28   - .likeIfPresent(MaterialTypeDO::getTypeName, req.getTypeName())
29   - .eqIfPresent(MaterialTypeDO::getParentId, req.getParentId())
30   - .eqIfPresent(MaterialTypeDO::getLevel, req.getLevel())
31   - .orderByDesc(MaterialTypeDO::getId);
32   - return mapper.selectList(wrapper);
  67 + public void updateMaterialType(MaterialTypeSaveReqVO updateReqVO) {
  68 + // 校验存在
  69 + validateMaterialTypeExists(updateReqVO.getId());
  70 + // 更新
  71 + MaterialTypeDO updateObj = BeanUtils.toBean(updateReqVO, MaterialTypeDO.class);
  72 + materialTypeMapper.updateById(updateObj);
33 73 }
34 74  
35 75 @Override
36   - public Page<MaterialTypeDO> selectPage(Page<MaterialTypeDO> page, MaterialTypeDO req) {
37   - com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO> wrapper =
38   - new com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO>()
39   - .likeIfPresent(MaterialTypeDO::getTypeName, req.getTypeName())
40   - .eqIfPresent(MaterialTypeDO::getParentId, req.getParentId())
41   - .eqIfPresent(MaterialTypeDO::getLevel, req.getLevel())
42   - .orderByDesc(MaterialTypeDO::getId);
43   - return mapper.selectPage(page, wrapper);
  76 + public void deleteMaterialType(Long id) {
  77 + // 校验存在
  78 + validateMaterialTypeExists(id);
  79 + // 删除
  80 + materialTypeMapper.deleteById(id);
44 81 }
45 82  
46 83 @Override
47   - public boolean insert(MaterialTypeDO entity) {
48   - entity.clean();
49   - return mapper.insert(entity) > 0;
  84 + public void deleteMaterialTypeListByIds(List<Long> ids) {
  85 + // 删除
  86 + materialTypeMapper.deleteByIds(ids);
  87 + }
  88 +
  89 +
  90 + private void validateMaterialTypeExists(Long id) {
  91 + if (materialTypeMapper.selectById(id) == null) {
  92 + throw exception(MATERIAL_TYPE_NOT_EXISTS);
  93 + }
50 94 }
51 95  
52 96 @Override
53   - public boolean update(MaterialTypeDO entity) {
54   - entity.clean();
55   - return mapper.updateById(entity) > 0;
  97 + public MaterialTypeDO getMaterialType(Long id) {
  98 + return materialTypeMapper.selectById(id);
56 99 }
57 100  
58 101 @Override
59   - public boolean deleteById(Long id) {
60   - return mapper.deleteById(id) > 0;
  102 + public PageResult<MaterialTypeDO> getMaterialTypePage(MaterialTypePageReqVO pageReqVO) {
  103 + return materialTypeMapper.selectPage(pageReqVO);
61 104 }
62 105  
63 106 @Override
64   - public List<MaterialTypeManagerRespVO> queryMaterialBigType(Long materialTypeId) {
65   - com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO> wrapper =
66   - new com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO>()
67   - .eqIfPresent(MaterialTypeDO::getLevel, 1)
68   - .orderByDesc(MaterialTypeDO::getId);
69   - List<MaterialTypeDO> list = mapper.selectList(wrapper);
70   - return list.stream().filter(it -> materialTypeId == null || !it.getId().equals(materialTypeId))
71   - .map(it -> {
72   - MaterialTypeManagerRespVO vo = new MaterialTypeManagerRespVO();
73   - vo.setValue(it.getId());
74   - vo.setLabel(it.getTypeName());
75   - return vo;
76   - }).toList();
  107 + public List<MaterialTypeResp> queryMaterialBigType(Long materialTypeId) {
  108 + List<MaterialTypeDO> list;
  109 + // 入参为空时查询所有,非空时按ID查询
  110 + if (materialTypeId == null) {
  111 + list = materialTypeMapper.selectList();
  112 + } else {
  113 + list = materialTypeMapper.selectList(MaterialTypeDO::getMaterialTypeId, materialTypeId);
  114 + }
  115 +
  116 + // 空列表判断,避免空指针
  117 + if (list == null || list.isEmpty()) {
  118 + return List.of(); // 返回空列表而非null,更符合Java规范
  119 + }
  120 +
  121 + Set<Long> seenIds = new HashSet<>();
  122 + return list.stream()
  123 + .map(doObj -> {
  124 + MaterialTypeResp resp = new MaterialTypeResp();
  125 + resp.setValue(doObj.getMaterialTypeId());
  126 + resp.setLabel(doObj.getMaterialTypeName());
  127 + return resp;
  128 + })
  129 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  130 + .collect(Collectors.toList());
77 131 }
78 132  
79 133 @Override
80   - public List<MaterialTypeManagerRespVO> queryMaterialMidType(Long materialTypeId) {
81   - com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO> wrapper =
82   - new com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO>()
83   - .eqIfPresent(MaterialTypeDO::getLevel, 2)
84   - .eqIfPresent(MaterialTypeDO::getParentId, materialTypeId)
85   - .orderByDesc(MaterialTypeDO::getId);
86   - List<MaterialTypeDO> list = mapper.selectList(wrapper);
87   - return list.stream().map(it -> {
88   - MaterialTypeManagerRespVO vo = new MaterialTypeManagerRespVO();
89   - vo.setValue(it.getId());
90   - vo.setLabel(it.getTypeName());
91   - vo.setMaterialParentTypeId(it.getParentId());
92   - return vo;
93   - }).toList();
  134 + public List<MaterialTypeResp> queryMaterialMidType(Long materialParentTypeId) {
  135 + List<MaterialTypeDO> list = materialTypeMapper.selectList(MaterialTypeDO::getMaterialParentTypeId, materialParentTypeId);
  136 + // 2. 空列表判断,避免空指针
  137 + if (list == null || list.isEmpty()) {
  138 + return List.of(); // 返回空列表而非null,更符合Java规范
  139 + }
  140 + Set<Long> seenIds = new HashSet<>();
  141 + return list.stream()
  142 + .map(doObj -> {
  143 + MaterialTypeResp resp = new MaterialTypeResp();
  144 + resp.setValue(doObj.getTypeId());
  145 + resp.setLabel(doObj.getTypeName());
  146 + return resp;
  147 + })
  148 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  149 + .collect(Collectors.toList());
94 150 }
95 151  
96 152 @Override
97   - public List<MaterialTypeManagerRespVO> queryMaterialDetailType(Long parentTypeId) {
98   - com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO> wrapper =
99   - new com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX<MaterialTypeDO>()
100   - .eqIfPresent(MaterialTypeDO::getLevel, 3)
101   - .eqIfPresent(MaterialTypeDO::getParentId, parentTypeId)
102   - .orderByDesc(MaterialTypeDO::getId);
103   - List<MaterialTypeDO> list = mapper.selectList(wrapper);
104   - return list.stream().map(it -> {
105   - MaterialTypeManagerRespVO vo = new MaterialTypeManagerRespVO();
106   - vo.setValue(it.getId());
107   - vo.setLabel(it.getTypeName());
108   - vo.setParentTypeId(it.getParentId());
109   - return vo;
110   - }).toList();
  153 + public List<MaterialTypeResp> queryMaterialDetailType(Long parentTypeId) {
  154 + List<MaterialTypeDO> list = materialTypeMapper.selectList(MaterialTypeDO::getParentTypeId, parentTypeId);
  155 + // 2. 空列表判断,避免空指针
  156 + if (list == null || list.isEmpty()) {
  157 + return List.of(); // 返回空列表而非null,更符合Java规范
  158 + }
  159 + Set<Long> seenIds = new HashSet<>();
  160 + return list.stream()
  161 + .map(doObj -> {
  162 + MaterialTypeResp resp = new MaterialTypeResp();
  163 + resp.setValue(doObj.getTypeDetailId());
  164 + resp.setLabel(doObj.getTypeDetailName());
  165 + return resp;
  166 + })
  167 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  168 + .collect(Collectors.toList());
111 169 }
112 170  
113 171 @Override
114 172 public Long selectMaxTypeDetailId(Long materialTypeId, Long typeId) {
115 173 QueryWrapper<MaterialTypeDO> qw = new QueryWrapper<>();
116   - qw.select("max(id) AS maxId")
117   - .eq("level", 3)
118   - .eq("parent_id", typeId);
119   - List<java.util.Map<String, Object>> maps = mapper.selectMaps(qw);
120   - if (maps.isEmpty() || maps.get(0).get("maxId") == null) {
121   - return 0L;
122   - }
123   - return ((Number) maps.get(0).get("maxId")).longValue();
  174 + qw.select("max(type_detail_id) AS maxId")
  175 + .eq("material_type_id", materialTypeId)
  176 + .eq("type_id", typeId);
  177 +
  178 + List<Map<String, Object>> maps = materialTypeMapper.selectMaps(qw);
  179 + return CollectionUtils.isEmpty(maps)
  180 + ? 0L
  181 + : Optional.ofNullable((Number) maps.get(0).get("maxId"))
  182 + .map(Number::longValue)
  183 + .orElse(0L);
124 184 }
125   -}
126 185 \ No newline at end of file
  186 +
  187 +}
... ...
urbanops-module-garden/src/main/resources/mapper/materialtype/MaterialTypeMapper.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.material.MaterialTypeMapper">
  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
... ...