diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index d247459f..4143a67a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -3,7 +3,9 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.google.common.collect.ImmutableList; import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.starter.annotation.LogRecord; import com.nflg.product.base.core.api.BaseApi; @@ -371,4 +373,16 @@ public class PBomApi extends BaseApi { bomNewPbomParentService.generateNoticeNum(param); return ResultVO.success(true); } + + @GetMapping("getUserAuthFac") + @ApiOperation("获取用可查看pbom工厂") + public ResultVO> getUserAuthFac() { + String userFactory = userRoleService.getUserFactory(); + if(StrUtil.isBlank(userFactory)){ + return ResultVO.success(ImmutableList.of("1010","1020")); + } + return ResultVO.success(ImmutableList.of(userFactory)); + } + + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/MaterialMainMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/MaterialMainMapper.java index 400951c2..04e059fb 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/MaterialMainMapper.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/MaterialMainMapper.java @@ -60,4 +60,6 @@ public interface MaterialMainMapper extends BaseMapper { List getRolePostByUserId(@Param("userRowId") Long userRowId); UserInfoVO getUserInfoByUserCode(@Param("userCode")String userCode); + + String getUserDepartmentDptCode(@Param("rowId") Long rowId); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 9622d64c..9e1df8ee 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.mzt.logapi.context.LogRecordContext; @@ -141,8 +142,10 @@ public class BomNewPbomParentService extends ServiceImpl parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo)); parentMaterialByMaterialNo.add(materialNo); if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { - List parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo); - List childs = this.getBaseMapper().getChildForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo, materialNo); + String queryFac= StrUtil.isBlank(query.getFacCode())? userRoleService.getUserFactory():query.getFacCode(); + + List parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo); + List childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo); List data = new ArrayList<>(); data.addAll(parents); data.addAll(childs); @@ -155,6 +158,7 @@ public class BomNewPbomParentService extends ServiceImpl(); @@ -191,6 +195,24 @@ public class BomNewPbomParentService extends ServiceImpl parentNoResult, Set materialNos){ + + List childList = pbomChildService.lambdaQuery().in(BomNewPbomChildEntity::getMaterialNo, materialNos).select(BomNewPbomChildEntity::getParentRowId).list(); + List parentRowIdList = childList.stream().map(u -> u.getParentRowId()).collect(Collectors.toList()); + List parentList = this.lambdaQuery().in(BomNewPbomParentEntity::getRowId, parentRowIdList).select(BomNewPbomParentEntity::getMaterialNo).list(); + Set parentNoSet = parentList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + Set relParentNoSet= Sets.difference(parentNoSet,parentNoResult); + parentNoResult.addAll(materialNos); + while (CollUtil.isNotEmpty(relParentNoSet)){ + getGetParentMaterialByMaterialNoNew(parentNoResult, relParentNoSet); + } + } + /** * 获取物料所有子级 * @@ -199,25 +221,28 @@ public class BomNewPbomParentService extends ServiceImpl getParentMaterialByMaterialNo(String materialNo) { - BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one(); - Set result = new HashSet<>(); - if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) { - Set relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ",")); - - while (CollUtil.isNotEmpty(relSkuNo)) { - result.addAll(relSkuNo); - List relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list(); - relSkuNo.clear(); - Set finalRelSkuNo = relSkuNo; - relSkuList.forEach(k -> { - if (StrUtil.isNotBlank(k.getParentMaterialNo())) { - finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ","))); - } - }); - relSkuNo = finalRelSkuNo; - } - } + Set result=new HashSet<>(); + getGetParentMaterialByMaterialNoNew(result, ImmutableSet.of(materialNo)); return result; +// BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one(); +// Set result = new HashSet<>(); +// if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) { +// Set relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ",")); +// +// while (CollUtil.isNotEmpty(relSkuNo)) { +// result.addAll(relSkuNo); +// List relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list(); +// relSkuNo.clear(); +// Set finalRelSkuNo = relSkuNo; +// relSkuList.forEach(k -> { +// if (StrUtil.isNotBlank(k.getParentMaterialNo())) { +// finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ","))); +// } +// }); +// relSkuNo = finalRelSkuNo; +// } +// } +// return result; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java index bacd2e71..fa43e501 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java @@ -1,6 +1,7 @@ package com.nflg.product.bomnew.service; +import cn.hutool.core.util.StrUtil; import com.google.common.collect.ImmutableList; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.EBomConstant; @@ -56,12 +57,17 @@ public class UserRoleService { */ public String getUserFactory(){ Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId()); - return ""; -// if(userMultiplantFacRoleCount>0){ -// return ""; -// }else { -// return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010; -// } + // return ""; + if(userMultiplantFacRoleCount>0){ + return ""; + }else { + String dptCde=materialMainService.getBaseMapper().getUserDepartmentDptCode(SessionUtil.getDepartRowId()); + if(StrUtil.isNotBlank(dptCde) && dptCde.contains("仙桃公司")){ + return EBomConstant.XIAN_TAO_FACTORY_CODE_1020; + } + return EBomConstant.MAIN_FACTORY_CODE_1010; + // return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010; + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml index 20de0127..2a33a071 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml @@ -229,11 +229,11 @@ and a.fac_code=#{userFac} - and ( b.material_no in + and b.material_no in #{item} - or b.material_no=#{materialNo}) + @@ -371,4 +371,6 @@ + + diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml index 0ea18db0..96234d55 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml @@ -197,4 +197,8 @@ WHERE u.user_code= #{userCode} + +