From b5ff162d60fa082ae6a68108b72ef1a3efcc9916 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 11 Sep 2023 16:22:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Draft=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8D=95=E6=AF=94=E5=AF=B9=20=E4=BF=AE=E6=94=B9=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=8A=B6=E6=80=81=E7=9A=84=E4=BF=9D=E5=AD=98=E3=80=81?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=92=8C=E8=AE=A2=E8=88=B1=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 133 ++++++++++++------ .../BookingOrder/BookingValueAddedService.cs | 4 +- .../BookingOrder/IBookingOrderService.cs | 2 +- .../TaskManagePlat/TaskDraftCompareService.cs | 8 +- .../ServiceWorkFlowManageService.cs | 51 +++++-- ServiceProjectSyncWin/Program.cs | 70 ++++++++- 6 files changed, 203 insertions(+), 65 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index acca5063..4961bcca 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -79,6 +79,8 @@ using System.Collections; using System.Security.Principal; using Myshipping.Core.Const; using ICSharpCode.SharpZipLib.BZip2; +using Furion.ClayObject; +using System.Dynamic; namespace Myshipping.Application { @@ -134,6 +136,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repextendstate; private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService; + private readonly IDjyUserConfigService _djyUserConfigService; const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING"; @@ -157,7 +160,7 @@ namespace Myshipping.Application SqlSugarRepository repTenant, SqlSugarRepository repBookingStatus, SqlSugarRepository bookingEDIExt, SqlSugarRepository serviceItem, SqlSugarRepository paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository djyWebsiteAccountConfigRepository, ISysOrgService orgService, SqlSugarRepository repLineOpMgrConfig, SqlSugarRepository repSysEmp, SqlSugarRepository repAutoYard, - IServiceWorkFlowManageService serviceWorkFlowManageService) + IServiceWorkFlowManageService serviceWorkFlowManageService, IDjyUserConfigService djyUserConfigService) { this._logger = logger; this._rep = rep; @@ -203,6 +206,7 @@ namespace Myshipping.Application this._repAutoYard = repAutoYard; this._repextendstate = repextendstate; _serviceWorkFlowManageService = serviceWorkFlowManageService; + _djyUserConfigService = djyUserConfigService; } #region 主表和箱信息 @@ -466,21 +470,38 @@ namespace Myshipping.Application var itgoodsStatus = new List(); var itconfigs = new List(); + //是否展示服务状态列表 + bool isUserShowGoodsStatus = true; + List statusList = new List(); + if (App.Configuration["ServiceStatusOpenAuto"] == "1") { - QueryServiceProjectWithStatusBatch batchQuery = new QueryServiceProjectWithStatusBatch + var djyUserCfg = _djyUserConfigService.Multi(new string[] { "booking_list_column" }) + .GetAwaiter().GetResult().FirstOrDefault(); + + if (djyUserCfg != null) { - BookingIds = bookingidlist.ToArray(), - QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_ALL, - TenantId = list.Items.FirstOrDefault().TenantId.Value - }; - var queryRlt = _serviceWorkFlowManageService.GetEnableStatusListByBusinessBatch(batchQuery) - .GetAwaiter().GetResult(); + //如果不存在goodsStatusList则不获取服务状态详情 + isUserShowGoodsStatus = !Regex.IsMatch(djyUserCfg.ConfigJson, "\\bfield\\b.*?\\bgoodsStatusList\\b"); + } - if (queryRlt.succ) + if (isUserShowGoodsStatus) { - statusList = JSON.Deserialize>(JSON.Serialize(queryRlt.ext)); + QueryServiceProjectWithStatusBatch batchQuery = new QueryServiceProjectWithStatusBatch + { + BookingIds = bookingidlist.ToArray(), + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_ALL, + TenantId = list.Items.FirstOrDefault().TenantId.Value + }; + + var queryRlt = _serviceWorkFlowManageService.GetEnableStatusListByBusinessBatch(batchQuery) + .GetAwaiter().GetResult(); + + if (queryRlt.succ) + { + statusList = JSON.Deserialize>(JSON.Serialize(queryRlt.ext)); + } } } else @@ -609,37 +630,53 @@ namespace Myshipping.Application if (App.Configuration["ServiceStatusOpenAuto"] == "1") { - var currStatusList = statusList.Where(a => long.Parse(a.BusiId) == item.Id).ToList(); - - if (currStatusList.Count > 0) + if (isUserShowGoodsStatus) { - if (currStatusList.Any(a => a.StatusSKUCode.Equals("YFVGM", StringComparison.OrdinalIgnoreCase) && a.IsYield)) - { - item.IsVGM = currStatusList.FirstOrDefault(a => - a.StatusSKUCode.Equals("YFVGM", StringComparison.OrdinalIgnoreCase) && a.IsYield).ActDate.Value; - } - if (currStatusList.Any(a => a.StatusSKUCode.Equals("YFCD", StringComparison.OrdinalIgnoreCase) && a.IsYield)) + var currStatusList = statusList.Where(a => long.Parse(a.BusiId) == item.Id).ToList(); + + if (currStatusList.Count > 0) { - item.IsCanDan = currStatusList.FirstOrDefault(a => - a.StatusSKUCode.Equals("YFCD", StringComparison.OrdinalIgnoreCase) && a.IsYield).ActDate.Value; + if (currStatusList.Any(a => a.StatusSKUCode.Equals("YFVGM", StringComparison.OrdinalIgnoreCase) && a.IsYield)) + { + var currSt = currStatusList.FirstOrDefault(a => + a.StatusSKUCode.Equals("YFVGM", StringComparison.OrdinalIgnoreCase) && a.IsYield); + + if (currSt != null && currSt.ActDate.HasValue) + item.IsVGM = currSt.ActDate.Value; + } + if (currStatusList.Any(a => a.StatusSKUCode.Equals("YFCD", StringComparison.OrdinalIgnoreCase) && a.IsYield)) + { + var currSt = currStatusList.FirstOrDefault(a => + a.StatusSKUCode.Equals("YFCD", StringComparison.OrdinalIgnoreCase) && a.IsYield); + + if (currSt != null && currSt.ActDate.HasValue) + item.IsCanDan = currSt.ActDate.Value; + } + if (currStatusList.Any(a => a.StatusSKUCode.Equals("ZZFX", StringComparison.OrdinalIgnoreCase) && a.IsYield)) + { + var currSt = currStatusList.FirstOrDefault(a => + a.StatusSKUCode.Equals("ZZFX", StringComparison.OrdinalIgnoreCase) && a.IsYield); + + if (currSt != null && currSt.ActDate.HasValue) + item.IsZZFX = currSt.ActDate.Value; + } + + item.GoodsStatusList = currStatusList.OrderBy(a => a.CalcSortNo) + .Select(a => new GoodsStatusList + { + FinishTime = a.ActDate, + IsLast = a.IsEnd, + Sort = a.ActSortNo, + StatusName = a.ShowName, + SystemCode = a.StatusSKUCode, + ExtData = !string.IsNullOrWhiteSpace(a.ActVal) ? a.ActVal : string.Empty, + Remark = !string.IsNullOrWhiteSpace(a.ActRemark) ? a.ActRemark : string.Empty + }).ToList(); } - if (currStatusList.Any(a => a.StatusSKUCode.Equals("ZZFX", StringComparison.OrdinalIgnoreCase) && a.IsYield)) + else { - item.IsZZFX = currStatusList.FirstOrDefault(a => - a.StatusSKUCode.Equals("ZZFX", StringComparison.OrdinalIgnoreCase) && a.IsYield).ActDate.Value; + item.GoodsStatusList = new List(); } - - item.GoodsStatusList = currStatusList.OrderBy(a => a.CalcSortNo) - .Select(a => new GoodsStatusList - { - FinishTime = a.ActDate, - IsLast = a.IsEnd, - Sort = a.ActSortNo, - StatusName = a.ShowName, - SystemCode = a.StatusSKUCode, - ExtData = !string.IsNullOrWhiteSpace(a.ActVal) ? a.ActVal : string.Empty, - Remark = !string.IsNullOrWhiteSpace(a.ActRemark) ? a.ActRemark : string.Empty - }).ToList(); } else { @@ -9218,8 +9255,10 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 if (statusList != null) { var maxStatus = statusList.Where(a => a.IsYield) - .OrderByDescending(a=>a.WFSortNo) - .ThenByDescending(a => a.CalcSortNo).FirstOrDefault(); + //.OrderByDescending(a=>a.WFSortNo) + //.ThenByDescending(a => a.CalcSortNo) + .OrderByDescending(a => a.SortNo) + .FirstOrDefault(); if (maxStatus != null) { @@ -9227,7 +9266,7 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 .First(a => a.Id == bookingId); model.BSSTATUSNAME = maxStatus.ShowName; - model.VERSION = IDGen.NextID().ToString().Replace("-", ""); + //model.VERSION = IDGen.NextID().ToString().Replace("-", ""); //更新订舱 _rep.AsUpdateable(model) @@ -9311,8 +9350,10 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 if (statusList != null) { var maxStatus = statusList.Where(a => a.IsYield) - .OrderByDescending(a => a.WFSortNo) - .ThenByDescending(a => a.CalcSortNo).FirstOrDefault(); + //.OrderByDescending(a => a.WFSortNo) + //.ThenByDescending(a => a.CalcSortNo) + .OrderByDescending(a => a.SortNo) + .FirstOrDefault(); var model = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); @@ -9326,7 +9367,7 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 model.BSSTATUSNAME = string.Empty; } - model.VERSION = IDGen.NextID().ToString().Replace("-", ""); + //model.VERSION = IDGen.NextID().ToString().Replace("-", ""); //更新订舱 _rep.AsUpdateable(model) @@ -9352,7 +9393,7 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 /// /// 是否默认同步东胜 true-自动同步 false-不自动同步 /// - public async Task SetBookingOrderGoodsStatus(long bookingId, bool isAutoSyncDS = false) + public async Task SetBookingGoodsStatus(long bookingId, bool isAutoSyncDS = false) { var bookingOrder = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); @@ -9373,8 +9414,10 @@ HLCUTA12307DPXJ3 以这票为例 6个柜 if (statusList != null) { var maxStatus = statusList.Where(a => a.IsYield) - .OrderByDescending(a => a.WFSortNo) - .ThenByDescending(a => a.CalcSortNo).FirstOrDefault(); + //.OrderByDescending(a => a.WFSortNo) + //.ThenByDescending(a => a.CalcSortNo) + .OrderByDescending(a=>a.SortNo) + .FirstOrDefault(); var model = _rep.AsQueryable().Filter(null, true) .First(a => a.Id == bookingId); diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index 3c274e4b..63566699 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2309,7 +2309,7 @@ namespace Myshipping.Application result.succ = true; result.msg = "推送成功"; - await _bookingOrderService.SetBookingOrderGoodsStatus(bookingOrder.Id, true); + await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true); } } @@ -2403,7 +2403,7 @@ namespace Myshipping.Application result.succ = true; result.msg = "推送成功"; - await _bookingOrderService.SetBookingOrderGoodsStatus(bookingOrder.Id, true); + await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true); } } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index ff05aec4..3f74b52d 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -107,6 +107,6 @@ namespace Myshipping.Application /// /// 是否默认同步东胜 true-自动同步 false-不自动同步 /// - Task SetBookingOrderGoodsStatus(long bookingId, bool isAutoSyncDS = false); + Task SetBookingGoodsStatus(long bookingId, bool isAutoSyncDS = false); } } \ No newline at end of file diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs index 3ceea975..e0819be4 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskDraftCompareService.cs @@ -240,7 +240,8 @@ namespace Myshipping.Application var bookFilePath = await FileAttachHelper.MoveFile(bookingOrder.Id.ToString(), fileFullName, batchNo); //将格式单附件写入订舱的附件 - await SaveEDIFile(bookingOrder.Id, bookFilePath, new System.IO.FileInfo(fileFullName).Name, CONST_DRAFT_FILE_CODE, CONST_DRAFT_FILE_NAME); + await SaveEDIFile(bookingOrder.Id, bookFilePath, new System.IO.FileInfo(fileFullName).Name, entity.TenantId.Value, + CONST_DRAFT_FILE_CODE, CONST_DRAFT_FILE_NAME); result = compareResult; } @@ -396,11 +397,13 @@ namespace Myshipping.Application /// 订舱ID /// 文件路径 /// 文件名 + /// 租户ID /// 附件类型代码 /// 附件类型名称 /// [NonAction] - private async Task SaveEDIFile(long boookId, string FilePath, string fileName, string fileTypeCode = "bc", string fileTypeName = "Booking Confirmation") + private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId, + string fileTypeCode = "bc", string fileTypeName = "Booking Confirmation") { /* 直接将附件信息写入附件表 @@ -414,6 +417,7 @@ namespace Myshipping.Application TypeCode = fileTypeCode, TypeName = fileTypeName, BookingId = boookId, + TenantId = tenantId }; await _bookingFileRepository.InsertAsync(bookFile); diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index 8ee69885..ac90cb99 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -2003,6 +2003,17 @@ namespace Myshipping.Application int lastWFSortNo = 0; int calcNum = 1; + var allStatus = statuList.SelectMany(b => { + var curArg = b.StatusList.SelectMany(x => x.SubStatusList).ToList(); + + if (curArg == null) + curArg = new List(); + + curArg.AddRange(b.StatusList); + + return curArg; + }).ToList(); + var resultList = statuList.Join(runList, l => l.WFPKId, r => r.WFPKId, (l, r) => { @@ -2025,6 +2036,7 @@ namespace Myshipping.Application ActRemark = b.ActRemark, WFSortNo = l.SortNo, CalcSortNo = (decimal)b.ActSortNo, + SortNo = b.SortNo }); if(b.SubStatusList != null && b.SubStatusList.Count > 0) @@ -2038,7 +2050,8 @@ namespace Myshipping.Application StatusSKUCode = c.StatusSKUCode, ActRemark = c.ActRemark, WFSortNo = l.SortNo, - CalcSortNo = (decimal)b.ActSortNo + (c.ActSortNo * 0.001m) + CalcSortNo = (decimal)b.ActSortNo + (c.ActSortNo * 0.001m), + SortNo = c.SortNo }).ToList()); } }); @@ -2046,6 +2059,8 @@ namespace Myshipping.Application else { runInfo.ActivitiesList.ForEach(b => { + var pSkuInfo = allStatus.FirstOrDefault(x => x.SkuPKId == b.StatusSKUId); + rltList.Add(new ServiceProjectStatusDto { ActPKId = b.ActId, @@ -2057,24 +2072,32 @@ namespace Myshipping.Application StatusSKUCode = b.StatusSKUCode, ActRemark = b.ActRemark, WFSortNo = l.SortNo, - CalcSortNo = (decimal)b.ExecSortNo + CalcSortNo = (decimal)b.ExecSortNo, + SortNo = pSkuInfo != null? pSkuInfo.SortNo:0, }); if (b.SubList != null && b.SubList.Count > 0) { - rltList.AddRange(b.SubList.Select(c => new ServiceProjectStatusDto + b.SubList.ForEach(c => { - ActPKId = c.ActId, - ActSortNo = c.ExecSortNo, - ShowName = c.ShowName, - IsYield = c.IsYield == 1 ? true : false, - ActDate = c.ActDate, - ActVal = c.ActVal, - StatusSKUCode = c.StatusSKUCode, - ActRemark = c.ActRemark, - WFSortNo = l.SortNo, - CalcSortNo = (decimal)b.ExecSortNo + (c.ExecSortNo * 0.001m) - }).ToList()); + var subSkuInfo = allStatus.FirstOrDefault(x => x.SkuPKId == c.StatusSKUId); + + rltList.Add(new ServiceProjectStatusDto + { + ActPKId = c.ActId, + ActSortNo = c.ExecSortNo, + ShowName = c.ShowName, + IsYield = c.IsYield == 1 ? true : false, + ActDate = c.ActDate, + ActVal = c.ActVal, + StatusSKUCode = c.StatusSKUCode, + ActRemark = c.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = (decimal)b.ExecSortNo + (c.ExecSortNo * 0.001m), + SortNo = subSkuInfo.SortNo + }); + }); + } }); } diff --git a/ServiceProjectSyncWin/Program.cs b/ServiceProjectSyncWin/Program.cs index fcde72da..06268493 100644 --- a/ServiceProjectSyncWin/Program.cs +++ b/ServiceProjectSyncWin/Program.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging; using ServiceProjectSyncWin; using SqlSugar; using System.Text; +using System.Text.RegularExpressions; using static System.Net.Mime.MediaTypeNames; Serve.RunGeneric(additional: services => @@ -23,13 +24,18 @@ Serve.RunGeneric(additional: services => Console.WriteLine("开始准备同步历史服务状态数据"); var service1 = App.GetService(); -service1.SyncServiceProjectRecord(); +//service1.SyncServiceProjectRecord(); +service1.SyncServiceProjectRecord2(); Console.ReadKey(); public interface ISyncHisRecord { void SyncServiceProjectRecord(); + + void SyncServiceProjectRecord2(); + + //void SyncServiceProjectRecord3(); } public class SyncHisRecord: ISyncHisRecord,ITransient @@ -350,4 +356,66 @@ public class SyncHisRecord: ISyncHisRecord,ITransient return model; } + + + public void SyncServiceProjectRecord2() + { + /* + string fmt = "(16)PortofDischarge(17)PlaceofDelivery"; + + var fmtList = fmt.Select(a => a).ToList(); + + string name = "(1P6)E PNorAt oNf GDi,scMhaArgLeA YSIA P(1E7)N PAlaNceG o,f DMeAlivLerAy YSIA"; + + List array = new List(); + List array2 = new List(); + + for (var i=0;i< name.Length;i++) + { + bool isExists = false; + + if(fmtList.Count > 0) + { + if (name[i] == fmtList.First()) + { + array.Add(name[i]); + + fmtList.Remove(fmtList[0]); + + isExists = true; + } + } + + if (!isExists) + array2.Add(name[i]); + } + + string s1 = string.Join("", array); + string s2 = string.Join("", array2); + */ + + string Consignee = "LOT 13/3,KAWASAN PERINDUSTRIAN, K AMPUNG KOLAM PADANG BESAR,02100 P ADANG BESAR,PERLIS. T EL;04-949 0507 FAX 94-949 2888"; + + string NotifyParty = "SHUN EE TRADING SDN BHD (1183208 U) LOT 13/3,KAWASAN PERINDUSTRIAN, K AMPUNG KOLAM PADANG BESAR,02100 P ADANG BESAR,PERLIS. T EL;04-949 0507 FAX 94-949 2888"; + + if (Regex.IsMatch(Consignee, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b")) + { + Consignee = Regex.Replace(Consignee, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "\\s+", "")); + } + + if (Regex.IsMatch(NotifyParty, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b")) + { + NotifyParty = Regex.Replace(NotifyParty, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "\\s+", "")); + } + + decimal similarity = 100; + + for (int i = 0; i < NotifyParty.Length; i++) + { + + } + + } + + } \ No newline at end of file