批量替代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.bomnew.pojo.query.BatchBomQuery;
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
import com.nflg.product.bomnew.pojo.vo.BaseBomVO;
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.pojo.vo.*;
import com.nflg.product.bomnew.service.BatchBomService;
import com.nflg.product.bomnew.service.BomNewEbomExportToSAP;
import com.nflg.product.bomnew.service.BomNewPbomParentService;
@ -25,10 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 批量替代BOM
@ -68,32 +62,34 @@ public class BatchBomApi extends BaseApi {
@PostMapping("updateEBom")
@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<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
// 导入SAP
if (CollUtil.isNotEmpty(addRowIds)) {
addRowIds.forEach(rootRowId -> {
BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP();
exportToSAP.export(rootRowId);
errorMsgVOS.addAll(exportToSAP.export(rootRowId));
});
}
return ResultVO.success();
return ResultVO.success(errorMsgVOS);
}
@PostMapping("updatePBom")
@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<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
// 导入SAP
if (CollUtil.isNotEmpty(addRowIds)) {
addRowIds.forEach(rootRowId -> {
PbomImportToSAPQuery query = new PbomImportToSAPQuery();
query.setRootBomRowId(rootRowId);
query.setIsForSale(false);
bomNewPbomParentService.importToSAP2(query);
errorMsgVOS.addAll(bomNewPbomParentService.importToSAP2(query));
});
}
return ResultVO.success();
return ResultVO.success(errorMsgVOS);
}
@PostMapping("exportExcel")

View File

@ -96,7 +96,6 @@ public class BatchBomService {
.orderByDesc(BomNewEbomParentEntity::getCreatedTime)
.list();
if (CollectionUtil.isNotEmpty(ebomParentEntities)) {
long counter = 0;
for (BomNewEbomParentEntity parent : ebomParentEntities) {
// 按创建时间过滤
if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) {
@ -112,7 +111,6 @@ public class BatchBomService {
}
}
BaseBomVO baseBomVO = new BaseBomVO();
baseBomVO.setOrderNum(++counter);
baseBomVO.setParentRowId(parent.getRowId());
baseBomVO.setParentMaterialNo(parent.getMaterialNo());
baseBomVO.setParentVersion(parent.getCurrentVersion());
@ -153,7 +151,6 @@ public class BatchBomService {
.orderByDesc(BomNewPbomParentEntity::getCreatedTime)
.list();
if (CollectionUtil.isNotEmpty(pbomParentEntities)) {
long counter = 0;
for (BomNewPbomParentEntity parent : pbomParentEntities) {
// 按创建时间过滤
if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) {
@ -169,7 +166,6 @@ public class BatchBomService {
}
}
BaseBomVO baseBomVO = new BaseBomVO();
baseBomVO.setOrderNum(++counter);
baseBomVO.setParentRowId(parent.getRowId());
baseBomVO.setParentMaterialNo(parent.getMaterialNo());
baseBomVO.setParentVersion(parent.getCurrentVersion());
@ -198,22 +194,14 @@ public class BatchBomService {
if (CollectionUtil.isEmpty(resultList)) {
return null;
}
// 实时查询物料的物料描述物料类别等字段
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);
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());
});
initMaterialInfoAndFilter(resultList);
if (CollectionUtil.isNotEmpty(resultList)) {
long counter = 0;
for (BaseBomVO result : resultList) {
result.setOrderNum(++counter);
}
}
BomPageVO<Map<String, Object>, BomTbHeaderVO> pageVO = new BomPageVO<>();
List<Map<String, Object>> records = new ArrayList<>(resultList.size());
resultList.forEach(result -> records.add(BeanUtil.beanToMap(result)));
@ -226,6 +214,37 @@ public class BatchBomService {
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() {
List<BomTbHeaderVO> headerVOS = new ArrayList<>();
headerVOS.add(new BomTbHeaderVO("序号", "orderNum"));