批量替代BOM

√1、查询结果自动过滤父级冻结物料;
√2、SAP导入失败,参照EBOM PBOM给按钮查询SAP异常信息,用户可以重新点“更新BOM并导入SAP”;
√3、导入完成后弹出提示弹窗,成功多少条失败多少条;
√4、表格高度布局调整,统计查询数量和选中数量;
This commit is contained in:
10001392 2024-10-23 16:18:30 +08:00
parent 8f4fb88d4a
commit 4715a6a8fb
2 changed files with 49 additions and 34 deletions

View File

@ -6,10 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.bomnew.pojo.query.BatchBomQuery; import com.nflg.product.bomnew.pojo.query.BatchBomQuery;
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery; import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
import com.nflg.product.bomnew.pojo.vo.BaseBomVO; import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.BomPageVO;
import com.nflg.product.bomnew.pojo.vo.BomTbHeaderVO;
import com.nflg.product.bomnew.service.BatchBomService; import com.nflg.product.bomnew.service.BatchBomService;
import com.nflg.product.bomnew.service.BomNewEbomExportToSAP; import com.nflg.product.bomnew.service.BomNewEbomExportToSAP;
import com.nflg.product.bomnew.service.BomNewPbomParentService; import com.nflg.product.bomnew.service.BomNewPbomParentService;
@ -25,10 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* 批量替代BOM * 批量替代BOM
@ -68,32 +62,34 @@ public class BatchBomApi extends BaseApi {
@PostMapping("updateEBom") @PostMapping("updateEBom")
@ApiOperation("更新EBOM并导入SAP") @ApiOperation("更新EBOM并导入SAP")
public ResultVO<List<BaseBomVO>> updateEBom(@RequestBody List<BaseBomVO> baseBomVOList) { public ResultVO<List<OperationErrorMsgVO>> updateEBom(@RequestBody List<BaseBomVO> baseBomVOList) {
List<Long> addRowIds = batchBomService.updateEBom(baseBomVOList); List<Long> addRowIds = batchBomService.updateEBom(baseBomVOList);
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
// 导入SAP // 导入SAP
if (CollUtil.isNotEmpty(addRowIds)) { if (CollUtil.isNotEmpty(addRowIds)) {
addRowIds.forEach(rootRowId -> { addRowIds.forEach(rootRowId -> {
BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP();
exportToSAP.export(rootRowId); errorMsgVOS.addAll(exportToSAP.export(rootRowId));
}); });
} }
return ResultVO.success(); return ResultVO.success(errorMsgVOS);
} }
@PostMapping("updatePBom") @PostMapping("updatePBom")
@ApiOperation("更新PBOM并导入SAP") @ApiOperation("更新PBOM并导入SAP")
public ResultVO<List<BaseBomVO>> updatePBom(@RequestBody List<BaseBomVO> baseBomVOList) { public ResultVO<List<OperationErrorMsgVO>> updatePBom(@RequestBody List<BaseBomVO> baseBomVOList) {
List<Long> addRowIds = batchBomService.updatePBom(baseBomVOList); List<Long> addRowIds = batchBomService.updatePBom(baseBomVOList);
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
// 导入SAP // 导入SAP
if (CollUtil.isNotEmpty(addRowIds)) { if (CollUtil.isNotEmpty(addRowIds)) {
addRowIds.forEach(rootRowId -> { addRowIds.forEach(rootRowId -> {
PbomImportToSAPQuery query = new PbomImportToSAPQuery(); PbomImportToSAPQuery query = new PbomImportToSAPQuery();
query.setRootBomRowId(rootRowId); query.setRootBomRowId(rootRowId);
query.setIsForSale(false); query.setIsForSale(false);
bomNewPbomParentService.importToSAP2(query); errorMsgVOS.addAll(bomNewPbomParentService.importToSAP2(query));
}); });
} }
return ResultVO.success(); return ResultVO.success(errorMsgVOS);
} }
@PostMapping("exportExcel") @PostMapping("exportExcel")

View File

@ -96,7 +96,6 @@ public class BatchBomService {
.orderByDesc(BomNewEbomParentEntity::getCreatedTime) .orderByDesc(BomNewEbomParentEntity::getCreatedTime)
.list(); .list();
if (CollectionUtil.isNotEmpty(ebomParentEntities)) { if (CollectionUtil.isNotEmpty(ebomParentEntities)) {
long counter = 0;
for (BomNewEbomParentEntity parent : ebomParentEntities) { for (BomNewEbomParentEntity parent : ebomParentEntities) {
// 按创建时间过滤 // 按创建时间过滤
if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) { if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) {
@ -112,7 +111,6 @@ public class BatchBomService {
} }
} }
BaseBomVO baseBomVO = new BaseBomVO(); BaseBomVO baseBomVO = new BaseBomVO();
baseBomVO.setOrderNum(++counter);
baseBomVO.setParentRowId(parent.getRowId()); baseBomVO.setParentRowId(parent.getRowId());
baseBomVO.setParentMaterialNo(parent.getMaterialNo()); baseBomVO.setParentMaterialNo(parent.getMaterialNo());
baseBomVO.setParentVersion(parent.getCurrentVersion()); baseBomVO.setParentVersion(parent.getCurrentVersion());
@ -153,7 +151,6 @@ public class BatchBomService {
.orderByDesc(BomNewPbomParentEntity::getCreatedTime) .orderByDesc(BomNewPbomParentEntity::getCreatedTime)
.list(); .list();
if (CollectionUtil.isNotEmpty(pbomParentEntities)) { if (CollectionUtil.isNotEmpty(pbomParentEntities)) {
long counter = 0;
for (BomNewPbomParentEntity parent : pbomParentEntities) { for (BomNewPbomParentEntity parent : pbomParentEntities) {
// 按创建时间过滤 // 按创建时间过滤
if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) { if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) {
@ -169,7 +166,6 @@ public class BatchBomService {
} }
} }
BaseBomVO baseBomVO = new BaseBomVO(); BaseBomVO baseBomVO = new BaseBomVO();
baseBomVO.setOrderNum(++counter);
baseBomVO.setParentRowId(parent.getRowId()); baseBomVO.setParentRowId(parent.getRowId());
baseBomVO.setParentMaterialNo(parent.getMaterialNo()); baseBomVO.setParentMaterialNo(parent.getMaterialNo());
baseBomVO.setParentVersion(parent.getCurrentVersion()); baseBomVO.setParentVersion(parent.getCurrentVersion());
@ -198,22 +194,14 @@ public class BatchBomService {
if (CollectionUtil.isEmpty(resultList)) { if (CollectionUtil.isEmpty(resultList)) {
return null; return null;
} }
// 实时查询物料的物料描述物料类别等字段 initMaterialInfoAndFilter(resultList);
List<BaseMaterialVO> tempList = new ArrayList<>(); if (CollectionUtil.isNotEmpty(resultList)) {
resultList.forEach(result -> { long counter = 0;
BaseMaterialVO parent = new BaseMaterialVO(); for (BaseBomVO result : resultList) {
parent.setMaterialNo(result.getParentMaterialNo()); result.setOrderNum(++counter);
tempList.add(parent); }
}); }
materialMainService.intiMaterialInfo(tempList);
Map<String, BaseMaterialVO> materialMp = ListCommonUtil.listToMap(tempList, BaseMaterialVO::getMaterialNo);
resultList.forEach(result -> {
result.setParentMaterialRowId(materialMp.get(result.getParentMaterialNo()).getMaterialRowId());
result.setParentMaterialDesc(materialMp.get(result.getParentMaterialNo()).getMaterialDesc());
result.setCategoryCode(materialMp.get(result.getParentMaterialNo()).getMaterialCategoryCode());
result.setRelCategoryCode(materialMp.get(result.getParentMaterialNo()).getRelCategoryCode());
result.setCategoryName(materialMp.get(result.getParentMaterialNo()).getCategoryName());
});
BomPageVO<Map<String, Object>, BomTbHeaderVO> pageVO = new BomPageVO<>(); BomPageVO<Map<String, Object>, BomTbHeaderVO> pageVO = new BomPageVO<>();
List<Map<String, Object>> records = new ArrayList<>(resultList.size()); List<Map<String, Object>> records = new ArrayList<>(resultList.size());
resultList.forEach(result -> records.add(BeanUtil.beanToMap(result))); resultList.forEach(result -> records.add(BeanUtil.beanToMap(result)));
@ -226,6 +214,37 @@ public class BatchBomService {
return pageVO; return pageVO;
} }
/**
* 初始化物料信息并过滤掉冻结物料
*/
private void initMaterialInfoAndFilter(List<BaseBomVO> resultList) {
// 实时查询物料的物料描述物料类别等字段
List<BaseMaterialVO> tempList = new ArrayList<>();
resultList.forEach(result -> {
BaseMaterialVO parent = new BaseMaterialVO();
parent.setMaterialNo(result.getParentMaterialNo());
tempList.add(parent);
});
materialMainService.intiMaterialInfo(tempList);
Map<String, BaseMaterialVO> materialMp = ListCommonUtil.listToMap(tempList, BaseMaterialVO::getMaterialNo);
ListIterator<BaseBomVO> listIterator = resultList.listIterator();
while (listIterator.hasNext()) {
BaseBomVO result = listIterator.next();
// 过滤掉冻结物料
if (ObjectUtil.isNotEmpty(materialMp.get(result.getParentMaterialNo()))
&& (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(materialMp.get(result.getParentMaterialNo()).getMaterialState())
|| MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(materialMp.get(result.getParentMaterialNo()).getMaterialState()))) {
listIterator.remove();
continue;
}
result.setParentMaterialRowId(materialMp.get(result.getParentMaterialNo()).getMaterialRowId());
result.setParentMaterialDesc(materialMp.get(result.getParentMaterialNo()).getMaterialDesc());
result.setCategoryCode(materialMp.get(result.getParentMaterialNo()).getMaterialCategoryCode());
result.setRelCategoryCode(materialMp.get(result.getParentMaterialNo()).getRelCategoryCode());
result.setCategoryName(materialMp.get(result.getParentMaterialNo()).getCategoryName());
}
}
private List<BomTbHeaderVO> getTbHeaders() { private List<BomTbHeaderVO> getTbHeaders() {
List<BomTbHeaderVO> headerVOS = new ArrayList<>(); List<BomTbHeaderVO> headerVOS = new ArrayList<>();
headerVOS.add(new BomTbHeaderVO("序号", "orderNum")); headerVOS.add(new BomTbHeaderVO("序号", "orderNum"));