1-pbom-工作表查询

2-pbom工作表工厂权限问题
This commit is contained in:
luoliming 2024-08-10 14:27:25 +08:00
parent cddc01abc3
commit 4c6f47cf2c
6 changed files with 81 additions and 28 deletions

View File

@ -3,7 +3,9 @@ package com.nflg.product.bomnew.api.user;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.ImmutableList;
import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.starter.annotation.LogRecord; import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.api.BaseApi;
@ -371,4 +373,16 @@ public class PBomApi extends BaseApi {
bomNewPbomParentService.generateNoticeNum(param); bomNewPbomParentService.generateNoticeNum(param);
return ResultVO.success(true); return ResultVO.success(true);
} }
@GetMapping("getUserAuthFac")
@ApiOperation("获取用可查看pbom工厂")
public ResultVO<List<String>> getUserAuthFac() {
String userFactory = userRoleService.getUserFactory();
if(StrUtil.isBlank(userFactory)){
return ResultVO.success(ImmutableList.of("1010","1020"));
}
return ResultVO.success(ImmutableList.of(userFactory));
}
} }

View File

@ -60,4 +60,6 @@ public interface MaterialMainMapper extends BaseMapper<MaterialMainEntity> {
List<RolePostVo> getRolePostByUserId(@Param("userRowId") Long userRowId); List<RolePostVo> getRolePostByUserId(@Param("userRowId") Long userRowId);
UserInfoVO getUserInfoByUserCode(@Param("userCode")String userCode); UserInfoVO getUserInfoByUserCode(@Param("userCode")String userCode);
String getUserDepartmentDptCode(@Param("rowId") Long rowId);
} }

View File

@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.context.LogRecordContext;
@ -141,8 +142,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<String> parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo)); List<String> parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo));
parentMaterialByMaterialNo.add(materialNo); parentMaterialByMaterialNo.add(materialNo);
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo); String queryFac= StrUtil.isBlank(query.getFacCode())? userRoleService.getUserFactory():query.getFacCode();
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo, materialNo);
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo);
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo);
List<BomNewPbomParentVO> data = new ArrayList<>(); List<BomNewPbomParentVO> data = new ArrayList<>();
data.addAll(parents); data.addAll(parents);
data.addAll(childs); data.addAll(childs);
@ -155,6 +158,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return handSeachToTree(parents, childs); return handSeachToTree(parents, childs);
} }
} }
return new Page<>(); return new Page<>();
@ -191,6 +195,24 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return resutlData; return resutlData;
} }
/**
* 获取物料编码所有父节点
* @param materialNos
* @return
*/
public void getGetParentMaterialByMaterialNoNew(Set<String> parentNoResult, Set<String> materialNos){
List<BomNewPbomChildEntity> childList = pbomChildService.lambdaQuery().in(BomNewPbomChildEntity::getMaterialNo, materialNos).select(BomNewPbomChildEntity::getParentRowId).list();
List<Long> parentRowIdList = childList.stream().map(u -> u.getParentRowId()).collect(Collectors.toList());
List<BomNewPbomParentEntity> parentList = this.lambdaQuery().in(BomNewPbomParentEntity::getRowId, parentRowIdList).select(BomNewPbomParentEntity::getMaterialNo).list();
Set<String> parentNoSet = parentList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
Set<String> relParentNoSet= Sets.difference(parentNoSet,parentNoResult);
parentNoResult.addAll(materialNos);
while (CollUtil.isNotEmpty(relParentNoSet)){
getGetParentMaterialByMaterialNoNew(parentNoResult, relParentNoSet);
}
}
/** /**
* 获取物料所有子级 * 获取物料所有子级
* *
@ -199,25 +221,28 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
* @return * @return
*/ */
public Set<String> getParentMaterialByMaterialNo(String materialNo) { public Set<String> getParentMaterialByMaterialNo(String materialNo) {
BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one(); Set<String> result=new HashSet<>();
Set<String> result = new HashSet<>(); getGetParentMaterialByMaterialNoNew(result, ImmutableSet.of(materialNo));
if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ","));
while (CollUtil.isNotEmpty(relSkuNo)) {
result.addAll(relSkuNo);
List<BomNewPbomMaterialUseEntity> relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
relSkuNo.clear();
Set<String> finalRelSkuNo = relSkuNo;
relSkuList.forEach(k -> {
if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
}
});
relSkuNo = finalRelSkuNo;
}
}
return result; return result;
// BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one();
// Set<String> result = new HashSet<>();
// if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
// Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ","));
//
// while (CollUtil.isNotEmpty(relSkuNo)) {
// result.addAll(relSkuNo);
// List<BomNewPbomMaterialUseEntity> relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
// relSkuNo.clear();
// Set<String> finalRelSkuNo = relSkuNo;
// relSkuList.forEach(k -> {
// if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
// finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
// }
// });
// relSkuNo = finalRelSkuNo;
// }
// }
// return result;
} }

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.service; package com.nflg.product.bomnew.service;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.constant.EBomConstant;
@ -56,12 +57,17 @@ public class UserRoleService {
*/ */
public String getUserFactory(){ public String getUserFactory(){
Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId()); Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId());
return ""; // return "";
// if(userMultiplantFacRoleCount>0){ if(userMultiplantFacRoleCount>0){
// return ""; return "";
// }else { }else {
// return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010; 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;
}
} }

View File

@ -229,11 +229,11 @@
<if test="userFac!=null and userFac!=''"> <if test="userFac!=null and userFac!=''">
and a.fac_code=#{userFac} and a.fac_code=#{userFac}
</if> </if>
and ( b.material_no in and b.material_no in
<foreach collection="materialNoList" item="item" open="(" separator="," close=")"> <foreach collection="materialNoList" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
or b.material_no=#{materialNo})
</select> </select>
@ -371,4 +371,6 @@
</mapper> </mapper>

View File

@ -197,4 +197,8 @@
WHERE WHERE
u.user_code= #{userCode} u.user_code= #{userCode}
</select> </select>
<select id="getUserDepartmentDptCode" resultType="java.lang.String">
select dpt_code from t_authority_department where row_id=#{rowId}
</select>
</mapper> </mapper>