|
|
|
@ -11,14 +11,9 @@ import com.hw.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.hw.jindie.api.RemoteJindieService;
|
|
|
|
|
import com.hw.mes.api.RemoteMesService;
|
|
|
|
|
import com.hw.mes.api.domain.MesPurchaseOrder;
|
|
|
|
|
import com.hw.wms.domain.WmsProductInstock;
|
|
|
|
|
import com.hw.wms.domain.WmsProductOutstock;
|
|
|
|
|
import com.hw.wms.domain.WmsRawInstock;
|
|
|
|
|
import com.hw.wms.domain.WmsRawOutstock;
|
|
|
|
|
import com.hw.wms.mapper.WmsProductInstockMapper;
|
|
|
|
|
import com.hw.wms.mapper.WmsProductOutstockMapper;
|
|
|
|
|
import com.hw.wms.mapper.WmsRawInstockMapper;
|
|
|
|
|
import com.hw.wms.mapper.WmsRawOutstockMapper;
|
|
|
|
|
import com.hw.wms.config.WmsConfig;
|
|
|
|
|
import com.hw.wms.domain.*;
|
|
|
|
|
import com.hw.wms.mapper.*;
|
|
|
|
|
import com.hw.wms.service.IWmsErpScheduledTaskService;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -55,14 +50,20 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
@Autowired
|
|
|
|
|
private WmsProductOutstockMapper wmsProductOutstockMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private WmsRawReturnDetailMapper wmsRawReturnDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteMesService remoteMesService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteJindieService remoteJindieService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private WmsConfig wmsConfig;
|
|
|
|
|
|
|
|
|
|
//仓库编码
|
|
|
|
|
private String FStockId = "CK050";
|
|
|
|
|
// private String FStockId = "CK050";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定时同步入库信息给ERP
|
|
|
|
@ -110,7 +111,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
data.put("FSrcBillNo", instock.getSrcBillNo());
|
|
|
|
|
data.put("FUnitID", instock.getUnitCode());
|
|
|
|
|
data.put("FRealQty", FRealQty);
|
|
|
|
|
data.put("FStockId", FStockId);
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
data.put("FSupplierCode", supplierCode);
|
|
|
|
|
data.put("FTondBase", projectNo);
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
@ -155,6 +156,76 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 定时同步退库信息给ERP
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
// @Transactional
|
|
|
|
|
public int 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
public void syncRawReturnInformation(Map<Long, List<WmsRawReturnDetail>> purchaseOrderIdMap, Long purchaseOrderId, int result) {
|
|
|
|
|
R<MesPurchaseOrder> purchaseOrderData = remoteMesService.selectPurchaseOrderJoinSupplierProjectByOrderId(purchaseOrderId, SecurityConstants.INNER);
|
|
|
|
|
MesPurchaseOrder mesPurchaseOrder = null;
|
|
|
|
|
if (purchaseOrderData != null) {
|
|
|
|
|
mesPurchaseOrder = purchaseOrderData.getData();
|
|
|
|
|
|
|
|
|
|
String supplierCode = mesPurchaseOrder == null ? "" : mesPurchaseOrder.getSupplierCode();
|
|
|
|
|
String projectNo = mesPurchaseOrder == null ? "" : mesPurchaseOrder.getProjectNo();
|
|
|
|
|
String srcBillNo = mesPurchaseOrder.getSrcBillNo();
|
|
|
|
|
|
|
|
|
|
List<WmsRawReturnDetail> wmsRawReturnDetaiList = purchaseOrderIdMap.get(purchaseOrderId);
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
double FRealQty = wmsRawReturnDetaiList.stream().mapToDouble(item -> item.getReturnAmount().subtract(item.getErpAmount()).doubleValue()).sum();
|
|
|
|
|
WmsRawReturnDetail rawReturnDetail = wmsRawReturnDetaiList.get(0);
|
|
|
|
|
String specificationParameter = StringUtils.isNotEmpty(mesPurchaseOrder.getSpecificationParameter()) ? mesPurchaseOrder.getSpecificationParameter() : rawReturnDetail.getMaterialSpec();
|
|
|
|
|
if (StringUtils.isNotEmpty(specificationParameter)) {
|
|
|
|
|
|
|
|
|
|
for (WmsRawReturnDetail wmsRawReturnDetail : wmsRawReturnDetaiList) {
|
|
|
|
|
wmsRawReturnDetail.setErpStatus("1");//同步ERP状态(0:失败,1成功)
|
|
|
|
|
wmsRawReturnDetail.setErpAmount(wmsRawReturnDetail.getReturnAmount());
|
|
|
|
|
wmsRawReturnDetail.setUpdateDate(DateUtils.getNowDate());
|
|
|
|
|
wmsRawReturnDetailMapper.updateWmsRawReturnDetail(wmsRawReturnDetail);
|
|
|
|
|
}
|
|
|
|
|
data.put("FDate", DateUtils.getTime());
|
|
|
|
|
data.put("FMaterialId", rawReturnDetail.getMaterialCode());
|
|
|
|
|
data.put("FAuxPropId", specificationParameter);
|
|
|
|
|
data.put("FSrcBillNo", srcBillNo);
|
|
|
|
|
data.put("FUnitID", rawReturnDetail.getUnitCode());
|
|
|
|
|
data.put("FRealQty", FRealQty);
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
data.put("FSupplierCode", supplierCode);
|
|
|
|
|
data.put("FTondBase", projectNo);
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
|
R<AjaxResult> paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER);
|
|
|
|
|
String paramsResultData = paramsResult.getMsg();
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(paramsResultData);
|
|
|
|
|
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
result++;
|
|
|
|
|
log.info("synchronizeInventoryInformationToERP同步原材料退库成功:" + paramsResult.toString());
|
|
|
|
|
} else {
|
|
|
|
|
log.error("synchronizeInventoryInformationToERP同步原材料退库失败:" + paramsResult.toString());
|
|
|
|
|
throw new ServiceException("同步原材料入库失败" + paramsResult.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
public int syncOutstockInformation(Map<Long, List<WmsRawOutstock>> materialIdMap, Long materialId, String taskType) {
|
|
|
|
|
int result = 0;
|
|
|
|
@ -186,7 +257,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
data.put("FUnitID", outstock.getUnitCode());
|
|
|
|
|
data.put("FQty", FRealQty);
|
|
|
|
|
data.put("FPrice", outstock.getPrice());
|
|
|
|
|
data.put("FStockId", FStockId);
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
|
R<AjaxResult> paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER);
|
|
|
|
@ -246,7 +317,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
data.put("FUnitID", instock.getUnitCode());
|
|
|
|
|
data.put("FQty", FRealQty);
|
|
|
|
|
data.put("FPrice", instock.getPrice());
|
|
|
|
|
data.put("FStockId", FStockId);
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
|
R<AjaxResult> paramsResult = remoteJindieService.saveOtherInStorage(params, SecurityConstants.INNER);
|
|
|
|
|
String paramsResultData = paramsResult.getMsg();
|
|
|
|
@ -303,7 +374,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
|
|
|
|
|
data.put("FUnitID", outstock.getUnitCode());
|
|
|
|
|
data.put("FQty", FRealQty);
|
|
|
|
|
data.put("FPrice", outstock.getPrice());
|
|
|
|
|
data.put("FStockId", FStockId);
|
|
|
|
|
data.put("FStockId", wmsConfig.getfStockId());
|
|
|
|
|
data.put("FTONDCombo", "一般领料");
|
|
|
|
|
String params = data.toJSONString();
|
|
|
|
|
R<AjaxResult> paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER);
|
|
|
|
|