diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Configs/AgvRequestConfig.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Configs/AgvRequestConfig.cs index 903932cf..ccb1db36 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Configs/AgvRequestConfig.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Configs/AgvRequestConfig.cs @@ -15,5 +15,9 @@ /// 取消任务链url请求地址 /// public string CancelTaskChainUrl { get; set; } + /// + /// 三四号梯关门前请求WCS地址 + /// + public string thirdFloorUrl { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 0916f041..11b628ee 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -1810,7 +1810,30 @@ namespace Tnb.WarehouseMgr whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.startlocation_id), (a, b, c) => b.location_id == input.startlocation_id); } - ISugarQueryable queryable = _db.CopyNew().Queryable().InnerJoin((a, b) => a.id == b.bill_id) + var db = _db.CopyNew(); + #region 如果是出到三楼出库缓存区 + + List queryable_f3outstock = db.Queryable() + .InnerJoin((a, b) => a.endlocation_id == b.id) + .InnerJoin((a, b, c) => a.endlocation_code == c.startlocation_code) + .InnerJoin((a, b, c, d) => c.endlocation_code == d.location_code) + .InnerJoin((a, b, c, d, e) => d.bill_id == e.id) + .Where((a, b, c, d, e) => a.endlocation_id == input.endlocation_id && a.bill_code == input.taskCode && b.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID) + .Select((a, b, c, d, e) => new WmsElevatorH + { + bill_code = a.bill_code, + device_id = e.elevator_id, + end_floor = a.end_floor + }).ToList(); + if (queryable_f3outstock.Count() > 0) + { + var ele_f3outstock = queryable_f3outstock[0]; + + return ele_f3outstock; + } + #endregion + + ISugarQueryable queryable = db.Queryable().InnerJoin((a, b) => a.id == b.bill_id) .InnerJoin((a, b, c) => b.location_code == c.endlocation_code || b.location_code == c.startlocation_code) .Where(whereExpable.ToExpression()) .WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-R", input.sourceName), (a, b, c) => c.startpoint_code == input.sourceName) @@ -1824,6 +1847,8 @@ namespace Tnb.WarehouseMgr var ele = await queryable.FirstAsync(); + + Logger.Information($"【FindElevatorFromPars】 " + queryable.ToSqlString()); return ele; @@ -2296,7 +2321,7 @@ namespace Tnb.WarehouseMgr if (doubleCarryRunElevators.Contains(devName) && disTasks[0].end_floor == 1) { AgvRequestConfig requestCfg = App.Configuration.Build(); - string url = requestCfg.AgvRequestUrls.CreateTaskChainUrl; + string url = requestCfg.AgvRequestUrls.thirdFloorUrl; dynamic reqBody = new ExpandoObject(); reqBody.floor = devName == "Elevator3" ? "03" : "04"; reqBody.isDown = true; @@ -2304,10 +2329,15 @@ namespace Tnb.WarehouseMgr Logger.Information($"【ElevatorTaskExceptionHandle】 电梯{devName}下行 开始请求WCS lift/thirdFloor接口 请求地址:{url} 请求参数:{JsonConvert.SerializeObject(reqBody)} "); dynamic respBody = await HttpClientHelper.PostStreamAsync(url, reqBody, Ctu.Token); Logger.Information($"【ElevatorTaskExceptionHandle】 电梯{devName}下行 接收到WCS lift/thirdFloor接口信息:{respBody}"); - if (respBody.code != "200") + JObject respBodyobj = JObject.Parse(respBody); + if (respBodyobj["code"].ToString() != "200") { throw new Exception($"通知WCS电梯{devName}下行接口调用错误"); } + else + { + throw new Exception($"通知WCS电梯{devName}下行接口调用成功"); + } } } @@ -2611,7 +2641,7 @@ namespace Tnb.WarehouseMgr { eleUpdateRow += await db.Updateable().SetColumns(it => new WmsElevatorH { task_nums = it.task_nums - 1 }).Where(it => disTask.area_code == it.area_code).ExecuteCommandAsync(); } - Logger.LogInformation($"【TaskComplate】更新前电梯{disTasks[0].area_code}任务行数{eleUpdateRow}"); + Logger.LogInformation($"【TaskComplate】更新电梯{disTasks[0].area_code}任务行数{eleUpdateRow}"); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs index 40ed29c0..74ba8cd0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs @@ -72,13 +72,12 @@ namespace Tnb.WarehouseMgr Logger.Information($"进入成品调拨入库单上传BIP逻辑"); - WmsInstockH instock = await _db.Queryable().SingleAsync(x => x.id == input.requireId); - List allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + string TransferInstockDId = input.requireId; + WmsTransferInstockD wmsTransferInstockD = await _db.Queryable().SingleAsync(x => x.id == TransferInstockDId); + string TransferInstockHId = wmsTransferInstockD?.bill_id ?? ""; + WmsTransferInstockH wmsTransferInstockH = await _db.Queryable().SingleAsync(x => x.id == TransferInstockHId); - string rawmatTransferinstockDId = input.source_id; - WmsRawmatTransferinstockD wmsRawmatTransferinstockD = await _db.Queryable().SingleAsync(x => x.id == rawmatTransferinstockDId); - string rawmatTransferinstockHId = wmsRawmatTransferinstockD?.bill_id ?? ""; - WmsRawmatTransferinstockH wmsRawmatTransferinstockH = await _db.Queryable().SingleAsync(x => x.id == rawmatTransferinstockHId); + List allInstockDetails = await _db.Queryable().Where(it => it.bill_id == TransferInstockHId).ToListAsync(); List materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList(); List unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().ToList(); @@ -88,9 +87,9 @@ namespace Tnb.WarehouseMgr .Select((x, y) => y) .ToListAsync(); List erpWarehouserelaHs = await _db.Queryable().Where(x=>x.id!=null).ToListAsync(); - BasWarehouse basWarehouse = await _db.Queryable().SingleAsync(x=>x.id==instock.warehouse_id); - string userAccount = wmsRawmatTransferinstockH?.biller ?? ""; - string deptCode = wmsRawmatTransferinstockH?.dept_code ?? ""; + BasWarehouse basWarehouse = await _db.Queryable().Where(r => r.id == WmsWareHouseConst.WAREHOUSE_CP_ID).FirstAsync(); + string userAccount = wmsTransferInstockH?.biller ?? ""; + string deptCode = wmsTransferInstockH?.dept_code ?? ""; UserEntity userEntity = await _db.Queryable().Where(x=>x.Account==userAccount).FirstAsync(); string userId = userEntity?.Id ?? WmsWareHouseConst.AdministratorUserId; @@ -98,7 +97,7 @@ namespace Tnb.WarehouseMgr List tableIds = new List(); tableIds.Add(userId); tableIds.Add(WmsWareHouseConst.AdministratorOrgId); - tableIds.Add(instock.warehouse_id); + tableIds.Add(basWarehouse.id); tableIds.AddRange(materialIds); tableIds.Add(supplierId); tableIds.AddRange(unitDatas.Select(x => x.Id).ToList()); @@ -128,14 +127,18 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("pk_org_v", erpOrg.pk_org_v); erpRequestData.Add("pk_group", erpOrg.pk_group); erpRequestData.Add("vdef1", null); - erpRequestData.Add("vbillcode", instock.bill_code); + erpRequestData.Add("vbillcode", wmsTransferInstockH.bill_code); erpRequestData.Add("ctrantypeid", "0001H11000000000D31E");//先写死 erpRequestData.Add("vtrantypecode", "4E-01");//先写死 - erpRequestData.Add("csourcebillhid", wmsRawmatTransferinstockH?.erp_pk ?? ""); - + erpRequestData.Add("csourcebillhid", wmsTransferInstockH?.erp_pk ?? ""); + + List wmsCarryCodes = _db.Queryable().Where(r => r.carry_id == input.wmsDistaskH.carry_id) + .Where(r => r.material_id == wmsTransferInstockD.material_id && r.code_batch == wmsTransferInstockD.pi_code).ToList(); + + decimal qty = wmsCarryCodes.Sum(r => r.codeqty); List> erpRequestDataDetails = new List>(); - foreach (WmsInstockD item in allInstockDetails) + foreach (WmsTransferInstockD item in allInstockDetails) { erpRequestDataDetails.Add(new Dictionary() { @@ -147,24 +150,24 @@ namespace Tnb.WarehouseMgr ["corpoid"] = erpOrg.corpoid, ["corpvid"] = erpOrg.corpvid, ["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10, - ["csourcebillhid"] = wmsRawmatTransferinstockH?.erp_pk ?? "", - ["csourcebillbid"] = wmsRawmatTransferinstockD?.erp_line_pk ?? "", + ["csourcebillhid"] = wmsTransferInstockH?.erp_pk ?? "", + ["csourcebillbid"] = wmsTransferInstockD?.erp_line_pk ?? "", ["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "", ["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "", ["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "", - ["dbizdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"), - ["dplanarrivedate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"), - ["dplanoutdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"), + ["dbizdate"] = wmsTransferInstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + ["dplanarrivedate"] = wmsTransferInstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), + ["dplanoutdate"] = wmsTransferInstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), // ["nnum"] = item.qty, // ["nshouldnum"] = item.pr_qty, - ["nnum"] = wmsRawmatTransferinstockD.actual_qty, - ["nshouldnum"] = wmsRawmatTransferinstockD.actual_qty, + ["nnum"] = qty, + ["nshouldnum"] = qty, ["pk_group"] = erpOrg.pk_group, ["pk_org"] = erpOrg.pk_org, ["pk_org_v"] = erpOrg.pk_org_v, - ["vbatchcode"] = item.code_batch, - ["coutcalbodyoid"] = wmsRawmatTransferinstockH.outstockorg_code, - ["coutcalbodyvid"] = wmsRawmatTransferinstockH.outstockorg_id, + ["vbatchcode"] = item.pi_code, + ["coutcalbodyoid"] = wmsTransferInstockH.outstockorg_code, + ["coutcalbodyvid"] = wmsTransferInstockH.outstockorg_id, }); } erpRequestData.Add("dtls", erpRequestDataDetails); diff --git a/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json b/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json index 697ba175..7b3082bf 100644 --- a/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json +++ b/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json @@ -1,6 +1,7 @@ { "AgvRequestUrls": { "CreateTaskChainUrl": "http://10.147.19.104:5013/api/task-chain/create", - "CancelTaskChainUrl": "http://192.168.11.104:1880/api/task-chain/cancel" + "CancelTaskChainUrl": "http://192.168.11.104:1880/api/task-chain/cancel", + "thirdFloorUrl": "http://192.168.11.104:1880/api/lift/thirdFloor" } } \ No newline at end of file