调整异常

This commit is contained in:
jing's 2023-12-24 22:54:56 +08:00
parent 0f795e71fd
commit 7b3f7318ba
5 changed files with 100 additions and 19 deletions

View File

@ -185,7 +185,7 @@ public class EbomApi extends BaseApi {
// }
@PostMapping("createBomImport")
@ApiOperation("创建EBOM-导入")
public ResultVO<Boolean> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException {
public ResultVO<Boolean> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException, ExecutionException, InterruptedException {
if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
return ResultVO.error("请上传Excel文件");
}

View File

@ -274,6 +274,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public List<BomNewEbomParentVO> getChildBatch(List<Long> rowIds) {
List<BomNewEbomParentVO> result = new ArrayList<>();
for (Long bomRowId : rowIds) {
@ -283,6 +289,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* 获取整个BOM树
*
@ -599,19 +611,40 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException {
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException, ExecutionException, InterruptedException {
if(dto.getParent()==null){
VUtils.isTure(true).throwMessage( "没选择父级不能导入");
}
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, result);
List<String> materialNos = datas.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
//检查物料编码是否在主数据中存在
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo);
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO);
if(dto.getParent().getBomRowId()>0 && (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))){
deleteBom(dto.getParent().getBomRowId());
}
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
@ -620,6 +653,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
computeLevelNumAndRootState();
}
@ -808,6 +844,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
for (Long bomRowId :
rowIds) {
CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
checkEBomException.initException();
//错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus);
//筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新
@ -947,7 +984,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//设计 工艺删录入 excel导入
delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0
&& (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus())))
||u.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())))
.collect(Collectors.toList());
//借用件不能删除原始bom转换只能自己
@ -1001,7 +1038,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public Boolean temporary(BomNewEBomParentEditDTO dto) {
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
dto.setOpType(EbomEditStatusEnum.HANDLER_CREATED.getValue());
eBomEdit.temporary(dto);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
@ -1011,7 +1050,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
ebomChildService.getBaseMapper().updateEBomMaterialUse();
}
if (dto.getParent() != null) {
if (dto.getParent() != null) {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
}
@ -1027,6 +1066,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
dto.setOpType(EbomEditStatusEnum.HANDLER_FINISHED.getValue());
eBomEdit.temporary(dto);
List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
@ -1049,6 +1089,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.initException();
checkEBomException.checkContainExcept(checkStatus);
@ -1063,7 +1104,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
if (dto.getParent() != null) {
deleteBomChild(dto.getDelDatas());
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
}
ebomChildService.getBaseMapper().updateEBomMaterialUse();
return true;
@ -1079,6 +1122,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
*/
private void deleteBomChild(List<BomNewEbomParentVO> delList) {
if(CollectionUtil.isEmpty(delList)){
return;
}
List<BomNewEbomParentVO> delTagList = new ArrayList<>();
//原始bom不正常
List<BomNewEbomParentVO> s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())

View File

@ -182,11 +182,17 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
child.setDeviseUserCode(parent.getDeviseUserCode());
child.setDeviseName(parent.getDeviseName());
child.setDeptName(parent.getDeptName());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(OriginalStatusEnum.UN_CONVERT.getValue());
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
try {
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(OriginalStatusEnum.UN_CONVERT.getValue());
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
}
}catch (Exception e){
e.getMessage();
}
}
}
}

View File

@ -65,6 +65,12 @@ public class CheckEBomException {
//初始化物料信息
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail);
checkException();
}
public void checkException(){
for (BomNewEbomParentVO vo : allBomDetail) {
if(Objects.isNull(vo.getExceptionStatus())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
@ -89,9 +95,11 @@ public class CheckEBomException {
}
checkOther();
}
/**
* 检查 EXCEPT_NO_3 EXCEPT_NO_6 EXCEPT_NO_9 EXCEPT_NO_10
*

View File

@ -106,21 +106,39 @@ public class EBomEdit {
childEntities = new ArrayList<>();
//添加数据
if (dto.getParent() == null) {
CheckEBomException eBomException=new CheckEBomException( dto.getDatas() );
eBomException.checkException();
for (BomNewEbomParentVO vo : dto.getDatas()) {
parentEntities.add(createParentBomInfo (vo));
}
} else {
BomNewEbomParentEntity parent;
List<BomNewEbomParentVO> exceptList=new ArrayList<>();
exceptList.addAll(dto.getDatas());
//缺bom
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
dto.getParent().setBomRowId(dto.getParent().getRowId());
exceptList.add(dto.getParent());
CheckEBomException eBomException=new CheckEBomException( exceptList );
eBomException.checkException();
parent = createParentBomInfo(dto.getParent());
parentEntities.add(parent);
}else {
exceptList.add(dto.getParent());
CheckEBomException eBomException=new CheckEBomException( exceptList );
eBomException.checkException();
parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent());
parent.setEditStatus(dto.getOpType());
parentEntities.add(parent);
}
SpringUtil.getBean(BomNewEbomParentService.class).initBomException(dto.getDatas());
childEntities=Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
}, dto.getDatas());
@ -130,7 +148,7 @@ public class EBomEdit {
//child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
List<String> roleList= SpringUtil.getBean(UserRoleService.class).getUserPost();
//新增数据
if(child.getRowId()==null || child.getRowId().longValue()==0){
child.setRowId(IdWorker.getId());
@ -141,14 +159,21 @@ public class EBomEdit {
child.setCreatedTime(LocalDateTime.now());
child.setCreatedBy(SessionUtil.getUserCode());
child.setSourceRowId(0l);
child.setParentRowId(parent.getRowId());
child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
//工艺人员
if(roleList.contains(EBomConstant.TECHNICIAN)){
parent.setStatus(EBomStatusEnum.CHECKED.getValue());
}
}
child.setEditStatus(dto.getOpType());
parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
child.setParentRowId(parent.getRowId());
if(StrUtil.isEmpty(child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
}
@ -170,8 +195,4 @@ public class EBomEdit {
}
}