From ac9a5abe7efdafdfd1cb53c4fb465fe019a7aca9 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 12 Jul 2023 16:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=80=E6=9D=A5=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceWorkFlowManageService.cs | 75 ++++++++++++++----- .../Service/DjyCustomer/DjyCustomerService.cs | 13 ++++ 2 files changed, 69 insertions(+), 19 deletions(-) diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index d5a0e337..38f06cc8 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -3,6 +3,7 @@ using Furion.DistributedIDGenerator; using Furion.DynamicApiController; using Furion.FriendlyException; using Furion.JsonSerialization; +using Google.Protobuf.Collections; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -129,15 +130,21 @@ namespace Myshipping.Application throw Oops.Oh($"报文Main的状态列表至少需要提供一个以上的状态信息", typeof(InvalidOperationException)); } - UserTendDto userTendInfo = GetUserTendInfo(info.Main.RecvUserId); + UserTendDto userTendInfo = GetUserTendInfo(info.Main.RecvUserId); - //根据状态编号检索对应的状态和活动信息,如果已经提取到的状态数量与推送的不一致不能直接返回错误 + //检索状态对应所有的服务流程,如果已经提取到的状态数量与推送的不一致,提示错误不能入库s var skuList = _statusSkuBaseInfoRepository.AsQueryable().Filter(null, true) .LeftJoin((sts, act) => sts.PK_ID == act.STATUS_SKU_ID) + .LeftJoin((sts,act,rela)=> + act.PK_ID == rela.SERVICE_ACTIVITIES_ID) + .LeftJoin((sts, act, rela,wf)=> + rela.SERVICE_WORKFLOW_ID == wf.PK_ID && rela.WF_VERSION == wf.RELEASE_VERSION) .Where((sts, act) => statusArg.Contains(sts.STATUS_SKU_CODE) && !sts.IsDeleted && sts.IS_ENABLE == 1 && !act.IsDeleted) - .Select((sts, act) => new { Sku = sts, Act = act }).ToList(); + .Select((sts, act,rela,wf) => + new { Sku = sts, Act = act, Rela = rela,WF = wf }).ToList(); + //推送状态与已有状态进行匹配 var reqStatusList = info.Main.StatusList.GroupJoin(skuList, l => l.StatusCode, r => r.Sku.STATUS_SKU_CODE, (l, r) => @@ -149,11 +156,12 @@ namespace Myshipping.Application return new { Exists = false, Sku = new StatusSkuBaseInfo(), Act = new ServiceWorkFlowActivitiesInfo(),Req = l }; }).ToList(); - if (reqStatusList.Any(a=>!a.Exists)) + //如果有不存在的状态则提示无法入库 + if (reqStatusList.Any(a => !a.Exists)) { - var errList = + var errList = reqStatusList.Where(a => !a.Exists) - .Select(a=>a.Req.StatusCode).ToArray(); + .Select(a => a.Req.StatusCode).ToArray(); string errMsg = $"以下状态不存在 {(string.Join(",", errList))} 不能入库"; @@ -170,8 +178,46 @@ namespace Myshipping.Application && m.BUSI_SYSTEM_CODE.Equals(info.Main.BusiSystemCode) && !m.IsDeleted && !s.IsDeleted) .Select((m, s) => new { main = m, sub = s }).ToList(); + var wfList = skuList.Select(a => a.WF) + .Distinct().ToList(); + + //var ddd = wfList.GroupJoin(runList, l => l.PK_ID, + // r => r.main.SERVICE_WF_ID, + // (l, r) => { + // var currList = r.ToList(); + + // if (currList.Count > 0) + // { + // return new { Exists = true, WF = l }; + // } + + // return { Exists = true, WF = l }; + + // }).ToList(); + + + + //状态关联的服务流程与运行表中的服务流程对应,对已经有的进行更新,对未进入运行表的进行写入 + var actArg = reqStatusList.Select(a => a.Act.PK_ID).ToArray(); + //根据服务流程活动获取所有相关的服务流程 + var wfRlt = _serviceWorkFlowBaseService.GetServiceWorkFlowListByActivities(actArg).GetAwaiter().GetResult(); + if (!wfRlt.succ) + { + string errMsg = $"获取服务流程失败,原因:{wfRlt.msg}"; + + _logger.LogInformation("批次={no} {msg}", batchNo, errMsg); + + throw Oops.Oh(errMsg, typeof(InvalidOperationException)); + } + + var list = JSON.Deserialize>(JSON.Serialize(wfRlt.ext)); + + + + + //list.GroupJoin(runList,l=>l.) //如果有已经运行的业务主键则只补充对应的活动表 - if(runList.Count > 0) + if (runList.Count > 0) { reqStatusList.ForEach(async reqMd => { @@ -192,22 +238,13 @@ namespace Myshipping.Application } else { - var actArg = reqStatusList.Select(a => a.Act.PK_ID).ToArray(); - //获取最后发布的服务流程写入运行表 - var wfRlt = _serviceWorkFlowBaseService.GetServiceWorkFlowListByActivities(actArg).GetAwaiter().GetResult(); - - if(!wfRlt.succ) - { - string errMsg = $"获取服务流程失败,原因:{wfRlt.msg}"; - - _logger.LogInformation("批次={no} {msg}", batchNo, errMsg); + - throw Oops.Oh(errMsg, typeof(InvalidOperationException)); - } + DateTime nowDate = DateTime.Now; - var list = JSON.Deserialize>(JSON.Serialize(wfRlt.ext)); + list.ForEach(async wf => { diff --git a/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs b/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs index fc00912c..77ce137b 100644 --- a/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs +++ b/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs @@ -301,7 +301,20 @@ namespace Myshipping.Core.Service var curList = r.ToList(); if (curList.Count > 0) + { l.Addrs = curList.Adapt>(); + } + + if(!string.IsNullOrWhiteSpace(l.Addr)) + { + if(l.Addrs == null) + l.Addrs = new List(); + + l.Addrs.Add(new DjyCustomerAddrInput { + CustomerId = l.Id, + Addr = l.Addr, + }); + } return l;