parent
cddc01abc3
commit
4c6f47cf2c
|
|
@ -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<List<String>> getUserAuthFac() {
|
||||
String userFactory = userRoleService.getUserFactory();
|
||||
if(StrUtil.isBlank(userFactory)){
|
||||
return ResultVO.success(ImmutableList.of("1010","1020"));
|
||||
}
|
||||
return ResultVO.success(ImmutableList.of(userFactory));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,6 @@ public interface MaterialMainMapper extends BaseMapper<MaterialMainEntity> {
|
|||
List<RolePostVo> getRolePostByUserId(@Param("userRowId") Long userRowId);
|
||||
|
||||
UserInfoVO getUserInfoByUserCode(@Param("userCode")String userCode);
|
||||
|
||||
String getUserDepartmentDptCode(@Param("rowId") Long rowId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<BomNewPbomParentMapper,
|
|||
List<String> parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo));
|
||||
parentMaterialByMaterialNo.add(materialNo);
|
||||
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo);
|
||||
List<BomNewPbomParentVO> 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<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo);
|
||||
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo);
|
||||
List<BomNewPbomParentVO> data = new ArrayList<>();
|
||||
data.addAll(parents);
|
||||
data.addAll(childs);
|
||||
|
|
@ -155,6 +158,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
|
||||
materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||
return handSeachToTree(parents, childs);
|
||||
|
||||
}
|
||||
}
|
||||
return new Page<>();
|
||||
|
|
@ -191,6 +195,24 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
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
|
||||
*/
|
||||
public Set<String> getParentMaterialByMaterialNo(String materialNo) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Set<String> result=new HashSet<>();
|
||||
getGetParentMaterialByMaterialNoNew(result, ImmutableSet.of(materialNo));
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -229,11 +229,11 @@
|
|||
<if test="userFac!=null and userFac!=''">
|
||||
and a.fac_code=#{userFac}
|
||||
</if>
|
||||
and ( b.material_no in
|
||||
and b.material_no in
|
||||
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
or b.material_no=#{materialNo})
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
|
@ -371,4 +371,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -197,4 +197,8 @@
|
|||
WHERE
|
||||
u.user_code= #{userCode}
|
||||
</select>
|
||||
|
||||
<select id="getUserDepartmentDptCode" resultType="java.lang.String">
|
||||
select dpt_code from t_authority_department where row_id=#{rowId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue