模具保养计划执行模块代码提交
This commit is contained in:
@@ -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