生产任务单代码调整
This commit is contained in:
@@ -33,6 +33,7 @@ using Aop.Api.Domain;
|
||||
using Senparc.Weixin.MP.AdvancedAPIs.Card;
|
||||
using Aspose.Cells.Drawing.Texts;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using WebSocketSharp.Frame;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -50,6 +51,7 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private static Dictionary<string, object> _dicDefect = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicWorkLine = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicProcess = new Dictionary<string, object>();
|
||||
private readonly ISqlSugarClient _db;
|
||||
|
||||
|
||||
@@ -108,8 +110,10 @@ namespace Tnb.ProductionMgr
|
||||
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,
|
||||
cavity_qty = a.cavity_qty,
|
||||
material_code = b.code,
|
||||
available_stations = SqlFunc.Subqueryable<EqpEquipment>().Where(it => it.mold_id == a.id).Count(),
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
@@ -429,11 +433,10 @@ namespace Tnb.ProductionMgr
|
||||
var pos = taskCode.IndexOf("-", StringComparison.Ordinal);
|
||||
if (pos > -1)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt();
|
||||
var code = taskCode.AsSpan().Slice(0, pos).ToString();
|
||||
var n = (num + 1).ToString().PadLeft(2, '0');
|
||||
moTask.mo_task_code = sb.Append(code).Append("-").Append(n).ToString();
|
||||
moTask.mo_task_code = $"{code}-{n}";
|
||||
}
|
||||
}
|
||||
try
|
||||
@@ -509,15 +512,28 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 获取组装包装排产任务列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <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(ProductionSchedulingCrInput input)
|
||||
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())
|
||||
@@ -535,8 +551,12 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
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;
|
||||
@@ -546,8 +566,97 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
//生成任务单号
|
||||
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>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PackSchedling(PackSchedlingCrInput input)
|
||||
{
|
||||
if (input.items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input.items));
|
||||
}
|
||||
DbResult<bool> dbResult = null;
|
||||
if (input.items.Count > 0)
|
||||
{
|
||||
var moTasks = input.items.Select(x => new PrdMoTask
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
mo_task_code = x.mo_task_code,
|
||||
material_id = x.material_id,
|
||||
mo_id = x.mo_id,
|
||||
bom_id = x.bom_id,
|
||||
create_id = _userManager.UserId,
|
||||
scheduled_qty = x.qty.ParseToInt(),
|
||||
create_time = DateTime.Now
|
||||
}).ToList();
|
||||
dbResult = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _db.Insertable(moTasks).ExecuteCommandAsync();
|
||||
List<PrdTaskLog> taskLogList = new();
|
||||
List<PrdMoTaskDefectRecord> taskDefectRecordList = new();
|
||||
|
||||
foreach (var moTask in moTasks)
|
||||
{
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
|
||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == moTask.mo_id);
|
||||
var taskLog = new PrdTaskLog();
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.mo_code = mo?.mo_code;
|
||||
taskLog.eqp_code = (await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code;
|
||||
taskLog.mold_code = (await _db.Queryable<Molds>().FirstAsync(it => it.id == moTask.mold_id))?.mold_code;
|
||||
taskLog.item_code = material?.code;
|
||||
taskLog.item_standard = material?.material_standard;
|
||||
taskLog.status = DictConst.ToBeScheduledEncode;
|
||||
taskLog.operator_name = _userManager.RealName;
|
||||
taskLog.create_id = _userManager.UserId;
|
||||
taskLog.create_time = DateTime.Now;
|
||||
taskLog.mo_task_id = moTask.id;
|
||||
taskLog.mo_task_code = moTask.mo_task_code;
|
||||
taskLogList.Add(taskLog);
|
||||
//将生产任务插入到自检报废记录表
|
||||
var sacipRecord = new PrdMoTaskDefectRecord();
|
||||
sacipRecord.id = SnowflakeIdHelper.NextId();
|
||||
sacipRecord.material_code = material?.code;
|
||||
sacipRecord.material_name = material?.name;
|
||||
sacipRecord.estimated_start_date = mo?.plan_start_date;
|
||||
sacipRecord.estimated_end_date = mo?.plan_end_date;
|
||||
sacipRecord.plan_qty = moTask.plan_qty;
|
||||
sacipRecord.scrap_qty = moTask.scrap_qty;
|
||||
sacipRecord.status = moTask.mo_task_status;
|
||||
sacipRecord.create_id = _userManager.UserId;
|
||||
sacipRecord.create_time = DateTime.Now;
|
||||
sacipRecord.mo_task_id = moTask.id;
|
||||
sacipRecord.mo_task_code = moTask.mo_task_code;
|
||||
taskDefectRecordList.Add(sacipRecord);
|
||||
}
|
||||
await _db.Insertable(taskLogList).ExecuteCommandAsync();
|
||||
await _db.Insertable(taskDefectRecordList).ExecuteCommandAsync();
|
||||
});
|
||||
}
|
||||
return dbResult!.IsSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产任务下发,开始 、结束、完成
|
||||
|
||||
Reference in New Issue
Block a user