组装包装,生产排产代码调整
This commit is contained in:
@@ -83,111 +83,7 @@ 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>
|
||||
/// 关联模具
|
||||
|
||||
Reference in New Issue
Block a user