Browse Source

更新版本

master
zhaoxinyu 9 months ago
parent
commit
1e7a784154
  1. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  2. 78
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/ML_MNG.cs
  3. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/SettleAccount.Domain.csproj

38
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -690,21 +690,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
// { version = $"{before.ToString()}11"; }
// else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear)
// { version = $"{before.ToString()}12"; }
// if (string.IsNullOrEmpty(version))
// {
// return 200802;//找不到的数据默认写到这个区间
// }
// return int.Parse(version);
//}
private int GetVersionByBillTime(DateTime p_billtime, string p_day)
{
@ -828,6 +820,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.PartCode= item.RealPartCode;
seDetail.RealPartCode=item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
@ -861,6 +855,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.PartCode = item.RealPartCode;
seDetail.RealPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
@ -907,6 +903,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.PartCode = item.RealPartCode;
seDetail.RealPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
seDetail.Qty = item.Qty;
@ -919,7 +917,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetails.Add(seDetail);
}
}
var result = await CheckBusinessJISLocation(seDetails, businessType).ConfigureAwait(false);
if (result != "ok")
{
@ -953,6 +950,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.PartCode = item.RealPartCode;
seDetail.RealPartCode = item.RealPartCode;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ErpToLoc = item.ErpToLoc;
@ -998,6 +997,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.PartCode = item.RealPartCode;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
@ -1005,6 +1006,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.PN = item.VinCode;
seDetail.LU = item.CustPartCode;
seDetail.CustPartCode = item.CustPartCode;
seDetail.PartCode = item.RealPartCode;
seDetail.BillTime = DateTime.Now;
seDetail.Remark = "期初初始化";
seDetails.Add(seDetail);
@ -1042,6 +1045,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.PartCode = item.RealPartCode;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
@ -1086,6 +1091,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.SubBillType = 0;
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.PartCode = item.RealPartCode;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
@ -1131,6 +1137,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
seDetail.TransType = EnumDelTransType.;
seDetail.UID = 000;
seDetail.FactoryPartCode = item.RealPartCode;
seDetail.PartCode = item.RealCode;
seDetail.CustomerPartCodeNoSpace = item.RealPartCode.Replace("-", "");
seDetail.ToErpLocCode = item.ErpToLoc;
seDetail.Qty = item.Qty;
@ -1167,7 +1174,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <returns></returns>
private async Task<IActionResult> BeginTran<T>(List<T> p_list, List<VmiLog> logList) where T : SE_BASE, new()
{
//var messageList = logList.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) }).ToList();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
@ -1190,7 +1196,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
itm.Version= GetVersionByBillTime(itm.ShippingDate, value);
}
await context.BulkInsertAsync(p_list).ConfigureAwait(false);
await context.BulkInsertAsync(logList).ConfigureAwait(false);
transaction.Commit();
@ -1237,7 +1242,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
p.Value == "JisHBPO"
).ToList();
break;
case EnumBusinessType.MaiDanJianHBPO:
locList = locList.Where(p => p.Value == "MaiDanJianHBPO").ToList();
break;
@ -1278,7 +1282,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var locList = _codeRepository.Where(p => p.Project == "库位").ToList();
switch (enumBusinessType)
{
case EnumBusinessType.ZhiGongJianBBAC:
locList = locList.Where(p => p.Value == "ZhiGongJianBBAC顺义" || p.Value == "ZhiGongJianBBAC").ToList();
break;
@ -1291,11 +1294,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
case EnumBusinessType.YinDuJian:
locList = locList.Where(p => p.Value == "YinDuJian").ToList();
break;
}
var locs = locList.Select(p => p.Description).ToList();
if (p_list.Any(p => !locs.Contains(p.ToErpLocCode)))
{
return "发运数据有不在" + string.Join(",", locs) + "库位中";
}
@ -1342,6 +1346,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var logList = tupleList.Select(o => o.Item1).ToList();
logList.AsParallel().ForEach(Update);
//List<BBAC_SE_DETAIL> seDetails = new List<BBAC_SE_DETAIL>();
//List<HBPO_SE_DETAIL> hbpo_seDetails=new List<HBPO_SE_DETAIL>();
//List<PUB_SE_DETAIL> pub_seDetails=new List<PUB_SE_DETAIL>();
@ -1724,7 +1732,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
catch (Exception ex)
{
this._logger.LogError(ex.ToString());
return new JsonResult(new { code = 500, data = ex.ToString(), message = ex.Message }); ;
return new JsonResult(new { code = 500, data = ex.ToString(), message = ex.Message });
}
}

78
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/ML_MNG.cs

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ML;
using SettleAccount.Domain.BQ;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
public class ML_MNG
{
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _canRepository;
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _saRepository;
public ML_MNG(
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> canRepository,
INormalEfCoreRepository<PUB_SA_DETAIL, Guid> saRepository
)
{
_canRepository = canRepository;
_saRepository = saRepository;
}
//public async Task Load(string p_load)
//{
// var mlContext = new MLContext();
// mlContext.Regression.Trainers.OnlineGradientDescent
// var trainer = mlContext.Regression.Trainers.FastTreeTweedie(labelColumnName: "Label", featureColumnName: "Features");
// var trainingPipeline = mlContext.Transforms.Concatenate(outputColumnName: "NumFeatures", nameof(ProductData.year), nameof(ProductData.month), nameof(ProductData.units), nameof(ProductData.avg), nameof(ProductData.count),
// nameof(ProductData.max), nameof(ProductData.min), nameof(ProductData.prev))
// .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "CatFeatures", inputColumnName: nameof(ProductData.productId)))
// .Append(mlContext.Transforms.Concatenate(outputColumnName: "Features", "NumFeatures", "CatFeatures"))
// .Append(mlContext.Transforms.CopyColumns(outputColumnName: "Label", inputColumnName: nameof(ProductData.next)))
// .Append(trainer);
// var crossValidationResults = mlContext.Regression.CrossValidate(data: trainingDataView, estimator: trainingPipeline, numberOfFolds: 6, labelColumnName: "Label");
// //ConsoleHelper.PrintRegressionFoldsAverageMetrics(trainer.ToString(), crossValidationResults);
// var model = trainingPipeline.Fit(trainingDataView);
//}
//public Task LoadSampleAsync(string name) {
// //// MLContext mlContext = new MLContext();
// ////var mlContext = new MLContext(seed: 0);
// ////IDataView data1View = mlContext.Data.LoadFromTextFile<ModelInput>(_data1Path, separatorChar: ',', hasHeader: false);
// ////IDataView data2View = mlContext.Data.LoadFromTextFile<ModelInput>(_data2Path, separatorChar: ',', hasHeader: false);
// //var ls=_canRepository.ToList();
// //var mlContext = new MLContext(seed: 0);
// //// Load data
// //IDataView data = mlContext.Data.lo
// // LoadFromTextFile<HouseData>("house-prices.csv", hasHeader: true, separatorChar: ',');
// //// Define pipeline
// //var pipeline = mlContext.Transforms.Concatenate("Features", new[] { "Size" })
// // .Append(mlContext.Regression.Trainers.LbfgsPoissonRegression());
// //// Train model
// //var model = pipeline.Fit(data);
// //// Make prediction
// //var predictionEngine = mlContext.Model.CreatePredictionEngine<HouseData, Prediction>(model);
// //var house = new HouseData() { Size = 1500 };
// //var prediction = predictionEngine.Predict(house);
// //Console.WriteLine($"Predicted price for a house with size {house.Size}: {prediction.Price}");
//}
}
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/SettleAccount.Domain.csproj

@ -35,6 +35,7 @@
<PackageReference Include="EFCore.BulkExtensions" Version="5.3.0" />
<PackageReference Include="Magicodes.IE.Csv" Version="2.7.4.5" />
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.4.5" />
<PackageReference Include="Microsoft.ML" Version="3.0.1" />
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="4.3.3" />
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" Version="4.3.3" />
<PackageReference Include="Volo.Abp.BlobStoring" Version="4.3.3" />

Loading…
Cancel
Save