From 43ea52026b19786c6e77a419b3ec19885a43aee6 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Tue, 11 Jul 2023 14:01:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E5=9C=BA=E7=AB=99=E7=AE=B1=E5=B0=81=E5=8F=B7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 229 +++++------------- .../BookingOrder/Dto/BookingYardData.cs | 137 +++++++++++ 2 files changed, 203 insertions(+), 163 deletions(-) create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/BookingYardData.cs diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index f6495737..2afa6ae7 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -7563,7 +7563,19 @@ namespace Myshipping.Application throw Oops.Bah("请先选择场站"); } - var rtn = await YardDataHelper.GetYardData(UserManager.UserId, order.TenantId.Value, order.TenantName, order.MBLNO, order.YARDID, isWeb); + var listRtn = await GetYardDataAndMappingSystem(order, isWeb); + + return listRtn.ToJsonString(); + } + + /// + /// 从爬虫获取场站数据,并映射为系统中的箱型 + /// + /// + private async Task> GetYardDataAndMappingSystem(BookingOrder order, bool isWeb = false) + { + + var rtn = await YardDataHelper.GetYardData(App.User.FindFirst(ClaimConst.CLAINM_USERID) == null ? order.CreatedUserId.Value : UserManager.UserId, order.TenantId.Value, order.TenantName, order.MBLNO, order.YARDID, isWeb); if (!rtn.Key) { throw Oops.Bah(rtn.Value); @@ -7573,23 +7585,24 @@ namespace Myshipping.Application var ctnList = await _cache.GetAllCodeCtn(); var mapCtn = await _cache.GetAllMappingCtn(); - var jData = JArray.Parse(rtn.Value); - foreach (JObject item in jData) + var listRtn = JsonConvert.DeserializeObject>(rtn.Value); + + foreach (var item in listRtn) { - var ctnall = item.GetStringValue("CTNALL"); + var ctnall = item.CTNALL; var findMap = mapCtn.FirstOrDefault(x => x.Module == "YardData" && x.MapCode == ctnall); var findCtn = ctnList.FirstOrDefault(x => x.Name == ctnall); if (findMap != null) { - item.Add("CtnCode", findMap.Code); + item.CtnCode = findMap.Code; findCtn = ctnList.First(c => c.Code == findMap.Code); - item["CTNALL"] = findCtn.Name; //名称显示维护的箱型 + item.CTNALL = findCtn.Name; //名称显示维护的箱型 } else if (findCtn != null) { - item.Add("CtnCode", findCtn.Code); - item["CTNALL"] = findCtn.Name; //名称显示维护的箱型 + item.CtnCode = findCtn.Code; + item.CTNALL = findCtn.Name; //名称显示维护的箱型 } else { @@ -7597,7 +7610,48 @@ namespace Myshipping.Application } } - return jData.ToString(); + return listRtn; + } + + /// + /// 自动引入场站箱型箱量数据 + /// + /// + /// + private async Task AutoYardData(long bookId) + { + var order = _rep.AsQueryable().Filter(null, true).First(x => x.Id == bookId); + var ctns = _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == bookId).ToList(); + if (ctns.Count(x => !string.IsNullOrEmpty(x.CNTRNO) || !string.IsNullOrEmpty(x.SEALNO)) > 0) //有数据填写了箱封号,不再处理 + { + _logger.LogInformation($"{bookId}({order.MBLNO})的数据已填写过箱封号,不再处理自动引入"); + return; + } + + var rtn = await GetYardDataAndMappingSystem(order, false); + await _repCtn.DeleteAsync(x => x.BILLID == bookId); + + foreach (var item in rtn) + { + var ctn = new BookingCtn(); + ctn.BILLID = order.Id; + ctn.CTNCODE = item.CtnCode; + ctn.CTNALL = item.CTNALL; + ctn.CTNNUM = item.XiangLiang; + ctn.CNTRNO = item.CNTRNO; + ctn.SEALNO = item.SEALNO; + ctn.KINDPKGS = string.IsNullOrEmpty(item.KINDPKGS) ? order.KINDPKGS : item.KINDPKGS; + ctn.PKGS = item.PKGS; + ctn.KGS = Convert.ToDecimal(item.KGS); + ctn.CBM = Convert.ToDecimal(item.CBM); + ctn.TAREWEIGHT = Convert.ToDecimal(item.TAREWEIGHT); + ctn.TenantId = order.TenantId; + ctn.CreatedUserId = order.CreatedUserId; + ctn.CreatedUserName = "系统"; + await _repCtn.InsertAsync(ctn); + } + + } /// @@ -8310,162 +8364,11 @@ namespace Myshipping.Application "} "; } - [HttpGet("/BookingOrder/XHZGLJ"), AllowAnonymous] - public async Task XHZGLJ(long bookId = 432917132775494) + [HttpGet("/BookingOrder/AutoYard"), AllowAnonymous] + public async Task AutoYard(long bookId = 437779259732037) { - var order = _rep.AsQueryable().Filter(null, true).First(x => x.Id == bookId); - var ctns = _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == bookId).ToList(); - MemoryStream ms = new MemoryStream(File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XhzGlj.xls"))); - var workbook = new HSSFWorkbook(ms); - FileStream fs = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XhzGlj_1.xls"), FileMode.Create); - var sheet = workbook.GetSheetAt(0); - - //第一行标题 - var title = $"下货纸清单-{order.LANENAME} SERVICE"; - sheet.GetRow(0).GetCell(0).SetCellValue(title); - - //船期B2 - sheet.GetRow(1).GetCell(1).SetCellValue(order.ETD.HasValue ? order.ETD.Value.ToString("yyyy.MM.dd") : ""); - - //船名B3 - sheet.GetRow(2).GetCell(1).SetCellValue(order.VESSEL); - - //航次F3 - sheet.GetRow(2).GetCell(5).SetCellValue(order.VOYNO); - - //代理B4 - sheet.GetRow(3).GetCell(1).SetCellValue(order.TenantName); - - //联系电话F4 - var usr = _repUser.AsQueryable().Filter(null, true).First(u => u.Id == order.CreatedUserId); - if (!string.IsNullOrEmpty(usr.Tel)) - { - sheet.GetRow(3).GetCell(5).SetCellValue(usr.Tel); - } - else if (!string.IsNullOrEmpty(usr.Phone)) - { - sheet.GetRow(3).GetCell(5).SetCellValue(usr.Phone); - } - else - { - sheet.GetRow(3).GetCell(5).SetCellValue(""); - } - - //订舱号B7 - sheet.GetRow(6).GetCell(1).SetCellValue(order.CUSTNO); - - //目的港C7 - sheet.GetRow(6).GetCell(2).SetCellValue(order.PORTDISCHARGE); - - //中转港D7 - sheet.GetRow(6).GetCell(3).SetCellValue(""); - - //货名E7 - sheet.GetRow(6).GetCell(4).SetCellValue(order.DESCRIPTION); - - //件数F7 - sheet.GetRow(6).GetCell(5).SetCellValue(order.PKGS.Value.ToString()); - - //重量G7 - sheet.GetRow(6).GetCell(6).SetCellValue(Convert.ToDouble(order.KGS.Value).ToString()); - - //尺码H7 - sheet.GetRow(6).GetCell(7).SetCellValue(Convert.ToDouble(order.CBM.Value).ToString()); - - //冻柜信息 温度C I7 - if (order.CARGOID == "R") - { - sheet.GetRow(6).GetCell(8).SetCellValue(order.TEMPSET); - } - else - { - sheet.GetRow(6).GetCell(8).SetCellValue(""); - } - - //冻柜信息 通风CBM/H J7 - if (order.CARGOID == "R") - { - sheet.GetRow(6).GetCell(9).SetCellValue(order.REEFERF); - } - else - { - sheet.GetRow(6).GetCell(9).SetCellValue(""); - } - - //冻柜信息 湿度% K7 - if (order.CARGOID == "R") - { - sheet.GetRow(6).GetCell(10).SetCellValue(order.HUMIDITY); - } - else - { - sheet.GetRow(6).GetCell(10).SetCellValue(""); - } - - //整理箱型箱量 - var groupList = ctns.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => new { CTNALL = g.Key.Replace("'", ""), CTNNUM = g.Sum(gg => gg.CTNNUM) }); - - //箱量 20GP L7 - var findCtn = groupList.FirstOrDefault(x => x.CTNALL == "20GP"); - if (findCtn != null) - { - sheet.GetRow(6).GetCell(11).SetCellValue(findCtn.CTNNUM.Value.ToString()); - } - else - { - sheet.GetRow(6).GetCell(11).SetCellValue(""); - } - - //箱量 40GP M7 - findCtn = groupList.FirstOrDefault(x => x.CTNALL == "40GP"); - if (findCtn != null) - { - sheet.GetRow(6).GetCell(12).SetCellValue(findCtn.CTNNUM.Value.ToString()); - } - else - { - sheet.GetRow(6).GetCell(12).SetCellValue(""); - } - - //箱量 40HC N7 - findCtn = groupList.FirstOrDefault(x => x.CTNALL == "40HC"); - if (findCtn != null) - { - sheet.GetRow(6).GetCell(13).SetCellValue(findCtn.CTNNUM.Value.ToString()); - } - else - { - sheet.GetRow(6).GetCell(13).SetCellValue(""); - } - - //箱量 20RF O7 - findCtn = groupList.FirstOrDefault(x => x.CTNALL == "20RF"); - if (findCtn != null) - { - sheet.GetRow(6).GetCell(14).SetCellValue(findCtn.CTNNUM.Value.ToString()); - } - else - { - sheet.GetRow(6).GetCell(14).SetCellValue(""); - } - - //箱量 40RH P7 - findCtn = groupList.FirstOrDefault(x => x.CTNALL == "40RH"); - if (findCtn != null) - { - sheet.GetRow(6).GetCell(15).SetCellValue(findCtn.CTNNUM.Value.ToString()); - } - else - { - sheet.GetRow(6).GetCell(15).SetCellValue(""); - } - - //备注 场站/特殊要求 Q7 - sheet.GetRow(6).GetCell(16).SetCellValue(order.YARDREMARK); + await AutoYardData(bookId); - workbook.Write(fs); - fs.Flush(); - fs.Close(); } #endregion diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingYardData.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingYardData.cs new file mode 100644 index 00000000..6b82920d --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingYardData.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Service.BookingOrder.Dto +{ + public class BookingYardDataRtn + { + /// + /// 箱号 + /// + public string CNTRNO { get; set; } + /// + /// 封号 + /// + public string SEALNO { get; set; } + /// + /// 箱型 + /// + public string CTNALL { get; set; } + /// + /// 箱量 + /// + public int XiangLiang { get; set; } + /// + /// 船名 + /// + public string VESSEL { get; set; } + /// + /// 航次 + /// + public string VOYNO { get; set; } + /// + /// 中转港 + /// + public string tra_name { get; set; } + /// + /// 卸货港 + /// + public string pod_name { get; set; } + /// + /// 目的港 + /// + public string Destination { get; set; } + /// + /// 皮重 + /// + public float? TAREWEIGHT { get; set; } + /// + /// 车号 + /// + public string CheHao { get; set; } + /// + /// 包装 + /// + public string KINDPKGS { get; set; } + /// + /// 件数 + /// + public int PKGS { get; set; } + /// + /// 尺码 + /// + public float? CBM { get; set; } + /// + /// 货重 + /// + public float? KGS { get; set; } + /// + /// 提箱时间 + /// + public string TiXiangShiJian { get; set; } + /// + /// 返场时间 + /// + public string FanChangShiJian { get; set; } + /// + /// 集港时间 + /// + public string JiGangShiJian { get; set; } + /// + /// 计划集港开始时间 + /// + public string PortStartPlanTime { get; set; } + /// + /// 计划集港结束时间 + /// + public string PortEndPlanTime { get; set; } + /// + /// 完船时间 + /// + public string WanChuanShiJian { get; set; } + /// + /// 危险品主等级 + /// + public string DClass { get; set; } + /// + /// 危险品编号 + /// + public string DUNNo { get; set; } + /// + /// 危险品副等级 + /// + public string FuDClass { get; set; } + /// + /// 危险品副编号 + /// + public string FuDUNNo { get; set; } + /// + /// 海污 + /// + public string HaiWu { get; set; } + /// + /// 温度 + /// + public string TempSet { get; set; } + /// + /// 通风 + /// + public string Reeferf { get; set; } + /// + /// 湿度 + /// + public string Humidity { get; set; } + + } + + public class BookingGetYardDataDto: BookingYardDataRtn + { + /// + /// 箱型代码 + /// + public string CtnCode { get; set; } + } +} From ad194c37e8abe37f7a2cc124b3ee8d87f1eaec7a Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Tue, 11 Jul 2023 16:30:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=AE=B1=E5=8F=B7?= =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 742eb489..7a865400 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1006,7 +1006,7 @@ namespace Myshipping.Application return ordOut; } - + /// /// 在订舱台账保存单证备注、操作备注等功能 @@ -1029,12 +1029,14 @@ namespace Myshipping.Application throw Oops.Bah("无权修改"); } + var orderCompare = await _rep.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == model.Id); + model.Adapt(order); order.VERSION = Guid.NewGuid().ToString(); await _rep.UpdateAsync(order); - //todo:记录修改日志,等待抽取方法 - + //记录修改日志 + await SaveLog(order, orderCompare); } /// @@ -2164,13 +2166,13 @@ namespace Myshipping.Application public async Task LetteryardSave(UpdateBookingLetteryardInput input) { long rtnId = 0; - + if (input.Id == 0) { var entity = input.Adapt(); await _repLetterYard.InsertAsync(entity); rtnId = entity.Id; - + } else { @@ -2178,7 +2180,7 @@ namespace Myshipping.Application input.Adapt(entity); await _repLetterYard.UpdateAsync(entity); rtnId = entity.Id; - + } var order = _rep.FirstOrDefault(x => x.Id == input.BookingId); @@ -2197,7 +2199,7 @@ namespace Myshipping.Application await VgmLink(input.BookingId); } - await SendLetterYard(input.BookingId); + await SendLetterYard(input.BookingId); return rtnId; } @@ -2205,10 +2207,10 @@ namespace Myshipping.Application /// 放舱推送东胜 /// /// - public async Task SendLetterYard(long bookingId) + public async Task SendLetterYard(long bookingId) { - var entity= _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId); - var json = entity.ToJsonString(); + var entity = _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId); + var json = entity.ToJsonString(); try { const string MqActionExchangeName = "djy.output.dingcang.ds6"; @@ -7585,6 +7587,14 @@ namespace Myshipping.Application private async Task AutoYardData(long bookId) { var order = _rep.AsQueryable().Filter(null, true).First(x => x.Id == bookId); + + var paraAuto = _cache.GetAllTenantParam().Result.FirstOrDefault(x => x.TenantId == order.TenantId && x.ParaCode == "AUTO_CNTRNO_SEALNO_IMPORT"); + if (paraAuto == null || paraAuto.ItemCode != "YES") + { + _logger.LogInformation($"{order.TenantName}未开启自动箱号引入"); + return; + } + var ctns = _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == bookId).ToList(); if (ctns.Count(x => !string.IsNullOrEmpty(x.CNTRNO) || !string.IsNullOrEmpty(x.SEALNO)) > 0) //有数据填写了箱封号,不再处理 { From 4091b9309ddad37f9a81a21dd1d1d8f3dba48d41 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 11 Jul 2023 16:35:08 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=8E=A8=E9=80=81=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TrackingMessageInfo.cs | 25 ----- .../ServiceWorkFlowBaseService.cs | 101 +++++++++++------- .../ServiceWorkFlowManageService.cs | 39 +++---- 3 files changed, 82 insertions(+), 83 deletions(-) diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs index 3aa95c23..e41ef045 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs @@ -138,31 +138,6 @@ namespace Myshipping.Application /// public string RecvUserName { get; set; } - /// - /// 任务对应接收操作人ID(大简云账户体系) - /// - public string DJYRecvUserId { get; set; } - - /// - /// 任务对应接收操作人名称(大简云账户体系) - /// - public string DJYRecvUserName { get; set; } - - /// - /// 任务对应接收操作人邮箱(大简云账户体系) - /// - public string DJYRecvUserEmail { get; set; } - - /// - /// 任务对应部门代码(大简云账户体系) - /// - public string DJYTaskOrgCode { get; set; } - - /// - /// 任务对应部门名称(大简云账户体系) - /// - public string DJYTaskOrgName { get; set; } - /// /// 状态列表 /// diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index 3d06539c..c68f4372 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -261,9 +261,28 @@ namespace Myshipping.Application entity.UpdatedTime = DateTime.Now; entity.UpdatedUserId = UserManager.UserId; entity.UpdatedUserName = UserManager.Name; + + if (!isSetEnable) + { + entity.IS_ENABLE = model.IS_ENABLE; + } + + entity.IS_LOCK = model.IS_LOCK; + + if (string.IsNullOrWhiteSpace(model.DEVELOP_VERSION)) + { + if(!string.IsNullOrWhiteSpace(model.RELEASE_VERSION)) + { + entity.DEVELOP_VERSION = "DEVELOP"; + } + } + else + { + entity.DEVELOP_VERSION = model.DEVELOP_VERSION; + + } - if(string.IsNullOrWhiteSpace(model.DEVELOP_VERSION) && !string.IsNullOrWhiteSpace(model.RELEASE_VERSION)) - entity.DEVELOP_VERSION = "DEVELOP"; + currVersion = entity.DEVELOP_VERSION; if (info.StatusSkuList != null && info.StatusSkuList.Count > 0) { @@ -290,7 +309,7 @@ namespace Myshipping.Application it.IS_LOCK }).ExecuteCommandAsync(); - currVersion = model.DEVELOP_VERSION; + currVersion = entity.DEVELOP_VERSION; //批量删除服务流程与服务项目关系(物理删除) _serviceWorkFlowProjectRelationRepository.EntityContext.Deleteable() @@ -529,16 +548,18 @@ namespace Myshipping.Application 1、通过服务活动ID获取所有关联的服务流程详情列表 2、轮询服务流程列表,组织详细的服务流程列表 */ - var activitiesList = _serviceWorkFlowActivitiesRelationRepository.AsQueryable() - .LeftJoin((rela, wf) => rela.SERVICE_WORKFLOW_ID == wf.PK_ID) + var activitiesList = _serviceWorkFlowActivitiesRelationRepository.AsQueryable().Filter(null, true) + .LeftJoin((rela, wf) => rela.SERVICE_WORKFLOW_ID == wf.PK_ID + && rela.WF_VERSION == wf.RELEASE_VERSION) .Where((rela,wf) => activitiesArgs.Contains(rela.SERVICE_ACTIVITIES_ID) - && !wf.IsDeleted && wf.IS_ENABLE == 1 && !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION)) + && !wf.IsDeleted && wf.IS_ENABLE == 1) .Select((rela, wf) => wf).Distinct().ToList(); - var subActList = _serviceWorkFlowActivitiesSubRelationRepository.AsQueryable() - .LeftJoin((rela, wf) => rela.SERVICE_WORKFLOW_ID == wf.PK_ID) + var subActList = _serviceWorkFlowActivitiesSubRelationRepository.AsQueryable().Filter(null, true) + .LeftJoin((rela, wf) => rela.SERVICE_WORKFLOW_ID == wf.PK_ID + && rela.WF_VERSION == wf.RELEASE_VERSION) .Where((rela, wf) => activitiesArgs.Contains(rela.SUB_SERVICE_ACTIVITIES_ID) - && !wf.IsDeleted && wf.IS_ENABLE == 1 && !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION)) + && !wf.IsDeleted && wf.IS_ENABLE == 1) .Select((rela, wf) => wf).Distinct().ToList(); if(subActList.Count > 0) @@ -558,41 +579,41 @@ namespace Myshipping.Application var wfArg = activitiesList.Select(a => a.PK_ID).ToArray(); var mergeList = - _serviceWorkFlowBaseRepository.AsQueryable() + _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) .LeftJoin((wf, rela) => wf.PK_ID == rela.SERVICE_WORKFLOW_ID - && wf.RELEASE_VERSION == rela.WF_VERSION) - .Where(wf => wfArg.Contains(wf.PK_ID)) - .Select((wf, rela) => new { WF = wf, Rela = rela }) - .LeftJoin((rela, act) => - rela.Rela.SERVICE_ACTIVITIES_ID == act.PK_ID) - .LeftJoin((rela, act, sku) => + && wf.RELEASE_VERSION == rela.WF_VERSION) + .LeftJoin((wf,rela, act) => + rela.SERVICE_ACTIVITIES_ID == act.PK_ID && wf.RELEASE_VERSION == rela.WF_VERSION) + .LeftJoin((wf,rela, act, sku) => act.STATUS_SKU_ID == sku.PK_ID) - .Select((rela, act, sku) => - new { WF = rela.WF, Act = act, Sku = sku, SortNo = rela.Rela.SORT_NO, IsSub = rela.Rela.IS_CONTAINS_SUB, ValType = rela.Rela.VAL_TYPE }) + .Where((wf) => wfArg.Contains(wf.PK_ID)) + .Select((wf,rela, act, sku) => + new { WF = wf, Act = act, Sku = sku, SortNo = rela.SORT_NO, IsSub = rela.IS_CONTAINS_SUB, ValType = rela.VAL_TYPE }) .ToList(); + var mergeSubList = - _serviceWorkFlowBaseRepository.AsQueryable() + _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) .LeftJoin((wf, rela) => wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION) - .Where(wf => wfArg.Contains(wf.PK_ID)) - .Select((wf, rela) => new { WF = wf, Rela = rela }) - .LeftJoin((rela, act) => - rela.Rela.SUB_SERVICE_ACTIVITIES_ID == act.PK_ID) - .LeftJoin((rela, act, sku) => + .LeftJoin((wf, rela, act) => + rela.SUB_SERVICE_ACTIVITIES_ID == act.PK_ID && wf.RELEASE_VERSION == rela.WF_VERSION) + .LeftJoin((wf, rela, act, sku) => act.STATUS_SKU_ID == sku.PK_ID) - .Select((rela, act, sku) => - new { WF = rela.WF, Act = act, Sku = sku, SortNo = rela.Rela.SORT_NO, ParentId = rela.Rela.SERVICE_ACTIVITIES_ID, ValType = rela.Rela.VAL_TYPE }) + .Where((wf) => wfArg.Contains(wf.PK_ID)) + .Select((wf,rela, act, sku) => + new { WF = wf, Act = act, Sku = sku, SortNo = rela.SORT_NO, ParentId = rela.SERVICE_ACTIVITIES_ID, ValType = rela.VAL_TYPE }) .ToList(); - var prjectList = _serviceWorkFlowBaseRepository.AsQueryable() + var prjectList = + _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) .LeftJoin((wf, rela) => wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION) - .Select((wf,rela)=> new { WF = wf, Rela = rela }) - .LeftJoin((rela, prj) => - rela.Rela.SERVICE_PROJECT_ID == prj.PK_ID) - .Select((rela, prj) => new{ WF = rela.WF, Rela = rela.Rela,Prj = prj }).ToList(); + .LeftJoin((wf,rela, prj) => + rela.SERVICE_PROJECT_ID == prj.PK_ID) + .Where((wf) => wfArg.Contains(wf.PK_ID)) + .Select((wf,rela, prj) => new{ WF = wf, Rela = rela,Prj = prj }).ToList(); var list = mergeList.GroupBy(a => a.WF.PK_ID) @@ -615,7 +636,8 @@ namespace Myshipping.Application { actModel.SubList = mergeSubList.Where( b => - b.WF.PK_ID == a.WF.PK_ID && b.Act.PK_ID == a.Act.PK_ID).OrderBy(b => b.SortNo) + b.WF.PK_ID == a.WF.PK_ID && b.ParentId == a.Act.PK_ID) + .OrderBy(b => b.SortNo) .Select(b => { @@ -1233,15 +1255,16 @@ namespace Myshipping.Application }; if (lastReleaseInfo != null) - releaseInfo.LAST_PK_ID = lastReleaseInfo.PK_ID; - - lastReleaseInfo.IS_DEL = 1; - - _serviceWorkFlowReleaseInfoRepository.AsUpdateable(lastReleaseInfo).UpdateColumns(it => new { - it.IS_DEL - }).ExecuteCommand(); + releaseInfo.LAST_PK_ID = lastReleaseInfo.PK_ID; + lastReleaseInfo.IS_DEL = 1; + _serviceWorkFlowReleaseInfoRepository.AsUpdateable(lastReleaseInfo).UpdateColumns(it => new + { + it.IS_DEL + }).ExecuteCommand(); + } + //写入发布表 _serviceWorkFlowReleaseInfoRepository.Insert(releaseInfo); diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index b8a859b4..02e7162d 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -3,11 +3,13 @@ using Furion.DistributedIDGenerator; using Furion.DynamicApiController; using Furion.FriendlyException; using Furion.JsonSerialization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Myshipping.Application.Entity; using Myshipping.Core; using Myshipping.Core.Entity; +using NPOI.OpenXmlFormats.Vml; using NPOI.SS.Formula.Functions; using Org.BouncyCastle.Asn1.Tsp; using Org.BouncyCastle.Ocsp; @@ -23,7 +25,7 @@ namespace Myshipping.Application /// /// 服务流程管理 /// - [ApiDescriptionSettings("Application", Name = "ServiceWorkFlowManage", Order = 30)] + [AllowAnonymous, ApiDescriptionSettings("Application", Name = "ServiceWorkFlowManage", Order = 30)] public class ServiceWorkFlowManageService : IServiceWorkFlowManageService, IDynamicApiController, ITransient { private readonly ILogger _logger; @@ -124,20 +126,10 @@ namespace Myshipping.Application throw Oops.Oh($"报文Main的状态列表至少需要提供一个以上的状态信息", typeof(InvalidOperationException)); } - UserTendDto userTendInfo = null; - - //如果大简云用户ID不为空,接收人为空时,通过大简云用户ID关联订舱人ID - if (!string.IsNullOrWhiteSpace(info.Main.DJYRecvUserId)) - { - userTendInfo = GetUserTendInfoByDJYUserId(info.Main.DJYRecvUserId, info.Main.DJYRecvUserEmail); - } - else - { - userTendInfo = GetUserTendInfo(info.Main.RecvUserId); - } + UserTendDto userTendInfo = GetUserTendInfo(info.Main.RecvUserId); //根据状态编号检索对应的状态和活动信息,如果已经提取到的状态数量与推送的不一致不能直接返回错误 - var skuList = _statusSkuBaseInfoRepository.AsQueryable() + var skuList = _statusSkuBaseInfoRepository.AsQueryable().Filter(null, true) .LeftJoin((sts, act) => sts.PK_ID == act.STATUS_SKU_ID) .Where((sts, act) => statusArg.Contains(sts.STATUS_SKU_CODE) && !sts.IsDeleted && sts.IS_ENABLE == 1 && !act.IsDeleted) @@ -168,7 +160,7 @@ namespace Myshipping.Application } //先从运行表按主键获取运行主表和活动表 - var runList = _serviceWorkFlowRunInfoRepository.AsQueryable() + var runList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) .LeftJoin( (m, s) => m.PK_ID == s.RUN_ID) .Where((m, s) => m.BUSI_ID == info.Main.BusiId @@ -254,8 +246,6 @@ namespace Myshipping.Application IS_START = sku.SortNo == 1 ? 1 : 0, IS_END = sku.SortNo == endNum ? 1 : 0, ACT_ID = sku.PKId, - ACT_DATE = currReq.Req.StatusDate, - ACT_VAL = currReq.Req.StatusVal, STATUS_SKU_CODE = sku.statusSkuBase.StatusSKUCode, STATUS_SKU_ID = sku.StatusSKUId, SHOW_NAME = sku.ShowName, @@ -272,7 +262,14 @@ namespace Myshipping.Application SOURCE_TYPE = "AUTO" }; - if(!string.IsNullOrWhiteSpace(lastActId)) + if(currReq != null) + { + activitiesRunInfo.ACT_DATE = currReq.Req.StatusDate; + activitiesRunInfo.ACT_VAL = currReq.Req.StatusVal; + } + + + if (!string.IsNullOrWhiteSpace(lastActId)) activitiesRunInfo.NEXT_ACT_ID = lastActId; await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesRunInfo); @@ -296,8 +293,6 @@ namespace Myshipping.Application IS_START = sub.SortNo == 1 ? 1 : 0, IS_END = sub.SortNo == endNum ? 1 : 0, ACT_ID = sub.PKId, - ACT_DATE = currSubReq.Req.StatusDate, - ACT_VAL = currSubReq.Req.StatusVal, STATUS_SKU_CODE = sub.statusSkuBase.StatusSKUCode, STATUS_SKU_ID = sub.StatusSKUId, SHOW_NAME = sub.ShowName, @@ -314,6 +309,12 @@ namespace Myshipping.Application SOURCE_TYPE = "AUTO" }; + if(currSubReq != null) + { + activitiesSubRunInfo.ACT_DATE = currSubReq.Req.StatusDate; + activitiesSubRunInfo.ACT_VAL = currSubReq.Req.StatusVal; + } + if (!string.IsNullOrWhiteSpace(lastSubActId)) activitiesSubRunInfo.NEXT_ACT_ID = lastSubActId; From bfa95852062e313e43dfdf90905b524e06f56b2e Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Wed, 12 Jul 2023 09:05:12 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8F=B0=E8=B4=A6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E4=B8=9C=E8=83=9C=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=AE=88=E6=8A=A4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 3 ++ Myshipping.sln | 6 ++++ ServiceDeamon/App.config | 6 ++++ ServiceDeamon/CheckServiceHelper.cs | 28 +++++++++++++++++++ ServiceDeamon/Program.cs | 13 +++++++++ ServiceDeamon/ServiceDeamon.csproj | 14 ++++++++++ 6 files changed, 70 insertions(+) create mode 100644 ServiceDeamon/App.config create mode 100644 ServiceDeamon/CheckServiceHelper.cs create mode 100644 ServiceDeamon/Program.cs create mode 100644 ServiceDeamon/ServiceDeamon.csproj diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 7a865400..39cb6263 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1037,6 +1037,9 @@ namespace Myshipping.Application //记录修改日志 await SaveLog(order, orderCompare); + + //推送东胜 + await SendBookingOrder(new long[] { order.Id }); } /// diff --git a/Myshipping.sln b/Myshipping.sln index 9e88214f..04f0a42b 100644 --- a/Myshipping.sln +++ b/Myshipping.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Myshipping.FlowCenter", "My EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Myshipping.Report", "Myshipping.Report\Myshipping.Report.csproj", "{66E98A13-17A5-4B2A-B78A-A3FC87D2645A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDeamon", "ServiceDeamon\ServiceDeamon.csproj", "{A0F9B98D-6466-465F-B2D1-278B7284C11E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Debug|Any CPU.Build.0 = Debug|Any CPU {66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Release|Any CPU.ActiveCfg = Release|Any CPU {66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Release|Any CPU.Build.0 = Release|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ServiceDeamon/App.config b/ServiceDeamon/App.config new file mode 100644 index 00000000..8780b642 --- /dev/null +++ b/ServiceDeamon/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ServiceDeamon/CheckServiceHelper.cs b/ServiceDeamon/CheckServiceHelper.cs new file mode 100644 index 00000000..9b489d19 --- /dev/null +++ b/ServiceDeamon/CheckServiceHelper.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceDeamon +{ + public class CheckServiceHelper + { + private static ServiceController servCtl; + + + public static void CheckStatus(string servName) + { + if (servCtl == null || servCtl.ServiceName != servName) + { + servCtl = new ServiceController(servName); + } + + if (servCtl != null && servCtl.Status == ServiceControllerStatus.Stopped) + { + servCtl.Start(); + } + } + } +} diff --git a/ServiceDeamon/Program.cs b/ServiceDeamon/Program.cs new file mode 100644 index 00000000..064ff175 --- /dev/null +++ b/ServiceDeamon/Program.cs @@ -0,0 +1,13 @@ +using ServiceDeamon; +using System.Configuration; +using System.ServiceProcess; + +var servName = ConfigurationManager.AppSettings["ServiceName"]; + +//Timer t = new System.Threading.Timer((sta) => +//{ +// CheckServiceHelper.CheckStatus(servName); +//}); + +//t.Change(1000,) + diff --git a/ServiceDeamon/ServiceDeamon.csproj b/ServiceDeamon/ServiceDeamon.csproj new file mode 100644 index 00000000..9af9c439 --- /dev/null +++ b/ServiceDeamon/ServiceDeamon.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + +