模具保养大改
This commit is contained in:
@@ -29,6 +29,9 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
/// 保养项Ids
|
||||
/// </summary>
|
||||
public List<MaintainItemInfo> items { get; set; }
|
||||
|
||||
|
||||
public string starttime { get; set; }
|
||||
}
|
||||
|
||||
public class MaintainItemInfo
|
||||
@@ -37,5 +40,7 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
public string item_group_id { get; set; }
|
||||
public string item_id { get; set; }
|
||||
|
||||
public string result { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,6 @@ public partial class ToolMoldMaintainItemRecord : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string plan_id { get; set; }
|
||||
|
||||
public string result { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Aspose.Words;
|
||||
using DingTalk.Api.Request;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
@@ -69,31 +70,29 @@ namespace Tnb.EquipMgr
|
||||
plan_start_time = c.plan_start_time,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (planMoldRelations?.Count > 0)
|
||||
var moldids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||
var molds = await _db.Queryable<ToolMolds>().Where(it => moldids.Contains(it.id)).ToListAsync();
|
||||
foreach (var planMoldRelation in planMoldRelations)
|
||||
|
||||
{
|
||||
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||
var molds = await _db.Queryable<ToolMolds>().Where(it => mids.Contains(it.id)).ToListAsync();
|
||||
if (molds?.Count > 0)
|
||||
var mold= molds.Where(p=>p.id== planMoldRelation.mold_id).FirstOrDefault();
|
||||
if (mold != null)
|
||||
{
|
||||
for (int i = 0, cnt = molds.Count; i < cnt; 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 = (await _dictionaryDataService.GetInfo(mold.mold_status!))?.FullName;
|
||||
info.maintain_qty = mold.maintain_qty;
|
||||
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)
|
||||
{
|
||||
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 = (await _dictionaryDataService.GetInfo(mold.mold_status))?.FullName;
|
||||
info.maintain_qty = mold.maintain_qty;
|
||||
info.plan_start_time = planMoldRelations[i].plan_start_time;
|
||||
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
||||
if (moldEqpRelation != null)
|
||||
{
|
||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
|
||||
info.eqp_code = eqp.code;
|
||||
info.eqp_name = eqp.name;
|
||||
}
|
||||
result.Add(info);
|
||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
|
||||
info.eqp_code = eqp.code;
|
||||
info.eqp_name = eqp.name;
|
||||
}
|
||||
result.Add(info);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -106,24 +105,19 @@ namespace Tnb.EquipMgr
|
||||
Dictionary<string, string> dicstatus = new Dictionary<string, string>();
|
||||
dicstatus.Add("UnMaintain", "待保养");
|
||||
dicstatus.Add("Completed", "已完成");
|
||||
string status = string.Empty;
|
||||
if (!string.IsNullOrEmpty(input.status))
|
||||
{
|
||||
status = dicstatus.Where(p => p.Value == input.status).Any() ? dicstatus.Where(p => p.Value == input.status).First().Key : "";
|
||||
}
|
||||
List<dynamic> result = new();
|
||||
var plans = await _db.Queryable<ToolMoldMaintainPlan>()
|
||||
.WhereIF(!string.IsNullOrEmpty(status), p => p.status == status)
|
||||
.ToListAsync();
|
||||
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();
|
||||
var records = _db.Queryable<ToolMoldMaintainItemRecord>().ToList();
|
||||
var runrecords = _db.Queryable<ToolMoldMaintainRunRecord>().ToList();
|
||||
foreach (var plan in plans)
|
||||
{
|
||||
var planMoldRelations = await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
|
||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
||||
.Where(a => a.maintain_plan_id == plan.id)
|
||||
.Select((a, b, c) => new
|
||||
@@ -139,21 +133,32 @@ namespace Tnb.EquipMgr
|
||||
.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];
|
||||
if (!string.IsNullOrEmpty(input.status))
|
||||
{
|
||||
var moldstatus = records.Where(p => p.mold_id == mold.id && p.plan_id == plan.id).Any() ? "已完成" : "待保养";
|
||||
if (input.status != moldstatus)
|
||||
continue;
|
||||
}
|
||||
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.plan_start_time = plan.plan_start_date == null ? "" : ((DateTime)plan.plan_start_date!).ToString("yyyy-MM-dd");
|
||||
info.createtime = plan.create_time == null ? "" : ((DateTime)plan.create_time).ToString("yyyy-MM-dd");
|
||||
info.status = plan.status == "UnMaintain" ? "待保养" : "已完成";
|
||||
info.status = records.Where(p=>p.mold_id== mold.id&&p.plan_id== plan.id).Any()? "已完成" : "待保养";//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;
|
||||
info.starttime = "";
|
||||
if (runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).Any())
|
||||
{
|
||||
var run = runrecords.Where(p => p.mold_code == mold.mold_code && p.plan_code == plan.plan_code).First();
|
||||
info.starttime = run.plan_start_time!=null? ((DateTime)run.plan_start_time).ToString("yyyy-MM-dd") : "";
|
||||
}
|
||||
var moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault();
|
||||
if (moldEqpRelation != null)
|
||||
{
|
||||
@@ -261,6 +266,14 @@ namespace Tnb.EquipMgr
|
||||
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
var flag= _db.Queryable<ToolMoldMaintainRunRecord>()
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.plan_code == b.plan_code)
|
||||
.LeftJoin<ToolMolds>((a,b,c)=>a.mold_code==c.mold_code)
|
||||
.Where((a,b,c)=>b.id== input.plan_id&&c.id==input.mold_id).Any();
|
||||
if (flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
@@ -286,7 +299,7 @@ namespace Tnb.EquipMgr
|
||||
record.designer_time = DateTime.Now;
|
||||
record.mold_code = mold.mold_code;
|
||||
record.mold_name = mold.mold_name;
|
||||
record.plan_start_time = DateTime.Now;
|
||||
record.plan_start_time = string.IsNullOrEmpty(input.starttime) ? DateTime.Now :DateTime.Parse(input.starttime);
|
||||
var row = await _db.Insertable(record).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
|
||||
@@ -350,6 +363,37 @@ namespace Tnb.EquipMgr
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模具保养完成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task FinishMaintain(MoldMaintainRunUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.items == null || input.items.Count == 0) throw new ArgumentException($"parameter {nameof(input.items)} not be null or empty");
|
||||
List<ToolMoldMaintainItemRecord> records = new();
|
||||
foreach (var item in input.items)
|
||||
{
|
||||
ToolMoldMaintainItemRecord record = new();
|
||||
record.plan_id = input.plan_id;
|
||||
record.mold_id = input.mold_id;
|
||||
record.item_group_id = item.item_group_id;
|
||||
record.item_id = item.item_id;
|
||||
record.status = 1;
|
||||
record.result = item.result;
|
||||
records.Add(record);
|
||||
}
|
||||
await _db.Insertable(records).ExecuteCommandAsync();
|
||||
await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
|
||||
var count = await _db.Queryable<ToolMoldMaintainPlanRelation>().Where(p => p.maintain_plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
|
||||
var finish = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(p => p.plan_id == input.plan_id).Select(p => p.mold_id).Distinct().CountAsync();
|
||||
if (count == finish)
|
||||
await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task MaintainItemFinish(MoldMaintainRunUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
|
||||
Reference in New Issue
Block a user