组装包装排产代码提交
This commit is contained in:
@@ -10,14 +10,6 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// 组装、包装排产输入参数
|
/// 组装、包装排产输入参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PackSchedlingCrInput
|
public class PackSchedlingCrInput
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// bom任务集合
|
|
||||||
/// </summary>
|
|
||||||
public List<PackSchedlingItem> items{ get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PackSchedlingItem
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工单Id
|
/// 工单Id
|
||||||
@@ -28,10 +20,6 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string bom_id { get; set; }
|
public string bom_id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工序id
|
|
||||||
/// </summary>
|
|
||||||
public string process_id { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 产线Id
|
/// 产线Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string workline_id { get; set; }
|
public string workline_id { get; set; }
|
||||||
@@ -39,21 +27,26 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// 物料Id
|
/// 物料Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string material_id { get; set; }
|
public string material_id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生产任务单号
|
/// 排产数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string mo_task_code { get; set; }
|
public string scheduled_qty { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料编码
|
/// Desc:预计开始时间
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string material_code { get; set; }
|
public DateTime estimated_start_date { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料名称
|
/// Desc:预计结束时间
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string material_name { get; set; }
|
public DateTime estimated_end_date { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// bom产出料数量
|
|
||||||
/// </summary>
|
|
||||||
public string qty { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.DirectoryServices.Protocols;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 组装、包装生产任务待下发输出参数列表
|
||||||
|
/// </summary>
|
||||||
|
public class PackSechelToBeIssueListOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生产任务ID
|
||||||
|
/// </summary>
|
||||||
|
public string mo_task_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 生产任务编号
|
||||||
|
/// </summary>
|
||||||
|
public string mo_task_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string material_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料名称
|
||||||
|
/// </summary>
|
||||||
|
public string material_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 产线编号
|
||||||
|
/// </summary>
|
||||||
|
public string workline_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 产线名称
|
||||||
|
/// </summary>
|
||||||
|
public string workline_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单状态
|
||||||
|
/// </summary>
|
||||||
|
public string mo_task_status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 生产任务数量
|
||||||
|
/// </summary>
|
||||||
|
public int scheduled_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 计划数量
|
||||||
|
/// </summary>
|
||||||
|
public int plan_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工序任务量
|
||||||
|
/// </summary>
|
||||||
|
public int process_task_qty { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string eqp_type_code { get; set; }
|
public string eqp_type_code { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 产线编码
|
||||||
|
/// </summary>
|
||||||
|
public string workline_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 产线名称
|
||||||
|
/// </summary>
|
||||||
|
public string workline_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// 任务单数量
|
/// 任务单数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int mo_task_qty { get; set; }
|
public int mo_task_qty { get; set; }
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ namespace DbModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsPrimaryKey = true)]
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 父任务ID
|
||||||
|
/// </summary>
|
||||||
|
public string parent_id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:生产任务编号
|
/// Desc:生产任务编号
|
||||||
@@ -229,6 +233,10 @@ namespace DbModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public int mold_cavity_qty { get; set; }
|
public int mold_cavity_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工序任务量
|
||||||
|
/// </summary>
|
||||||
|
public int process_task_qty { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ namespace Tnb.ProductionMgr.Entities
|
|||||||
/// 任务单编号
|
/// 任务单编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string mo_task_code { get; set; }
|
public string mo_task_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 产线Code
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public string workline_code { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ using Senparc.Weixin.MP.AdvancedAPIs.Card;
|
|||||||
using Aspose.Cells.Drawing.Texts;
|
using Aspose.Cells.Drawing.Texts;
|
||||||
using JNPF.Systems.Entitys.Permission;
|
using JNPF.Systems.Entitys.Permission;
|
||||||
using WebSocketSharp.Frame;
|
using WebSocketSharp.Frame;
|
||||||
|
using JNPF.Logging;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -344,40 +345,130 @@ namespace Tnb.ProductionMgr
|
|||||||
/// <br/>}
|
/// <br/>}
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[HttpGet("{moId}")]
|
[HttpGet("{moId}")]
|
||||||
public async Task<dynamic> GetPrdTaskInfoByMoId(string moId)
|
public async Task<dynamic> GetPrdTaskInfoByMoId(string moId, int schedType = 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
List<PrdMoTaskOutput> result = new();
|
||||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||||
var result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
if (schedType == 1)
|
||||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
{
|
||||||
.LeftJoin<Molds>((a, b, c, d) => a.mold_id == d.id)
|
result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||||
.LeftJoin<EqpEquipment>((a, b, c, d, e) => a.eqp_id == e.id)
|
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||||
.Where((a, b, c, d, e) => a.mo_id == moId)
|
.LeftJoin<Molds>((a, b, c, d) => a.mold_id == d.id)
|
||||||
.Select((a, b, c, d, e) => new PrdMoTaskOutput
|
.LeftJoin<EqpEquipment>((a, b, c, d, e) => a.eqp_id == e.id)
|
||||||
{
|
.Where((a, b, c, d, e) => a.mo_id == moId)
|
||||||
mo_task_code = a.mo_task_code,
|
.Select((a, b, c, d, e) => new PrdMoTaskOutput
|
||||||
mo_task_status = a.mo_task_status,
|
{
|
||||||
mold_code = d.mold_code,
|
mo_task_code = a.mo_task_code,
|
||||||
mold_name = d.mold_name,
|
mo_task_status = a.mo_task_status,
|
||||||
material_code = c.code,
|
mold_code = d.mold_code,
|
||||||
material_name = c.name,
|
mold_name = d.mold_name,
|
||||||
eqp_code = e.code,
|
material_code = c.code,
|
||||||
eqp_name = e.name,
|
material_name = c.name,
|
||||||
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(it => it.id == e.equip_type_id).Select(it => it.code),
|
eqp_code = e.code,
|
||||||
mo_task_qty = SqlFunc.Subqueryable<PrdMoTask>().Where(a => a.mo_id == moId).Count(),
|
eqp_name = e.name,
|
||||||
estimated_start_date = a.estimated_start_date,
|
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(it => it.id == e.equip_type_id).Select(it => it.code),
|
||||||
estimated_end_date = a.estimated_end_date,
|
mo_task_qty = SqlFunc.Subqueryable<PrdMoTask>().Where(a => a.mo_id == moId).Count(),
|
||||||
plan_qty = b.plan_qty,
|
estimated_start_date = a.estimated_start_date,
|
||||||
complete_qty = a.complete_qty,
|
estimated_end_date = a.estimated_end_date,
|
||||||
})
|
plan_qty = b.plan_qty,
|
||||||
.Mapper(it =>
|
complete_qty = a.complete_qty,
|
||||||
{
|
})
|
||||||
it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
|
.Mapper(it =>
|
||||||
})
|
{
|
||||||
.ToListAsync();
|
it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||||
|
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||||
|
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||||
|
.Where((a, b, c, d) => a.mo_id == moId)
|
||||||
|
.Select((a, b, c, d) => new PrdMoTaskOutput
|
||||||
|
{
|
||||||
|
mo_task_code = a.mo_task_code,
|
||||||
|
mo_task_status = a.mo_task_status,
|
||||||
|
workline_code = d.EnCode,
|
||||||
|
workline_name = d.FullName,
|
||||||
|
material_code = c.code,
|
||||||
|
material_name = c.name,
|
||||||
|
mo_task_qty = SqlFunc.Subqueryable<PrdMoTask>().Where(a => a.mo_id == moId).Count(),
|
||||||
|
estimated_start_date = a.estimated_start_date,
|
||||||
|
estimated_end_date = a.estimated_end_date,
|
||||||
|
plan_qty = b.plan_qty,
|
||||||
|
complete_qty = a.complete_qty,
|
||||||
|
})
|
||||||
|
.Mapper(it =>
|
||||||
|
{
|
||||||
|
it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
///组装、包装 获取待下发任务列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetPackScheldToBeIssueList()
|
||||||
|
{
|
||||||
|
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||||
|
var result = await _db.Queryable<PrdMoTask>().Where(it => it.schedule_type == 2)
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
||||||
|
.LeftJoin<PrdMo>((a, b, c, d) => a.mo_id == d.id)
|
||||||
|
.Select((a, b, c, d) => new PackSechelToBeIssueListOutput
|
||||||
|
{
|
||||||
|
mo_task_id = a.id,
|
||||||
|
mo_task_code = a.mo_task_code,
|
||||||
|
material_code = b.code,
|
||||||
|
material_name = b.name,
|
||||||
|
workline_code = c.EnCode,
|
||||||
|
workline_name = c.FullName,
|
||||||
|
mo_task_status = a.mo_task_status,
|
||||||
|
scheduled_qty = a.scheduled_qty,
|
||||||
|
plan_qty = d.plan_qty
|
||||||
|
})
|
||||||
|
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "")
|
||||||
|
.ToListAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 根据生产任务ID获取子任务列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mo_task_id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{mo_task_id}")]
|
||||||
|
public async Task<dynamic> GetSubMoTaskListByTaskId(string mo_task_id)
|
||||||
|
{
|
||||||
|
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||||
|
var result = await _db.Queryable<PrdMoTask>()
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
||||||
|
.LeftJoin<PrdMo>((a, b, c, d) => a.mo_id == d.id)
|
||||||
|
.Where((a, b, c, d) => a.parent_id == mo_task_id)
|
||||||
|
.Select((a, b, c, d) => new PackSechelToBeIssueListOutput
|
||||||
|
{
|
||||||
|
mo_task_id = a.id,
|
||||||
|
mo_task_code = a.mo_task_code,
|
||||||
|
material_code = b.code,
|
||||||
|
material_name = b.name,
|
||||||
|
workline_code = c.EnCode,
|
||||||
|
workline_name = c.FullName,
|
||||||
|
mo_task_status = a.mo_task_status,
|
||||||
|
scheduled_qty = a.scheduled_qty,
|
||||||
|
plan_qty = d.plan_qty,
|
||||||
|
process_task_qty = a.process_task_qty,
|
||||||
|
})
|
||||||
|
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "")
|
||||||
|
.ToListAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -593,69 +684,126 @@ namespace Tnb.ProductionMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<dynamic> PackSchedling(PackSchedlingCrInput input)
|
public async Task<dynamic> PackSchedling(PackSchedlingCrInput input)
|
||||||
{
|
{
|
||||||
if (input.items == null)
|
var row = -1;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(input.items));
|
await _db.Ado.BeginTranAsync();
|
||||||
}
|
var moTask = input.Adapt<PrdMoTask>();
|
||||||
DbResult<bool> dbResult = null;
|
moTask.id = SnowflakeIdHelper.NextId();
|
||||||
if (input.items.Count > 0)
|
moTask.create_id = _userManager.UserId;
|
||||||
{
|
moTask.create_time = DateTime.Now;
|
||||||
var moTasks = input.items.Select(x => new PrdMoTask
|
moTask.schedule_type = 2;
|
||||||
|
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||||
|
moTask.estimated_start_date = input.estimated_start_date;
|
||||||
|
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();
|
||||||
|
if (taskCode.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
id = SnowflakeIdHelper.NextId(),
|
moTask.mo_task_code = $"{moCode}-01";
|
||||||
mo_task_code = x.mo_task_code,
|
}
|
||||||
material_id = x.material_id,
|
else
|
||||||
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();
|
var pos = taskCode.IndexOf("-", StringComparison.Ordinal);
|
||||||
List<PrdTaskLog> taskLogList = new();
|
if (pos > -1)
|
||||||
List<PrdMoTaskDefectRecord> taskDefectRecordList = new();
|
|
||||||
|
|
||||||
foreach (var moTask in moTasks)
|
|
||||||
{
|
{
|
||||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
|
var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt();
|
||||||
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == moTask.mo_id);
|
var code = taskCode.AsSpan().Slice(0, pos).ToString();
|
||||||
var taskLog = new PrdTaskLog();
|
var n = (num + 1).ToString().PadLeft(2, '0');
|
||||||
taskLog.id = SnowflakeIdHelper.NextId();
|
moTask.mo_task_code = $"{code}-{n}";
|
||||||
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();
|
row = await _db.Insertable(moTask).ExecuteCommandAsync();
|
||||||
});
|
var material_h = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
|
||||||
|
//添加生产任务操作记录日志s
|
||||||
|
var taskLog = new PrdTaskLog();
|
||||||
|
taskLog.id = SnowflakeIdHelper.NextId();
|
||||||
|
taskLog.mo_code = (await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id))?.mo_code;
|
||||||
|
//taskLog.eqp_code = (await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id))?.code;
|
||||||
|
//taskLog.mold_code = (await _db.Queryable<Molds>().FirstAsync(it => it.id == input.mold_id))?.mold_code;
|
||||||
|
taskLog.item_code = material_h?.code;
|
||||||
|
taskLog.item_standard = material_h?.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;
|
||||||
|
row = await _db.Insertable(taskLog).ExecuteCommandAsync();
|
||||||
|
//根据工单号获取当前工单包含的已排产数
|
||||||
|
var schedQty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
|
||||||
|
if (mo != null)
|
||||||
|
{//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产
|
||||||
|
if (schedQty.HasValue && schedQty.Value >= mo.plan_qty)
|
||||||
|
{
|
||||||
|
mo.mo_status = DictConst.AlreadyId;
|
||||||
|
await _db.Updateable(mo).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (schedQty.HasValue)
|
||||||
|
{
|
||||||
|
mo.scheduled_qty += schedQty.Value;
|
||||||
|
await _db.Updateable(mo).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//根据生产bomId 拆解生产子任务
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
List<PrdMoTask> subMoTasks = new();
|
||||||
|
foreach (var item in bomOutputs)
|
||||||
|
{
|
||||||
|
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == item.material_id);
|
||||||
|
PrdMoTask subMoTask = new();
|
||||||
|
subMoTask.id = SnowflakeIdHelper.NextId();
|
||||||
|
subMoTask.schedule_type = 2;
|
||||||
|
subMoTask.parent_id = moTask.id;
|
||||||
|
subMoTask.bom_id = input.bom_id;
|
||||||
|
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||||
|
subMoTask.workline_id = input.workline_id;
|
||||||
|
subMoTask.material_id = item.material_id;
|
||||||
|
subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
|
||||||
|
subMoTask.estimated_start_date = input.estimated_start_date;
|
||||||
|
subMoTask.estimated_end_date = input.estimated_end_date;
|
||||||
|
subMoTask.create_id = _userManager.UserId;
|
||||||
|
subMoTask.create_time = DateTime.Now;
|
||||||
|
subMoTasks.Add(subMoTask);
|
||||||
|
}
|
||||||
|
//根据生产任务编号生成子任务编号
|
||||||
|
if (moTask.mo_task_code.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= subMoTasks.Count; i++)
|
||||||
|
{
|
||||||
|
string n = i.ToString();
|
||||||
|
subMoTasks[i - 1].mo_task_code = $"{moTask.mo_task_code}-{n.PadLeft(2, '0')}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
return dbResult!.IsSuccess;
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error("组装包装排产时报错", ex);
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
}
|
||||||
|
return row > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -710,57 +858,75 @@ namespace Tnb.ProductionMgr
|
|||||||
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||||
.Where(it => input.TaskIds.Contains(it.id))
|
.Where(it => input.TaskIds.Contains(it.id))
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
//插入操作记录日志
|
if (row > 0)
|
||||||
List<PrdTaskLog> taskLogEntities = new();
|
|
||||||
foreach (var taskId in input.TaskIds)
|
|
||||||
{
|
{
|
||||||
var taskLog = await db.Queryable<PrdTaskLog>().FirstAsync(it => it.mo_task_id == taskId);
|
//更新子任务
|
||||||
if (taskLog is null)
|
var subMoTaskList = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.parent_id)).ToListAsync();
|
||||||
|
if (subMoTaskList?.Count > 0)
|
||||||
{
|
{
|
||||||
var taskItem = list?.Find(x => x.id == taskId);
|
var subTaskIds = subMoTaskList.Select(it => it.id).ToList();
|
||||||
taskLog = new PrdTaskLog();
|
row = await db.Updateable<PrdMoTask>()
|
||||||
taskLog.id = SnowflakeIdHelper.NextId();
|
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||||
if (taskItem != null)
|
.Where(it => subTaskIds.Contains(it.id))
|
||||||
{
|
.ExecuteCommandAsync();
|
||||||
if (taskItem.mo_id.IsNotEmptyOrNull())
|
|
||||||
{
|
|
||||||
taskLog.mo_code = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code;
|
|
||||||
}
|
|
||||||
if (taskItem.eqp_id.IsNotEmptyOrNull())
|
|
||||||
{
|
|
||||||
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskItem.eqp_id))?.code;
|
|
||||||
}
|
|
||||||
if (taskItem.mold_id.IsNotEmptyOrNull())
|
|
||||||
{
|
|
||||||
taskLog.mold_code = (await db.Queryable<Molds>().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code;
|
|
||||||
}
|
|
||||||
if (taskItem.material_id.IsNotEmptyOrNull())
|
|
||||||
{
|
|
||||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == taskItem.material_id);
|
|
||||||
taskLog.item_code = material?.code;
|
|
||||||
taskLog.item_standard = material?.material_standard;
|
|
||||||
}
|
|
||||||
taskLog.operator_name = _userManager.RealName;
|
|
||||||
taskLog.status = status;
|
|
||||||
taskLog.create_id = _userManager.UserId;
|
|
||||||
taskLog.create_time = DateTime.Now;
|
|
||||||
taskLog.mo_task_id = taskItem.id;
|
|
||||||
}
|
|
||||||
taskLogEntities.Add(taskLog);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
//插入操作记录日志
|
||||||
|
var prdMOTasks = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && string.IsNullOrEmpty(it.parent_id)).ToListAsync();
|
||||||
|
if (prdMOTasks?.Count > 0)
|
||||||
|
{
|
||||||
|
List<PrdTaskLog> taskLogEntities = new();
|
||||||
|
foreach (var taskId in input.TaskIds)
|
||||||
|
{
|
||||||
|
var taskLog = await db.Queryable<PrdTaskLog>().FirstAsync(it => it.mo_task_id == taskId);
|
||||||
|
if (taskLog is null)
|
||||||
|
{
|
||||||
|
var taskItem = list?.Find(x => x.id == taskId);
|
||||||
|
taskLog = new PrdTaskLog();
|
||||||
|
taskLog.id = SnowflakeIdHelper.NextId();
|
||||||
|
if (taskItem != null)
|
||||||
|
{
|
||||||
|
if (taskItem.mo_id.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
taskLog.mo_code = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code;
|
||||||
|
}
|
||||||
|
if (taskItem.eqp_id.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskItem.eqp_id))?.code;
|
||||||
|
}
|
||||||
|
if (taskItem.mold_id.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
taskLog.mold_code = (await db.Queryable<Molds>().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code;
|
||||||
|
}
|
||||||
|
if (taskItem.material_id.IsNotEmptyOrNull())
|
||||||
|
{
|
||||||
|
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == taskItem.material_id);
|
||||||
|
taskLog.item_code = material?.code;
|
||||||
|
taskLog.item_standard = material?.material_standard;
|
||||||
|
}
|
||||||
|
taskLog.operator_name = _userManager.RealName;
|
||||||
|
taskLog.status = status;
|
||||||
|
taskLog.create_id = _userManager.UserId;
|
||||||
|
taskLog.create_time = DateTime.Now;
|
||||||
|
taskLog.mo_task_id = taskItem.id;
|
||||||
|
}
|
||||||
|
taskLogEntities.Add(taskLog);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
}
|
||||||
return (row > 0);
|
return (row > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user