From 29d2f240c2d070c84e2dd72edfbfb89c9e6d04ee Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 18 Jul 2023 17:14:49 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E5=92=8C=E6=B3=A8=E5=A1=91=E6=8C=A4=E5=87=BA=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/DictConst.cs | 12 ++++ .../Dto/WorklineAndEquipTreeOutput.cs | 42 ++++++++++++ .../IEquipmentService.cs | 6 ++ EquipMgr/Tnb.EquipMgr/EquipmentService.cs | 67 +++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index 8c6eede0..bfc6fcf5 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -12,6 +12,18 @@ public static class DictConst /// public const string RegionCategoryStationCode = "workstation"; /// + /// 区域类型-公司Code + /// + public const string RegionCategoryCompanyCode = "company"; + /// + /// 区域类型-车间Code + /// + public const string RegionCategoryWorkshopCode = "workshop"; + /// + /// 区域类型-产线Code + /// + public const string RegionCategoryWorklineCode = "workline"; + /// /// 备品备件类型 /// public const string SparePartsType = "SparePartsType"; diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs new file mode 100644 index 00000000..dcfee410 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs @@ -0,0 +1,42 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class WorklineAndEquipTreeOutput + { + /// + /// 获取节点id. + /// + /// + public string id { get; set; } + + /// + /// 标题 + /// + public string title { 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; + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs index a1255946..3473dbf8 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs @@ -17,5 +17,11 @@ namespace Tnb.EquipMgr.Interfaces /// /// public Task GetListByTypeId(Dictionary dic); + + /// + /// 获取产线和注塑挤出设备树 + /// + /// + public Task GetWorklineAndEquipTree(Dictionary dic); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs index f2be6958..a904bcaa 100644 --- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs @@ -1,13 +1,18 @@ using Aop.Api.Domain; using Aspose.Cells.Drawing; using JNPF.Common.Filter; +using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; +using JNPF.Systems.Entitys.Permission; using JNPF.VisualDev; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using Mapster; using Microsoft.AspNetCore.Mvc; +using Senparc.NeuChar.ApiHandlers; using SqlSugar; +using Tnb.BasicData; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Interfaces; @@ -78,5 +83,67 @@ namespace Tnb.EquipMgr return await _repository.AsSugarClient().Queryable().Where(x => typeIdArr.Contains(x.equip_type_id)) .ToListAsync(); } + + [HttpPost] + public async Task GetWorklineAndEquipTree(Dictionary dic) + { + string equipTypes = dic.ContainsKey("equipTypes") ? dic["equipTypes"] : ""; + var db = _repository.AsSugarClient(); + var queryable1 = db.Queryable() + .Where((a) => a.DeleteMark == null && a.Category==DictConst.RegionCategoryWorkshopCode) + .Select((a) => new WorklineAndEquipTreeOutput() + { + id = a.Id, + title = a.EnCode+"/"+a.FullName, + parentId = "0", + hasChildren = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Any(), + num = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Count(), + isLeaf = false, + children = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).ToList(b=>new WorklineAndEquipTreeOutput() + { + id = b.Id, + title = b.EnCode+"/"+b.FullName, + parentId = b.ParentId, + hasChildren = false, + num = 0, + isLeaf = true, + }) + }); + + List list2 = new List(); + if (!string.IsNullOrEmpty(equipTypes)) + { + string[] equipTypeArr = equipTypes.Split(","); + list2 = await db.Queryable() + .Where((a) => equipTypeArr.Contains(a.code)) + .Select((a) => new WorklineAndEquipTreeOutput() + { + id = a.id, + title = a.name, + parentId = "0", + hasChildren = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).Any(), + num = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).Count(), + isLeaf = false, + children = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).ToList(b=>new WorklineAndEquipTreeOutput() + { + id = b.id, + title = b.code+"/"+b.name, + parentId = b.equip_type_id, + hasChildren = false, + num = 0, + isLeaf = true, + }) + }).ToListAsync(); + + } + + // var list = await db.UnionAll(queryable1, queryable2).ToListAsync(); + var list1 = await queryable1.ToListAsync(); + list1.AddRange(list2); + return new AuthResponse(200, "", new Dictionary() + { + ["list"] = list1, + }); + } } } \ No newline at end of file From 36c65acc0e1d7267cbd11feea2d2c302341fa662 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 11:06:17 +0800 Subject: [PATCH 2/5] bug --- .../PrdMoTaskIssueService.cs | 121 +++++++++++------- 1 file changed, 77 insertions(+), 44 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs index 28190f8d..2f3ebcec 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs @@ -20,6 +20,11 @@ using Tnb.ProductionMgr.Interfaces; using Aspose.Cells.Drawing; using Microsoft.AspNetCore.Mvc; using JNPF.Common.Extension; +using JNPF.Common.Filter; +using JNPF.Systems.Entitys.System; +using Newtonsoft.Json; +using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen; +using Tnb.BasicData; namespace Tnb.ProductionMgr { @@ -46,54 +51,82 @@ namespace Tnb.ProductionMgr } + // private async Task GetList(VisualDevModelListQueryInput input) + // { + // var db = _repository.AsSugarClient(); + // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + // var data = await _runService.GetListResult(templateEntity, input); + // if (data?.list?.Count > 0) + // { + // var scheduledTypeField = nameof(PrdMoTask.schedule_type); + // data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList(); + // foreach (var row in data.list) + // { + // var dic = row.ToDictionary(x => x.Key, x => x.Value); + // var pkName = "material_id"; + // if (dic.ContainsKey(pkName)) + // { + // var materialId = dic[pkName]?.ToString(); + // var material = await db.Queryable().FirstAsync(it => it.id == materialId); + // if (material != null) + // { + // row["material_id"] = $"{material.code}/{material.name}"; + // row["materialid"] = material.id; + // } + // } + // //模具 + // if (dic.ContainsKey("mold_id")) + // { + // var moldId = dic["mold_id"]?.ToString(); + // var mold = await db.Queryable().FirstAsync(it => it.id == moldId); + // if (mold != null) + // { + // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; + // row["moldid"] = mold.id; + // } + // } + // //设备 + // if (dic.ContainsKey("eqp_id")) + // { + // var eqpId = dic["eqp_id"]?.ToString(); + // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); + // if (eqp != null) + // { + // row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + // row["eqpid"] = eqp.id; + // } + // } + // } + // } + // return data!; + // } + private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - var data = await _runService.GetListResult(templateEntity, input); - if (data?.list?.Count > 0) - { - var scheduledTypeField = nameof(PrdMoTask.schedule_type); - data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList(); - foreach (var row in data.list) + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + string moTaskStatus = queryJson.ContainsKey("mo_task_status") ? queryJson["mo_task_status"].ToString() : ""; + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) + .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode) + .LeftJoin((a,b,c,d,e)=>a.mold_id==e.id) + .LeftJoin((a,b,c,d,e,f)=>a.mo_id==f.id) + .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) + .WhereIF(!string.IsNullOrEmpty(moTaskStatus), (a, b, c, d) => a.mo_task_status == moTaskStatus) + .Where((a,b,c,d,e,f)=>a.schedule_type==1) + .Select((a, b, c, d,e,f) => new PrdMoTask { - var dic = row.ToDictionary(x => x.Key, x => x.Value); - var pkName = "material_id"; - if (dic.ContainsKey(pkName)) - { - var materialId = dic[pkName]?.ToString(); - var material = await db.Queryable().FirstAsync(it => it.id == materialId); - if (material != null) - { - row["material_id"] = $"{material.code}/{material.name}"; - row["materialid"] = material.id; - } - } - //模具 - if (dic.ContainsKey("mold_id")) - { - var moldId = dic["mold_id"]?.ToString(); - var mold = await db.Queryable().FirstAsync(it => it.id == moldId); - if (mold != null) - { - row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; - row["moldid"] = mold.id; - } - } - //设备 - if (dic.ContainsKey("eqp_id")) - { - var eqpId = dic["eqp_id"]?.ToString(); - var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); - if (eqp != null) - { - row["eqp_id"] = $"{eqp.code}/{eqp.name}"; - row["eqpid"] = eqp.id; - } - } - } - } - return data!; + id = a.id, + mo_task_code = a.mo_task_code, + material_id = b.code+"/"+b.name, + mold_id = e.mold_code+"/"+e.mold_name, + mo_task_status = d.FullName, + plan_qty = f.plan_qty, + scheduled_qty = a.scheduled_qty, + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); } } } From 3fac1f47d02615d134ba8bc923acfb7eed2e5c03 Mon Sep 17 00:00:00 2001 From: FanLian Date: Wed, 19 Jul 2023 11:07:49 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=A9=BA=E8=BD=BD=E5=85=B7=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E6=9C=80=E5=B0=8F=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsEmptyOutstockService .cs | 82 ++++++++++--------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index de713b5a..2bf0f988 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -104,7 +104,8 @@ namespace Tnb.WarehouseMgr //根据每个载具的起始库位做路径运算 if (carrys?.Count > 0) { - for (int i = 0; i < setQty.qty; i++) + int min = (carrys.Count > setQty.qty) ? setQty.qty : carrys.Count; + for (int i = 0; i < min; i++) { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carrys[i].location_id); @@ -121,26 +122,29 @@ 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 = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = carrys![i].id; - preTask.carry_code = carrys![i].carry_code; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data["ReturnIdentity"].ToString(); - preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; - 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 = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID, + carry_id = carrys![i].id, + carry_code = carrys![i].carry_code, + area_id = sPoint?.area_id!, + area_code = it.Key, + require_id = input.data["ReturnIdentity"].ToString(), + require_code = input.data[nameof(preTask.bill_code)]?.ToString()!, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + return preTask; }).ToList(); //更新页面 @@ -153,24 +157,28 @@ namespace Tnb.WarehouseMgr } if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!; - preTaskUpInput.CarryId = carrys![i].id; - preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!; - preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!; - preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!; + GenPreTaskUpInput preTaskUpInput = new() + { + RquireId = input.data["ReturnIdentity"].ToString()!, + CarryId = carrys![i].id, + CarryStartLocationId = points!.FirstOrDefault()!.location_id!, + CarryStartLocationCode = points!.FirstOrDefault()!.location_code!, + LocationIds = points!.Select(x => x.location_id).ToList()! + }; //更新明细表 - WmsEmptyOutstockD wmsEmptyOutstockD = new(); - wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); - wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; - wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - wmsEmptyOutstockD.location_id = ePoint.location_id!; - wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID; - wmsEmptyOutstockD.carry_id = carrys[i].id; - wmsEmptyOutstockD.carry_code = carrys[i].carry_code; - wmsEmptyOutstockD.create_id = _userManager.UserId; - wmsEmptyOutstockD.create_time = DateTime.Now; + WmsEmptyOutstockD wmsEmptyOutstockD = new() + { + id = SnowflakeIdHelper.NextId(), + bill_id = preTaskUpInput.RquireId, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + location_id = ePoint.location_id!, + status = WmsWareHouseConst.BILLSTATUS_ON_ID, + carry_id = carrys[i].id, + carry_code = carrys[i].carry_code, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; await _db.Insertable(wmsEmptyOutstockD) .ExecuteCommandAsync(); From 42e0e3a13ce88bbcf2caa7685c0e0f62e9b9fb9b Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 11:45:17 +0800 Subject: [PATCH 4/5] bug --- .../WorkOrderAdjustmentListOutput.cs | 21 +++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 128 ++++++++++++------ 2 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs new file mode 100644 index 00000000..46a099c5 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs @@ -0,0 +1,21 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 任务单调整列表输出 + /// + public class WorkOrderAdjustmentListOutput + { + public string id { get; set; } + public string mo_task_code { get; set; } + public string mo_task_status { get; set; } + public string material_id { get; set; } + public string mold_id { get; set; } + public int? plan_qty { get; set; } + public int? complete_qty { get; set; } + public int? scheduled_qty { get; set; } + public string workline_id { get; set; } + public string estimated_start_date { get; set; } + public string estimated_end_date { get; set; } + public string eqp_id { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 4b8074d5..b53f0461 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -888,6 +888,7 @@ namespace Tnb.ProductionMgr if (subTaskList?.Count > 0) { List subMoTasks = new(); + List subMoTaskLogs = new(); foreach (var item in subTaskList) { PrdMoTask subMoTask = new(); @@ -909,6 +910,20 @@ namespace Tnb.ProductionMgr subMoTask.create_id = _userManager.UserId; subMoTask.create_time = DateTime.Now; subMoTasks.Add(subMoTask); + + var subTaskLog = new PrdTaskLog(); + var subMaterial = await _db.Queryable().SingleAsync(x => x.id == item.material_id); + subTaskLog.id = SnowflakeIdHelper.NextId(); + subTaskLog.mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!; + subTaskLog.item_code = subMaterial?.code!; + subTaskLog.item_standard = subMaterial?.material_standard!; + subTaskLog.status = DictConst.ToBeScheduledEncode; + subTaskLog.operator_name = _userManager.RealName; + subTaskLog.create_id = _userManager.UserId; + subTaskLog.create_time = DateTime.Now; + subTaskLog.mo_task_id = subMoTask.id; + subTaskLog.mo_task_code = subMoTask.mo_task_code!; + subMoTaskLogs.Add(subTaskLog); } //根据生产任务编号生成子任务编号 if (moTask.mo_task_code!.IsNotEmptyOrNull()) @@ -920,6 +935,7 @@ namespace Tnb.ProductionMgr } } row = await _db.Insertable(subMoTasks).ExecuteCommandAsync(); + await _db.Insertable(subMoTaskLogs).ExecuteCommandAsync(); } await _db.Ado.CommitTranAsync(); } @@ -1575,49 +1591,83 @@ namespace Tnb.ProductionMgr } return instance; } + // private async Task GetList(VisualDevModelListQueryInput input) + // { + // var db = _repository.AsSugarClient(); + // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + // var data = await _runService.GetListResult(templateEntity, input); + // if (data?.list?.Count > 0) + // { + // foreach (var row in data.list) + // { + // var dic = row.ToDictionary(x => x.Key, x => x.Value); + // var pkName = "material_id_id"; + // if (dic.ContainsKey(pkName)) + // { + // var materialId = dic[pkName]?.ToString(); + // var material = await db.Queryable().FirstAsync(it => it.id == materialId); + // if (material != null) + // { + // row["material_id"] = $"{material.code}/{material.name}"; + // } + // } + // //模具 + // if (dic.ContainsKey("mold_id")) + // { + // var moldId = dic["mold_id"]?.ToString(); + // var mold = await db.Queryable().FirstAsync(it => it.id == moldId); + // if (mold != null) + // { + // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; + // } + // } + // //设备 + // if (dic.ContainsKey("eqp_id")) + // { + // var eqpId = dic["eqp_id"]?.ToString(); + // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); + // if (eqp != null) + // { + // row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + // } + // } + // } + // } + // return data!; + // } + private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - var data = await _runService.GetListResult(templateEntity, input); - if (data?.list?.Count > 0) - { - foreach (var row in data.list) + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : ""; + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) + .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode) + .LeftJoin((a,b,c,d,e)=>a.mold_id==e.id) + .LeftJoin((a,b,c,d,e,f)=>a.mo_id==f.id) + .LeftJoin((a,b,c,d,e,f,g)=>a.workline_id==g.Id) + .LeftJoin((a,b,c,d,e,f,g,h)=>a.eqp_id==h.id) + .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) + .WhereIF(!string.IsNullOrEmpty(eqpId), (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput { - var dic = row.ToDictionary(x => x.Key, x => x.Value); - var pkName = "material_id_id"; - if (dic.ContainsKey(pkName)) - { - var materialId = dic[pkName]?.ToString(); - var material = await db.Queryable().FirstAsync(it => it.id == materialId); - if (material != null) - { - row["material_id"] = $"{material.code}/{material.name}"; - } - } - //模具 - if (dic.ContainsKey("mold_id")) - { - var moldId = dic["mold_id"]?.ToString(); - var mold = await db.Queryable().FirstAsync(it => it.id == moldId); - if (mold != null) - { - row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; - } - } - //设备 - if (dic.ContainsKey("eqp_id")) - { - var eqpId = dic["eqp_id"]?.ToString(); - var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); - if (eqp != null) - { - row["eqp_id"] = $"{eqp.code}/{eqp.name}"; - } - } - } - } - return data!; + id = a.id, + mo_task_code = a.mo_task_code, + material_id = b.code+"/"+b.name, + mold_id = e.mold_code+"/"+e.mold_name, + mo_task_status = d.FullName, + plan_qty = f.plan_qty, + complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0), + scheduled_qty = a.scheduled_qty, + workline_id = a.workline_id==null ? "" :g.EnCode+"/"+g.FullName, + estimated_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"), + estimated_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"), + eqp_id = a.eqp_id==null ? "" : h.code+"/"+h.name, + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); } /// From e6d2dda71cb0f134d92906e24e96b7d922ba3d45 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 13:37:36 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8D=95=E8=B0=83=E6=95=B4=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b53f0461..b73e6164 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1642,6 +1642,14 @@ namespace Tnb.ProductionMgr Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : ""; + List worklineIds = new List(); + List equipIds = new List(); + if (!string.IsNullOrEmpty(eqpId)) + { + worklineIds = await db.Queryable().Where(x => x.ParentId == eqpId && x.Category==DictConst.RegionCategoryWorklineCode && x.DeleteMark==null).Select(x=>x.Id).ToListAsync(); + equipIds = await db.Queryable().Where(x => x.equip_type_id == eqpId).Select(x => x.id).ToListAsync(); + } + var result = await db.Queryable() .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) @@ -1651,7 +1659,9 @@ namespace Tnb.ProductionMgr .LeftJoin((a,b,c,d,e,f,g)=>a.workline_id==g.Id) .LeftJoin((a,b,c,d,e,f,g,h)=>a.eqp_id==h.id) .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) - .WhereIF(!string.IsNullOrEmpty(eqpId), (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count<=0 && worklineIds.Count<=0, (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .WhereIF(worklineIds.Count>0,(a, b, c, d)=>worklineIds.Contains(a.workline_id)) + .WhereIF(equipIds.Count>0,(a, b, c, d)=>equipIds.Contains(a.eqp_id)) .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput { id = a.id,