Compare commits
No commits in common. "b2e89ddbd9d39677875a6171e29a41f484f16c37" and "f081772d4008f686606c6dcc2f23605574bf52fe" have entirely different histories.
b2e89ddbd9
...
f081772d40
@ -7,7 +7,6 @@
|
|||||||
using Admin.NET.Core;
|
using Admin.NET.Core;
|
||||||
using Admin.NET.Core.Service;
|
using Admin.NET.Core.Service;
|
||||||
using DocumentFormat.OpenXml.Bibliography;
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
using DocumentFormat.OpenXml.Drawing;
|
|
||||||
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||||
using Furion.DependencyInjection;
|
using Furion.DependencyInjection;
|
||||||
using Furion.DynamicApiController;
|
using Furion.DynamicApiController;
|
||||||
@ -28,7 +27,6 @@ using Vistar.Application.Entity;
|
|||||||
using Vistar.Application.SapService.Dto;
|
using Vistar.Application.SapService.Dto;
|
||||||
using Vistar.Application.Util;
|
using Vistar.Application.Util;
|
||||||
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinAccountGetAccountBasicInfoResponse.Types;
|
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinAccountGetAccountBasicInfoResponse.Types;
|
||||||
using static SKIT.FlurlHttpClient.Wechat.Api.Models.ScanProductAddV2Request.Types.Product.Types;
|
|
||||||
|
|
||||||
namespace Vistar.Application.Common;
|
namespace Vistar.Application.Common;
|
||||||
public class DataValidationService : IDynamicApiController, ITransient
|
public class DataValidationService : IDynamicApiController, ITransient
|
||||||
@ -397,17 +395,14 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<string> ModifyInventoryInformation(string recordGuid, string code, long objectid, string Bdmng, string Labst, string ZwqslPo, string ZwqslPr, DateTime dateUpdated)
|
public async Task<string> ModifyInventoryInformation(string recordGuid, string code, long objectid, string Bdmng, string Labst, string ZwqslPo, string ZwqslPr, DateTime dateUpdated)
|
||||||
{
|
{
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
|
||||||
if (code == "S")
|
if (code == "S")
|
||||||
{
|
{
|
||||||
if (objectid == 137)
|
if (objectid == 137)
|
||||||
{
|
{
|
||||||
var data = await db.CopyNew().Queryable<Obj137>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
var data = _obj137Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.idRecord).First();
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
db.CopyNew().Updateable<Obj137>()
|
await _obj137Rep.AsUpdateable().SetColumns(it => new Obj137
|
||||||
.SetColumns(it => new Obj137
|
|
||||||
{
|
{
|
||||||
fld006530 = Bdmng,
|
fld006530 = Bdmng,
|
||||||
fld005623 = Labst,
|
fld005623 = Labst,
|
||||||
@ -416,16 +411,16 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
fld005624 = dateUpdated
|
fld005624 = dateUpdated
|
||||||
})
|
})
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
.Where(it => it.idRecord == data.idRecord)
|
||||||
.ExecuteCommand();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectid == 112)
|
if (objectid == 112)
|
||||||
{
|
{
|
||||||
var data = await db.CopyNew().Queryable<Obj112>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).FirstAsync();
|
var data = _obj112Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).First();
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
db.CopyNew().Updateable<Obj112>().SetColumns(it => new Obj112
|
await _obj112Rep.AsUpdateable().SetColumns(it => new Obj112
|
||||||
{
|
{
|
||||||
fld006750 = Bdmng,
|
fld006750 = Bdmng,
|
||||||
fld006751 = Labst,
|
fld006751 = Labst,
|
||||||
@ -434,7 +429,7 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
fld006755 = dateUpdated
|
fld006755 = dateUpdated
|
||||||
})
|
})
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
.Where(it => it.idRecord == data.idRecord)
|
||||||
.ExecuteCommand();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -442,10 +437,10 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
if (objectid == 137)
|
if (objectid == 137)
|
||||||
{
|
{
|
||||||
var data = await db.CopyNew().Queryable<Obj137>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
var data = await _obj137Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
db.CopyNew().Updateable<Obj137>().SetColumns(it => new Obj137
|
await _obj137Rep.AsUpdateable().SetColumns(it => new Obj137
|
||||||
{
|
{
|
||||||
fld006530 = "",
|
fld006530 = "",
|
||||||
fld005623 = "",
|
fld005623 = "",
|
||||||
@ -454,17 +449,16 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
fld005624 = dateUpdated
|
fld005624 = dateUpdated
|
||||||
})
|
})
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
.Where(it => it.idRecord == data.idRecord)
|
||||||
.ExecuteCommand();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectid == 112)
|
if (objectid == 112)
|
||||||
{
|
{
|
||||||
var data = await db.CopyNew().Queryable<Obj112>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).FirstAsync();
|
var data = await _obj112Rep.AsQueryable().Where(x => x.RecordGuid == recordGuid && x.deleted == false).FirstAsync();
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
db.CopyNew().Updateable<Obj112>()
|
await _obj112Rep.AsUpdateable().SetColumns(it => new Obj112
|
||||||
.SetColumns(it => new Obj112
|
|
||||||
{
|
{
|
||||||
fld006750 = "",
|
fld006750 = "",
|
||||||
fld006751 = "",
|
fld006751 = "",
|
||||||
@ -473,95 +467,13 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
fld006755 = dateUpdated
|
fld006755 = dateUpdated
|
||||||
})
|
})
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
.Where(it => it.idRecord == data.idRecord)
|
||||||
.ExecuteCommand();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "修改成功";
|
return "修改成功";
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 修改价格信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="recordGuid"></param>
|
|
||||||
/// <param name="code"></param>
|
|
||||||
/// <param name="objectid"></param>
|
|
||||||
/// <param name="Verpr"></param>
|
|
||||||
/// <param name="dateUpdated"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<string> ModifyPriceInformation(string recordGuid, string code, long objectid, string Verpr, DateTime dateUpdated)
|
|
||||||
{
|
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
|
||||||
if (code == "S")
|
|
||||||
{
|
|
||||||
if (objectid == 137)
|
|
||||||
{
|
|
||||||
var data = await db.CopyNew().Queryable<Obj137>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
db.CopyNew().Updateable<Obj137>()
|
|
||||||
.SetColumns(it => new Obj137
|
|
||||||
{
|
|
||||||
fld005625 = Verpr,
|
|
||||||
fld005626 = dateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
|
||||||
.ExecuteCommand();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objectid == 112)
|
|
||||||
{
|
|
||||||
var data = await db.CopyNew().Queryable<Obj112>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).FirstAsync();
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
db.CopyNew().Updateable<Obj112>().SetColumns(it => new Obj112
|
|
||||||
{
|
|
||||||
fld006754 = Verpr,
|
|
||||||
fld006756 = dateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
|
||||||
.ExecuteCommand();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (objectid == 137)
|
|
||||||
{
|
|
||||||
var data = await db.CopyNew().Queryable<Obj137>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
db.CopyNew().Updateable<Obj137>().SetColumns(it => new Obj137
|
|
||||||
{
|
|
||||||
fld005625 = "",
|
|
||||||
fld005626 = dateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
|
||||||
.ExecuteCommand();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objectid == 112)
|
|
||||||
{
|
|
||||||
var data = await db.CopyNew().Queryable<Obj112>().Where(x => x.RecordGuid == recordGuid && x.deleted == false).FirstAsync();
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
db.CopyNew().Updateable<Obj112>()
|
|
||||||
.SetColumns(it => new Obj112
|
|
||||||
{
|
|
||||||
fld006754 = "",
|
|
||||||
fld006756 = dateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
|
||||||
.ExecuteCommand();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "修改成功";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -599,42 +511,6 @@ public class DataValidationService : IDynamicApiController, ITransient
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<decimal> ProcessNumber(decimal number)
|
|
||||||
{
|
|
||||||
if (number < 1)
|
|
||||||
{
|
|
||||||
string numStr = number.ToString();
|
|
||||||
int decimalIndex = numStr.IndexOf('.');
|
|
||||||
string decimalPart = numStr.Substring(decimalIndex + 1);
|
|
||||||
// 去除小数部分末尾的 0
|
|
||||||
decimalPart = decimalPart.TrimEnd('0');
|
|
||||||
if (decimalPart.Length == 1)
|
|
||||||
{
|
|
||||||
return number;
|
|
||||||
}
|
|
||||||
int firstNonZeroIndex = 0;
|
|
||||||
while (firstNonZeroIndex < decimalPart.Length && decimalPart[firstNonZeroIndex] == '0')
|
|
||||||
{
|
|
||||||
firstNonZeroIndex++;
|
|
||||||
}
|
|
||||||
if (firstNonZeroIndex == decimalPart.Length - 1)
|
|
||||||
{
|
|
||||||
// 若只有一位非零数字,找到合适的进位位置
|
|
||||||
string newDecimalPart = new string('0', firstNonZeroIndex - 1) + "1";
|
|
||||||
return decimal.Parse("0." + newDecimalPart);
|
|
||||||
}
|
|
||||||
return Math.Round(number, decimalPart.Length - firstNonZeroIndex - 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (number < 10000)
|
|
||||||
{
|
|
||||||
int power = (int)Math.Floor(Math.Log10((double)number));
|
|
||||||
return (decimal)(Math.Floor((double)number / Math.Pow(10, power)) * Math.Pow(10, power));
|
|
||||||
}
|
|
||||||
return (decimal)(Math.Floor((double)number / 1000) * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 验证是否存在bom和工艺路线
|
///// 验证是否存在bom和工艺路线
|
||||||
|
@ -553,9 +553,4 @@ public class Obj112
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime fld006755 { get; set; }
|
public DateTime fld006755 { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 成本更新日期
|
|
||||||
/// </summary>
|
|
||||||
public DateTime fld006756 { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1407,9 +1407,4 @@ public class Obj137
|
|||||||
/// 库存更新日期
|
/// 库存更新日期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime fld005624 { get; set; }
|
public DateTime fld005624 { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 成本更新日期
|
|
||||||
/// </summary>
|
|
||||||
public DateTime fld005626 { get; set; }
|
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ public class PurchasingRequisitionToSap : IJob
|
|||||||
var sapOutputs = await _purchasingRequisition.TimingSyncToSAPPurchasingRequisition();
|
var sapOutputs = await _purchasingRequisition.TimingSyncToSAPPurchasingRequisition();
|
||||||
var json = JsonConvert.SerializeObject(sapOutputs);
|
var json = JsonConvert.SerializeObject(sapOutputs);
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
using var serviceScope = _scopeFactory.CreateScope();
|
||||||
|
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||||
var dbMain = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("1300000000001").CopyNew();
|
var dbMain = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("1300000000001").CopyNew();
|
||||||
string output = json;
|
string output = json;
|
||||||
var elapsedMilliseconds = (DateTime.Now - startTime).TotalMilliseconds;
|
var elapsedMilliseconds = (DateTime.Now - startTime).TotalMilliseconds;
|
||||||
|
@ -120,8 +120,4 @@ public class ItemData
|
|||||||
/// 研发模块
|
/// 研发模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ZYFMK { get; set; }
|
public string ZYFMK { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 子件guid
|
|
||||||
/// </summary>
|
|
||||||
public string? ChildGuid { get; set; }
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
|
||||||
//
|
|
||||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
|
||||||
//
|
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Vistar.Application.SapService.Dto;
|
|
||||||
public class SapPriceQueryInput: SapEcnQueryInput
|
|
||||||
{
|
|
||||||
}
|
|
@ -11,7 +11,6 @@ using DocumentFormat.OpenXml.Spreadsheet;
|
|||||||
using Furion.DependencyInjection;
|
using Furion.DependencyInjection;
|
||||||
using Furion.DynamicApiController;
|
using Furion.DynamicApiController;
|
||||||
using MailKit;
|
using MailKit;
|
||||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
|
||||||
using OnceMi.AspNetCore.OSS;
|
using OnceMi.AspNetCore.OSS;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -1219,128 +1218,4 @@ public class SapService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SAP 成本查询服务
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<SapPriceQueryOutput> SapPriceQueryApi(SapPriceQueryInput input)
|
|
||||||
{
|
|
||||||
// 创建命名空间
|
|
||||||
XNamespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
|
|
||||||
XNamespace urn = "urn:sap-com:document:sap:rfc:functions";
|
|
||||||
// 创建 SOAP XML 请求
|
|
||||||
var soapEnvelope = new XDocument(
|
|
||||||
new XDeclaration("1.0", "utf-8", "yes"),
|
|
||||||
new XElement(soapenv + "Envelope",
|
|
||||||
new XAttribute(XNamespace.Xmlns + "soapenv", soapenv.NamespaceName),
|
|
||||||
new XAttribute(XNamespace.Xmlns + "urn", urn.NamespaceName),
|
|
||||||
new XElement(soapenv + "Header"),
|
|
||||||
new XElement(soapenv + "Body",
|
|
||||||
new XElement(urn + "ZFIFM006",
|
|
||||||
new XElement("IS_DATA",
|
|
||||||
new XElement("IT_MATNR",
|
|
||||||
new XElement("item",
|
|
||||||
new XElement("SIGN", input.Sign),
|
|
||||||
new XElement("OPTION", input.Option),
|
|
||||||
new XElement("LOW", input.Low),
|
|
||||||
new XElement("HIGH", input.High)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
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)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
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");
|
|
||||||
httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh");
|
|
||||||
// 设置 SAP Web 服务的 URL
|
|
||||||
//sap正式地址
|
|
||||||
var url = "https://vhjqeps4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/ZFIFM006/800/ZFIFM006/ZFIFM006";
|
|
||||||
|
|
||||||
//sap测试地址
|
|
||||||
//var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/ZFIFM006/130/ZFIFM006/ZFIFM006";
|
|
||||||
|
|
||||||
// 发起 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 esRet = doc.Descendants("ES_RET").FirstOrDefault();
|
|
||||||
var code = esRet?.Element("CODE")?.Value;
|
|
||||||
|
|
||||||
var item = doc.Descendants("item").FirstOrDefault();
|
|
||||||
var bwkey = item?.Element("BWKEY")?.Value;
|
|
||||||
var matnr = item?.Element("MATNR")?.Value;
|
|
||||||
var verpr = item?.Element("VERPR")?.Value;
|
|
||||||
|
|
||||||
|
|
||||||
var output = new SapPriceQueryOutput()
|
|
||||||
{
|
|
||||||
Parameter = soapEnvelope.ToString(),
|
|
||||||
Code = code,
|
|
||||||
Matnr = matnr,
|
|
||||||
Bwkey = bwkey,
|
|
||||||
Verpr = verpr,
|
|
||||||
Result = result
|
|
||||||
};
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var result = await response.Content.ReadAsStringAsync();
|
|
||||||
var output = new SapPriceQueryOutput()
|
|
||||||
{
|
|
||||||
Parameter = soapEnvelope.ToString(),
|
|
||||||
Code = "失败",
|
|
||||||
Result = result
|
|
||||||
};
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
// 记录错误日志
|
|
||||||
Console.WriteLine("发生错误: " + ex.Message);
|
|
||||||
var output = new SapPriceQueryOutput()
|
|
||||||
{
|
|
||||||
Code = "失败",
|
|
||||||
Result = "发生错误" + ex
|
|
||||||
};
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -16,7 +16,6 @@ using static Elastic.Clients.Elasticsearch.JoinField;
|
|||||||
using Qiniu.CDN;
|
using Qiniu.CDN;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace Vistar.Application.Service.MaterialManagement;
|
namespace Vistar.Application.Service.MaterialManagement;
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ namespace Vistar.Application.Service.MaterialManagement;
|
|||||||
public class ProductManagementService : IDynamicApiController, ITransient
|
public class ProductManagementService : IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
private readonly SqlSugarRepository<Obj110> _obj110Rep;
|
private readonly SqlSugarRepository<Obj110> _obj110Rep;
|
||||||
private readonly SqlSugarRepository<Obj137> _obj137Rep;
|
|
||||||
private readonly SqlSugarRepository<Configurations> _configurationsRep;
|
private readonly SqlSugarRepository<Configurations> _configurationsRep;
|
||||||
private readonly SysConfigService _sysConfigService;
|
private readonly SysConfigService _sysConfigService;
|
||||||
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
|
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
|
||||||
@ -40,7 +38,6 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
public ProductManagementService(
|
public ProductManagementService(
|
||||||
SqlSugarRepository<Obj110> obj110Rep,
|
SqlSugarRepository<Obj110> obj110Rep,
|
||||||
SqlSugarRepository<Obj137> obj137Rep,
|
|
||||||
SqlSugarRepository<Configurations> configurationsRep,
|
SqlSugarRepository<Configurations> configurationsRep,
|
||||||
SysConfigService sysConfigService,
|
SysConfigService sysConfigService,
|
||||||
SqlSugarRepository<ConfigurationData> configurationDataRep,
|
SqlSugarRepository<ConfigurationData> configurationDataRep,
|
||||||
@ -63,7 +60,6 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
_obj122Rep = obj122Rep;
|
_obj122Rep = obj122Rep;
|
||||||
_obj121Rep = obj121Rep;
|
_obj121Rep = obj121Rep;
|
||||||
_scopeFactory = scopeFactory;
|
_scopeFactory = scopeFactory;
|
||||||
_obj137Rep = obj137Rep;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页查询产品管理
|
/// 分页查询产品管理
|
||||||
@ -194,30 +190,11 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync();
|
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync();
|
||||||
var parent = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false && x.fld004311 == "成功" && x.fld004312 == "N").MaxAsync(x => x.VersionIndex);
|
var parent = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false && x.fld004311 == "成功" && x.fld004312 == "N").MaxAsync(x => x.VersionIndex);
|
||||||
var BomData = await _configurationDataRep.AsQueryable()
|
var BomData = await _configurationDataRep.AsQueryable()
|
||||||
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent && (x.fld005586 != "不包含" || x.fld005586 == null)).Select<ProductManagementBomOutput>().ToListAsync();
|
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent && (x.fld005586 != "不包含" || x.fld005586 == null))
|
||||||
//.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
|
||||||
//.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
|
||||||
//.Select<ProductManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
|
.Select<ProductManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
|
||||||
|
return BomData;
|
||||||
foreach (var item in BomData)
|
|
||||||
{
|
|
||||||
if (item.ChildObjID == 137)
|
|
||||||
{
|
|
||||||
if (item.PartNumber != null && Regex.IsMatch(item.PartNumber, "默认"))
|
|
||||||
{
|
|
||||||
var data137 = await _obj137Rep.AsQueryable().Where(x => x.RecordGuid == item.ChildGuid && x.deleted == false && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
|
|
||||||
if (data137 != null)
|
|
||||||
{
|
|
||||||
item.PartNumber = data137._System_objNBS;
|
|
||||||
item.Description = data137._System_ObjDescription;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = BomData.ToPagedList(input.Page, input.PageSize);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 产品管理-Bom同步到SAP
|
/// 产品管理-Bom同步到SAP
|
||||||
@ -240,28 +217,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
for (int i = 0; i < input.Count; i++)
|
for (int i = 0; i < input.Count; i++)
|
||||||
{
|
{
|
||||||
//var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
|
var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
|
||||||
|
if (Verification == "不存在")
|
||||||
string verification = "不存在";
|
|
||||||
if (input[i].ChildObjID == 137)
|
|
||||||
{
|
|
||||||
var data137 = await _obj137Rep.AsQueryable().Where(x => x._System_objNBS == input[i].PartNumber && x.deleted == false && x.RecordGuid == input[i].ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
|
|
||||||
if (data137 == null)
|
|
||||||
{
|
|
||||||
verification = "不存在";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
input[i].PartNumber = data137._System_objNBS;
|
|
||||||
verification = "存在";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verification == "不存在")
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -277,8 +234,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
ALPRF = input[i].fld004939,
|
ALPRF = input[i].fld004939,
|
||||||
ZDELETE = input[i].fld004940,
|
ZDELETE = input[i].fld004940,
|
||||||
POSTP = input[i].fld004492,
|
POSTP = input[i].fld004492,
|
||||||
ZYFMK = input[i].fld004941,
|
ZYFMK = input[i].fld004941
|
||||||
ChildGuid= input[i].ChildGuid
|
|
||||||
};
|
};
|
||||||
itemDataList.Add(itemData);
|
itemDataList.Add(itemData);
|
||||||
}
|
}
|
||||||
@ -290,8 +246,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
for (int i = 0; i < BomData.Count; i++)
|
for (int i = 0; i < BomData.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
//var itemList = itemDataList.Where(x => x.IDNRK == BomData[i].PartNumber).ToList();
|
var itemList = itemDataList.Where(x => x.IDNRK == BomData[i].PartNumber).ToList();
|
||||||
var itemList = itemDataList.Where(x => x.ChildGuid == BomData[i].ChildGuid).ToList();
|
|
||||||
if (itemList.Count == 0)
|
if (itemList.Count == 0)
|
||||||
{
|
{
|
||||||
var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid);
|
var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid);
|
||||||
@ -1009,48 +964,11 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
var itemDataList = new List<ItemData>();
|
var itemDataList = new List<ItemData>();
|
||||||
foreach (var item in data.Bom)
|
foreach (var item in data.Bom)
|
||||||
{
|
{
|
||||||
string verification = "不存在";
|
var verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
||||||
if (item.ChildObjID == 137)
|
|
||||||
{
|
|
||||||
var data137 = await db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.PartNumber && x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x=>x.idRecord).FirstAsync();
|
|
||||||
if (data137 == null)
|
|
||||||
{
|
|
||||||
verification = "不存在";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
item.PartNumber = data137._System_objNBS;
|
|
||||||
verification = "存在";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verification == "不存在")
|
if (verification == "不存在")
|
||||||
{
|
|
||||||
if (item.ChildObjID == 137)
|
|
||||||
{
|
|
||||||
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
|
|
||||||
if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.ChildGuid && x.deleted == false && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).First();
|
|
||||||
|
|
||||||
if (data137 != null)
|
|
||||||
{
|
|
||||||
item.PartNumber = data137._System_objNBS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var itemData = new ItemData
|
var itemData = new ItemData
|
||||||
{
|
{
|
||||||
POSNR = (data.Bom.IndexOf(item) + 1).ToString(),
|
POSNR = (data.Bom.IndexOf(item) + 1).ToString(),
|
||||||
@ -1062,8 +980,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
ALPRF = item.ALPRF,
|
ALPRF = item.ALPRF,
|
||||||
ZDELETE = item.ZDELETE,
|
ZDELETE = item.ZDELETE,
|
||||||
POSTP = item.POSTP,
|
POSTP = item.POSTP,
|
||||||
ZYFMK = item.ZYFMK,
|
ZYFMK = item.ZYFMK
|
||||||
ChildGuid=item.ChildGuid
|
|
||||||
};
|
};
|
||||||
itemDataList.Add(itemData);
|
itemDataList.Add(itemData);
|
||||||
}
|
}
|
||||||
@ -1072,36 +989,14 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
|||||||
var BomData = db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == 1 && x.ParentGuid == data.RecordGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(data.SyncVersion) && (x.fld005586 != "不包含" || x.fld005586 == null)).ToList();
|
var BomData = db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == 1 && x.ParentGuid == data.RecordGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(data.SyncVersion) && (x.fld005586 != "不包含" || x.fld005586 == null)).ToList();
|
||||||
foreach (var item in BomData)
|
foreach (var item in BomData)
|
||||||
{
|
{
|
||||||
//var itemList = itemDataList.Where(x => x.IDNRK == item.PartNumber).ToList();
|
var itemList = itemDataList.Where(x => x.IDNRK == item.PartNumber).ToList();
|
||||||
var itemList = itemDataList.Where(x => x.ChildGuid == item.ChildGuid).ToList();
|
|
||||||
if (itemList.Count == 0)
|
if (itemList.Count == 0)
|
||||||
{
|
{
|
||||||
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
||||||
if (Verification == "不存在")
|
if (Verification == "不存在")
|
||||||
{
|
|
||||||
if (item.ChildObjID == 137)
|
|
||||||
{
|
|
||||||
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
|
|
||||||
if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == partNumber && x.deleted == false).OrderByDescending(x => x.idRecord).First();
|
|
||||||
|
|
||||||
if (data137 != null)
|
|
||||||
{
|
|
||||||
item.PartNumber = data137._System_objNBS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var itemData = new ItemData()
|
var itemData = new ItemData()
|
||||||
{
|
{
|
||||||
POSNR = "",//组件序号 sun.ToString()
|
POSNR = "",//组件序号 sun.ToString()
|
||||||
|
@ -120,7 +120,7 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
//查询BOM
|
//查询BOM
|
||||||
var bomData = await db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == configid && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == item.VersionIndex).ToListAsync();
|
var bomData = await db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == configid && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == item.VersionIndex).ToListAsync();
|
||||||
var project = await db.CopyNew().Queryable<Obj109>().Where(x => x.RecordGuid == item.fld004639_Rec && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
|
var project = await db.CopyNew().Queryable<Obj119>().Where(x => x.RecordGuid == item.fld004639_Rec && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
|
||||||
foreach (var bomItem in bomData)
|
foreach (var bomItem in bomData)
|
||||||
{
|
{
|
||||||
var unit = await _dataValidationService.GetUnit(bomItem.ChildObjID, bomItem.ChildGuid);
|
var unit = await _dataValidationService.GetUnit(bomItem.ChildObjID, bomItem.ChildGuid);
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
|
||||||
//
|
|
||||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
|
||||||
//
|
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Vistar.Application.Service.StockInquiry.Dto;
|
|
||||||
public class BomPriceInquiryOutput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 物料编码
|
|
||||||
/// </summary>
|
|
||||||
public string materialCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物料描述
|
|
||||||
/// </summary>
|
|
||||||
public string materialName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// sap入参
|
|
||||||
/// </summary>
|
|
||||||
public string Parameter { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息类型
|
|
||||||
/// </summary>
|
|
||||||
public string Code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物料编码
|
|
||||||
/// </summary>
|
|
||||||
public string Matnr { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工厂
|
|
||||||
/// </summary>
|
|
||||||
public string Bwkey { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 价格
|
|
||||||
/// </summary>
|
|
||||||
public string Verpr { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// sap出参
|
|
||||||
/// </summary>
|
|
||||||
public string Result { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新日期
|
|
||||||
/// </summary>
|
|
||||||
public DateTime DateUpdated { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询状态
|
|
||||||
/// </summary>
|
|
||||||
public string State { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BomPriceInquiryUpdateable
|
|
||||||
{
|
|
||||||
public long Objectid { get; set; }
|
|
||||||
public string RecordGuid { get; set; }
|
|
||||||
public string Code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 价格
|
|
||||||
/// </summary>
|
|
||||||
public string Verpr { get; set; }
|
|
||||||
|
|
||||||
public DateTime DateUpdated { get; set; }
|
|
||||||
}
|
|
@ -6,18 +6,15 @@
|
|||||||
|
|
||||||
using Admin.NET.Core;
|
using Admin.NET.Core;
|
||||||
using Admin.NET.Core.Service;
|
using Admin.NET.Core.Service;
|
||||||
using DocumentFormat.OpenXml.VariantTypes;
|
|
||||||
using Furion.DependencyInjection;
|
using Furion.DependencyInjection;
|
||||||
using Furion.DynamicApiController;
|
using Furion.DynamicApiController;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data.OscarClient;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -40,7 +37,6 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
public SolidWorksManageService.SolidWorksManageService _solidWorksManageService;
|
public SolidWorksManageService.SolidWorksManageService _solidWorksManageService;
|
||||||
private readonly SysConfigService _sysConfigService;
|
private readonly SysConfigService _sysConfigService;
|
||||||
public SapService.SapService _sapService;
|
public SapService.SapService _sapService;
|
||||||
private readonly IServiceScopeFactory _scopeFactory;
|
|
||||||
public StockInquiryService
|
public StockInquiryService
|
||||||
(
|
(
|
||||||
DataValidationService dataValidationService,
|
DataValidationService dataValidationService,
|
||||||
@ -49,8 +45,7 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
SqlSugarRepository<ConfigurationData> configurationDataRep,
|
SqlSugarRepository<ConfigurationData> configurationDataRep,
|
||||||
SolidWorksManageService.SolidWorksManageService solidWorksManageService,
|
SolidWorksManageService.SolidWorksManageService solidWorksManageService,
|
||||||
SysConfigService sysConfigService,
|
SysConfigService sysConfigService,
|
||||||
SapService.SapService sapService,
|
SapService.SapService sapService
|
||||||
IServiceScopeFactory scopeFactory
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_obj137Rep = obj137Rep;
|
_obj137Rep = obj137Rep;
|
||||||
@ -60,7 +55,6 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
_sysConfigService = sysConfigService;
|
_sysConfigService = sysConfigService;
|
||||||
_sapService = sapService;
|
_sapService = sapService;
|
||||||
_dataValidationService = dataValidationService;
|
_dataValidationService = dataValidationService;
|
||||||
_scopeFactory = scopeFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -143,17 +137,14 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<List<BomStockInquiryOutput>> GetBomProductInventory(string materialCode)
|
public async Task<List<BomStockInquiryOutput>> GetBomProductInventory(string materialCode)
|
||||||
{
|
{
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
|
||||||
|
|
||||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||||
|
|
||||||
var materialData = await db.CopyNew().Queryable<Obj137>()
|
var materialData = await _obj137Rep.AsQueryable()
|
||||||
.Where(x => x._System_objNBS == materialCode && x.deleted == false)
|
.Where(x => x._System_objNBS == materialCode && x.deleted == false)
|
||||||
.OrderByDescending(x => x.idRecord)
|
.OrderByDescending(x => x.idRecord)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
var bomList = await db.CopyNew().Queryable<ConfigurationData>()
|
var bomList = await _configurationDataRep.AsQueryable()
|
||||||
.Where(x => x.ParentGuid == materialData.RecordGuid && x.isDeleted == false
|
.Where(x => x.ParentGuid == materialData.RecordGuid && x.isDeleted == false
|
||||||
&& x.ParentVersion == materialData.VersionIndex
|
&& x.ParentVersion == materialData.VersionIndex
|
||||||
&& (x.fld005577 != "不包含" || x.fld005577 == null)
|
&& (x.fld005577 != "不包含" || x.fld005577 == null)
|
||||||
@ -161,17 +152,8 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var UpdateableList = new List<BomStockInquiryUpdateable>();
|
var UpdateableList = new List<BomStockInquiryUpdateable>();
|
||||||
var UpdateableOutput = new List<BomStockInquiryOutput>();
|
|
||||||
|
|
||||||
int batchSize = 20; // 每批的大小
|
var tasks = bomList.Select(async item =>
|
||||||
int totalCount = bomList.ToList().Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < totalCount; i += batchSize)
|
|
||||||
{
|
|
||||||
var batch = bomList.Skip(i).Take(batchSize); // 分批获取数据
|
|
||||||
|
|
||||||
// 处理当前批次的数据
|
|
||||||
var tasks = batch.Select(async item =>
|
|
||||||
{
|
{
|
||||||
var code = item.PartNumber;
|
var code = item.PartNumber;
|
||||||
var name = item.Description;
|
var name = item.Description;
|
||||||
@ -210,8 +192,7 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
ZwqslPr = apiOutput.ZwqslPr,
|
ZwqslPr = apiOutput.ZwqslPr,
|
||||||
DateUpdated = dateUpdated
|
DateUpdated = dateUpdated
|
||||||
};
|
};
|
||||||
//UpdateableList.Add(UpdateableData);
|
UpdateableList.Add(UpdateableData);
|
||||||
_dataValidationService.ModifyInventoryInformation(UpdateableData.RecordGuid, UpdateableData.Code, UpdateableData.Objectid, UpdateableData.Bdmng, UpdateableData.Labst, UpdateableData.ZwqslPo, UpdateableData.ZwqslPr, UpdateableData.DateUpdated);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -225,8 +206,7 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
ZwqslPr = "",
|
ZwqslPr = "",
|
||||||
DateUpdated = dateUpdated
|
DateUpdated = dateUpdated
|
||||||
};
|
};
|
||||||
//UpdateableList.Add(UpdateableData);
|
UpdateableList.Add(UpdateableData);
|
||||||
_dataValidationService.ModifyInventoryInformation(UpdateableData.RecordGuid, UpdateableData.Code, UpdateableData.Objectid, UpdateableData.Bdmng, UpdateableData.Labst, UpdateableData.ZwqslPo, UpdateableData.ZwqslPr, UpdateableData.DateUpdated);
|
|
||||||
}
|
}
|
||||||
if (apiOutput.Code == "S")
|
if (apiOutput.Code == "S")
|
||||||
{
|
{
|
||||||
@ -248,104 +228,19 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
materialCode = code,
|
materialCode = code,
|
||||||
materialName = name,
|
materialName = name,
|
||||||
State = "SAP未查询到库存信息"
|
State = "SAP未查询库存信息"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).ToList();
|
});
|
||||||
var bomStockInquiryOutput = await Task.WhenAll(tasks); // 等待当前批次的所有任务完成
|
|
||||||
|
|
||||||
// 合并当前批次的结果
|
var bomStockInquiryOutput = await Task.WhenAll(tasks);
|
||||||
UpdateableOutput.AddRange(bomStockInquiryOutput);
|
|
||||||
|
foreach (var item in UpdateableList)
|
||||||
|
{
|
||||||
|
await _dataValidationService.ModifyInventoryInformation(item.RecordGuid, item.Code, item.Objectid, item.Bdmng, item.Labst, item.ZwqslPo, item.ZwqslPr, item.DateUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// var tasks = bomList.Select(async item =>
|
return bomStockInquiryOutput.ToList();
|
||||||
//{
|
|
||||||
// var code = item.PartNumber;
|
|
||||||
// var name = item.Description;
|
|
||||||
// var objectid = item.ChildObjID;
|
|
||||||
// var childGuid = item.ChildGuid;
|
|
||||||
|
|
||||||
// var SapEcnQueryData = new SapEcnQueryInput
|
|
||||||
// {
|
|
||||||
// Reqkeyid = "",
|
|
||||||
// Businessid = "",
|
|
||||||
// Messageid = "",
|
|
||||||
// Sndprn = "PLM",
|
|
||||||
// Rcvprn = "SAP",
|
|
||||||
// Requser = Requser,
|
|
||||||
// Note1 = "",
|
|
||||||
// Note2 = "",
|
|
||||||
// Note3 = "",
|
|
||||||
// Sign = "I",
|
|
||||||
// Option = "EQ",
|
|
||||||
// Low = code,
|
|
||||||
// High = ""
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var apiOutput = await _sapService.SapEcnQueryApi(SapEcnQueryData);
|
|
||||||
// var dateUpdated = DateTime.Now;
|
|
||||||
// if (apiOutput.Code == "S")
|
|
||||||
// {
|
|
||||||
// var UpdateableData = new BomStockInquiryUpdateable
|
|
||||||
// {
|
|
||||||
// Objectid = objectid,
|
|
||||||
// Code = apiOutput.Code,
|
|
||||||
// RecordGuid = childGuid,
|
|
||||||
// Bdmng = apiOutput.Bdmng,
|
|
||||||
// Labst = apiOutput.Labst,
|
|
||||||
// ZwqslPo = apiOutput.ZwqslPo,
|
|
||||||
// ZwqslPr = apiOutput.ZwqslPr,
|
|
||||||
// DateUpdated = dateUpdated
|
|
||||||
// };
|
|
||||||
// UpdateableList.Add(UpdateableData);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// var UpdateableData = new BomStockInquiryUpdateable
|
|
||||||
// {
|
|
||||||
// Code = "",
|
|
||||||
// RecordGuid = "",
|
|
||||||
// Bdmng = "",
|
|
||||||
// Labst = "",
|
|
||||||
// ZwqslPo = "",
|
|
||||||
// ZwqslPr = "",
|
|
||||||
// DateUpdated = dateUpdated
|
|
||||||
// };
|
|
||||||
// UpdateableList.Add(UpdateableData);
|
|
||||||
// }
|
|
||||||
// if (apiOutput.Code == "S")
|
|
||||||
// {
|
|
||||||
// return new BomStockInquiryOutput
|
|
||||||
// {
|
|
||||||
// materialCode = code,
|
|
||||||
// materialName = name,
|
|
||||||
// Labst = apiOutput.Labst,
|
|
||||||
// Bdmng = apiOutput.Bdmng,
|
|
||||||
// ZwqslPr = apiOutput.ZwqslPr,
|
|
||||||
// ZwqslPo = apiOutput.ZwqslPo,
|
|
||||||
// DateUpdated = dateUpdated,
|
|
||||||
// State = "查询成功"
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return new BomStockInquiryOutput
|
|
||||||
// {
|
|
||||||
// materialCode = code,
|
|
||||||
// materialName = name,
|
|
||||||
// State = "SAP未查询到库存信息"
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
|
|
||||||
//var bomStockInquiryOutput = await Task.WhenAll(tasks);
|
|
||||||
|
|
||||||
//foreach (var item in UpdateableList)
|
|
||||||
//{
|
|
||||||
// await _dataValidationService.ModifyInventoryInformation(item.RecordGuid, item.Code, item.Objectid, item.Bdmng, item.Labst, item.ZwqslPo, item.ZwqslPr, item.DateUpdated);
|
|
||||||
//}
|
|
||||||
|
|
||||||
return UpdateableOutput.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -375,26 +270,14 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<List<BomStockInquiryOutput>> RawMaterialStockInquiry()
|
public async Task<List<BomStockInquiryOutput>> RawMaterialStockInquiry()
|
||||||
{
|
{
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
|
||||||
|
|
||||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||||
var data = await db.CopyNew().Queryable<Obj112>()
|
var data = await _obj112Rep.AsQueryable()
|
||||||
.Where(x => x.deleted == false)
|
.Where(x => x.deleted == false)
|
||||||
.Select<RawMaterialOutput>()
|
.Select<RawMaterialOutput>()
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var UpdateableList = new List<BomStockInquiryUpdateable>();
|
var UpdateableList = new List<BomStockInquiryUpdateable>();
|
||||||
var UpdateableOutput = new List<BomStockInquiryOutput>();
|
|
||||||
|
|
||||||
int batchSize = 20; // 每批的大小
|
var tasks = data.Select(async item =>
|
||||||
int totalCount = data.ToList().Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < totalCount; i += batchSize)
|
|
||||||
{
|
|
||||||
var batch = data.Skip(i).Take(batchSize); // 分批获取数据
|
|
||||||
|
|
||||||
// 处理当前批次的数据
|
|
||||||
var tasks = batch.Select(async item =>
|
|
||||||
{
|
{
|
||||||
var code = item._System_objNBS;
|
var code = item._System_objNBS;
|
||||||
var name = item._System_objDescription;
|
var name = item._System_objDescription;
|
||||||
@ -468,101 +351,16 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
materialCode = code,
|
materialCode = code,
|
||||||
materialName = name,
|
materialName = name,
|
||||||
State = "SAP未查询到库存信息"
|
State = "SAP未查询库存信息"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).ToList();
|
});
|
||||||
|
|
||||||
var bomStockInquiryOutput = await Task.WhenAll(tasks); // 等待当前批次的所有任务完成
|
var bomStockInquiryOutput = await Task.WhenAll(tasks);
|
||||||
|
|
||||||
// 合并当前批次的结果
|
|
||||||
UpdateableOutput.AddRange(bomStockInquiryOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
// var tasks = data.Select(async item =>
|
|
||||||
//{
|
|
||||||
// var code = item._System_objNBS;
|
|
||||||
// var name = item._System_objDescription;
|
|
||||||
// var objectid = 112;
|
|
||||||
// var id = item.idRecord;
|
|
||||||
// var SapEcnQueryData = new SapEcnQueryInput
|
|
||||||
// {
|
|
||||||
// Reqkeyid = "",
|
|
||||||
// Businessid = "",
|
|
||||||
// Messageid = "",
|
|
||||||
// Sndprn = "PLM",
|
|
||||||
// Rcvprn = "SAP",
|
|
||||||
// Requser = Requser,
|
|
||||||
// Note1 = "",
|
|
||||||
// Note2 = "",
|
|
||||||
// Note3 = "",
|
|
||||||
// Sign = "I",
|
|
||||||
// Option = "EQ",
|
|
||||||
// Low = code,
|
|
||||||
// High = ""
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var apiOutput = await _sapService.SapEcnQueryApi(SapEcnQueryData);
|
|
||||||
// var dateUpdated = DateTime.Now;
|
|
||||||
// if (apiOutput.Code == "S")
|
|
||||||
// {
|
|
||||||
// var UpdateableData = new BomStockInquiryUpdateable
|
|
||||||
// {
|
|
||||||
// Objectid = objectid,
|
|
||||||
// Code = apiOutput.Code,
|
|
||||||
// RecordGuid = id.ToString(),//在这个方法中使用RecordGuid字段作为id字段
|
|
||||||
// Bdmng = apiOutput.Bdmng,
|
|
||||||
// Labst = apiOutput.Labst,
|
|
||||||
// ZwqslPo = apiOutput.ZwqslPo,
|
|
||||||
// ZwqslPr = apiOutput.ZwqslPr,
|
|
||||||
// DateUpdated = dateUpdated
|
|
||||||
// };
|
|
||||||
// UpdateableList.Add(UpdateableData);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// var UpdateableData = new BomStockInquiryUpdateable
|
|
||||||
// {
|
|
||||||
// Code = "",
|
|
||||||
// RecordGuid = "",
|
|
||||||
// Bdmng = "",
|
|
||||||
// Labst = "",
|
|
||||||
// ZwqslPo = "",
|
|
||||||
// ZwqslPr = "",
|
|
||||||
// DateUpdated = dateUpdated
|
|
||||||
// };
|
|
||||||
// UpdateableList.Add(UpdateableData);
|
|
||||||
// }
|
|
||||||
// if (apiOutput.Code == "S")
|
|
||||||
// {
|
|
||||||
// return new BomStockInquiryOutput
|
|
||||||
// {
|
|
||||||
// materialCode = code,
|
|
||||||
// materialName = name,
|
|
||||||
// Labst = apiOutput.Labst,
|
|
||||||
// Bdmng = apiOutput.Bdmng,
|
|
||||||
// ZwqslPr = apiOutput.ZwqslPr,
|
|
||||||
// ZwqslPo = apiOutput.ZwqslPo,
|
|
||||||
// DateUpdated = dateUpdated,
|
|
||||||
// State = "查询成功"
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return new BomStockInquiryOutput
|
|
||||||
// {
|
|
||||||
// materialCode = code,
|
|
||||||
// materialName = name,
|
|
||||||
// State = "SAP未查询到库存信息"
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
|
|
||||||
//var bomStockInquiryOutput = await Task.WhenAll(tasks);
|
|
||||||
foreach (var item in UpdateableList)
|
foreach (var item in UpdateableList)
|
||||||
{
|
{
|
||||||
var dateUpdated = DateTime.Now;
|
var dateUpdated = DateTime.Now;
|
||||||
db.CopyNew().Updateable<Obj112>().SetColumns(it => new Obj112
|
await _obj112Rep.AsUpdateable().SetColumns(it => new Obj112
|
||||||
{
|
{
|
||||||
fld006750 = item.Bdmng,
|
fld006750 = item.Bdmng,
|
||||||
fld006751 = item.Labst,
|
fld006751 = item.Labst,
|
||||||
@ -571,348 +369,10 @@ public class StockInquiryService : IDynamicApiController, ITransient
|
|||||||
fld006755 = dateUpdated
|
fld006755 = dateUpdated
|
||||||
})
|
})
|
||||||
.Where(it => it.idRecord == Convert.ToInt32(item.RecordGuid))//在这个方法中使用RecordGuid字段作为id字段
|
.Where(it => it.idRecord == Convert.ToInt32(item.RecordGuid))//在这个方法中使用RecordGuid字段作为id字段
|
||||||
.ExecuteCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
return UpdateableOutput.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 产品管理库-价格查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="materialCode"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ApiDescriptionSettings(Name = "GetPriceInquiry", Description = "产品管理库-价格查询", Order = 1000), HttpGet]
|
|
||||||
[DisplayName("产品管理库-价格查询")]
|
|
||||||
[AllowAnonymous]
|
|
||||||
public async Task<SapPriceQueryOutput> GetPriceInquiry(string materialCode)
|
|
||||||
{
|
|
||||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
|
||||||
|
|
||||||
var SapPriceQueryData = new SapPriceQueryInput
|
|
||||||
{
|
|
||||||
Reqkeyid = "",
|
|
||||||
Businessid = "",
|
|
||||||
Messageid = "",
|
|
||||||
Sndprn = "PLM",
|
|
||||||
Rcvprn = "SAP",
|
|
||||||
Requser = Requser,
|
|
||||||
Note1 = "",
|
|
||||||
Note2 = "",
|
|
||||||
Note3 = "",
|
|
||||||
Sign = "I",
|
|
||||||
Option = "EQ",
|
|
||||||
Low = materialCode,
|
|
||||||
High = ""
|
|
||||||
};
|
|
||||||
|
|
||||||
var apiOutput = await _sapService.SapPriceQueryApi(SapPriceQueryData);
|
|
||||||
|
|
||||||
if (apiOutput.Code == "S")
|
|
||||||
{
|
|
||||||
string priceValue = apiOutput.Verpr;
|
|
||||||
var Verpr2 = await _dataValidationService.ProcessNumber(0);
|
|
||||||
var Verpr3 = await _dataValidationService.ProcessNumber(apiOutput.Verpr.ToDecimal());
|
|
||||||
var priceValue3 = Verpr3 == 0 ? "9999.99" : Verpr3.ToString();
|
|
||||||
if (apiOutput.Verpr != "0.0")
|
|
||||||
{
|
|
||||||
var Verpr = await _dataValidationService.ProcessNumber(apiOutput.Verpr.ToDecimal());
|
|
||||||
priceValue = Verpr == 0 ? "9999.99" : Verpr.ToString();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
priceValue = "9999.99";
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = await _obj137Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
apiOutput.DateUpdated = DateTime.Now;
|
|
||||||
await _obj137Rep.AsUpdateable().SetColumns(it => new Obj137
|
|
||||||
{
|
|
||||||
fld005625 = priceValue,
|
|
||||||
fld005626 = apiOutput.DateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == data.idRecord)
|
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
apiOutput.Verpr = priceValue;
|
|
||||||
return apiOutput;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var RawMaterialData = await _obj112Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false).FirstAsync();
|
return bomStockInquiryOutput.ToList();
|
||||||
|
|
||||||
if (RawMaterialData != null)
|
|
||||||
{
|
|
||||||
apiOutput.DateUpdated = DateTime.Now;
|
|
||||||
await _obj112Rep.AsUpdateable().SetColumns(it => new Obj112
|
|
||||||
{
|
|
||||||
fld006754 = priceValue,
|
|
||||||
fld006756 = apiOutput.DateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == RawMaterialData.idRecord)
|
|
||||||
.ExecuteCommandAsync();
|
|
||||||
apiOutput.Verpr = priceValue;
|
|
||||||
return apiOutput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 产品管理库-Bom成本查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="materialCode"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ApiDescriptionSettings(Name = "GetBomPriceInquiry", Description = "产品管理库-Bom成本查询", Order = 1000), HttpGet]
|
|
||||||
[DisplayName("产品管理库-Bom成本查询")]
|
|
||||||
[AllowAnonymous]
|
|
||||||
public async Task<List<BomPriceInquiryOutput>> GetBomPriceInquiry(string materialCode)
|
|
||||||
{
|
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
|
||||||
|
|
||||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
|
||||||
|
|
||||||
var materialData = await db.CopyNew().Queryable<Obj137>()
|
|
||||||
.Where(x => x._System_objNBS == materialCode && x.deleted == false)
|
|
||||||
.OrderByDescending(x => x.idRecord)
|
|
||||||
.FirstAsync();
|
|
||||||
|
|
||||||
var bomList = await db.CopyNew().Queryable<ConfigurationData>()
|
|
||||||
.Where(x => x.ParentGuid == materialData.RecordGuid && x.isDeleted == false
|
|
||||||
&& x.ParentVersion == materialData.VersionIndex
|
|
||||||
&& (x.fld005577 != "不包含" || x.fld005577 == null)
|
|
||||||
&& x.isSuppressed == false && x.inContext == false)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var UpdateableList = new List<BomPriceInquiryUpdateable>();
|
|
||||||
var UpdateableOutput = new List<BomPriceInquiryOutput>();
|
|
||||||
|
|
||||||
int batchSize = 20; // 每批的大小
|
|
||||||
int totalCount = bomList.ToList().Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < totalCount; i += batchSize)
|
|
||||||
{
|
|
||||||
var batch = bomList.Skip(i).Take(batchSize); // 分批获取数据
|
|
||||||
|
|
||||||
// 处理当前批次的数据
|
|
||||||
var tasks = batch.Select(async item =>
|
|
||||||
{
|
|
||||||
var code = item.PartNumber;
|
|
||||||
var name = item.Description;
|
|
||||||
var objectid = item.ChildObjID;
|
|
||||||
var childGuid = item.ChildGuid;
|
|
||||||
|
|
||||||
var SapPriceQueryData = new SapPriceQueryInput
|
|
||||||
{
|
|
||||||
Reqkeyid = "",
|
|
||||||
Businessid = "",
|
|
||||||
Messageid = "",
|
|
||||||
Sndprn = "PLM",
|
|
||||||
Rcvprn = "SAP",
|
|
||||||
Requser = Requser,
|
|
||||||
Note1 = "",
|
|
||||||
Note2 = "",
|
|
||||||
Note3 = "",
|
|
||||||
Sign = "I",
|
|
||||||
Option = "EQ",
|
|
||||||
Low = code,
|
|
||||||
High = ""
|
|
||||||
};
|
|
||||||
|
|
||||||
var apiOutput = await _sapService.SapPriceQueryApi(SapPriceQueryData);
|
|
||||||
var dateUpdated = DateTime.Now;
|
|
||||||
if (apiOutput.Code == "S")
|
|
||||||
{
|
|
||||||
string priceValue = apiOutput.Verpr;
|
|
||||||
|
|
||||||
if (apiOutput.Verpr != "0.0")
|
|
||||||
{
|
|
||||||
var Verpr = await _dataValidationService.ProcessNumber(apiOutput.Verpr.ToDecimal());
|
|
||||||
priceValue = Verpr == 0 ? "9999.99" : Verpr.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
priceValue = "9999.99";
|
|
||||||
}
|
|
||||||
|
|
||||||
var UpdateableData = new BomPriceInquiryUpdateable
|
|
||||||
{
|
|
||||||
Objectid = objectid,
|
|
||||||
Code = apiOutput.Code,
|
|
||||||
RecordGuid = childGuid,
|
|
||||||
Verpr = priceValue,
|
|
||||||
DateUpdated = dateUpdated
|
|
||||||
};
|
|
||||||
//UpdateableList.Add(UpdateableData);
|
|
||||||
_dataValidationService.ModifyPriceInformation(UpdateableData.RecordGuid, UpdateableData.Code, UpdateableData.Objectid, UpdateableData.Verpr, UpdateableData.DateUpdated);
|
|
||||||
|
|
||||||
return new BomPriceInquiryOutput
|
|
||||||
{
|
|
||||||
materialCode = code,
|
|
||||||
materialName = name,
|
|
||||||
Verpr = priceValue,
|
|
||||||
DateUpdated = dateUpdated,
|
|
||||||
State = "查询成功"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var UpdateableData = new BomPriceInquiryUpdateable
|
|
||||||
{
|
|
||||||
Code = "",
|
|
||||||
RecordGuid = "",
|
|
||||||
Verpr = "",
|
|
||||||
DateUpdated = dateUpdated
|
|
||||||
};
|
|
||||||
//UpdateableList.Add(UpdateableData);
|
|
||||||
_dataValidationService.ModifyPriceInformation(UpdateableData.RecordGuid, UpdateableData.Code, UpdateableData.Objectid, UpdateableData.Verpr, UpdateableData.DateUpdated);
|
|
||||||
|
|
||||||
return new BomPriceInquiryOutput
|
|
||||||
{
|
|
||||||
materialCode = code,
|
|
||||||
materialName = name,
|
|
||||||
State = "查询失败"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
//if (apiOutput.Code == "S")
|
|
||||||
//{
|
|
||||||
// return new BomPriceInquiryOutput
|
|
||||||
// {
|
|
||||||
// materialCode = code,
|
|
||||||
// materialName = name,
|
|
||||||
// Verpr = apiOutput.Verpr,
|
|
||||||
// DateUpdated = dateUpdated,
|
|
||||||
// State = "查询成功"
|
|
||||||
// };
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// return new BomPriceInquiryOutput
|
|
||||||
// {
|
|
||||||
// materialCode = code,
|
|
||||||
// materialName = name,
|
|
||||||
// State = "SAP未查询到价格信息"
|
|
||||||
// };
|
|
||||||
//}
|
|
||||||
}).ToList();
|
|
||||||
var bomStockInquiryOutput = await Task.WhenAll(tasks); // 等待当前批次的所有任务完成
|
|
||||||
|
|
||||||
// 合并当前批次的结果
|
|
||||||
UpdateableOutput.AddRange(bomStockInquiryOutput);
|
|
||||||
}
|
|
||||||
return UpdateableOutput.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 原材料成本查询
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ApiDescriptionSettings(Name = "RawMaterialPriceInquiry", Description = "原材料成本查询", Order = 1000), HttpGet]
|
|
||||||
[DisplayName("原材料成本查询")]
|
|
||||||
[AllowAnonymous]
|
|
||||||
public async Task<List<BomPriceInquiryOutput>> RawMaterialPriceInquiry()
|
|
||||||
{
|
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
|
||||||
|
|
||||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
|
||||||
var data = await db.CopyNew().Queryable<Obj112>()
|
|
||||||
.Where(x => x.deleted == false)
|
|
||||||
.Select<RawMaterialOutput>()
|
|
||||||
.ToListAsync();
|
|
||||||
var UpdateableList = new List<BomPriceInquiryUpdateable>();
|
|
||||||
var UpdateableOutput = new List<BomPriceInquiryOutput>();
|
|
||||||
|
|
||||||
int batchSize = 20; // 每批的大小
|
|
||||||
int totalCount = data.ToList().Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < totalCount; i += batchSize)
|
|
||||||
{
|
|
||||||
var batch = data.Skip(i).Take(batchSize); // 分批获取数据
|
|
||||||
|
|
||||||
// 处理当前批次的数据
|
|
||||||
var tasks = batch.Select(async item =>
|
|
||||||
{
|
|
||||||
var code = item._System_objNBS;
|
|
||||||
var name = item._System_objDescription;
|
|
||||||
var objectid = 112;
|
|
||||||
var id = item.idRecord;
|
|
||||||
var SapPriceQueryData = new SapPriceQueryInput
|
|
||||||
{
|
|
||||||
Reqkeyid = "",
|
|
||||||
Businessid = "",
|
|
||||||
Messageid = "",
|
|
||||||
Sndprn = "PLM",
|
|
||||||
Rcvprn = "SAP",
|
|
||||||
Requser = Requser,
|
|
||||||
Note1 = "",
|
|
||||||
Note2 = "",
|
|
||||||
Note3 = "",
|
|
||||||
Sign = "I",
|
|
||||||
Option = "EQ",
|
|
||||||
Low = code,
|
|
||||||
High = ""
|
|
||||||
};
|
|
||||||
|
|
||||||
var apiOutput = await _sapService.SapPriceQueryApi(SapPriceQueryData);
|
|
||||||
var dateUpdated = DateTime.Now;
|
|
||||||
if (apiOutput.Code == "S")
|
|
||||||
{
|
|
||||||
string priceValue = apiOutput.Verpr;
|
|
||||||
|
|
||||||
if (apiOutput.Verpr != "0.0")
|
|
||||||
{
|
|
||||||
var Verpr = await _dataValidationService.ProcessNumber(apiOutput.Verpr.ToDecimal());
|
|
||||||
priceValue = Verpr == 0 ? "9999.99" : Verpr.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
priceValue = "9999.99";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
db.CopyNew().Updateable<Obj112>().SetColumns(it => new Obj112
|
|
||||||
{
|
|
||||||
fld006754 = priceValue,
|
|
||||||
fld006755 = dateUpdated
|
|
||||||
})
|
|
||||||
.Where(it => it.idRecord == id)//在这个方法中使用RecordGuid字段作为id字段
|
|
||||||
.ExecuteCommand();
|
|
||||||
|
|
||||||
return new BomPriceInquiryOutput
|
|
||||||
{
|
|
||||||
materialCode = code,
|
|
||||||
materialName = name,
|
|
||||||
Verpr = priceValue,
|
|
||||||
DateUpdated = dateUpdated,
|
|
||||||
State = "查询成功"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
db.CopyNew().Updateable<Obj112>().SetColumns(it => new Obj112
|
|
||||||
{
|
|
||||||
fld006754 = "",
|
|
||||||
fld006755 = dateUpdated
|
|
||||||
}).Where(it => it.idRecord == id)
|
|
||||||
.ExecuteCommand();
|
|
||||||
|
|
||||||
return new BomPriceInquiryOutput
|
|
||||||
{
|
|
||||||
materialCode = code,
|
|
||||||
materialName = name,
|
|
||||||
State = "查询失败"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
var bomStockInquiryOutput = await Task.WhenAll(tasks); // 等待当前批次的所有任务完成
|
|
||||||
|
|
||||||
// 合并当前批次的结果
|
|
||||||
UpdateableOutput.AddRange(bomStockInquiryOutput);
|
|
||||||
}
|
|
||||||
return UpdateableOutput.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -79,42 +79,7 @@ public class SapEcnQueryOutput
|
|||||||
/// 更新日期
|
/// 更新日期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime DateUpdated { get; set; }
|
public DateTime DateUpdated { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public class SapPriceQueryOutput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// sap入参
|
|
||||||
/// </summary>
|
|
||||||
public string Parameter { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息类型
|
|
||||||
/// </summary>
|
|
||||||
public string Code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物料编码
|
|
||||||
/// </summary>
|
|
||||||
public string Matnr { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工厂
|
|
||||||
/// </summary>
|
|
||||||
public string Bwkey { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 价格
|
|
||||||
/// </summary>
|
|
||||||
public string Verpr { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// sap出参
|
|
||||||
/// </summary>
|
|
||||||
public string Result { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新日期
|
|
||||||
/// </summary>
|
|
||||||
public DateTime DateUpdated { get; set; }
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user