andon呼叫 aql 模具保养
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Joins;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using DingTalk.Api.Request;
|
||||
using JNPF.Common.Core.Manager;
|
||||
@@ -13,7 +15,10 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
@@ -93,6 +98,68 @@ namespace Tnb.EquipMgr
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetMaintainInfo()
|
||||
{
|
||||
List<dynamic> result = new();
|
||||
var plans = await _db.Queryable<ToolMoldMaintainPlan>().ToListAsync();
|
||||
var ToolMolds = await _db.Queryable<ToolMolds>().ToListAsync();
|
||||
var ToolMoldsEquipments = await _db.Queryable<ToolMoldsEquipment>().ToListAsync();
|
||||
var EqpEquipments = await _db.Queryable<EqpEquipment>().ToListAsync();
|
||||
var dic = await _db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == "26149299883285").ToListAsync();
|
||||
var users = await _db.Queryable<UserEntity>().ToListAsync();
|
||||
foreach (var plan in plans)
|
||||
{
|
||||
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)
|
||||
.Where(a => a.maintain_plan_id == plan.id)
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
mold_id = a.mold_id,
|
||||
plan_start_time = c.plan_start_time,
|
||||
}).ToListAsync();
|
||||
if (planMoldRelations?.Count > 0)
|
||||
{
|
||||
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||
var molds = ToolMolds.Where(it => mids.Contains(it.id)).ToList();
|
||||
if (molds?.Count > 0)
|
||||
{
|
||||
List<dynamic> infos = new List<dynamic> { };
|
||||
for (int i = 0, cnt = molds.Count; i < cnt; i++)
|
||||
{
|
||||
var mold = molds[i];
|
||||
dynamic info = new ExpandoObject();
|
||||
info.mold_id = mold.id;
|
||||
info.mold_code = mold.mold_code;
|
||||
info.mold_name = mold.mold_name;
|
||||
info.mold_status = dic.Where(p => p.Id == mold.mold_status).Any() ? dic.Where(p => p.Id == mold.mold_status).First().FullName : "";
|
||||
info.maintain_qty = mold.maintain_qty;
|
||||
info.plan_start_time = planMoldRelations[i].plan_start_time == null ? "" : ((DateTime)planMoldRelations[i].plan_start_time).ToString("yyyy-MM-dd");
|
||||
info.createtime = plan.create_time == null ? "" : ((DateTime)plan.create_time).ToString("yyyy-MM-dd");
|
||||
info.status = plan.status == "UnMaintain" ? "待保养" : "已完成";
|
||||
info.createuser = string.IsNullOrEmpty(plan.create_id) ? "" : users.Where(p => p.Id == plan.create_id).First().RealName;
|
||||
info.plan_id = plan.id;
|
||||
var moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault();
|
||||
if (moldEqpRelation != null)
|
||||
{
|
||||
var eqp = EqpEquipments.Where(it => it.id == moldEqpRelation.equipment_id).FirstOrDefault();
|
||||
if (eqp != null)
|
||||
{
|
||||
info.eqp_code = eqp.code;
|
||||
info.eqp_name = eqp.name;
|
||||
}
|
||||
}
|
||||
result.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划Id、模具ID获取,保养组及项目信息
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user