diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs new file mode 100644 index 00000000..054a8d4f --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/PadMainListOutput.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + public class PadMainListOutput + { + public string plan_id { get; set; } + public string mold_id { get; set; } + + public string mold_code { get; set; } + + public string mold_name { get; set; } + + public string mold_status { get; set; } + public string status { get; set; } + public string createuser { get; set; } + public string createtime { get; set; } + public string plan_start_time { get; set; } + public string starttime { get; set; } + + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/PdaMaintainInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/PdaMaintainInput.cs new file mode 100644 index 00000000..dfeffb72 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/PdaMaintainInput.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Filter; + +namespace Tnb.EquipMgr.Entities.Dto +{ + public class PdaMaintainInput : PageInputBase + { + public string status { get; set; } + + public string maintain_info { get; set; } + + public DateTime? start_time { get; set; } + public DateTime? end_time { get; set; } + + } +} diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index 6fb1fa6c..0bb50b4c 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Dynamic; using System.Linq; +using System.Numerics; using System.Reactive.Joins; using System.Text; using System.Threading.Tasks; @@ -12,6 +13,7 @@ using DingTalk.Api.Request; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; +using JNPF.Common.Filter; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; @@ -62,12 +64,14 @@ namespace Tnb.EquipMgr List result = new(); var planMoldRelations = await _db.Queryable() .LeftJoin((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan - .LeftJoin((a, b, c) => b.plan_code == c.plan_code) + .LeftJoin((a, b, c) => a.mold_id == c.id) + .LeftJoin((a, b, c,d) => d.plan_code == b.plan_code&&d.mold_code==c.mold_code) .Where(a => a.maintain_plan_id == planId) - .Select((a, b, c) => new + .Select((a, b, c,d) => new { mold_id = a.mold_id, - plan_start_time = c.plan_start_time, + plan_start_time = d.plan_start_time, + designer=d.designer }) .ToListAsync(); var moldids = planMoldRelations.Select(x => x.mold_id).ToList(); @@ -75,7 +79,7 @@ namespace Tnb.EquipMgr foreach (var planMoldRelation in planMoldRelations) { - var mold= molds.Where(p=>p.id== planMoldRelation.mold_id).FirstOrDefault(); + var mold = molds.Where(p => p.id == planMoldRelation.mold_id).FirstOrDefault(); if (mold != null) { dynamic info = new ExpandoObject(); @@ -84,6 +88,7 @@ namespace Tnb.EquipMgr info.mold_name = mold.mold_name; info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status!))?.FullName; info.maintain_qty = mold.maintain_qty; + info.designer = planMoldRelation.designer == null ? "" : planMoldRelation.designer; info.plan_start_time = planMoldRelation.plan_start_time == null ? "" : ((DateTime)planMoldRelation.plan_start_time).ToString("yyyy-MM-dd"); var moldEqpRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id); if (moldEqpRelation != null) @@ -183,6 +188,51 @@ namespace Tnb.EquipMgr return result; } + [HttpPost] + public async Task GetPdaMaintainInfo(PdaMaintainInput input) + { + DateTime? start_time = input.start_time; + DateTime? end_time = input.end_time; + if (string.IsNullOrEmpty(input.sidx)) + { + input.sidx = "b.create_time"; + input.sort = "desc"; + } + else + { + input.sidx = "b." + input.sidx; + } + var records = await _db.Queryable().Select(p => p.plan_id + p.mold_id).ToListAsync(); + var result= await _db.Queryable() + .LeftJoin((a, b) => a.maintain_plan_id == b.id) + .LeftJoin((a, b, c) => a.mold_id == c.id) + .LeftJoin((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code) + .LeftJoin((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id) + .LeftJoin((a, b, c, d, e, f) => b.create_id == f.Id) + .LeftJoin((a, b, c, d, e, f,g) => c.mold_status == g.Id) + .Where((a, b, c, d, e, f) => b.create_time != null) + .WhereIF(!string.IsNullOrEmpty(input.maintain_info), (a, b, c, d, e, f, g) => c.mold_code!.Contains(input.maintain_info) || c.mold_name!.Contains(input.maintain_info)) + .WhereIF(start_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time >= start_time) + .WhereIF(end_time != null, (a, b, c, d, e, f, g) => b.create_time != null && b.create_time <= end_time) + .WhereIF(input.status == "待保养", (a, b, c, d, e, f, g) => !records.Contains(a.maintain_plan_id + a.mold_id)) + .WhereIF(input.status == "已完成", (a, b, c, d, e, f, g) => records.Contains(a.maintain_plan_id + a.mold_id)) + .Select((a, b, c, d, e, f, g) => new PadMainListOutput + { + plan_id = b.id, + mold_id = c.id, + mold_code = c.mold_code!, + mold_name = c.mold_name!, + mold_status=g.FullName!, + status = input.status, + createuser = f.RealName, + createtime = b.create_time == null ? "" : b.create_time.Value.ToString(DbTimeFormat.SS), + plan_start_time = b.plan_start_date == null ? "" : b.plan_start_date.Value.ToString(DbTimeFormat.SS), + starttime = d.plan_start_time == null ? "" : d.plan_start_time.Value.ToString(DbTimeFormat.SS), + }).OrderBy($"{input.sidx} {input.sort}").ToPagedListAsync((input?.currentPage ?? 1), (input?.pageSize ?? 50)); + return PageResult.SqlSugarPageResult(result); + } + + /// /// 根据计划Id、模具ID获取,保养组及项目信息 ///