This commit is contained in:
DEVICE8\12494
2023-05-29 12:07:48 +08:00
parent 43d080690e
commit cf7c43230d
7 changed files with 147 additions and 24 deletions

View File

@@ -90,10 +90,6 @@ public static class DictConst
/// 模具保养状态-待保养编码
/// </summary>
public const string MoldMaintainStatusDBYCode = "UnMaintain";
/// <summary>
/// 模具保养状态TypeId
/// </summary>
public const string MoldMaintainStatusTypeId = "26171564065301";
@@ -114,6 +110,10 @@ public static class DictConst
/// </summary>
public const string MaintainStatusTypeId = "26171564065301";
/// <summary>
/// 模具保养状态TypeId
/// </summary>
public const string MoldMaintainStatusTypeId = "26149299883285";
/// <summary>
/// 保养状态待保养Code
/// </summary>
public const string UnMaintainStatusCode = "UnMaintain";

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.EquipMgr.Entities.Dto
{
/// <summary>
/// 模具保养计划执行查询输出参数
/// </summary>
public class MoldMaintainPlanRunQueryOutput
{
/// <summary>
/// 保养开始时间
/// </summary>
public string? start_time { get; set; }
/// <summary>
/// 模具编码
/// </summary>
public string mold_code { get; set; }
/// <summary>
/// 模具名称
/// </summary>
public string mold_name { get; set; }
/// <summary>
/// 保养完成打磨次
/// </summary>
public int? maintain_qty { get; set; }
/// <summary>
/// 模具状态
/// </summary>
public string mold_status { get; set; }
/// <summary>
/// 设备编码
/// </summary>
public string eqp_code { get; set; }
/// <summary>
/// 设备名称
/// </summary>
public string eqp_name { get; set; }
/// <summary>
/// 保养人
/// </summary>
public string operator_name { get; set; }
/// <summary>
/// 保养项信息
/// </summary>
public List<CheckItemInfo> check_items { get; set; }
}
public class CheckItemInfo
{
/// <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; }
}
}

View File

@@ -15,5 +15,13 @@ namespace Tnb.EquipMgr.Entities.Dto
/// 执行计划id
/// </summary>
public string plan_id { get; set; }
/// <summary>
/// 保养项Ids
/// </summary>
public List<string>itemIds { get; set; }
/// <summary>
/// 保养项状态 0未完成 1已完成
/// </summary>
public int? status { get; set; }
}
}

View File

@@ -63,5 +63,9 @@ public partial class ToolMoldMaintainItem : BaseEntity<string>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 保养项完成状态 0未完成1,已完成
/// </summary>
public int? status { get; set; }
}

View File

@@ -142,7 +142,7 @@ namespace Tnb.EquipMgr
var maintainRules = await _db.Queryable<ToolMoldMaintainRule>().Where(it => input.ruleIds.Contains(it.id)).ToListAsync();
var ruleMoldRelations = await _db.Queryable<ToolMoldMaintainRuleRelation>().Where(it=>input.ruleIds.Contains(it.rule_id)).ToListAsync();
if (maintainRules?.Count > 0)
if (ruleMoldRelations?.Count > 0)
{
List<ToolMoldMaintainPlan> maintainPlans = new();
List<ToolMoldMaintainPlanRelation> maintainPlanRelations = new();

View File

@@ -21,6 +21,9 @@ using Tnb.EquipMgr.Interfaces;
namespace Tnb.EquipMgr
{
/// <summary>
/// 模具维修任务执行
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
@@ -55,6 +58,8 @@ namespace Tnb.EquipMgr
{
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;
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
if (moldEqpRelation != null)
{
@@ -65,19 +70,22 @@ namespace Tnb.EquipMgr
var itemGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
if (itemGroupRelation != null)
{
var itemGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == itemGroupRelation.item_group_id);
if (itemGroup != null)
var checkItems = await _db.Queryable<ToolMoldMaintainGroup, ToolMoldMaintainGroupItem, ToolMoldMaintainItem>((a, b, c) => new JoinQueryInfos
(
JoinType.Left, a.id == b.item_group_id,
JoinType.Left, b.item_id == c.id
))
.Where(a => a.id == itemGroupRelation.item_group_id)
.Select((a, b, c) => new
{
item_group_id = a.id,
item_group_name = a.name,
item_id = c.id,
item_name = c.name,
}).ToListAsync();
if (checkItems?.Count > 0)
{
info.item_group_name = itemGroup.name;
}
var itemRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == itemGroupRelation.item_group_id);
if (itemRelation != null)
{
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemRelation.item_id);
if (checkItem != null)
{
info.item_name = checkItem.name;
}
info.check_items = checkItems;
}
}
}
@@ -148,6 +156,14 @@ namespace Tnb.EquipMgr
}
}
public async Task MaintainItemFinish(MoldMaintainRunUpInput 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");
var row = await _db.Updateable<ToolMoldMaintainItem>().SetColumns(it => new ToolMoldMaintainItem { status = input.status }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
}
/// <summary>
/// 模具保养计划执行-保养完成
/// </summary>
@@ -156,7 +172,9 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task MaintainFinish(MoldMaintainRunUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
}
}
}

View File

@@ -804,8 +804,8 @@ namespace Tnb.ProductionMgr
{
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
}
var taskList = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
if (taskList?.Count > 0)
//var taskList = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
//if (taskList?.Count > 0)
{
string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
{
@@ -912,7 +912,10 @@ namespace Tnb.ProductionMgr
}
}
}
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
if (taskLogEntities?.Count > 0)
{
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
}
List<PrdReportRecord> prdReportLogs = new();
List<PrdMoTaskDefectRecord> prdTaskDefectLogs = new();
@@ -924,6 +927,7 @@ namespace Tnb.ProductionMgr
var material = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == taskInfo.material_id));
var mo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == taskInfo.mo_id);
var record = taskInfo.Adapt<PrdReportRecord>();
record.id = SnowflakeIdHelper.NextId();
record.masterial_code = material?.code;
record.masterial_name = material?.name;
record.plan_start_date = taskInfo.estimated_start_date;
@@ -938,6 +942,7 @@ namespace Tnb.ProductionMgr
//组装自检报废对象
var sacipRecord = new PrdMoTaskDefectRecord();
sacipRecord.id = SnowflakeIdHelper.NextId();
sacipRecord.material_code = material?.code!;
sacipRecord.material_name = material?.name!;
sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskInfo.eqp_id))?.code!;
@@ -956,12 +961,28 @@ namespace Tnb.ProductionMgr
prdTaskDefectLogs.Add(sacipRecord);
}
}
row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
var reportTaskIds = prdReportLogs.Select(it => it.mo_task_id).ToList();
if (reportTaskIds?.Count > 0)
{
var items = await db.Queryable<PrdReportRecord>().Where(it => reportTaskIds.Contains(it.mo_task_id)).ToListAsync();
if (items == null || items.Count < 1)
{
row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
}
}
var defectTaskIds = prdTaskDefectLogs.Select(it => it.mo_task_id).ToList();
if (defectTaskIds?.Count > 0)
{
var items = await db.Queryable<PrdMoTaskDefectRecord>().Where(it => defectTaskIds.Contains(it.mo_task_id)).ToListAsync();
if (items == null || items.Count < 1)
{
row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
}
}
}
}
else
throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
//else
// throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
return (row > 0);
}