更新物料行同步主
This commit is contained in:
parent
1aa43f0ef8
commit
a0a17c8d67
|
|
@ -1697,125 +1697,132 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 变更物料
|
||||
* 全量更新目前编辑页面的物料信息,可以理解为同步主数据的物料信息到此处,更新物料的状态,并根据物料的状态更新异常情况。
|
||||
*/
|
||||
|
||||
|
||||
public List<BomNewEbomParentVO> changeMaterial(BomNewEBomChangeDTO dto) {
|
||||
|
||||
CheckEBomException.checkMaterialNoInMain(dto.getDatas());
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(dto.getDatas(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
||||
|
||||
|
||||
List<BomNewEbomParentVO> childList = getChild(dto.getParent().getBomRowId());
|
||||
|
||||
List<BomNewEbomParentVO> tmp1 = dto.getDatas().stream().filter(item -> (Objects.nonNull(item.getRowId()) && item.getRowId() > 0)).collect(Collectors.toList());
|
||||
|
||||
//相同rowid 不同物料号
|
||||
List<BomNewEbomParentVO> unionEdit = tmp1.stream().filter(u -> {
|
||||
return childList.stream().filter(e ->
|
||||
Objects.equals(u.getRowId(), e.getRowId())
|
||||
&& !Objects.equals(u.getMaterialNo(), e.getMaterialNo())
|
||||
).count() > 0;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
//相同rowid 相同物料号
|
||||
List<BomNewEbomParentVO> union2 = tmp1.stream().filter(u -> {
|
||||
return childList.stream().filter(e ->
|
||||
Objects.equals(u.getRowId(), e.getRowId())
|
||||
&& Objects.equals(u.getMaterialNo(), e.getMaterialNo())
|
||||
).count() > 0;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
Map<Long, List<BomNewEbomParentVO>> groupList = childList.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId));
|
||||
|
||||
// Map<Long,List<BomNewEbomParentVO>> groupUnionEdit=unionEdit.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId));
|
||||
|
||||
List<BomNewEbomParentVO> tmp2 = dto.getDatas().stream().filter(item -> Objects.isNull(item.getRowId()) || item.getRowId() == 0).collect(Collectors.toList());
|
||||
|
||||
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2, "projectType");
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(unionEdit, "projectType");
|
||||
|
||||
|
||||
String[] ignore = new String[]{
|
||||
"projectType",
|
||||
"procureType",
|
||||
"materialUnit",
|
||||
"material",
|
||||
"materialTexture",
|
||||
"materialGetType"
|
||||
};
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(union2, ignore);
|
||||
|
||||
|
||||
List<BomNewEbomParentVO> returnList = new ArrayList<>();
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(unionEdit)) {
|
||||
unionEdit.forEach(item -> {
|
||||
// if(item.getMaterialUnit().contains("KG")){
|
||||
// item.setUnitWeight(null);
|
||||
// }else{
|
||||
//// if(StrUtil.isNotBlank(item.getMaterialUnit())) {
|
||||
//// item.setUnitWeight(NumberUtil.toBigDecimal(item.getMaterialUnit().toString()));
|
||||
//// }
|
||||
// }
|
||||
|
||||
|
||||
item.setTotalWeight(NumberUtil.mul(item.getUnitWeight(), item.getNum()));
|
||||
if (StrUtil.isBlank(item.getMaterialNo())) {
|
||||
BeanUtil.copyProperties(groupList.get(item.getRowId()).get(0), item);
|
||||
}
|
||||
});
|
||||
returnList.addAll(unionEdit);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(union2)) {
|
||||
union2.forEach(item -> {
|
||||
if (Objects.isNull(item.getMaterialNo())) {
|
||||
BeanUtil.copyProperties(item, groupList.get(item.getRowId()).get(0));
|
||||
}
|
||||
});
|
||||
returnList.addAll(union2);
|
||||
}
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(tmp2)) {
|
||||
for (BomNewEbomParentVO vo :
|
||||
tmp2) {
|
||||
if (Objects.isNull(vo.getRowId()) || vo.getRowId() == 0) {
|
||||
vo.setDeviseUserCode(SessionUtil.getUserCode());
|
||||
vo.setDeviseName(SessionUtil.getRealName());
|
||||
vo.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
||||
// if (vo.getUnitWeight() == null || BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) {
|
||||
// vo.setUnitWeight(vo.getMaterialWeight());
|
||||
// }
|
||||
|
||||
// if(vo.getMaterialUnit().contains("KG")){
|
||||
// vo.setUnitWeight(null);
|
||||
// }else{
|
||||
// // vo.setUnitWeight(NumberUtil.toBigDecimal( vo.getMaterialUnit() ));
|
||||
// }
|
||||
|
||||
|
||||
dto.getDatas()) {
|
||||
vo.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
returnList.addAll(tmp2);
|
||||
return dto.getDatas();
|
||||
|
||||
}
|
||||
|
||||
List<BomNewEbomParentVO> checkBom = new ArrayList<>();
|
||||
|
||||
checkBom.addAll(unionEdit);
|
||||
checkBom.addAll(union2);
|
||||
checkBom.addAll(tmp2);
|
||||
checkBom.add(dto.getParent());
|
||||
checkBomException(checkBom, Arrays.asList(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()));
|
||||
|
||||
return returnList;
|
||||
}
|
||||
// public List<BomNewEbomParentVO> changeMaterial(BomNewEBomChangeDTO dto) {
|
||||
//
|
||||
// CheckEBomException.checkMaterialNoInMain(dto.getDatas());
|
||||
// List<BomNewEbomParentVO> childList = getChild(dto.getParent().getBomRowId());
|
||||
// List<BomNewEbomParentVO> tmp1 = dto.getDatas().stream().filter(item -> (Objects.nonNull(item.getRowId()) && item.getRowId() > 0)).collect(Collectors.toList());
|
||||
//
|
||||
// //相同rowid 不同物料号
|
||||
// List<BomNewEbomParentVO> unionEdit = tmp1.stream().filter(u -> {
|
||||
// return childList.stream().filter(e ->
|
||||
// Objects.equals(u.getRowId(), e.getRowId())
|
||||
// && !Objects.equals(u.getMaterialNo(), e.getMaterialNo())
|
||||
// ).count() > 0;
|
||||
// }).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// //相同rowid 相同物料号
|
||||
// List<BomNewEbomParentVO> union2 = tmp1.stream().filter(u -> {
|
||||
// return childList.stream().filter(e ->
|
||||
// Objects.equals(u.getRowId(), e.getRowId())
|
||||
// && Objects.equals(u.getMaterialNo(), e.getMaterialNo())
|
||||
// ).count() > 0;
|
||||
// }).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// Map<Long, List<BomNewEbomParentVO>> groupList = childList.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId));
|
||||
//
|
||||
// // Map<Long,List<BomNewEbomParentVO>> groupUnionEdit=unionEdit.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId));
|
||||
//
|
||||
// List<BomNewEbomParentVO> tmp2 = dto.getDatas().stream().filter(item -> Objects.isNull(item.getRowId()) || item.getRowId() == 0).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2, "projectType");
|
||||
// SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(unionEdit, "projectType");
|
||||
//
|
||||
//
|
||||
// String[] ignore = new String[]{
|
||||
// "projectType",
|
||||
// "procureType",
|
||||
// "materialUnit",
|
||||
// "material",
|
||||
// "materialTexture",
|
||||
// "materialGetType"
|
||||
// };
|
||||
// SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(union2, ignore);
|
||||
//
|
||||
//
|
||||
// List<BomNewEbomParentVO> returnList = new ArrayList<>();
|
||||
//
|
||||
//
|
||||
// if (CollectionUtil.isNotEmpty(unionEdit)) {
|
||||
// unionEdit.forEach(item -> {
|
||||
//
|
||||
//
|
||||
// item.setTotalWeight(NumberUtil.mul(item.getUnitWeight(), item.getNum()));
|
||||
// if (StrUtil.isBlank(item.getMaterialNo())) {
|
||||
// BeanUtil.copyProperties(groupList.get(item.getRowId()).get(0), item);
|
||||
// }
|
||||
// });
|
||||
// returnList.addAll(unionEdit);
|
||||
// }
|
||||
//
|
||||
// if (CollectionUtil.isNotEmpty(union2)) {
|
||||
// union2.forEach(item -> {
|
||||
// if (Objects.isNull(item.getMaterialNo())) {
|
||||
// BeanUtil.copyProperties(item, groupList.get(item.getRowId()).get(0));
|
||||
// }
|
||||
// });
|
||||
// returnList.addAll(union2);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (CollectionUtil.isNotEmpty(tmp2)) {
|
||||
// for (BomNewEbomParentVO vo :
|
||||
// tmp2) {
|
||||
// if (Objects.isNull(vo.getRowId()) || vo.getRowId() == 0) {
|
||||
// vo.setDeviseUserCode(SessionUtil.getUserCode());
|
||||
// vo.setDeviseName(SessionUtil.getRealName());
|
||||
// vo.setCreatedBy(SessionUtil.getUserCode());
|
||||
//
|
||||
//// if (vo.getUnitWeight() == null || BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) {
|
||||
//// vo.setUnitWeight(vo.getMaterialWeight());
|
||||
//// }
|
||||
//
|
||||
//// if(vo.getMaterialUnit().contains("KG")){
|
||||
//// vo.setUnitWeight(null);
|
||||
//// }else{
|
||||
//// // vo.setUnitWeight(NumberUtil.toBigDecimal( vo.getMaterialUnit() ));
|
||||
//// }
|
||||
//
|
||||
//
|
||||
// vo.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// returnList.addAll(tmp2);
|
||||
// }
|
||||
//
|
||||
// List<BomNewEbomParentVO> checkBom = new ArrayList<>();
|
||||
//
|
||||
// checkBom.addAll(unionEdit);
|
||||
// checkBom.addAll(union2);
|
||||
// checkBom.addAll(tmp2);
|
||||
// checkBom.add(dto.getParent());
|
||||
// checkBomException(checkBom, Arrays.asList(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()));
|
||||
//
|
||||
// return returnList;
|
||||
// }
|
||||
|
||||
|
||||
public void createOrder() {
|
||||
|
|
|
|||
|
|
@ -125,18 +125,7 @@ public class EBomEdit {
|
|||
|
||||
}
|
||||
|
||||
List<BomNewEbomChildEntity> updateOrCreateChild(BomNewEBomParentEditDTO dto) {
|
||||
List<BomNewEbomChildEntity> childEntity = Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
|
||||
}, dto.getDatas());
|
||||
|
||||
|
||||
for (BomNewEbomChildEntity child :
|
||||
childEntity) {
|
||||
|
||||
child.setEditStatus(dto.getOpType());
|
||||
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
|
||||
public static void checkVirtualPackage(BomNewEbomChildEntity child){
|
||||
if (child.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) {
|
||||
child.setVirtualPartType(VirtualPackageTypeEnum.MAKING_PACKAGE.getValue());
|
||||
child.setVirtualPartIs(1);
|
||||
|
|
@ -151,7 +140,36 @@ public class EBomEdit {
|
|||
child.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue());
|
||||
child.setVirtualPartIs(1);
|
||||
}
|
||||
}
|
||||
|
||||
List<BomNewEbomChildEntity> updateOrCreateChild(BomNewEBomParentEditDTO dto) {
|
||||
List<BomNewEbomChildEntity> childEntity = Convert.convert(new TypeReference<List<BomNewEbomChildEntity>>() {
|
||||
}, dto.getDatas());
|
||||
|
||||
|
||||
for (BomNewEbomChildEntity child :
|
||||
childEntity) {
|
||||
|
||||
child.setEditStatus(dto.getOpType());
|
||||
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
|
||||
// if (child.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) {
|
||||
// child.setVirtualPartType(VirtualPackageTypeEnum.MAKING_PACKAGE.getValue());
|
||||
// child.setVirtualPartIs(1);
|
||||
//
|
||||
// } else if (child.getMaterialName().contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
// child.setVirtualPartType(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue());
|
||||
// child.setVirtualPartIs(1);
|
||||
// } else if (child.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())) {
|
||||
// child.setVirtualPartType(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue());
|
||||
// child.setVirtualPartIs(1);
|
||||
// } else if (child.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())) {
|
||||
// child.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue());
|
||||
// child.setVirtualPartIs(1);
|
||||
// }
|
||||
|
||||
EBomEdit.checkVirtualPackage(child);
|
||||
|
||||
//新增数据
|
||||
if (child.getRowId() == null || child.getRowId().longValue() == 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue