From b53e5f7552c99becaba5daa09318d9d37bd0dfa9 Mon Sep 17 00:00:00 2001 From: liuyunfeng Date: Thu, 11 Jul 2024 15:55:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E8=B6=85=E6=97=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commons/CommonHelper.cs | 38 ++++++ .../SplitPackings/SplitPackingRecManager.cs | 123 ++++++++++++------ 2 files changed, 120 insertions(+), 41 deletions(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs index ade4d7ddb..5b709e4d7 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/CommonHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; @@ -36,5 +37,42 @@ public sealed class CommonHelper return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } } +} +/// +/// Expression动态拼接+泛型缓存 +/// +/// +/// +public class ExpressionGenericMapper//Mapper`2 +{ + private static Func _FUNC = null; + static ExpressionGenericMapper() + { + ParameterExpression parameterExpression = Expression.Parameter(typeof(TIn), "p"); + List memberBindingList = new List(); + foreach (var item in typeof(TOut).GetProperties()) + { + MemberExpression property = Expression.Property(parameterExpression, typeof(TIn).GetProperty(item.Name)); + MemberBinding memberBinding = Expression.Bind(item, property); + memberBindingList.Add(memberBinding); + } + foreach (var item in typeof(TOut).GetFields()) + { + MemberExpression property = Expression.Field(parameterExpression, typeof(TIn).GetField(item.Name)); + MemberBinding memberBinding = Expression.Bind(item, property); + memberBindingList.Add(memberBinding); + } + MemberInitExpression memberInitExpression = Expression.MemberInit(Expression.New(typeof(TOut)), memberBindingList.ToArray()); + Expression> lambda = Expression.Lambda>(memberInitExpression, new ParameterExpression[] + { + parameterExpression + }); + _FUNC = lambda.Compile();//拼装是一次性的 + } + public static TOut Trans(TIn t) + { + return _FUNC(t); + } } + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs index bd72af6e8..e47c930ec 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/SplitPackings/SplitPackingRecManager.cs @@ -25,9 +25,9 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager public async Task BatchInsertAsync(List input) { + #region 校验 foreach (SplitPackingRec item in input) { - #region 校验 if (item.OprType == OprTypeEnum.SplitBox || item.OprType == OprTypeEnum.MergeBox) //拆箱或合箱 { if (item.FromPackingCode == item.ToPackingCode) @@ -42,18 +42,26 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager throw new UserFriendlyException("操作类型不是拆箱或合箱状态,源箱码和目标箱码必须相同!"); } } - #endregion } - + #endregion + //缓存数据 var query = await _repository.GetQueryableAsync().ConfigureAwait(false); + var fromPackCodeLst = input.Select(itm => itm.FromPackingCode).ToList(); + var toPackCodeLst = input.Select(itm => itm.ToPackingCode).ToList(); + var historyLst = await query.Where(itm => fromPackCodeLst.Contains(itm.ToPackingCode) && (itm.OprType == OprTypeEnum.SplitBox || itm.OprType == OprTypeEnum.MergeBox)).ToListAsync().ConfigureAwait(false); //取顶级箱码时用到 + var hisLst2 = await query.Where(itm => fromPackCodeLst.Contains(itm.FromPackingCode)).ToListAsync().ConfigureAwait(false); + Dictionary hisLst3 = await query.Where(itm => toPackCodeLst.Contains(itm.FromPackingCode) && itm.OprType == OprTypeEnum.Other).ToDictionaryAsync(itm => itm.FromPackingCode, it2 => it2).ConfigureAwait(false); + + //遍历、批量插入 + List operLst = new List(); foreach (SplitPackingRec item in input) { if (item.OprType == OprTypeEnum.SplitBox || item.OprType == OprTypeEnum.MergeBox) { //设置顶级箱码 - item.FromTopPackingCode = CalcuTopPackingCode(query, item.FromPackingCode); - item.ToTopPackingCode = CalcuTopPackingCode(query, item.FromPackingCode); //ToPackingCode + item.FromTopPackingCode = CalcuTopPackingCode(input, historyLst, item); + item.ToTopPackingCode = CalcuTopPackingCode(input, historyLst, item); if (item.FromTopPackingCode.IsNullOrEmpty()) { item.FromTopPackingCode = item.FromPackingCode; @@ -63,14 +71,12 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager item.ToTopPackingCode = item.FromTopPackingCode; } //设置六个单据号 - SetBillNumber(query, item); + SetBillNumber(hisLst2, item); //拆箱时,如果目标箱不存在,插入目标箱(两个箱码相同) - string toPackCode = item.ToPackingCode; - var toHis = await query.Where(itm => itm.FromPackingCode == toPackCode && itm.ToPackingCode == toPackCode).OrderBy(itm => itm.CreationTime).FirstOrDefaultAsync().ConfigureAwait(false); - if (toHis == null) + if (hisLst3.ContainsKey(item.ToPackingCode) == false) { - - SplitPackingRec newObj = CommonHelper.CloneObj(item); + //SplitPackingRec newObj = CommonHelper.CloneObj(item); + SplitPackingRec newObj = ExpressionGenericMapper.Trans(item); newObj.SetId(GuidGenerator.Create()); newObj.OprType = OprTypeEnum.Other; newObj.FromPackingCode = newObj.ToPackingCode; //克隆赋值 @@ -79,11 +85,20 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager newObj.FromUom = newObj.ToUom; newObj.FromQty = newObj.ToQty; newObj.FromLot = newObj.ToLot; - var res = await _repository.InsertAsync(newObj, false).ConfigureAwait(false); + //var res = await _repository.InsertAsync(newObj, false).ConfigureAwait(false); + operLst.Add(newObj); } - SplitPackingRec newEntity = CommonHelper.CloneObj(item); + //var toHis = await query.Where(itm => itm.FromPackingCode == toPackCode && itm.ToPackingCode == toPackCode).OrderBy(itm => itm.CreationTime).FirstOrDefaultAsync().ConfigureAwait(false); + //if (toHis == null) + //{ + //} + //SplitPackingRec newEntity = CommonHelper.CloneObj(item); + SplitPackingRec newEntity = ExpressionGenericMapper.Trans(item); + newEntity.SetId(GuidGenerator.Create()); - var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false); + // var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false); + operLst.Add(newEntity); + } else { @@ -95,11 +110,14 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager { item.ToTopPackingCode = item.FromPackingCode;// ToPackingCode; } - SplitPackingRec newEntity = CommonHelper.CloneObj(item); + //SplitPackingRec newEntity = CommonHelper.CloneObj(item); + SplitPackingRec newEntity = ExpressionGenericMapper.Trans(item); newEntity.SetId(GuidGenerator.Create()); - var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false); + //var ret = await _repository.InsertAsync(newEntity, false).ConfigureAwait(false); + operLst.Add(newEntity); } } //foreach + await _repository.InsertManyAsync(operLst).ConfigureAwait(false); return true; } @@ -203,48 +221,71 @@ public class SplitPackingRecManager : DomainService, ISplitPackingRecManager } /// - /// 取顶级箱码 + /// 取顶级箱码: /// - /// 箱码历史 - /// 箱码,from to时都传入from + /// 本次操作要插入的拆箱记录列表,位于内存中 + /// 数据库中的历史数据:拆箱或合箱、to箱码=内存中的from箱码 + /// 内存中当前记录 /// - private static string CalcuTopPackingCode(IQueryable historyQuery, string packingCode) + private static string CalcuTopPackingCode(List memoryInput, List historyLst, SplitPackingRec curRecord) { - var qry = historyQuery.Where(itm => itm.OprType == OprTypeEnum.SplitBox || itm.OprType == OprTypeEnum.MergeBox); - string ret = null; - SplitPackingRec? firstObj = null; - string toCode = packingCode; + //根据当前记录在内存列表中递归取得最上级拆箱记录:1-2 2-3 3-4 根据3-4能取到1-2 + SplitPackingRec priorMemoryRecord = curRecord; while (1 == 1) { - firstObj = qry.FirstOrDefault(itm => itm.ToPackingCode == toCode); - if (firstObj == null) + var obj = memoryInput.FirstOrDefault(itm => itm.ToPackingCode == priorMemoryRecord.FromPackingCode); + if (obj != null) { - ret = toCode; - break; + priorMemoryRecord = obj; } else { - toCode = firstObj.FromPackingCode; + break; } } - return ret; - //var historyRec = historyQuery.Where(itm => itm.FromPackingCode == packingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault(); - //if (historyRec != null) - //{ - // return historyRec.FromTopPackingCode; - //} - //else + /* + 算法:根据当前记录的from箱码在数据库中取上级拆箱记录,并返回顶级箱码 + 前提:只查找拆箱、合箱记录 + 1-1 + 2-2 + 1-2 查询to箱码=1的(没有,顶级箱码=from箱码) + 3-3 + 2-3 查询 to箱码=2的(找到1-2记录,取顶级箱码字段) + 4-4 + 3-4 查询to箱码=3的(找到2-3记录,取顶级箱码字段) + 5-5 + 3-5 查询to箱码=3的(找到2-3记录,取顶级箱码字段) + */ + var hisObj = historyLst.FirstOrDefault(itm => itm.ToPackingCode == priorMemoryRecord.FromPackingCode); + if (hisObj != null) + { + return hisObj.FromTopPackingCode; + } + else + { + return priorMemoryRecord.FromPackingCode; + } + //var qry = historyLst.Where(itm => itm.OprType == OprTypeEnum.SplitBox || itm.OprType == OprTypeEnum.MergeBox); + //string ret = null; + //SplitPackingRec? firstObj = null; + //string toCode = priorRecord.FromPackingCode; + //while (1 == 1) //{ - // historyRec = historyQuery.Where(itm => itm.ToPackingCode == packingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault(); - // if (historyRec != null) + // firstObj = qry.FirstOrDefault(itm => itm.ToPackingCode == toCode); + // if (firstObj == null) + // { + // ret = toCode; + // break; + // } + // else // { - // return historyRec.ToTopPackingCode; + // toCode = firstObj.FromPackingCode; // } //} - //return null; + //return ret; } - private static void SetBillNumber(IQueryable historyQuery, SplitPackingRec obj) + private static void SetBillNumber(List historyQuery, SplitPackingRec obj) { var historyRec = historyQuery.Where(itm => itm.FromPackingCode == obj.FromPackingCode).OrderBy(itm => itm.CreationTime).FirstOrDefault(); if (historyRec != null) From f3c1252fc2ad6d574d7e25be973ad824166b50df Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Fri, 12 Jul 2024 17:31:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=B8=AD=E5=87=BA=E7=8E=B0=E7=9A=84bug20240712?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Jobs/IssueJobs/SparePartIssueJobsController.cs | 8 ++++---- .../ProductionLineItems/ProductionLineItemAppService.cs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/SparePartIssueJobsController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/SparePartIssueJobsController.cs index 66cbe7fae..23e5fe456 100644 --- a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/SparePartIssueJobsController.cs +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/IssueJobs/SparePartIssueJobsController.cs @@ -52,10 +52,10 @@ public class SparePartIssueJobsController : AbpController { status.Add((int)EnumJobStatus.Open); } - else if (jobStatus == "Wait") - { - status.Add((int)EnumJobStatus.Wait); - } + //else if (jobStatus == "Wait") + //{ + // status.Add((int)EnumJobStatus.Wait); + //} else { status.Add((int)EnumJobStatus.Done); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs index ea7be1738..500bc1ec7 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ProductionLineItems/ProductionLineItemAppService.cs @@ -126,9 +126,9 @@ public class ProductionLineItemAppService : public virtual async Task GetByProductLineCodeAndItemCodeAsync(string productLineCode, string itemCode) { - var entityList = await _repository - .FindAsync(p => p.ProdLineCode == productLineCode && p.ItemCode == itemCode).ConfigureAwait(false); - return ObjectMapper.Map(entityList); + var entity = await _repository + .FirstOrDefaultAsync(p => p.ProdLineCode == productLineCode && p.ItemCode == itemCode).ConfigureAwait(false); + return ObjectMapper.Map(entity); } [HttpPost("get-by-productlinecode-and-itemcode-and-erplocationcode-async")] public virtual async Task> GetByProductLineCodeAndItemCodeAndErpLocationCodeAsync(List locationType, string erpLocationCodes,string itemCode) From ecc52926532bdaa774bee88cfc9bf662acda4923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Fri, 12 Jul 2024 21:50:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/WZC2/v17/.wsuo | Bin 238080 -> 229888 bytes .../Client/WebApi.cs | 54 +++++++++++++++--- .../Incoming/InjectionMoldingRequestReader.cs | 12 +++- ...tionMoldingTaskIncomingBackgroundWorker.cs | 36 ++++++------ .../appsettings.json | 2 +- .../tests/Class1.cs | 20 +++++++ .../test/TestAppService.cs | 18 ++++-- 7 files changed, 109 insertions(+), 33 deletions(-) diff --git a/.vs/WZC2/v17/.wsuo b/.vs/WZC2/v17/.wsuo index 78d4fb1e68f43b4628ac4cd45651943fc90d5a62..5a177d4c348e16688dba793929c7961619cbd9bf 100644 GIT binary patch delta 2535 zcmbu=OHfl+7zglsZb*o569NPRAxMHiqb7I>At6yT8dT8o(g3~?lL$VF6)~|IABnY7 zyXrtr+pM~2XIR*cn06eeU34moE;`nQi%!Q)J9g@_<3OucrT;GyM6J_ldzc^hyzV() z?&G_OX>H;i?f4p&GtpvDRtkc!lpj+YrbZtz?WlM6x~;c9eFywuU>8OVi^i%&HRz->rnT>df32w@(h?M z@q>9^@jI(bNh!iSJSxRi4>5f6B7Z2gYZ%2yH;$s=69qMFBadq0tTjDbk}oFz!+vV) z_jP7Jy`Ntf8+b(DEzwO}_G}j`zpsC!+Jp|Zz#kf7Y%`CR#p$Ujt6*HGZRFRBI@06X z%dCXr%9ams!iVrAZE<|YlGUx!;s=YO=aK3FZ!_BXOm(+p#?*44(=&s4} zUevpVG2y77q)8~!?TQOuobcV{z8+b(f9S+u>&`*HKiio=Cv8Hn#2n(u%+v*Bo$dIw zPp`!e$FirVy91Zm%e}h5Z)_@PWoc{E58_mCoE2uSLS{Ak$#ZiJPp?Q0yGxbluFC^V zqpSL=>+*?LjMEY#e!2pbKy4L{xuAw6kO%o7fd;ft06HjyA}9tult3vMpbW~v2o+$0 zN>~b2U}i#Gu%J>6%b*5op$=XHD=dc!o-~u-^g9p5@8rDDy ztc7*pV{s$}R5pMgT45t>g3Ztd?XU&5!t2lhozMl{&;#3GI|QH?`k)_nz)si&yI~Iu zz+M=HeR2E?LI}dJABJEU4!}V;1c%`b7=a`3CLD!PI0j>I93l{f6Yv(Cgi{cM({KjP z!a1P56$vJ!=JLhIsTz%V8!uL}D8g3rXweON&sj5%7RMzwo}tV;fn(AeVSXO?-mBon&@_OakHM^>#w6#k^>|Bn|^FQ(5DOwBf=Q}xUV+3SB@V- zzT1QKWS~`j*p6;TjqGR`ZgPY@cDK{vu{)hZ9(%LL6}E>$Znqo?h8-byFq2s+4QI+B zAM%W_!M;7^=xDY#$YGZ=7m=OKL{8IA;WGMRu(iZgygmJk5YrM<*QwUFWqdKmHnFv(j1=@jZ=}M3KIn^nNJD?5V*mzX5Hc_rnHYjB48<^9g{zT` zYmj3yxlOrruElVSKpw8cNL-H_FbX%~CXB|-7=v3d7WpW^I22+$CSW2a;Z{t>6ck}9 zreV7Jn#FWxU?yh42^VH#4(4JWN-!S_un?tiqYNs~rrj~Wljp#WB46b}<=UTHoqjM> zPSm+T`mJ;A&u>)AH7cK>^ewH%D(0^TtE{m^%DaMkUg+7R0RM3|<;loF;p&(5TgI<` zFJx%gp7P>GkM0yj(xtltdk_r0N1o7!+Dwu3)dJ_f({gwFII%*yY;Ix5qqY&&%UhlB zIwKmyAI_id6w{Sjs#t8 z1Y1>=(mVwjy1x+BXQ-!>&VoE^Cr+LTG!^97L>v)+?f!b%xExulB?hSbb?@;@+gLnN z8G1KHs+`ZtK48Mb7PbSIhInv@_VuqwV@`x}#W z=<8m}hm^wu34gwq(>JgJD{&w0#{+l}tFRht@DM8SFxKJ`RN_&r!+LDMV|W}-;7L5C zwveakY(y2jcm~hnIr#8AUcigkgqN@xTktZfQG>0hMIBzjtJsEmY{zSO9SwK`JFru2 zVY}$;#+!Hxd+;{i!MkY0d)SNj@c}->K753au^$KU2@c^P+Tk;N0hQY?Ievw&@eRJk zVSgci$KVLQM-xnfwB#pLCDaMM1H&%x7lS6IE)vByMZkfwRk ze(qMyR5jR&TGZhcyozn8$99}5&ws!22cgUAI|AjF>Cr}BBY#46P0R4@uxLF3o!j`3L*njOM$ zdWF+?ae;Z5apZ0>*?2lcvo2p?&h+J#a8|67HK%78QS@cSkCTnz^UQg4Cdsnhy0L05 sH(A0&gRyI*`ATE)B6F6{?lzAVvgwf1s46v=%DT)nc{n?-nO)O=0U#5lga7~l diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs index a4498b3d5..071d4433e 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs @@ -1,5 +1,3 @@ - - //---------------------- // // Generated using the NSwag toolchain v14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) @@ -72,7 +70,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming /// /// Success /// A server side error occurred. - public virtual System.Threading.Tasks.Task GetMacStaticAsync() + public virtual System.Threading.Tasks.Task GetMacStaticAsync() { return GetMacStaticAsync(System.Threading.CancellationToken.None); } @@ -83,7 +81,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming /// /// Success /// A server side error occurred. - public virtual async System.Threading.Tasks.Task GetMacStaticAsync(System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task GetMacStaticAsync(System.Threading.CancellationToken cancellationToken) { var client_ = _httpClient; var disposeClient_ = false; @@ -125,7 +123,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -214,7 +212,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming /// Success /// A server side error occurred. - public virtual System.Threading.Tasks.Task> GetCargoStaticAsync(string areaID) + public virtual System.Threading.Tasks.Task GetCargoStaticAsync(string areaID) { return GetCargoStaticAsync(areaID, System.Threading.CancellationToken.None); } @@ -222,7 +220,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// Success /// A server side error occurred. - public virtual async System.Threading.Tasks.Task> GetCargoStaticAsync(string areaID, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task GetCargoStaticAsync(string areaID, System.Threading.CancellationToken cancellationToken) { var client_ = _httpClient; var disposeClient_ = false; @@ -269,7 +267,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -536,6 +534,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming } + public partial class ResponCargoItem1 { /// @@ -572,6 +571,45 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ResponCargos + { + [Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int Code { get; set; } + + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Value { get; set; } + + [Newtonsoft.Json.JsonProperty("msg", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Msg { get; set; } + + [Newtonsoft.Json.JsonProperty("datalist", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection Datalist { get; set; } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ResultJson + { + [Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int Code { get; set; } + + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int Value { get; set; } + + [Newtonsoft.Json.JsonProperty("result", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Result { get; set; } + + [Newtonsoft.Json.JsonProperty("msg", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Msg { get; set; } + + [Newtonsoft.Json.JsonProperty("valuestr", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Valuestr { get; set; } + + } + + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] public partial class ApiException : System.Exception { diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs index 302e865ea..afa36a95d 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs @@ -76,7 +76,7 @@ public class InjectionMoldingRequestReader : IReader Stopwatch sw = Stopwatch.StartNew(); Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录 var flag = await client.GetMacStaticAsync().ConfigureAwait(false); - if (flag != 1) + if (flag.Code != 200) { // 记录错误日志并返回空列表 _logger.LogInformation($"读取到摄像头信息为不可用{DateTime.Now},请检查摄像头"); @@ -94,7 +94,15 @@ public class InjectionMoldingRequestReader : IReader { foreach (var itm in ids)//遍历区域查找所有货物 { - var idsList = await client.GetCargoStaticAsync(itm).ConfigureAwait(false); + + + var obj= await client.GetCargoStaticAsync(itm).ConfigureAwait(false); + var idsList = obj.Datalist; + if (idsList == null) + { + _logger.LogInformation($"没有设置指定区域无数据"); + return new List(); + } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs index bc6238dd0..484af500e 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingTaskIncomingBackgroundWorker.cs @@ -40,24 +40,24 @@ public class InjectionMoldingTaskIncomingBackgroundWorker : AsyncPeriodicBackgro protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) { Logger.LogInformation($"开始: 执行 {Incoming}"); - var configManager = workerContext.ServiceProvider.GetRequiredService(); - var confitem = await configManager.GetInterfaceConfig("SJ-IN").ConfigureAwait(false); - if (confitem == null) - { - if (!_options.Value.IncomingOptions.Active) - { - Logger.LogInformation($"{Incoming} 已关闭没有执行!"); - return; - } - } - else - { - if (!confitem.Active) - { - Logger.LogInformation($"{Incoming} 已关闭没有执行!"); - return; - } - } + //var configManager = workerContext.ServiceProvider.GetRequiredService(); + //var confitem = await configManager.GetInterfaceConfig("SJ-IN").ConfigureAwait(false); + //if (confitem == null) + //{ + // if (!_options.Value.IncomingOptions.Active) + // { + // Logger.LogInformation($"{Incoming} 已关闭没有执行!"); + // return; + // } + //} + //else + //{ + // if (!confitem.Active) + // { + // Logger.LogInformation($"{Incoming} 已关闭没有执行!"); + // return; + // } + //} Logger.LogInformation($"注塑任务");//缴库 var reader = workerContext.ServiceProvider.GetService(); diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json index d4aaa87d0..ea533dd5c 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/appsettings.json @@ -67,7 +67,7 @@ "InjectionMoldingTaskOptions": { "AutoRemote": { - "IpAddress": "http://10.164.227.103:30000/", + "IpAddress": " http://localhost:59094/", "UserName": "", "Password": "", "Token": "", diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs index 1401e6a5b..8224cdc45 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs @@ -35,3 +35,23 @@ public class ResponCargoItem [Display(Name = "货位状态")] public int Flag { set; get; } = 0; } +public class ResponCargos : ResponseJson +{ + //货位状态列表 + public List Datalist { set; get; } + +} +public class ResultJson +{ + // 错误码: + public int Code { set; get; } = 0; + // 返回值 其具体含义由调用接口确定 + public int Value { set; get; } = 0; + // 错误消息 + public string Result { set; get; } = ""; + + public string Msg { set; get; } = ""; + + public string Valuestr { set; get; } +} + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs index e5fea514f..da93b4435 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs @@ -40,9 +40,12 @@ public class TestService:ApplicationService /// 生命周期操作 /// [HttpPost("GetMacStatic")] - public async Task GetMacStatic() + public async Task GetMacStatic() { - return 1; + + + + return new ResultJson() { Code = 200, Msg = "SUCESS", Value = 1 , Valuestr = "", Result = ""}; } @@ -51,7 +54,7 @@ public class TestService:ApplicationService /// /// 异步开始生命周期操作不能堵塞 /// - public async Task> GetCargoStatic(string AreaID) + public async Task GetCargoStatic(string AreaID) { List result = new List(); @@ -63,7 +66,14 @@ public class TestService:ApplicationService result = result.Where(p => p.AreaID == AreaID).ToList(); - return result; + + var t = new ResponCargos(); + t.Code = 200; + t.Msg = "Success"; + t.Datalist = result; + + + return t; } //[HttpPost("SyncIssueJobStereo")] From 366e6580f68092af5e5c1278751ae98a59da9499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Sat, 13 Jul 2024 08:44:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Client/WebApi.cs | 2 +- .../tests/Class1.cs | 2 +- .../test/TestAppService.cs | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs index 071d4433e..3fb62f854 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Client/WebApi.cs @@ -578,7 +578,7 @@ namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming public int Code { get; set; } [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Value { get; set; } + public int Value { get; set; } [Newtonsoft.Json.JsonProperty("msg", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Msg { get; set; } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs index 8224cdc45..b6694229a 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/tests/Class1.cs @@ -15,7 +15,7 @@ public class ResponseJson // 错误码: public int Code { set; get; } = 0; // 返回值 其具体含义由调用接口确定 - public string Value { set; get; } = ""; + public int Value { set; get; } =0; // 错误消息 public string Msg { set; get; } = ""; } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs index da93b4435..60ee8ab81 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/test/TestAppService.cs @@ -92,8 +92,18 @@ public class TestService:ApplicationService //} + [HttpPost("GetCargoStatic1")] + /// + /// 异步开始生命周期操作不能堵塞 + /// + public async Task GetCargoStatic1(ResponCargos p_cas) + { + + + return p_cas; + } @@ -103,7 +113,9 @@ public class TestService:ApplicationService - } + + +} /// /// 发给立体库主表 ///