Commit 58051e0b9ec693d55b965350baeec963e8ae2546

Authored by wangqian
1 parent b228e0d8

工单添加物料是级联筛选

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventory/MaterialInventoryController.java
@@ -112,4 +112,44 @@ public class MaterialInventoryController { @@ -112,4 +112,44 @@ public class MaterialInventoryController {
112 return success(count); 112 return success(count);
113 } 113 }
114 114
  115 +
  116 + /**
  117 + * 获取物料类型详细信息
  118 + */
  119 + @Operation(summary ="物料类型基础表-耗材类型List")
  120 + @GetMapping(value = "/getMaterialBigTypeList")
  121 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  122 + public CommonResult getInfo() {
  123 + return success(materialInventoryService.queryMaterialBigType(null));
  124 + }
  125 +
  126 + /**
  127 + * 获取物料类型详细信息
  128 + */
  129 + @Operation(summary ="物料类型基础表-类别List")
  130 + @GetMapping(value = "/getMaterialMidTypeList")
  131 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  132 + public CommonResult getMaterialMidTypeList(@RequestParam("materialTypeId") Long materialTypeId) {
  133 + return success(materialInventoryService.queryMaterialMidType(materialTypeId));
  134 + }
  135 +
  136 + /**
  137 + * 获取物料类型详细信息
  138 + */
  139 + @Operation(summary ="物料类型基础表-类别List")
  140 + @GetMapping(value = "/getMaterialDetailTypeList")
  141 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  142 + public CommonResult getMaterialDetailTypeList(@RequestParam("typeId") Long typeId) {
  143 + return success(materialInventoryService.queryMaterialDetailType(typeId));
  144 + }
  145 +
  146 + /**
  147 + * 获取物料类型详细信息
  148 + */
  149 + @Operation(summary ="物料-类别List")
  150 + @GetMapping(value = "/getMaterialList")
  151 + @PreAuthorize("@ss.hasPermission('garden:material-type:query')")
  152 + public CommonResult getMaterialList(@RequestParam("typeDetailId") Long typeDetailId) {
  153 + return success(materialInventoryService.getMaterialInventorList(typeDetailId));
  154 + }
115 } 155 }
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryService.java
1 package com.zteits.urbanops.module.garden.service.materialinventory; 1 package com.zteits.urbanops.module.garden.service.materialinventory;
2 2
3 import java.util.*; 3 import java.util.*;
  4 +
  5 +import com.zteits.urbanops.module.garden.controller.admin.materialtype.vo.MaterialTypeResp;
4 import jakarta.validation.*; 6 import jakarta.validation.*;
5 import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.*; 7 import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.*;
6 import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; 8 import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO;
@@ -107,4 +109,12 @@ public interface MaterialInventoryService { @@ -107,4 +109,12 @@ public interface MaterialInventoryService {
107 */ 109 */
108 MaterialInventoryDO selectMaterialInventoryByMaterialId(Long materialId); 110 MaterialInventoryDO selectMaterialInventoryByMaterialId(Long materialId);
109 111
  112 + List<MaterialTypeResp> queryMaterialBigType(Long materialTypeId);
  113 +
  114 + List<MaterialTypeResp> queryMaterialMidType(Long materialTypeId);
  115 +
  116 + List<MaterialTypeResp> queryMaterialDetailType(Long typeId);
  117 +
  118 + List<MaterialTypeResp> getMaterialInventorList(Long typeDetailId);
  119 +
110 } 120 }
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryServiceImpl.java
1 package com.zteits.urbanops.module.garden.service.materialinventory; 1 package com.zteits.urbanops.module.garden.service.materialinventory;
2 2
3 -import com.baomidou.mybatisplus.core.conditions.Wrapper;  
4 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 3 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 4 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 -import com.baomidou.mybatisplus.core.toolkit.StringUtils;  
7 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
8 import com.zteits.urbanops.framework.common.pojo.PageResult; 6 import com.zteits.urbanops.framework.common.pojo.PageResult;
9 import com.zteits.urbanops.framework.common.util.object.BeanUtils; 7 import com.zteits.urbanops.framework.common.util.object.BeanUtils;
10 import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.MaterialInventoryPageReqVO; 8 import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.MaterialInventoryPageReqVO;
11 import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.MaterialInventorySaveReqVO; 9 import com.zteits.urbanops.module.garden.controller.admin.materialinventory.vo.MaterialInventorySaveReqVO;
  10 +import com.zteits.urbanops.module.garden.controller.admin.materialtype.vo.MaterialTypeResp;
12 import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO; 11 import com.zteits.urbanops.module.garden.dal.dataobject.materialinventory.MaterialInventoryDO;
13 import com.zteits.urbanops.module.garden.dal.mysql.materialinventory.MaterialInventoryMapper; 12 import com.zteits.urbanops.module.garden.dal.mysql.materialinventory.MaterialInventoryMapper;
14 import com.zteits.urbanops.module.system.api.dept.DeptApi; 13 import com.zteits.urbanops.module.system.api.dept.DeptApi;
@@ -17,13 +16,16 @@ import jakarta.annotation.Resource; @@ -17,13 +16,16 @@ import jakarta.annotation.Resource;
17 import org.springframework.stereotype.Service; 16 import org.springframework.stereotype.Service;
18 import org.springframework.validation.annotation.Validated; 17 import org.springframework.validation.annotation.Validated;
19 18
  19 +import java.util.HashSet;
20 import java.util.List; 20 import java.util.List;
  21 +import java.util.Set;
  22 +import java.util.stream.Collectors;
21 23
22 import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; 24 import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
23 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; 25 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
24 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; 26 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0;
25 import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getCompanyId; 27 import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getCompanyId;
26 -import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; 28 +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.MATERIAL_INVENTORY_NOT_EXISTS;
27 29
28 /** 30 /**
29 * 物料库存 Service 实现类 31 * 物料库存 Service 实现类
@@ -176,4 +178,88 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService { @@ -176,4 +178,88 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService {
176 queryWrapper.eq(MaterialInventoryDO::getMaterialId, materialId); 178 queryWrapper.eq(MaterialInventoryDO::getMaterialId, materialId);
177 return materialInventoryMapper.selectOne(queryWrapper); 179 return materialInventoryMapper.selectOne(queryWrapper);
178 } 180 }
  181 +
  182 + @Override
  183 + public List<MaterialTypeResp> queryMaterialBigType(Long materialTypeId) {
  184 + List<MaterialInventoryDO> list;
  185 + // 入参为空时查询所有,非空时按ID查询
  186 + if (materialTypeId == null) {
  187 + list = materialInventoryMapper.selectList();
  188 + } else {
  189 + list = materialInventoryMapper.selectList(MaterialInventoryDO::getMaterialTypeId, materialTypeId);
  190 + }
  191 +
  192 + // 空列表判断,避免空指针
  193 + if (list == null || list.isEmpty()) {
  194 + return List.of(); // 返回空列表而非null,更符合Java规范
  195 + }
  196 +
  197 + Set<Long> seenIds = new HashSet<>();
  198 + return list.stream()
  199 + .map(doObj -> {
  200 + MaterialTypeResp resp = new MaterialTypeResp();
  201 + resp.setValue(doObj.getMaterialTypeId());
  202 + resp.setLabel(doObj.getMaterialTypeName());
  203 + return resp;
  204 + })
  205 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  206 + .collect(Collectors.toList());
  207 + }
  208 +
  209 + @Override
  210 + public List<MaterialTypeResp> queryMaterialMidType(Long materialTypeId) {
  211 + List<MaterialInventoryDO> list = materialInventoryMapper.selectList(MaterialInventoryDO::getMaterialTypeId, materialTypeId);
  212 + // 2. 空列表判断,避免空指针
  213 + if (list == null || list.isEmpty()) {
  214 + return List.of(); // 返回空列表而非null,更符合Java规范
  215 + }
  216 + Set<Long> seenIds = new HashSet<>();
  217 + return list.stream()
  218 + .map(doObj -> {
  219 + MaterialTypeResp resp = new MaterialTypeResp();
  220 + resp.setValue(doObj.getTypeId());
  221 + resp.setLabel(doObj.getTypeName());
  222 + return resp;
  223 + })
  224 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  225 + .collect(Collectors.toList());
  226 + }
  227 +
  228 + @Override
  229 + public List<MaterialTypeResp> queryMaterialDetailType(Long typeId) {
  230 + List<MaterialInventoryDO> list = materialInventoryMapper.selectList(MaterialInventoryDO::getTypeId, typeId);
  231 + // 2. 空列表判断,避免空指针
  232 + if (list == null || list.isEmpty()) {
  233 + return List.of(); // 返回空列表而非null,更符合Java规范
  234 + }
  235 + Set<Long> seenIds = new HashSet<>();
  236 + return list.stream()
  237 + .map(doObj -> {
  238 + MaterialTypeResp resp = new MaterialTypeResp();
  239 + resp.setValue(doObj.getTypeDetailId());
  240 + resp.setLabel(doObj.getTypeDetailName());
  241 + return resp;
  242 + })
  243 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  244 + .collect(Collectors.toList());
  245 + }
  246 +
  247 + @Override
  248 + public List<MaterialTypeResp> getMaterialInventorList(Long typeDetailId) {
  249 + List<MaterialInventoryDO> list = materialInventoryMapper.selectList(MaterialInventoryDO::getTypeDetailId, typeDetailId);
  250 + // 2. 空列表判断,避免空指针
  251 + if (list == null || list.isEmpty()) {
  252 + return List.of(); // 返回空列表而非null,更符合Java规范
  253 + }
  254 + Set<Long> seenIds = new HashSet<>();
  255 + return list.stream()
  256 + .map(doObj -> {
  257 + MaterialTypeResp resp = new MaterialTypeResp();
  258 + resp.setValue(doObj.getMaterialId());
  259 + resp.setLabel(doObj.getMaterialName());
  260 + return resp;
  261 + })
  262 + .filter(resp -> seenIds.add(resp.getValue())) // add成功返回true(未重复)
  263 + .collect(Collectors.toList());
  264 + }
179 } 265 }
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/admin/maininfo/MainInfoController.java
1 package com.zteits.urbanops.module.workorder.controller.admin.maininfo; 1 package com.zteits.urbanops.module.workorder.controller.admin.maininfo;
2 2
  3 +import com.baomidou.mybatisplus.core.toolkit.StringUtils;
3 import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; 4 import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
4 import com.zteits.urbanops.framework.common.pojo.CommonResult; 5 import com.zteits.urbanops.framework.common.pojo.CommonResult;
5 import com.zteits.urbanops.framework.common.pojo.PageParam; 6 import com.zteits.urbanops.framework.common.pojo.PageParam;
@@ -27,6 +28,7 @@ import org.springframework.validation.annotation.Validated; @@ -27,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
27 import org.springframework.web.bind.annotation.*; 28 import org.springframework.web.bind.annotation.*;
28 29
29 import java.io.IOException; 30 import java.io.IOException;
  31 +import java.util.Arrays;
30 import java.util.Collections; 32 import java.util.Collections;
31 import java.util.List; 33 import java.util.List;
32 import java.util.Map; 34 import java.util.Map;
@@ -86,7 +88,23 @@ public class MainInfoController { @@ -86,7 +88,23 @@ public class MainInfoController {
86 @PreAuthorize("@ss.hasPermission('workorder:main-info:query')") 88 @PreAuthorize("@ss.hasPermission('workorder:main-info:query')")
87 public CommonResult<MainInfoRespVO> getMainInfo(@RequestParam("id") Long id) { 89 public CommonResult<MainInfoRespVO> getMainInfo(@RequestParam("id") Long id) {
88 MainInfoDO mainInfo = mainInfoService.getMainInfo(id); 90 MainInfoDO mainInfo = mainInfoService.getMainInfo(id);
89 - return success(BeanUtils.toBean(mainInfo, MainInfoRespVO.class)); 91 +
  92 + // 若订单号列表非空,查询附件;否则跳过
  93 + Map<String, AttachmentDO> attachmentMap = Collections.emptyMap();
  94 + if (mainInfo != null) {
  95 + List<AttachmentDO> attachmentDOList = attachmentService.getAttachmentByOrderNo(Arrays.asList(mainInfo.getOrderNo()));
  96 + // 构建订单号→附件对象的映射(处理重复key,取第一个对象)
  97 + if (!CollectionUtils.isEmpty(attachmentDOList)) {
  98 + attachmentMap = attachmentDOList.stream()
  99 + .filter(attachmentDO -> "01".equals(attachmentDO.getBusiType()))
  100 + .collect(Collectors.toMap(
  101 + AttachmentDO::getOrderNo, // key:订单号
  102 + attachmentDO -> attachmentDO, // value:附件对象
  103 + (existing, replacement) -> existing // 重复key时保留已有值
  104 + ));
  105 + }
  106 + }
  107 + return success(MainInfoConvert.INSTANCE.buildMainInfo(mainInfo, attachmentMap));
90 } 108 }
91 109
92 @GetMapping("/page") 110 @GetMapping("/page")
@@ -94,6 +112,10 @@ public class MainInfoController { @@ -94,6 +112,10 @@ public class MainInfoController {
94 @PreAuthorize("@ss.hasPermission('workorder:main-info:query')") 112 @PreAuthorize("@ss.hasPermission('workorder:main-info:query')")
95 public CommonResult<PageResult<MainInfoRespVO>> getMainInfoPage(@Valid MainInfoPageReqVO pageReqVO) { 113 public CommonResult<PageResult<MainInfoRespVO>> getMainInfoPage(@Valid MainInfoPageReqVO pageReqVO) {
96 PageResult<MainInfoDO> pageResult = mainInfoService.getMainInfoPage(pageReqVO); 114 PageResult<MainInfoDO> pageResult = mainInfoService.getMainInfoPage(pageReqVO);
  115 +
  116 + if (pageResult == null) {
  117 + return success(PageResult.empty());
  118 + }
97 // 2. 初始化附件映射(默认空Map,避免后续空指针) 119 // 2. 初始化附件映射(默认空Map,避免后续空指针)
98 Map<String, AttachmentDO> attachmentMap = Collections.emptyMap(); 120 Map<String, AttachmentDO> attachmentMap = Collections.emptyMap();
99 121
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/convert/maininfo/MainInfoConvert.java
@@ -32,4 +32,13 @@ public interface MainInfoConvert { @@ -32,4 +32,13 @@ public interface MainInfoConvert {
32 }); 32 });
33 return new PageResult<>(mainInfoVOList, pageResult.getTotal()); 33 return new PageResult<>(mainInfoVOList, pageResult.getTotal());
34 } 34 }
  35 +
  36 + default MainInfoRespVO buildMainInfo(MainInfoDO mainInfoDO, Map<String, AttachmentDO> attachmentMap) {
  37 + MainInfoRespVO mainInfoVo = BeanUtils.toBean(mainInfoDO, MainInfoRespVO.class);
  38 + if (mainInfoDO != null) {
  39 + AttachmentDO attachmentDO = attachmentMap.get(mainInfoDO.getOrderNo());
  40 + mainInfoVo.setFileNames(attachmentDO.getFileNames());
  41 + }
  42 + return mainInfoVo;
  43 + }
35 } 44 }