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 e6de4c5a..947c7c6b 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 @@ -9,6 +9,7 @@ import javax.validation.constraints.NotNull; import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.log.enums.OperaType; import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.ma.MaTypeConfigDto; import com.bonus.material.ma.vo.MaTypeListVo; import com.bonus.material.ma.vo.MaTypeSelectVo; import com.bonus.material.warehouse.domain.WhHouseSet; @@ -201,4 +202,15 @@ public class TypeController extends BaseController { public AjaxResult remove(@PathVariable Long[] typeIds) { return toAjax(typeService.deleteTypeByTypeIds(typeIds)); } + + /** + * 查询物资类型配置右侧列表 + */ + @ApiOperation(value = "查询物资类型配置右侧列表") + @RequiresPermissions("ma:typeConfig:list") + @GetMapping("/getMaTypeConfigList") + public AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto) { + // 调用service处理业务逻辑 + return typeService.getMaTypeConfigList(maTypeConfigDto); + } } 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 728f0640..fc132e0e 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 @@ -3,6 +3,8 @@ package com.bonus.material.ma.service; import java.util.List; import com.bonus.common.biz.domain.TreeSelect; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.ma.MaTypeConfigDto; import com.bonus.material.ma.domain.Type; import com.bonus.material.ma.vo.MaTypeConfigVo; import com.bonus.material.ma.vo.MaTypeListVo; @@ -93,4 +95,6 @@ public interface ITypeService { * @return 树结构列表 */ List buildMaTypeTree(List maTypeList); + + AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto); } 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 0a2efe27..bf286c80 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 @@ -8,6 +8,12 @@ import com.bonus.common.biz.domain.TreeSelect; import com.bonus.common.biz.enums.DataCodeEnum; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.ma.MaTypeConfigDto; +import com.bonus.material.ma.domain.TypeKeeper; +import com.bonus.material.ma.domain.TypeRepair; +import com.bonus.material.ma.service.ITypeKeeperService; +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; @@ -33,6 +39,12 @@ public class TypeServiceImpl implements ITypeService { @Resource private TypeMapper typeMapper; + @Resource + private ITypeKeeperService typeKeeperService; + + @Resource + private ITypeRepairService typeRepairService; + /** * 查询物资类型 -- 根据id * @@ -373,4 +385,96 @@ public class TypeServiceImpl implements ITypeService { return !getChildList(list, t).isEmpty(); } + @Override + public AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto) { + // 1.把所有物资类型查出来 + List list = selectThreeFourLevelTypeListAndParent(new Type()); + // 2.把维修配置信息查出来 + List typeRepairList = typeRepairService.selectTypeRepairListAndUserName(new TypeRepair()); + // 3.把库管配置信息查出来 + List typeKeeperList = typeKeeperService.selectTypeKeeperListAndUserName(new TypeKeeper()); + + // ------------------- 开启数据处理 --------------------- + + // 4.循环所有物资类型,重型数据集合保障只循环一次,减少性能损失 + for (MaTypeConfigVo typeConfigVo1 : list) { + // 1.外层 先对比维修班组 + for (TypeRepair typeRepair : typeRepairList) { + // 2.判断当前维修配置信息中的物资类型id是否等于当前物资类型配置信息中的物资类型id + if (typeRepair.getTypeId().equals(typeConfigVo1.getTypeId())) { + // 3.如果相等,把维修员信息设置到物资类型配置信息中 + typeConfigVo1.setRepairUserId(typeRepair.getUserId()); + typeConfigVo1.setRepairUserName(typeRepair.getUserName()); + break; + } + } + // 1.外层 再对比库管班组 + for (TypeKeeper typeKeeper : typeKeeperList) { + // 2.判断当前库管配置信息中的物资类型id是否等于当前物资类型配置信息中的物资类型id + if (typeKeeper.getTypeId().equals(typeConfigVo1.getTypeId())) { + // 3.如果相等,把库管员信息设置到物资类型配置信息中 + typeConfigVo1.setKeeperUserId(typeKeeper.getUserId()); + typeConfigVo1.setKeeperUserName(typeKeeper.getUserName()); + } + } + + // 5.判断当前物资类型配置信息是否有子节点 + if (typeConfigVo1.getChildren() != null) { + // 6.有子节点,继续循环子节点,判断子节点是否有维修配置信息 + for (MaTypeConfigVo typeConfigVo2 : typeConfigVo1.getChildren()) { + // 7.有维修配置信息,把维修员信息设置到子节点中 + for (TypeRepair typeRepair : typeRepairList) { + if (typeRepair.getTypeId().equals(typeConfigVo2.getTypeId())) { + typeConfigVo2.setRepairUserId(typeRepair.getUserId()); + typeConfigVo2.setRepairUserName(typeRepair.getUserName()); + } + } + } + + // 8.有子节点,继续循环子节点, + for (MaTypeConfigVo typeConfigVo3 : typeConfigVo1.getChildren()) { + // 9.判断子节点是否有库管配置信息 + for (TypeKeeper typeKeeper : typeKeeperList) { + if (typeKeeper.getTypeId().equals(typeConfigVo3.getTypeId())) { + typeConfigVo3.setKeeperUserId(typeKeeper.getUserId()); + typeConfigVo3.setKeeperUserName(typeKeeper.getUserName()); + } + } + } + } + + } + + // -------------------- 数据处理结束 --------------------- + + // TODO: 先暂时取消后续过滤流程 + if (true) { + return AjaxResult.success(list); + } + + + // ------------------- 数据过滤开始 --------------------- + if (maTypeConfigDto == null || maTypeConfigDto.getUserId() == null || maTypeConfigDto.getUserId() == 0L) { + // 如果参数无效,则返回原始列表 + return AjaxResult.success(list); + } + + List filteredList = new ArrayList<>(); + + for (MaTypeConfigVo maTypeConfigVo : list) { + if ( + maTypeConfigVo.getKeeperUserId().equals(maTypeConfigDto.getUserId()) || + maTypeConfigVo.getRepairUserId().equals(maTypeConfigDto.getUserId()) + ) + { + filteredList.add(maTypeConfigVo); + } + } + + // ------------------- 数据过滤结束 --------------------- + + + // 返回前端 + return AjaxResult.success(filteredList); + } }