|
@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotlockstock.vo.IotLockStockPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotsappickinglist.vo.IotSapPickingListPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotsapstock.vo.IotSapStockPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotlockstock.IotLockStockDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmaterial.IotMaterialDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotsappickinglist.IotSapPickingListDO;
|
|
@@ -570,7 +571,9 @@ public class IotSapServiceImpl implements IotSapService {
|
|
|
});
|
|
|
// 查询所有SAP库存集合A,以 ‘工厂编码+库存地点code+物料编码’ 为唯一key 如果 sapStocks 中有物料不在A中 新增物料
|
|
|
Set<String> existStockKeys = new HashSet<>();
|
|
|
- List<IotSapStockDO> existStocks = TenantUtils.execute(1L, () -> iotSapStockMapper.selectList());
|
|
|
+ IotSapStockPageReqVO reqVO = new IotSapStockPageReqVO();
|
|
|
+ reqVO.setFactoryCode(factoryCode);
|
|
|
+ List<IotSapStockDO> existStocks = TenantUtils.execute(1L, () -> iotSapStockMapper.selectList(reqVO));
|
|
|
if (CollUtil.isNotEmpty(existStocks)) {
|
|
|
existStockKeys = existStocks.stream()
|
|
|
// 过滤非空对象和非空code
|
|
@@ -593,10 +596,10 @@ public class IotSapServiceImpl implements IotSapService {
|
|
|
(existing, replacement) -> existing // 处理键冲突: 保留先出现的元素
|
|
|
));
|
|
|
|
|
|
- // 找出需要新增的库存(SAP物料编码去掉前导零后,不在现有物料集合中的记录)
|
|
|
+ // 找出当前工厂 需要新增的库存(SAP物料编码去掉前导零后,不在现有物料集合中的记录)
|
|
|
Set<String> finalExistStockKeys = existStockKeys;
|
|
|
List<IotSapStockVO> newStocks = sapStocks.stream()
|
|
|
- .filter(stk -> StrUtil.isNotBlank(stk.getMATNR()) && StrUtil.isNotBlank(stk.getLGORT())
|
|
|
+ .filter(stk -> factoryCode.equals(stk.getWERKS()) && StrUtil.isNotBlank(stk.getMATNR()) && StrUtil.isNotBlank(stk.getLGORT())
|
|
|
&& storageLocationIdPair.containsKey(StrUtil.join("-", stk.getWERKS(), stk.getLGORT())))
|
|
|
.filter(stk -> {
|
|
|
// 处理前导零:移除MATNR前的 00000000
|
|
@@ -664,7 +667,7 @@ public class IotSapServiceImpl implements IotSapService {
|
|
|
// pms中已有 SAP返回数据中也存在 则更新 再次判断更新deptId 因为有可能又将SAP库存地点关联到了 组织部门
|
|
|
List<IotSapStockDO> actualUpdatedStocks = new ArrayList<>();
|
|
|
// key库存id-物料编码 value库存对象
|
|
|
- Map<String, IotSapStockVO> existStockPair = createExistStockMap(sapStocks, existStockKeys, storageLocationIdPair);
|
|
|
+ Map<String, IotSapStockVO> existStockPair = createExistStockMap(factoryCode, sapStocks, existStockKeys, storageLocationIdPair);
|
|
|
if (CollUtil.isNotEmpty(existStockPair)) {
|
|
|
Map<String, IotSapStockDO> finalTobeUpdatedStockPair = tobeUpdatedStockPair;
|
|
|
existStockPair.forEach((k, v) -> {
|
|
@@ -777,10 +780,10 @@ public class IotSapServiceImpl implements IotSapService {
|
|
|
* @param storageLocationIdPair key库存地点code value库存地点id
|
|
|
* @return 物料编码到描述的映射
|
|
|
*/
|
|
|
- private Map<String, IotSapStockVO> createExistStockMap(List<IotSapStockVO> sapStocks, Set<String> existStockKeys,
|
|
|
+ private Map<String, IotSapStockVO> createExistStockMap(String factoryCode, List<IotSapStockVO> sapStocks, Set<String> existStockKeys,
|
|
|
Map<String, Long> storageLocationIdPair) {
|
|
|
return sapStocks.stream()
|
|
|
- .filter(sapStock -> StrUtil.isNotBlank(sapStock.getMATNR()) &&
|
|
|
+ .filter(sapStock -> factoryCode.equals(sapStock.getWERKS()) && StrUtil.isNotBlank(sapStock.getMATNR()) &&
|
|
|
StrUtil.isNotBlank(sapStock.getLGORT()) &&
|
|
|
storageLocationIdPair.containsKey(StrUtil.join("-", sapStock.getWERKS(), sapStock.getLGORT())))
|
|
|
.map(sapStock -> {
|