|
@@ -5,13 +5,22 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.ObjUtil;
|
|
import cn.hutool.core.util.ObjUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
|
|
|
+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.iotmaterial.IotMaterialDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsappickinglist.IotSapPickingListDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstock.IotSapStockDO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotlockstock.IotLockStockMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmaterial.IotMaterialMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmaterial.IotMaterialMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmaterial.IotSapMaterialMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmaterial.IotSapMaterialMapper;
|
|
-import cn.iocoder.yudao.module.pms.sap.vo.IotSapMaterialVO;
|
|
|
|
-import cn.iocoder.yudao.module.pms.sap.vo.IotSapMerchantVO;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotsappickinglist.IotSapPickingListMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotsapstock.IotSapStockMapper;
|
|
|
|
+import cn.iocoder.yudao.module.pms.sap.vo.*;
|
|
import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
|
|
import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
|
|
import cn.iocoder.yudao.module.supplier.dal.mysql.product.SupplierMapper;
|
|
import cn.iocoder.yudao.module.supplier.dal.mysql.product.SupplierMapper;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.saporg.SapOrgApi;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.saporg.dto.SapOrgRespDTO;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -20,6 +29,8 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import java.util.concurrent.CountDownLatch;
|
|
@@ -43,6 +54,16 @@ public class IotSapServiceImpl implements IotSapService {
|
|
private ThreadPoolTaskExecutor pmsThreadPoolTaskExecutor;
|
|
private ThreadPoolTaskExecutor pmsThreadPoolTaskExecutor;
|
|
@Autowired
|
|
@Autowired
|
|
private SupplierMapper supplierMapper;
|
|
private SupplierMapper supplierMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SapOrgApi sapOrgApi;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DeptApi deptApi;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotLockStockMapper iotLockStockMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotSapStockMapper iotSapStockMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IotSapPickingListMapper iotSapPickingListMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void processMaterials(List<IotSapMaterialVO> sapMaterials) {
|
|
public void processMaterials(List<IotSapMaterialVO> sapMaterials) {
|
|
@@ -189,6 +210,298 @@ public class IotSapServiceImpl implements IotSapService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void processPickingLists(String factoryCode, List<IotSapPickingListHeadVO> pickingListHeads, List<IotSapPickingListItemVO> pickingListItems) {
|
|
|
|
+ // 查询出所有成本中心 对应的 deptId 新增本地库存时 可以匹配
|
|
|
|
+ List<SapOrgRespDTO> costCenters = TenantUtils.execute(1L, () -> sapOrgApi.getSapOrgByType(2));
|
|
|
|
+ // 查询所有工厂
|
|
|
|
+ List<SapOrgRespDTO> factories = TenantUtils.execute(1L, () -> sapOrgApi.getSapOrgByType(1));
|
|
|
|
+ // key成本中心id value成本中心code
|
|
|
|
+ Map<Long, String> costCenterCodeIdPair = new HashMap<>();
|
|
|
|
+ // key工厂code value工厂id
|
|
|
|
+ Map<String, Long> factoryIdPair = new HashMap<>();
|
|
|
|
+ // key成本中心code value成本中心id
|
|
|
|
+ Map<String, Long> costCenterIdPair = new HashMap<>();
|
|
|
|
+ // key成本中心code value工厂code
|
|
|
|
+ Map<String, String> costCenterFactoryCodePair = new HashMap<>();
|
|
|
|
+ // key成本中心code value部门id
|
|
|
|
+ Map<String, Long> costCenterCodeDeptIdPair = new HashMap<>();
|
|
|
|
+ // 工厂集合
|
|
|
|
+ factories.forEach(factory -> {
|
|
|
|
+ factoryIdPair.put(factory.getFactoryCode(), factory.getId());
|
|
|
|
+ });
|
|
|
|
+ // 成本中心集合
|
|
|
|
+ costCenters.forEach(center -> {
|
|
|
|
+ costCenterCodeIdPair.put(center.getId(), center.getCostCenterCode());
|
|
|
|
+ costCenterIdPair.put(center.getCostCenterCode(), center.getId());
|
|
|
|
+ costCenterFactoryCodePair.put(center.getCostCenterCode(), center.getFactoryCode());
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 查询所有部门
|
|
|
|
+ List<DeptRespDTO> depts = TenantUtils.execute(1L, () -> deptApi.getDeptList());
|
|
|
|
+ // 筛选出所有设置了成本中心的部门
|
|
|
|
+ depts.forEach(dept -> {
|
|
|
|
+ Set<Long> costCenterIds = dept.getCostCenterIds();
|
|
|
|
+ // 循环遍历 costCenterIds
|
|
|
|
+ if (CollUtil.isNotEmpty(costCenterIds)) {
|
|
|
|
+ costCenterIds.forEach(center -> {
|
|
|
|
+ if (costCenterCodeIdPair.containsKey(center)) {
|
|
|
|
+ // 当前部门设置的成本中心
|
|
|
|
+ String costCenterCode = costCenterCodeIdPair.get(center);
|
|
|
|
+ costCenterCodeDeptIdPair.put(costCenterCode, dept.getId());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 将集合 pickingListHeads 设置成 Map<String, String> key领料单号 value成本中心
|
|
|
|
+ Map<String, String> pickingCodeCostCenterPair = new HashMap<>();
|
|
|
|
+ // 遍历主表
|
|
|
|
+ pickingListHeads.forEach(head -> {
|
|
|
|
+ pickingCodeCostCenterPair.put(head.getZLTNO(), head.getKOSTL());
|
|
|
|
+ });
|
|
|
|
+ // 遍历子表 所有物料
|
|
|
|
+ // 领料单表不合并物料数量、单价 审核入本地库时 合并相同成本中心下的物料数量 单价
|
|
|
|
+ List<IotSapPickingListDO> pickingLists = new ArrayList<>();
|
|
|
|
+ // 本地库存初始化时合并相同成本中心的 物料数量 单价
|
|
|
|
+ List<IotLockStockDO> lockStocks = new ArrayList<>();
|
|
|
|
+ // 本地库存初始化 成本中心+物料编码,确定唯一明细记录,合并数量、单价
|
|
|
|
+ // 合并的物料数量集合
|
|
|
|
+ Map<String, BigDecimal> mergeMaterialQuantities = new HashMap<>();
|
|
|
|
+ // 合并的物料单价
|
|
|
|
+ Map<String, BigDecimal> mergeMaterialUnitPrices = new HashMap<>();
|
|
|
|
+ // 合并的物料总价
|
|
|
|
+ Map<String, BigDecimal> mergeMaterialTotalPrices = new HashMap<>();
|
|
|
|
+ Map<String, IotSapPickingListItemVO> basicMaterials = new HashMap<>();
|
|
|
|
+ // 以 成本中心-物料编码 维度统计 物料总数量 物料总金额
|
|
|
|
+ pickingListItems.forEach(item -> {
|
|
|
|
+ if (StrUtil.isNotBlank(item.getMATNR())
|
|
|
|
+ && StrUtil.isNotBlank(item.getZLTNO()) && pickingCodeCostCenterPair.containsKey(item.getZLTNO())) {
|
|
|
|
+
|
|
|
|
+ // 领料单号<->成本中心编码
|
|
|
|
+ String costCenterCode = pickingCodeCostCenterPair.get(item.getZLTNO());
|
|
|
|
+ if (StrUtil.isNotBlank(costCenterCode)) {
|
|
|
|
+ String uniqueKey = StrUtil.join("~~", costCenterCode, item.getMATNR());
|
|
|
|
+ System.out.println("唯一key:" + uniqueKey);
|
|
|
|
+ // 当前明细行 物料数量
|
|
|
|
+ BigDecimal currentQuantity = ObjUtil.isEmpty(item.getMENGE()) ? BigDecimal.ZERO : item.getMENGE();
|
|
|
|
+ // 当前明细行 物料单价 移动平均价或标准价
|
|
|
|
+ BigDecimal currentUnitPrice = ObjUtil.isEmpty(item.getVERPR()) ? BigDecimal.ZERO : item.getVERPR();
|
|
|
|
+ // 当前明细行 物料总价
|
|
|
|
+ BigDecimal currentTotalPrice = currentQuantity.multiply(currentUnitPrice);
|
|
|
|
+ // 物料总数量
|
|
|
|
+ if (mergeMaterialQuantities.containsKey(uniqueKey)) {
|
|
|
|
+ BigDecimal tempQuantity = mergeMaterialQuantities.get(uniqueKey);
|
|
|
|
+ mergeMaterialQuantities.put(uniqueKey, tempQuantity.add(currentQuantity));
|
|
|
|
+ } else {
|
|
|
|
+ mergeMaterialQuantities.put(uniqueKey, currentQuantity);
|
|
|
|
+ }
|
|
|
|
+ // 物料总价 单价*数量
|
|
|
|
+ if (mergeMaterialTotalPrices.containsKey(uniqueKey)) {
|
|
|
|
+ BigDecimal tempTotalPrice = mergeMaterialTotalPrices.get(uniqueKey);
|
|
|
|
+ // 查询已经暂存的 物料总数量
|
|
|
|
+ mergeMaterialTotalPrices.put(uniqueKey, tempTotalPrice.add(currentTotalPrice));
|
|
|
|
+ } else {
|
|
|
|
+ mergeMaterialTotalPrices.put(uniqueKey, currentTotalPrice);
|
|
|
|
+ }
|
|
|
|
+ // 基准物料集合
|
|
|
|
+ if (!basicMaterials.containsKey(uniqueKey)) {
|
|
|
|
+ basicMaterials.put(uniqueKey, item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ System.out.println(factoryCode + "基准物料集合容量:" + basicMaterials.size());
|
|
|
|
+ // 以 成本中心-物料编码 维度统计 物料平均单价=物料总金额/物料总数量
|
|
|
|
+ if (CollUtil.isNotEmpty(mergeMaterialTotalPrices)) {
|
|
|
|
+ mergeMaterialTotalPrices.forEach((k,v) -> {
|
|
|
|
+ // k成本中心code+物料编码 v物料总价
|
|
|
|
+ if (mergeMaterialQuantities.containsKey(k)) {
|
|
|
|
+ BigDecimal totalQuantity = mergeMaterialQuantities.get(k);
|
|
|
|
+ if (totalQuantity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
+ BigDecimal unitPrice = v.divide(totalQuantity, 2, RoundingMode.HALF_UP);
|
|
|
|
+ mergeMaterialUnitPrices.put(k, unitPrice);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 用合并后的物料数量、单价 初始化本地库存
|
|
|
|
+ if (CollUtil.isNotEmpty(basicMaterials)) {
|
|
|
|
+ basicMaterials.forEach((k,v) -> {
|
|
|
|
+ // k成本中心code-物料编码 v随机明细物料对象
|
|
|
|
+ String[] costCenterMaterialAttr = k.split("~~");
|
|
|
|
+ if (costCenterMaterialAttr.length > 1) {
|
|
|
|
+ // 领料单<->成本中心<->部门
|
|
|
|
+ String costCenterCode = costCenterMaterialAttr[0];
|
|
|
|
+ if (costCenterCodeDeptIdPair.containsKey(costCenterCode)) {
|
|
|
|
+ IotLockStockDO lockStock = new IotLockStockDO();
|
|
|
|
+ if (costCenterCodeDeptIdPair.containsKey(costCenterCode)) {
|
|
|
|
+ lockStock.setDeptId(costCenterCodeDeptIdPair.get(costCenterCode));
|
|
|
|
+ }
|
|
|
|
+ // sap成本中心 在pms系统中的id
|
|
|
|
+ if (costCenterIdPair.containsKey(costCenterCode)) {
|
|
|
|
+ lockStock.setCostCenterId(costCenterIdPair.get(costCenterCode));
|
|
|
|
+ }
|
|
|
|
+ // sap工厂 在pms系统中的id
|
|
|
|
+ if (costCenterFactoryCodePair.containsKey(costCenterCode)) {
|
|
|
|
+ String tempFactoryCode = costCenterFactoryCodePair.get(costCenterCode);
|
|
|
|
+ if (factoryIdPair.containsKey(tempFactoryCode)) {
|
|
|
|
+ lockStock.setFactoryId(factoryIdPair.get(tempFactoryCode));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 物料编码
|
|
|
|
+ lockStock.setMaterialCode(costCenterMaterialAttr[1]);
|
|
|
|
+ // 物料描述
|
|
|
|
+ lockStock.setMaterialName(v.getMAKTX());
|
|
|
|
+ // 单位
|
|
|
|
+ lockStock.setUnit(v.getMEINS());
|
|
|
|
+ // 物料数量
|
|
|
|
+ if (mergeMaterialQuantities.containsKey(k)) {
|
|
|
|
+ lockStock.setQuantity(mergeMaterialQuantities.get(k));
|
|
|
|
+ }
|
|
|
|
+ // 单价
|
|
|
|
+ if (mergeMaterialUnitPrices.containsKey(k)) {
|
|
|
|
+ lockStock.setUnitPrice(mergeMaterialUnitPrices.get(k));
|
|
|
|
+ }
|
|
|
|
+ lockStocks.add(lockStock);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ pickingListItems.forEach(item -> {
|
|
|
|
+ IotSapPickingListDO picking = new IotSapPickingListDO();
|
|
|
|
+ // 领料单<->成本中心<->部门
|
|
|
|
+ if (pickingCodeCostCenterPair.containsKey(item.getZLTNO())) {
|
|
|
|
+ String costCenterCode = pickingCodeCostCenterPair.get(item.getZLTNO());
|
|
|
|
+ if (costCenterCodeDeptIdPair.containsKey(costCenterCode)) {
|
|
|
|
+ picking.setDeptId(costCenterCodeDeptIdPair.get(costCenterCode));
|
|
|
|
+ // sap成本中心 在pms系统中的id
|
|
|
|
+ if (costCenterIdPair.containsKey(costCenterCode)) {
|
|
|
|
+ picking.setCostCenterId(costCenterIdPair.get(costCenterCode));
|
|
|
|
+ }
|
|
|
|
+ // sap工厂 在pms系统中的id
|
|
|
|
+ if (factoryIdPair.containsKey(item.getWERKS())) {
|
|
|
|
+ picking.setFactoryId(factoryIdPair.get(item.getWERKS()));
|
|
|
|
+ }
|
|
|
|
+ // 领料单号
|
|
|
|
+ picking.setNumber(item.getZLTNO());
|
|
|
|
+ // 物料编码
|
|
|
|
+ picking.setMaterialCode(item.getMATNR());
|
|
|
|
+ // 物料名称 描述
|
|
|
|
+ picking.setMaterialName(item.getMAKTX());
|
|
|
|
+ // 物料数量
|
|
|
|
+ picking.setQuantity(item.getMENGE());
|
|
|
|
+ // 单价
|
|
|
|
+ picking.setUnitPrice(item.getVERPR());
|
|
|
|
+ // 单位
|
|
|
|
+ picking.setUnit(item.getMEINS());
|
|
|
|
+ // 同步时间
|
|
|
|
+ picking.setSyncTime(LocalDateTime.now());
|
|
|
|
+ pickingLists.add(picking);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 本地库存 初始化 批量插入本地库存 记录
|
|
|
|
+ if (CollUtil.isNotEmpty(lockStocks)) {
|
|
|
|
+ TenantUtils.execute(1L, () -> iotLockStockMapper.insertBatch(lockStocks));
|
|
|
|
+ }
|
|
|
|
+ // 新增领料单
|
|
|
|
+ if (CollUtil.isNotEmpty(pickingLists)) {
|
|
|
|
+ TenantUtils.execute(1L, () -> iotSapPickingListMapper.insertBatch(pickingLists));
|
|
|
|
+ }
|
|
|
|
+ // 记录日志 所有领料单如果有的成本中心 在系统中不存在 或 没有对应的部门 记录到日志
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void processSapStock(String factoryCode, List<IotSapStockVO> sapStocks) {
|
|
|
|
+ // 查询出所有工厂 对应的 deptId 新增本地库存时 可以匹配
|
|
|
|
+ List<SapOrgRespDTO> storageLocations = TenantUtils.execute(1L, () -> sapOrgApi.getSapOrgByType(3));
|
|
|
|
+ // 查询所有工厂
|
|
|
|
+ List<SapOrgRespDTO> factories = TenantUtils.execute(1L, () -> sapOrgApi.getSapOrgByType(1));
|
|
|
|
+ // key工厂code value工厂id
|
|
|
|
+ Map<String, Long> factoryIdPair = new HashMap<>();
|
|
|
|
+ // key工厂code value工厂名称
|
|
|
|
+ Map<String, String> factoryNamePair = new HashMap<>();
|
|
|
|
+ // key库存地点code value库存地点id
|
|
|
|
+ Map<String, Long> storageLocationIdPair = new HashMap<>();
|
|
|
|
+ // key库存地点id value库存地点code
|
|
|
|
+ Map<Long, String> stockLocationCodeIdPair = new HashMap<>();
|
|
|
|
+ // key库存地点code value部门id
|
|
|
|
+ Map<String, Long> locationCodeDeptIdPair = new HashMap<>();
|
|
|
|
+ // key库存地点code value库存地点名称描述
|
|
|
|
+ Map<String, String> stockLocationNamePair = new HashMap<>();
|
|
|
|
+ // 工厂集合
|
|
|
|
+ factories.forEach(factory -> {
|
|
|
|
+ factoryIdPair.put(factory.getFactoryCode(), factory.getId());
|
|
|
|
+ factoryNamePair.put(factory.getFactoryCode(), factory.getFactoryName());
|
|
|
|
+ });
|
|
|
|
+ // 库存地点集合
|
|
|
|
+ storageLocations.forEach(location -> {
|
|
|
|
+ stockLocationCodeIdPair.put(location.getId(), location.getStorageLocationCode());
|
|
|
|
+ storageLocationIdPair.put(location.getStorageLocationCode(), location.getId());
|
|
|
|
+ stockLocationNamePair.put(location.getStorageLocationCode(), location.getStorageLocationName());
|
|
|
|
+ });
|
|
|
|
+ // 查询所有部门
|
|
|
|
+ List<DeptRespDTO> depts = TenantUtils.execute(1L, () -> deptApi.getDeptList());
|
|
|
|
+ // 筛选出所有设置了 库存地点 的部门
|
|
|
|
+ depts.forEach(dept -> {
|
|
|
|
+ Set<Long> stockLocationIds = dept.getStockLocationIds();
|
|
|
|
+ // 循环遍历 stockLocationIds
|
|
|
|
+ if (CollUtil.isNotEmpty(stockLocationIds)) {
|
|
|
|
+ stockLocationIds.forEach(location -> {
|
|
|
|
+ if (stockLocationCodeIdPair.containsKey(location)) {
|
|
|
|
+ // 当前部门设置的 库存地点
|
|
|
|
+ String locationCode = stockLocationCodeIdPair.get(location);
|
|
|
|
+ locationCodeDeptIdPair.put(locationCode, dept.getId());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 遍历明细数据 新增 修改 SAP库存数据
|
|
|
|
+ List<IotSapStockDO> tobeSapStocks = new ArrayList<>();
|
|
|
|
+ sapStocks.forEach(stock -> {
|
|
|
|
+ // 只保存pms维护过库存地点的数据
|
|
|
|
+ if (locationCodeDeptIdPair.containsKey(stock.getLGORT())) {
|
|
|
|
+ IotSapStockDO sapStock = new IotSapStockDO();
|
|
|
|
+ // 部门id
|
|
|
|
+ sapStock.setDeptId(locationCodeDeptIdPair.get(stock.getLGORT()));
|
|
|
|
+ // 工厂id
|
|
|
|
+ if (factoryIdPair.containsKey(stock.getWERKS())) {
|
|
|
|
+ sapStock.setFactoryId(factoryIdPair.get(stock.getWERKS()));
|
|
|
|
+ }
|
|
|
|
+ // 工厂名称
|
|
|
|
+ if (factoryNamePair.containsKey(stock.getWERKS())) {
|
|
|
|
+ sapStock.setFactory(factoryNamePair.get(stock.getWERKS()));
|
|
|
|
+ }
|
|
|
|
+ // 库存地点id
|
|
|
|
+ if (storageLocationIdPair.containsKey(stock.getLGORT())) {
|
|
|
|
+ sapStock.setStorageLocationId(storageLocationIdPair.get(stock.getLGORT()));
|
|
|
|
+ }
|
|
|
|
+ // 库存地点名称
|
|
|
|
+ if (stockLocationNamePair.containsKey(stock.getLGORT())) {
|
|
|
|
+ sapStock.setProjectDepartment(stockLocationNamePair.get(stock.getLGORT()));
|
|
|
|
+ }
|
|
|
|
+ // 物料编码
|
|
|
|
+ sapStock.setMaterialCode(stock.getMATNR());
|
|
|
|
+ // 物料描述
|
|
|
|
+ sapStock.setMaterialName(stock.getMAKTX());
|
|
|
|
+ // 库存数量
|
|
|
|
+ sapStock.setQuantity(stock.getLABST());
|
|
|
|
+ // 单价
|
|
|
|
+ sapStock.setUnitPrice(stock.getJIAGE());
|
|
|
|
+ // 基本单位
|
|
|
|
+ sapStock.setUnit(stock.getMEINS());
|
|
|
|
+ // 同步时间
|
|
|
|
+ sapStock.setSyncTime(LocalDateTime.now());
|
|
|
|
+ tobeSapStocks.add(sapStock);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // 本地库存 初始化 批量插入本地库存 记录
|
|
|
|
+ if (CollUtil.isNotEmpty(tobeSapStocks)) {
|
|
|
|
+ TenantUtils.execute(1L, () -> iotSapStockMapper.insertBatch(tobeSapStocks));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 创建物料编码到描述的映射
|
|
* 创建物料编码到描述的映射
|
|
* @param sapMaterials SAP返回的物料列表
|
|
* @param sapMaterials SAP返回的物料列表
|