diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java index 947c7c6b..26ec40bb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/TypeController.java @@ -38,9 +38,6 @@ public class TypeController extends BaseController { @Resource private ITypeService typeService; - @Resource - private IWhHouseSetService houseSetService; - /** * 查询物资类型管理列表 */ @@ -82,32 +79,12 @@ public class TypeController extends BaseController { */ @ApiOperation(value = "获取物资类型连动式下拉框") @GetMapping("/equipmentType") - public AjaxResult equipmentType(@RequestParam(required = false) Long typeId, - @RequestParam(required = false) String typeName) { + public AjaxResult equipmentType(@RequestParam(required = false) Long typeId, @RequestParam(required = false) String typeName) { List listByMaType = typeService.getEquipmentType(typeId, typeName); return success(listByMaType); } - /** - * 根据左列表类型id查询右表格 --- 暂未启用,代码有问题!! - * TODO: 待完善 - * @param typeId 左列表类型id - */ - @ApiOperation(value = "根据左列表类型id查询右表格") - @GetMapping("/getListByMaType") - public AjaxResult getListByMaType(Long typeId, @RequestParam(required = false) String typeName, Integer level) { - List parentIds = typeService.selectParentId(typeId, level); - List listByMaType = new ArrayList<>(); - for (Integer parentId : parentIds) { - listByMaType.addAll(typeService.getListByParentId(parentId.longValue(), typeName)); - } -// Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); -// Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); -// return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, listByMaType)); - return null; - } - /** * TODO : 后续优化代码逻辑 * 物资类型下拉树 @@ -115,32 +92,9 @@ public class TypeController extends BaseController { @ApiOperation(value = "物资类型下拉树") @RequiresPermissions("ma:type:list") @GetMapping("/getMaTypeTreeSelect") - public AjaxResult getMaTypeTreeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { - // 1.顶级节点及子节点数据全部查询完毕 - List maTypeList = typeService.getMaTypeTree(typeName, parentId); - // 2.查询所有的仓库配置 - List whHouseSets = houseSetService.selectListByMaType(null); - // 2.1 定义最终接口返回集合 - List treeSelectResultList = new ArrayList<>(); - // 3.遍历所有配置关联 - for (WhHouseSet whHouseSet : whHouseSets) { - Long typeId = whHouseSet.getTypeId(); - if (typeId == null) {continue;} - // 构造函数定义0级Tree对象 - TreeSelect thisTree = new TreeSelect(whHouseSet.getId(),whHouseSet.getHouseName(),0,null); - // 定义1级列表,并循环push相应的1级节点 - List oneLevelTreeList = new ArrayList<>(); - for (TreeSelect treeSelect : maTypeList) { - if (treeSelect.getId().equals(typeId)) { - oneLevelTreeList.add(treeSelect); - } - } - // 把处理后对应上的1级列表当作child存入0级Tree对象中 - thisTree.setChildren(!oneLevelTreeList.isEmpty() ? oneLevelTreeList : null); - // 最后把0级Tree对象存入Result返回集合中,返回给前端 - treeSelectResultList.add(thisTree); - } - return AjaxResult.success(treeSelectResultList); + public AjaxResult getMaTypeTreeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, + @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { + return typeService.getMaTypeTreeSelect(typeName, parentId); } /** @@ -213,4 +167,21 @@ public class TypeController extends BaseController { // 调用service处理业务逻辑 return typeService.getMaTypeConfigList(maTypeConfigDto); } + + + /** + * 根据左列表类型id查询右表格 --- 暂未启用,代码有问题!! + * TODO: 待完善 + * @param typeId 左列表类型id + + @ApiOperation(value = "根据左列表类型id查询右表格") + @GetMapping("/getListByMaType") + public AjaxResult getListByMaType(Long typeId, @RequestParam(required = false) String typeName, Integer level) { + List parentIds = typeService.selectParentId(typeId, level); + List listByMaType = new ArrayList<>(); + for (Integer parentId : parentIds) { + listByMaType.addAll(typeService.getListByParentId(parentId.longValue(), typeName)); + } + return null; + }*/ } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java index fc132e0e..799153df 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/ITypeService.java @@ -88,6 +88,8 @@ public interface ITypeService { List getMaTypeTree(String typeName, String parentId); + AjaxResult getMaTypeTreeSelect(String typeName,String parentId); + /** * 构建前端所需要树结构 * diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java index bf286c80..e82182b7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/TypeServiceImpl.java @@ -17,6 +17,8 @@ import com.bonus.material.ma.service.ITypeRepairService; import com.bonus.material.ma.vo.MaTypeConfigVo; import com.bonus.material.ma.vo.MaTypeListVo; import com.bonus.material.ma.vo.MaTypeSelectVo; +import com.bonus.material.warehouse.domain.WhHouseSet; +import com.bonus.material.warehouse.service.IWhHouseSetService; import org.springframework.stereotype.Service; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.ma.domain.Type; @@ -45,6 +47,9 @@ public class TypeServiceImpl implements ITypeService { @Resource private ITypeRepairService typeRepairService; + @Resource + private IWhHouseSetService houseSetService; + /** * 查询物资类型 -- 根据id * @@ -83,8 +88,6 @@ public class TypeServiceImpl implements ITypeService { } - - @Override public List selectMaTypeListByHouseId(Long houseId) { return typeMapper.selectMaTypeListByHouseId(houseId); @@ -115,7 +118,7 @@ public class TypeServiceImpl implements ITypeService { @Override public List selectTypeList(Type type) { if (type != null ) { - if (type.getDelFlag() == null || type.getDelFlag().isEmpty()) { + if (StringUtils.isEmpty(type.getDelFlag())) { // 如果没赋值,则默认查询正常数据状态 type.setDelFlag(String.valueOf(DataCodeEnum.NORMAL.getCode())); } @@ -286,15 +289,44 @@ public class TypeServiceImpl implements ITypeService { List maTypes = typeMapper.selectMaTypeTree(TYPE_MIN_LEVEL); List builtMaTypeList = buildMaTypeTree(maTypes); - List treeSelectList = builtMaTypeList.stream() - .filter(Objects::nonNull) - .map(this::convertToTreeSelect) - .collect(Collectors.toList()); - // 查询顶级节点的仓库配置信息 // 如果没有查询到那么返回空 - return treeSelectList; + return builtMaTypeList.stream() + .filter(Objects::nonNull) + .map(this::convertToTreeSelect) + .collect(Collectors.toList()); + } + + @Override + public AjaxResult getMaTypeTreeSelect(String typeName, String parentId) { + // 1.顶级节点及子节点数据全部查询完毕 + List maTypeList = this.getMaTypeTree(typeName, parentId); + // 2.查询所有的仓库配置 + List whHouseSets = houseSetService.selectListByMaType(null); + // 2.1 定义最终接口返回集合 + List treeSelectResultList = new ArrayList<>(); + + // 使用HashMap来存储maTypeList,以便快速查找 + Map maTypeMap = new HashMap<>(); + for (TreeSelect treeSelect : maTypeList) { + maTypeMap.put(treeSelect.getId(), treeSelect); + } + + // 3.遍历所有配置关联 + for (WhHouseSet whHouseSet : whHouseSets) { + // --- 数据校验 ---- + if (whHouseSet == null || whHouseSet.getTypeId() == null) { continue; } + // 构造函数定义0级Tree对象 + TreeSelect thisTree = new TreeSelect(whHouseSet.getId(),whHouseSet.getHouseName(),0,null); + // 从Map中直接获取对应的1级节点 + TreeSelect oneLevelTree = maTypeMap.get(whHouseSet.getTypeId()); + // 转换为集合存入0级Tree对象中 + thisTree.setChildren(oneLevelTree != null ? Collections.singletonList(oneLevelTree) : null); + // 最后把0级Tree对象存入Result结果集合,返回给前端 + treeSelectResultList.add(thisTree); + } + return AjaxResult.success(treeSelectResultList); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseNoticePersonServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseNoticePersonServiceImpl.java index acf32e96..58758346 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseNoticePersonServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseNoticePersonServiceImpl.java @@ -26,10 +26,6 @@ public class PurchaseNoticePersonServiceImpl implements IPurchaseNoticePersonSer @Resource private PurchaseNoticePersonMapper purchaseNoticePersonMapper; - @Resource - private SmsUtils smsUtils; - - /** * 查询新购短信通知人员 *