😎实现产品管理、项目管理工艺路线功能,增加sap工艺路线同步服务

This commit is contained in:
bairubing 2024-10-14 13:38:05 +08:00
parent 55a080bd89
commit 8c197178d6
16 changed files with 1352 additions and 20 deletions

View File

@ -23,17 +23,20 @@ public class DataValidationService : IDynamicApiController, ITransient
public SqlSugarRepository<Obj109> _obj109Rep;
public SqlSugarRepository<Obj112> _obj112Rep;
public SqlSugarRepository<Obj133> _obj133Rep;
public SqlSugarRepository<Obj122> _obj122Rep;
public DataValidationService(
SqlSugarRepository<Obj110> obj110Rep,
SqlSugarRepository<Obj109> obj109Rep,
SqlSugarRepository<Obj112> obj112Rep,
SqlSugarRepository<Obj133> obj133Rep
SqlSugarRepository<Obj133> obj133Rep,
SqlSugarRepository<Obj122> obj122Rep
)
{
_obj110Rep = obj110Rep;
_obj109Rep = obj109Rep;
_obj112Rep = obj112Rep;
_obj133Rep = obj133Rep;
_obj122Rep = obj122Rep;
}
/// <summary>
/// 验证物料是否存在
@ -60,6 +63,9 @@ public class DataValidationService : IDynamicApiController, ITransient
case 133:
tasks.Add(_obj133Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false && x.RecordGuid == recordGuid).CountAsync());
break;
case 122:
tasks.Add(_obj122Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false && x.RecordGuid == recordGuid).CountAsync());
break;
}
if (tasks.Count > 0)
{

View File

@ -545,5 +545,16 @@ public class ConfigurationData
/// </summary>
[SugarColumn(ColumnName = "fld005020", ColumnDescription = "", Length = -1)]
public string? fld005020 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005296", ColumnDescription = "", Length = -1)]
public long? fld005296 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005298", ColumnDescription = "", Length = -1)]
public long? fld005298 { get; set; }
}

View File

@ -745,4 +745,10 @@ public class Obj110
/// </summary>
[SugarColumn(ColumnName = "fld004945", ColumnDescription = "", Length = -1)]
public DateTime? fld004945 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005288", ColumnDescription = "", Length = -1)]
public string? fld005288 { get; set; }
}

View File

@ -0,0 +1,256 @@
// 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("OBJ121","")]
[Tenant("启威星 1.94.4.74")]
public class Obj121
{
/// <summary>
///
/// </summary>
[Required]
[SugarColumn(ColumnName = "idRecord", IsIdentity = true, ColumnDescription = "", IsPrimaryKey = true)]
public long idRecord { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")]
public bool? CheckedStatus { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "VersionIndex", ColumnDescription = "")]
public int? VersionIndex { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "IsLatestVersion", ColumnDescription = "")]
public bool? IsLatestVersion { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "CreatedDate", ColumnDescription = "")]
public DateTime? CreatedDate { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "VersionCreatedDate", ColumnDescription = "")]
public DateTime? VersionCreatedDate { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "dateModified", ColumnDescription = "")]
public DateTime? dateModified { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "UserCreatedId", ColumnDescription = "")]
public long? UserCreatedId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "VersionUserCreatedId", ColumnDescription = "")]
public long? VersionUserCreatedId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "UserModifiedId", ColumnDescription = "")]
public long? UserModifiedId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "RecordGuid", ColumnDescription = "", Length = 40)]
public string? RecordGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "isVisibilityNormal", ColumnDescription = "")]
public bool? isVisibilityNormal { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "deleted", ColumnDescription = "")]
public bool? deleted { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "SubObjectGuid", ColumnDescription = "", Length = 40)]
public string? SubObjectGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "PreviousStatus", ColumnDescription = "")]
public bool? PreviousStatus { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "revision", ColumnDescription = "", Length = 10)]
public string? revision { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "Record_image160_160", ColumnDescription = "")]
public byte[]? Record_image160_160 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "Record_Image320_240", ColumnDescription = "")]
public byte[]? Record_Image320_240 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "Record_ImageMax", ColumnDescription = "")]
public byte[]? Record_ImageMax { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_objNBS", ColumnDescription = "", Length = 100)]
public string? _System_objNBS { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_ObjDescription", ColumnDescription = "", Length = 200)]
public string? _System_ObjDescription { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_Effectivity_Begin", ColumnDescription = "")]
public DateTime? _System_Effectivity_Begin { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_Effectivity_End", ColumnDescription = "")]
public DateTime? _System_Effectivity_End { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "CheckedOutPc", ColumnDescription = "", Length = 255)]
public string? CheckedOutPc { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "GroupObjId", ColumnDescription = "")]
public long? GroupObjId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_CheckOutInProgress", ColumnDescription = "")]
public bool? _CheckOutInProgress { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "EnableNotifications", ColumnDescription = "")]
public bool? EnableNotifications { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objConfigurationName", ColumnDescription = "", Length = 255)]
public string? _system_objConfigurationName { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objConfigurationType", ColumnDescription = "")]
public bool? _system_objConfigurationType { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objConfigurationGuid", ColumnDescription = "", Length = 40)]
public string? _system_objConfigurationGuid { get; set; }
/// <summary>
///
/// </summary>
[Required]
[SugarColumn(ColumnName = "ShowBomFromConfiguration", ColumnDescription = "", Length = 250)]
public string ShowBomFromConfiguration { get; set; }
/// <summary>
///
/// </summary>
[Required]
[SugarColumn(ColumnName = "_System_ObjNbsAuto", ColumnDescription = "", Length = 50)]
public string _System_ObjNbsAuto { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_DerivedFrom", ColumnDescription = "", Length = 50)]
public string? _System_DerivedFrom { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_DerivedFrom_RecordGuid", ColumnDescription = "", Length = 50)]
public string? _System_DerivedFrom_RecordGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objLinkedCompare", ColumnDescription = "")]
public bool? _system_objLinkedCompare { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "isReleasedVersion", ColumnDescription = "")]
public bool? isReleasedVersion { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_WebLink", ColumnDescription = "", Length = 500)]
public string? _System_WebLink { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "LinkDrw", ColumnDescription = "")]
public bool? LinkDrw { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "ParentRecordGuid", ColumnDescription = "", Length = 40)]
public string? ParentRecordGuid { get; set; }
}

View File

@ -0,0 +1,274 @@
// 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("OBJ122","")]
[Tenant("启威星 1.94.4.74")]
public class Obj122
{
/// <summary>
///
/// </summary>
[Required]
[SugarColumn(ColumnName = "idRecord", IsIdentity = true, ColumnDescription = "", IsPrimaryKey = true)]
public long idRecord { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")]
public bool? CheckedStatus { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "VersionIndex", ColumnDescription = "")]
public int? VersionIndex { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "IsLatestVersion", ColumnDescription = "")]
public bool? IsLatestVersion { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "CreatedDate", ColumnDescription = "")]
public DateTime? CreatedDate { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "VersionCreatedDate", ColumnDescription = "")]
public DateTime? VersionCreatedDate { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "dateModified", ColumnDescription = "")]
public DateTime? dateModified { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "UserCreatedId", ColumnDescription = "")]
public long? UserCreatedId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "VersionUserCreatedId", ColumnDescription = "")]
public long? VersionUserCreatedId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "UserModifiedId", ColumnDescription = "")]
public long? UserModifiedId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "RecordGuid", ColumnDescription = "", Length = 40)]
public string? RecordGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "isVisibilityNormal", ColumnDescription = "")]
public bool? isVisibilityNormal { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "deleted", ColumnDescription = "")]
public bool? deleted { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "SubObjectGuid", ColumnDescription = "", Length = 40)]
public string? SubObjectGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "PreviousStatus", ColumnDescription = "")]
public bool? PreviousStatus { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "revision", ColumnDescription = "", Length = 10)]
public string? revision { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "Record_image160_160", ColumnDescription = "")]
public byte[]? Record_image160_160 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "Record_Image320_240", ColumnDescription = "")]
public byte[]? Record_Image320_240 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "Record_ImageMax", ColumnDescription = "")]
public byte[]? Record_ImageMax { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_objNBS", ColumnDescription = "", Length = 100)]
public string? _System_objNBS { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_ObjDescription", ColumnDescription = "", Length = 200)]
public string? _System_ObjDescription { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_Effectivity_Begin", ColumnDescription = "")]
public DateTime? _System_Effectivity_Begin { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_Effectivity_End", ColumnDescription = "")]
public DateTime? _System_Effectivity_End { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "CheckedOutPc", ColumnDescription = "", Length = 255)]
public string? CheckedOutPc { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "GroupObjId", ColumnDescription = "")]
public long? GroupObjId { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_CheckOutInProgress", ColumnDescription = "")]
public bool? _CheckOutInProgress { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "EnableNotifications", ColumnDescription = "")]
public bool? EnableNotifications { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objConfigurationName", ColumnDescription = "", Length = 255)]
public string? _system_objConfigurationName { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objConfigurationType", ColumnDescription = "")]
public bool? _system_objConfigurationType { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objConfigurationGuid", ColumnDescription = "", Length = 40)]
public string? _system_objConfigurationGuid { get; set; }
/// <summary>
///
/// </summary>
[Required]
[SugarColumn(ColumnName = "ShowBomFromConfiguration", ColumnDescription = "", Length = 250)]
public string ShowBomFromConfiguration { get; set; }
/// <summary>
///
/// </summary>
[Required]
[SugarColumn(ColumnName = "_System_ObjNbsAuto", ColumnDescription = "", Length = 50)]
public string _System_ObjNbsAuto { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_DerivedFrom", ColumnDescription = "", Length = 50)]
public string? _System_DerivedFrom { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_DerivedFrom_RecordGuid", ColumnDescription = "", Length = 50)]
public string? _System_DerivedFrom_RecordGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_system_objLinkedCompare", ColumnDescription = "")]
public bool? _system_objLinkedCompare { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "isReleasedVersion", ColumnDescription = "")]
public bool? isReleasedVersion { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "_System_WebLink", ColumnDescription = "", Length = 500)]
public string? _System_WebLink { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "LinkDrw", ColumnDescription = "")]
public bool? LinkDrw { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "ParentRecordGuid", ColumnDescription = "", Length = 40)]
public string? ParentRecordGuid { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005058", ColumnDescription = "", Length = -1)]
public string? fld005058 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005059", ColumnDescription = "")]
public long? fld005059 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005059_Rec", ColumnDescription = "", Length = 40)]
public string? fld005059_Rec { get; set; }
}

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vistar.Application.SapService.Dto
{
public class SapProcessRouteIS_REQ
{
public string ReqKeyId { get; set; }
public string BusinessId { get; set; }
public string MessageId { get; set; }
public string SndPrn { get; set; }
public string RcvPrn { get; set; }
public string ReqUser { get; set; }
public string Note1 { get; set; }
public string Note2 { get; set; }
public string Note3 { get; set; }
/// <summary>
/// 外部唯一ID
/// </summary>
public string Zwbid { get; set; }
/// <summary>
/// 抬头物料
/// </summary>
public string Matnr { get; set; }
/// <summary>
/// 工厂
/// </summary>
public string Werks { get; set; }
/// <summary>
/// 有效日期
/// </summary>
public string Datuv { get; set; }
/// <summary>
/// 组号
/// </summary>
public string Plnal { get; set; }
public List<SapProcessRouteItemData> ItemList { get; set; }
}
public class SapProcessRouteItemData
{
/// <summary>
/// 工序序号
/// </summary>
public string? VORNR { get; set; }
/// <summary>
/// 工序描述
/// </summary>
public string? LTXA1 { get; set; }
/// <summary>
/// 工作中心
/// </summary>
public string? ARBPL { get; set; }
/// <summary>
/// 工时
/// </summary>
public string? VGW01 { get; set; }
/// <summary>
/// 工时单位
/// </summary>
public string? VGE01 { get; set; }
/// <summary>
/// 控制码
/// </summary>
public string? STEUS { get; set; }
/// <summary>
/// 基本数量
/// </summary>
public string? BMSCH { get; set; }
}
}

View File

@ -418,6 +418,159 @@ public class SapService : IDynamicApiController, ITransient
return output;
}
}
/// <summary>
/// SAP同步工艺路线
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<SapOutput> SapProcessRouteApi(SapProcessRouteIS_REQ input)
{
// 创建SOAP XML请求
var soapEnvelope = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement(XName.Get("Envelope", "http://schemas.xmlsoap.org/soap/envelope/"),
new XElement(XName.Get("Header", "http://schemas.xmlsoap.org/soap/envelope/")),
new XElement(XName.Get("Body", "http://schemas.xmlsoap.org/soap/envelope/"),
new XElement(XName.Get("ZPPFM004", "urn:sap-com:document:sap:rfc:functions"),
new XElement("IS_REQ",
new XElement("REQKEYID", input.ReqKeyId),
new XElement("BUSINESSID", input.BusinessId),
new XElement("MESSAGEID", input.MessageId),
new XElement("SNDPRN", input.SndPrn),
new XElement("RCVPRN", input.RcvPrn),
new XElement("REQUSER", input.ReqUser),
new XElement("NOTE1", input.Note1),
new XElement("NOTE2", input.Note2),
new XElement("NOTE3", input.Note3)
),
new XElement("IT_DATA",
new XElement("item",
new XElement("ZWBID", input.Zwbid),
new XElement("MATNR", input.Matnr),
new XElement("WERKS", input.Werks),
new XElement("DATUV", input.Datuv),
new XElement("PLNAL", input.Plnal),
new XElement("ITEM",
// 使用循环生成 <item> 元素
ProcessRouteGenerateItemElements(input.ItemList)
)
)
)
)
)
)
);
var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true,
ClientCertificateOptions = ClientCertificateOption.Manual
};
try
{
using (var httpClient = new HttpClient(httpClientHandler))
{
// 设置基本身份验证信息
var username = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
var password = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapPassword);
var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
// 将 XML 内容转换为字符串并设置请求内容类型为 text/xml
var content = new StringContent(soapEnvelope.ToString(), Encoding.UTF8, "text/xml");
content.Headers.ContentType = new MediaTypeHeaderValue("text/xml");
// 设置 SAP Web 服务的 URL
var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm004/120/zppfm004/zppfm004";
// 发起 POST 请求到 SAP Web 服务
var response = await httpClient.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
XDocument doc = XDocument.Parse(result);
var item = doc.Descendants("item").FirstOrDefault();
var code = item?.Element("CODE")?.Value;
var msg = item?.Element("MSG")?.Value;
if (item == null)
{
var ES_RETItem = doc.Descendants("ES_RET").FirstOrDefault();
var ES_RETcode = ES_RETItem?.Element("CODE")?.Value;
var ES_RETmsg = ES_RETItem?.Element("MSG")?.Value;
var outputES_RET = new SapOutput()
{
parameter = soapEnvelope.ToString(),
code = ES_RETcode,
msg = ES_RETmsg,
result = result
};
return outputES_RET;
}
var output = new SapOutput()
{
parameter = soapEnvelope.ToString(),
code = code,
msg = msg,
result = result
};
return output;
}
else
{
var result = await response.Content.ReadAsStringAsync();
var output = new SapOutput()
{
parameter = soapEnvelope.ToString(),
code = "失败",
msg = "调用失败,状态码: " + response.StatusCode,
result = result
};
return output;
}
}
}
catch (Exception ex)
{
// 记录错误日志
Console.WriteLine("发生错误: " + ex.Message);
var output = new SapOutput()
{
code = "失败",
msg = "发生错误" + ex.Message,
result = "发生错误" + ex
};
return output;
}
}
/// <summary>
/// 生成工艺路线 item 元素
/// </summary>
/// <param name="items"></param>
/// <returns></returns>
public List<XElement> ProcessRouteGenerateItemElements(List<SapProcessRouteItemData> items)
{
var itemElements = new List<XElement>();
foreach (var item in items)
{
var element = new XElement("item",
new XElement("VORNR", item.VORNR),
new XElement("LTXA1", item.LTXA1),
new XElement("ARBPL", item.ARBPL),
new XElement("VGW01", item.VGW01),
new XElement("VGE01", item.VGE01),
new XElement("STEUS", item.STEUS),
new XElement("BMSCH", item.BMSCH)
);
itemElements.Add(element);
}
return itemElements;
}
}

View File

@ -198,4 +198,8 @@ public class BomPageProductManagementInput : BasePageInput
public string? fld005019 { get; set; }
public string? fld005020 { get; set; }
public long? fld005296 { get; set; }
public long? fld005298 { get; set; }
}

View File

@ -517,6 +517,8 @@ public class ProductManagementBaseInput
/// </summary>
public string? fld004699 { get; set; }
public long idRecord { get; set; }
public string? fld005288 { get; set; }
}
/// <summary>

View File

@ -253,5 +253,6 @@ public class ProductManagementOutput
public string? fld004944_Rec { get; set; }
public DateTime? fld004945 { get; set; }
public string? fld005288 { get; set; }
}

View File

@ -11,6 +11,8 @@ using Admin.NET.Core.Service;
using Vistar.Application.Util;
using Vistar.Application.SapService.Dto;
using Vistar.Application.Common;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using static Elastic.Clients.Elasticsearch.JoinField;
namespace Vistar.Application.Service.MaterialManagement;
@ -27,6 +29,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
public SapService.SapService _sapService;
public SqlSugarRepository<Obj118> _obj118Rep;
public Common.DataValidationService _dataValidationService;
public SqlSugarRepository<Obj122> _obj122Rep;
public SqlSugarRepository<Obj121> _obj121Rep;
public ProductManagementService(
SqlSugarRepository<Obj110> obj110Rep,
@ -35,7 +39,9 @@ public class ProductManagementService : IDynamicApiController, ITransient
SqlSugarRepository<ConfigurationData> configurationDataRep,
SapService.SapService sapService,
SqlSugarRepository<Obj118> obj118Rep,
DataValidationService dataValidationService
DataValidationService dataValidationService,
SqlSugarRepository<Obj122> obj122Rep,
SqlSugarRepository<Obj121> obj121Rep
)
{
@ -46,6 +52,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
_sapService = sapService;
_obj118Rep = obj118Rep;
_dataValidationService = dataValidationService;
_obj122Rep= obj122Rep;
_obj121Rep= obj121Rep;
}
/// <summary>
/// 分页查询产品管理
@ -208,10 +216,10 @@ public class ProductManagementService : IDynamicApiController, ITransient
{
continue;
}
int sun = i + 1;
//int sun = i + 1;
var itemData = new ItemData()
{
POSNR = sun.ToString(),//组件序号
POSNR = "",//组件序号 sun.ToString()
IDNRK = input[i].PartNumber,//组件物料号
MENGE = input[i].Quantity.ToString(),//组件数量
SORTF = input[i].fld004936,
@ -225,6 +233,39 @@ public class ProductManagementService : IDynamicApiController, ITransient
itemDataList.Add(itemData);
}
if (!string.IsNullOrEmpty(ParentData.fld005288)) {
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync();
var BomData = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input[0].ParentGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(ParentData.fld005288)).ToListAsync();
for (int i = 0; i < BomData.Count; i++)
{
var itemList= itemDataList.Where(x=>x.IDNRK == BomData[i].PartNumber).ToList();
if (itemList.Count == 0) {
var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid);
if (Verification == "不存在")
{
continue;
}
//int sun = i + 1;
var itemData = new ItemData()
{
POSNR = "",//组件序号 sun.ToString()
IDNRK = BomData[i].PartNumber,//组件物料号
MENGE = BomData[i].Quantity.ToString(),//组件数量
SORTF = BomData[i].fld004936,
ITISOB = BomData[i].fld004937,
ALPGR = BomData[i].fld004938,
ALPRF = BomData[i].fld004939,
ZDELETE = "X",
POSTP = BomData[i].fld004492,
ZYFMK = BomData[i].fld004941
};
itemDataList.Add(itemData);
}
}
}
//获取时间戳精确到毫秒sap要求每次调用生成不重复guid
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
@ -255,7 +296,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
fld004631 = DateTime.Now,
fld004315 = codeVal,
fld004316 = "N",
fld004317 = apiOutput.msg
fld004317 = apiOutput.msg,
fld005288= input[0].ParentVersion.ToString()////////////////////////////////////////////////////////////xinixnixn
})
.Where(it => it.idRecord == ParentData.idRecord)
.ExecuteCommandAsync();
@ -614,4 +656,117 @@ public class ProductManagementService : IDynamicApiController, ITransient
return sapOutputList;
}
/// <summary>
/// 产品管理-获取工艺路线
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "GetProcessRoute", Description = "获取工艺路线", Order = 1000), HttpPost]
[DisplayName("获取工艺路线")]
public async Task<SqlSugarPagedList<ProductManagementBomOutput>> GetProcessRoute(BomPageProductManagementInput input)
{
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "pBOM").FirstAsync();
var parent = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false).MaxAsync(x => x.VersionIndex);
var BomData = await _configurationDataRep.AsQueryable()
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent)
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
.Select<ProductManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
return BomData;
}
/// <summary>
/// 产品管理-工艺路线同步到SAP
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "SyncToSAPProcessRoute"), HttpPost]
[DisplayName("产品管理-工艺路线同步到SAP")]
public async Task<SapOutput> SyncToSAPProcessRoute(List<BomPageProductManagementInput> input)
{
var ParentData = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input[0].ParentGuid && x.deleted == false && x.VersionIndex == input[0].ParentVersion).FirstAsync();
var itemDataList = new List<SapProcessRouteItemData>();
for (int i = 0; i < input.Count; i++)
{
var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
if (Verification == "不存在")
{
continue;
}
//获取工序描述
var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == input[i].ChildGuid).ToListAsync();
//获取工作中心
var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync();
//int sun = i + 1;
var itemData = new SapProcessRouteItemData()
{
VORNR = input[i].Marker,
LTXA1 = procedureDescription[0]._System_ObjDescription,
ARBPL = workCenter[0]._System_objNBS,
VGW01 = input[i].fld004994.ToString(),
VGE01 = input[i].fld004995,
STEUS = input[i].fld004996,
BMSCH = input[i].fld005296.ToString()
};
itemDataList.Add(itemData);
}
//获取时间戳精确到毫秒sap要求每次调用生成不重复guid
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
var Datuv = ParentData.fld004945.ToString();
if (!string.IsNullOrEmpty(Datuv))
{
Datuv = ParentData.fld004945.ToDateTime().ToString("yyyy-MM-dd");
}
var isreq = new SapProcessRouteIS_REQ()
{
ReqKeyId = "",
BusinessId = "",
MessageId = "",
SndPrn = "PLM",
RcvPrn = "SAP",
ReqUser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
Note1 = "",
Note2 = "",
Note3 = "",
Zwbid = millisecondTimestamp,
Matnr = ParentData._System_objNBS,
Werks = ParentData.fld004325,
Datuv = Datuv,
Plnal = "",
ItemList = itemDataList
};
var apiOutput = await _sapService.SapProcessRouteApi(isreq);
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
await _obj110Rep.AsUpdateable()
.SetColumns(it => new Obj110
{
fld004632 = DateTime.Now,
fld004319 = codeVal,
fld004320 = "N",
fld004321 = apiOutput.msg
})
.Where(it => it.idRecord == ParentData.idRecord)
.ExecuteCommandAsync();
var msg = apiOutput.msg;
if (apiOutput.msg == "")
{
msg = "同步成功";
}
var output = new SapOutput()
{
parameter = apiOutput.parameter,
code = codeVal,
msg = msg,
result = apiOutput.result
};
return output;
}
}

View File

@ -14,6 +14,7 @@ using Vistar.Application.Common;
using Vistar.Application.Const;
using Vistar.Application.Entity;
using Vistar.Application.SapService.Dto;
using Vistar.Application.Service.MaterialManagement.Dto;
using Vistar.Application.Service.ProjectManagement.Dto;
using Vistar.Application.Util;
@ -31,6 +32,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
public SqlSugarRepository<Obj118> _obj118Rep;
public Common.DataValidationService _dataValidationService;
public SqlSugarRepository<Obj122> _obj122Rep;
public SqlSugarRepository<Obj121> _obj121Rep;
public ProjectManagementService(
SqlSugarRepository<Obj109> obj109Rep,
@ -39,7 +42,9 @@ public class ProjectManagementService : IDynamicApiController, ITransient
SqlSugarRepository<Configurations> configurationsRep,
SqlSugarRepository<ConfigurationData> configurationDataRep,
SqlSugarRepository<Obj118> obj118Rep,
DataValidationService dataValidationService
DataValidationService dataValidationService,
SqlSugarRepository<Obj122> obj122Rep,
SqlSugarRepository<Obj121> obj121Rep
)
{
_obj109Rep = obj109Rep;
@ -49,6 +54,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
_configurationDataRep = configurationDataRep;
_obj118Rep = obj118Rep;
_dataValidationService = dataValidationService;
_obj122Rep = obj122Rep;
_obj121Rep = obj121Rep;
}
/// <summary>
/// 分页查询项目管理
@ -516,7 +523,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
var sapOutputList = new List<SapOutput>();
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
// 配置
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync();
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "mBOM").FirstAsync();
var materialData = await _obj109Rep.AsQueryable()
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布" && x.fld004511 == "成功" && (x.fld004514 == "A" || x.fld004514 == "M"))
@ -621,4 +628,116 @@ public class ProjectManagementService : IDynamicApiController, ITransient
return sapOutputList;
}
/// <summary>
/// 项目管理-获取工艺路线
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "GetProcessRoute", Description = "获取工艺路线", Order = 1000), HttpPost]
[DisplayName("获取工艺路线")]
public async Task<SqlSugarPagedList<ProductManagementBomOutput>> GetProcessRoute(BomPageProductManagementInput input)
{
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "pBOM").FirstAsync();
var parent = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false).MaxAsync(x => x.VersionIndex);
var BomData = await _configurationDataRep.AsQueryable()
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent)
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
.Select<ProductManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
return BomData;
}
/// <summary>
/// 项目管理-工艺路线同步到SAP
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "SyncToSAPProcessRoute"), HttpPost]
[DisplayName("项目管理-工艺路线同步到SAP")]
public async Task<SapOutput> SyncToSAPProcessRoute(List<BomPageProductManagementInput> input)
{
var ParentData = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input[0].ParentGuid && x.deleted == false && x.VersionIndex == input[0].ParentVersion).FirstAsync();
var itemDataList = new List<SapProcessRouteItemData>();
for (int i = 0; i < input.Count; i++)
{
var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
if (Verification == "不存在")
{
continue;
}
//获取工序描述
var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == input[i].ChildGuid).ToListAsync();
//获取工作中心
var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync();
//int sun = i + 1;
var itemData = new SapProcessRouteItemData()
{
VORNR = input[i].Marker,
LTXA1 = procedureDescription[0]._System_ObjDescription,
ARBPL = workCenter[0]._System_objNBS,
VGW01 = input[i].fld004994.ToString(),
VGE01 = input[i].fld004995,
STEUS = input[i].fld004996,
BMSCH = input[i].fld005298.ToString()
};
itemDataList.Add(itemData);
}
//获取时间戳精确到毫秒sap要求每次调用生成不重复guid
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
var Datuv = ParentData.fld004949.ToString();
if (!string.IsNullOrEmpty(Datuv))
{
Datuv = ParentData.fld004949.ToDateTime().ToString("yyyy-MM-dd");
}
var isreq = new SapProcessRouteIS_REQ()
{
ReqKeyId = "",
BusinessId = "",
MessageId = "",
SndPrn = "PLM",
RcvPrn = "SAP",
ReqUser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
Note1 = "",
Note2 = "",
Note3 = "",
Zwbid = millisecondTimestamp,
Matnr = ParentData._System_objNBS,
Werks = ParentData.fld004522,
Datuv = Datuv,
Plnal = "",
ItemList = itemDataList
};
var apiOutput = await _sapService.SapProcessRouteApi(isreq);
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004518 = DateTime.Now,
fld004515 = codeVal,
fld004517 = "N",
fld004516 = apiOutput.msg
})
.Where(it => it.idRecord == ParentData.idRecord)
.ExecuteCommandAsync();
var msg = apiOutput.msg;
if (apiOutput.msg == "")
{
msg = "同步成功";
}
var output = new SapOutput()
{
parameter = apiOutput.parameter,
code = codeVal,
msg = msg,
result = apiOutput.result
};
return output;
}
}

View File

@ -4,7 +4,10 @@ enum Api {
SyncToSAPProductManagement = '/api/productManagement/SyncToSAP',
GetetBOMProductManagement = '/api/productManagement/getBOM',
SyncToSAPBomProductManagement = '/api/productManagement/syncToSAPBom',
BatchSyncToSAPProductManagement = '/api/productManagement/batchSyncToSAP'
BatchSyncToSAPProductManagement = '/api/productManagement/batchSyncToSAP',
GetetProcessRouteProductManagement = '/api/productManagement/getProcessRoute',
SyncToSAPProcessRouteProductManagement = '/api/productManagement/syncToSAPProcessRoute'
}
// 分页查询产品管理
@ -44,3 +47,18 @@ export const BatchSyncToSAPProductManagement = (params?: any) =>
method: 'post',
data: params,
});
// 分页查询产品管理工艺路线
export const GetetProcessRouteProductManagement = (params?: any) =>
request({
url: Api.GetetProcessRouteProductManagement,
method: 'post',
data: params,
});
// 工艺路线同步到sap
export const SyncToSAPProcessRouteProductManagement = (params?: any) =>
request({
url: Api.SyncToSAPProcessRouteProductManagement,
method: 'post',
data: params,
});

View File

@ -4,7 +4,9 @@ enum Api {
SyncToSAPProjectManagement = '/api/projectManagement/SyncToSAP',
GetBOMProjectManagement = '/api/projectManagement/getBOM',
SyncToSAPBomProjectManagement = '/api/projectManagement/syncToSAPBom',
BatchSyncToSAPProjectManagement = '/api/projectManagement/batchSyncToSAP'
BatchSyncToSAPProjectManagement = '/api/projectManagement/batchSyncToSAP',
GetetProcessRouteProjectManagement = '/api/ProjectManagement/getProcessRoute',
SyncToSAPProcessRouteProjectManagement = '/api/ProjectManagement/syncToSAPProcessRoute'
}
// 分页查询产品管理
@ -44,3 +46,18 @@ export const BatchSyncToSAPProjectManagement = (params?: any) =>
method: 'post',
data: params,
});
// 分页查询工艺路线
export const GetetProcessRouteProjectManagement = (params?: any) =>
request({
url: Api.GetetProcessRouteProjectManagement,
method: 'post',
data: params,
});
// 工艺路线同步到sap
export const SyncToSAPProcessRouteProjectManagement = (params?: any) =>
request({
url: Api.SyncToSAPProcessRouteProjectManagement,
method: 'post',
data: params,
});

View File

@ -53,8 +53,8 @@
同步BOM </el-button>
</el-tooltip>
<el-tooltip content="工艺路线" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click=""
v-if="row.fld004320 != 'N'">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click="examineProcessRoute(row)"
v-if="(row.fld004320=='A'||row.fld004320=='M')&&row.fld004311=='成功'">
工艺路线 </el-button>
</el-tooltip>
@ -87,6 +87,25 @@
</el-drawer>
<el-drawer v-model="showProcessRoute" title="工艺路线" :direction="'rtl'" :visible.sync="false" size="50%">
<!-- 这里可以放置 BOM 的具体内容 -->
<el-card class="full-table" shadow="hover" style="margin-top: 5px;height: 100%;">
<el-form :model="stateProcessRoute.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true"
label-width="auto" style="flex: 1 1 0%" @submit.prevent="handleQueryProcessRoute">
<el-input v-model="stateProcessRoute.queryParams.ParentGuid" placeholder="父GUID" @click="handleQueryProcessRoute" />
</el-form>
<vxe-grid ref="processRoutexGrid" v-bind="processRouteOptions" v-on="gridEvents">
<template #toolbar_tools>
<el-button style="position: absolute; left: 0" icon="ele-Promotion" size="small" text=""
type="success" @click="syncToSAPprocessRoute" v-auth="'productManagement/syncToSAPProcessRoute'"> 工艺路线同步到SAP
</el-button>
</template>
</vxe-grid>
</el-card>
</el-drawer>
</div>
</template>
@ -100,7 +119,7 @@ import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import { formatDate } from '/@/utils/formatTime';
import { PageProductManagement, SyncToSAPProductManagement, GetetBOMProductManagement, SyncToSAPBomProductManagement, BatchSyncToSAPProductManagement } from '/@/api/materialManagement/productManagement';
import { PageProductManagement, SyncToSAPProductManagement, GetetBOMProductManagement, SyncToSAPBomProductManagement, BatchSyncToSAPProductManagement,GetetProcessRouteProductManagement,SyncToSAPProcessRouteProductManagement } from '/@/api/materialManagement/productManagement';
import { disable } from 'ol/rotationconstraint';
//
@ -266,6 +285,8 @@ const examineBom = async (row: any) => {
const showBom = ref(false);
//
const stateBom = reactive({
showAdvanceQueryUI: false,
@ -379,6 +400,101 @@ const batchSyncToSAP = async () => {
.catch(() => { });
options.loading = false;
}
// 线
//Guid
const processRoutexGrid = ref<VxeGridInstance>();
// BOM
const examineProcessRoute = async (row: any) => {
stateProcessRoute.queryParams.ParentGuid = row.recordGuid;
showProcessRoute.value = true;
await handleQueryProcessRoute();
};
const showProcessRoute = ref(false);
//
const stateProcessRoute = reactive({
showAdvanceQueryUI: false,
queryParams: {
PartNumber: undefined,
Description: undefined,
ParentGuid: undefined
},
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'createTime', order: 'asc', descStr: 'desc' },
},
visible: false,
title: '',
});
//
const localPageParamKeyProcessRoute = 'localPageParam:productManagementProcessRoute';
//
const processRouteOptions = useVxeTable(
{
id: 'productManagementProcessRoute',
name: '产品管理',
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'partNumber', title: '物料编码', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'description', title: '物料描述', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'quantity', title: '数量', minWidth: 100, showOverflow: 'tooltip', sortable: false },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleProcessRouteQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKeyProcessRoute)?.defaultSort || stateBom.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKeyProcessRoute)?.pageSize || stateBom.localPageParam.pageSize },
//
toolbarConfig: { export: false },
//
// rowConfig: { height: 80 },
}
);
// 线 API
const handleProcessRouteQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(stateProcessRoute.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' });
var data = GetetProcessRouteProductManagement(params);
return data;
};
const handleQueryProcessRoute = async (reset = false) => {
processRouteOptions.loading = true;
await processRoutexGrid.value?.commitProxy('query');
processRouteOptions.loading = false;
};
//线sap
const syncToSAPprocessRoute = async () => {
options.loading = true;
var data = processRoutexGrid.value?.getTableData().fullData;
ElMessageBox.confirm(`确定要同步工艺路线吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
var output = await SyncToSAPProcessRouteProductManagement(data);
await handleQuery();
if (output.data.result.code == "成功") {
ElMessage.success("同步成功");
} else {
ElMessage.error("同步失败");
}
})
.catch(() => { });
options.loading = false;
}
</script>
<style lang="scss" scoped>

View File

@ -46,8 +46,8 @@
同步BOM </el-button>
</el-tooltip>
<el-tooltip content="工艺路线" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click=""
v-if="row.fld004320 != 'N'">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click="examineProcessRoute(row)"
v-if="(row.fld004517=='A'||row.fld004517=='M')&&row.fld004509=='成功'">
工艺路线 </el-button>
</el-tooltip>
@ -78,6 +78,24 @@
</el-card>
</el-drawer>
<el-drawer v-model="showProcessRoute" title="工艺路线" :direction="'rtl'" :visible.sync="false" size="50%">
<!-- 这里可以放置 BOM 的具体内容 -->
<el-card class="full-table" shadow="hover" style="margin-top: 5px;height: 100%;">
<el-form :model="stateProcessRoute.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true"
label-width="auto" style="flex: 1 1 0%" @submit.prevent="handleQueryProcessRoute">
<el-input v-model="stateProcessRoute.queryParams.ParentGuid" placeholder="父GUID" @click="handleQueryProcessRoute" />
</el-form>
<vxe-grid ref="processRoutexGrid" v-bind="processRouteOptions" v-on="gridEvents">
<template #toolbar_tools>
<el-button style="position: absolute; left: 0" icon="ele-Promotion" size="small" text=""
type="success" @click="syncToSAPprocessRoute" v-auth="'projectManagement/syncToSAPProcessRoute'"> 工艺路线同步到SAP
</el-button>
</template>
</vxe-grid>
</el-card>
</el-drawer>
</div>
</template>
<script lang="ts" setup name="projectManagement">
@ -90,7 +108,7 @@ import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import { formatDate } from '/@/utils/formatTime';
import { PageProjectManagement, SyncToSAPProjectManagement, GetBOMProjectManagement, BatchSyncToSAPProjectManagement, SyncToSAPBomProjectManagement } from '/@/api/materialManagement/projectManagement';
import { PageProjectManagement, SyncToSAPProjectManagement, GetBOMProjectManagement, BatchSyncToSAPProjectManagement, SyncToSAPBomProjectManagement ,GetetProcessRouteProjectManagement,SyncToSAPProcessRouteProjectManagement} from '/@/api/materialManagement/projectManagement';
import { disable } from 'ol/rotationconstraint';
//
@ -147,7 +165,7 @@ const localPageParamKey = 'localPageParam:projectManagement';
const options = useVxeTable(
{
id: 'projectManagement',
name: '产品管理',
name: '项目管理',
columns: [
{ type: 'checkbox', title: '', width: 60},
{ type: 'seq', title: '序号', width: 60 },
@ -284,13 +302,13 @@ const getBOM = async (row: any) => {
};
//
const localPageParamKeyBom = 'localPageParam:productManagementBom';
const localPageParamKeyBom = 'localPageParam:projectManagementBom';
//
const bomOptions = useVxeTable(
{
id: 'productManagementBom',
name: '产品管理',
id: 'projectManagementBom',
name: '项目管理',
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'partNumber', title: '物料编码', minWidth: 100, showOverflow: 'tooltip', sortable: false },
@ -350,4 +368,98 @@ const syncToSAPBom = async () => {
options.loading = false;
}
// 线
//Guid
const processRoutexGrid = ref<VxeGridInstance>();
// BOM
const examineProcessRoute = async (row: any) => {
stateProcessRoute.queryParams.ParentGuid = row.recordGuid;
showProcessRoute.value = true;
await handleQueryProcessRoute();
};
const showProcessRoute = ref(false);
//
const stateProcessRoute = reactive({
showAdvanceQueryUI: false,
queryParams: {
PartNumber: undefined,
Description: undefined,
ParentGuid: undefined
},
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'createTime', order: 'asc', descStr: 'desc' },
},
visible: false,
title: '',
});
//
const localPageParamKeyProcessRoute = 'localPageParam:projectManagementProcessRoute';
//
const processRouteOptions = useVxeTable(
{
id: 'projectManagementProcessRoute',
name: '项目管理',
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'partNumber', title: '物料编码', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'description', title: '物料描述', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'quantity', title: '数量', minWidth: 100, showOverflow: 'tooltip', sortable: false },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleProcessRouteQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKeyProcessRoute)?.defaultSort || stateBom.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKeyProcessRoute)?.pageSize || stateBom.localPageParam.pageSize },
//
toolbarConfig: { export: false },
//
// rowConfig: { height: 80 },
}
);
// 线 API
const handleProcessRouteQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(stateProcessRoute.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' });
var data = GetetProcessRouteProjectManagement(params);
return data;
};
const handleQueryProcessRoute = async (reset = false) => {
processRouteOptions.loading = true;
await processRoutexGrid.value?.commitProxy('query');
processRouteOptions.loading = false;
};
//线sap
const syncToSAPprocessRoute = async () => {
options.loading = true;
var data = processRoutexGrid.value?.getTableData().fullData;
ElMessageBox.confirm(`确定要同步工艺路线吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
var output = await SyncToSAPProcessRouteProjectManagement(data);
await handleQuery();
if (output.data.result.code == "成功") {
ElMessage.success("同步成功");
} else {
ElMessage.error("同步失败");
}
})
.catch(() => { });
options.loading = false;
}
</script>