fix:永丰售后修复BUG,
1,物料库存获取不到ERP:重新调整触发查询逻辑 2,工序变更导致物料无法出库:配置旧工序 3,测试出库订单ERP推送,任务下发
This commit is contained in:
1 parent
b2a9a38f38
commit
c76e7bb681
69 files changed
+5510
-157
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
@@ -27,12 +28,30 @@ namespace WebService
|
||||
{
|
||||
try
|
||||
{
|
||||
_wtm.DoLog("", ActionLogTypesEnum.Normal,"mes", request: materails);
|
||||
_wtm.DoLog($"MES物料推送: 收到请求", ActionLogTypesEnum.Normal, "物料", request: materails);
|
||||
var data = JsonConvert.DeserializeObject<MesMaterials>(materails);
|
||||
// 插入物料信息表
|
||||
|
||||
// 解析物料数量和编码列表,用于日志
|
||||
var items = data?.ISSUEMATERIALS?.ISSUEITEM ?? new List<ISSUEITEMItem>();
|
||||
var codes = items.Select(x => x.MATNR).Distinct().ToList();
|
||||
_wtm.DoLog($"MES物料推送: 解析完成{items.Count}条", ActionLogTypesEnum.Normal,
|
||||
"物料", request: $"codes=[{string.Join(",", codes)}]");
|
||||
|
||||
// 查本地已存在的物料编码
|
||||
var existingCodes = _unitwork.Find<Material>(m => codes.Contains(m.MaterialCode))
|
||||
.Select(m => m.MaterialCode)
|
||||
.ToHashSet();
|
||||
var newCodes = codes.Where(c => !existingCodes.Contains(c)).ToList();
|
||||
var skipCodes = codes.Where(c => existingCodes.Contains(c)).ToList();
|
||||
|
||||
var materialList = new List<Material>();
|
||||
foreach (var item in data.ISSUEMATERIALS.ISSUEITEM)
|
||||
foreach (var item in items)
|
||||
{
|
||||
// 已存在的跳过,不重复插入
|
||||
if (existingCodes.Contains(item.MATNR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var material = new Material
|
||||
{
|
||||
MaterialCode = item.MATNR,
|
||||
@@ -41,20 +60,30 @@ namespace WebService
|
||||
MaterialUnit = item.ERFME,
|
||||
MaterialSpec = item.ZZXHGG,
|
||||
Batch = item.LICHA,
|
||||
|
||||
SupplierCode = item.ZZSCCJ,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "mes"
|
||||
};
|
||||
materialList.Add(material);
|
||||
}
|
||||
_unitwork.BatchAdd<Material>(materialList.ToArray());
|
||||
|
||||
if (materialList.Count > 0)
|
||||
{
|
||||
_unitwork.BatchAdd<Material>(materialList.ToArray());
|
||||
}
|
||||
|
||||
_wtm.DoLog($"MES物料推送: 完成", ActionLogTypesEnum.Normal,
|
||||
"物料",
|
||||
request: $"新增={materialList.Count}条, 跳过(已存在)={skipCodes.Count}条",
|
||||
result: $"new=[{string.Join(",", newCodes)}], skip=[{string.Join(",", skipCodes)}]");
|
||||
|
||||
return new Result();
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: materails, result: "error");
|
||||
return new Result { Status = "N", Message = ex.Message};
|
||||
_wtm.DoLog($"MES物料推送: 异常", ActionLogTypesEnum.Normal, "物料",
|
||||
request: materails, result: ex.ToString());
|
||||
return new Result { Status = "N", Message = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user