主物料类别

This commit is contained in:
jing's 2023-12-24 19:42:43 +08:00
parent 9535d8d1df
commit 0f795e71fd
4 changed files with 120 additions and 102 deletions

View File

@ -274,7 +274,7 @@ public class EbomApi extends BaseApi {
@ApiOperation("删除物料")
public ResultVO<Boolean> deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteBom(bomRowId);
bomNewEbomParentService.computeLevelNumAndRootState();
return ResultVO.success(true);
}

View File

@ -55,4 +55,9 @@ public class BaseMaterialVO {
@ApiModelProperty("物料大类别")
private String relCategoryCode;
@ApiModelProperty("物料分类编码名称")
private String categoryName;
}

View File

@ -203,6 +203,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 获取变更影响
*
* @param query
* @return
*/
@ -213,8 +214,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* 获取子级
*
@ -233,16 +232,23 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
for (BomNewEbomParentVO child : parentChild) {
if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
child.setCurrentVersion(parentEntity.getCurrentVersion());
child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
//child.setCreatedBy(parentEntity.getCreatedBy());
child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId());
child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName());
child.setSource(parentEntity.getSource());
child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist());
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
}
@ -297,9 +303,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public List<BomNewEbomParentVO> buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> list= getBomTree(rowId);
BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,this.getById(rowId));
if(parentVO!=null) {
List<BomNewEbomParentVO> list = getBomTree(rowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, this.getById(rowId));
if (parentVO != null) {
parentVO.setBomRowId(rowId);
parentVO.setParentRowId(0L);
list.add(parentVO);
@ -466,7 +472,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parent.setChildBomRowId(parent.getRowId());
parent.setParentRowId(0L);
bomTree.add(parent);
EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes(),0L);
EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes(), 0L);
eBomToPBom.convert();
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
@ -476,14 +482,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
}
if(CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())){
if (CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())) {
virtualPackageCompositionService.saveOrUpdateBatch(eBomToPBom.getVirtualPackageCompositionResult());
}
if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())){
if (CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())) {
upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult());
};
if(CollUtil.isNotEmpty(eBomToPBom.getHasConvertEBomRowIds())){
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(),eBomToPBom.getHasConvertEBomRowIds());
}
;
if (CollUtil.isNotEmpty(eBomToPBom.getHasConvertEBomRowIds())) {
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), eBomToPBom.getHasConvertEBomRowIds());
}
@ -581,6 +588,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// CompletableFuture.runAsync(() -> {
try {
this.getBaseMapper().updateRootState();
ebomChildService.getBaseMapper().updateEBomMaterialUse();
this.compucteLevelNum();
} catch (Exception e) {
@ -600,7 +608,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo);
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO=new BomNewEBomParentEditDTO();
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO);
@ -705,11 +713,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
List<Long> revertList=new ArrayList<>();
for (Long bomRowId:
List<Long> revertList = new ArrayList<>();
for (Long bomRowId :
rowIds) {
List<BomNewEbomParentVO> bomTreeList= buildBomTreeContainSelf(bomRowId);
List<BomNewEbomParentVO> bomTreeList = buildBomTreeContainSelf(bomRowId);
//
//
//
@ -735,7 +743,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//忽略叶子节点
revertList.addAll(bomTreeList.stream()
.filter(u->u.getBomRowId()>0)
.filter(u -> u.getBomRowId() > 0)
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
}
@ -785,7 +793,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// return ResultVO.error("数据中包含有下级BOM无法进行复核");
}
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{
List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
@ -797,15 +805,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
});
List<Long> updateReviewIdList = new ArrayList<>();
for (Long bomRowId:
for (Long bomRowId :
rowIds) {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
//错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus);
//筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新
//设计人员只可以复核自己的物料如果存在引用其他用户创建的物料时不可以改变被引用物料的审核状态
updateReviewIdList.addAll( checkEBomException.getAllBomDetail().stream()
.filter(u->u.getBomRowId()>0
updateReviewIdList.addAll(checkEBomException.getAllBomDetail().stream()
.filter(u -> u.getBomRowId() > 0
&& u.getCreatedBy().equals(dto.getUserCode()))
.map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()));
}
@ -830,14 +838,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 更新项目类型
*
* @return
*/
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto ){
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto) {
List<BomNewEbomChildEntity> childEntity=new ArrayList<>();
dto.getRowIdList().forEach(rowid->{
BomNewEbomChildEntity entity=new BomNewEbomChildEntity();
List<BomNewEbomChildEntity> childEntity = new ArrayList<>();
dto.getRowIdList().forEach(rowid -> {
BomNewEbomChildEntity entity = new BomNewEbomChildEntity();
entity.setRowId(rowid);
entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
entity.setProjectType(dto.getProjectType());
@ -850,15 +859,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public BomNewEbomEditDetailVO editDetail(Long bomRowId) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent= this.getById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent);
BomNewEbomParentEntity parent = this.getById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
// List<BomNewEbomParentVO> parentList = new ArrayList<>();
// parentList.add(parentVO);
// materialMainService.intiMaterialInfo(parentList);
@ -898,7 +906,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
BeanUtil.copyProperties(materialMainEntity, baseMaterialVO);
baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState());
return baseMaterialVO;
}
@ -917,11 +924,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 3. 如果是借用件的节点不能删除
* 4. 如果存在其它用户创建的节点不可以删除
* 5. 如果是工艺岗位角色的时候只能删除自己在EBOM中创建的数据
*
* @return
* @throws ExecutionException
* @throws InterruptedException
*/
@Transactional(rollbackFor = Exception.class)
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
@ -942,19 +950,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|| EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus())))
.collect(Collectors.toList());
//借用件不能删除原始bom转换只能自己
List<BomNewEbomParentVO> obomList=null;
List<BomNewEbomParentVO> obomList = null;
if (userRoleService.designer()) {
obomList=bomTree.stream().filter(u -> u.getBomRowId() > 0
obomList = bomTree.stream().filter(u -> u.getBomRowId() > 0
&& (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue())
&&u.getCreatedBy().equals(SessionUtil.getUserCode())
&& u.getCreatedBy().equals(SessionUtil.getUserCode())
))
.collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(obomList)){
if (CollectionUtil.isNotEmpty(obomList)) {
delBom.addAll(obomList);
}
}
@ -969,16 +974,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(delParentRowId)) {
this.getBaseMapper().delBatch(delParentRowId);
}
computeLevelNumAndRootState();
}
//恢复原始bom状态
if(CollectionUtil.isNotEmpty(obomList)){
List<Long> rowIds=obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(obomList)) {
List<Long> rowIds = obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList());
SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds);
}
return true;
}
@ -999,20 +1008,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
ebomChildService.getBaseMapper().updateEBomMaterialUse();
}
if (dto.getParent() != null) {
if (dto.getParent() != null) {
deleteBomChild(dto.getDelDatas());
}
}
ebomChildService.getBaseMapper().updateEBomMaterialUse();
return true;
}
/**
* 提交物料
*
* <p>
* 1.
*/
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
@ -1020,7 +1029,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto);
List<Integer> checkStatus=CollectionUtil.toList(new Integer[]{
List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(),
@ -1032,30 +1041,31 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
});
List<BomNewEbomParentVO> allBom =Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
},eBomEdit.childEntities);
List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, eBomEdit.childEntities);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
allBom.add(Convert.convert(BomNewEbomParentVO.class,eBomEdit.parentEntities.get(0)));
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
allBom.add(Convert.convert(BomNewEbomParentVO.class, eBomEdit.parentEntities.get(0)));
}
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.checkContainExcept(checkStatus);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
if (dto.getParent() != null) {
deleteBomChild(dto.getDelDatas());
}
ebomChildService.getBaseMapper().updateEBomMaterialUse();
return true;
}
@ -1067,32 +1077,35 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 1. 从原始Bom导入的数据数据没有异常的情况下用户不可以删除
* 2. 用户可以直接删除用户单击暂存或是提交时才会保存至数据库
*/
private void deleteBomChild(List<BomNewEbomParentVO> delList){
private void deleteBomChild(List<BomNewEbomParentVO> delList) {
List<BomNewEbomParentVO> delTagList=new ArrayList<>();
List<BomNewEbomParentVO> delTagList = new ArrayList<>();
//原始bom不正常
List<BomNewEbomParentVO> s1List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_BOM.getValue(),u.getSource())
&&!Objects.equals(u.getExceptionStatus(),EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(s1List)){
List<BomNewEbomParentVO> s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
&& !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(s1List)) {
delTagList.addAll(s1List);
}
//手动创建
List<BomNewEbomParentVO> s2List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(),u.getSource() )
|| Objects.equals(EBomSourceEnum.FROM_MDM.getValue(),u.getSource())).collect(Collectors.toList());
List<BomNewEbomParentVO> s2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource())
|| Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(s2List)){
if (CollectionUtil.isNotEmpty(s2List)) {
delTagList.addAll(s2List);
}
if(CollectionUtil.isNotEmpty(delTagList)){
List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId()!=null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(delTagList)) {
List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(rowIdList)) {
ebomChildService.removeByIds(rowIdList);
}
}
}
}

View File

@ -71,7 +71,7 @@
<select id="getMaterialBaseInfo" resultType="com.nflg.product.bomnew.pojo.vo.BaseMaterialVO">
select a.row_id as materialRowId, material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no,a.material_category_code ,material_get_type,drawing_no
,material_texture as material ,material_texture , b.rel_category_code
,material_texture as material ,material_texture , b.rel_category_code,b.category_name
from t_material_main a join t_material_category b on a.material_category_code=b.category_code
where material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">