From 73e496b9892fde5898b31b6cc817d4565a3f974e Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Tue, 16 Jul 2024 17:26:49 +0800 Subject: [PATCH 1/6] bug --- BasicData/Tnb.BasicData/ThirdApiRecordService.cs | 11 ++++++++++- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 4 ++-- .../Tnb.WarehouseMgr/WmsMaterialTransferService.cs | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index 33ecc31a..742ed849 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -50,7 +50,16 @@ namespace Tnb.BasicData stopwatch.Stop(); var elapsedMilliseconds = stopwatch.ElapsedMilliseconds; - ThirdResult thirdResult = JsonConvert.DeserializeObject(response); + ThirdResult thirdResult = null; + try + { + thirdResult = JsonConvert.DeserializeObject(response); + } + catch (Exception e) + { + thirdResult.Code = 500; + thirdResult.msgResult = response; + } if (thirdResult.Code == 200) { await db.Updateable() diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 2e5738d7..d972d069 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -2367,7 +2367,7 @@ namespace Tnb.WarehouseMgr List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); string erpCreateId = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.create_id)?.user_id ?? ""; ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId)); - string nowStr = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); @@ -2423,7 +2423,7 @@ namespace Tnb.WarehouseMgr thirdWebapiRecord.name = "其它入库"; thirdWebapiRecord.method = "POST"; thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/generalin/save"; - thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); + thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData); thirdWebapiRecord.create_time = DateTime.Now; await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index 991b0816..0e14bb2b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -649,7 +649,7 @@ namespace Tnb.WarehouseMgr List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); - string nowStr = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); + string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); erpRequestData.Add("billmaker",erpCreateId); erpRequestData.Add("cdptid","1001A1100000000JRLI1A100");// 先写死 erpRequestData.Add("cdptvid","0001A11000000007GGO8");// 先写死 From ff038ff1d5ab08cee88d80acb530be585eb86b47 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 09:32:56 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=BB=84=E8=A3=85=E6=8F=90=E6=8A=A5?= =?UTF-8?q?=E4=BB=93=E5=BA=93=20=E5=BA=93=E4=BD=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 9 +++++---- .../Consts/WmsWareHouseConst.cs | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index d74ca75b..822847eb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1723,16 +1723,17 @@ namespace Tnb.ProductionMgr // throw Oops.Bah("未找到对应产线"); // } - report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID; + // report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID; + report.warehouse_id = WmsWareHouseConst.WAREHOUSE_SLDMJC_ID; Dictionary worklineWarehouseDic = new Dictionary() { - [WmsWareHouseConst.XUELUGUAN1XIAN] = "ZZ-01-01", - [WmsWareHouseConst.XUELUGUAN2XIAN] = "ZZ-01-02", + [WmsWareHouseConst.XUELUGUAN1XIAN] = "ZZ-01-02", + [WmsWareHouseConst.XUELUGUAN2XIAN] = "ZZ-02-02", }; report.location_code = worklineWarehouseDic.GetOrDefault(prdMoTask.workline_id); if (string.IsNullOrEmpty(report.location_code)) { - report.location_code = "ZZ-01-01"; + report.location_code = "ZZ-01-02"; } location = await db.Queryable().SingleAsync(x=>x.location_code==report.location_code); if (location == null) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 1260e665..da13a785 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -26,8 +26,10 @@ /// 暂存仓仓库ID /// public const string WAREHOUSE_ZCC_ID = "33780009364245"; - - + /// + /// 四楼待灭菌仓 + /// + public const string WAREHOUSE_SLDMJC_ID = "35412479754517"; /// /// 四楼解析库 /// From 96875e8afc0b83342941510ec5db9b4b91c876a6 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 12:07:27 +0800 Subject: [PATCH 3/6] bug --- BasicData/Tnb.BasicData/ThirdApiRecordService.cs | 2 +- ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 4 ++-- .../Tnb.WarehouseMgr/WmsMaterialTransferService.cs | 7 +++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index 742ed849..d6bfbd27 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -50,7 +50,7 @@ namespace Tnb.BasicData stopwatch.Stop(); var elapsedMilliseconds = stopwatch.ElapsedMilliseconds; - ThirdResult thirdResult = null; + ThirdResult thirdResult = new ThirdResult(); try { thirdResult = JsonConvert.DeserializeObject(response); diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 55add93a..c407d322 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -461,7 +461,7 @@ namespace Tnb.ProductionMgr Stopwatch stopwatch = null; string response = ""; var elapsedMilliseconds = 0l; - ThirdResult thirdResult = null; + ThirdResult thirdResult = new ThirdResult(); foreach (var record in records) { now = DateTime.Now; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index d972d069..2fa300cd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -2396,8 +2396,8 @@ namespace Tnb.WarehouseMgr ["cbodytranstypecode"] = "4A-01", ["cbodywarehouseid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "", ["cgeneralbid"] = erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? "", - ["cgeneralbid"] = item.id, - ["cgeneralhid"] = item.bill_id, + ["cgeneralbid"] = item.erp_line_pk ?? "", + ["cgeneralhid"] = wmsMaterialTransfer.erp_pk ?? "", ["cmaterialoid"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "", ["cmaterialvid"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialvid ?? "", ["corpoid"] = erpOrg.corpoid, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index 0e14bb2b..17e3d2d4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -641,7 +641,6 @@ namespace Tnb.WarehouseMgr ids.Add(wmsMaterialTransfer.warehouse_instock); ids.Add(wmsMaterialTransferd.material_id); ids.Add(unitData.Id); - List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (wmsMaterialTransfer.org_id ?? WmsWareHouseConst.AdministratorOrgId)); @@ -655,7 +654,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("cdptvid","0001A11000000007GGO8");// 先写死 erpRequestData.Add("corpoid",erpOrg.corpoid); erpRequestData.Add("corpvid",erpOrg.corpoid); - erpRequestData.Add("cothercalbodyoid",erpOrg.cdptid); + erpRequestData.Add("cothercalbodyoid",erpOrg.pk_org); erpRequestData.Add("cotherwhid",erpExtendFields.Find(x=>x.table_id==wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? ""); erpRequestData.Add("creationtime",nowStr); erpRequestData.Add("creator",erpCreateId); @@ -679,8 +678,8 @@ namespace Tnb.WarehouseMgr ["corpoid"] = erpOrg.corpoid, ["corpvid"] = erpOrg.corpvid, ["crowno"] = (dList.FindIndex(x=>x.id==wmsMaterialTransferd.id)+1) * 10, - ["csourcebillbid"] = wmsMaterialTransferd.id, - ["csourcebillhid"] = wmsMaterialTransferd.bill_id, + ["csourcebillbid"] = wmsMaterialTransferd.erp_line_pk ?? "", + ["csourcebillhid"] = wmsMaterialTransfer.erp_pk ?? "", ["cunitid"] = erpExtendFields.Find(x=>x.table_id==unitData.Id)?.cunitid ?? "", ["cvendorid"] = "", ["cvendorvid"] = "", From 44d586e85b95b20b22af41b72cf271f1bbdf01de Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 14:10:31 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E5=AE=9A=E7=82=B9?= =?UTF-8?q?=E9=85=8D=E9=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 7d2837bc..c15eef6c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -10,6 +10,7 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.FriendlyException; using JNPF.Logging; +using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using Mapster; @@ -29,6 +30,8 @@ using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Interfaces; +using Tnb.BasicData; +using Tnb.ProductionMgr.Entities.Entity; namespace Tnb.WarehouseMgr { @@ -103,6 +106,110 @@ namespace Tnb.WarehouseMgr instockD.org_id = _userManager.User.OrganizeId; }); await _db.Insertable(instockDs).ExecuteCommandAsync(); + + var purchase = await _db.Queryable().FirstAsync(it => it.id == purchaseDs.First().bill_id); + List dList = await _db.Queryable().Where(x=>x.bill_id==purchaseDs.First().bill_id).OrderBy(x=>x.id).ToListAsync(); + List materialIds = purchaseDs.Select(x=>x.material_id).Distinct().ToList(); + List unitCodes = purchaseDs.Select(x => x.unit_id).Distinct().ToList(); + List unitDatas = await _db.Queryable() + .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) + .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode)) + .Select((x,y)=>y) + .ToListAsync(); + + List ids = new List(); + ids.Add(_userManager.UserId); + ids.Add(WmsWareHouseConst.AdministratorOrgId); + ids.Add(purchase.warehouse_id); + ids.AddRange(materialIds); + ids.AddRange(unitDatas.Select(x=>x.Id).ToList()); + + List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); + string erpCreateId = erpExtendFields.Find(x=>x.table_id==_userManager.UserId)?.user_id ?? ""; + ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId)); + string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + List> requestData = new List>(); + Dictionary erpRequestData = new Dictionary(); + erpRequestData.Add("approver",erpCreateId); + erpRequestData.Add("billmaker",erpCreateId); + erpRequestData.Add("bisback",false); + erpRequestData.Add("creationtime",nowStr); + erpRequestData.Add("creator",erpCreateId); + erpRequestData.Add("ctrantypeid",""); + erpRequestData.Add("dbilldate",""); + erpRequestData.Add("dmakedate",nowStr); + erpRequestData.Add("ntotalastnum",purchaseDs.Sum(x=>x.purchase_arriveqty)); + erpRequestData.Add("pk_arriveorder",""); + erpRequestData.Add("pk_dept","1001A1100000000JRLI1A100"); + erpRequestData.Add("pk_dept_v","0001A11000000007GGO8"); + erpRequestData.Add("pk_org",erpOrg.pk_org); + erpRequestData.Add("pk_org_v",erpOrg.pk_org_v); + erpRequestData.Add("pk_group",erpOrg.pk_group); + erpRequestData.Add("pk_pupsndoc",""); + erpRequestData.Add("pk_purchaseorg",erpOrg.pk_org); + erpRequestData.Add("pk_purchaseorg_v",erpOrg.pk_org_v); + erpRequestData.Add("pk_supplier","1001A110000000000ZDB");//先写死 + erpRequestData.Add("pk_supplier_v","1001A110000000000ZDB");//先写死 + erpRequestData.Add("vbillcode",purchase.bill_code); + erpRequestData.Add("vmemo",purchase.remark); + erpRequestData.Add("vtrantypecode",""); + + List> erpRequestDataDetails = new List>(); + foreach(WmsPurchaseD item in dList) + { + erpRequestDataDetails.Add(new Dictionary() + { + ["castunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "", + ["cfirstbid"] = "", + ["cfirstid"] = "", + ["cfirsttypecode"] = "", + ["crececountryid"] = "0001Z010000000079UJJ", + ["crowno"] = (dList.FindIndex(x=>x.id==item.id)+1) * 10, + ["csendcountryid"] = "0001Z010000000079UJJ", + ["csourcetypecode"] = "", + ["ctaxcountryid"] = "0001Z010000000079UJJ", + ["cunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "", + ["dbilldate"] = "", + ["dplanreceivedate"] = "", + ["dproducedate"] = "", + ["fbuysellflag"] = 2, + ["fproductclass"] = 1, + ["naccumchecknum"] = 0, + // ["nastnum"] = 0, + ["nnum"] = item.purchase_arriveqty, + // ["nplanastnum"] = 0, + ["nplannum"] = item.purchase_qty, + ["apfinanceorg"] = erpOrg.pk_org, + ["pk_apfinanceorg_v"] = erpOrg.pk_org_v, + ["pk_arriveorder"] = "", + ["pk_arriveorder_b"] = "", + ["pk_group"] = "", + ["pk_material"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "", + ["pk_order"] = purchase.erp_bill_code, + // ["pk_order_b"] = "", + ["pk_org"] = erpOrg.pk_org, + ["pk_org_v"] = erpOrg.pk_org_v, + ["pk_psfinanceorg"] = erpOrg.pk_org_v, + ["pk_psfinanceorg_v"] = erpOrg.pk_org_v, + ["pk_receivestore"] = erpExtendFields.Find(x=>x.table_id==purchase.warehouse_id)?.cotherwhid ?? "", + ["pk_reqstoorg"] = erpOrg.pk_org, + ["pk_reqstoorg_v"] = erpOrg.pk_org_v, + }); + } + erpRequestData.Add("ArriveItemVODtl",erpRequestDataDetails); + requestData.Add(erpRequestData); + + ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord(); + thirdWebapiRecord.id = SnowflakeIdHelper.NextId(); + thirdWebapiRecord.third_name = WmsWareHouseConst.BIP; + thirdWebapiRecord.name = "采购到货"; + thirdWebapiRecord.method = "POST"; + thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save"; + thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); + thirdWebapiRecord.create_time = DateTime.Now; + + await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); } //通知Mes接口 //_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号); From 251acac5913d625e932c9aa09eb2416a07974f93 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 14:12:22 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E4=B8=8A=E4=B8=AA?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 107 ------------------ 1 file changed, 107 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index c15eef6c..7d2837bc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -10,7 +10,6 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.FriendlyException; using JNPF.Logging; -using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using Mapster; @@ -30,8 +29,6 @@ using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Interfaces; -using Tnb.BasicData; -using Tnb.ProductionMgr.Entities.Entity; namespace Tnb.WarehouseMgr { @@ -106,110 +103,6 @@ namespace Tnb.WarehouseMgr instockD.org_id = _userManager.User.OrganizeId; }); await _db.Insertable(instockDs).ExecuteCommandAsync(); - - var purchase = await _db.Queryable().FirstAsync(it => it.id == purchaseDs.First().bill_id); - List dList = await _db.Queryable().Where(x=>x.bill_id==purchaseDs.First().bill_id).OrderBy(x=>x.id).ToListAsync(); - List materialIds = purchaseDs.Select(x=>x.material_id).Distinct().ToList(); - List unitCodes = purchaseDs.Select(x => x.unit_id).Distinct().ToList(); - List unitDatas = await _db.Queryable() - .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) - .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode)) - .Select((x,y)=>y) - .ToListAsync(); - - List ids = new List(); - ids.Add(_userManager.UserId); - ids.Add(WmsWareHouseConst.AdministratorOrgId); - ids.Add(purchase.warehouse_id); - ids.AddRange(materialIds); - ids.AddRange(unitDatas.Select(x=>x.Id).ToList()); - - List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); - string erpCreateId = erpExtendFields.Find(x=>x.table_id==_userManager.UserId)?.user_id ?? ""; - ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId)); - string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - - List> requestData = new List>(); - Dictionary erpRequestData = new Dictionary(); - erpRequestData.Add("approver",erpCreateId); - erpRequestData.Add("billmaker",erpCreateId); - erpRequestData.Add("bisback",false); - erpRequestData.Add("creationtime",nowStr); - erpRequestData.Add("creator",erpCreateId); - erpRequestData.Add("ctrantypeid",""); - erpRequestData.Add("dbilldate",""); - erpRequestData.Add("dmakedate",nowStr); - erpRequestData.Add("ntotalastnum",purchaseDs.Sum(x=>x.purchase_arriveqty)); - erpRequestData.Add("pk_arriveorder",""); - erpRequestData.Add("pk_dept","1001A1100000000JRLI1A100"); - erpRequestData.Add("pk_dept_v","0001A11000000007GGO8"); - erpRequestData.Add("pk_org",erpOrg.pk_org); - erpRequestData.Add("pk_org_v",erpOrg.pk_org_v); - erpRequestData.Add("pk_group",erpOrg.pk_group); - erpRequestData.Add("pk_pupsndoc",""); - erpRequestData.Add("pk_purchaseorg",erpOrg.pk_org); - erpRequestData.Add("pk_purchaseorg_v",erpOrg.pk_org_v); - erpRequestData.Add("pk_supplier","1001A110000000000ZDB");//先写死 - erpRequestData.Add("pk_supplier_v","1001A110000000000ZDB");//先写死 - erpRequestData.Add("vbillcode",purchase.bill_code); - erpRequestData.Add("vmemo",purchase.remark); - erpRequestData.Add("vtrantypecode",""); - - List> erpRequestDataDetails = new List>(); - foreach(WmsPurchaseD item in dList) - { - erpRequestDataDetails.Add(new Dictionary() - { - ["castunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "", - ["cfirstbid"] = "", - ["cfirstid"] = "", - ["cfirsttypecode"] = "", - ["crececountryid"] = "0001Z010000000079UJJ", - ["crowno"] = (dList.FindIndex(x=>x.id==item.id)+1) * 10, - ["csendcountryid"] = "0001Z010000000079UJJ", - ["csourcetypecode"] = "", - ["ctaxcountryid"] = "0001Z010000000079UJJ", - ["cunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "", - ["dbilldate"] = "", - ["dplanreceivedate"] = "", - ["dproducedate"] = "", - ["fbuysellflag"] = 2, - ["fproductclass"] = 1, - ["naccumchecknum"] = 0, - // ["nastnum"] = 0, - ["nnum"] = item.purchase_arriveqty, - // ["nplanastnum"] = 0, - ["nplannum"] = item.purchase_qty, - ["apfinanceorg"] = erpOrg.pk_org, - ["pk_apfinanceorg_v"] = erpOrg.pk_org_v, - ["pk_arriveorder"] = "", - ["pk_arriveorder_b"] = "", - ["pk_group"] = "", - ["pk_material"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "", - ["pk_order"] = purchase.erp_bill_code, - // ["pk_order_b"] = "", - ["pk_org"] = erpOrg.pk_org, - ["pk_org_v"] = erpOrg.pk_org_v, - ["pk_psfinanceorg"] = erpOrg.pk_org_v, - ["pk_psfinanceorg_v"] = erpOrg.pk_org_v, - ["pk_receivestore"] = erpExtendFields.Find(x=>x.table_id==purchase.warehouse_id)?.cotherwhid ?? "", - ["pk_reqstoorg"] = erpOrg.pk_org, - ["pk_reqstoorg_v"] = erpOrg.pk_org_v, - }); - } - erpRequestData.Add("ArriveItemVODtl",erpRequestDataDetails); - requestData.Add(erpRequestData); - - ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord(); - thirdWebapiRecord.id = SnowflakeIdHelper.NextId(); - thirdWebapiRecord.third_name = WmsWareHouseConst.BIP; - thirdWebapiRecord.name = "采购到货"; - thirdWebapiRecord.method = "POST"; - thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save"; - thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); - thirdWebapiRecord.create_time = DateTime.Now; - - await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); } //通知Mes接口 //_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号); From 757bdf8cb9261d328fa67e7bf213c06bdb96f405 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 14:12:52 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E5=AE=9A=E7=82=B9?= =?UTF-8?q?=E9=85=8D=E9=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/TimeWorkService.cs | 148 +++++++++++++++++- 1 file changed, 144 insertions(+), 4 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index c407d322..51079787 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -247,6 +247,132 @@ namespace Tnb.ProductionMgr return msg; } + // [HttpGet] + // [AllowAnonymous] + // public async Task FixedPointDelivery() + // { + // string state = await _redisData.TryGetValueByKeyField("YTCS", "State"); + // if ("OK" != state) + // { + // Log.Error($"TCS没开机"); + // return "YTCS没开机"; + // } + // string stateHxja = await _redisData.TryGetValueByKeyField("hxjA", "State"); + // string stateHxjc = await _redisData.TryGetValueByKeyField("hxjC", "State"); + // List hxjList = new List(); + // if ("OK" == stateHxja) + // { + // hxjList.Add("hxjA"); + // } + // if ("OK" == stateHxjc) + // { + // hxjList.Add("hxjC"); + // } + // + // if (hxjList.IsEmpty()) + // { + // Log.Error($"hxjA,hxjC不正常"); + // return "hxjA,hxjC不正常"; + // } + // string msg = ""; + // List equipments = await _db.Queryable() + // .InnerJoin((x, y) => x.id == y.equip_type_id) + // .Where((x, y) => x.code == "ZSJ") + // .Select((x, y) => y).ToListAsync(); + // + // int? cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); + // int? cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); + // + // List eqpIds = equipments.Select(x => x.id).ToList(); + // List eqpDaqs = await _db.Queryable().Where(x => eqpIds.Contains(x.equip_id) && x.label_name.Contains("允许入空箱")).ToListAsync(); + // //BasFactoryConfig config = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN); + // foreach (var equipment in equipments) + // { + // EqpDaq eqpDaq = eqpDaqs.FirstOrDefault(x => x.equip_id==equipment.id); + // if (eqpDaq == null) + // { + // Log.Error($"{equipment.name}没配置允许入空箱"); + // continue; + // } + // if (!hxjList.Contains(eqpDaq.equip_code)) + // { + // Log.Error($"{eqpDaq.equip_code}状态不正常"); + // continue; + // } + // if (string.IsNullOrEmpty(equipment.upmat_location_id)) + // { + // Log.Error($"{equipment.name}未配置上料库位"); + // continue; + // } + // if (await _db.Queryable().AnyAsync(x => + // x.endlocation_id == equipment.upmat_location_id && + // x.biz_type == WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID && + // (x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID + // || x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID + // || x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_START_ID + // ) + // )) + // { + // Log.Error($"{equipment.name}存在未完成的任务"); + // continue; + // } + // bool? value = await _redisData.TryGetValueByKeyField(eqpDaq.equip_code, eqpDaq.label_name); + // bool valueFlag = _redisData.Get($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag"); + // Log.Information($"机台号{eqpDaq.equip_code},标签名{eqpDaq.label_name}redis的值为{value.ToString()}"); + // + // if (value==true && !valueFlag) + // { + // bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); + // bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); + // string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; + // if (cs01==true && cs03==true) + // { + // string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; + // if (string.IsNullOrEmpty(last_fixed_point_delivery)) + // { + // startLocationCode = "ZSSSXCTU01"; + // } + // else + // { + // startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); + // } + // } + // if (startLocationCode.IsEmpty()) + // { + // Log.Error($"输送线无空载具"); + // return "输送线无空载具"; + // } + // + // BasLocation startLocation = await _db.Queryable().Where(x=>x.location_code==startLocationCode).FirstAsync(); + // CommonCreatePretaskInput postData = new CommonCreatePretaskInput(); + // postData.startlocation_id = startLocation.id; + // postData.endlocation_id = equipment.upmat_location_id; + // postData.biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID; + // postData.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; + // Log.Information($"【FixedPointDelivery】注塑定点配送,参数:{JsonConvert.SerializeObject(postData)}"); + // Result result = await _wareHouseService.CommonCreatePretask(postData); + // // string sendResult = HttpUtils.RequestPost($"{config.value}/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); + // // string sendResult = HttpUtils.RequestPost($"http://localhost:9232/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); + // // AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + // if(result.code == HttpStatusCode.OK) + // { + // msg += $"{equipment.name}注塑定点配送成功,"; + // Log.Information($"【FixedPointDelivery】{equipment.name}注塑定点配送成功"); + // _redisData.Set($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag", true, TimeSpan.FromMinutes(20)); + // _redisData.Set($"last_fixed_point_delivery", startLocationCode); + // } + // else + // { + // msg += $"{equipment.name}注塑定点配送失败:{result.msg},"; + // Log.Error($"【FixedPointDelivery】{equipment.name}注塑定点配送失败:{result.msg}"); + // } + // + // } + // } + // + // return msg; + // } + [HttpGet] [AllowAnonymous] public async Task FixedPointDelivery() @@ -280,8 +406,8 @@ namespace Tnb.ProductionMgr .Where((x, y) => x.code == "ZSJ") .Select((x, y) => y).ToListAsync(); - int? cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); - int? cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); + int cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); + int cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); List eqpIds = equipments.Select(x => x.id).ToList(); List eqpDaqs = await _db.Queryable().Where(x => eqpIds.Contains(x.equip_id) && x.label_name.Contains("允许入空箱")).ToListAsync(); @@ -324,8 +450,9 @@ namespace Tnb.ProductionMgr { bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); - string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; - if (cs01==true && cs03==true) + string startLocationCode = ""; + + if (cs01==true && cs03==true && cs01Count>0 && cs03Count>0) { string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; if (string.IsNullOrEmpty(last_fixed_point_delivery)) @@ -337,6 +464,19 @@ namespace Tnb.ProductionMgr startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); } } + else + { + if (cs01==true && cs01Count > 0) + { + startLocationCode = "ZSSSXCTU01"; + cs01Count--; + }else if (cs03==true && cs03Count > 0) + { + startLocationCode = "ZSSSXCTU02"; + cs03Count--; + } + } + if (startLocationCode.IsEmpty()) { Log.Error($"输送线无空载具");