From b770e0d83d4b9d8ba4665b326c6ec9a37a43b172 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Wed, 22 Nov 2023 10:59:31 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81agv=20=E4=BF=A1=E6=81=AF=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=B0=E5=A2=9Eswagger=E5=A4=87=E6=B3=A8=202?= =?UTF-8?q?=E3=80=81=E6=96=B0=E5=A2=9E=E7=9B=98=E7=82=B9=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/ModuleConsts.cs | 4 + .../Dto/Inputs/TakeStockSignInput.cs | 16 ++ .../Dto/Queries/CarryCodeInfoQuery.cs | 23 +++ .../Entity/WmsCarryCode.part.cs | 5 + .../Entity/WmsCheckstockD.part.cs | 5 + .../Tnb.WarehouseMgr/DeviceProviderService.cs | 8 +- .../Tnb.WarehouseMgr/WmsCheckTaskService.cs | 174 +++++++++++++++++- .../WmsPDATakeStockService.cs | 24 +++ 8 files changed, 250 insertions(+), 9 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TakeStockSignInput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CarryCodeInfoQuery.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsPDATakeStockService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index 0851a960..49e67eac 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -204,5 +204,9 @@ public class ModuleConsts /// 模块标识-盘点签收配置 /// public const string MODULE_WMSCHECKSIGNCONFIG_ID = "30059737083669"; + /// + /// 模块标识-PDA盘点签收 + /// + public const string MODLUE_WMSTASKSTOCK_ID = "27690726707477"; } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TakeStockSignInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TakeStockSignInput.cs new file mode 100644 index 00000000..d116f304 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/TakeStockSignInput.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Inputs +{ + /// + /// Pda盘点签收输入参数 + /// + public class TakeStockSignInput + { + public List details{ get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CarryCodeInfoQuery.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CarryCodeInfoQuery.cs new file mode 100644 index 00000000..a1d01ca3 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CarryCodeInfoQuery.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Queries +{ + /// + /// 根据条码编号、载具Id获取条码信息输入参数 + /// + public class CarryCodeInfoQuery + { + /// + /// 条码编号 + /// + public string barcode { get; set; } + /// + /// 载具Id + /// + public string carryId { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs index abc29c92..4a5c092c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.part.cs @@ -43,5 +43,10 @@ public partial class WmsCarryCode /// [SugarColumn(IsIgnore = true)] public decimal pr_qty { get; set; } + /// + /// 载具编码 + /// + [SugarColumn(IsIgnore = true)] + public string carry_code { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockD.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockD.part.cs index 26c04195..1fea5ddc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockD.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockD.part.cs @@ -12,5 +12,10 @@ public partial class WmsCheckstockD /// [SugarColumn(IsIgnore = true)] public decimal codeqty { get; set; } + /// + /// 待盘点数量 + /// + [SugarColumn(IsIgnore = true)] + public decimal? delayeqty { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index 0afc5cfb..a5044d16 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -370,13 +370,13 @@ namespace Tnb.WarehouseMgr /// 根据产线获取Agv列表 /// /// 产线Id,默认空,(潍柴的只有一条产线所以不用传) - /// + /// /// returns: ///
{ ///
name:设备名称 ///
code:设备代码 ///
} - ///
+ /// [HttpGet("lineId"), AllowAnonymous] public async Task GetAgvListByLineId(string lineId = "") { @@ -394,7 +394,7 @@ namespace Tnb.WarehouseMgr /// 获取Agv实时信息 /// /// 查询输入参数 - /// + /// ///
{ ///
deviceCode:设备序号 ///
devicePostionRec:设备所在二维码的x,y坐标,前边的值是x,后边的是y @@ -403,7 +403,7 @@ namespace Tnb.WarehouseMgr ///
speed:速度 ///
shelfNumber:当前搬运的货架编号,对应载具编号 ///
} - ///
+ /// [HttpGet, AllowAnonymous] public async Task> GetAgvRealInfo([FromQuery] AgvRealInfoQuery q) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs index d919a626..d2df50e3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Linq.Expressions; +using Aop.Api.Domain; using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Extension; @@ -12,12 +13,16 @@ using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using NPOI.OpenXmlFormats.Dml.Spreadsheet; +using NPOI.SS.Formula.PTG; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.WarehouseMgr.Entities.Dto.Queries; using Tnb.WarehouseMgr.Entities.Enums; @@ -146,7 +151,7 @@ namespace Tnb.WarehouseMgr var carryCodes = await _db.Queryable().InnerJoin((a, b) => a.id == b.location_id) .InnerJoin((a, b, c) => b.carry_id == c.id) .Where(filterExpable.ToExpression()) - .Select() + .Select((a, b, c) => new WmsCarryCode { carry_code = c.carry_code }, true) .ToListAsync(); carryCodes ??= Enumerable.Empty().ToList(); @@ -166,7 +171,7 @@ namespace Tnb.WarehouseMgr details.Add(checkstockD); } } - var r = await _db.Insertable(details).ExecuteCommandAsync(); + var r = await _db.Insertable(details).ExecuteCommandAsync(); //生成预任务信息 if (details.Count > 0 && carryCodes.Count > 0) { @@ -237,6 +242,9 @@ namespace Tnb.WarehouseMgr startlocation_code = sPoint?.location_code!, endlocation_id = ePoint?.location_id!, endlocation_code = ePoint?.location_code!, + startpoint_id = sPoint?.id!, + endpoint_id = ePoint?.id!, + endpoint_code = ePoint?.point_code!, start_floor = sPoint?.floor.ToString(), end_floor = ePoint?.floor.ToString(), bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), @@ -309,7 +317,7 @@ namespace Tnb.WarehouseMgr private Task> FetchDisTasks(Expression> joinExp, Expression> whereExp) { - var details= _db.CopyNew().Queryable().InnerJoin(joinExp).Where(whereExp).Select().ToListAsync(); + var details = _db.CopyNew().Queryable().InnerJoin(joinExp).Where(whereExp).Select().ToListAsync(); return details; } /// @@ -320,7 +328,10 @@ namespace Tnb.WarehouseMgr [HttpGet("{checkStockId}")] public async Task> GetCheckStockDList(string checkStockId) { - var details = await _db.Queryable().Where(it => it.checkstock_id == checkStockId).ToListAsync(); + var details = await _db.Queryable().Where(it => it.checkstock_id == checkStockId) + .Select() + .Mapper(it => it.delayeqty = Math.Max(0, it.pr_qty.Value - it.qty.Value)) + .ToListAsync(); return details; } @@ -380,7 +391,7 @@ namespace Tnb.WarehouseMgr var carryCodes = await _db.Queryable().InnerJoin((a, b) => a.id == b.location_id) .InnerJoin((a, b, c) => b.carry_id == c.id) .Where(filterExp) - .Select() + .Select((a, b, c) => new WmsCarryCode { carry_code = c.carry_code }, true) .ToListAsync(); List outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new WmsCheckstockD @@ -398,5 +409,158 @@ namespace Tnb.WarehouseMgr .ToList(); return outputs; } + /// + /// 获取盘点任务信息 + /// + /// 载具编号 + /// + /// + /// + /// + [HttpGet("{carryCode}")] + public async Task GetCheckTaskInfo(string carryCode) + { + var result = await _db.Queryable().InnerJoin((a, b) => a.require_id == b.id) + .Where((a, b) => a.carry_code == carryCode) + .Select() + .ToListAsync(); + return result; + } + /// + /// 根据条码编号和载具id获取对应载具条码信息 + /// + /// + /// + public async Task GetCarryCodeInfoByBarCode([FromQuery] CarryCodeInfoQuery q) + { + var items = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id) + .Where((a, b) => b.barcode == q.barcode && b.carry_id == q.carryId) + .Select((a, b) => new WmsCarryCode { carry_code = a.carry_code }, true) + .ToListAsync(); + return items; + } + + public async Task TakeStockSign(TakeStockSignInput input) + { + if (input == null) throw new ArgumentNullException("input"); + if (input.details == null) throw new ArgumentNullException(nameof(input.details)); + var checkStockCodes = input.details.Adapt>(); + + + var disTask = await _db.Queryable().Where(it => it.carry_id == checkStockCodes[0].carry_id && + it.status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID && + it.is_sign == 0).FirstAsync(); + + if (disTask != null) + { + disTask.is_sign = 1; + _ = await _db.Updateable(disTask).UpdateColumns(it => it.is_sign).ExecuteCommandAsync(); + } + var checkStock = await _db.Queryable().SingleAsync(it => it.id == checkStockCodes[0].checkstock_id); + if (checkStock != null) + { + InStockStrategyQuery q = new() { warehouse_id = checkStock.warehouse_id }; + var endLocs = await _warehouseService.InStockStrategy(q); + WmsPointH? sPoint = null, ePoint = null; + var carry = await _db.Queryable().SingleAsync(it => it.id == checkStockCodes[0].carry_id); + sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); + if (endLocs?.Count > 0) + { + ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocs[0].id); + } + if (sPoint == null || ePoint == null) throw new AppFriendlyException("路径无效", 500); + List points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id); + //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + if (points?.Count > 0) + { + if (points.Count <= 2) + { + throw new AppFriendlyException("该路径不存在", 500); + } + + List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => + { + WmsPointH? sPoint = it.FirstOrDefault(); + WmsPointH? ePoint = it.LastOrDefault(); + + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId!, + startlocation_id = sPoint?.location_id!, + startlocation_code = sPoint?.location_code!, + endlocation_id = ePoint?.location_id!, + endlocation_code = ePoint?.location_code!, + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + startpoint_id = sPoint?.id!, + startpoint_code = sPoint?.point_code!, + endpoint_id = ePoint?.id!, + endpoint_code = ePoint?.point_code!, + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID, + task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID, + carry_id = carry?.id, + carry_code = carry?.carry_code, + area_id = sPoint?.area_id!, + area_code = it.Key, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + + return preTask; + }).ToList(); + bool isOk = await _warehouseService.GenPreTask(preTasks, null!); + if (isOk) + { + GenPreTaskUpInput preTaskUpInput = new() + { + //RquireId = input.data["ReturnIdentity"].ToString()!, + CarryId = checkStockCodes[0].carry_id, + CarryStartLocationId = points.FirstOrDefault()!.location_id!, + CarryStartLocationCode = points.FirstOrDefault()!.location_code!, + LocationIds = points.Select(x => x.location_id).ToList()! + }; + + WmsHandleH handleH = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = carry.location_id, + endlocation_id = endLocs?[0].id ?? string.Empty, + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(), + biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID, + carry_id = checkStockCodes[0].carry_id, + carry_code = carry?.carry_code ?? string.Empty, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + preTaskUpInput.PreTaskRecord = handleH; + //根据载具移入Id,回更单据状态 + _ = await _db.Updateable().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); + + await _warehouseService.GenInStockTaskHandleAfter(preTaskUpInput, + it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, + it => new BasLocation { is_lock = 1 }); + } + } + } + + foreach (var csCode in checkStockCodes) + { + csCode.id = SnowflakeIdHelper.NextId(); + var checkStockPartDs = await _db.Queryable().Where(it => it.checkstock_id == csCode.checkstock_id).ToListAsync(); + var checkStockDMap = checkStockPartDs.GroupBy(g => $"{g.carry_id}{g.material_id}{g.code_batch}").ToDictionary(x => x.Key, x => x.First().id); + csCode.checkstock_d_id = checkStockDMap.ContainsKey($"{csCode.carry_id}{csCode.material_id}{csCode.code_batch}") ? checkStockDMap[$"{csCode.carry_id}{csCode.material_id}{csCode.code_batch}"] : ""; + } + //插入 盘点code表 + await _db.Insertable(checkStockCodes).ExecuteCommandAsync(); + var detailIds = checkStockCodes.Select(x => x.checkstock_d_id).ToList(); + var checkStockDs = _db.Queryable().Where(it => detailIds.Contains(it.id)).ToListAsync(); + foreach (var csCode in checkStockCodes) + { + + } + } + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATakeStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATakeStockService.cs new file mode 100644 index 00000000..768b56a8 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATakeStockService.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.VisualDev; +using SqlSugar; +using Tnb.WarehouseMgr.Entities; + +namespace Tnb.WarehouseMgr +{ + /// + /// Pda盘点 + /// + [OverideVisualDev(ModuleConsts.MODLUE_WMSTASKSTOCK_ID)] + public class WmsPDATakeStockService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + public WmsPDATakeStockService(ISqlSugarRepository repo) + { + _db = repo.AsSugarClient(); + } + } +}