Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -72,6 +72,10 @@ public static class DictConst
|
||||
/// </summary>
|
||||
public const string ToBeScheduledEncode = "ToBeScheduled";
|
||||
/// <summary>
|
||||
/// 任务单状态码-暂停
|
||||
/// </summary>
|
||||
public const string MoStatusPauseCode = "Pause";
|
||||
/// <summary>
|
||||
/// 模具维修状态码-待维修
|
||||
/// </summary>
|
||||
public const string MaintainStatusDWXCode = "DWX";
|
||||
@@ -79,6 +83,14 @@ public static class DictConst
|
||||
/// 模具维修状态码-已完成
|
||||
/// </summary>
|
||||
public const string MaintainStatusYWCCode = "YWC";
|
||||
/// <summary>
|
||||
/// 模具保养状态-待保养编码
|
||||
/// </summary>
|
||||
public const string MoldMaintainStatusDBYCode = "UnMaintain";
|
||||
/// <summary>
|
||||
/// 模具保养状态TypeId
|
||||
/// </summary>
|
||||
public const string MoldMaintainStatusTypeId = "26171564065301";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 规则id
|
||||
/// </summary>
|
||||
public string rule_id { get; set; }
|
||||
public List<string> ruleIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
19
EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
Normal file
19
EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
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 MoldMaintainRunUpInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行计划id
|
||||
/// </summary>
|
||||
public string plan_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 保养计划与模具关联表
|
||||
/// </summary>
|
||||
[SugarTable("tool_mold_maintain_plan_relation")]
|
||||
public partial class ToolMoldMaintainPlanRelation : BaseEntity<string>
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarTable("tool_mold_maintain_run_record")]
|
||||
public partial class ToolMoldMaintainRunRecord : BaseEntity<string>
|
||||
{
|
||||
public ToolMoldMaintainRunRecord()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 计划单号
|
||||
/// </summary>
|
||||
public string? plan_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养方式
|
||||
/// </summary>
|
||||
public string? mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划状态
|
||||
/// </summary>
|
||||
public string? plan_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制定人
|
||||
/// </summary>
|
||||
public string? designer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制定时间
|
||||
/// </summary>
|
||||
public DateTime? designer_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
public string? mold_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string? mold_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string? eqp_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
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>
|
||||
public DateTime? plan_start_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划完成时间
|
||||
/// </summary>
|
||||
public DateTime? plan_end_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划时间
|
||||
/// </summary>
|
||||
public decimal? plan_time { get; set; }
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,6 +13,7 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
@@ -32,10 +34,13 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager)
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据规则Id获取匹配的模具列表
|
||||
@@ -78,6 +83,111 @@ namespace Tnb.EquipMgr
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.id == planId);
|
||||
if (planMoldRelation != null)
|
||||
{
|
||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == planMoldRelation.mold_id);
|
||||
if (mold != null)
|
||||
{
|
||||
info.mold_code = mold.mold_code;
|
||||
info.mold_name = mold.mold_name;
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模具保养计划执行-开始模具保养
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
/// {
|
||||
/// plan_id:执行计划id
|
||||
/// }
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
|
||||
var plan = await _db.Queryable<ToolMoldMaintainPlan>().FirstAsync(it => it.id == input.plan_id);
|
||||
if (plan != null)
|
||||
{
|
||||
plan.status = DictConst.MoldMaintainStatusDBYCode;
|
||||
var row = await _db.Updateable(plan).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
ToolMoldMaintainRunRecord record = new();
|
||||
record.plan_code = plan.plan_code;
|
||||
record.mode = plan.mode;
|
||||
record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "";
|
||||
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;
|
||||
record.mold_name = mold?.mold_name;
|
||||
var moldGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
||||
if (moldGroupRelation != null)
|
||||
{
|
||||
var maintainGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == moldGroupRelation.item_group_id);
|
||||
record.group_name = maintainGroup.name;
|
||||
var itemGrpRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == maintainGroup.id);
|
||||
if (itemGrpRelation != null)
|
||||
{
|
||||
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemGrpRelation.item_id);
|
||||
record.check_item_name = checkItem.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
record.plan_start_time = DateTime.Now;
|
||||
row = await _db.Insertable(record).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("开始模具保养失败", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关联模具
|
||||
@@ -89,6 +199,7 @@ namespace Tnb.EquipMgr
|
||||
public async Task RelevanceMold(RelevanceMoldInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
await _db.Deleteable<ToolMoldMaintainRuleRelation>().Where(it => it.rule_id == input.rule_id).ExecuteCommandAsync();
|
||||
if (input.rowIds?.Count > 0)
|
||||
{
|
||||
List<ToolMoldMaintainRuleRelation> entities = new();
|
||||
@@ -133,30 +244,34 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var maintainRule = await _db.Queryable<ToolMoldMaintainRule>().FirstAsync(it => it.id == input.rule_id);
|
||||
if (maintainRule is not null)
|
||||
var maintainRules = await _db.Queryable<ToolMoldMaintainRule>().Where(it => input.ruleIds.Contains(it.id)).ToListAsync();
|
||||
if (maintainRules?.Count > 0)
|
||||
{
|
||||
if (maintainRule.cycle.HasValue && maintainRule.cycle.Value > 0)
|
||||
List<ToolMoldMaintainPlan> maintainPlans = new();
|
||||
List<ToolMoldMaintainPlanRelation> maintainPlanRelations = new();
|
||||
foreach (var maintainRule in maintainRules)
|
||||
{
|
||||
ToolMoldMaintainPlan maintainPlan = new();
|
||||
maintainPlan.plan_code = $"JHDM{DateTime.Now:yyyyMMddmmss}";
|
||||
maintainPlan.mode = maintainRule.mode;
|
||||
maintainPlan.status = DictConst.UnMaintainStatusCode;
|
||||
maintainPlan.plan_start_date = DateTime.Now;
|
||||
maintainPlan.plan_end_date = DateTime.Now.AddDays(maintainRule.cycle.Value);
|
||||
maintainPlan.create_id = _userManager.UserId;
|
||||
maintainPlan.create_time = DateTime.Now;
|
||||
if (maintainRule.cycle.HasValue && maintainRule.cycle.Value > 0)
|
||||
{
|
||||
ToolMoldMaintainPlan maintainPlan = new();
|
||||
maintainPlan.plan_code = $"JHDM{DateTime.Now:yyyyMMddmmss}";
|
||||
maintainPlan.mode = maintainRule.mode;
|
||||
maintainPlan.status = DictConst.UnMaintainStatusCode;
|
||||
maintainPlan.plan_start_date = DateTime.Now;
|
||||
maintainPlan.plan_end_date = DateTime.Now.AddDays(maintainRule.cycle.Value);
|
||||
maintainPlan.create_id = _userManager.UserId;
|
||||
maintainPlan.create_time = DateTime.Now;
|
||||
maintainPlans.Add(maintainPlan);
|
||||
|
||||
await _db.Insertable(maintainPlan).ExecuteCommandAsync();
|
||||
|
||||
ToolMoldMaintainPlanRelation maintainPlanReation = new();
|
||||
maintainPlanReation.maintain_plan_id = maintainPlan.id;
|
||||
maintainPlanReation.mold_id = (await _db.Queryable<ToolMoldMaintainRuleRelation>().FirstAsync(it => it.rule_id == maintainRule.id))?.mold_id!;
|
||||
|
||||
await _db.Insertable(maintainPlanReation).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
ToolMoldMaintainPlanRelation maintainPlanReation = new();
|
||||
maintainPlanReation.maintain_plan_id = maintainPlan.id;
|
||||
maintainPlanReation.mold_id = (await _db.Queryable<ToolMoldMaintainRuleRelation>().FirstAsync(it => it.rule_id == maintainRule.id))?.mold_id!;
|
||||
maintainPlanRelations.Add(maintainPlanReation);
|
||||
}
|
||||
}
|
||||
await _db.Insertable(maintainPlans).ExecuteCommandAsync();
|
||||
await _db.Insertable(maintainPlanRelations).ExecuteCommandAsync();
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class ClosedownHistoryOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 停机开始时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_start_time { get; set; }
|
||||
/// <summary>
|
||||
/// 停机结束时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_end_time { get; set; }
|
||||
/// <summary>
|
||||
/// 停机时间
|
||||
/// </summary>
|
||||
public decimal? closedown_time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Filter;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 停机历史查询输入参数
|
||||
/// </summary>
|
||||
public class ClosedownHistoryQuery : PageInputBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
public DateTime? beginTime { get; set; }
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
public DateTime? endTime { get; set; }
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string eqpName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -58,5 +58,19 @@ public partial class PrdCancelClosedownRecord : BaseEntity<string>
|
||||
/// 停机结束时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_end_time { get; set; }
|
||||
/// <summary>
|
||||
/// 停机时间
|
||||
/// </summary>
|
||||
public decimal? closedown_time { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string eqp_name { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -128,6 +129,54 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取停机历史记录
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetClosedownHistory([FromQuery] ClosedownHistoryQuery input)
|
||||
{
|
||||
var pagedList = await _db.Queryable<PrdCancelClosedownRecord>()
|
||||
.WhereIF(!string.IsNullOrEmpty(input.eqpName), it => it.eqp_name.Contains(input.eqpName))
|
||||
.WhereIF(input.beginTime.HasValue, it => it.closedown_start_time.Value == input.beginTime)
|
||||
.WhereIF(input.endTime.HasValue, it => it.closedown_end_time.Value == input.endTime)
|
||||
.Select(it => new ClosedownHistoryOutput
|
||||
{
|
||||
closedown_start_time = it.closedown_start_time,
|
||||
closedown_end_time = it.closedown_end_time,
|
||||
closedown_time = it.closedown_time,
|
||||
})
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return pagedList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据设备id获取生产任务单信息,模具信息
|
||||
/// </summary>
|
||||
/// <param name="eqpId">设备Id</param>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>{
|
||||
/// <br/> mo_task_code:任务单编号
|
||||
/// <br/> mold_code:模具编号
|
||||
/// <br/> mold_name:模具名称
|
||||
/// <br/>}
|
||||
/// </remarks>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetInfoFromEqpId([FromRoute] string eqpId)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
var moTask = await _db.Queryable<PrdMoTask>().Where(it => it.mo_task_status == DictConst.InProgressEnCode).FirstAsync(it => it.eqp_id == eqpId);
|
||||
if (moTask != null)
|
||||
{
|
||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == moTask.mo_id);
|
||||
info.mo_task_code = moTask.mo_task_code;
|
||||
info.mold_code = mold?.mold_code;
|
||||
info.mold_name = mold?.mold_name;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异常停机-开始
|
||||
@@ -145,7 +194,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id);
|
||||
if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500);
|
||||
if (moTaskList.Count > 0)
|
||||
if (moTaskList?.Count > 0)
|
||||
{
|
||||
var cancelCloseDown = input.Adapt<PrdCancelClosedown>();
|
||||
cancelCloseDown.id = SnowflakeIdHelper.NextId();
|
||||
@@ -155,7 +204,10 @@ namespace Tnb.ProductionMgr
|
||||
cancelCloseDown.closedown_start_time = DateTime.Now;
|
||||
|
||||
await _db.Insertable(cancelCloseDown).ExecuteCommandAsync();
|
||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id);
|
||||
var record = cancelCloseDown.Adapt<PrdCancelClosedownRecord>();
|
||||
record.eqp_code = eqp?.code;
|
||||
record.eqp_name = eqp?.name;
|
||||
await _db.Insertable(record).ExecuteCommandAsync();
|
||||
|
||||
var moldId = moTaskList.First().mold_id;
|
||||
@@ -179,13 +231,13 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
Log.Error("停机开始失败", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw ex;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 停机结束
|
||||
/// </summary>
|
||||
/// <param name="maintainTaskId"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task CloseDownEnd(CloseDownStartInput input)
|
||||
@@ -196,46 +248,29 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id);
|
||||
if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500);
|
||||
|
||||
var cancelCloseDown = input.Adapt<PrdCancelClosedown>();
|
||||
cancelCloseDown.id = SnowflakeIdHelper.NextId();
|
||||
cancelCloseDown.create_id = _userManager.UserId;
|
||||
cancelCloseDown.create_time = DateTime.Now;
|
||||
cancelCloseDown.closedown_start_time = DateTime.Now;
|
||||
|
||||
var row = await _db.Insertable(cancelCloseDown).ExecuteCommandAsync();
|
||||
|
||||
var moldId = moTaskList.First().mold_id;
|
||||
if (moldId.IsNullOrEmpty())
|
||||
var closeDown = await _db.Queryable<PrdCancelClosedown>().Where(it => it.eqp_id == input.eqp_id).OrderByDescending(it => it.closedown_start_time).FirstAsync();
|
||||
if (closeDown != null)
|
||||
{
|
||||
var mold = await _moldService.GetListById(moldId);
|
||||
var maintaindTask = new ToolMoldMaintainTask();
|
||||
maintaindTask.mold_id = moldId;
|
||||
maintaindTask.code = DictConst.MaintainStatusYWCCode;
|
||||
maintaindTask.create_id = _userManager.UserId;
|
||||
maintaindTask.create_time = DateTime.Now;
|
||||
closeDown.closedown_end_time = DateTime.Now;
|
||||
await _db.Updateable(closeDown).ExecuteCommandAsync();
|
||||
var record = closeDown.Adapt<PrdCancelClosedownRecord>();
|
||||
//计算停机时间间隔,以小时为单位
|
||||
if (record.closedown_start_time.HasValue && record.closedown_end_time.HasValue)
|
||||
{
|
||||
var interval = record.closedown_end_time.Value.Subtract(record.closedown_start_time.Value).TotalHours;
|
||||
record.closedown_time = Convert.ToDecimal(interval);
|
||||
}
|
||||
await _db.Updateable(record).ExecuteCommandAsync();
|
||||
|
||||
|
||||
await _maintainTaskService.Create(maintaindTask);
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("停机开始失败", ex);
|
||||
Log.Error("停机结束失败", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
//var row = await _db.Updateable<ToolMoldMaintainTask>().SetColumns(c => new ToolMoldMaintainTask
|
||||
//{
|
||||
// status = DictConst.MaintainStatusDWXCode,
|
||||
// modify_id = _userManager.UserId,
|
||||
// modify_end_time = DateTime.Now,
|
||||
//})
|
||||
// .ExecuteCommandAsync();
|
||||
//if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,22 +98,22 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet("{materialId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string materialId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<ToolMolds>().InnerJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.material_id == materialId)
|
||||
.Select((a, b) => new MoldListOutput
|
||||
{
|
||||
mold_id = a.id,
|
||||
mold_code = a.mold_code,
|
||||
mold_name = a.mold_name,
|
||||
mold_type_code = a.mold_type_code,
|
||||
material_name = b.name,
|
||||
material_code = b.code,
|
||||
available_stations = SqlFunc.Subqueryable<EqpEquipment>().Where(it => it.mold_id == a.id).Count(),
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
|
||||
var result = new List<MoldListOutput>();
|
||||
result = await _db.Queryable<ToolMoldsMaterial>()
|
||||
.InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.InnerJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.Where((a, b, c) => a.material_id == materialId)
|
||||
.Select((a, b, c) => new MoldListOutput
|
||||
{
|
||||
mold_id = a.id,
|
||||
mold_code = b.mold_code,
|
||||
mold_name = b.mold_name,
|
||||
mold_type_code = b.mold_type_code,
|
||||
material_name = c.name,
|
||||
material_code = c.code,
|
||||
available_stations = SqlFunc.Subqueryable<EqpEquipment>().Where(it => it.mold_id == a.id).Count(),
|
||||
}).ToListAsync();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据模具Id获取设备列表
|
||||
@@ -123,23 +123,21 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet("{moldId}")]
|
||||
public async Task<dynamic> GetEquipmentListByMoldId(string moldId)
|
||||
{
|
||||
var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
|
||||
.Where(it => it.mold_id == moldId)
|
||||
.Select(it => new EquipmentListOutput
|
||||
{
|
||||
eqp_id = it.id,
|
||||
eqp_code = it.code,
|
||||
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(iit => iit.id == it.equip_type_id).Select(iit => iit.code),
|
||||
eqp_machine_num = it.eqp_machine_num,
|
||||
tonnage = it.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).Count(),
|
||||
estimated_end_date = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).OrderByDesc(o => o.plan_end_date).Select(x => x.plan_end_date)
|
||||
})
|
||||
.Mapper(x =>
|
||||
{
|
||||
x.first_date = x.estimated_end_date.HasValue ? x.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
})
|
||||
.ToListAsync();
|
||||
var items = await _db.Queryable<ToolMoldsEquipment>().InnerJoin<EqpEquipment>((a, b) => a.equipment_id == b.id)
|
||||
.Where((a, b) => a.mold_id == moldId)
|
||||
.Select((a, b) => new EquipmentListOutput
|
||||
{
|
||||
eqp_id = b.id,
|
||||
eqp_code = b.code,
|
||||
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(iit => iit.id == b.equip_type_id).Select(iit => iit.code),
|
||||
eqp_machine_num = b.eqp_machine_num,
|
||||
tonnage = b.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == b.id).Count(),
|
||||
estimated_end_date = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == b.id).OrderByDesc(o => o.plan_end_date).Select(x => x.plan_end_date)
|
||||
}).Mapper(x =>
|
||||
{
|
||||
x.first_date = x.estimated_end_date.HasValue ? x.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
}).ToListAsync();
|
||||
return items;
|
||||
|
||||
}
|
||||
@@ -247,19 +245,17 @@ namespace Tnb.ProductionMgr
|
||||
materialProp = material != null ? material.material_property : "";
|
||||
}
|
||||
|
||||
|
||||
var res = await db.Queryable<PrdReport>().Where(it => it.mo_task_code == mo_task_code)
|
||||
.Select(it => new PrdReportOutput
|
||||
{
|
||||
icmo_qty = it.icmo_qty,
|
||||
reported_work_qty = it.reported_work_qty,
|
||||
//reported_qty = it.reported_qty,
|
||||
eqp_code = eqpCode,
|
||||
mold_code = moldCode,
|
||||
material_code = materialCode,
|
||||
material_name = materialName,
|
||||
prd_qty = it.prd_qty,
|
||||
scrap_qty = SqlFunc.Subqueryable<PrdScrapped>().Select(x => x.scrap_qty),
|
||||
//scrap_qty = SqlFunc.Subqueryable<PrdScrapped>().Select(x => x.scrap_qty),
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
@@ -274,9 +270,8 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
icmo_qty = db.Queryable<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty,
|
||||
reported_work_qty = 0,
|
||||
//reported_qty = 0,
|
||||
prd_qty = 0,
|
||||
scrap_qty = 0,
|
||||
//scrap_qty = 0,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
@@ -472,8 +467,6 @@ namespace Tnb.ProductionMgr
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -602,81 +595,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取组装包装排产任务列表
|
||||
/// </summary>
|
||||
/// <param name="input">拆解bom,生成组装包装任务列表,输入参数</param>
|
||||
/// <remarks>
|
||||
/// output:
|
||||
///<br/>{
|
||||
///<br/> workline_id:产线Id
|
||||
///<br/> workline_name:产线名称
|
||||
///<br/> material_code:物料编码
|
||||
///<br/> material_name:物料名称
|
||||
///<br/> qty:输出料数量
|
||||
///<br/>}
|
||||
/// </remarks>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetPackSchedulingTaskList(UnPackSchedlingInput input)
|
||||
{
|
||||
if (_dicWorkLine.Count < 1)
|
||||
{
|
||||
_dicWorkLine = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToDictionaryAsync(x => x.Id, x => x.FullName);
|
||||
}
|
||||
if (_dicProcess.Count < 1)
|
||||
{
|
||||
_dicProcess = await _db.Queryable<BasProcess>().Select(it => new { id = it.id, process_name = it.process_name }).Distinct().ToDictionaryAsync(x => x.id, x => x.process_name);
|
||||
}
|
||||
var outputList = new List<PackingSchedulingListOutput>();
|
||||
var bom = await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id);
|
||||
if (bom != null && bom.route_id.IsNotEmptyOrNull())
|
||||
{
|
||||
var routes = await _db.Queryable<BasRouteD>().Where(it => it.route_id == bom.route_id).ToListAsync();
|
||||
if (routes?.Count > 0)
|
||||
{
|
||||
var processIds = routes.Select(x => x.process_id).ToList();
|
||||
if (processIds?.Count > 0)
|
||||
{
|
||||
var bomOutputs = await _db.Queryable<BasMbomOutput>().Where(it => processIds.Contains(it.process_id)).ToListAsync();
|
||||
if (bomOutputs?.Count > 0)
|
||||
{
|
||||
foreach (var item in bomOutputs)
|
||||
{
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == item.material_id);
|
||||
var output = new PackingSchedulingListOutput();
|
||||
output.mo_id = input.mo_id;
|
||||
output.process_id = item.process_id;
|
||||
output.workline_id = input.workline_id;
|
||||
output.workline_name = _dicWorkLine.ContainsKey(input.workline_id) ? _dicWorkLine[input.workline_id].ToString() : "";
|
||||
output.process_name = _dicProcess[item.process_id]?.ToString();
|
||||
output.material_id = item.material_id;
|
||||
output.material_code = material?.code;
|
||||
output.material_name = material?.name;
|
||||
output.qty = item.num;
|
||||
outputList.Add(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成任务单号
|
||||
if (outputList.Count > 0)
|
||||
{
|
||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
if (mo != null && mo.mo_code.IsNotEmptyOrNull())
|
||||
{
|
||||
var taskCodes = outputList.Where(it => it.mo_task_code.IsNotEmptyOrNull()).ToList();
|
||||
if (taskCodes == null || taskCodes.Count < 1)
|
||||
{
|
||||
for (int i = 1, len = outputList.Count; i <= len; i++)
|
||||
{
|
||||
outputList[i - 1].mo_task_code = $"{mo.mo_code}-{i.ToString().PadLeft(2, '0')}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return outputList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 组装包装排产
|
||||
/// </summary>
|
||||
@@ -700,7 +619,10 @@ namespace Tnb.ProductionMgr
|
||||
moTask.estimated_end_date = input.estimated_end_date;
|
||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
var moCode = mo?.mo_code;
|
||||
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)).OrderByDescending(it => it.mo_task_code).Select(it => it.mo_task_code).FirstAsync();
|
||||
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
|
||||
.OrderByDescending(it => it.mo_task_code)
|
||||
.Select(it => it.mo_task_code)
|
||||
.FirstAsync();
|
||||
if (taskCode!.IsNullOrEmpty())
|
||||
{
|
||||
moTask.mo_task_code = $"{moCode}-01";
|
||||
@@ -917,7 +839,6 @@ namespace Tnb.ProductionMgr
|
||||
var records = await db.Queryable<PrdTaskLog>().Where(it => it.mo_task_id == taskLog.mo_task_id).ToListAsync();
|
||||
if (records != null && !records.Select(x => x.status).Contains(status))
|
||||
{
|
||||
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.status = status;
|
||||
taskLogEntities.Add(taskLog);
|
||||
@@ -925,7 +846,6 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
return (row > 0);
|
||||
}
|
||||
@@ -1128,8 +1048,6 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
row["material_id"] = $"{material.code}/{material.name}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//模具
|
||||
if (dic.ContainsKey("mold_id"))
|
||||
@@ -1182,9 +1100,7 @@ namespace Tnb.ProductionMgr
|
||||
return row > 0;
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1002);
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<PrdMoTask>> GetListByEqpId(string eqpId)
|
||||
{
|
||||
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
|
||||
|
||||
Reference in New Issue
Block a user