物资类型--控制器代码抽出 优化三四级节点关联逻辑
This commit is contained in:
parent
77e19d4d9d
commit
ed2290bc99
|
|
@ -36,23 +36,6 @@ import java.util.*;
|
|||
@RequestMapping("/ma_type_config")
|
||||
public class MaTypeConfigController extends BaseController {
|
||||
|
||||
/**
|
||||
* 物资类型库管员配置Service
|
||||
*/
|
||||
@Resource
|
||||
private ITypeKeeperService typeKeeperService;
|
||||
|
||||
/**
|
||||
* 物资类型维修员配置Service
|
||||
*/
|
||||
@Resource
|
||||
private ITypeRepairService typeRepairService;
|
||||
|
||||
// 物资类型Service
|
||||
@Resource
|
||||
private ITypeService typeService;
|
||||
|
||||
|
||||
@Resource
|
||||
private MaTypeConfigService maTypeConfigService;
|
||||
|
||||
|
|
@ -91,97 +74,9 @@ public class MaTypeConfigController extends BaseController {
|
|||
@RequiresPermissions("ma:typeConfig:list")
|
||||
@GetMapping("/getMaTypeConfigList")
|
||||
public AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto) {
|
||||
// 1.把所有物资类型查出来
|
||||
List<MaTypeConfigVo> list = typeService.selectThreeFourLevelTypeListAndParent(new Type());
|
||||
// 2.把维修配置信息查出来
|
||||
List<TypeRepair> typeRepairList = typeRepairService.selectTypeRepairListAndUserName(new TypeRepair());
|
||||
// 3.把库管配置信息查出来
|
||||
List<TypeKeeper> 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;
|
||||
// 调用service处理业务逻辑
|
||||
return maTypeConfigService.getMaTypeConfigList(maTypeConfigDto);
|
||||
}
|
||||
}
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// -------------------- NEW ----------------------------
|
||||
|
||||
// TODO: 先暂时取消后续过滤流程
|
||||
if (true) {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
// ------------------- 数据过滤开始 ---------------------
|
||||
if (maTypeConfigDto == null || maTypeConfigDto.getUserId() == null || maTypeConfigDto.getUserId() == 0L) {
|
||||
// 如果参数无效,则返回原始列表
|
||||
return success(list);
|
||||
}
|
||||
|
||||
List<MaTypeConfigVo> filteredList = new ArrayList<>();
|
||||
|
||||
for (MaTypeConfigVo maTypeConfigVo : list) {
|
||||
if (
|
||||
maTypeConfigVo.getKeeperUserId().equals(maTypeConfigDto.getUserId()) ||
|
||||
maTypeConfigVo.getRepairUserId().equals(maTypeConfigDto.getUserId())
|
||||
)
|
||||
{
|
||||
filteredList.add(maTypeConfigVo);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------- 数据过滤结束 ---------------------
|
||||
|
||||
// 返回前端
|
||||
return success(filteredList);
|
||||
// -------------------- 数据处理结束 ---------------------
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ public class Type extends BaseEntity {
|
|||
private Long storageNum = 0L;
|
||||
|
||||
/** 是否扣费 */
|
||||
@ApiModelProperty(value = "是否扣费,true:扣费, false:不")
|
||||
private Boolean isCharging = false;
|
||||
@ApiModelProperty(value = "是否扣费,0:扣费, 1:不扣费")
|
||||
private Byte isCharging = 1;
|
||||
|
||||
/** 检验周期 */
|
||||
@ApiModelProperty(value = "检验周期,单位:月")
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ public interface MaTypeConfigService{
|
|||
|
||||
AjaxResult updateMaTypeBindInfo(MaTypeConfigDto maTypeConfigDto);
|
||||
|
||||
|
||||
AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@ package com.bonus.material.ma.service.impl;
|
|||
|
||||
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.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.service.ITypeService;
|
||||
import com.bonus.material.ma.service.MaTypeConfigService;
|
||||
import com.bonus.material.ma.vo.MaTypeConfigVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
|
|
@ -33,6 +38,10 @@ public class MaTypeConfigServiceImpl implements MaTypeConfigService {
|
|||
@Resource
|
||||
private ITypeRepairService typeRepairService;
|
||||
|
||||
// 物资类型Service
|
||||
@Resource
|
||||
private ITypeService typeService;
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult updateMaTypeBindInfo(MaTypeConfigDto maTypeConfigDto) {
|
||||
|
|
@ -50,6 +59,99 @@ public class MaTypeConfigServiceImpl implements MaTypeConfigService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto) {
|
||||
// 1.把所有物资类型查出来
|
||||
List<MaTypeConfigVo> list = typeService.selectThreeFourLevelTypeListAndParent(new Type());
|
||||
// 2.把维修配置信息查出来
|
||||
List<TypeRepair> typeRepairList = typeRepairService.selectTypeRepairListAndUserName(new TypeRepair());
|
||||
// 3.把库管配置信息查出来
|
||||
List<TypeKeeper> 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<MaTypeConfigVo> 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);
|
||||
}
|
||||
|
||||
|
||||
private int handleBind(int bindRoleType, Long typeId, Long userId) {
|
||||
switch (bindRoleType) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
package com.bonus.material.ma.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.bonus.common.biz.domain.TreeSelect;
|
||||
import com.bonus.common.biz.enums.DataCodeEnum;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
|
|
@ -167,18 +166,30 @@ public class TypeServiceImpl implements ITypeService {
|
|||
// 查询四级节点列表
|
||||
List<MaTypeConfigVo> fourLevelTypeList = typeMapper.selectFourLevelTypeListAndParent(type);
|
||||
List<MaTypeConfigVo> threeLevelTypeList = null;
|
||||
if (fourLevelTypeList != null && !fourLevelTypeList.isEmpty()) {
|
||||
|
||||
if (ArrayUtil.isNotEmpty(fourLevelTypeList)) {
|
||||
// 查询三级节点列表
|
||||
threeLevelTypeList = typeMapper.selectThreeLevelTypeListAndParent(type);
|
||||
if (threeLevelTypeList != null && !threeLevelTypeList.isEmpty()) {
|
||||
// 循环,把三级节点放入fourLevelTypeList集合中
|
||||
for (MaTypeConfigVo fourLevelType : fourLevelTypeList) {
|
||||
// 内循环四级节点
|
||||
if (ArrayUtil.isNotEmpty(threeLevelTypeList)) {
|
||||
|
||||
// 使用 HashMap 存储三级节点,以便快速查找
|
||||
Map<Long, MaTypeConfigVo> threeLevelTypeMap = new HashMap<>();
|
||||
for (MaTypeConfigVo threeLevelType : threeLevelTypeList) {
|
||||
// 如果四级节点的父级id和三级节点的id相同,则把四级节点放入三级节点的children集合中
|
||||
if (fourLevelType.getParentId().equals(threeLevelType.getTypeId())) {
|
||||
threeLevelType.getChildren().add(fourLevelType);
|
||||
threeLevelTypeMap.put(threeLevelType.getTypeId(), threeLevelType);
|
||||
}
|
||||
|
||||
// 外层循环四级节点列表
|
||||
for (MaTypeConfigVo fourLevelType : fourLevelTypeList) {
|
||||
// 对4级节点进行必要性检查
|
||||
if (fourLevelType == null || fourLevelType.getParentId() == null) {
|
||||
continue;
|
||||
}
|
||||
// 拿到4级节点的父级id
|
||||
Long fourLevelTypeParentId = fourLevelType.getParentId();
|
||||
// 查找对应的三级节点
|
||||
MaTypeConfigVo threeLevelType = threeLevelTypeMap.get(fourLevelTypeParentId);
|
||||
if (threeLevelType != null) {
|
||||
threeLevelType.getChildren().add(fourLevelType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public interface PurchaseCheckDetailsMapper {
|
|||
* @param id 新购验收任务详细主键
|
||||
* @return 新购验收任务详细
|
||||
*/
|
||||
public PurchaseCheckDetails selectPurchaseCheckDetailsById(Long id);
|
||||
PurchaseCheckDetails selectPurchaseCheckDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询新购验收任务详细列表
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public interface IPurchaseCheckInfoService {
|
|||
* @param id 新购验收任务主键
|
||||
* @return 新购验收任务
|
||||
*/
|
||||
PurchaseCheckInfo selectPurchaseCheckInfoById(Long id);
|
||||
PurchaseCheckDto selectPurchaseCheckInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 查询新购验收任务列表
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
|
||||
import com.bonus.material.purchase.dto.PurchaseCheckDto;
|
||||
import com.bonus.material.purchase.mapper.PurchaseCheckDetailsMapper;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
|
|
@ -41,8 +42,19 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
* @return 新购验收任务
|
||||
*/
|
||||
@Override
|
||||
public PurchaseCheckInfo selectPurchaseCheckInfoById(Long id) {
|
||||
return purchaseCheckInfoMapper.selectPurchaseCheckInfoById(id);
|
||||
public PurchaseCheckDto selectPurchaseCheckInfoById(Long id) {
|
||||
PurchaseCheckDto purchaseCheckDtoResult = new PurchaseCheckDto();
|
||||
PurchaseCheckInfo purchaseCheckInfo = purchaseCheckInfoMapper.selectPurchaseCheckInfoById(id);
|
||||
if (purchaseCheckInfo != null) {
|
||||
purchaseCheckDtoResult.setPurchaseCheckInfo(purchaseCheckInfo);
|
||||
PurchaseCheckDetails purchaseCheckDetailDto = new PurchaseCheckDetails();
|
||||
purchaseCheckDetailDto.setTaskId(purchaseCheckInfo.getTaskId());
|
||||
List<PurchaseCheckDetails> purchaseCheckDetails = purchaseCheckDetailsMapper.selectPurchaseCheckDetailsList(purchaseCheckDetailDto);
|
||||
if (purchaseCheckDetails != null) {
|
||||
purchaseCheckDtoResult.setPurchaseCheckDetailsList(purchaseCheckDetails);
|
||||
}
|
||||
}
|
||||
return purchaseCheckDtoResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue