diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index d59ffd89..7a451c34 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -14,7 +14,10 @@ using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.VisualDev; using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; +using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.WarehouseMgr.Entities.Entity; @@ -43,6 +46,7 @@ namespace Tnb.WarehouseMgr } } } + [NonAction] protected async Task DoUpdate(WareHouseUpInput input) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 5b2ab182..4c1460cf 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -102,7 +102,7 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task ApplyFor(InOutStockApplyforUpInput input) { - if (input == null) throw new ArgumentNullException("input"); + if (input == null) throw new ArgumentNullException(nameof(input)); async Task _updateLocalFunc(InOutStockApplyforUpInput input) where TStockD : BaseEntity, new() @@ -151,7 +151,7 @@ namespace Tnb.WarehouseMgr { CodeDetails = SqlFunc.Subqueryable().Where(it => it.bill_d_id == a.id).ToList(), }, true) - .Mapper(it => it.line_status = dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "") + .Mapper(it => it.line_status = it.line_status != null && dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "") .ToListAsync(); return data; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs index bc4576b2..8035deb5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs @@ -1,14 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Interfaces; @@ -38,18 +41,21 @@ namespace Tnb.WarehouseMgr { dicMaterial = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.name); } - var items = await _db.Queryable().Where(a => a.carry_id == carryId) - .Select(a => new CarryCodeDetailOutput - { - barcode = a.barcode, - code_batch = a.code_batch!, - codeqty = a.codeqty, - material_code = a.material_code, - material_id = a.material_id, - unit_id = a.unit_id, - }) - .Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString()! : "") + var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); + List items = new(); + List carryMIds = new(); + if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) + { + var carryDs = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); + carryMIds = carryDs.Select(x => x.membercarry_id).ToList(); + } + Expression> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId; + items = await _db.Queryable().Where(whereExp) + .Select() + .Mapper(it => it.material_name = (it.material_id != null && dicMaterial.ContainsKey(it.material_id)) ? dicMaterial[it.material_id].ToString() : "") .ToListAsync(); + + return items ?? Enumerable.Empty(); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 95aefa47..a6d55e85 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -72,7 +73,11 @@ namespace Tnb.WarehouseMgr { foreach (var ko in kittingOuts) { - var carrys = await _db.Queryable().Where(it => it.collocation_scheme_id == ko.collocation_scheme_id && it.is_lock == 0).ToListAsync(); + var carrys = await _db.Queryable() + .InnerJoin((a,b) => a.collocation_scheme_id == b.id) + .Where(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0) + .OrderBy((a,b)=>b.seq) + .ToListAsync(); if (carrys?.Count > 0) { var firstCarry = carrys.FirstOrDefault(); @@ -131,7 +136,7 @@ namespace Tnb.WarehouseMgr /// /// [HttpPost] - public async Task KittingOutByIsToBeShipped(IDbTransaction? tran = null) + public async Task KittingOutByIsToBeShipped() { try { @@ -152,10 +157,13 @@ namespace Tnb.WarehouseMgr var carry = await _db.Queryable().SingleAsync(it => it.id == ko.carry_id); if (carry != null) { + WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == ko.location_id); if (sPoint != null && ePoint != null) { + //判断目标库位是否自动签收 + var loc = await _db.Queryable().SingleAsync(it => it.id == ePoint.location_id); var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id); if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); if (points?.Count > 0) @@ -165,36 +173,38 @@ namespace Tnb.WarehouseMgr var sPoint = it.FirstOrDefault(); var 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(), - bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), - status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, - biz_type = ko.biz_type, - task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID, - carry_id = ko!.carry_id!, - carry_code = ko!.carry_code!, - area_id = sPoint?.area_id!, - area_code = it.Key, - require_id = ko.id, - require_code = ko.bill_code, - create_id = _userManager.UserId, - create_time = DateTime.Now - }; + WmsPretaskH preTask = new(); + preTask.org_id = _userManager.User.OrganizeId; + preTask.startlocation_id = sPoint?.location_id!; + preTask.startlocation_code = sPoint?.location_code!; + preTask.endlocation_id = ePoint?.location_id!; + preTask.endlocation_code = ePoint?.location_code!; + preTask.start_floor = sPoint?.floor.ToString(); + preTask.end_floor = ePoint?.floor.ToString(); + preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); + preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; + preTask.biz_type = ko.biz_type; + preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; + preTask.carry_id = ko!.carry_id!; + preTask.carry_code = ko!.carry_code!; + preTask.area_id = sPoint?.area_id!; + preTask.area_code = it.Key; + preTask.require_id = ko.id; + preTask.require_code = ko.bill_code; + preTask.create_id = _userManager.UserId; + preTask.create_time = DateTime.Now; return preTask; }).ToList(); + if (loc.is_sign == 0) + { + preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 + } await _warehouseService.GenPreTask(preTasks, null!); var subCarrys = await _db.Queryable().Where(it => it.carry_id == ko.carry_id).ToListAsync(); var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList(); GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List { carry.location_id!, ko.location_id! } }; await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套).ToString() }, it => new BasLocation { is_lock = 1 }); - + await _db.Updateable().SetColumns(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).Where(it => it.id == ko.id).ExecuteCommandAsync(); } } }