模具保养

This commit is contained in:
qianjiawei
2023-11-02 10:14:06 +08:00
parent b00eea39dd
commit b1984e5548
3 changed files with 101 additions and 4 deletions

View File

@@ -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; }
}
}

View File

@@ -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; }
}
}

View File

@@ -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<dynamic> result = new();
var planMoldRelations = await _db.Queryable<ToolMoldMaintainPlanRelation>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
.LeftJoin<ToolMoldMaintainRunRecord>((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<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
if (moldEqpRelation != null)
@@ -183,6 +188,51 @@ namespace Tnb.EquipMgr
return result;
}
[HttpPost]
public async Task<dynamic> 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<ToolMoldMaintainItemRecord>().Select(p => p.plan_id + p.mold_id).ToListAsync();
var result= await _db.Queryable<ToolMoldMaintainPlanRelation>()
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c, d) => b.plan_code == d.plan_code && c.mold_code == d.mold_code)
.LeftJoin<ToolMoldMaintainItemRecord>((a, b, c, d, e) => e.plan_id == b.id && e.mold_id == c.id)
.LeftJoin<UserEntity>((a, b, c, d, e, f) => b.create_id == f.Id)
.LeftJoin<DictionaryDataEntity>((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<PadMainListOutput>.SqlSugarPageResult(result);
}
/// <summary>
/// 根据计划Id、模具ID获取保养组及项目信息
/// </summary>