移除SAP的zwm3A01和zwm3A02支持
This commit is contained in:
parent
54f73be1b2
commit
31b7c35127
|
|
@ -565,7 +565,7 @@ public class InProduceOrderController extends BaseController {
|
|||
Set<String> dbMapBins = storageService.getBinNos(it.getMaterialNo(), it.getFactoryNo(), it.getWarehouseNo());
|
||||
if (!binNos.equals(dbMapBins)) {
|
||||
//调用SAP接口保存库位信息
|
||||
sapService.zwm3A02(it.getFactoryNo(), it.getMaterialNo(), it.getWarehouseNo(), binNos);
|
||||
// sapService.zwm3A02(it.getFactoryNo(), it.getMaterialNo(), it.getWarehouseNo(), binNos);
|
||||
//保存库位信息到数据库
|
||||
DictionaryItem factory = dictionaryService.getItemByCode(Constant.DICTIONARY_FACTORY, it.getFactoryNo());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(factory)).throwMessage("工厂(" + it.getFactoryNo() + ")不存在");
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@ import com.nflg.wms.common.pojo.qo.WarehouseSearchQO;
|
|||
import com.nflg.wms.common.pojo.qo.WarehouseUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.WarehouseSimpleVO;
|
||||
import com.nflg.wms.common.pojo.vo.WarehouseVO;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.DictionaryItem;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.apache.http.annotation.Obsolete;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -132,12 +134,13 @@ public class WarehouseController extends BaseController {
|
|||
return ApiResult.success(warehouseControllerService.getEnableList(factoryNo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动拉取
|
||||
* @param id 仓库id
|
||||
*/
|
||||
@GetMapping("syncFromSAP")
|
||||
public ApiResult<String> syncFromSAP(@Valid @RequestParam @NotNull Long id) {
|
||||
return ApiResult.success(warehouseControllerService.syncFromSAP(id));
|
||||
}
|
||||
// /**
|
||||
// * 手动拉取
|
||||
// * @param id 仓库id
|
||||
// */
|
||||
// @Obsolete
|
||||
// @GetMapping("syncFromSAP")
|
||||
// public ApiResult<String> syncFromSAP(@Valid @RequestParam @NotNull Long id) {
|
||||
// return ApiResult.success(warehouseControllerService.syncFromSAP(id));
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,17 @@ public class BinService {
|
|||
|
||||
public String getBinNos(String materialNo, String factory, String warehouseNo) {
|
||||
Set<String> bins = storageService.getBinNos(materialNo, factory, warehouseNo);
|
||||
if (CollectionUtil.isNotEmpty(bins)){
|
||||
// if (CollectionUtil.isNotEmpty(bins)){
|
||||
// return String.join("/",bins);
|
||||
// }else {
|
||||
// List<SAPSyncFromDTO> dtos = sapService.zwm3A01(factory, List.of(warehouseNo), List.of(materialNo), null, null);
|
||||
// if (CollectionUtil.isEmpty(dtos)){
|
||||
// log.error("{},{},{}未从SAP的ZWM3A01接口查询到数据", factory, warehouseNo, materialNo);
|
||||
// return null;
|
||||
// }else {
|
||||
// return dtos.get(0).getBinNos();
|
||||
// }
|
||||
// }
|
||||
return String.join("/",bins);
|
||||
}else {
|
||||
List<SAPSyncFromDTO> dtos = sapService.zwm3A01(factory, List.of(warehouseNo), List.of(materialNo), null, null);
|
||||
if (CollectionUtil.isEmpty(dtos)){
|
||||
log.error("{},{},{}未从SAP的ZWM3A01接口查询到数据", factory, warehouseNo, materialNo);
|
||||
return null;
|
||||
}else {
|
||||
return dtos.get(0).getBinNos();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,13 +305,13 @@ public class NormalPGIControllerService {
|
|||
inventoryService.in(inventories);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(storageLocationDTOS)) {
|
||||
storageLocationDTOS.forEach(storageLocationDTO -> {
|
||||
sapService.zwm3A02(storageLocationDTO.getFactory(),
|
||||
storageLocationDTO.getMaterialNo(),
|
||||
storageLocationDTO.getWarehouseNo(), storageLocationDTO.getBinNos());
|
||||
});
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(storageLocationDTOS)) {
|
||||
// storageLocationDTOS.forEach(storageLocationDTO -> {
|
||||
// sapService.zwm3A02(storageLocationDTO.getFactory(),
|
||||
// storageLocationDTO.getMaterialNo(),
|
||||
// storageLocationDTO.getWarehouseNo(), storageLocationDTO.getBinNos());
|
||||
// });
|
||||
// }
|
||||
|
||||
//推送到SAP
|
||||
if (CollectionUtil.isNotEmpty(zwm3A17DTOS)) {
|
||||
|
|
@ -437,13 +437,13 @@ public class NormalPGIControllerService {
|
|||
inventoryService.in(inventories);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(storageLocationDTOS)) {
|
||||
storageLocationDTOS.forEach(storageLocationDTO -> {
|
||||
sapService.zwm3A02(storageLocationDTO.getFactory(),
|
||||
storageLocationDTO.getMaterialNo(),
|
||||
storageLocationDTO.getWarehouseNo(), storageLocationDTO.getBinNos());
|
||||
});
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(storageLocationDTOS)) {
|
||||
// storageLocationDTOS.forEach(storageLocationDTO -> {
|
||||
// sapService.zwm3A02(storageLocationDTO.getFactory(),
|
||||
// storageLocationDTO.getMaterialNo(),
|
||||
// storageLocationDTO.getWarehouseNo(), storageLocationDTO.getBinNos());
|
||||
// });
|
||||
// }
|
||||
|
||||
//推送到SAP
|
||||
if (CollectionUtil.isNotEmpty(zwm3A17DTOS)) {
|
||||
|
|
|
|||
|
|
@ -140,13 +140,13 @@ public class NormalQMControllerService {
|
|||
}
|
||||
|
||||
// 修改储位信息
|
||||
if (CollectionUtil.isNotEmpty(qcReceiveDTO.getStorageLocationDTOS())) {
|
||||
qcReceiveDTO.getStorageLocationDTOS().forEach(storageLocationDTO -> {
|
||||
sapService.zwm3A02(storageLocationDTO.getFactory(),
|
||||
storageLocationDTO.getMaterialNo(),
|
||||
storageLocationDTO.getWarehouseNo(), storageLocationDTO.getBinNos());
|
||||
});
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(qcReceiveDTO.getStorageLocationDTOS())) {
|
||||
// qcReceiveDTO.getStorageLocationDTOS().forEach(storageLocationDTO -> {
|
||||
// sapService.zwm3A02(storageLocationDTO.getFactory(),
|
||||
// storageLocationDTO.getMaterialNo(),
|
||||
// storageLocationDTO.getWarehouseNo(), storageLocationDTO.getBinNos());
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,17 +45,17 @@ public class SAPCommonService {
|
|||
syncParams.setKzkri(materialInfoInOrder.getKzkri());
|
||||
|
||||
//获取仓库信息
|
||||
List<String> warehouseNos = new ArrayList<>();
|
||||
warehouseNos.add(materialInfoInOrder.getWarehouseNo());
|
||||
List<String> materialNos = new ArrayList<>();
|
||||
materialNos.add(materialInfoInOrder.getMatnr());
|
||||
List<SAPSyncFromDTO> list = sapService.zwm3A01(materialInfoInOrder.getWerks(), warehouseNos, materialNos, null, null);
|
||||
if (!CollectionUtil.isEmpty(list)) {
|
||||
//同步仓库信息
|
||||
SAPSyncFromDTO dbWarehouse = list.get(0);
|
||||
syncParams.setWarehouseNo(dbWarehouse.getWarehouseNo());
|
||||
syncParams.setBinNos(dbWarehouse.getBinNos());
|
||||
}
|
||||
// List<String> warehouseNos = new ArrayList<>();
|
||||
// warehouseNos.add(materialInfoInOrder.getWarehouseNo());
|
||||
// List<String> materialNos = new ArrayList<>();
|
||||
// materialNos.add(materialInfoInOrder.getMatnr());
|
||||
// List<SAPSyncFromDTO> list = sapService.zwm3A01(materialInfoInOrder.getWerks(), warehouseNos, materialNos, null, null);
|
||||
// if (!CollectionUtil.isEmpty(list)) {
|
||||
// //同步仓库信息
|
||||
// SAPSyncFromDTO dbWarehouse = list.get(0);
|
||||
// syncParams.setWarehouseNo(dbWarehouse.getWarehouseNo());
|
||||
// syncParams.setBinNos(dbWarehouse.getBinNos());
|
||||
// }
|
||||
result.add(syncParams);
|
||||
}
|
||||
return result;
|
||||
|
|
@ -94,17 +94,17 @@ public class SAPCommonService {
|
|||
syncParams.setKzkri(materialInfoInOrder.getKzkri());
|
||||
|
||||
//获取仓库信息
|
||||
List<String> warehouseNos = new ArrayList<>();
|
||||
warehouseNos.add(materialInfoInOrder.getWarehouseNo());
|
||||
List<String> materialNos = new ArrayList<>();
|
||||
materialNos.add(materialInfoInOrder.getMatnr());
|
||||
List<SAPSyncFromDTO> list = sapService.zwm3A01(materialInfoInOrder.getWerks(), warehouseNos, materialNos, null, null);
|
||||
if (!CollectionUtil.isEmpty(list)) {
|
||||
//同步仓库信息
|
||||
SAPSyncFromDTO dbWarehouse = list.get(0);
|
||||
syncParams.setWarehouseNo(dbWarehouse.getWarehouseNo());
|
||||
syncParams.setBinNos(dbWarehouse.getBinNos());
|
||||
}
|
||||
// List<String> warehouseNos = new ArrayList<>();
|
||||
// warehouseNos.add(materialInfoInOrder.getWarehouseNo());
|
||||
// List<String> materialNos = new ArrayList<>();
|
||||
// materialNos.add(materialInfoInOrder.getMatnr());
|
||||
// List<SAPSyncFromDTO> list = sapService.zwm3A01(materialInfoInOrder.getWerks(), warehouseNos, materialNos, null, null);
|
||||
// if (!CollectionUtil.isEmpty(list)) {
|
||||
// //同步仓库信息
|
||||
// SAPSyncFromDTO dbWarehouse = list.get(0);
|
||||
// syncParams.setWarehouseNo(dbWarehouse.getWarehouseNo());
|
||||
// syncParams.setBinNos(dbWarehouse.getBinNos());
|
||||
// }
|
||||
return syncParams;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -311,78 +311,78 @@ public class SapService {
|
|||
, Pair.of(structure.getString("MAT_DOC_103"), structure.getString("DOC_YEAR_103")));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存库位
|
||||
* @param factory 工厂编号
|
||||
* @param materialNo 物料编号
|
||||
* @param warehouseNo 仓库编号
|
||||
* @param binNos 储位编号列表
|
||||
*/
|
||||
public void zwm3A02(String factory, String materialNo, String warehouseNo, Collection<String> binNos) {
|
||||
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("WERKS", factory);
|
||||
item.put("MATNR", materialNo);
|
||||
item.put("LGORT", warehouseNo);
|
||||
item.put("LGPBE", StrUtil.join("/", binNos));
|
||||
tables.put("T_OUT", List.of(item));
|
||||
// /**
|
||||
// * 保存库位
|
||||
// * @param factory 工厂编号
|
||||
// * @param materialNo 物料编号
|
||||
// * @param warehouseNo 仓库编号
|
||||
// * @param binNos 储位编号列表
|
||||
// */
|
||||
// public void zwm3A02(String factory, String materialNo, String warehouseNo, Collection<String> binNos) {
|
||||
// Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
// Map<String, Object> item = new HashMap<>();
|
||||
// item.put("WERKS", factory);
|
||||
// item.put("MATNR", materialNo);
|
||||
// item.put("LGORT", warehouseNo);
|
||||
// item.put("LGPBE", StrUtil.join("/", binNos));
|
||||
// tables.put("T_OUT", List.of(item));
|
||||
//
|
||||
// JCoFunction function = exec("ZWM3A02", null, tables);
|
||||
//
|
||||
// JCoTable table = function.getTableParameterList().getTable("T_OUT");
|
||||
// List<Map<String, Object>> tOut = JCoUtil.toMapList(table);
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(tOut)).throwMessage("SAP未返回结果");
|
||||
// VUtil.trueThrowBusinessError(!StrUtil.equals(tOut.get(0).get("E_TYPE").toString(), "S"))
|
||||
// .throwMessage("SAP:" + tOut.get(0).get("E_MSG"));
|
||||
// }
|
||||
|
||||
JCoFunction function = exec("ZWM3A02", null, tables);
|
||||
// /**
|
||||
// * 获取库存信息
|
||||
// * @param factory 工厂编号
|
||||
// * @param warehouseNo 仓库编号
|
||||
// * @param materialNo 物料编号
|
||||
// */
|
||||
// public SAPSyncFromDTO zwm3A01(String factory, String warehouseNo, String materialNo) {
|
||||
// return zwm3A01(factory, Collections.singletonList(warehouseNo), Collections.singletonList(materialNo), null, null)
|
||||
// .stream().findFirst().orElse(null);
|
||||
// }
|
||||
|
||||
JCoTable table = function.getTableParameterList().getTable("T_OUT");
|
||||
List<Map<String, Object>> tOut = JCoUtil.toMapList(table);
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(tOut)).throwMessage("SAP未返回结果");
|
||||
VUtil.trueThrowBusinessError(!StrUtil.equals(tOut.get(0).get("E_TYPE").toString(), "S"))
|
||||
.throwMessage("SAP:" + tOut.get(0).get("E_MSG"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取库存信息
|
||||
* @param factory 工厂编号
|
||||
* @param warehouseNo 仓库编号
|
||||
* @param materialNo 物料编号
|
||||
*/
|
||||
public SAPSyncFromDTO zwm3A01(String factory, String warehouseNo, String materialNo) {
|
||||
return zwm3A01(factory, Collections.singletonList(warehouseNo), Collections.singletonList(materialNo), null, null)
|
||||
.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取库存信息
|
||||
* @param factory 工厂编号
|
||||
* @param warehouseNos 仓库编号列表
|
||||
* @param beginTime 开始时间,格式yyyyMMdd
|
||||
* @param endTime 结束时间,格式yyyyMMdd
|
||||
*/
|
||||
public List<SAPSyncFromDTO> zwm3A01(String factory, List<String> warehouseNos, List<String> materialNos, String beginTime, String endTime) {
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("I_WERKS", factory);
|
||||
parameters.put("I_TYPE", Objects.nonNull(beginTime) || Objects.nonNull(endTime) ? "I" : "A");
|
||||
if (Objects.nonNull(beginTime)) {
|
||||
parameters.put("S_DATE", beginTime);
|
||||
}
|
||||
if (Objects.nonNull(endTime)) {
|
||||
parameters.put("E_DATE", endTime);
|
||||
}
|
||||
|
||||
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
List<Map<String, Object>> warehouses = new ArrayList<>();
|
||||
warehouseNos.forEach(warehouseNo -> {
|
||||
warehouses.add(Map.of("LGORT", warehouseNo));
|
||||
});
|
||||
tables.put("IT_LGORT", warehouses);
|
||||
List<Map<String, Object>> materials = new ArrayList<>();
|
||||
materialNos.forEach(materialNo -> {
|
||||
materials.add(Map.of("MATNR", materialNo));
|
||||
});
|
||||
tables.put("IT_MATNR", materials);
|
||||
|
||||
JCoTable tOut = execReturnTable("ZWM3A01", parameters, tables);
|
||||
|
||||
List<SAPSyncFromDTO> result = JCoUtil.toBeanList(tOut, SAPSyncFromDTO.class);
|
||||
log.debug("数据:{}", JSONUtil.toJsonStr(result));
|
||||
return result;
|
||||
}
|
||||
// /**
|
||||
// * 获取库存信息
|
||||
// * @param factory 工厂编号
|
||||
// * @param warehouseNos 仓库编号列表
|
||||
// * @param beginTime 开始时间,格式yyyyMMdd
|
||||
// * @param endTime 结束时间,格式yyyyMMdd
|
||||
// */
|
||||
// public List<SAPSyncFromDTO> zwm3A01(String factory, List<String> warehouseNos, List<String> materialNos, String beginTime, String endTime) {
|
||||
// Map<String, Object> parameters = new HashMap<>();
|
||||
// parameters.put("I_WERKS", factory);
|
||||
// parameters.put("I_TYPE", Objects.nonNull(beginTime) || Objects.nonNull(endTime) ? "I" : "A");
|
||||
// if (Objects.nonNull(beginTime)) {
|
||||
// parameters.put("S_DATE", beginTime);
|
||||
// }
|
||||
// if (Objects.nonNull(endTime)) {
|
||||
// parameters.put("E_DATE", endTime);
|
||||
// }
|
||||
//
|
||||
// Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
// List<Map<String, Object>> warehouses = new ArrayList<>();
|
||||
// warehouseNos.forEach(warehouseNo -> {
|
||||
// warehouses.add(Map.of("LGORT", warehouseNo));
|
||||
// });
|
||||
// tables.put("IT_LGORT", warehouses);
|
||||
// List<Map<String, Object>> materials = new ArrayList<>();
|
||||
// materialNos.forEach(materialNo -> {
|
||||
// materials.add(Map.of("MATNR", materialNo));
|
||||
// });
|
||||
// tables.put("IT_MATNR", materials);
|
||||
//
|
||||
// JCoTable tOut = execReturnTable("ZWM3A01", parameters, tables);
|
||||
//
|
||||
// List<SAPSyncFromDTO> result = JCoUtil.toBeanList(tOut, SAPSyncFromDTO.class);
|
||||
// log.debug("数据:{}", JSONUtil.toJsonStr(result));
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取订单信息
|
||||
|
|
@ -1392,48 +1392,48 @@ public class SapService {
|
|||
return Pair.of(structure.getString("MAT_DOC"), structure.getString("DOC_YEAR"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取库存信息
|
||||
* @param factory 工厂编号
|
||||
* @param warehouseNos 仓库编号列表
|
||||
* @param beginTime 开始时间,格式yyyyMMdd
|
||||
* @param endTime 结束时间,格式yyyyMMdd
|
||||
*/
|
||||
public List<SAPSyncFromDTO> getStorage(String factory, List<String> warehouseNos, String beginTime, String endTime) {
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("I_WERKS", factory);
|
||||
parameters.put("I_TYPE", Objects.nonNull(beginTime) || Objects.nonNull(endTime) ? "I" : "A");
|
||||
if (Objects.nonNull(beginTime)) {
|
||||
parameters.put("S_DATE", beginTime);
|
||||
}
|
||||
if (Objects.nonNull(endTime)) {
|
||||
parameters.put("E_DATE", endTime);
|
||||
}
|
||||
|
||||
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
List<Map<String, Object>> warehouses = new ArrayList<>();
|
||||
warehouseNos.forEach(warehouseNo -> {
|
||||
warehouses.add(Map.of("LGORT", warehouseNo));
|
||||
});
|
||||
tables.put("IT_LGORT", warehouses);
|
||||
|
||||
JCoTable tOut = execReturnTable("ZWM3A01", parameters, tables);
|
||||
|
||||
List<SAPSyncFromDTO> result = new ArrayList<>();
|
||||
for (int i = 0; i < tOut.getNumRows(); i++) {
|
||||
tOut.setRow(i);
|
||||
result.add(new SAPSyncFromDTO()
|
||||
.setFactoryNo(tOut.getString("WERKS"))
|
||||
.setMaterialNo(tOut.getString("MATNR"))
|
||||
.setMaterialDesc(tOut.getString("MAKTX"))
|
||||
.setWarehouseNo(tOut.getString("LGORT"))
|
||||
.setWarehouseName(tOut.getString("LGOBE"))
|
||||
.setBinNos(tOut.getString("LGPBE")))
|
||||
;
|
||||
}
|
||||
log.debug("数据:{}", JSONUtil.toJsonStr(result));
|
||||
return result;
|
||||
}
|
||||
// /**
|
||||
// * 获取库存信息
|
||||
// * @param factory 工厂编号
|
||||
// * @param warehouseNos 仓库编号列表
|
||||
// * @param beginTime 开始时间,格式yyyyMMdd
|
||||
// * @param endTime 结束时间,格式yyyyMMdd
|
||||
// */
|
||||
// public List<SAPSyncFromDTO> getStorage(String factory, List<String> warehouseNos, String beginTime, String endTime) {
|
||||
// Map<String, Object> parameters = new HashMap<>();
|
||||
// parameters.put("I_WERKS", factory);
|
||||
// parameters.put("I_TYPE", Objects.nonNull(beginTime) || Objects.nonNull(endTime) ? "I" : "A");
|
||||
// if (Objects.nonNull(beginTime)) {
|
||||
// parameters.put("S_DATE", beginTime);
|
||||
// }
|
||||
// if (Objects.nonNull(endTime)) {
|
||||
// parameters.put("E_DATE", endTime);
|
||||
// }
|
||||
//
|
||||
// Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
// List<Map<String, Object>> warehouses = new ArrayList<>();
|
||||
// warehouseNos.forEach(warehouseNo -> {
|
||||
// warehouses.add(Map.of("LGORT", warehouseNo));
|
||||
// });
|
||||
// tables.put("IT_LGORT", warehouses);
|
||||
//
|
||||
// JCoTable tOut = execReturnTable("ZWM3A01", parameters, tables);
|
||||
//
|
||||
// List<SAPSyncFromDTO> result = new ArrayList<>();
|
||||
// for (int i = 0; i < tOut.getNumRows(); i++) {
|
||||
// tOut.setRow(i);
|
||||
// result.add(new SAPSyncFromDTO()
|
||||
// .setFactoryNo(tOut.getString("WERKS"))
|
||||
// .setMaterialNo(tOut.getString("MATNR"))
|
||||
// .setMaterialDesc(tOut.getString("MAKTX"))
|
||||
// .setWarehouseNo(tOut.getString("LGORT"))
|
||||
// .setWarehouseName(tOut.getString("LGOBE"))
|
||||
// .setBinNos(tOut.getString("LGPBE")))
|
||||
// ;
|
||||
// }
|
||||
// log.debug("数据:{}", JSONUtil.toJsonStr(result));
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private JCoTable execReturnTable(String functionName, Map<String, Object> parameters) {
|
||||
return execReturnTable(functionName, parameters, null, "T_OUT");
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ public class StructuralPackageControllerService {
|
|||
.toList()
|
||||
);
|
||||
//调用SAP接口保存库位信息
|
||||
sapService.zwm3A02(qo.getFactory(), qo.getMaterialNo(), qo.getReceivedWarehouse(), qo.getBinNos());
|
||||
// sapService.zwm3A02(qo.getFactory(), qo.getMaterialNo(), qo.getReceivedWarehouse(), qo.getBinNos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,131 +222,131 @@ public class WarehouseControllerService {
|
|||
return warehouseService.getEnableList(factoryNo);
|
||||
}
|
||||
|
||||
public String syncFromSAP(@Valid @NotNull Long id) {
|
||||
WmsWarehouse warehouse = warehouseService.getById(id);
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(warehouse)).throwMessage("仓库不存在");
|
||||
VUtil.trueThrowBusinessError(!warehouse.getEnable()).throwMessage("仓库未启用");
|
||||
DictionaryItem factory = dictionaryItemService.getById(warehouse.getFactoryId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(factory)).throwMessage("工厂不存在");
|
||||
String start = DateTimeUtil.format(LocalDate.now(), "yyyyMMdd");
|
||||
String end = DateTimeUtil.format(LocalDate.now().plusDays(1), "yyyyMMdd");
|
||||
return save(factory, List.of(warehouse.getNo()), start, end);
|
||||
}
|
||||
// public String syncFromSAP(@Valid @NotNull Long id) {
|
||||
// WmsWarehouse warehouse = warehouseService.getById(id);
|
||||
// VUtil.trueThrowBusinessError(Objects.isNull(warehouse)).throwMessage("仓库不存在");
|
||||
// VUtil.trueThrowBusinessError(!warehouse.getEnable()).throwMessage("仓库未启用");
|
||||
// DictionaryItem factory = dictionaryItemService.getById(warehouse.getFactoryId());
|
||||
// VUtil.trueThrowBusinessError(Objects.isNull(factory)).throwMessage("工厂不存在");
|
||||
// String start = DateTimeUtil.format(LocalDate.now(), "yyyyMMdd");
|
||||
// String end = DateTimeUtil.format(LocalDate.now().plusDays(1), "yyyyMMdd");
|
||||
// return save(factory, List.of(warehouse.getNo()), start, end);
|
||||
// }
|
||||
|
||||
private String save(DictionaryItem fy, List<String> warehouseNos, String start, String end) {
|
||||
log.info("处理工厂:{},开始日期:{},结束日期:{}", fy.getValue(), start, end);
|
||||
List<SAPSyncFromDTO> list = sapService.getStorage(fy.getValue(), warehouseNos, start, end);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
log.info("没有获取到数据");
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("没有获取到数据");
|
||||
} else {
|
||||
log.info("获取到{}条数据", list.size());
|
||||
//同步仓库信息
|
||||
warehouseNos = list.stream().map(SAPSyncFromDTO::getWarehouseNo).distinct().toList();
|
||||
List<WmsWarehouse> dbWarehouses = warehouseService.lambdaQuery().eq(WmsWarehouse::getFactoryId, fy.getId()).in(WmsWarehouse::getNo, warehouseNos).list();
|
||||
warehouseNos.forEach(wn -> {
|
||||
String name = list.stream().filter(dto -> StrUtil.equals(dto.getWarehouseNo(), wn)).findFirst().get().getWarehouseName();
|
||||
WmsWarehouse dbWarehouse = dbWarehouses.stream().filter(w -> StrUtil.equals(w.getNo(), wn)).findFirst().orElse(null);
|
||||
if (Objects.isNull(dbWarehouse)) {
|
||||
dbWarehouse = new WmsWarehouse()
|
||||
.setNo(wn)
|
||||
.setName(name)
|
||||
.setFactoryId(fy.getId())
|
||||
.setRemark("从SAP同步")
|
||||
.setCreateBy("SAP同步")
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
warehouseService.save(dbWarehouse);
|
||||
dbWarehouses.add(dbWarehouse);
|
||||
} else if (!StrUtil.equals(dbWarehouse.getName(), name)) {
|
||||
warehouseService.lambdaUpdate()
|
||||
.set(WmsWarehouse::getId, dbWarehouse.getId())
|
||||
.set(WmsWarehouse::getName, name)
|
||||
.set(WmsWarehouse::getUpdateBy, "SAP同步")
|
||||
.set(WmsWarehouse::getUpdateTime, LocalDateTime.now());
|
||||
}
|
||||
});
|
||||
List<WmsBin> dbBins = new ArrayList<>();
|
||||
List<WmsBin> binsForAdd = new ArrayList<>();
|
||||
List<WmsStorage> storagesForAdd = new ArrayList<>();
|
||||
List<WmsStorageBin> storageBins = new ArrayList<>();
|
||||
List<WmsStorage> storagesForUpdate = new ArrayList<>();
|
||||
List<String> materialNos = list.stream().map(SAPSyncFromDTO::getMaterialNo).toList();
|
||||
List<VStorage> lv = vStorageService.lambdaQuery().eq(VStorage::getFactoryId, fy.getId()).in(VStorage::getMaterialNo, materialNos).list();
|
||||
if (CollectionUtil.isNotEmpty(lv)) {
|
||||
storageBinService.remove(new LambdaQueryWrapper<WmsStorageBin>().in(WmsStorageBin::getStorageId, lv.stream().map(VStorage::getId).toList()));
|
||||
}
|
||||
list.forEach(dto -> {
|
||||
log.info("处理物料:{}", dto.getMaterialNo());
|
||||
WmsWarehouse dbWarehouse = dbWarehouses.stream().filter(w -> StrUtil.equals(w.getNo(), dto.getWarehouseNo())).findFirst().get();
|
||||
VStorage dbStorage = lv.stream().filter(l -> StrUtil.equals(l.getMaterialNo(), dto.getMaterialNo())
|
||||
&& StrUtil.equals(l.getWarehouseNo(), dto.getWarehouseNo())).findFirst().orElse(null);
|
||||
List<String> sapBinNos = StrUtil.split(dto.getBinNos(), "/");
|
||||
if (CollectionUtil.isNotEmpty(sapBinNos)) {
|
||||
for (String sapBinNo : sapBinNos) {
|
||||
WmsBin dbBin = dbBins.stream().filter(b -> StrUtil.equals(b.getNo(), sapBinNo)).findFirst().orElse(null);
|
||||
if (Objects.isNull(dbBin)) {
|
||||
dbBin = wmsBinService.lambdaQuery().eq(WmsBin::getNo, sapBinNo).one();
|
||||
if (Objects.isNull(dbBin)) {
|
||||
dbBin = new WmsBin()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setWarehouseId(dbWarehouse.getId())
|
||||
.setNo(sapBinNo)
|
||||
.setName(sapBinNo)
|
||||
.setCreateBy("SAP同步")
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
binsForAdd.add(dbBin);
|
||||
}
|
||||
dbBins.add(dbBin);
|
||||
}
|
||||
if (Objects.isNull(dbStorage)) {
|
||||
log.info("添加,仓库:{},储位:{}", dto.getWarehouseNo(), sapBinNo);
|
||||
WmsStorage storage = new WmsStorage()
|
||||
.setId(IdUtil.getSnowflakeNextId())
|
||||
.setMaterialNo(dto.getMaterialNo())
|
||||
.setWarehouseId(dbWarehouse.getId())
|
||||
.setMaterialDesc(dto.getMaterialDesc())
|
||||
.setRemark("从SAP同步")
|
||||
.setCreateBy("SAP同步")
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
storagesForAdd.add(storage);
|
||||
if (StrUtil.isNotBlank(sapBinNo)) {
|
||||
storageBins.add(new WmsStorageBin()
|
||||
.setStorageId(storage.getId())
|
||||
.setBinId(dbBin.getId()));
|
||||
}
|
||||
} else {
|
||||
log.info("更新,仓库:{},储位:{}", dto.getWarehouseNo(), sapBinNo);
|
||||
if (!StrUtil.equals(dbStorage.getWarehouseNo(), dto.getWarehouseNo())) {
|
||||
storagesForUpdate.add(new WmsStorage()
|
||||
.setId(dbStorage.getId())
|
||||
.setWarehouseId(dbWarehouse.getId())
|
||||
.setUpdateBy("SAP同步")
|
||||
.setUpdateTime(LocalDateTime.now()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(sapBinNo)) {
|
||||
storageBins.add(new WmsStorageBin()
|
||||
.setStorageId(dbStorage.getId())
|
||||
.setBinId(dbBin.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(storagesForAdd)) {
|
||||
storageService.saveBatch(storagesForAdd, 1000);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(storagesForUpdate)) {
|
||||
storageService.updateBatchById(storagesForUpdate, 1000);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(storageBins)) {
|
||||
storageBinService.saveBatch(storageBins, 1000);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(binsForAdd)) {
|
||||
wmsBinService.saveBatch(binsForAdd, 1000);
|
||||
}
|
||||
}
|
||||
return "共同步" + list.size() + "条数据";
|
||||
}
|
||||
// private String save(DictionaryItem fy, List<String> warehouseNos, String start, String end) {
|
||||
// log.info("处理工厂:{},开始日期:{},结束日期:{}", fy.getValue(), start, end);
|
||||
// List<SAPSyncFromDTO> list = sapService.getStorage(fy.getValue(), warehouseNos, start, end);
|
||||
// if (CollectionUtil.isEmpty(list)) {
|
||||
// log.info("没有获取到数据");
|
||||
// VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("没有获取到数据");
|
||||
// } else {
|
||||
// log.info("获取到{}条数据", list.size());
|
||||
// //同步仓库信息
|
||||
// warehouseNos = list.stream().map(SAPSyncFromDTO::getWarehouseNo).distinct().toList();
|
||||
// List<WmsWarehouse> dbWarehouses = warehouseService.lambdaQuery().eq(WmsWarehouse::getFactoryId, fy.getId()).in(WmsWarehouse::getNo, warehouseNos).list();
|
||||
// warehouseNos.forEach(wn -> {
|
||||
// String name = list.stream().filter(dto -> StrUtil.equals(dto.getWarehouseNo(), wn)).findFirst().get().getWarehouseName();
|
||||
// WmsWarehouse dbWarehouse = dbWarehouses.stream().filter(w -> StrUtil.equals(w.getNo(), wn)).findFirst().orElse(null);
|
||||
// if (Objects.isNull(dbWarehouse)) {
|
||||
// dbWarehouse = new WmsWarehouse()
|
||||
// .setNo(wn)
|
||||
// .setName(name)
|
||||
// .setFactoryId(fy.getId())
|
||||
// .setRemark("从SAP同步")
|
||||
// .setCreateBy("SAP同步")
|
||||
// .setCreateTime(LocalDateTime.now());
|
||||
// warehouseService.save(dbWarehouse);
|
||||
// dbWarehouses.add(dbWarehouse);
|
||||
// } else if (!StrUtil.equals(dbWarehouse.getName(), name)) {
|
||||
// warehouseService.lambdaUpdate()
|
||||
// .set(WmsWarehouse::getId, dbWarehouse.getId())
|
||||
// .set(WmsWarehouse::getName, name)
|
||||
// .set(WmsWarehouse::getUpdateBy, "SAP同步")
|
||||
// .set(WmsWarehouse::getUpdateTime, LocalDateTime.now());
|
||||
// }
|
||||
// });
|
||||
// List<WmsBin> dbBins = new ArrayList<>();
|
||||
// List<WmsBin> binsForAdd = new ArrayList<>();
|
||||
// List<WmsStorage> storagesForAdd = new ArrayList<>();
|
||||
// List<WmsStorageBin> storageBins = new ArrayList<>();
|
||||
// List<WmsStorage> storagesForUpdate = new ArrayList<>();
|
||||
// List<String> materialNos = list.stream().map(SAPSyncFromDTO::getMaterialNo).toList();
|
||||
// List<VStorage> lv = vStorageService.lambdaQuery().eq(VStorage::getFactoryId, fy.getId()).in(VStorage::getMaterialNo, materialNos).list();
|
||||
// if (CollectionUtil.isNotEmpty(lv)) {
|
||||
// storageBinService.remove(new LambdaQueryWrapper<WmsStorageBin>().in(WmsStorageBin::getStorageId, lv.stream().map(VStorage::getId).toList()));
|
||||
// }
|
||||
// list.forEach(dto -> {
|
||||
// log.info("处理物料:{}", dto.getMaterialNo());
|
||||
// WmsWarehouse dbWarehouse = dbWarehouses.stream().filter(w -> StrUtil.equals(w.getNo(), dto.getWarehouseNo())).findFirst().get();
|
||||
// VStorage dbStorage = lv.stream().filter(l -> StrUtil.equals(l.getMaterialNo(), dto.getMaterialNo())
|
||||
// && StrUtil.equals(l.getWarehouseNo(), dto.getWarehouseNo())).findFirst().orElse(null);
|
||||
// List<String> sapBinNos = StrUtil.split(dto.getBinNos(), "/");
|
||||
// if (CollectionUtil.isNotEmpty(sapBinNos)) {
|
||||
// for (String sapBinNo : sapBinNos) {
|
||||
// WmsBin dbBin = dbBins.stream().filter(b -> StrUtil.equals(b.getNo(), sapBinNo)).findFirst().orElse(null);
|
||||
// if (Objects.isNull(dbBin)) {
|
||||
// dbBin = wmsBinService.lambdaQuery().eq(WmsBin::getNo, sapBinNo).one();
|
||||
// if (Objects.isNull(dbBin)) {
|
||||
// dbBin = new WmsBin()
|
||||
// .setId(IdUtil.getSnowflakeNextId())
|
||||
// .setWarehouseId(dbWarehouse.getId())
|
||||
// .setNo(sapBinNo)
|
||||
// .setName(sapBinNo)
|
||||
// .setCreateBy("SAP同步")
|
||||
// .setCreateTime(LocalDateTime.now());
|
||||
// binsForAdd.add(dbBin);
|
||||
// }
|
||||
// dbBins.add(dbBin);
|
||||
// }
|
||||
// if (Objects.isNull(dbStorage)) {
|
||||
// log.info("添加,仓库:{},储位:{}", dto.getWarehouseNo(), sapBinNo);
|
||||
// WmsStorage storage = new WmsStorage()
|
||||
// .setId(IdUtil.getSnowflakeNextId())
|
||||
// .setMaterialNo(dto.getMaterialNo())
|
||||
// .setWarehouseId(dbWarehouse.getId())
|
||||
// .setMaterialDesc(dto.getMaterialDesc())
|
||||
// .setRemark("从SAP同步")
|
||||
// .setCreateBy("SAP同步")
|
||||
// .setCreateTime(LocalDateTime.now());
|
||||
// storagesForAdd.add(storage);
|
||||
// if (StrUtil.isNotBlank(sapBinNo)) {
|
||||
// storageBins.add(new WmsStorageBin()
|
||||
// .setStorageId(storage.getId())
|
||||
// .setBinId(dbBin.getId()));
|
||||
// }
|
||||
// } else {
|
||||
// log.info("更新,仓库:{},储位:{}", dto.getWarehouseNo(), sapBinNo);
|
||||
// if (!StrUtil.equals(dbStorage.getWarehouseNo(), dto.getWarehouseNo())) {
|
||||
// storagesForUpdate.add(new WmsStorage()
|
||||
// .setId(dbStorage.getId())
|
||||
// .setWarehouseId(dbWarehouse.getId())
|
||||
// .setUpdateBy("SAP同步")
|
||||
// .setUpdateTime(LocalDateTime.now()));
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(sapBinNo)) {
|
||||
// storageBins.add(new WmsStorageBin()
|
||||
// .setStorageId(dbStorage.getId())
|
||||
// .setBinId(dbBin.getId()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// if (CollectionUtil.isNotEmpty(storagesForAdd)) {
|
||||
// storageService.saveBatch(storagesForAdd, 1000);
|
||||
// }
|
||||
// if (CollectionUtil.isNotEmpty(storagesForUpdate)) {
|
||||
// storageService.updateBatchById(storagesForUpdate, 1000);
|
||||
// }
|
||||
// if (CollectionUtil.isNotEmpty(storageBins)) {
|
||||
// storageBinService.saveBatch(storageBins, 1000);
|
||||
// }
|
||||
// if (CollectionUtil.isNotEmpty(binsForAdd)) {
|
||||
// wmsBinService.saveBatch(binsForAdd, 1000);
|
||||
// }
|
||||
// }
|
||||
// return "共同步" + list.size() + "条数据";
|
||||
// }
|
||||
|
||||
public WarehouseVO getInfo(Long id) {
|
||||
return warehouseService.getInfo(id);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.Objects;
|
|||
/**
|
||||
* 从SAP同步物料存储信息
|
||||
*/
|
||||
@Component(value = "SyncStorageFromSAPProcessor")
|
||||
//@Component(value = "SyncStorageFromSAPProcessor")
|
||||
public class SyncStorageFromSAPProcessor implements BasicProcessor {
|
||||
|
||||
@Resource
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
/**
|
||||
* 同步物料存储位置到SAP
|
||||
*/
|
||||
@Component(value = "SyncStorageToSAPProcessor")
|
||||
//@Component(value = "SyncStorageToSAPProcessor")
|
||||
public class SyncStorageToSAPProcessor implements BasicProcessor {
|
||||
|
||||
@Resource
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public class MaterialController extends BaseController {
|
|||
dbMaterial.setLength(data.getLength());
|
||||
dbMaterial.setWidth(data.getWidth());
|
||||
dbMaterial.setHeight(data.getHeight());
|
||||
dbMaterial.setUpdateBy(UserUtil.getUserName());
|
||||
dbMaterial.setUpdateBy("同步");
|
||||
dbMaterial.setUpdateTime(LocalDateTime.now());
|
||||
shipmentMaterialService.updateById(dbMaterial);
|
||||
});
|
||||
|
|
@ -171,7 +171,7 @@ public class MaterialController extends BaseController {
|
|||
if (CollectionUtil.isNotEmpty(datas)) {
|
||||
shipmentMaterialService.saveBatch(datas.stream().map(data -> {
|
||||
WmsShipmentMaterial material = Convert.convert(WmsShipmentMaterial.class, data);
|
||||
material.setCreateBy(UserUtil.getUserName());
|
||||
material.setCreateBy("同步");
|
||||
material.setCreateTime(LocalDateTime.now());
|
||||
return material;
|
||||
}).toList());
|
||||
|
|
|
|||
Loading…
Reference in New Issue