😎更改查询ECN编号方法,修改变更通知ECN接口查询ecn逻辑,修改sap 同步ecn服务逻辑
This commit is contained in:
parent
8c10248dc2
commit
a2e5b55f1d
@ -5,14 +5,18 @@
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using Admin.NET.Core;
|
||||
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using NewLife;
|
||||
using RazorEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Vistar.Application.Entity;
|
||||
using Vistar.Application.SapService.Dto;
|
||||
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinAccountGetAccountBasicInfoResponse.Types;
|
||||
|
||||
namespace Vistar.Application.Common;
|
||||
@ -25,13 +29,15 @@ public class DataValidationService : IDynamicApiController, ITransient
|
||||
public SqlSugarRepository<Obj133> _obj133Rep;
|
||||
public SqlSugarRepository<Obj122> _obj122Rep;
|
||||
public SqlSugarRepository<Obj137> _obj137Rep;
|
||||
public SqlSugarRepository<ObjectTypeCheckList> _objectTypeCheckListRep;
|
||||
public DataValidationService(
|
||||
SqlSugarRepository<Obj110> obj110Rep,
|
||||
SqlSugarRepository<Obj109> obj109Rep,
|
||||
SqlSugarRepository<Obj112> obj112Rep,
|
||||
SqlSugarRepository<Obj133> obj133Rep,
|
||||
SqlSugarRepository<Obj122> obj122Rep,
|
||||
SqlSugarRepository<Obj137> obj137Rep
|
||||
SqlSugarRepository<Obj137> obj137Rep,
|
||||
SqlSugarRepository<ObjectTypeCheckList> objectTypeCheckList
|
||||
)
|
||||
{
|
||||
_obj110Rep = obj110Rep;
|
||||
@ -40,7 +46,7 @@ public class DataValidationService : IDynamicApiController, ITransient
|
||||
_obj133Rep = obj133Rep;
|
||||
_obj122Rep = obj122Rep;
|
||||
_obj137Rep = obj137Rep;
|
||||
|
||||
_objectTypeCheckListRep = objectTypeCheckList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 验证物料是否存在
|
||||
@ -83,16 +89,72 @@ public class DataValidationService : IDynamicApiController, ITransient
|
||||
return verification;
|
||||
}
|
||||
|
||||
public async Task<string> ChangeModuleMaterial(long objId, string recordGuid)
|
||||
/// <summary>
|
||||
/// 查询ecn编号
|
||||
/// </summary>
|
||||
/// <param name="idRecord"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<EcnItemData>> ChangeModuleMaterial(long idRecord)
|
||||
{
|
||||
string encoding = "";
|
||||
var encodingList = new List<EcnItemData>();
|
||||
|
||||
if (objId==110)
|
||||
// 获取符合条件的检查列表项
|
||||
var checkList = await _objectTypeCheckListRep.AsQueryable()
|
||||
.Where(x => x.ParentIdRecord == idRecord && (x.ColumnId == 4638 || x.ColumnId == 6002))
|
||||
.ToListAsync();
|
||||
|
||||
// 遍历检查列表
|
||||
foreach (var item in checkList)
|
||||
{
|
||||
var data = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).FirstAsync();
|
||||
encoding = data._System_objNBS;
|
||||
var recordGuid = item.RecordGuid;
|
||||
var objectId = item.ObjectId;
|
||||
dynamic data = null; // 使用 dynamic 类型来通用处理不同的仓储查询
|
||||
|
||||
// 根据 ObjectId 选择相应的仓储并查询数据
|
||||
switch (objectId)
|
||||
{
|
||||
case 110:
|
||||
data = await _obj110Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == recordGuid && x.deleted == false)
|
||||
.FirstAsync();
|
||||
break;
|
||||
case 109:
|
||||
data = await _obj109Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == recordGuid && x.deleted == false)
|
||||
.FirstAsync();
|
||||
break;
|
||||
case 112:
|
||||
data = await _obj112Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == recordGuid && x.deleted == false)
|
||||
.FirstAsync();
|
||||
break;
|
||||
case 133:
|
||||
data = await _obj133Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == recordGuid && x.deleted == false)
|
||||
.FirstAsync();
|
||||
break;
|
||||
case 122:
|
||||
data = await _obj122Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == recordGuid && x.deleted == false)
|
||||
.FirstAsync();
|
||||
break;
|
||||
case 137:
|
||||
data = await _obj137Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == recordGuid && x.deleted == false)
|
||||
.FirstAsync();
|
||||
break;
|
||||
default:
|
||||
continue; // 如果 ObjectId 不匹配,跳过本次循环
|
||||
}
|
||||
|
||||
// 创建新的 EcnItemData 对象并添加到列表中
|
||||
encodingList.Add(new EcnItemData
|
||||
{
|
||||
Matnr = data._System_objNBS
|
||||
});
|
||||
}
|
||||
|
||||
return encoding;
|
||||
// 返回编码列表
|
||||
return encodingList;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
//
|
||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||
//
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using Admin.NET.Core;
|
||||
using SqlSugar;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Vistar.Application.Entity;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarTable("ObjectTypeCheckList","")]
|
||||
[Tenant("启威星 1.94.4.74")]
|
||||
public class ObjectTypeCheckList
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "ObjectTypeCheckListId", IsIdentity = true, ColumnDescription = "", IsPrimaryKey = true)]
|
||||
public long ObjectTypeCheckListId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "RecordGuid", ColumnDescription = "", Length = 40)]
|
||||
public string RecordGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "ObjectId", ColumnDescription = "")]
|
||||
public long ObjectId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "ColumnId", ColumnDescription = "")]
|
||||
public long ColumnId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "ParentIdRecord", ColumnDescription = "")]
|
||||
public long ParentIdRecord { get; set; }
|
||||
|
||||
}
|
@ -43,8 +43,14 @@ public class SapEcnInput
|
||||
/// </summary>
|
||||
public string Lvorm { get; set; }
|
||||
|
||||
public List<EcnItemData> ItemList { get; set; }
|
||||
}
|
||||
|
||||
public class EcnItemData
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string Matnr { get; set; }
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ public class SapService : IDynamicApiController, ITransient
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var httpClientHandler = new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true,
|
||||
@ -107,8 +108,9 @@ public class SapService : IDynamicApiController, ITransient
|
||||
// 将 XML 内容转换为字符串并设置请求内容类型为 text/xml
|
||||
var content = new StringContent(soapEnvelope.ToString(), Encoding.UTF8, "text/xml");
|
||||
content.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
|
||||
httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh");
|
||||
// 设置 SAP Web 服务的 URL
|
||||
var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zmmfm012/110/zmmfm012/zmmfm012";
|
||||
var url = "https://vhjqeps4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zmmfm012/100/zmmfm012/zmmfm012";
|
||||
|
||||
// 发起 POST 请求到 SAP Web 服务
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
@ -200,6 +202,7 @@ public class SapService : IDynamicApiController, ITransient
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var httpClientHandler = new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true,
|
||||
@ -217,8 +220,9 @@ public class SapService : IDynamicApiController, ITransient
|
||||
// 将 XML 内容转换为字符串并设置请求内容类型为 text/xml
|
||||
var content = new StringContent(soapEnvelope.ToString(), Encoding.UTF8, "text/xml");
|
||||
content.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
|
||||
httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh");
|
||||
// 设置 SAP Web 服务的 URL
|
||||
var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm001/110/zppfm001/zppfm001";
|
||||
var url = "https://vhjqeps4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm001/100/zppfm001/zppfm001";
|
||||
|
||||
// 发起 POST 请求到 SAP Web 服务
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
@ -310,6 +314,28 @@ public class SapService : IDynamicApiController, ITransient
|
||||
return itemElements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成 EcnItem 元素
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <returns></returns>
|
||||
public List<XElement> EcnItem(List<EcnItemData> items)
|
||||
{
|
||||
var itemElements = new List<XElement>();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var element = new XElement("item",
|
||||
new XElement("MATNR", item.Matnr)
|
||||
);
|
||||
|
||||
itemElements.Add(element);
|
||||
}
|
||||
|
||||
return itemElements;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// SAP同步ECN
|
||||
/// </summary>
|
||||
@ -342,7 +368,7 @@ public class SapService : IDynamicApiController, ITransient
|
||||
new XElement("Lvorm", input.Lvorm),
|
||||
new XElement("Item",
|
||||
new XElement("item",
|
||||
new XElement("Matnr", input.Matnr)
|
||||
EcnItem(input.ItemList)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -370,8 +396,9 @@ public class SapService : IDynamicApiController, ITransient
|
||||
// 将 XML 内容转换为字符串并设置请求内容类型为 text/xml
|
||||
var content = new StringContent(soapEnvelope.ToString(), Encoding.UTF8, "text/xml");
|
||||
content.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
|
||||
httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh");
|
||||
// 设置 SAP Web 服务的 URL
|
||||
var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm003/110/zppfm003/zppfm003";
|
||||
var url = "https://vhjqeps4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm003/100/zppfm003/zppfm003";
|
||||
|
||||
// 发起 POST 请求到 SAP Web 服务
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
@ -461,6 +488,7 @@ public class SapService : IDynamicApiController, ITransient
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var httpClientHandler = new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true,
|
||||
@ -478,8 +506,9 @@ public class SapService : IDynamicApiController, ITransient
|
||||
// 将 XML 内容转换为字符串并设置请求内容类型为 text/xml
|
||||
var content = new StringContent(soapEnvelope.ToString(), Encoding.UTF8, "text/xml");
|
||||
content.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
|
||||
httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh");
|
||||
// 设置 SAP Web 服务的 URL
|
||||
var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm004/110/zppfm004/zppfm004";
|
||||
var url = "https://vhjqeps4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm004/100/zppfm004/zppfm004";
|
||||
|
||||
// 发起 POST 请求到 SAP Web 服务
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
|
@ -33,18 +33,21 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
public SqlSugarRepository<Obj118> _obj118Rep;
|
||||
private readonly SysConfigService _sysConfigService;
|
||||
public Common.DataValidationService _dataValidationService;
|
||||
public SapService.SapService _sapService;
|
||||
public SapService.SapService _sapService;
|
||||
|
||||
public ChangeNoticeEcnService(
|
||||
SqlSugarRepository<Obj118> obj118Rep,
|
||||
SysConfigService sysConfigService,
|
||||
DataValidationService dataValidationService,
|
||||
SapService.SapService sapService
|
||||
SapService.SapService sapService
|
||||
|
||||
)
|
||||
{
|
||||
_obj118Rep = obj118Rep;
|
||||
_sysConfigService = sysConfigService;
|
||||
_dataValidationService = dataValidationService;
|
||||
_sapService = sapService;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询变更通知ECN
|
||||
@ -90,7 +93,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
Aetxt = input._System_ObjDescription,
|
||||
Datuv = input.fld004693.ToDateTime().ToString("yyyy-MM-dd"),
|
||||
Lvorm = input.fld004694,
|
||||
Matnr = await _dataValidationService.ChangeModuleMaterial(input.fld004638.ToLong(),input.fld004638_Rec)
|
||||
ItemList = await _dataValidationService.ChangeModuleMaterial(input.idRecord)
|
||||
};
|
||||
|
||||
var apiOutput = await _sapService.SapEcnApi(sapEcnInput);
|
||||
@ -154,7 +157,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
Aetxt = input[i]._System_ObjDescription,
|
||||
Datuv = input[i].fld004693.ToDateTime().ToString("yyyy-MM-dd"),
|
||||
Lvorm = input[i].fld004694,
|
||||
Matnr = await _dataValidationService.ChangeModuleMaterial(input[i].fld004638.ToLong(), input[i].fld004638_Rec)
|
||||
ItemList = await _dataValidationService.ChangeModuleMaterial(input[i].idRecord)
|
||||
};
|
||||
var apiOutput = await _sapService.SapEcnApi(sapEcnInput);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
@ -221,7 +224,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
Aetxt = input[i]._System_ObjDescription,
|
||||
Datuv = input[i].fld004693.ToDateTime().ToString("yyyy-MM-dd"),
|
||||
Lvorm = input[i].fld004694,
|
||||
Matnr = await _dataValidationService.ChangeModuleMaterial(input[i].fld004638.ToLong(), input[i].fld004638_Rec)
|
||||
ItemList = await _dataValidationService.ChangeModuleMaterial(input[i].idRecord)
|
||||
};
|
||||
var apiOutput = await _sapService.SapEcnApi(sapEcnInput);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
|
Loading…
Reference in New Issue
Block a user