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