|
|
|
@ -65,6 +65,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
@Autowired
|
|
|
|
|
private WmsConfig wmsConfig;
|
|
|
|
|
|
|
|
|
|
public int i=0;
|
|
|
|
|
//仓库编码
|
|
|
|
|
// private String FStockId = "CK050";
|
|
|
|
|
|
|
|
|
@ -74,20 +75,18 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeInventoryInformationToERP() {
|
|
|
|
|
// @Transactional
|
|
|
|
|
public Map<Long, List<WmsRawInstock>> synchronizeInventoryInformationToERP() {
|
|
|
|
|
WmsRawInstock wmsRawInstock = new WmsRawInstock();
|
|
|
|
|
int result = 0;
|
|
|
|
|
List<WmsRawInstock> inStockList = wmsRawInstockMapper.selectWmsRawInstockERPNotSynchronized(wmsRawInstock);
|
|
|
|
|
Map<Long, List<WmsRawInstock>> purchaseOrderIdMap = inStockList.stream().collect(Collectors.groupingBy(WmsRawInstock::getPurchaseOrderId));
|
|
|
|
|
|
|
|
|
|
for (Long purchaseOrderId : purchaseOrderIdMap.keySet()) {
|
|
|
|
|
syncInventoryInformation(purchaseOrderIdMap, purchaseOrderId, result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
return purchaseOrderIdMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public void syncInventoryInformation(Map<Long, List<WmsRawInstock>> purchaseOrderIdMap, Long purchaseOrderId, int result) {
|
|
|
|
|
R<MesPurchaseOrder> purchaseOrderData = remoteMesService.selectPurchaseOrderJoinSupplierProjectByOrderId(purchaseOrderId, SecurityConstants.INNER);
|
|
|
|
|
MesPurchaseOrder mesPurchaseOrder = null;
|
|
|
|
@ -116,7 +115,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
|
|
|
|
|
String specificationParameter = instock.getSpecificationParameter();
|
|
|
|
|
if(StringUtils.isEmpty(specificationParameter)){
|
|
|
|
|
specificationParameter = instock.getMaterialSpec();
|
|
|
|
|
specificationParameter = instock.getMaterialSpec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isEmpty(specificationParameter)){
|
|
|
|
@ -143,11 +142,11 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("同步原材料入库失败" + paramsResult.toString());
|
|
|
|
|
throw new ServiceException("同步原材料入库失败" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("同步原材料入库失败" + e.getMessage());
|
|
|
|
|
throw new RuntimeException("同步原材料入库失败" + e.getMessage());
|
|
|
|
|
throw new ServiceException("同步原材料入库失败" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -158,8 +157,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeRawMaterialDeliveryInformationToERP() {
|
|
|
|
|
public Map<Long, List<WmsRawOutstockDetail>> synchronizeOtherMaterialDeliveryInformationToERP() {
|
|
|
|
|
int result = 0;
|
|
|
|
|
//领料
|
|
|
|
|
WmsRawOutstockDetail otherRawOutstockDetail = new WmsRawOutstockDetail();
|
|
|
|
@ -167,22 +165,102 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
+ "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_AUTO_OUTSTOCK + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_OTHER);
|
|
|
|
|
List<WmsRawOutstockDetail> otherRawOutstockDetailList = wmsRawOutstockDetailMapper.selectWmsRawOutstockDetailERPNotSynchronized(otherRawOutstockDetail);
|
|
|
|
|
Map<Long, List<WmsRawOutstockDetail>> otherMaterialIdMap = otherRawOutstockDetailList.stream().collect(Collectors.groupingBy(WmsRawOutstockDetail::getMaterialId));
|
|
|
|
|
for (Long materialId : otherMaterialIdMap.keySet()) {
|
|
|
|
|
result += syncOutstockInformation(otherMaterialIdMap, materialId, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return otherMaterialIdMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定时同步原材料退货出库信息给ERP
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Map<Long, List<WmsRawOutstockDetail>> synchronizeReturnMaterialDeliveryInformationToERP() {
|
|
|
|
|
int result = 0;
|
|
|
|
|
//退货出库
|
|
|
|
|
WmsRawOutstockDetail returnRawOutstockDetail = new WmsRawOutstockDetail();
|
|
|
|
|
returnRawOutstockDetail.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK);
|
|
|
|
|
List<WmsRawOutstockDetail> returnRawOutstockDetailList = wmsRawOutstockDetailMapper.selectWmsRawOutstockDetailERPNotSynchronized(returnRawOutstockDetail);
|
|
|
|
|
Map<Long, List<WmsRawOutstockDetail>> returnMaterialIdMap = returnRawOutstockDetailList.stream().collect(Collectors.groupingBy(WmsRawOutstockDetail::getMaterialId));
|
|
|
|
|
for (Long materialId : returnMaterialIdMap.keySet()) {
|
|
|
|
|
result += syncOutstockInformation(returnMaterialIdMap, materialId, WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK);
|
|
|
|
|
|
|
|
|
|
return returnMaterialIdMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public int syncOutstockInformation(Map<Long, List<WmsRawOutstockDetail>> materialIdMap, Long materialId, String taskType) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
List<WmsRawOutstockDetail> wmsRawOutstockDetailList = materialIdMap.get(materialId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsRawOutstockDetailList.stream().mapToDouble(item -> item.getOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsRawOutstockDetail outstockDetail = wmsRawOutstockDetailList.get(0);
|
|
|
|
|
for (WmsRawOutstockDetail wmsRawOutstockDetail : wmsRawOutstockDetailList) {
|
|
|
|
|
if (wmsRawOutstockDetail.getPlanAmount().equals(wmsRawOutstockDetail.getOutstockAmount())) {
|
|
|
|
|
wmsRawOutstockDetail.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
} else {
|
|
|
|
|
wmsRawOutstockDetail.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
}
|
|
|
|
|
wmsRawOutstockDetail.setErpAmount(wmsRawOutstockDetail.getOutstockAmount());
|
|
|
|
|
wmsRawOutstockDetail.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsRawOutstockDetailMapper.updateWmsRawOutstockDetail(wmsRawOutstockDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(taskType) && taskType.equals(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK)) {
|
|
|
|
|
data.put("FTONDCombo", "售后服务");
|
|
|
|
|
} else {
|
|
|
|
|
data.put("FTONDCombo", "一般领料");
|
|
|
|
|
}
|
|
|
|
|
// model.put("F_TOND_Combo", "一般领料"); //领料类型(必填项)
|
|
|
|
|
|
|
|
|
|
String fdate = DateUtils.getTime();
|
|
|
|
|
if (outstockDetail.getOutstockTime() != null) {
|
|
|
|
|
fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, outstockDetail.getOutstockTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String barcodeSpec = outstockDetail.getBarcodeSpec();
|
|
|
|
|
String materialSpec = outstockDetail.getMaterialSpec();
|
|
|
|
|
if(StringUtils.isEmpty(barcodeSpec)){
|
|
|
|
|
if(StringUtils.isNotEmpty(materialSpec)){
|
|
|
|
|
barcodeSpec = materialSpec;
|
|
|
|
|
}else{
|
|
|
|
|
barcodeSpec = "无";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.put("FDate", fdate);
|
|
|
|
|
data.put("FMaterialId", outstockDetail.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", barcodeSpec);
|
|
|
|
|
data.put("FUnitID", outstockDetail.getUnitCode());
|
|
|
|
|
data.put("FQty", FRealQty);
|
|
|
|
|
data.put("FPrice", outstockDetail.getPrice());
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
|
try {
|
|
|
|
|
R<AjaxResult> paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER);
|
|
|
|
|
String paramsResultData = paramsResult.getMsg();
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(paramsResultData);
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
log.info("synchronizeRawMaterialDeliveryInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new ServiceException("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + e.getMessage());
|
|
|
|
|
throw new ServiceException("synchronizeRawMaterialDeliveryInformationToERP失败:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定时同步退库信息给ERP
|
|
|
|
|
*
|
|
|
|
@ -190,20 +268,18 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeRawReturnInformationToERP() {
|
|
|
|
|
public Map<Long, List<WmsRawReturnDetail>> synchronizeRawReturnInformationToERP() {
|
|
|
|
|
WmsRawReturnDetail wmsRawReturnDetail = new WmsRawReturnDetail();
|
|
|
|
|
int result = 0;
|
|
|
|
|
List<WmsRawReturnDetail> returnDetailList = wmsRawReturnDetailMapper.selectWmsRawReturnDetailERPNotSynchronized(wmsRawReturnDetail);
|
|
|
|
|
Map<Long, List<WmsRawReturnDetail>> purchaseOrderIdMap = returnDetailList.stream().collect(Collectors.groupingBy(WmsRawReturnDetail::getPurchaseOrderId));
|
|
|
|
|
|
|
|
|
|
for (Long purchaseOrderId : purchaseOrderIdMap.keySet()) {
|
|
|
|
|
syncRawReturnInformation(purchaseOrderIdMap, purchaseOrderId, result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
return purchaseOrderIdMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public void syncRawReturnInformation(Map<Long, List<WmsRawReturnDetail>> purchaseOrderIdMap, Long purchaseOrderId, int result) {
|
|
|
|
|
R<MesPurchaseOrder> purchaseOrderData = remoteMesService.selectPurchaseOrderJoinSupplierProjectByOrderId(purchaseOrderId, SecurityConstants.INNER);
|
|
|
|
|
MesPurchaseOrder mesPurchaseOrder = null;
|
|
|
|
@ -267,74 +343,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
public int syncOutstockInformation(Map<Long, List<WmsRawOutstockDetail>> materialIdMap, Long materialId, String taskType) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
List<WmsRawOutstockDetail> wmsRawOutstockDetailList = materialIdMap.get(materialId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsRawOutstockDetailList.stream().mapToDouble(item -> item.getOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsRawOutstockDetail outstockDetail = wmsRawOutstockDetailList.get(0);
|
|
|
|
|
for (WmsRawOutstockDetail wmsRawOutstockDetail : wmsRawOutstockDetailList) {
|
|
|
|
|
if (wmsRawOutstockDetail.getPlanAmount().equals(wmsRawOutstockDetail.getOutstockAmount())) {
|
|
|
|
|
wmsRawOutstockDetail.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
} else {
|
|
|
|
|
wmsRawOutstockDetail.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
}
|
|
|
|
|
wmsRawOutstockDetail.setErpAmount(wmsRawOutstockDetail.getOutstockAmount());
|
|
|
|
|
wmsRawOutstockDetail.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsRawOutstockDetailMapper.updateWmsRawOutstockDetail(wmsRawOutstockDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(taskType) && taskType.equals(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK)) {
|
|
|
|
|
data.put("FTONDCombo", "售后服务");
|
|
|
|
|
} else {
|
|
|
|
|
data.put("FTONDCombo", "一般领料");
|
|
|
|
|
}
|
|
|
|
|
// model.put("F_TOND_Combo", "一般领料"); //领料类型(必填项)
|
|
|
|
|
|
|
|
|
|
String fdate = DateUtils.getTime();
|
|
|
|
|
if (outstockDetail.getOutstockTime() != null) {
|
|
|
|
|
fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, outstockDetail.getOutstockTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String barcodeSpec = outstockDetail.getBarcodeSpec();
|
|
|
|
|
String materialSpec = outstockDetail.getMaterialSpec();
|
|
|
|
|
if(StringUtils.isEmpty(barcodeSpec)){
|
|
|
|
|
if(StringUtils.isNotEmpty(materialSpec)){
|
|
|
|
|
barcodeSpec = materialSpec;
|
|
|
|
|
}else{
|
|
|
|
|
barcodeSpec = "无";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.put("FDate", fdate);
|
|
|
|
|
data.put("FMaterialId", outstockDetail.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", barcodeSpec);
|
|
|
|
|
data.put("FUnitID", outstockDetail.getUnitCode());
|
|
|
|
|
data.put("FQty", FRealQty);
|
|
|
|
|
data.put("FPrice", outstockDetail.getPrice());
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
|
try {
|
|
|
|
|
R<AjaxResult> paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER);
|
|
|
|
|
String paramsResultData = paramsResult.getMsg();
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(paramsResultData);
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
log.info("synchronizeRawMaterialDeliveryInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + e.getMessage());
|
|
|
|
|
throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定时同步成品入库信息给ERP
|
|
|
|
@ -343,8 +352,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeProductInstockInformationToERP(Integer days) {
|
|
|
|
|
public Map<Long, List<WmsProductInstock>> synchronizeProductInstockInformationToERP(Integer days) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
WmsProductInstock wmsProductInstock = new WmsProductInstock();
|
|
|
|
|
HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
|
@ -354,13 +362,12 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
wmsProductInstock.setParams(paramMap);
|
|
|
|
|
List<WmsProductInstock> productInstockList = wmsProductInstockMapper.selectWmsProductInstockERPNotSynchronized(wmsProductInstock);
|
|
|
|
|
Map<Long, List<WmsProductInstock>> productIdMap = productInstockList.stream().collect(Collectors.groupingBy(WmsProductInstock::getProductId));
|
|
|
|
|
for (Long productId : productIdMap.keySet()) {
|
|
|
|
|
syncProductInstockInformation(productIdMap, productId, result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
return productIdMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public void syncProductInstockInformation(Map<Long, List<WmsProductInstock>> productIdMap, Long productId, int result) {
|
|
|
|
|
List<WmsProductInstock> wmsProductInstockList = productIdMap.get(productId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
@ -402,12 +409,12 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
log.info("synchronizeProductInstockInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new ServiceException("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("synchronizeProductInstockInformationToERP失败:" + e.getMessage());
|
|
|
|
|
throw new RuntimeException("synchronizeProductInstockInformationToERP失败:" + e.getMessage());
|
|
|
|
|
throw new ServiceException("synchronizeProductInstockInformationToERP失败:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -418,8 +425,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeProductOutstockInformationToERP(Integer days) {
|
|
|
|
|
public Map<Long, List<WmsProductOutstock>> synchronizeProductOutstockInformationToERP(Integer days) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
WmsProductOutstock wmsProductOutstock = new WmsProductOutstock();
|
|
|
|
|
HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
|
@ -429,13 +435,12 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
wmsProductOutstock.setParams(paramMap);
|
|
|
|
|
List<WmsProductOutstock> productOutstockList = wmsProductOutstockMapper.selectWmsProductOutstockERPNotSynchronized(wmsProductOutstock);
|
|
|
|
|
Map<Long, List<WmsProductOutstock>> productIdMap = productOutstockList.stream().collect(Collectors.groupingBy(WmsProductOutstock::getProductId));
|
|
|
|
|
for (Long productId : productIdMap.keySet()) {
|
|
|
|
|
syncProductOutstockInformation(productIdMap, productId, result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
return productIdMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public void syncProductOutstockInformation(Map<Long, List<WmsProductOutstock>> productIdMap, Long productId, int result) {
|
|
|
|
|
List<WmsProductOutstock> wmsProductOutstockList = productIdMap.get(productId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
@ -479,12 +484,12 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
log.info("synchronizeProductOutstockInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new ServiceException("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("synchronizeProductOutstockInformationToERP失败:" + e.getMessage());
|
|
|
|
|
throw new RuntimeException("synchronizeProductOutstockInformationToERP失败:" + e.getMessage());
|
|
|
|
|
throw new ServiceException("synchronizeProductOutstockInformationToERP失败:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|