模具保养执行业务代码调整
This commit is contained in:
@@ -11,6 +11,10 @@ namespace Tnb.EquipMgr.Entities.Consts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模具使用状态在库状态ID
|
/// 模具使用状态在库状态ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MOLDUSESTATUSZKID = "26149307089941";
|
public const string MOLD_USE_STATUS_ZK_ID = "26149307089941";
|
||||||
|
/// <summary>
|
||||||
|
/// 模具使用状态-保养Id
|
||||||
|
/// </summary>
|
||||||
|
public const string MOLD_USE_STATUS_MAINTAIN_ID = "26149311082005";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ public partial class ToolMoldMaintainItem : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保养项完成状态 0,未完成,1,已完成
|
/// 保养项完成状态 0,未完成,1,已完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? status { get; set; }
|
public int status { get; set; } = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 模具id
|
||||||
|
/// </summary>
|
||||||
|
public string mold_id { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模具保养
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("tool_mold_maintain_item_record")]
|
||||||
|
public partial class ToolMoldMaintainItemRecord : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public ToolMoldMaintainItemRecord()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 保养项 保养状态 0 未完成,1 已完成
|
||||||
|
/// </summary>
|
||||||
|
public int status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养组Id
|
||||||
|
/// </summary>
|
||||||
|
public string? item_group_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养组名称
|
||||||
|
/// </summary>
|
||||||
|
public string? item_group_name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养项Id
|
||||||
|
/// </summary>
|
||||||
|
public string? item_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养项名称
|
||||||
|
/// </summary>
|
||||||
|
public string? item_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 模具ID
|
||||||
|
/// </summary>
|
||||||
|
public string mold_id { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -59,26 +59,6 @@ public partial class ToolMoldMaintainRunRecord : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? eqp_name { get; set; }
|
public string? eqp_name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保养组编码
|
|
||||||
/// </summary>
|
|
||||||
public string? group_code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保养组名称
|
|
||||||
/// </summary>
|
|
||||||
public string? group_name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保养项编号
|
|
||||||
/// </summary>
|
|
||||||
public string? check_item_code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保养项名称
|
|
||||||
/// </summary>
|
|
||||||
public string? check_item_name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计划开始时间
|
/// 计划开始时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -94,4 +74,14 @@ public partial class ToolMoldMaintainRunRecord : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? plan_time { get; set; }
|
public decimal? plan_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 维保人
|
||||||
|
/// </summary>
|
||||||
|
public string? maintain_person { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异常记录
|
||||||
|
/// </summary>
|
||||||
|
public string? exception_record { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using JNPF.Common.Contracts;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模具保养计划记录表子表
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("tool_mold_maintain_run_record_d")]
|
||||||
|
public partial class ToolMoldMaintainRunRecordD : BaseEntity<string>
|
||||||
|
{
|
||||||
|
public ToolMoldMaintainRunRecordD()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 模具编号
|
||||||
|
/// </summary>
|
||||||
|
public string? mold_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养组编码
|
||||||
|
/// </summary>
|
||||||
|
public string? group_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养组名称
|
||||||
|
/// </summary>
|
||||||
|
public string? group_name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养项编号
|
||||||
|
/// </summary>
|
||||||
|
public string? check_item_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保养项名称
|
||||||
|
/// </summary>
|
||||||
|
public string? check_item_name { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -133,5 +133,9 @@ public partial class ToolMolds : BaseEntity<string>
|
|||||||
/// 模具型号
|
/// 模具型号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? mold_type_code { get; set; }
|
public string? mold_type_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 关联保养项信息
|
||||||
|
/// </summary>
|
||||||
|
public string item_json { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ using JNPF.Common.Contracts;
|
|||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
using Tnb.EquipMgr.Entities.Dto;
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
using Tnb.EquipMgr.Interfaces;
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
using Senparc.Weixin.MP.AdvancedAPIs.GroupMessage;
|
||||||
|
using Aop.Api.Domain;
|
||||||
|
|
||||||
namespace Tnb.EquipMgr
|
namespace Tnb.EquipMgr
|
||||||
{
|
{
|
||||||
@@ -79,8 +81,60 @@ namespace Tnb.EquipMgr
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input) =>
|
public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input)
|
||||||
await Relevance<MoldMaintainGroupItemInput, ToolMoldMaintainGroupItem>(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id);
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
if (input.ids == null || input.ids.Count == 0) throw new ArgumentException($"parameter {nameof(input.ids)} not be null or count not be zero");
|
||||||
|
await Relevance<MoldMaintainGroupItemInput, ToolMoldMaintainGroupItem>(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id);
|
||||||
|
List<ToolMoldMaintainItemRecord> itemRecords = new();
|
||||||
|
var grpIds = await _db.Queryable<ToolMoldMaintainGroupItem>().Where(it => input.ids.Contains(it.item_id)).Select(it => it.item_group_id).Distinct().ToListAsync();
|
||||||
|
if (grpIds?.Count > 0)
|
||||||
|
{
|
||||||
|
var grps = await _db.Queryable<ToolMoldMaintainGroup>().Where(it => grpIds.Contains(it.id)).ToListAsync();
|
||||||
|
foreach (var grp in grps)
|
||||||
|
{
|
||||||
|
var molds = await _db.Queryable<ToolMoldMaintainGroupRelation>().Where(it => it.item_group_id == grp.id).ToListAsync();
|
||||||
|
if (molds?.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var mold in molds)
|
||||||
|
{
|
||||||
|
var dbItIds = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.mold_id == mold.id && it.item_group_id == grp.id && input.ids.Contains(it.id)).Select(it => it.item_id).ToListAsync();
|
||||||
|
input.ids = input.ids.Except(dbItIds).ToList();
|
||||||
|
if (input.ids?.Count > 0)
|
||||||
|
{
|
||||||
|
var items = await _db.Queryable<ToolMoldMaintainItem>().Where(it => input.ids.Contains(it.id)).ToListAsync();
|
||||||
|
if (items?.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
ToolMoldMaintainItemRecord record = new();
|
||||||
|
record.mold_id = mold.id;
|
||||||
|
record.item_group_id = grp.id;
|
||||||
|
record.item_group_name = grp.name;
|
||||||
|
record.item_id = item.id;
|
||||||
|
record.item_name = item.name;
|
||||||
|
record.status = 0;
|
||||||
|
itemRecords.Add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _db.Insertable(itemRecords).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联项目组与模具
|
/// 关联项目组与模具
|
||||||
@@ -88,8 +142,45 @@ namespace Tnb.EquipMgr
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input) =>
|
public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input)
|
||||||
|
{
|
||||||
await Relevance<MoldMaintainGroupItemRelationInput, ToolMoldMaintainGroupRelation>(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.id);
|
await Relevance<MoldMaintainGroupItemRelationInput, ToolMoldMaintainGroupRelation>(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.id);
|
||||||
|
List<ToolMoldMaintainItemRecord> itemRecords = new();
|
||||||
|
foreach (var moldId in input.ids)
|
||||||
|
{
|
||||||
|
var grpIds = await _db.Queryable<ToolMoldMaintainGroupRelation>().Where(it => it.mold_id == moldId).Select(it => it.item_group_id).Distinct().ToListAsync();
|
||||||
|
if (grpIds?.Count > 0)
|
||||||
|
{
|
||||||
|
var grps = await _db.Queryable<ToolMoldMaintainGroup>().Where(it => grpIds.Contains(it.id)).ToListAsync();
|
||||||
|
foreach (var grp in grps)
|
||||||
|
{
|
||||||
|
var itemIds = await _db.Queryable<ToolMoldMaintainGroupItem>().Where(it => it.item_group_id == grp.id).Select(it => it.item_id).ToListAsync();
|
||||||
|
if (itemIds?.Count > 0)
|
||||||
|
{
|
||||||
|
var dbItemIds = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.mold_id == moldId && it.item_group_id == grp.id && itemIds.Contains(it.item_id)).Select(it => it.item_id).ToListAsync();
|
||||||
|
itemIds = itemIds.Except(dbItemIds).ToList();
|
||||||
|
if (itemIds?.Count > 0)
|
||||||
|
{
|
||||||
|
var items = await _db.Queryable<ToolMoldMaintainItem>().Where(it => itemIds.Contains(it.id)).ToListAsync();
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
ToolMoldMaintainItemRecord record = new();
|
||||||
|
record.mold_id = moldId;
|
||||||
|
record.item_group_id = grp.id;
|
||||||
|
record.item_group_name = grp.name;
|
||||||
|
record.item_id = item.id;
|
||||||
|
record.item_name = item.name;
|
||||||
|
record.status = 0;
|
||||||
|
itemRecords.Add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _db.Insertable(itemRecords).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除项目组与模具检查项信息
|
/// 删除项目组与模具检查项信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -98,14 +189,15 @@ namespace Tnb.EquipMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task Delete(MoldMaintainDelInput input)
|
public async Task Delete(MoldMaintainDelInput input)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (input.table_name == "item")
|
if (input.table_name == "item")
|
||||||
{
|
{
|
||||||
await Delete<ToolMoldMaintainGroupItem>(it => it.item_group_id == input.id && input.ids.Contains(it.item_id));
|
await Delete<ToolMoldMaintainGroupItem>(it => it.item_group_id == input.id && input.ids.Contains(it.item_id));
|
||||||
|
await Delete<ToolMoldMaintainItemRecord>(it => it.item_group_id == input.id && input.ids.Contains(it.item_id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await Delete<ToolMoldMaintainGroupRelation>(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id));
|
await Delete<ToolMoldMaintainGroupRelation>(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id));
|
||||||
|
await Delete<ToolMoldMaintainItemRecord>(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
|
using DingTalk.Api.Request;
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
@@ -14,6 +15,7 @@ using JNPF.FriendlyException;
|
|||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using StackExchange.Profiling.Internal;
|
using StackExchange.Profiling.Internal;
|
||||||
using Tnb.BasicData;
|
using Tnb.BasicData;
|
||||||
@@ -51,8 +53,8 @@ namespace Tnb.EquipMgr
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
||||||
{
|
{
|
||||||
dynamic info = new ExpandoObject();
|
List<dynamic> result = new();
|
||||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
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)//ToolMoldMaintainPlan
|
||||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
||||||
.Where(a => a.maintain_plan_id == planId)
|
.Where(a => a.maintain_plan_id == planId)
|
||||||
@@ -61,27 +63,35 @@ namespace Tnb.EquipMgr
|
|||||||
mold_id = a.mold_id,
|
mold_id = a.mold_id,
|
||||||
plan_start_time = c.plan_start_time,
|
plan_start_time = c.plan_start_time,
|
||||||
})
|
})
|
||||||
.FirstAsync();
|
.ToListAsync();
|
||||||
if (planMoldRelation != null)
|
if (planMoldRelations?.Count > 0)
|
||||||
{
|
{
|
||||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == planMoldRelation.mold_id);
|
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||||
if (mold != null)
|
var molds = await _db.Queryable<ToolMolds>().Where(it => mids.Contains(it.id)).ToListAsync();
|
||||||
|
if (molds?.Count > 0)
|
||||||
{
|
{
|
||||||
info.mold_code = mold.mold_code;
|
for (int i = 0, cnt = molds.Count; i < cnt; i++)
|
||||||
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;
|
|
||||||
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);
|
var mold = molds[i];
|
||||||
info.eqp_code = eqp.code;
|
dynamic info = new ExpandoObject();
|
||||||
info.eqp_name = eqp.name;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return result;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据模具ID获取,保养组及项目信息
|
/// 根据模具ID获取,保养组及项目信息
|
||||||
@@ -92,23 +102,32 @@ namespace Tnb.EquipMgr
|
|||||||
public async Task<dynamic> GetCheckItemAndGrpByMoldId([FromRoute] string moldId)
|
public async Task<dynamic> GetCheckItemAndGrpByMoldId([FromRoute] string moldId)
|
||||||
{
|
{
|
||||||
if (moldId.IsNullOrEmpty()) throw new ArgumentException($"parameter {nameof(moldId)} not be null or empty");
|
if (moldId.IsNullOrEmpty()) throw new ArgumentException($"parameter {nameof(moldId)} not be null or empty");
|
||||||
|
|
||||||
var itemGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == moldId);
|
|
||||||
if (itemGroupRelation != null)
|
|
||||||
{
|
{
|
||||||
var checkItems = await _db.Queryable<ToolMoldMaintainGroup, ToolMoldMaintainGroupItem, ToolMoldMaintainItem>((a, b, c) => new JoinQueryInfos
|
|
||||||
(
|
var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.mold_id == moldId).Select(it => new
|
||||||
JoinType.Left, a.id == b.item_group_id,
|
{
|
||||||
JoinType.Left, b.item_id == c.id
|
item_group_id = it.item_group_id,
|
||||||
))
|
item_group_name = it.item_group_name,
|
||||||
.Where(a => a.id == itemGroupRelation.item_group_id)
|
item_id = it.item_id,
|
||||||
.Select((a, b, c) => new
|
item_name = it.item_name,
|
||||||
{
|
status = it.status,
|
||||||
item_group_id = a.id,
|
}).ToListAsync();
|
||||||
item_group_name = a.name,
|
|
||||||
item_id = c.id,
|
//var checkItems = await _db.Queryable<ToolMoldMaintainGroupRelation, ToolMoldMaintainGroup, ToolMoldMaintainGroupItem, ToolMoldMaintainItem>((a, b, c, d) => new JoinQueryInfos
|
||||||
item_name = c.name,
|
// (
|
||||||
}).ToListAsync();
|
// JoinType.Inner, a.item_group_id == b.id,
|
||||||
|
// JoinType.Inner, b.id == c.item_group_id,
|
||||||
|
// JoinType.Inner, c.item_id == d.id
|
||||||
|
// ))
|
||||||
|
// .Where(a => a.mold_id == moldId)
|
||||||
|
// .Select((a, b, c, d) => new
|
||||||
|
// {
|
||||||
|
// item_group_id = b.id,
|
||||||
|
// item_group_name = b.name,
|
||||||
|
// item_id = d.id,
|
||||||
|
// item_name = d.name,
|
||||||
|
// status = d.status,
|
||||||
|
// }).ToListAsync();
|
||||||
return checkItems;
|
return checkItems;
|
||||||
}
|
}
|
||||||
return Enumerable.Empty<dynamic>();
|
return Enumerable.Empty<dynamic>();
|
||||||
@@ -127,48 +146,67 @@ namespace Tnb.EquipMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
||||||
{
|
{
|
||||||
|
if (input == null) throw new ArgumentNullException("input");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
|
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
|
||||||
var plan = await _db.Queryable<ToolMoldMaintainPlan>().FirstAsync(it => it.id == input.plan_id);
|
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == input.mold_id);
|
||||||
if (plan != null)
|
if (mold != null)
|
||||||
{
|
{
|
||||||
plan.status = DictConst.MoldMaintainStatusDBYCode;
|
mold.mold_status = MoldUseStatus.MOLD_USE_STATUS_MAINTAIN_ID;
|
||||||
var row = await _db.Updateable(plan).ExecuteCommandAsync();
|
var isOk = await _db.Updateable<ToolMolds>(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync();
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
ToolMoldMaintainRunRecord record = new();
|
var plan = await _db.Queryable<ToolMoldMaintainPlanRelation>().LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
|
||||||
record.plan_code = plan.plan_code;
|
.Where(a => a.mold_id == input.mold_id).Select((a, b) => b).FirstAsync();
|
||||||
record.mode = plan.mode;
|
|
||||||
record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "";
|
if (plan is not null)
|
||||||
record.designer = _userManager.RealName;
|
|
||||||
record.designer_time = DateTime.Now;
|
|
||||||
var moldPlanRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.maintain_plan_id == input.plan_id);
|
|
||||||
if (moldPlanRelation != null)
|
|
||||||
{
|
{
|
||||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == moldPlanRelation.mold_id);
|
//插入保养计划记录
|
||||||
record.mold_code = mold?.mold_code;
|
ToolMoldMaintainRunRecord record = new();
|
||||||
record.mold_name = mold?.mold_name;
|
record.plan_code = plan.plan_code;
|
||||||
var moldGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
record.mode = plan.mode;
|
||||||
if (moldGroupRelation != null)
|
record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "";
|
||||||
{
|
record.designer = _userManager.RealName;
|
||||||
var maintainGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == moldGroupRelation.item_group_id);
|
record.designer_time = DateTime.Now;
|
||||||
record.group_name = maintainGroup.name;
|
record.mold_code = mold.mold_code;
|
||||||
var itemGrpRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == maintainGroup.id);
|
record.mold_name = mold.mold_name;
|
||||||
if (itemGrpRelation != null)
|
record.plan_start_time = DateTime.Now;
|
||||||
|
var row = await _db.Insertable(record).ExecuteCommandAsync();
|
||||||
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
|
||||||
|
var maintainInfos = await _db.Queryable<ToolMoldMaintainGroupRelation>()
|
||||||
|
.LeftJoin<ToolMoldMaintainGroup>((a, b) => a.item_group_id == b.id)
|
||||||
|
.LeftJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.id == c.item_group_id)
|
||||||
|
.LeftJoin<ToolMoldMaintainItem>((a, b, c, d) => c.item_id == d.id)
|
||||||
|
.Where(a => a.mold_id == input.mold_id)
|
||||||
|
.Select((a, b, c, d) => new
|
||||||
{
|
{
|
||||||
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemGrpRelation.item_id);
|
group_id = b.id,
|
||||||
record.check_item_name = checkItem.name;
|
group_name = b.name,
|
||||||
|
check_item_id = d.id,
|
||||||
|
check_item_name = d.name
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (maintainInfos?.Count > 0)
|
||||||
|
{
|
||||||
|
List<ToolMoldMaintainRunRecordD> recordDs = new();
|
||||||
|
foreach (var info in maintainInfos)
|
||||||
|
{
|
||||||
|
ToolMoldMaintainRunRecordD record_d = new();
|
||||||
|
record_d.group_id = info.group_id;
|
||||||
|
record_d.group_name = info.group_name;
|
||||||
|
record_d.check_item_id = info.check_item_id;
|
||||||
|
record_d.check_item_name = info.check_item_name;
|
||||||
|
recordDs.Add(record_d);
|
||||||
}
|
}
|
||||||
|
row = await _db.Insertable(recordDs).ExecuteCommandAsync();
|
||||||
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
record.plan_start_time = DateTime.Now;
|
|
||||||
row = await _db.Insertable(record).ExecuteCommandAsync();
|
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
|
||||||
}
|
}
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -183,9 +221,10 @@ namespace Tnb.EquipMgr
|
|||||||
{
|
{
|
||||||
if (input == null) throw new ArgumentNullException("input");
|
if (input == null) throw new ArgumentNullException("input");
|
||||||
if (input.itemIds == null || input.itemIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.itemIds)} not be null or empty");
|
if (input.itemIds == null || input.itemIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.itemIds)} not be null or empty");
|
||||||
var row = await _db.Updateable<ToolMoldMaintainItem>().SetColumns(it => new ToolMoldMaintainItem { status = input.status }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync();
|
var row = await _db.Updateable<ToolMoldMaintainItemRecord>().SetColumns(it => new ToolMoldMaintainItemRecord { status = 1 }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模具保养计划执行-保养完成
|
/// 模具保养计划执行-保养完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -204,18 +243,18 @@ namespace Tnb.EquipMgr
|
|||||||
var itemIds = await _db.Queryable<ToolMoldMaintainGroupItem>().Where(it => grpIds.Contains(it.item_group_id)).Select(it => it.item_id).ToListAsync();
|
var itemIds = await _db.Queryable<ToolMoldMaintainGroupItem>().Where(it => grpIds.Contains(it.item_group_id)).Select(it => it.item_id).ToListAsync();
|
||||||
if (itemIds?.Count > 0)
|
if (itemIds?.Count > 0)
|
||||||
{
|
{
|
||||||
var items = await _db.Queryable<ToolMoldMaintainItem>().Where(it => itemIds.Contains(it.id) && it.status.HasValue && it.status.Value == 1).ToListAsync();
|
var items = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.mold_id == input.mold_id && it.status == 1).ToListAsync();
|
||||||
if (items?.Count < itemIds.Count)
|
if (items?.Count < itemIds.Count)
|
||||||
{
|
{
|
||||||
throw new AppFriendlyException("当前模具有未完成的保养项目", 500);
|
throw new AppFriendlyException("当前模具有未完成的保养项目", 500);
|
||||||
}
|
}
|
||||||
var row = await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLDUSESTATUSZKID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
|
var row = await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLD_USE_STATUS_ZK_ID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
var allMoldStatus = await _db.Queryable<ToolMoldMaintainPlanRelation>().InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
var allMoldStatus = await _db.Queryable<ToolMoldMaintainPlanRelation>().InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||||
.Where((a, b) => a.maintain_plan_id == input.plan_id)
|
.Where((a, b) => a.maintain_plan_id == input.plan_id)
|
||||||
.Select((a, b) => b.mold_status)
|
.Select((a, b) => b.mold_status)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (allMoldStatus?.Count > 0 && allMoldStatus.All(x => x == MoldUseStatus.MOLDUSESTATUSZKID))
|
if (allMoldStatus?.Count > 0 && allMoldStatus.All(x => x == MoldUseStatus.MOLD_USE_STATUS_ZK_ID))
|
||||||
{
|
{
|
||||||
row = await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
|
row = await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user