From 0afdf90a19c101bf708dab447ff5d7d137edb5b6 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 09:43:23 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E6=B6=88=E9=99=A4=E9=83=A8=E5=88=86warni?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WareHouseService.cs | 2 +- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 16 ++++++++++++---- .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 13 +++++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index ae11f831..fe61e471 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -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 = dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "") .ToListAsync(); return data; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 5219afc2..f4c41568 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -150,7 +150,7 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat? carryMat = x.FirstOrDefault(); + WmsCarryMat carryMat = new(); carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) @@ -353,11 +353,19 @@ namespace Tnb.WarehouseMgr { List carryMats = new(); List carryCodes = new(); + var whereExp = Expressionable.Create() + .And((a, b, c) => a.is_lock == 0) + .And((a, b, c) => !string.IsNullOrEmpty(a.location_id)) + .And((a, b, c) => a.status == (int)EnumCarryStatus.占用) + .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString()); + foreach (var os in outStockDList) { + whereExp.And((a, b, c) => b.material_id == os.material_id) + .AndIF(!string.IsNullOrEmpty(os.code_batch), (a, b, c) => b.code_batch == os.code_batch); + var carryCodesPart = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id).InnerJoin((a, b, c) => a.location_id == c.id) - .Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.占用 && c.is_type == ((int)EnumLocationType.存储库位).ToString()) - .WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch) + .Where(whereExp.ToExpression()) .Select() .ToListAsync(); if (carryCodesPart?.Count > 0) @@ -399,7 +407,7 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat? carryMat = x.FirstOrDefault()!; + WmsCarryMat carryMat = new(); carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 7b5c05af..282556f8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -50,7 +50,7 @@ namespace Tnb.WarehouseMgr /// /// [HttpPost] - public async Task PackSortingByAdd() + public async Task PackSortingByAdd(WmsCarryMat? carryMat) { var setSortings = await _db.Queryable() .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq) @@ -142,10 +142,11 @@ namespace Tnb.WarehouseMgr List preTasks = new(); List locIds = new(); string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; - if (carrys.Length > 6) + var mid = 6; + if (carrys.Length > mid) { - var leftCarrys = carrys[..6]; - var rightCarrys = carrys[6..]; + var leftCarrys = carrys[..mid]; + var rightCarrys = carrys[mid..]; await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks); } @@ -167,7 +168,7 @@ namespace Tnb.WarehouseMgr pretaskCodes.AddRange(curPreTaskCodes); } await _wareHouseService.GenPreTask(preTasks, pretaskCodes); - await _db.Updateable().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it=> it.id == singleSorting.id).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == singleSorting.id).ExecuteCommandAsync(); GenPreTaskUpInput genPreTaskAfterUpInput = new(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList(); @@ -298,7 +299,7 @@ namespace Tnb.WarehouseMgr var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); if (carry != null) { - if (carry!.location_id!.IsNotEmptyOrNull()) + if (carry.location_id?.IsNotEmptyOrNull() ?? false) { await _db.Updateable().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.空闲).ToString() }).Where(it => it.id == carry.location_id).ExecuteCommandAsync(); } From 713247236c6163e2ff4795aca416e259b042c8e6 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 10:09:20 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=B6=88=E9=99=A4=E9=83=A8=E5=88=86warni?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WareHouseService.cs | 17 ++----- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 6 +-- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 48 ++++++++++--------- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index fe61e471..5b2ab182 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -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 = dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "") .ToListAsync(); return data; } @@ -555,20 +555,13 @@ namespace Tnb.WarehouseMgr //根据载具ID,更新是否锁定和赋值起始库位 if (setCarryColumnsExp != null) { - if (input.CarryIds?.Count > 0) - { - await _db.Updateable().SetColumns(setCarryColumnsExp).Where(it => input.CarryIds.Contains(it.id)).ExecuteCommandAsync(); - } - else - { - await _db.Updateable().SetColumns(setCarryColumnsExp).Where(it => it.id == input.CarryId).ExecuteCommandAsync(); - } + Expression> whereExp = input.CarryIds?.Count > 0 ? it => input.CarryIds.Contains(it.id) : it => it.id == input.CarryId; + await _db.Updateable().SetColumns(setCarryColumnsExp).Where(whereExp).ExecuteCommandAsync(); } - //根据所有库位更新库位的锁定状态为“锁定” - if (setLocaionColumbExp != null) + if (setLocaionColumbExp != null && input.LocationIds?.Count > 0) { - await _db.Updateable().SetColumns(setLocaionColumbExp).Where(it => input.LocationIds!.Contains(it.id)).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(setLocaionColumbExp).Where(it => input.LocationIds.Contains(it.id)).ExecuteCommandAsync(); } await _db.Ado.CommitTranAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index f4c41568..357de608 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -443,10 +443,8 @@ namespace Tnb.WarehouseMgr List locIds = new(); foreach (var carry in carrys) { - WmsPointH sPoint = null!; - WmsPointH ePoint = null!; - sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); - ePoint = await _db.Queryable().FirstAsync(it => it.location_id == outstock.location_id.ToString()); + WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); + WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == outstock.location_id.ToString()); if (sPoint != null && ePoint != null) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 38aefcb1..95aefa47 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -76,11 +76,11 @@ namespace Tnb.WarehouseMgr if (carrys?.Count > 0) { var firstCarry = carrys.FirstOrDefault(); - GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry!.id! }; + GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry?.id }; await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1 }, null!); ko.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID; - ko.carry_id = firstCarry.id; - ko.carry_code = firstCarry.carry_code; + ko.carry_id = firstCarry?.id; + ko.carry_code = firstCarry?.carry_code; await _db.Updateable(ko).UpdateColumns(it => new { it.status, it.carry_id, it.carry_code }).ExecuteCommandAsync(); } else @@ -165,26 +165,28 @@ namespace Tnb.WarehouseMgr var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - 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; + 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 + }; return preTask; }).ToList(); await _warehouseService.GenPreTask(preTasks, null!); From 25c81366b66f9b15986f360119dcb45bfde28b04 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Mon, 17 Jul 2023 11:29:01 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E8=BD=BD=E5=85=B7=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=EF=BC=8C=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WebApiConst.cs | 16 +++ .../Dto/PrdManage/PrdInstockInput.cs | 34 ++++++ .../Entity/PrdInstockD.cs | 7 +- .../Entity/PrdInstockH.cs | 8 +- .../IPrdInstockService.cs | 9 ++ .../Tnb.ProductionMgr/PrdFeedingService.cs | 40 +++++-- .../Tnb.ProductionMgr/PrdInstockService.cs | 112 +++++++++++++++++- .../Tnb.ProductionMgr.csproj | 1 - 8 files changed, 205 insertions(+), 22 deletions(-) create mode 100644 BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs new file mode 100644 index 00000000..c3312e59 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs @@ -0,0 +1,16 @@ +namespace Tnb.BasicData +{ + public static class WebApiConst + { + #region wms + + //mes生产入库接口 + public const string MES_CREATE_INSTOCK = "/api/wms/wms-in-stock/mes-create-instock"; + + //载具签收接口 + public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign"; + + #endregion + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs new file mode 100644 index 00000000..485e4233 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs @@ -0,0 +1,34 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class PrdInstockInput + { + + /// + /// 单据类型 + /// + public string bill_type { get; set; } = string.Empty; + + + /// + /// 载具编号 + /// + public string carry_code { get; set; } = string.Empty; + + /// + /// 起始库位编号 + /// + public string location_code { get; set; } = string.Empty; + + + /// + /// 检验(0-未检 1-已检) + /// + public int is_check { get; set; } + + /// + /// 子表明细 + /// + public List> details { get; set; } + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs index 7bff1e66..04c6db66 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs @@ -37,7 +37,7 @@ public partial class PrdInstockD : BaseEntity /// /// 数量 /// - public string quantity { get; set; } = string.Empty; + public int quantity { get; set; } /// /// 批次 @@ -49,4 +49,9 @@ public partial class PrdInstockD : BaseEntity /// public string barcode { get; set; } = string.Empty; + /// + /// 生产提报id + /// + public string report_id { get; set; } = string.Empty; + } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs index 9616f5d2..390c5651 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs @@ -38,16 +38,12 @@ public partial class PrdInstockH : BaseEntity /// 起始库位编号 /// public string location_code { get; set; } = string.Empty; - - /// - /// 来源单据ID - /// - public string source_id { get; set; } = string.Empty; + /// /// 检验(0-未检 1-已检) /// - public string is_check { get; set; } = string.Empty; + public int is_check { get; set; } /// /// 创建用户 diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs index 4d48963a..5e6b5e87 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs @@ -1,3 +1,5 @@ +using Tnb.ProductionMgr.Entities.Dto; + namespace Tnb.ProductionMgr.Interfaces { /// @@ -6,6 +8,13 @@ namespace Tnb.ProductionMgr.Interfaces public interface IPrdInstockService { + /// + /// 生产入库报错 + /// + /// + /// + public Task SaveData(PrdInstockInput input); + /// /// 入库申请同步 /// diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 9e5a8039..2a0d6aec 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -1,13 +1,16 @@ +using JNPF; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using Microsoft.ClearScript.Util.Web; +using Newtonsoft.Json; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.ProductionMgr.Entities; @@ -16,6 +19,7 @@ using Tnb.ProductionMgr.Interfaces; using Tnb.ProductionMgr.Entities.Consts; using Tnb.WarehouseMgr; using Tnb.WarehouseMgr.Entities; +using Tnb.BasicData; namespace Tnb.ProductionMgr { @@ -29,20 +33,20 @@ namespace Tnb.ProductionMgr private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; - private readonly WmsSignForDeliveryService _wmsSignForDeliveryService; + // private readonly WmsSignForDeliveryService _wmsSignForDeliveryService; public PrdFeedingService( ISqlSugarRepository repository, IBillRullService billRullService, - WmsSignForDeliveryService wmsSignForDeliveryService, + // WmsSignForDeliveryService wmsSignForDeliveryService, IUserManager userManager ) { _repository = repository; _userManager = userManager; - _wmsSignForDeliveryService = _wmsSignForDeliveryService; + // _wmsSignForDeliveryService = _wmsSignForDeliveryService; _billRullService = billRullService; } @@ -143,12 +147,12 @@ namespace Tnb.ProductionMgr if (result.IsSuccess) { //签收后调用载具签收接口 - await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() - { - org_id = _userManager.GetUserInfo().Result.organizeId, - create_id = _userManager.UserId, - carry_code = input.carry_code ?? "", - }); + // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // { + // org_id = _userManager.GetUserInfo().Result.organizeId, + // create_id = _userManager.UserId, + // carry_code = input.carry_code ?? "", + // }); } if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); @@ -257,12 +261,26 @@ namespace Tnb.ProductionMgr if (result.IsSuccess) { //签收后调用载具签收接口 - await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + // { + // org_id = _userManager.GetUserInfo().Result.organizeId, + // create_id = _userManager.UserId, + // carry_code = input.carry_code ?? "", + // }); + + var mesCarrySignInput = new MESCarrySignInput() { org_id = _userManager.GetUserInfo().Result.organizeId, create_id = _userManager.UserId, carry_code = input.carry_code ?? "", - }); + }; + + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header); } if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 5e8a2a63..4f2ededd 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -1,12 +1,24 @@ +using JNPF; using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Utils; +using JNPF.FriendlyException; +using JNPF.RemoteRequest; using JNPF.Systems.Interfaces.System; +using Mapster; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using SqlSugar; +using Tnb.BasicData.Entities; using Tnb.ProductionMgr.Entities; using Tnb.ProductionMgr.Entities.Dto; using Tnb.ProductionMgr.Interfaces; +using Tnb.WarehouseMgr; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; +using Tnb.BasicData; namespace Tnb.ProductionMgr { @@ -19,18 +31,112 @@ namespace Tnb.ProductionMgr { private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; - private readonly IBillRullService _billRullService; public PrdInstockService( ISqlSugarRepository repository, - IBillRullService billRullService, IUserManager userManager ) { _repository = repository; _userManager = userManager; - _billRullService = billRullService; + } + + [HttpPost] + public async Task SaveData(PrdInstockInput input) + { + var db = _repository.AsSugarClient(); + var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code); + PrdInstockH prdInstockH = null; + DbResult result = await db.Ado.UseTranAsync(async () => + { + prdInstockH = new PrdInstockH() + { + bill_type = input.bill_type, + bill_date = DateTime.Now, + create_id = _userManager.UserId, + location_code = input.location_code, + carry_code = input.carry_code, + is_check = input.is_check, + org_id = _userManager.GetUserInfo().Result.organizeId, + warehouse_id = location?.wh_id, + status = 0, + }; + + List prdInstockDs = new List() { }; + foreach (var item in input.details) + { + prdInstockDs.Add(new PrdInstockD() + { + instock_id = prdInstockH.id, + report_id = item.ContainsKey("report_id") ? item["report_id"] : "", + material_id = item.ContainsKey("material_id") ? item["material_id"] : "", + material_code = item.ContainsKey("material_code") ? item["material_code"] : "", + unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "", + code_batch = item.ContainsKey("batch") ? item["batch"] : "", + barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "", + quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), + }); + } + + await _repository.InsertAsync(prdInstockH); + + if (prdInstockDs.Count > 0) + { + await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + } + + }); + + if (result.IsSuccess) + { + MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput(); + mesCreateInstockInput.instock = new MESWmsInstockHInput() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + bill_date = DateTime.Now, + bill_type = input.bill_type, + warehouse_id = location?.wh_id, + source_id = prdInstockH.id, + create_id = _userManager.UserId, + carry_code = input.carry_code, + location_code = input.location_code, + is_check = input.is_check, + }; + mesCreateInstockInput.instockds = new List(); + mesCreateInstockInput.instockcodes = new List(); + foreach (var item in input.details) + { + mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput() + { + material_id = item.ContainsKey("material_id") ? item["material_id"] : "", + material_code = item.ContainsKey("material_code") ? item["material_code"] : "", + unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "", + code_batch = item.ContainsKey("batch") ? item["batch"] : "", + pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), + }); + + mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput() + { + material_id = item.ContainsKey("material_id") ? item["material_id"] : "", + material_code = item.ContainsKey("material_code") ? item["material_code"] : "", + unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "", + code_batch = item.ContainsKey("batch") ? item["batch"] : "", + barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "", + codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"), + }); + } + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); + Console.WriteLine(sendResult); + } + + if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + return result.IsSuccess ? "保存成功" : result.ErrorMessage; } /// diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index 832c4f03..6316cd83 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -15,7 +15,6 @@ - From b869fec28355adf87a8a37f8ed0d944dbbc4d69d Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 17 Jul 2023 11:32:19 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E9=BD=90=E5=A5=97=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8CPDA=E5=87=BA=E5=BA=93=E7=AD=BE?= =?UTF-8?q?=E6=94=B6=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsFeedingService.cs | 49 ++++++++++++++----- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 22 +++++++-- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs index bc4576b2..3c20c3d1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs @@ -5,10 +5,12 @@ 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 +40,41 @@ 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()! : "") - .ToListAsync(); + var carry = await _db.Queryable().SingleAsync(it=>it.id == carryId); + List items = new(); + if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) + { + var carryDs = await _db.Queryable().Where(it=>it.carry_id == carryId).ToListAsync(); + var carryMIds = carryDs.Select(x=>x.membercarry_id).ToList(); + items = await _db.Queryable().Where(a => carryMIds.Contains(a.carry_id)) + .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()! : "") + .ToListAsync(); + } + else + { + 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()! : "") + .ToListAsync(); + } + return items ?? Enumerable.Empty(); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 38aefcb1..5c16bc73 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) @@ -164,7 +172,7 @@ namespace Tnb.WarehouseMgr { var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - + WmsPretaskH preTask = new(); preTask.org_id = _userManager.User.OrganizeId; preTask.startlocation_id = sPoint?.location_id!; @@ -176,7 +184,7 @@ namespace Tnb.WarehouseMgr 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.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; preTask.carry_id = ko!.carry_id!; preTask.carry_code = ko!.carry_code!; preTask.area_id = sPoint?.area_id!; @@ -187,12 +195,16 @@ namespace Tnb.WarehouseMgr 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(); } } } From 37341183e1313e42297d5498826fb2349a37339b Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 11:34:18 +0800 Subject: [PATCH 05/13] 1 --- WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs | 4 ++++ WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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; } From f1c8ad986ea4fb715f4759654317fdcb934da548 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 11:43:45 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=BC=98=E5=8C=96WmsFeedingService=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsFeedingService.cs | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs index 3c20c3d1..021c620c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.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 JNPF.DependencyInjection; @@ -40,41 +41,29 @@ namespace Tnb.WarehouseMgr { dicMaterial = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.name); } - var carry = await _db.Queryable().SingleAsync(it=>it.id == carryId); + 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(); - var carryMIds = carryDs.Select(x=>x.membercarry_id).ToList(); - items = await _db.Queryable().Where(a => carryMIds.Contains(a.carry_id)) - .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()! : "") - .ToListAsync(); + var carryDs = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); + carryMIds = carryDs.Select(x => x.membercarry_id).ToList(); } - else - { - 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()! : "") - .ToListAsync(); - } - + Expression> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId; + items = await _db.Queryable().Where(whereExp) + .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 = (it.material_id != null && dicMaterial.ContainsKey(it.material_id)) ? dicMaterial[it.material_id].ToString() : "") + .ToListAsync(); + + return items ?? Enumerable.Empty(); } } From f2a3da36341fc789cc36f1f008f0e7073f63c3d1 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 11:46:56 +0800 Subject: [PATCH 07/13] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs index 021c620c..8035deb5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs @@ -51,15 +51,7 @@ namespace Tnb.WarehouseMgr } Expression> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId; items = await _db.Queryable().Where(whereExp) - .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, - }) + .Select() .Mapper(it => it.material_name = (it.material_id != null && dicMaterial.ContainsKey(it.material_id)) ? dicMaterial[it.material_id].ToString() : "") .ToListAsync(); From 1006f54afbe67a81b9c6822db5e535590050ceea Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Mon, 17 Jul 2023 11:57:47 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E6=B6=88=E9=99=A4warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EquipMgr/Tnb.EquipMgr/EqpDaqService.cs | 8 ++++---- EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs | 2 +- .../Tnb.EquipMgr/EqpEquipSparePartsService.cs | 6 +++--- EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs | 4 ++-- .../EqpTechnologyParameterService.cs | 4 ++-- .../EqpWorkshopChangeLogService.cs | 2 +- .../Tnb.EquipMgr/ToolMoldRequisitionService.cs | 8 ++++---- EquipMgr/Tnb.EquipMgr/ToolMoldReturnService.cs | 15 ++++++++++----- .../Dto/PrdManage/PrdMoListTreeOutput.cs | 18 +++++++++--------- .../Dto/PrdManage/PrdTaskManageListOutput.cs | 6 +++--- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 4 ++-- 11 files changed, 41 insertions(+), 36 deletions(-) diff --git a/EquipMgr/Tnb.EquipMgr/EqpDaqService.cs b/EquipMgr/Tnb.EquipMgr/EqpDaqService.cs index 0218b0e5..6c233f6d 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpDaqService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpDaqService.cs @@ -39,10 +39,10 @@ namespace Tnb.EquipMgr } var result = await db.Queryable() .LeftJoin((a,b)=>a.create_id==b.Id) - .WhereIF(input!=null,a=>a.equip_id==input.equip_id) - .WhereIF(queryJson!=null && queryJson.ContainsKey("data_source"),a=>a.data_source==queryJson["data_source"]) - .WhereIF(queryJson!=null && queryJson.ContainsKey("label_name"),a=>a.label_name.Contains(queryJson["label_name"])) - .WhereIF(queryJson!=null && queryJson.ContainsKey("label_point"),a=>a.label_point.Contains(queryJson["label_point"])) + .WhereIF(input!=null,a=>a.equip_id==input!.equip_id) + .WhereIF(queryJson!=null && queryJson.ContainsKey("data_source"),a=>a.data_source==queryJson!["data_source"]) + .WhereIF(queryJson!=null && queryJson.ContainsKey("label_name"),a=>a.label_name.Contains(queryJson!["label_name"])) + .WhereIF(queryJson!=null && queryJson.ContainsKey("label_point"),a=>a.label_point.Contains(queryJson!["label_point"])) .Select((a,b) => new EquipDaqQueryOutput { id = a.id, diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs index 6a61b196..97f48c1a 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs @@ -89,7 +89,7 @@ namespace Tnb.EquipMgr .LeftJoin((a, b,c) => a.modify_id == c.Id) .LeftJoin((a, b,c,d) => a.equip_id == d.id) .Where((a,b,c,d)=>a.equip_id==input.equip_id) - .WhereIF(queryJson!=null && queryJson.ContainsKey("file_name"),(a,b,c,d)=>a.file_name.Contains(queryJson["file_name"])) + .WhereIF(queryJson!=null && queryJson.ContainsKey("file_name"),(a,b,c,d)=>a.file_name.Contains(queryJson!["file_name"])) .Select((a, b, c,d) => new EquipFileQueryOutput { id = a.id, diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs index 83d1341c..351b7f60 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpEquipSparePartsService.cs @@ -47,7 +47,7 @@ namespace Tnb.EquipMgr id = SnowflakeIdHelper.NextId(), equip_id = input.equip_id, spare_parts_id = spare_parts_id, - create_id = _userManager.UserId, + create_id = _userManager?.UserId ?? "", create_time = DateTime.Now, org_id = orgId, }); @@ -71,8 +71,8 @@ namespace Tnb.EquipMgr .LeftJoin((a, b, c) => c.EnCode == Tnb.BasicData.DictConst.SparePartsType && c.DeleteMark == null) .LeftJoin((a, b,c,d) => d.DictionaryTypeId == c.Id && b.type_id == d.EnCode) .Where((a,b,c,d)=>a.equip_id==input.equip_id) - .WhereIF(queryJson!=null && queryJson.ContainsKey("code"),(a,b,c,d)=>b.code.Contains(queryJson["code"])) - .WhereIF(queryJson!=null && queryJson.ContainsKey("name"),(a,b,c,d)=>b.name.Contains(queryJson["name"])) + .WhereIF(queryJson!=null && queryJson.ContainsKey("code"),(a,b,c,d)=>b.code.Contains(queryJson!["code"])) + .WhereIF(queryJson!=null && queryJson.ContainsKey("name"),(a,b,c,d)=>b.name.Contains(queryJson!["name"])) .Select((a, b, c,d) => new EquipSparePartsQueryOutput { id = a.id, diff --git a/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs b/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs index 95e2b2c9..276ab5a1 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpSubEquipService.cs @@ -43,8 +43,8 @@ namespace Tnb.EquipMgr .LeftJoin((a, b,c) => a.modify_id == c.Id) .LeftJoin((a, b,c,d) => a.equip_id == d.id) .Where((a,b,c,d)=>a.equip_id==input.equip_id) - .WhereIF(queryJson!=null && queryJson.ContainsKey("code"),(a,b,c,d)=>a.code.Contains(queryJson["code"])) - .WhereIF(queryJson!=null && queryJson.ContainsKey("name"),(a,b,c,d)=>a.name.Contains(queryJson["name"])) + .WhereIF(queryJson!=null && queryJson.ContainsKey("code"),(a,b,c,d)=>a.code.Contains(queryJson!["code"])) + .WhereIF(queryJson!=null && queryJson.ContainsKey("name"),(a,b,c,d)=>a.name.Contains(queryJson!["name"])) .Select((a, b, c,d) => new SubEquipQueryOutput { id = a.id, diff --git a/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs b/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs index 4ec042e2..22035383 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpTechnologyParameterService.cs @@ -37,8 +37,8 @@ namespace Tnb.EquipMgr queryJson = JsonConvert.DeserializeObject>(input?.queryJson ?? ""); } var result = await db.Queryable() - .WhereIF(input!=null,a=>a.equip_id==input.equip_id) - .WhereIF(queryJson!=null && queryJson.ContainsKey("name"),a=>a.name.Contains(queryJson["name"])) + .WhereIF(input!=null,a=>a.equip_id==input!.equip_id) + .WhereIF(queryJson!=null && queryJson.ContainsKey("name"),a=>a.name.Contains(queryJson!["name"])) .Select(a => new EquipTechnologyParameterQueryOutput { id = a.id, diff --git a/EquipMgr/Tnb.EquipMgr/EqpWorkshopChangeLogService.cs b/EquipMgr/Tnb.EquipMgr/EqpWorkshopChangeLogService.cs index 94074c06..75ac0af0 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpWorkshopChangeLogService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpWorkshopChangeLogService.cs @@ -42,7 +42,7 @@ namespace Tnb.EquipMgr var result = await db.Queryable() .LeftJoin((a,b)=>a.old_workshop_id==b.Id) .LeftJoin((a,b,c)=>a.new_workshop_id==c.Id) - .WhereIF(input!=null,a=>a.equip_id==input.equip_id) + .WhereIF(input!=null,a=>a.equip_id==input!.equip_id) //.WhereIF(queryJson!=null && queryJson.ContainsKey("name"),a=>a.name.Contains(queryJson["name"])) .Select((a,b,c) => new EquipWorkshopChangeQueryOutput { diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs index 6b8b554e..7f4aa7e7 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldRequisitionService.cs @@ -52,7 +52,7 @@ namespace Tnb.EquipMgr private async Task GetList(VisualDevModelListQueryInput input) { Dictionary? queryJson = new Dictionary(); - string requisitionCode = ""; + string? requisitionCode = ""; DateTime[] requisitionTimeArr = null; DateTime[] estimatedReturnArr = null; if (input!=null && !string.IsNullOrEmpty(input.queryJson)) @@ -60,15 +60,15 @@ namespace Tnb.EquipMgr queryJson = JsonConvert.DeserializeObject>(input?.queryJson ?? ""); } - if (queryJson.TryGetValue("requisition_code", out var value)) + if (queryJson!.TryGetValue("requisition_code", out var value)) { requisitionCode = value.ToString(); } - if (queryJson.TryGetValue("requisition_time", out var value1)) + if (queryJson!.TryGetValue("requisition_time", out var value1)) { requisitionTimeArr = value1.ToObject().Select(x=>DateTimeOffset.FromUnixTimeSeconds(x/1000).ToLocalTime().DateTime).ToArray(); } - if (queryJson.TryGetValue("estimated_return_time", out var value2)) + if (queryJson!.TryGetValue("estimated_return_time", out var value2)) { estimatedReturnArr = value2.ToObject().Select(x=>DateTimeOffset.FromUnixTimeSeconds(x/1000).ToLocalTime().DateTime).ToArray(); } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldReturnService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldReturnService.cs index 9f64db8e..79e9a012 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldReturnService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldReturnService.cs @@ -49,15 +49,20 @@ namespace Tnb.EquipMgr await _runService.Create(templateEntity, input); - string locationId = ""; + string? locationId = ""; if (input.data.TryGetValue("location_id", out var value)) { locationId = value.ToString(); } - await _db.Updateable() - .SetColumns(x => x.mold_status == Tnb.BasicData.DictConst.ZKTypeId) - .SetColumnsIF(!string.IsNullOrEmpty(locationId),x=>x.location_id==locationId) - .Where(X => X.id == input.data["mold_id"]).ExecuteCommandAsync(); + + string moldId = input.data.ContainsKey("mold_id") ? input.data["mold_id"].ToString() : ""; + if (!string.IsNullOrEmpty(moldId)) + { + await _db.Updateable() + .SetColumns(x => x.mold_status == Tnb.BasicData.DictConst.ZKTypeId) + .SetColumnsIF(!string.IsNullOrEmpty(locationId),x=>x.location_id==locationId) + .Where(X => X.id == moldId).ExecuteCommandAsync(); + } }); if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs index 7636d120..bb1c96ca 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs @@ -36,7 +36,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// /// 物料规格型号 /// - public string material_standard { get; set; } = string.Empty; + public string? material_standard { get; set; } = string.Empty; /// /// 工单类型:1-正常工单、2-返工工单、3-试制工单 @@ -51,32 +51,32 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// /// 计划生产数量 /// - public string plan_qty { get; set; } = string.Empty; + public string? plan_qty { get; set; } = string.Empty; /// /// 已投入数量 /// - public string input_qty { get; set; } = string.Empty; + public string? input_qty { get; set; } = string.Empty; /// /// 已完工数量 /// - public string complete_qty { get; set; } = string.Empty; + public string? complete_qty { get; set; } = string.Empty; /// /// 报废数量 /// - public string scrap_qty { get; set; } = string.Empty; + public string? scrap_qty { get; set; } = string.Empty; /// /// 计划开始时间 /// - public string plan_start_date { get; set; } = string.Empty; + public string? plan_start_date { get; set; } = string.Empty; /// /// 计划结束时间 /// - public string plan_end_date { get; set; } = string.Empty; + public string? plan_end_date { get; set; } = string.Empty; /// /// 是否生派工单 @@ -112,7 +112,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// /// 创建时间 /// - public string create_time { get; set; } = string.Empty; + public string? create_time { get; set; } = string.Empty; /// /// 修改用户 @@ -131,7 +131,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// /// 已排产数量 /// - public string scheduled_qty { get; set; } = string.Empty; + public string? scheduled_qty { get; set; } = string.Empty; /// /// 父工单id /// diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs index 42f333f4..eb79327c 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskManageListOutput.cs @@ -3,7 +3,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public class PrdTaskManageListOutput { public string id { get; set; } = string.Empty; - public string mo_task_code { get; set; } = string.Empty; + public string? mo_task_code { get; set; } = string.Empty; public string material_id { get; set; } = string.Empty; public string mold_id { get; set; } = string.Empty; public string eqp_id { get; set; } = string.Empty; @@ -11,7 +11,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string plan_end_date { get; set; } = string.Empty; public int? plan_qty { get; set; } public int? complete_qty { get; set; } - public string mo_task_status { get; set; } = string.Empty; - public string schedule_type { get; set; } = string.Empty; + public string? mo_task_status { get; set; } = string.Empty; + public string? schedule_type { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index 9d5d4331..ff33e912 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -144,8 +144,8 @@ namespace Tnb.ProductionMgr material_id = c.code+"/"+c.name, mold_id = d.mold_code+"/"+d.mold_name, eqp_id = b.code+"/"+b.name, - plan_start_date = a.estimated_start_date.Value.ToString("yyyy-MM-dd"), - plan_end_date = a.estimated_end_date.Value.ToString("yyyy-MM-dd"), + plan_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"), + plan_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"), plan_qty = a.scheduled_qty, complete_qty = a.reported_work_qty, mo_task_status = a.mo_task_status, From b8b040981b72e31e60ae2f9aa96ef42a38811efd Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 13:36:20 +0800 Subject: [PATCH 09/13] 1 --- WarehouseMgr/Tnb.WarehouseMgr/Dp.cs | 3 --- WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs | 10 ++++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/Dp.cs b/WarehouseMgr/Tnb.WarehouseMgr/Dp.cs index 4ba914fc..50e838b1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/Dp.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/Dp.cs @@ -18,9 +18,6 @@ namespace Tnb.WarehouseMgr public class Dp { private HashSet set = new HashSet(); - private const int Max = int.MaxValue; - private int Min = int.MaxValue; - private int Deep = 0; /// /// 动态规划函数 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs index 8035deb5..abbcdc7c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs @@ -42,7 +42,6 @@ namespace Tnb.WarehouseMgr dicMaterial = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.name); } var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); - List items = new(); List carryMIds = new(); if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) { @@ -50,11 +49,10 @@ namespace Tnb.WarehouseMgr 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(); - + var 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(); } From 1408bf0f97a03274f04e42fd3385f5c5e6729c80 Mon Sep 17 00:00:00 2001 From: taomin0419 <865692298@qq.com> Date: Mon, 17 Jul 2023 13:53:53 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E9=BD=90=E5=A5=97=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=BD=E5=85=B7=E4=B8=BA=E6=96=99=E6=9E=B6?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8F=96=E6=96=99=E7=AE=B1=E6=9D=A1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index a6d55e85..5fc48137 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using Aop.Api.Domain; @@ -238,7 +239,15 @@ namespace Tnb.WarehouseMgr var kods = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); //当前载具对应的所有条码插入 - var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); + 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; + + var carryCodes = await _db.Queryable().Where(whereExp).ToListAsync(); var kittingoutCodes = carryCodes.Adapt>(); kittingoutCodes.ForEach(x => { From 92a8389efa8ea8b590e662f164294b3cc698c09b Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 17 Jul 2023 14:28:46 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 5fc48137..5cb310ed 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -236,15 +236,16 @@ namespace Tnb.WarehouseMgr var carryId = input.carryIds[^input.carryIds.Count]; var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); - var kods = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); - //当前载具对应的所有条码插入 + + //载具为料架时,取所有料箱的条码 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; var carryCodes = await _db.Queryable().Where(whereExp).ToListAsync(); @@ -292,9 +293,7 @@ namespace Tnb.WarehouseMgr //判断当前载具是否为料架,如果是料架 清空所有料架/料箱数据, if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) { - var carryds = await _db.Queryable().Where(it => it.id == carryId).ToListAsync(); - var mids = carryds.Select(x => x.membercarry_id).ToList(); - var carrys = await _db.Queryable().Where(it => mids.Contains(it.id)).ToListAsync(); + var carrys = await _db.Queryable().Where(it => carryMIds.Contains(it.id)).ToListAsync(); carrys.Add(carry); if (carrys?.Count > 0) { From e2a03ded93ea978e465a2e523805189464376416 Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 17 Jul 2023 14:29:00 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 5cb310ed..79fff1cd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -75,9 +75,9 @@ namespace Tnb.WarehouseMgr foreach (var ko in kittingOuts) { var carrys = await _db.Queryable() - .InnerJoin((a,b) => a.collocation_scheme_id == b.id) + .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) + .OrderBy((a, b) => b.seq) .ToListAsync(); if (carrys?.Count > 0) { @@ -158,7 +158,7 @@ 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) @@ -237,7 +237,6 @@ namespace Tnb.WarehouseMgr var carryId = input.carryIds[^input.carryIds.Count]; var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); var kods = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); - //载具为料架时,取所有料箱的条码 List carryMIds = new(); if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) @@ -293,7 +292,7 @@ namespace Tnb.WarehouseMgr //判断当前载具是否为料架,如果是料架 清空所有料架/料箱数据, if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) { - var carrys = await _db.Queryable().Where(it => carryMIds.Contains(it.id)).ToListAsync(); + var carrys = await _db.Queryable().Where(it => carryMIds.Contains(it.id)).ToListAsync(); carrys.Add(carry); if (carrys?.Count > 0) { @@ -329,7 +328,7 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException("input"); try { - + await _db.Ado.BeginTranAsync(); List kittingOutDs = new(); var kittingOuts = input.Adapt>(); From 5bb09d4952c072fd81f0d1c47c72d3e24c3b906c Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 14:40:06 +0800 Subject: [PATCH 13/13] 1 --- .../Tnb.WarehouseMgr/BaseWareHouseService.cs | 4 +- .../Tnb.WarehouseMgr/WareHouseService.cs | 48 +++++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index 7a451c34..bb3d2c6f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -12,6 +12,7 @@ using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using Microsoft.AspNetCore.Mvc; using SqlSugar; @@ -46,7 +47,8 @@ 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 4c1460cf..0af932f0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -92,7 +92,7 @@ namespace Tnb.WarehouseMgr warehouse_name = c.whname, }) .ToListAsync(); - return items; + return items ?? Enumerable.Empty(); } /// /// 库房业务,入库、出库申请新增修改功能 @@ -139,27 +139,10 @@ namespace Tnb.WarehouseMgr [HttpGet] public async Task GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input) { - async Task _fetchInOutStockCodesById(string billDId) - where TStockD : BaseEntity, new() - where TOutput : IInOutStockDetail, new() - where TStockCode : BaseEntity, IInOutStockCode, new() - { - var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID); - var data = await _db.Queryable() - .Where(a => a.id == billDId) - .Select(a => new TOutput - { - CodeDetails = SqlFunc.Subqueryable().Where(it => it.bill_d_id == a.id).ToList(), - }, true) - .Mapper(it => it.line_status = it.line_status != null && dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "") - .ToListAsync(); - return data; - } - dynamic? result = input.inoutStockType switch { - EnumInOutStockType.In => await _fetchInOutStockCodesById(input.bill_d_id), - EnumInOutStockType.Out => await _fetchInOutStockCodesById(input.bill_d_id), + EnumInOutStockType.In => await FetchInOutStockCodesById(input.bill_d_id), + EnumInOutStockType.Out => await FetchInOutStockCodesById(input.bill_d_id), _ => throw new ArgumentOutOfRangeException(nameof(input.inoutStockType), $"Not expected EnumInOutStockType value: {input.inoutStockType}"), }; return result ?? Enumerable.Empty(); @@ -737,7 +720,30 @@ namespace Tnb.WarehouseMgr return isOk; } - + /// + /// 根据明细Id获取出入库明细信息 + /// + /// 出入库明细 + /// 明细输出类 + /// 出入库条码 + /// 明细Id + /// + private async Task FetchInOutStockCodesById(string billDId) + where TStockD : BaseEntity, new() + where TOutput : IInOutStockDetail, new() + where TStockCode : BaseEntity, IInOutStockCode, new() + { + var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID); + var data = await _db.Queryable() + .Where(a => a.id == billDId) + .Select(a => new TOutput + { + CodeDetails = SqlFunc.Subqueryable().Where(it => it.bill_d_id == a.id).ToList(), + }, true) + .Mapper(it => it.line_status = it.line_status != null && dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "") + .ToListAsync(); + return data; + } #endregion } }