|
|
|
@ -3,6 +3,7 @@ package com.hw.wms.service.impl;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.hw.common.core.constant.SecurityConstants;
|
|
|
|
|
import com.hw.common.core.domain.R;
|
|
|
|
|
import com.hw.common.core.exception.ServiceException;
|
|
|
|
|
import com.hw.common.core.utils.DateUtils;
|
|
|
|
|
import com.hw.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.hw.jindie.api.RemoteJindieService;
|
|
|
|
@ -62,20 +63,22 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeInventoryInformationToERP() {
|
|
|
|
|
WmsRawInstock wmsRawInstock = new WmsRawInstock();
|
|
|
|
|
int result = 0;
|
|
|
|
|
List<WmsRawInstock> inStockList = wmsRawInstockMapper.selectWmsRawInstockERPNotSynchronized(wmsRawInstock);
|
|
|
|
|
Map<Long, List<WmsRawInstock>> materialIdMap = inStockList.stream().collect(Collectors.groupingBy(WmsRawInstock::getMaterialId));
|
|
|
|
|
for (Long materialId : materialIdMap.keySet()) {
|
|
|
|
|
syncInventoryInformation(materialIdMap, materialId, result);
|
|
|
|
|
Map<Long, List<WmsRawInstock>> purchaseOrderIdMap = inStockList.stream().collect(Collectors.groupingBy(WmsRawInstock::getPurchaseOrderId));
|
|
|
|
|
|
|
|
|
|
for (Long purchaseOrderId : purchaseOrderIdMap.keySet()) {
|
|
|
|
|
syncInventoryInformation(purchaseOrderIdMap, purchaseOrderId, result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
void syncInventoryInformation(Map<Long, List<WmsRawInstock>> materialIdMap, Long materialId, int result) {
|
|
|
|
|
List<WmsRawInstock> wmsRawInstockList = materialIdMap.get(materialId);
|
|
|
|
|
public void syncInventoryInformation(Map<Long, List<WmsRawInstock>> purchaseOrderIdMap, Long purchaseOrderId, int result) {
|
|
|
|
|
List<WmsRawInstock> wmsRawInstockList = purchaseOrderIdMap.get(purchaseOrderId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsRawInstockList.stream().mapToDouble(item -> item.getInstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsRawInstock instock = wmsRawInstockList.get(0);
|
|
|
|
@ -88,7 +91,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
data.put("FDate", DateUtils.getTime());
|
|
|
|
|
data.put("FMaterialId", instock.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", instock.getSpecificationParameter());
|
|
|
|
|
data.put("FSrcBillNo", instock.getPoNo());
|
|
|
|
|
data.put("FSrcBillNo", instock.getSrcBillNo());
|
|
|
|
|
data.put("FUnitID", instock.getUnitCode());
|
|
|
|
|
data.put("FRealQty", FRealQty);
|
|
|
|
|
data.put("FStockId", FStockId);
|
|
|
|
@ -99,9 +102,10 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
log.info("synchronizeInventoryInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeInventoryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("同步原材料入库失败"+paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -111,6 +115,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeRawMaterialDeliveryInformationToERP() {
|
|
|
|
|
WmsRawOutstock rawOutstock = new WmsRawOutstock();
|
|
|
|
|
int result = 0;
|
|
|
|
@ -123,11 +128,22 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
void syncOutstockInformation(Map<Long, List<WmsRawOutstock>> materialIdMap, Long materialId, int result) {
|
|
|
|
|
public void syncOutstockInformation(Map<Long, List<WmsRawOutstock>> materialIdMap, Long materialId, int result) {
|
|
|
|
|
List<WmsRawOutstock> wmsRawOutstockList = materialIdMap.get(materialId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsRawOutstockList.stream().mapToDouble(item -> item.getRealOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsRawOutstock outstock = wmsRawOutstockList.get(0);
|
|
|
|
|
for (WmsRawOutstock wmsRawOutstock : wmsRawOutstockList) {
|
|
|
|
|
if (wmsRawOutstock.getRealOutstockAmount().equals(wmsRawOutstock.getOutstockAmount())) {
|
|
|
|
|
wmsRawOutstock.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
} else {
|
|
|
|
|
wmsRawOutstock.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
}
|
|
|
|
|
wmsRawOutstock.setErpAmount(wmsRawOutstock.getRealOutstockAmount());
|
|
|
|
|
wmsRawOutstock.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.put("FDate", DateUtils.getTime());
|
|
|
|
|
data.put("FMaterialId", outstock.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", outstock.getSpecificationParameter());
|
|
|
|
@ -142,19 +158,10 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
for (WmsRawOutstock wmsRawOutstock : wmsRawOutstockList) {
|
|
|
|
|
if (wmsRawOutstock.getRealOutstockAmount().equals(wmsRawOutstock.getOutstockAmount())) {
|
|
|
|
|
wmsRawOutstock.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
} else {
|
|
|
|
|
wmsRawOutstock.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中)
|
|
|
|
|
}
|
|
|
|
|
wmsRawOutstock.setErpAmount(wmsRawOutstock.getRealOutstockAmount());
|
|
|
|
|
wmsRawOutstock.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock);
|
|
|
|
|
}
|
|
|
|
|
log.info("synchronizeRawMaterialDeliveryInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -164,6 +171,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeProductInstockInformationToERP(Integer days) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
WmsProductInstock wmsProductInstock = new WmsProductInstock();
|
|
|
|
@ -181,11 +189,18 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
void syncProductInstockInformation(Map<Long, List<WmsProductInstock>> productIdMap, Long productId, int result) {
|
|
|
|
|
public void syncProductInstockInformation(Map<Long, List<WmsProductInstock>> productIdMap, Long productId, int result) {
|
|
|
|
|
List<WmsProductInstock> wmsProductInstockList = productIdMap.get(productId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsProductInstockList.stream().mapToDouble(item -> item.getInstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsProductInstock instock = wmsProductInstockList.get(0);
|
|
|
|
|
for (WmsProductInstock wmsProductInstock : wmsProductInstockList) {
|
|
|
|
|
wmsProductInstock.setErpStatus("1");//同步ERP状态(0:失败,1成功)
|
|
|
|
|
wmsProductInstock.setErpAmount(wmsProductInstock.getInstockAmount());
|
|
|
|
|
wmsProductInstock.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsProductInstockMapper.updateWmsProductInstock(wmsProductInstock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.put("FDate", DateUtils.getTime());
|
|
|
|
|
data.put("FMaterialId", instock.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", instock.getSpecificationParameter());
|
|
|
|
@ -200,15 +215,10 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
for (WmsProductInstock wmsProductInstock : wmsProductInstockList) {
|
|
|
|
|
wmsProductInstock.setErpStatus("1");//同步ERP状态(0:失败,1成功)
|
|
|
|
|
wmsProductInstock.setErpAmount(wmsProductInstock.getInstockAmount());
|
|
|
|
|
wmsProductInstock.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsProductInstockMapper.updateWmsProductInstock(wmsProductInstock);
|
|
|
|
|
}
|
|
|
|
|
log.info("synchronizeProductInstockInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -218,6 +228,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int synchronizeProductOutstockInformationToERP(Integer days) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
WmsProductOutstock wmsProductOutstock = new WmsProductOutstock();
|
|
|
|
@ -235,11 +246,17 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
void syncProductOutstockInformation(Map<Long, List<WmsProductOutstock>> productIdMap, Long productId, int result) {
|
|
|
|
|
public void syncProductOutstockInformation(Map<Long, List<WmsProductOutstock>> productIdMap, Long productId, int result) {
|
|
|
|
|
List<WmsProductOutstock> wmsProductOutstockList = productIdMap.get(productId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsProductOutstockList.stream().mapToDouble(item -> item.getOutstockQty().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsProductOutstock outstock = wmsProductOutstockList.get(0);
|
|
|
|
|
for (WmsProductOutstock wmsProductOutstock : wmsProductOutstockList) {
|
|
|
|
|
wmsProductOutstock.setErpStatus("1");//同步ERP状态(0:失败,1成功)
|
|
|
|
|
wmsProductOutstock.setErpAmount(wmsProductOutstock.getOutstockQty());
|
|
|
|
|
wmsProductOutstock.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsProductOutstockMapper.updateWmsProductOutstock(wmsProductOutstock);
|
|
|
|
|
}
|
|
|
|
|
data.put("FDate", DateUtils.getTime());
|
|
|
|
|
data.put("FMaterialId", outstock.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", outstock.getSpecificationParameter());
|
|
|
|
@ -254,15 +271,11 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
for (WmsProductOutstock wmsProductOutstock : wmsProductOutstockList) {
|
|
|
|
|
wmsProductOutstock.setErpStatus("1");//同步ERP状态(0:失败,1成功)
|
|
|
|
|
wmsProductOutstock.setErpAmount(wmsProductOutstock.getOutstockQty());
|
|
|
|
|
wmsProductOutstock.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsProductOutstockMapper.updateWmsProductOutstock(wmsProductOutstock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("synchronizeProductOutstockInformationToERP成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
throw new RuntimeException("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|