ERP:
成品出库和成品入库完善
master
xs 2 weeks ago
parent d02fda5211
commit be79405985

@ -3,6 +3,7 @@ package com.hw.jindie.config;
import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.utils.DateUtils;
import com.kingdee.bos.webapi.sdk.K3CloudApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -17,6 +18,18 @@ public class KingdeeConfig {
return new K3CloudApi();
}
/**
* erpID
* */
@Value("${erp.deptId}")
public Long erpDeptId;
/**
* erp
*/
@Value("${erp.materialCodePrefix}")
public String materialCodePrefix;
/**
*
*/

@ -32,6 +32,21 @@ public class KingdeeErpSyncController {
@Autowired
private KingdeeErpService kingdeeErpService;
/**
* erpMES
*/
@PostMapping("/syncDeptInfoFromErp")
@Log(title = "ERP部门信息", businessType = BusinessType.INSERT)
// @InnerAuth
public AjaxResult syncDeptInfoFromErp() {
try {
return AjaxResult.success(kingdeeErpSyncService.syncDeptInfoFromErp(0));
} catch (Exception e) {
logger.error("同步部门信息错误:" + e.getMessage());
return AjaxResult.error();
}
}
/**
* erpMES
*/
@ -65,9 +80,9 @@ public class KingdeeErpSyncController {
/**
* ERPMES
*/
@Log(title = "ERP物料信息", businessType = BusinessType.INSERT)
// @Log(title = "ERP物料信息", businessType = BusinessType.INSERT)
@PostMapping(("/syncMaterialInfoFromErp"))
@InnerAuth
// @InnerAuth
public AjaxResult syncMaterialInfoFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo) {
try {
return AjaxResult.success(kingdeeErpSyncService.syncMaterialInfoFromErp(0, erpSyncInfoVo));

@ -95,5 +95,11 @@ public interface MesBaseMaterialInfoMapper
*/
public int batchMesBaseMaterialInfo(List<MesBaseMaterialInfo> mesBaseMaterialInfos);
/**
*
*
* @param materialCode
* @return
*/
public MesBaseMaterialInfo selectMesBaseMaterialInfoByMaterialCode(String materialCode);
}

@ -4,6 +4,12 @@ import com.hw.jindie.api.domain.vo.ErpSyncInfoVo;
public interface IKingdeeErpSyncService {
/**
* @throws Exception
* @Description:ERP
*/
public int syncDeptInfoFromErp(int startRow) throws Exception;
/**
* @throws Exception
* @Description:ERP

@ -200,7 +200,12 @@ public class KingdeeErpService {
String FDate = (String) objectParams.get("FDate");//日期
Double FRealQty = (Double) objectParams.get("FRealQty");//实收数量
String FStockId = (String) objectParams.get("FStockId");//仓库
String F_TOND_Base = "JY(NT)-SA-XS-2020-0039";//京源项目
String F_TOND_Base = (String) objectParams.get("FTondBase");//京源项目
String supplierCode = (String) objectParams.get("FSupplierCode");//供应商编码
supplierCode = StringUtils.isEmpty(supplierCode)?"VEN04520":supplierCode;
// String F_TOND_Base = "JY(NT)-SA-XS-2020-0039";//京源项目
try {
//业务对象标识
String formId = KingdeeConfig.STK_InStock;
@ -254,7 +259,7 @@ public class KingdeeErpService {
F_TOND_BaseObject.put("FNUMBER", F_TOND_Base);
model.put("F_TOND_Base", F_TOND_BaseObject); //京源项目(必填项)
JSONObject FSupplierId = new JSONObject();
FSupplierId.put("FNumber", "VEN04969");
FSupplierId.put("FNumber", supplierCode);
model.put("FSupplierId", FSupplierId); //供应商(必填项)
data.put("Model", model);
String saveParams = data.toJSONString();
@ -405,6 +410,7 @@ public class KingdeeErpService {
Double FQty = (Double) objectParams.get("FQty");//实发数量
Double FPrice = (Double) objectParams.get("FPrice");//成本价
String FStockId = (String) objectParams.get("FStockId");//仓库
String FTONDCombo = (String) objectParams.get("FTONDCombo");//领料类型(必填项)
try {
//业务对象标识
String formId = KingdeeConfig.STK_MisDelivery;
@ -448,7 +454,7 @@ public class KingdeeErpService {
JSONObject FDeptIdObject = new JSONObject();
FDeptIdObject.put("FNumber", "BM000001");
model.put("FDeptId", FDeptIdObject); //部门
model.put("F_TOND_Combo", "一般领料"); //领料类型(必填项)
model.put("F_TOND_Combo", FTONDCombo); //领料类型(必填项)
data.put("Model", model);
String saveParams = data.toJSONString();
String resultJson = client.save(formId, saveParams);

@ -6,6 +6,7 @@ import com.hw.common.core.constant.MesConstants;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils;
import com.hw.jindie.api.domain.vo.ErpSyncInfoVo;
import com.hw.jindie.config.KingdeeConfig;
import com.hw.jindie.domain.*;
import com.hw.jindie.mapper.*;
import com.hw.jindie.service.IKingdeeErpSyncService;
@ -39,9 +40,131 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
private MesPurchaseOrderMapper mesPurchaseOrderMapper;
@Autowired
private MesBaseUnitInfoMapper mesBaseUnitInfoMapper;
@Autowired
private KingdeeConfig kingdeeConfig;
private static final int limit = 100;
/**
* @throws Exception
* @Description:ERP
*/
@Override
public int syncDeptInfoFromErp(int startRow) throws Exception {
// String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ?
// mesBaseSupplierInfoMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate();
// String maxErpModifyDate = erpSyncInfoVo.getMaxErpModifyDate();
return syncDeptInfoFromErp1(startRow);
}
/**
* @throws Exception
* @Description:ERP,使
*/
public int syncDeptInfoFromErp1(int startRow) throws Exception {
System.out.println("startRow=" + startRow);
K3CloudApi api = new K3CloudApi();
JSONObject queryJson = new JSONObject();
String formId = "BD_Department";
String fieldKeys = "FDeptId,FNumber,FName,FCreateDate,FModifyDate";
String orderString = "";
int topRowCount = 0;
// int startRow = 0;
// int limit = 2;
queryJson.put("FormId", formId);
queryJson.put("FieldKeys", fieldKeys);
queryJson.put("OrderString", orderString);
queryJson.put("TopRowCount", topRowCount);
queryJson.put("StartRow", startRow);
queryJson.put("Limit", limit);
queryJson.put("SubSystemId", "");
//条件查询
// System.out.println(queryJson.toString());
String result = api.billQuery(queryJson.toString());
if (StringUtils.isEmpty(result)) {
return 1;
}
System.out.println("部门单据查询接口: " + result);
JSONArray resultArray = JSONArray.parseArray(result);
if (resultArray == null) {
return 1;
}
List<MesBaseUnitInfo> toInsertSupplierInfoList = new ArrayList<>();
List<MesBaseUnitInfo> toUpdateSupplierInfoList = new ArrayList<>();
Date currentDate = new Date();
// for (int i = 0; i < resultArray.size(); i++) {
// try {
// JSONObject resultObject = (JSONObject) resultArray.get(i);
// MesBaseUnitInfo baseUnitInfo = new MesBaseUnitInfo();
// //主键
// Long FUnitId = resultObject.getLong("FUnitId");
// //编号
// String FNumber = resultObject.getString("FNumber");
// //描述
// String FName = resultObject.getString("FName");
// //创建时间
// String FCreateDate = resultObject.getString("FCreateDate");
// //更新时间
// String FModifyDate = resultObject.getString("FModifyDate");
//
// baseUnitInfo.setUnitCode(FNumber);
// baseUnitInfo.setErpId(FUnitId);
// baseUnitInfo.setUnitName(FName);
// baseUnitInfo.setUnitStatus("1");
// baseUnitInfo.setUpdateTime(currentDate);
// if (StringUtils.isNotEmpty(FCreateDate)) {
// baseUnitInfo.setCreateTime(conversionERPTime(FCreateDate));
// }
// if (StringUtils.isNotEmpty(FModifyDate)) {
// baseUnitInfo.setErpModifyDate(conversionERPTime(FModifyDate));
// }
//
// MesBaseUnitInfo existedUnitInfo = mesBaseUnitInfoMapper.selectMesBaseUnitInfoByErpId(FUnitId);
//
// if (existedUnitInfo != null) {
// baseUnitInfo.setUnitId(existedUnitInfo.getUnitId());
// toUpdateSupplierInfoList.add(baseUnitInfo);
// } else {
// toInsertSupplierInfoList.add(baseUnitInfo);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// if (!toInsertSupplierInfoList.isEmpty()) {
// for (MesBaseUnitInfo mesBaseUnitInfo : toInsertSupplierInfoList) {
// mesBaseUnitInfoMapper.insertMesBaseUnitInfo(mesBaseUnitInfo);
// }
// }
//
// if (!toUpdateSupplierInfoList.isEmpty()) {
// for (MesBaseUnitInfo toUpdatedUnitInfo : toUpdateSupplierInfoList) {
// mesBaseUnitInfoMapper.updateMesBaseUnitInfo(toUpdatedUnitInfo);
// }
// }
System.out.println("size:" + resultArray.size());
// System.out.println(resultArray);
//如果返回的数组的数量等于分页数量,则继续获取下一页数据
if (resultArray.size() == limit) {
//通过递归同步所有供应商,测试先不用
int i = syncDeptInfoFromErp1(startRow + resultArray.size());
return 1;
} else {
//为空时的总行数
return startRow + resultArray.size();
}
}
/**
* @throws Exception
* @Description:ERP
@ -165,7 +288,6 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
}
/**
* @throws Exception
* @Description:ERP
@ -323,6 +445,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
public int syncMaterialInfoFromErp(int startRow, String maxErpModifyDate) throws Exception {
K3CloudApi api = new K3CloudApi();
String FDocumentStatus = "C";
String materialCodePrefix = kingdeeConfig.materialCodePrefix;
JSONObject queryJson = new JSONObject();
String formId = "BD_Material";
@ -341,11 +464,18 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
queryJson.put("Limit", limit);
queryJson.put("SubSystemId", "");
if (StringUtils.isEmpty(materialCodePrefix)) {
return 0;
}
//条件查询
StringBuilder filterStringBuilder = new StringBuilder();
filterStringBuilder.append("FNumber like '%").append(materialCodePrefix).append("%'");
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
queryJson.put("FilterString", filterString);
filterStringBuilder.append(" and FModifyDate >'").append(maxErpModifyDate).append("'");
}
queryJson.put("FilterString", filterStringBuilder.toString());
System.out.println(queryJson.toString());
String result = api.billQuery(queryJson.toString());
@ -417,6 +547,9 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
}
MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpId);
// MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByMaterialCode(materialCode);
if (existedMesBaseMaterialInfo != null) {
mesBaseMaterialInfo.setMaterialId(existedMesBaseMaterialInfo.getMaterialId());
toUpdateMaterialInfoList.add(mesBaseMaterialInfo);
@ -486,6 +619,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
//
// String filterString = "FNumber='98010102'";
// String filterString = "";
String orderString = "";
int topRowCount = 0;
// int startRow = 0;
@ -501,11 +636,23 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
System.out.println(queryJson.toString());
//条件查询
Long deptId = kingdeeConfig.erpDeptId;
if (deptId == null) {
return 0;
}
StringBuilder filterStringBuilder = new StringBuilder();
filterStringBuilder.append("FSaleDeptId = ").append(deptId);
filterStringBuilder.append(" and FDocumentStatus='C'");
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
queryJson.put("FilterString", filterString);
filterStringBuilder.append(" and FModifyDate >'").append(maxErpModifyDate).append("'");
}
queryJson.put("FilterString", filterStringBuilder.toString());
System.out.println(queryJson.toString());
String result = api.billQuery(queryJson.toString());
@ -558,6 +705,10 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
Long stockOrgId = resultObject.getLong("FStockOrgId");
//单据状态
String documentStatus = resultObject.getString("FDocumentStatus");
if(!documentStatus.equals("C")){
System.out.println(documentStatus);
}
String tondBase = resultObject.getString("F.TOND.Base");
String FCreateDate = resultObject.getString("FCreateDate");
@ -672,7 +823,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
//条件查询
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
String filterString = "FModifyDate >'" + maxErpModifyDate + "' and FDocumentStatus ='C'";
queryJson.put("FilterString", filterString);
}
System.out.println(queryJson.toString());
@ -693,6 +844,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
String FNumber = resultObject.getString("FNumber");
String FName = resultObject.getString("FName");
String FDocumentStatus = resultObject.getString("FDocumentStatus");
if(!FDocumentStatus.equals("C")){
System.out.println(FDocumentStatus);
}
String FForbidStatus = resultObject.getString("FForbidStatus");
String FAuditDate = resultObject.getString("FAuditDate");
String FModifyDate = resultObject.getString("FModifyDate");
@ -767,13 +923,13 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
* @DescrptionERP
*/
public int syncPurchaseOrderFromErp(int startRow, String maxErpModifyDate) throws Exception {
maxErpModifyDate = "2022-03-23 11:30:57";
// maxErpModifyDate = "2022-03-23 11:30:57";
K3CloudApi api = new K3CloudApi();
// String FDocumentStatus = "C";
JSONObject queryJson = new JSONObject();
String formId = "PUR_PurchaseOrder";
String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," +
"FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId";
String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FRequireDeptId,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," +
"FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,FPurchaseDeptId,F_TOND_Base,FSupplierId";
// String filterString = "";
String orderString = "";
int topRowCount = 0;
@ -787,20 +943,32 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
queryJson.put("StartRow", startRow);
queryJson.put("Limit", limit);
queryJson.put("SubSystemId", "");
System.out.println(queryJson.toString());
// System.out.println(queryJson.toString());
//条件查询
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
Long deptId = kingdeeConfig.erpDeptId;
if (deptId == null) {
return 0;
}
// System.out.println("maxErpModifyDate=" + maxErpModifyDate);
StringBuilder filterStringBuilder = new StringBuilder();
filterStringBuilder.append("FPurchaseDeptId = ").append(deptId);
filterStringBuilder.append(" and FDocumentStatus = 'C'");
// System.out.println("maxErpModifyDate=" + maxErpModifyDate);
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
queryJson.put("FilterString", filterString);
filterStringBuilder.append(" FModifyDate >'").append(maxErpModifyDate).append("'");
}
System.out.println(queryJson.toString());
queryJson.put("FilterString", filterStringBuilder.toString());
// System.out.println(queryJson.toString());
String result = api.billQuery(queryJson.toString());
JSONArray resultArray = JSONArray.parseArray(result);
System.out.println(resultArray.size());
System.out.println("采购订单单据查询接口: " + result);
// System.out.println(resultArray.size());
// System.out.println("采购订单单据查询接口: " + result);
List<MesPurchaseOrder> toInsertPurchaseOrderList = new ArrayList<>();
List<MesPurchaseOrder> toUpdatePurchaseOrderList = new ArrayList<>();
@ -817,6 +985,9 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
String approveDate = resultObject.getString("FApproveDate");
//单据状态
String documentStatus = resultObject.getString("FDocumentStatus");
if(!documentStatus.equals("C")){
System.out.println(documentStatus);
}
//订单明细id
Long fentryId = resultObject.getLong("FPOOrderEntry.FEntryID");
//erp物料ID
@ -871,9 +1042,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
mesPurchaseOrder.setTondBase(tondBase);
mesPurchaseOrder.setSupplierId(supplierId);
mesPurchaseOrder.setUpdateTime(currentDate);
//todo:需要确认ERP中的采购订单信息有没有完成和代采购的状态等信息
// mesPurchaseOrder.setOrderStatus(待采购);
mesPurchaseOrder.setOrderStatus(MesConstants.MES_PURCHASE_ORDER_STATUS_TOPURCHASE);
if (approveDate != null) {
mesPurchaseOrder.setApproveDate(conversionERPTime(approveDate));

@ -258,4 +258,9 @@
</foreach>
</insert>
<select id="selectMesBaseMaterialInfoByMaterialCode" parameterType="String" resultMap="MesBaseMaterialInfoResult">
select material_id from mes_base_material_info where material_code = #{materialCode} limit 1
</select>
</mapper>

@ -216,7 +216,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchMesBasePurchaseOrder">
INSERT INTO mes_purchase_order (erp_id, fentry_id, po_no, document_status, material_id, material_code, material_name, order_amount, complete_amount, approve_date, erp_modify_date, plan_delivery_date, order_status, unit_id, stock_unit_id, price_unit_id, aux_prop_id, specification_parameter, src_bill_no, purchase_org_id, tond_base, supplier_id, create_time,update_time) VALUES
<foreach item="item" index="index" collection="list" separator=",">
(#{item.erpId}, #{item.fentryId}, #{item.poNo},#{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.orderAmount}, #{item.completeAmount}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.orderStatus}, #{item.unitId}, #{item.stockUnitId}, #{item.priceUnitId}, #{item.auxPropId}, #{specificationParameter},#{item.srcBillNo}, #{item.purchaseOrgId}, #{item.tondBase}, #{item.supplierId}, #{item.createTime},#{item.updateTime})
(#{item.erpId}, #{item.fentryId}, #{item.poNo},#{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.orderAmount}, #{item.completeAmount}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.orderStatus}, #{item.unitId}, #{item.stockUnitId}, #{item.priceUnitId}, #{item.auxPropId}, #{item.specificationParameter},#{item.srcBillNo}, #{item.purchaseOrgId}, #{item.tondBase}, #{item.supplierId}, #{item.createTime},#{item.updateTime})
</foreach>
</insert>
</mapper>

@ -229,6 +229,9 @@ public class WmsRawOutstock extends BaseEntity {
/** 计量单位编号 */
private String unitCode;
private String taskTypeStr;
public String getUnitCode() {
return unitCode;
}
@ -581,6 +584,14 @@ public class WmsRawOutstock extends BaseEntity {
this.saleOrderId = saleOrderId;
}
public String getTaskTypeStr() {
return taskTypeStr;
}
public void setTaskTypeStr(String taskTypeStr) {
this.taskTypeStr = taskTypeStr;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -2,9 +2,11 @@ package com.hw.wms.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants;
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.StringUtils;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.jindie.api.RemoteJindieService;
import com.hw.mes.api.RemoteMesService;
@ -133,18 +135,30 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
@Override
@Transactional
public int synchronizeRawMaterialDeliveryInformationToERP() {
WmsRawOutstock rawOutstock = new WmsRawOutstock();
int result = 0;
List<WmsRawOutstock> outStockList = wmsRawOutstockMapper.selectWmsRawOutstockERPNotSynchronized(rawOutstock);
Map<Long, List<WmsRawOutstock>> materialIdMap = outStockList.stream().collect(Collectors.groupingBy(WmsRawOutstock::getMaterialId));
for (Long materialId : materialIdMap.keySet()) {
syncOutstockInformation(materialIdMap, materialId, result);
// WmsRawOutstock otherRawOutstock = new WmsRawOutstock();
// otherRawOutstock.setTaskTypeStr(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_PICKING + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_INSTALL
// + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_OTHER);
// List<WmsRawOutstock> otherRawOutstockList = wmsRawOutstockMapper.selectWmsRawOutstockERPNotSynchronized(otherRawOutstock);
// Map<Long, List<WmsRawOutstock>> otherMaterialIdMap = otherRawOutstockList.stream().collect(Collectors.groupingBy(WmsRawOutstock::getMaterialId));
// for (Long materialId : otherMaterialIdMap.keySet()) {
// result += syncOutstockInformation(otherMaterialIdMap, materialId, "");
// }
WmsRawOutstock returnRawOutstock = new WmsRawOutstock();
returnRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK);
List<WmsRawOutstock> returnOutstockList = wmsRawOutstockMapper.selectWmsRawOutstockERPNotSynchronized(returnRawOutstock);
Map<Long, List<WmsRawOutstock>> returnMaterialIdMap = returnOutstockList.stream().collect(Collectors.groupingBy(WmsRawOutstock::getMaterialId));
for (Long materialId : returnMaterialIdMap.keySet()) {
result += syncOutstockInformation(returnMaterialIdMap, materialId, WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK);
}
return result;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void syncOutstockInformation(Map<Long, List<WmsRawOutstock>> materialIdMap, Long materialId, int result) {
public int syncOutstockInformation(Map<Long, List<WmsRawOutstock>> materialIdMap, Long materialId, String taskType) {
int result = 0;
List<WmsRawOutstock> wmsRawOutstockList = materialIdMap.get(materialId);
JSONObject data = new JSONObject();
double FRealQty = wmsRawOutstockList.stream().mapToDouble(item -> item.getRealOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
@ -160,15 +174,21 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock);
}
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", "一般领料"); //领料类型(必填项)
data.put("FDate", DateUtils.getTime());
data.put("FMaterialId", outstock.getMaterialCode());
data.put("FAuxPropId", outstock.getSpecificationParameter());
data.put("FAuxPropId", outstock.getSpecificationParameter() == null ? "" : outstock.getSpecificationParameter());
data.put("FUnitID", outstock.getUnitCode());
data.put("FQty", FRealQty);
data.put("FPrice", outstock.getPrice());
data.put("FStockId", FStockId);
String params = data.toJSONString();
R<AjaxResult> paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER);
String paramsResultData = paramsResult.getMsg();
@ -181,6 +201,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString());
}
return result;
}
/**
@ -222,7 +243,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
data.put("FDate", DateUtils.getTime());
data.put("FMaterialId", instock.getMaterialCode());
data.put("FAuxPropId", instock.getSpecificationParameter());
data.put("FAuxPropId", instock.getSpecificationParameter() == null ? "B" : instock.getSpecificationParameter());
data.put("FUnitID", instock.getUnitCode());
data.put("FQty", FRealQty);
data.put("FPrice", instock.getPrice());
@ -279,11 +300,12 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
}
data.put("FDate", DateUtils.getTime());
data.put("FMaterialId", outstock.getMaterialCode());
data.put("FAuxPropId", outstock.getSpecificationParameter());
data.put("FAuxPropId", outstock.getSpecificationParameter() == null ? "无" : outstock.getSpecificationParameter());
data.put("FUnitID", outstock.getUnitCode());
data.put("FQty", FRealQty);
data.put("FPrice", outstock.getPrice());
data.put("FStockId", FStockId);
data.put("FTONDCombo", "一般领料");
String params = data.toJSONString();
R<AjaxResult> paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER);
String paramsResultData = paramsResult.getMsg();

@ -248,6 +248,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wpi.execute_status = '2'
and (wpi.erp_status is null or wpi.erp_status != '1')
and wpi.instock_type = '1'
and mbmi.material_classfication = '1'
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and wpi.apply_date between #{beginTime} and #{endTime}
</if>

@ -320,6 +320,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wpo.outstock_qty > 0
and wpo.apply_qty >= wpo.outstock_qty
and wpo.outstock_qty > if(wpo.erp_amount is null, 0, wpo.erp_amount)
and mbmi.material_classfication = '1'
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and wpi.apply_date between #{beginTime} and #{endTime}
</if>

@ -375,11 +375,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join mes_base_unit_info mbui on mbui.erp_id = mbmi.material_unit_id
left join mes_product_plan mpp on mpp.plan_code = wro.plan_code
left join mes_sale_order mso on mso.sale_order_id = mpp.sale_order_id
where wro.real_outstock_amount > 0
<where>
wro.real_outstock_amount > 0
and wro.outstock_amount >= wro.real_outstock_amount
and wro.real_outstock_amount > if(wro.erp_amount is null, 0, wro.erp_amount)
and wro.task_type in (1, 3, 5,9)
and mbmi.material_classfication = '1'
<if test="taskTypeStr != null and taskTypeStr != ''"> and wro.task_type in (${taskTypeStr})</if>
<if test="taskType != null and taskType != ''"> and wro.task_type = #{taskType}</if>
</where>
</select>
</mapper>

Loading…
Cancel
Save