From a78186d7b0e29f64fdf89a22a82c239d85dcb21c Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 28 Jul 2023 13:40:20 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E6=8B=A3?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 3dfa04c8..173e890a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -562,7 +562,7 @@ namespace Tnb.WarehouseMgr if (curEleDs?.Count > 0) { //当前电梯 - var curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.status == 1) ?? throw new AppFriendlyException("电梯被禁用", 500); + var curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.status == 1) ?? throw new AppFriendlyException("电梯被禁用或未配置", 500); //同电梯组电梯 var sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.status == 1).ToListAsync(); //判断电梯组中各电梯任务数 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index d0456106..bd9f01fc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -110,8 +110,8 @@ namespace Tnb.WarehouseMgr if (carryCodesPart?.Count > 0) { - carryCodes.AddRange(carryCodesPart); - var codeQty = carryCodes.Sum(x => x.codeqty); + + var codeQty = carryCodesPart.Sum(x => x.codeqty); if (codeQty < os.pr_qty) { throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500); @@ -132,6 +132,7 @@ namespace Tnb.WarehouseMgr break; } } + carryCodes.AddRange(curCarryCodes); var partCarryMats = curCarryCodes.Adapt>(); for (int i = 0; i < partCarryMats.Count; i++) { @@ -655,6 +656,7 @@ namespace Tnb.WarehouseMgr osd.qty += dic[osd.id].Sum(d => d); if (osd.qty >= osd.pr_qty) { + osd.qty = osd.pr_qty; osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; } else @@ -704,9 +706,8 @@ namespace Tnb.WarehouseMgr await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).ExecuteCommandAsync(); } } - await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); + var row = await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Deleteable().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync(); - } if (delBarcodes.Count > 0) { From c18b937dc1acb1b1c489b9cc84fd792fb3560315 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Fri, 28 Jul 2023 16:26:27 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=80=92=E5=8F=99=EF=BC=8C=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=88=97=E8=A1=A8=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/PrdMoListOuput.cs | 22 +++ .../Dto/PrdManage/PrdMoTaskIssueListOutput.cs | 14 ++ .../Dto/PrdManage/PrdMoTaskOutput.cs | 2 + .../WorkOrderAdjustmentListOutput.cs | 1 + .../Entity/PrdMo.cs | 6 + .../Tnb.ProductionMgr/PrdMoService.cs | 136 ++++++++++++------ .../PrdMoTaskIssueService.cs | 7 +- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 28 ++-- .../Tnb.ProductionMgr/PrdPackReportService.cs | 3 +- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 3 +- 10 files changed, 163 insertions(+), 59 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListOuput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListOuput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListOuput.cs new file mode 100644 index 00000000..82f7295c --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoListOuput.cs @@ -0,0 +1,22 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class PrdMoListOuput + { + public string id { get; set; } + + public string mo_type { get; set; } + + public string mo_source { get; set; } + public string mo_code { get; set; } + public string plan_start_date { get; set; } + public string plan_end_date { get; set; } + public string material_id { get; set; } + public int? plan_qty { get; set; } + public string unit_id { get; set; } + public string mo_status { get; set; } + public string? remark { get; set; } + public string combine_mo_code { get; set; } + public string material_id_id { get; set; } + public List children { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs new file mode 100644 index 00000000..722ddda9 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs @@ -0,0 +1,14 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class PrdMoTaskIssueListOutput + { + public string id { get; set; } + public string mo_task_code { get; set; } + public string material_id { get; set; } + public string mold_id { get; set; } + public string mo_task_status { get; set; } + public int? plan_qty { get; set; } + public int? scheduled_qty { get; set; } + public string create_time { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs index e714bb9b..aa48d3b7 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs @@ -84,6 +84,8 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 工序名称 /// public string process_name { get; set;} + + public string create_time { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs index 46a099c5..c5ca9609 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs @@ -17,5 +17,6 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public string estimated_start_date { get; set; } public string estimated_end_date { get; set; } public string eqp_id { get; set; } + public string create_time { get; set; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs index f456faf7..6b12ce6d 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs @@ -227,5 +227,11 @@ public partial class PrdMo : BaseEntity /// 物料单位 /// public string? unit_id { get; set; } + + /// + /// 工单来源 + /// + public string? mo_source { get; set; } + } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 16b52328..6c2d1c49 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -1,28 +1,16 @@ -using System.Reflection.Emit; -using System.Text; -using Aop.Api.Domain; -using DbModels; -using JNPF.Common.Core.Manager; -using JNPF.Common.Enums; +using JNPF.Common.Core.Manager; using JNPF.Common.Extension; +using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; -using JNPF.Extensitions.EventBus; using JNPF.FriendlyException; -using JNPF.Logging; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; -using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using JNPF.VisualDev.Interfaces; -using Mapster; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging.Abstractions; -using NPOI.SS.Formula.Functions; -using Org.BouncyCastle.Crypto.Generators; -using Senparc.Weixin.Work.AdvancedAPIs.MailList; using SqlSugar; using Tnb.BasicData; using Tnb.BasicData.Entities; @@ -74,43 +62,103 @@ namespace Tnb.ProductionMgr OverideFuncs.GetListAsync = GetList; } + // 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.Add("material_name", material.name); + // row.Add($"material_attribute", material.attribute); + // if (dic.ContainsKey("material_id")) + // { + // row["material_id"] = material.code + "/" + material.name; + // } + // } + // + // if (dic.ContainsKey("unit_id")) + // { + // string unitId = dic["unit_id"]?.ToString() ?? ""; + // var unit = await db.Queryable().SingleAsync(x => x.Id == unitId); + // row["unit_id"] = unit?.FullName ?? ""; + // } + // } + // } + // } + // 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) ? Newtonsoft.Json.JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moCode = queryJson.ContainsKey("mo_code") ? queryJson["mo_code"].ToString() : ""; + string moStatus = queryJson.ContainsKey("mo_status") ? queryJson["mo_status"].ToString() : ""; + string combineMoCode = queryJson.ContainsKey("combine_mo_code") ? queryJson["combine_mo_code"].ToString() : ""; + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => c.EnCode == DictConst.MeasurementUnit) + .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.unit_id == d.Id) + .LeftJoin((a, b, c, d, e) => a.mo_status == e.Id) + .LeftJoin((a, b, c, d, e,f) => a.mo_type==f.Id) + .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)) + .WhereIF(!string.IsNullOrEmpty(moStatus), (a, b, c, d, e) => a.mo_status == moStatus) + .Where(a=>SqlFunc.IsNullOrEmpty(a.parent_id)) + .OrderByDescending(a=>a.create_time) + .Select((a, b, c, d, e,f) => new PrdMoListOuput { - 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) + id = a.id, + mo_type = f.FullName, + mo_source = a.mo_source=="1" ? "ERP同步" : "新建/导入", + mo_code = a.mo_code, + plan_start_date = a.plan_start_date==null ? "" : a.plan_start_date.Value.ToString("yyyy-MM-dd"), + plan_end_date = a.plan_end_date==null ? "" : a.plan_end_date.Value.ToString("yyyy-MM-dd"), + material_id = b.code+"/"+b.name, + material_id_id = b.id, + plan_qty = a.plan_qty, + unit_id = d.FullName, + mo_status = e.FullName, + remark = a.remark, + children = SqlFunc.Subqueryable() + .LeftJoin((aa, bb) => aa.material_id == bb.id) + .LeftJoin((aa, bb, cc) => cc.EnCode == DictConst.MeasurementUnit) + .LeftJoin((aa, bb, cc, dd) => cc.Id == dd.DictionaryTypeId && aa.unit_id == dd.Id) + .LeftJoin((aa, bb, cc, dd, ee) => aa.mo_status == ee.Id) + .LeftJoin((aa, bb, cc, dd, ee,ff) => aa.mo_type==ff.Id) + .Where(aa=>aa.parent_id==a.id) + .ToList((aa,bb,cc,dd,ee,ff)=>new PrdMoListOuput { - row.Add("material_name", material.name); - row.Add($"material_attribute", material.attribute); - if (dic.ContainsKey("material_id")) - { - row["material_id"] = material.code + "/" + material.name; - } - } - - if (dic.ContainsKey("unit_id")) - { - string unitId = dic["unit_id"]?.ToString() ?? ""; - var unit = await db.Queryable().SingleAsync(x => x.Id == unitId); - row["unit_id"] = unit?.FullName ?? ""; - } - } - } - } - return data!; + id = aa.id, + mo_type = ff.FullName, + mo_source = aa.mo_source=="1" ? "ERP同步" : "新建/导入", + mo_code = aa.mo_code, + plan_start_date = aa.plan_start_date==null ? "" : aa.plan_start_date.Value.ToString("yyyy-MM-dd"), + plan_end_date = aa.plan_end_date==null ? "" : aa.plan_end_date.Value.ToString("yyyy-MM-dd"), + material_id = bb.code+"/"+bb.name, + material_id_id = bb.id, + plan_qty = aa.plan_qty, + unit_id = dd.FullName, + mo_status = ee.FullName, + remark = aa.remark, + }) + }).ToPagedListAsync(input.currentPage, int.MaxValue); + return PageResult.SqlSugarPageResult(result); } + #region Get diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs index 2f3ebcec..3524721d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs @@ -25,6 +25,7 @@ using JNPF.Systems.Entitys.System; using Newtonsoft.Json; using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen; using Tnb.BasicData; +using Tnb.ProductionMgr.Entities.Dto; namespace Tnb.ProductionMgr { @@ -116,7 +117,8 @@ namespace Tnb.ProductionMgr .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 + .OrderByDescending(a=>a.create_time) + .Select((a, b, c, d,e,f) => new PrdMoTaskIssueListOutput { id = a.id, mo_task_code = a.mo_task_code, @@ -125,8 +127,9 @@ namespace Tnb.ProductionMgr mo_task_status = d.FullName, plan_qty = f.plan_qty, scheduled_qty = a.scheduled_qty, + create_time = a.create_time==null ? "" :a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), }).ToPagedListAsync(input.currentPage, input.pageSize); - return PageResult.SqlSugarPageResult(result); + return PageResult.SqlSugarPageResult(result); } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 02c93dd0..ab218734 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -303,6 +303,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d) => a.mold_id == d.id) .LeftJoin((a, b, c, d, e) => a.eqp_id == e.id) .Where((a, b, c, d, e) => a.mo_id == moId) + .OrderByDescending((a,b,c,d,e)=>a.create_time) .Select((a, b, c, d, e) => new PrdMoTaskOutput { mo_task_code = a.mo_task_code, @@ -321,6 +322,7 @@ namespace Tnb.ProductionMgr complete_qty = SqlFunc.IsNull(a.reported_work_qty,0)+SqlFunc.IsNull(a.scrap_qty,0), process_code = SqlFunc.Subqueryable().Where(it => it.id == a.process_id).Select(it => it.process_code), process_name = SqlFunc.Subqueryable().Where(it => it.id == a.process_id).Select(it => it.process_name), + create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), }) .Mapper(it => { @@ -335,6 +337,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d) => a.workline_id == d.Id) .LeftJoin((a,b,c,d,e)=>a.process_id==e.id) .Where((a, b, c, d) => (b.id == moId || b.parent_id == moId) && SqlFunc.IsNullOrEmpty(a.parent_id)) + .OrderByDescending((a,b,c,d,e)=>a.create_time) .Select((a, b, c, d,e) => new PrdMoTaskOutput { mo_task_code = a.mo_task_code, @@ -350,6 +353,7 @@ namespace Tnb.ProductionMgr estimated_end_date = a.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss"), plan_qty = a.scheduled_qty, complete_qty = SqlFunc.IsNull(a.reported_work_qty,0)+SqlFunc.IsNull(a.scrap_qty,0), + create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), }) .Mapper(it => { @@ -375,6 +379,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d) => a.bom_id == d.id) .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), (a, b, c, d) => a.mo_task_code.Contains(input.mo_task_code)) .Where((a, b, c, d) => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id)) + .OrderByDescending(a=>a.create_time) .Select((a, b, c, d) => new PackSechelToBeIssueListOutput { mo_task_id = a.id, @@ -1800,19 +1805,21 @@ namespace Tnb.ProductionMgr 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) - .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) + .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) && 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)) + .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, @@ -1827,7 +1834,8 @@ namespace Tnb.ProductionMgr 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); + create_time = a.create_time==null ? "" :a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") + }).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 4be63421..62cf4e1d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -81,6 +81,7 @@ namespace Tnb.ProductionMgr // .WhereIF(end, a => a.estimated_end_date != null && endTimes[0] <= a.estimated_end_date && endTimes[1] >= a.estimated_end_date) .WhereIF(!string.IsNullOrEmpty(input.workline), a => list.Where(p => p.EnCode.Contains(input.workline) || p.FullName.Contains(input.workline)).Select(p => p.Id).ToList().Contains(a.workline_id!)) .Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled") + .OrderByDescending(a=>a.create_time) .Select((a, b, c) => new PrdMoTask { id = a.id, @@ -187,7 +188,7 @@ namespace Tnb.ProductionMgr process_name = b.process_name, plan_start_date = a.estimated_start_date, plan_end_date = a.estimated_end_date, - plan_qty = c.scheduled_qty, + plan_qty = a.scheduled_qty, //complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty), complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0), mo_task_status = a.mo_task_status, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index c7cb7feb..d3903b74 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -155,8 +155,7 @@ namespace Tnb.ProductionMgr plan_qty = a.scheduled_qty, complete_qty = a.reported_work_qty, mo_task_status = a.mo_task_status, - schedule_type = a.schedule_type.ToString() - + schedule_type = a.schedule_type.ToString(), }) .Mapper(x=>x.mo_task_status=dic[x.mo_task_status].ToString()) .ToPagedListAsync(input.currentPage, input.pageSize); From fe4e0d90b7c9f78dca060e40078b57b89233aeb1 Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 31 Jul 2023 08:38:26 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WareHouseService.cs | 67 ++++++++++--------- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 4 +- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 173e890a..34c97202 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -160,7 +160,6 @@ namespace Tnb.WarehouseMgr try { items = await _db.Queryable().Where(it => it.wh_id == input.warehouse_id && it.is_lock == 0 && it.is_type == "0" && it.is_use == ((int)EnumCarryStatus.空闲).ToString()).OrderBy(it => new { it.layers, it.loc_line, it.loc_column }, OrderByType.Asc).ToListAsync(); - } catch (Exception) { @@ -553,46 +552,52 @@ namespace Tnb.WarehouseMgr { var roads = await _db.Queryable().ToListAsync(); var points = await LocPathCalcAlgorithms(pStartId, pEndId, roads); - - if (points.FindAll(x => x.location_code != null && x.location_code.Contains("ELE"))?.Count > 0) + try { - //查询当前电梯点 - var curEleDs = await _db.Queryable().Where(it => points.Select(x => x.id).Contains(it.point_id)).ToListAsync(); - //如果有电梯点,则会进行电梯的均匀分配 - if (curEleDs?.Count > 0) + if (points.FindAll(x => x.location_code != null && x.location_code.Contains("ELE"))?.Count > 0) { - //当前电梯 - var curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.status == 1) ?? throw new AppFriendlyException("电梯被禁用或未配置", 500); - //同电梯组电梯 - var sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.status == 1).ToListAsync(); - //判断电梯组中各电梯任务数 - if (sGpEle.FindAll(x => Math.Abs(x.task_nums - curEle.task_nums) % 2 == 1)?.Count > 0) + //查询当前电梯点 + var curEleDs = await _db.Queryable().Where(it => points.Select(x => x.id).Contains(it.point_id)).ToListAsync(); + //如果有电梯点,则会进行电梯的均匀分配 + if (curEleDs?.Count > 0) { - var sGpDs = await _db.Queryable().Where(it => it.bill_id == sGpEle.First().id).ToListAsync(); - if (sGpDs?.Count > 0) + //当前电梯 + var curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.status == 1) ?? throw new AppFriendlyException("电梯被禁用或未配置", 500); + //同电梯组电梯 + var sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.status == 1).ToListAsync(); + //判断电梯组中各电梯任务数 + if (sGpEle.FindAll(x => Math.Abs(x.task_nums - curEle.task_nums) % 2 == 1)?.Count > 0) { - var sGpPoints = await _db.Queryable().Where(it => sGpDs.Select(x => x.point_id).Contains(it.id)).ToListAsync(); - var sFEndId = sGpDs.Single(x => x.floor == curEleDs.First().floor).point_id; - var eFStartId = sGpDs.Single(x => x.floor == curEleDs.Last().floor).point_id; - var sFPoints = await LocPathCalcAlgorithms(pStartId, sFEndId, roads); - List elePoints = new(); - foreach (var pt in curEleDs) + var sGpDs = await _db.Queryable().Where(it => it.bill_id == sGpEle.First().id).ToListAsync(); + if (sGpDs?.Count > 0) { - var elePoint = sGpPoints.Find(x => x.floor == pt.floor); - if (elePoint != null) - elePoints.Add(elePoint); + var sGpPoints = await _db.Queryable().Where(it => sGpDs.Select(x => x.point_id).Contains(it.id)).ToListAsync(); + var sFEndId = sGpDs.Single(x => x.floor == curEleDs.First().floor).point_id; + var eFStartId = sGpDs.Single(x => x.floor == curEleDs.Last().floor).point_id; + var sFPoints = await LocPathCalcAlgorithms(pStartId, sFEndId, roads); + List elePoints = new(); + foreach (var pt in curEleDs) + { + var elePoint = sGpPoints.Find(x => x.floor == pt.floor); + if (elePoint != null) + elePoints.Add(elePoint); + } + var eFPoints = await LocPathCalcAlgorithms(eFStartId, pEndId, roads); + elePoints.Remove(elePoints.First()); + elePoints.Remove(elePoints.Last()); + points.Clear(); + points.AddRange(sFPoints); + points.AddRange(elePoints); + points.AddRange(eFPoints); } - var eFPoints = await LocPathCalcAlgorithms(eFStartId, pEndId, roads); - elePoints.Remove(elePoints.First()); - elePoints.Remove(elePoints.Last()); - points.Clear(); - points.AddRange(sFPoints); - points.AddRange(elePoints); - points.AddRange(eFPoints); } } } } + catch (Exception) + { + throw; + } return points; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index cc149b94..632d7a22 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -20,6 +20,7 @@ using JNPF.Systems.Interfaces.System; using Mapster; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.CodeAnalysis.CSharp.Syntax; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; @@ -341,8 +342,6 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException(nameof(input)); try { - - await _db.Ado.BeginTranAsync(); List kittingOutDs = new(); var kittingOuts = input.Adapt>(); @@ -372,6 +371,7 @@ namespace Tnb.WarehouseMgr kittingOutDs.AddRange(d); } } + await _db.Insertable(kittingOuts).ExecuteCommandAsync(); await _db.Insertable(kittingOutDs).ExecuteCommandAsync(); From 52f709c41a9080dd573c93ed52fb8bad71fb7a7b Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 31 Jul 2023 09:18:45 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=B5=E6=A2=AF?= =?UTF-8?q?=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 34c97202..fef48480 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -562,7 +562,8 @@ namespace Tnb.WarehouseMgr if (curEleDs?.Count > 0) { //当前电梯 - var curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.status == 1) ?? throw new AppFriendlyException("电梯被禁用或未配置", 500); + var curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.status == 1); + if (curEle == null) throw new AppFriendlyException("电梯被禁用或未配置", 500); //同电梯组电梯 var sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.status == 1).ToListAsync(); //判断电梯组中各电梯任务数 @@ -591,6 +592,7 @@ namespace Tnb.WarehouseMgr points.AddRange(eFPoints); } } + } } } From f4814f9af286936fa7ea91a7982106b6420a5d75 Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 31 Jul 2023 11:16:59 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs index 585b20b2..ac88c0a9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs @@ -69,8 +69,8 @@ namespace Tnb.WarehouseMgr var data = new CarryQueryOutput(); try { - var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.carry_code); - if (carry.IsNull()) throw new AppFriendlyException($"编号{input.carry_code},对应载具不存在", 500); + var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.carry_code && it.status == 1); + if (carry.IsNull()) throw new AppFriendlyException($"编号{input.carry_code},对应载具不存在或被禁用", 500); List carryCodes = new(); var carryDsLst = await _db.Queryable().Where(it => it.carry_id == carry.id).ToListAsync(); if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && carryDsLst?.Count > 0) From ca4e4c34e17d91ca9ff73e099b9bc695df8483ca Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 31 Jul 2023 11:36:04 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=E6=9C=89carry=5Fcode=E7=9A=84=E6=98=A0=E5=B0=84=EF=BC=8C?= =?UTF-8?q?=E5=B0=86carry=5Fid=E6=98=A0=E5=B0=84=E6=88=90carry=5Fcode?= =?UTF-8?q?=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index 6cb7f10d..91ea0b17 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -132,6 +132,7 @@ namespace Tnb.WarehouseMgr var isSuccessFul = false; if (input.IsNull()) throw new ArgumentNullException("input"); var signInput = input.Adapt(); + if(signInput.carryId.IsNotEmptyOrNull()) signInput.carryId = ""; try { await SignForDelivery(signInput); From b79ce73d427a2ec180b97fcfb34df038679533fe Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 31 Jul 2023 11:39:57 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index 91ea0b17..1281bcf7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -104,7 +104,7 @@ namespace Tnb.WarehouseMgr loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask!.require_id!, - carryIds = new List { input.carryId }, + carryIds = new List { carry!.id }, distaskCodes = input.distaskCodes }; await DoUpdate(upInput); //回更业务 @@ -132,7 +132,7 @@ namespace Tnb.WarehouseMgr var isSuccessFul = false; if (input.IsNull()) throw new ArgumentNullException("input"); var signInput = input.Adapt(); - if(signInput.carryId.IsNotEmptyOrNull()) signInput.carryId = ""; + if (signInput.carryId.IsNotEmptyOrNull()) signInput.carryId = ""; try { await SignForDelivery(signInput); From 05dcc210bf43600a875982b07fb52845716d7145 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Mon, 31 Jul 2023 11:59:10 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E6=8C=A4=E5=87=BA?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8D=95=E4=B8=8B=E5=8F=91=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E6=B7=BB=E5=8A=A0=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/PrdMoTaskIssueListOutput.cs | 1 + ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs index 722ddda9..c648d5f0 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskIssueListOutput.cs @@ -6,6 +6,7 @@ namespace Tnb.ProductionMgr.Entities.Dto public string mo_task_code { get; set; } public string material_id { get; set; } public string mold_id { get; set; } + public string eqp_id { get; set; } public string mo_task_status { get; set; } public int? plan_qty { get; set; } public int? scheduled_qty { get; set; } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs index 3524721d..9a07fb20 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs @@ -114,21 +114,22 @@ namespace Tnb.ProductionMgr .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)=>g.id==a.eqp_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) - .OrderByDescending(a=>a.create_time) - .Select((a, b, c, d,e,f) => new PrdMoTaskIssueListOutput + .Select((a, b, c, d,e,f,g) => new PrdMoTaskIssueListOutput { id = a.id, mo_task_code = a.mo_task_code, material_id = b.code+"/"+b.name, mold_id = e.mold_code+"/"+e.mold_name, + eqp_id = g.code+"/"+g.name, mo_task_status = d.FullName, plan_qty = f.plan_qty, scheduled_qty = a.scheduled_qty, create_time = a.create_time==null ? "" :a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), - }).ToPagedListAsync(input.currentPage, input.pageSize); + }).OrderByDescending(a=>a.create_time).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } }