From efb68b9ad7eda1e91d77e5366a6838faf6db8e30 Mon Sep 17 00:00:00 2001 From: FanLian Date: Wed, 21 Jun 2023 09:41:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9loc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs index 60b37ded..258b9c6a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs @@ -37,7 +37,7 @@ public partial class WmsCarryD : BaseEntity, IWmsCarryEntity /// /// 位置 /// - public string loc { get; set; } = string.Empty; + public int loc { get; set; } /// /// 创建用户 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 599aadc0..b7c5abc4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -74,7 +74,7 @@ namespace Tnb.WarehouseMgr org_id = carry?.org_id!, membercarry_id = subCarry.id, membercarry_code = subCarry.carry_code, - loc = input.data[nameof(WmsCarrybindH.loc)]?.ToString()!, + loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1), create_id = _userManager.UserId, create_time = DateTime.Now }; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs index e05ffdda..eab997a0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs @@ -74,7 +74,7 @@ namespace Tnb.WarehouseMgr org_id = carry?.org_id!, membercarry_id = subCarry.id, membercarry_code = subCarry.carry_code, - loc = input.data[nameof(WmsCarrybindH.loc)]?.ToString()!, + loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1), create_id = _userManager.UserId, create_time = DateTime.Now }; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs index 3e2728c6..8541d41e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs @@ -49,7 +49,6 @@ namespace Tnb.WarehouseMgr var isOk = false; try { - var isOk = false; await _db.Ado.BeginTranAsync(); var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; var feedBoxCode = input.data.ContainsKey("feedbox_code") ? input.data["feedbox_code"]?.ToString() : ""; From 798abfe5b013073a78dee3286cde0556b4bcc57b Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 21 Jun 2023 10:21:15 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=94=9F=E6=88=90=E9=A2=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=B6=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/WmsPretaskH.cs | 4 ++ .../Tnb.WarehouseMgr/WareHouseService.cs | 42 ++++++++++--------- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 12 +++--- .../Tnb.WarehouseMgr/WmsPDAFeedingService.cs | 1 - 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.cs index 87c8ae05..cd3050ee 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.cs @@ -161,5 +161,9 @@ public partial class WmsPretaskH : BaseEntity /// 优先级 /// public int is_sign { get; set; } = 1; + /// + /// 任务属性 + /// + public string chain_type { get; set; } = "3"; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 18a994cf..b20cea3f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -240,19 +240,18 @@ namespace Tnb.WarehouseMgr { x.is_chain = 0; - x.chain_type = "0"; }); } else if ((moveNum > areaPreTasks.Count && areaPreTasks.Count > 1) || moveNum < areaPreTasks.Count) { items.ForEach(x => x.is_chain = 1); - items[0].chain_type = "1"; - for (int i = 0; i < items.Count; i++) - { - if (i == 0 || i == items.Count - 1) continue; - items[i].chain_type = "2"; - } - items[^1].chain_type = "3"; + //items[0].chain_type = "1"; + //for (int i = 0; i < items.Count; i++) + //{ + // if (i == 0 || i == items.Count - 1) continue; + // items[i].chain_type = "2"; + //} + //items[^1].chain_type = "3"; } }); @@ -288,7 +287,7 @@ namespace Tnb.WarehouseMgr items.ForEach(x => { x.is_chain = 0; - x.chain_type = "0"; + x.chain_type = "3"; }); } else if (moveNum > 1) @@ -461,18 +460,10 @@ namespace Tnb.WarehouseMgr var disTaskCodes = await _db.Queryable().Where(it => it.bill_id == dt.id).ToListAsync(); var upInput = new WareHouseUpInput { bizTypeId = dt.biz_type, requireId = dt.require_id, distaskCodes = disTaskCodes, carryIds = disTasks.Select(x => x.carry_id).ToList() }; upInput.loginType = !_userManager.LoginType.IsNullOrEmpty() ? "app" : "web"; - if (dt.is_sign == 1) //区分出入库操作 + if (dt.is_sign == 1 && dt.chain_type == "3") { - if (dt.is_chain == 0) - { - await DoUpdate(upInput); - } - else if (dt.is_chain == 1 && dt.chain_type == "3") - { - await DoUpdate(upInput); - } + await DoUpdate(upInput); } - } } @@ -495,6 +486,19 @@ namespace Tnb.WarehouseMgr /// public async Task GenPreTask(List preTasks, List preTaskCodes) { + var grpList = preTasks.OrderBy(o => o.bill_code).GroupBy(g => g.carry_id).ToList(); + if (grpList?.Count > 0) + { + foreach (var grp in grpList) + { + var arr = grp.ToArray(); + if (arr.Length > 1) + { + var subArr = arr[..^1]; + Array.ForEach(subArr, a => a.chain_type = "1"); + } + } + } var row = await _db.Insertable(preTasks).ExecuteCommandAsync(); if (preTaskCodes?.Count > 0) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 432a46f6..2bb1f90e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -143,8 +143,8 @@ namespace Tnb.WarehouseMgr List locIds = new(); foreach (var carry in carrys) { - WmsPointH sPoint = null; - WmsPointH ePoint = null; + WmsPointH sPoint = null!; + WmsPointH ePoint = null!; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); @@ -168,10 +168,10 @@ namespace Tnb.WarehouseMgr 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.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(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs index 3e2728c6..8541d41e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs @@ -49,7 +49,6 @@ namespace Tnb.WarehouseMgr var isOk = false; try { - var isOk = false; await _db.Ado.BeginTranAsync(); var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; var feedBoxCode = input.data.ContainsKey("feedbox_code") ? input.data["feedbox_code"]?.ToString() : ""; From 785102ddab16c6443fbbf083a6e44df334a3e872 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 21 Jun 2023 10:21:17 +0800 Subject: [PATCH 3/4] bug --- .../Dto/PrdManage/PrdMoListTreeOutput.cs | 173 ++++++++++++++++++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 48 ++++- 2 files changed, 216 insertions(+), 5 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs new file mode 100644 index 00000000..13b260bd --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListTreeOutput.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Security; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + public class PrdMoListTreeOutput + { + + //public Dictionary row { get; set; } + + #region 注释代码 + public string? org_id { get; set; } + /// + /// 工单id + /// + + public string mo_id { get; set; } + + /// + /// 工单代码 + /// + public string mo_code { get; set; } = string.Empty; + + /// + /// 物料编号 + /// + public string? material_code { get; set; } + /// + /// 物料名称 + /// + public string material_name { get; set; } + /// + /// 物料规格型号 + /// + public string material_standard { get; set; } + + /// + /// 工单类型:1-正常工单、2-返工工单、3-试制工单 + /// + public string? mo_type { get; set; } + + /// + /// 生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停 + /// + public string? mo_status { get; set; } + + /// + /// 计划生产数量 + /// + public string plan_qty { get; set; } + + /// + /// 已投入数量 + /// + public string input_qty { get; set; } + + /// + /// 已完工数量 + /// + public string complete_qty { get; set; } + + /// + /// 报废数量 + /// + public string scrap_qty { get; set; } + + /// + /// 计划开始时间 + /// + public string plan_start_date { get; set; } + + /// + /// 计划结束时间 + /// + public string plan_end_date { get; set; } + + /// + /// 是否生派工单 + /// + public string is_create_dispatch { get; set; } + + + /// + /// 产线代码 + /// + public string? production_linecode { get; set; } + + /// + /// 是否合并 + /// + public string is_merge { get; set; } + + /// + /// 组合工单 + /// + public string? combine_mo_code { get; set; } + + /// + /// 时间戳 + /// + public string? time_stamp { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public string create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public string modify_time { get; set; } + /// + /// 物料ID + /// + public string? material_id { get; set; } + public string? material_id_id { get; set; } + /// + /// 已排产数量 + /// + public string scheduled_qty { get; set; } + /// + /// 父工单id + /// + public string parent_id { get; set; } + + /// + /// 获取节点id. + /// + /// + public string id { get; set; } + + /// + /// 获取节点父id. + /// + /// + public string parentId { get; set; } + + /// + /// 是否有子级. + /// + public bool hasChildren { get; set; } + + /// + /// 设置Children. + /// + public List? children { get; set; } = new List(); + + /// + /// 子节点数量. + /// + public int num { get; set; } + + /// + /// 是否为子节点. + /// + public bool isLeaf { get; set; } = false; + #endregion + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 503dbbfd..8060e370 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -426,6 +426,7 @@ namespace Tnb.ProductionMgr // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(MoModuleId, true); // var data = await _runService.GetListResult(templateEntity, input); // + // // if (data?.list?.Count > 0) // { // var parentIdField = nameof(PrdMo.parent_id); @@ -529,7 +530,7 @@ namespace Tnb.ProductionMgr .WhereIF(!string.IsNullOrEmpty(moCode),(a,b,c,d,e)=>a.mo_code.Contains(moCode)) .WhereIF(!string.IsNullOrEmpty(combineMoCode),(a,b,c,d,e)=>a.combine_mo_code.Contains(combineMoCode)) .OrderByDescending((a,b,c,d,e)=>a.create_time) - .Select((a, b, c, d, e) => new PrdMoTreeOutput + .Select((a, b, c, d, e) => new PrdMoListTreeOutput { org_id = a.org_id, mo_id = a.id, @@ -557,13 +558,50 @@ namespace Tnb.ProductionMgr scheduled_qty = a.scheduled_qty.Value.ToString(), parent_id = "0", id = a.id, - hasChildren = false, - num = 0, - isLeaf = true, + hasChildren = SqlFunc.Subqueryable().Where(x=>x.parent_id==a.id).Any(), + num = SqlFunc.Subqueryable().Where(x=>x.parent_id==a.id).Count(), + isLeaf = SqlFunc.Subqueryable().Where(x=>x.parent_id==a.id).Any(), + children = SqlFunc.Subqueryable() + .LeftJoin((h,i) => h.material_id == i.id) + .LeftJoin((h,i,j) => h.mo_type == j.Id) + .LeftJoin((h,i,j,k) => h.mo_status == k.Id) + .LeftJoin((h,i,j,k,l) => h.create_id == l.Id) + .Where((h,i,j,k,l)=>a.id==h.parent_id).ToList((h,i,j,k,l)=>new PrdMoListTreeOutput() + { + org_id = h.org_id, + mo_id = h.id, + mo_code = h.mo_code, + material_code = i.code, + material_name = i.name, + material_standard = i.material_standard, + mo_type = j.FullName, + mo_status = k.FullName, + plan_qty = h.plan_qty.Value.ToString(), + input_qty = h.input_qty.Value.ToString(), + complete_qty = h.complete_qty.Value.ToString(), + scrap_qty = h.scrap_qty.Value.ToString(), + plan_start_date = h.plan_start_date.Value.ToString("yyyy-MM-dd"), + plan_end_date = h.plan_end_date.Value.ToString("yyyy-MM-dd"), + is_create_dispatch = h.is_create_dispatch==0 ? "否" : "是", + production_linecode = h.production_linecode, + is_merge = h.is_merge==0 ? "否" : "是", + combine_mo_code = h.combine_mo_code, + time_stamp = h.time_stamp, + create_id = l.RealName, + create_time = h.create_time.Value.ToString("yyyy-MM-dd : HH:mm:ss"), + material_id = i.code, + material_id_id = h.material_id, + scheduled_qty = h.scheduled_qty.Value.ToString(), + parent_id = a.id, + id = h.id, + hasChildren = false, + num = 0, + isLeaf = true, + }) }).ToPagedListAsync(input.currentPage, input.pageSize); - return PageResult.SqlSugarPageResult(result); + return PageResult.SqlSugarPageResult(result); } #endregion From 1e555f372f7e3bca63da0546826946dd547d65fc Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 21 Jun 2023 11:17:32 +0800 Subject: [PATCH 4/4] bug --- .../Dto/BasEbom/EbomListOutput.cs | 4 ++ .../Dto/BasEbom/EbomTreeOutput.cs | 9 ++- .../Tnb.BasicData.Entities/Entity/BasEbomD.cs | 2 +- .../Tnb.BasicData.Entities/Entity/BasEbomH.cs | 2 +- BasicData/Tnb.BasicData/BasEbomService.cs | 1 + .../Tnb.ProductionMgr/PrdMoService.cs | 67 ++++++++++++++++--- 6 files changed, 70 insertions(+), 15 deletions(-) diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomListOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomListOutput.cs index 0a0c08a5..d87f9e8c 100644 --- a/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomListOutput.cs +++ b/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomListOutput.cs @@ -19,6 +19,10 @@ namespace Tnb.BasicData.Entities.Dto public string? unit_id { get; set; } public string? version { get; set; } /// + /// 数量 + /// + public int quantity { get; set; } + /// /// 工艺路线名称 /// public string? route_id { get; set; } diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs index 1c494894..bbd8639b 100644 --- a/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs +++ b/BasicData/Tnb.BasicData.Entities/Dto/BasEbom/EbomTreeOutput.cs @@ -45,12 +45,11 @@ namespace Tnb.BasicData.Entities.Dto /// public string? loss_rate {get;set;} - /// - /// Desc:数量 - /// Default:NULL::character varying - /// Nullable:True /// - public string? quantity {get;set;} + /// + /// 数量 + /// + public int quantity { get; set; } /// /// Desc:需要称量 diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs index eb68464a..8ab72cc4 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasEbomD.cs @@ -37,7 +37,7 @@ public partial class BasEbomD : BaseEntity /// /// 数量 /// - public string? quantity { get; set; } + public int quantity { get; set; } /// /// 损耗率 diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasEbomH.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasEbomH.cs index 75de569c..f480d120 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasEbomH.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasEbomH.cs @@ -32,7 +32,7 @@ public partial class BasEbomH : BaseEntity /// /// 数量 /// - public string? quantity { get; set; } + public int quantity { get; set; } /// /// 单位id diff --git a/BasicData/Tnb.BasicData/BasEbomService.cs b/BasicData/Tnb.BasicData/BasEbomService.cs index 363c5878..01679ee6 100644 --- a/BasicData/Tnb.BasicData/BasEbomService.cs +++ b/BasicData/Tnb.BasicData/BasEbomService.cs @@ -63,6 +63,7 @@ namespace Tnb.BasicData material_id_id = b.id, status = SqlFunc.IIF(a.status == "0", "禁用", "启用"), descrip = a.descrip, + quantity = a.quantity, version = a.version, route_id = c.name, route_id_id = c.id, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index e080b375..0c36460f 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -179,6 +179,56 @@ namespace Tnb.ProductionMgr .ExecuteCommandAsync(); return (row > 0); } + // /// + // /// 关联同组工单 + // /// + // /// 关联同组工单输入参数 + // /// + // [HttpPost] + // public async Task RelevancySameGroupMo(MoCrInput input) + // { + // (bool executeRes, string errMsg) multi = (true, ""); + // var list = await _repository.AsSugarClient().Queryable() + // .InnerJoin((a, b) => a.material_id == b.material_id) + // .Where((a, b) => input.WorkOrderIds.Contains(a.id)) + // .Select((a, b) => new + // { + // planDate = a.plan_start_date, + // mold_code = b.mold_code, + // }).ToListAsync(); + // var planDateAll = true; + // var moldIdAll = true; + // if (list?.Count > 0) + // { + // var planDate = list.FirstOrDefault()?.planDate; + // var moldCode = list.FirstOrDefault()?.mold_code; + // + // planDateAll = list.Skip(1).All(x => x.planDate == planDate); + // moldIdAll = list.Skip(1).All(x => x.mold_code == moldCode); + // if (planDateAll && moldIdAll) + // { + // var groupId = SnowflakeIdHelper.NextId(); + // multi.executeRes = await _repository.AsSugarClient().Updateable() + // .SetColumns(c => new PrdMo { combine_mo_code = groupId }) + // .Where(it => input.WorkOrderIds.Contains(it.id)) + // .ExecuteCommandHasChangeAsync(); + // } + // else + // { + // multi.executeRes = false; + // if (!planDateAll) + // { + // throw new AppFriendlyException("计划开始日期不一致", null); + // } + // if (!moldIdAll) + // { + // throw new AppFriendlyException("未关联到同一模具下", null); + // } + // } + // } + // return multi; + // } + /// /// 关联同组工单 /// @@ -189,12 +239,13 @@ namespace Tnb.ProductionMgr { (bool executeRes, string errMsg) multi = (true, ""); var list = await _repository.AsSugarClient().Queryable() - .InnerJoin((a, b) => a.material_id == b.material_id) - .Where((a, b) => input.WorkOrderIds.Contains(a.id)) - .Select((a, b) => new + .LeftJoin((a, b) => a.material_id == b.material_id) + .LeftJoin((a,b,c)=>b.mold_id==c.id) + .Where((a, b,c) => input.WorkOrderIds.Contains(a.id)) + .Select((a, b,c) => new { planDate = a.plan_start_date, - mold_code = b.mold_code, + mold_code = c.mold_code, }).ToListAsync(); var planDateAll = true; var moldIdAll = true; @@ -203,8 +254,8 @@ namespace Tnb.ProductionMgr var planDate = list.FirstOrDefault()?.planDate; var moldCode = list.FirstOrDefault()?.mold_code; - planDateAll = list.Skip(1).All(x => x.planDate == planDate); - moldIdAll = list.Skip(1).All(x => x.mold_code == moldCode); + planDateAll = list.All(x => x.planDate == planDate); + moldIdAll = moldCode != null && list.All(x => x.mold_code == moldCode); if (planDateAll && moldIdAll) { var groupId = SnowflakeIdHelper.NextId(); @@ -218,11 +269,11 @@ namespace Tnb.ProductionMgr multi.executeRes = false; if (!planDateAll) { - throw new AppFriendlyException("计划开始日期不一致", null); + throw Oops.Bah("计划开始日期不一致"); } if (!moldIdAll) { - throw new AppFriendlyException("未关联到同一模具下", null); + throw Oops.Bah("未关联到同一模具下"); } } }