|
|
|
@ -85,6 +85,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CrmService crmService;
|
|
|
|
private CrmService crmService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
BomNewPbomMaterialUseService pbomMaterialUseService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* pbom-工作列表
|
|
|
|
* pbom-工作列表
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -93,70 +97,92 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public IPage<BomNewPbomParentVO> workDetailsListByPage(BomNewPbomParentQuery query) {
|
|
|
|
public IPage<BomNewPbomParentVO> workDetailsListByPage(BomNewPbomParentQuery query) {
|
|
|
|
//物料编码搜索或图号搜索
|
|
|
|
//物料编码搜索或图号搜索
|
|
|
|
// if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
|
|
|
if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
|
|
|
// String materialNo = query.getMaterialNo();
|
|
|
|
String materialNo = query.getMaterialNo();
|
|
|
|
// if (StrUtil.isBlank(materialNo)) {
|
|
|
|
if (StrUtil.isBlank(materialNo)) {
|
|
|
|
// List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
|
|
|
|
List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
|
|
|
|
// if (CollUtil.isNotEmpty(materialList)) {
|
|
|
|
if (CollUtil.isNotEmpty(materialList)) {
|
|
|
|
// materialNo = materialList.get(0).getMaterialNo();
|
|
|
|
materialNo = materialList.get(0).getMaterialNo();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// if (StrUtil.isNotBlank(materialNo)) {
|
|
|
|
if (StrUtil.isNotBlank(materialNo)) {
|
|
|
|
// List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
|
|
|
|
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList());
|
|
|
|
// if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
|
|
|
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
|
|
|
// List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
|
|
|
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(userRoleService.getUserFactory(),parentMaterialByMaterialNo );
|
|
|
|
// List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo);
|
|
|
|
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(userRoleService.getUserFactory(),parentMaterialByMaterialNo, materialNo);
|
|
|
|
// List<BomNewEbomParentVO> data = new ArrayList<>();
|
|
|
|
List<BomNewPbomParentVO> data = new ArrayList<>();
|
|
|
|
// data.addAll(parents);
|
|
|
|
data.addAll(parents);
|
|
|
|
// data.addAll(childs);
|
|
|
|
data.addAll(childs);
|
|
|
|
// materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
// returnResult = handSeachToTree(parents, childs);
|
|
|
|
return handSeachToTree(parents, childs);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// return null;
|
|
|
|
return null;
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// else {
|
|
|
|
|
|
|
|
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
|
|
|
|
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
|
|
|
|
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Page<BomNewPbomParentVO> handSeachToTree(List<BomNewPbomParentVO> parents, List<BomNewPbomParentVO> childs) {
|
|
|
|
|
|
|
|
Page<BomNewPbomParentVO> resutlData = new Page<>();
|
|
|
|
|
|
|
|
Set<String> parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
Set<String> childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
Set<String> difference = Sets.difference(parentSet, childSet);
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> resultParents = parents.stream().filter(u -> difference.contains(u.getMaterialNo())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
resutlData.setTotal(difference.size());
|
|
|
|
|
|
|
|
resutlData.setSize(difference.size());
|
|
|
|
|
|
|
|
resutlData.setPages(1);
|
|
|
|
|
|
|
|
resutlData.setCurrent(1L);
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> all = new ArrayList<>();
|
|
|
|
|
|
|
|
// all.addAll(resultParents);
|
|
|
|
|
|
|
|
all.addAll(childs);
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> result = new ArrayList<>();
|
|
|
|
|
|
|
|
for (BomNewPbomParentVO vo : resultParents) {
|
|
|
|
|
|
|
|
//vo.setParentRowId(0L);
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> da = new ArrayList<>();
|
|
|
|
|
|
|
|
da.addAll(childs);
|
|
|
|
|
|
|
|
da.add(vo);
|
|
|
|
|
|
|
|
result.addAll(CTreePBomUtils.toTree(0L, da, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resutlData.setRecords(result);
|
|
|
|
|
|
|
|
return resutlData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取物料所有子级
|
|
|
|
* 获取物料所有子级
|
|
|
|
* @param materialNo
|
|
|
|
* @param materialNo
|
|
|
|
* @param selfIs
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// public Set<String> getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) {
|
|
|
|
public Set<String> getParentMaterialByMaterialNo(String materialNo) {
|
|
|
|
// BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
|
|
|
BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one();
|
|
|
|
// Set<String> result = new HashSet<>();
|
|
|
|
Set<String> result = new HashSet<>();
|
|
|
|
// if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
|
|
|
|
if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) {
|
|
|
|
// Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ","));
|
|
|
|
Set<String> relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ","));
|
|
|
|
// if (selfIs && CollUtil.isNotEmpty(relSkuNo)) {
|
|
|
|
|
|
|
|
// relSkuNo = getSelfMaterialNo(relSkuNo);
|
|
|
|
while (CollUtil.isNotEmpty(relSkuNo)) {
|
|
|
|
// }
|
|
|
|
result.addAll(relSkuNo);
|
|
|
|
// while (CollUtil.isNotEmpty(relSkuNo)) {
|
|
|
|
List<BomNewPbomMaterialUseEntity> relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
|
|
|
|
// result.addAll(relSkuNo);
|
|
|
|
relSkuNo.clear();
|
|
|
|
// List<BomNewEbomMaterialUseEntity> relSkuList = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, relSkuNo).list();
|
|
|
|
Set<String> finalRelSkuNo = relSkuNo;
|
|
|
|
// relSkuNo.clear();
|
|
|
|
relSkuList.forEach(k -> {
|
|
|
|
// Set<String> finalRelSkuNo = relSkuNo;
|
|
|
|
if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
|
|
|
|
// relSkuList.forEach(k -> {
|
|
|
|
finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
|
|
|
|
// if (StrUtil.isNotBlank(k.getParentMaterialNo())) {
|
|
|
|
}
|
|
|
|
// finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")));
|
|
|
|
});
|
|
|
|
// }
|
|
|
|
relSkuNo = finalRelSkuNo;
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
// relSkuNo = finalRelSkuNo;
|
|
|
|
}
|
|
|
|
// if (CollUtil.isNotEmpty(relSkuNo) && selfIs) {
|
|
|
|
return result;
|
|
|
|
// relSkuNo = getSelfMaterialNo(relSkuNo);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 已
|
|
|
|
* 已
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param query
|
|
|
|
* @param query
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -166,16 +192,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void exportWorkDetailsListByPage(BomNewPbomParentQuery query,HttpServletResponse response) throws IOException {
|
|
|
|
public void exportWorkDetailsListByPage(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
|
|
|
|
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
|
|
|
|
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
|
|
|
|
new Workbook().addSheet(new ListSheet<BomNewPbomParentVO>() {
|
|
|
|
new Workbook().addSheet(new ListSheet<BomNewPbomParentVO>() {
|
|
|
|
Long n = 1L;
|
|
|
|
Long n = 1L;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected List<BomNewPbomParentVO> more() {
|
|
|
|
protected List<BomNewPbomParentVO> more() {
|
|
|
|
query.setPage(n);
|
|
|
|
query.setPage(n);
|
|
|
|
n++;
|
|
|
|
n++;
|
|
|
|
List<BomNewPbomParentVO> result=workDetailsListByPage(query).getRecords();
|
|
|
|
List<BomNewPbomParentVO> result = workDetailsListByPage(query).getRecords();
|
|
|
|
return CollUtil.isNotEmpty(result)?result:null;
|
|
|
|
return CollUtil.isNotEmpty(result) ? result : null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).writeTo(response.getOutputStream());
|
|
|
|
}).writeTo(response.getOutputStream());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -322,7 +349,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 创建工艺包
|
|
|
|
* 创建工艺包
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -382,7 +408,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void checkCopyBomParam(Long sourceBomRowId , String targetFacCode){
|
|
|
|
private void checkCopyBomParam(Long sourceBomRowId, String targetFacCode) {
|
|
|
|
BomNewPbomParentEntity parent = this.getById(sourceBomRowId);
|
|
|
|
BomNewPbomParentEntity parent = this.getById(sourceBomRowId);
|
|
|
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误,复制源BOM不存在");
|
|
|
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误,复制源BOM不存在");
|
|
|
|
VUtils.isTure(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus())).throwMessage("只有已发布版本,才能复制");
|
|
|
|
VUtils.isTure(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus())).throwMessage("只有已发布版本,才能复制");
|
|
|
|
@ -393,28 +419,29 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 复制前检查
|
|
|
|
* 复制前检查
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param sourceBomRowId
|
|
|
|
* @param sourceBomRowId
|
|
|
|
* @param targetFacCode
|
|
|
|
* @param targetFacCode
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode) throws ExecutionException, InterruptedException {
|
|
|
|
public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode) throws ExecutionException, InterruptedException {
|
|
|
|
checkCopyBomParam(sourceBomRowId,targetFacCode);
|
|
|
|
checkCopyBomParam(sourceBomRowId, targetFacCode);
|
|
|
|
BomCopy bomCopy=new BomCopy(sourceBomRowId,targetFacCode,getAllBom(sourceBomRowId,0));
|
|
|
|
BomCopy bomCopy = new BomCopy(sourceBomRowId, targetFacCode, getAllBom(sourceBomRowId, 0));
|
|
|
|
bomCopy.check();
|
|
|
|
bomCopy.check();
|
|
|
|
return Convert.toList(BomCopyCheckResultVO.class,bomCopy.getCheckList() ) ;
|
|
|
|
return Convert.toList(BomCopyCheckResultVO.class, bomCopy.getCheckList());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void copyFrom(CopyPBomParam param) throws ExecutionException, InterruptedException {
|
|
|
|
public void copyFrom(CopyPBomParam param) throws ExecutionException, InterruptedException {
|
|
|
|
checkCopyBomParam(param.getSourceBomRowId(),param.getTargetFacCode());
|
|
|
|
checkCopyBomParam(param.getSourceBomRowId(), param.getTargetFacCode());
|
|
|
|
BomCopy bomCopy=new BomCopy(param.getSourceBomRowId(),param.getTargetFacCode(),getAllBom(param.getSourceBomRowId(),0));
|
|
|
|
BomCopy bomCopy = new BomCopy(param.getSourceBomRowId(), param.getTargetFacCode(), getAllBom(param.getSourceBomRowId(), 0));
|
|
|
|
bomCopy.copy(param.getCheckResult());
|
|
|
|
bomCopy.copy(param.getCheckResult());
|
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(bomCopy.getParentResult())){
|
|
|
|
if (CollUtil.isNotEmpty(bomCopy.getParentResult())) {
|
|
|
|
this.saveOrUpdateBatch(bomCopy.getParentResult());
|
|
|
|
this.saveOrUpdateBatch(bomCopy.getParentResult());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(CollUtil.isNotEmpty(bomCopy.getChildResult())){
|
|
|
|
if (CollUtil.isNotEmpty(bomCopy.getChildResult())) {
|
|
|
|
pbomChildService.saveBatch(bomCopy.getChildResult());
|
|
|
|
pbomChildService.saveBatch(bomCopy.getChildResult());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -422,8 +449,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取整颗树的BOM明细
|
|
|
|
* 获取整颗树的BOM明细
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param
|
|
|
|
* @param
|
|
|
|
* @param countLevelNum 是否标记层级 0-否 1-是
|
|
|
|
* @param countLevelNum 是否标记层级 0-否 1-是
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* @throws ExecutionException
|
|
|
|
* @throws ExecutionException
|
|
|
|
* @throws InterruptedException
|
|
|
|
* @throws InterruptedException
|
|
|
|
@ -431,7 +459,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
|
|
|
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
|
|
|
|
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
|
|
|
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
|
|
|
AtomicInteger levelNum = new AtomicInteger(1);
|
|
|
|
AtomicInteger levelNum = new AtomicInteger(1);
|
|
|
|
PBomDetailTask detailTask = new PBomDetailTask(bomDetail,countLevelNum,levelNum);
|
|
|
|
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
|
|
|
|
ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
|
|
|
|
ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
|
|
|
|
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> result = submit.join();
|
|
|
|
List<BomNewPbomParentVO> result = submit.join();
|
|
|
|
@ -439,29 +467,29 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<BomNewPbomParentVO> getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException {
|
|
|
|
public List<BomNewPbomParentVO> getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException {
|
|
|
|
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
|
|
|
|
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
|
|
|
|
|
|
|
|
|
|
|
|
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
|
|
|
|
return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
|
|
|
|
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
|
|
|
|
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
|
|
|
|
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
|
|
|
|
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
|
|
|
|
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public Boolean saveAllocationFactory(List<SaveAllocationFactoryDTO> params){
|
|
|
|
public Boolean saveAllocationFactory(List<SaveAllocationFactoryDTO> params) {
|
|
|
|
VUtils.isTure(CollUtil.isEmpty(params)).throwMessage("分配工厂数据为空");
|
|
|
|
VUtils.isTure(CollUtil.isEmpty(params)).throwMessage("分配工厂数据为空");
|
|
|
|
//按分配的工厂分组
|
|
|
|
//按分配的工厂分组
|
|
|
|
Map<String, List<SaveAllocationFactoryDTO>> stringListMap = ListCommonUtil.listGroupMap(params, SaveAllocationFactoryDTO::getProductionFactoryCode);
|
|
|
|
Map<String, List<SaveAllocationFactoryDTO>> stringListMap = ListCommonUtil.listGroupMap(params, SaveAllocationFactoryDTO::getProductionFactoryCode);
|
|
|
|
for (Map.Entry<String, List<SaveAllocationFactoryDTO>> entry : stringListMap.entrySet()) {
|
|
|
|
for (Map.Entry<String, List<SaveAllocationFactoryDTO>> entry : stringListMap.entrySet()) {
|
|
|
|
List<SaveAllocationFactoryDTO> saveList = entry.getValue();
|
|
|
|
List<SaveAllocationFactoryDTO> saveList = entry.getValue();
|
|
|
|
List<Long> rowIds = saveList.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
|
|
|
List<Long> rowIds = saveList.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
|
|
|
pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(),rowIds);
|
|
|
|
pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(), rowIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -470,43 +498,43 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
|
|
|
|
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
|
|
|
|
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId() ,0);
|
|
|
|
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0);
|
|
|
|
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
|
|
|
|
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
|
|
|
|
StringBuilder relPattern=new StringBuilder();
|
|
|
|
StringBuilder relPattern = new StringBuilder();
|
|
|
|
List<BomNewPbomChildEntity> result=new ArrayList<>();
|
|
|
|
List<BomNewPbomChildEntity> result = new ArrayList<>();
|
|
|
|
Boolean match=true;
|
|
|
|
Boolean match = true;
|
|
|
|
for (BomNewPbomParentVO child : childrenVO) {
|
|
|
|
for (BomNewPbomParentVO child : childrenVO) {
|
|
|
|
if(StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType()) ){
|
|
|
|
if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (BomFactorySplitRuleEntity role : relList) {
|
|
|
|
for (BomFactorySplitRuleEntity role : relList) {
|
|
|
|
if(StrUtil.isNotBlank(role.getMaterialCategoryCode())){
|
|
|
|
if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) {
|
|
|
|
match=match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode()));
|
|
|
|
match = match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StrUtil.isNotBlank(role.getDrawingPrefix())){
|
|
|
|
if (StrUtil.isNotBlank(role.getDrawingPrefix())) {
|
|
|
|
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().startsWith(role.getDrawingPrefix()));
|
|
|
|
match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().startsWith(role.getDrawingPrefix()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(StrUtil.isNotBlank(role.getDrawingContain())){
|
|
|
|
if (StrUtil.isNotBlank(role.getDrawingContain())) {
|
|
|
|
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().contains(role.getDrawingPrefix()));
|
|
|
|
match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().contains(role.getDrawingPrefix()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StrUtil.isNotBlank(role.getDrawingSuffix())){
|
|
|
|
if (StrUtil.isNotBlank(role.getDrawingSuffix())) {
|
|
|
|
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().endsWith(role.getDrawingSuffix()));
|
|
|
|
match = match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().endsWith(role.getDrawingSuffix()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(StrUtil.isNotBlank(role.getMaterialNameContain())){
|
|
|
|
if (StrUtil.isNotBlank(role.getMaterialNameContain())) {
|
|
|
|
match=match & (StrUtil.isNotBlank(child.getMaterialName()) && child.getMaterialName().contains(role.getMaterialNameContain()));
|
|
|
|
match = match & (StrUtil.isNotBlank(child.getMaterialName()) && child.getMaterialName().contains(role.getMaterialNameContain()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StrUtil.isNotBlank(role.getMaterialTexture())){
|
|
|
|
if (StrUtil.isNotBlank(role.getMaterialTexture())) {
|
|
|
|
match=match & (StrUtil.isNotBlank(child.getMaterialTexture()) && child.getMaterialName().equals(role.getMaterialTexture()));
|
|
|
|
match = match & (StrUtil.isNotBlank(child.getMaterialTexture()) && child.getMaterialName().equals(role.getMaterialTexture()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StrUtil.isNotBlank(role.getNextMaterialCategoryCode())){
|
|
|
|
if (StrUtil.isNotBlank(role.getNextMaterialCategoryCode())) {
|
|
|
|
List<BomNewPbomParentVO> childSubNodes=childrenVO.stream().filter(u->u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList());
|
|
|
|
List<BomNewPbomParentVO> childSubNodes = childrenVO.stream().filter(u -> u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList());
|
|
|
|
List<BomNewPbomParentVO> relChild = childSubNodes.stream().filter(u -> u.getMaterialCategoryCode().equals(role.getNextMaterialCategoryCode())).collect(Collectors.toList());
|
|
|
|
List<BomNewPbomParentVO> relChild = childSubNodes.stream().filter(u -> u.getMaterialCategoryCode().equals(role.getNextMaterialCategoryCode())).collect(Collectors.toList());
|
|
|
|
match=match & (relChild.size()>0);
|
|
|
|
match = match & (relChild.size() > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(match){
|
|
|
|
if (match) {
|
|
|
|
BomNewPbomChildEntity ent = new BomNewPbomChildEntity();
|
|
|
|
BomNewPbomChildEntity ent = new BomNewPbomChildEntity();
|
|
|
|
ent.setRowId(child.getRowId());
|
|
|
|
ent.setRowId(child.getRowId());
|
|
|
|
ent.setFacCode(role.getFactoryCode());
|
|
|
|
ent.setFacCode(role.getFactoryCode());
|
|
|
|
@ -517,51 +545,49 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(CollUtil.isNotEmpty(result)){
|
|
|
|
if (CollUtil.isNotEmpty(result)) {
|
|
|
|
pbomChildService.saveOrUpdateBatch(result);
|
|
|
|
pbomChildService.saveOrUpdateBatch(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void reConvertToMBom(Long bomRowId,List<Long> backRowId){
|
|
|
|
public void reConvertToMBom(Long bomRowId, List<Long> backRowId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateWrapper<BomNewPbomChildEntity > updateWrapper=new UpdateWrapper<>();
|
|
|
|
UpdateWrapper<BomNewPbomChildEntity> updateWrapper = new UpdateWrapper<>();
|
|
|
|
updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode,backRowId);
|
|
|
|
updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode, backRowId);
|
|
|
|
updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId,backRowId);
|
|
|
|
updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId, backRowId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 发布MBOM
|
|
|
|
* 发布MBOM
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException {
|
|
|
|
public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BomNewPbomParentEntity rootParent = this.getById(bomRowId);
|
|
|
|
BomNewPbomParentEntity rootParent = this.getById(bomRowId);
|
|
|
|
List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0);
|
|
|
|
List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0);
|
|
|
|
|
|
|
|
|
|
|
|
if(StrUtil.isBlank(rootParent.getOrderNo())){
|
|
|
|
if (StrUtil.isBlank(rootParent.getOrderNo())) {
|
|
|
|
String orderNo = crmService.getOrderNo(rootParent.getMaterialNo());
|
|
|
|
String orderNo = crmService.getOrderNo(rootParent.getMaterialNo());
|
|
|
|
rootParent.setOrderNo(orderNo);
|
|
|
|
rootParent.setOrderNo(orderNo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号");
|
|
|
|
VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号");
|
|
|
|
|
|
|
|
|
|
|
|
List<String> noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
|
|
|
List<String> noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
|
|
|
VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList)+"物料暂未分工厂,请分完工厂再进行发布");
|
|
|
|
VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布");
|
|
|
|
ConvertToMBom convertToMBom=new ConvertToMBom(rootParent ,allChild);
|
|
|
|
ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild);
|
|
|
|
convertToMBom.convertToMBom();
|
|
|
|
convertToMBom.convertToMBom();
|
|
|
|
if(CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())){
|
|
|
|
if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) {
|
|
|
|
mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult());
|
|
|
|
mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())){
|
|
|
|
if (CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())) {
|
|
|
|
mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult());
|
|
|
|
mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//将PBOM改为已发布
|
|
|
|
//将PBOM改为已发布
|
|
|
|
@ -569,25 +595,24 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
|
|
rootParent.setStatus(PBomStatusEnum.PUBLISH.getValue());
|
|
|
|
rootParent.setStatus(PBomStatusEnum.PUBLISH.getValue());
|
|
|
|
this.updateById(rootParent);
|
|
|
|
this.updateById(rootParent);
|
|
|
|
if(CollUtil.isNotEmpty(bomRowIds)){
|
|
|
|
if (CollUtil.isNotEmpty(bomRowIds)) {
|
|
|
|
this.getBaseMapper().toMBom(PBomStatusEnum.PUBLISH.getValue(), SessionUtil.getRealName(),bomRowIds);
|
|
|
|
this.getBaseMapper().toMBom(PBomStatusEnum.PUBLISH.getValue(), SessionUtil.getRealName(), bomRowIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 发布Pbom
|
|
|
|
* 发布Pbom
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param bomRowId
|
|
|
|
* @param bomRowId
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean realesePbom(Long bomRowId){
|
|
|
|
public boolean realesePbom(Long bomRowId) {
|
|
|
|
BomNewPbomParentEntity parent = this.getById(bomRowId);
|
|
|
|
BomNewPbomParentEntity parent = this.getById(bomRowId);
|
|
|
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("所选BOM-不存在");
|
|
|
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("所选BOM-不存在");
|
|
|
|
if(parent.getMaterialNo().startsWith("31")){
|
|
|
|
if (parent.getMaterialNo().startsWith("31")) {
|
|
|
|
String orderNo = crmService.getOrderNo(parent.getMaterialNo());
|
|
|
|
String orderNo = crmService.getOrderNo(parent.getMaterialNo());
|
|
|
|
parent.setOrderNo(orderNo);
|
|
|
|
parent.setOrderNo(orderNo);
|
|
|
|
|
|
|
|
|
|
|
|
@ -595,25 +620,25 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
|
|
|
|
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
|
|
|
|
List<Long> bomRowIds = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
|
|
|
List<Long> bomRowIds = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
|
|
|
Integer state= parent.getMaterialNo().startsWith("31")?PBomStatusEnum.WAIT_FACTORY.getValue():PBomStatusEnum.PUBLISH.getValue();
|
|
|
|
Integer state = parent.getMaterialNo().startsWith("31") ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
|
|
|
|
bomRowIds.add(bomRowId);
|
|
|
|
bomRowIds.add(bomRowId);
|
|
|
|
this.getBaseMapper().bomRelease(state,SessionUtil.getUserName(),bomRowIds);
|
|
|
|
this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds);
|
|
|
|
//保存订单号
|
|
|
|
//保存订单号
|
|
|
|
this.updateById(parent);
|
|
|
|
this.updateById(parent);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:" + ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex){
|
|
|
|
return true;
|
|
|
|
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:"+ex.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取CRM 订单号
|
|
|
|
* 获取CRM 订单号
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param materialNo
|
|
|
|
* @param materialNo
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public String getCrmOrderNo(String materialNo){
|
|
|
|
public String getCrmOrderNo(String materialNo) {
|
|
|
|
return crmService.getOrderNo(materialNo);
|
|
|
|
return crmService.getOrderNo(materialNo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|