From 0ac2aaf1718bb9920f2619307f53852282d96548 Mon Sep 17 00:00:00 2001 From: bairubing Date: Tue, 3 Dec 2024 11:14:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E6=96=B0=E5=A2=9E=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=8E=92=E7=89=88=E8=BD=AF=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/CreateLayoutInput.cs | 24 ++++ .../ProductDesignLibraryService.cs | 119 +++++++++++++++--- 2 files changed, 128 insertions(+), 15 deletions(-) create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/Dto/CreateLayoutInput.cs diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/Dto/CreateLayoutInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/Dto/CreateLayoutInput.cs new file mode 100644 index 0000000..604a24f --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/Dto/CreateLayoutInput.cs @@ -0,0 +1,24 @@ +// 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.ProductDesignLibrary.Dto; +public class CreateLayoutInput +{ + public string ParentCode { get; set; } + public List Item { get; set; } + +} +public class Item +{ + public string ChildCode { get; set; } + public string Quantity { get; set; } +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/ProductDesignLibraryService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/ProductDesignLibraryService.cs index 8df489e..ccd3887 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/ProductDesignLibraryService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductDesignLibrary/ProductDesignLibraryService.cs @@ -6,6 +6,7 @@ using Admin.NET.Core; using Admin.NET.Core.Service; +using DocumentFormat.OpenXml.Wordprocessing; using Furion.DependencyInjection; using Furion.DynamicApiController; using Microsoft.AspNetCore.Authorization; @@ -21,6 +22,7 @@ using Vistar.Application.Const; using Vistar.Application.Entity; using Vistar.Application.SapService.Dto; using Vistar.Application.Service.ProductDesignLibrary.Dto; +using Vistar.Application.SolidWorksManageService.Dto; using Vistar.Application.Util; namespace Vistar.Application.Service.ProductDesignLibrary; @@ -39,6 +41,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient public Common.DataValidationService _dataValidationService; public SqlSugarRepository _obj122Rep; public SqlSugarRepository _obj121Rep; + public SolidWorksManageService.SolidWorksManageService _solidWorksManageService; public ProductDesignLibraryService( SqlSugarRepository obj137Rep, @@ -49,7 +52,8 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient SqlSugarRepository obj118Rep, DataValidationService dataValidationService, SqlSugarRepository obj122Rep, - SqlSugarRepository obj121Rep + SqlSugarRepository obj121Rep, + SolidWorksManageService.SolidWorksManageService solidWorksManageService ) { _obj137Rep = obj137Rep; @@ -61,6 +65,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient _dataValidationService = dataValidationService; _obj122Rep = obj122Rep; _obj121Rep = obj121Rep; + _solidWorksManageService = solidWorksManageService; } /// @@ -192,7 +197,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient .Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false && x._system_objConfigurationName == "默认" && !x.SWPDMFileName.Contains("SLDDRW")) .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 && (x.fld005577 != "不包含" || x.fld005577 == null)&&x.isSuppressed== false && x.inContext == false) + .Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext == false) .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().ToPagedListAsync(input.Page, input.PageSize); @@ -314,7 +319,8 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient .Where(it => it.idRecord == ParentData.idRecord) .ExecuteCommandAsync(); } - else { + else + { await _obj137Rep.AsUpdateable() .SetColumns(it => new Obj137 { @@ -326,7 +332,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient .Where(it => it.idRecord == ParentData.idRecord) .ExecuteCommandAsync(); } - + var msg = apiOutput.msg; if (apiOutput.msg == "") { @@ -379,7 +385,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient }); continue; } - if (input[i].fld005530 == "N" || input[i].fld005530=="D"|| input[i].fld005530 ==null) + if (input[i].fld005530 == "N" || input[i].fld005530 == "D" || input[i].fld005530 == null) { SapOutputList.Add(new SapOutput() { @@ -500,7 +506,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient continue; } } - + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); @@ -638,7 +644,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient if (!string.IsNullOrEmpty(ParentData.fld005686)) { var configidold = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 137 && x.ConfigSystemName == "SolidWorks").FirstAsync(); - var BomData = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configidold.ConfigID && x.ParentGuid == bomData[0].ParentGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(ParentData.fld005686) && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext==false).ToListAsync(); + var BomData = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configidold.ConfigID && x.ParentGuid == bomData[0].ParentGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(ParentData.fld005686) && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext == false).ToListAsync(); for (int i = 0; i < BomData.Count; i++) { @@ -786,10 +792,10 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient public async Task SyncToSAPProcessRoute(List input) { var ParentData = await _obj137Rep.AsQueryable() - .Where(x => - x.RecordGuid == input[0].ParentGuid - && x.deleted == false - && x.VersionIndex == input[0].ParentVersion + .Where(x => + x.RecordGuid == input[0].ParentGuid + && x.deleted == false + && x.VersionIndex == input[0].ParentVersion && x._system_objConfigurationName == "默认" && !x.SWPDMFileName.Contains("SLDDRW") && x.CheckedStatus == 0 @@ -900,10 +906,10 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient //查询需要同步的产品 var materialData = await _obj137Rep.AsQueryable() - .Where(x => - x.CheckedStatus == 0 - && x.deleted == false - && x.IsLatestVersion == true + .Where(x => + x.CheckedStatus == 0 + && x.deleted == false + && x.IsLatestVersion == true && x._system_objConfigurationName == "默认" && !x.SWPDMFileName.Contains("SLDDRW") && (x._SWPDM_1202_SW_____ != "不展开" || x._SWPDM_1202_SW_____ == null) @@ -1013,4 +1019,87 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient return sapOutputList; } + /// + /// 创建排版软件 + /// + /// + /// + public async Task CreateLayout(CreateLayoutInput input) + { + string output = ""; + if (string.IsNullOrEmpty(input.ParentCode)) + { + return "请输入父项编码"; + } + var parentData = await _obj137Rep.AsQueryable().Where(x => x._System_objNBS == input.ParentCode && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync(); + if (parentData != null) + { + return "未查询到父项编码"; + } + int lineNumber = 0; + foreach (var item in input.Item) + { + lineNumber ++; + string lineNumberStr = (lineNumber * 10).ToString("0000"); + var outputData = output+"子项编码"+item.ChildCode; + if (string.IsNullOrEmpty(item.ChildCode)|| string.IsNullOrEmpty(item.Quantity)) + { + outputData = outputData + "未输入必填项编码"; + continue; + } + var childData = await _obj122Rep.AsQueryable().Where(x => x._System_objNBS == item.ChildCode && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync(); + + if (childData != null) + { + output = outputData + "未查询到子项编码;"; + continue; + } + + var configurationData = await _configurationDataRep.AsQueryable().Where(x=> x.RecordImage!=null && x.ChildObjID ==112).FirstAsync(); + + var bomData = new ConfigurationData + { + ParentGuid = parentData.RecordGuid, + ChildGuid = childData.RecordGuid, + ChildObjID = 112, + ConfigId = 8, + childVersion = childData.VersionIndex, + ParentVersion = (int)parentData.VersionIndex, + isDeleted = false, + ChildConfigID = 0, + CreatedUserID = 2, + ModifiedUserID = 2, + CreatedDate = DateTime.Now, + ModifiedDate = DateTime.Now, + Quantity = item.Quantity.ToDouble(), + Description = parentData._System_ObjDescription, + EffectiveFrom = DateTime.Now, + EffectiveTo = DateTime.Now.AddYears(100), + Revision = "", + Marker = lineNumberStr, + Type = "正常", + OrderIndex = lineNumber, + PartNumber = childData._System_objNBS, + RecordImage = configurationData.RecordImage, + Folder = configurationData.Folder, + ParentObjectID = 137, + ChildSwFileType = 0, + ParentSwFileType = 1, + isSuppressed = false, + isAddedFromSW = true, + QtyManual = item.Quantity.ToDouble(), + SwConfiguration = "", + inContext = false, + PrimaryFile = "", + bKeepQuantityInSync = true, + BOMGuid = await _dataValidationService.GetGuid(), + IsPDMReference=false + }; + var addChildBomBom = await _configurationDataRep.AsInsertable(bomData).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId,x.childVersion, x.ParentVersion, x.isDeleted, x.ChildConfigID, x.CreatedUserID, x.ModifiedUserID, x.CreatedDate, x.ModifiedDate, x.Quantity, x.Description, x.EffectiveFrom, x.EffectiveTo, x.Revision, x.Marker, x.Type, x.OrderIndex, x.PartNumber, x.RecordImage, x.Folder, x.ParentObjectID, x.ChildSwFileType, x.ParentSwFileType, x.isSuppressed, x.isAddedFromSW, x.QtyManual, x.SwConfiguration, x.inContext, x.PrimaryFile, x.bKeepQuantityInSync, x.BOMGuid, x.IsPDMReference }).ExecuteReturnEntityAsync(); + + //var message = AddItemsInBomOutput.Message; + //output = outputData + message+";"; + } + return output; + } }