diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs index 01718078..af24c68c 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMbomOutput.cs @@ -9,10 +9,13 @@ namespace Tnb.BasicData.Entities [SugarTable("bas_mbom_output")] public class BasMbomOutput : BaseEntity { - public BasMbomOutput() - { - } - + + + /// + /// 工单Id + /// + [SugarColumn(IsIgnore = true)] + public string mo_id { get; set; } /// /// Desc:生产bomid /// Default: diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs index 5e689dd0..34be5b6d 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs @@ -33,9 +33,9 @@ namespace Tnb.ProductionMgr.Entities.Dto /// public string mold_type_code { get; set; } /// - /// 型腔数 + /// 可用台数 /// - public int? cavity_qty { get; set; } + public int available_stations { get; set; } public string mold_id { get; set;} } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs new file mode 100644 index 00000000..baed56c1 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 组装、包装排产输入参数 + /// + public class PackSchedlingCrInput + { + /// + /// bom任务集合 + /// + public List items{ get; set; } + } + + public class PackSchedlingItem + { + /// + /// 工单Id + /// + public string mo_id { get; set; } + /// + /// 生产bomId + /// + public string bom_id { get; set; } + /// + /// 工序id + /// + public string process_id { get; set; } + /// + /// 产线Id + /// + public string workline_id { get; set; } + /// + /// 物料Id + /// + public string material_id { get; set; } + /// + /// 生产任务单号 + /// + public string mo_task_code { get; set; } + /// + /// 物料编码 + /// + public string material_code { get; set; } + /// + /// 物料名称 + /// + public string material_name { get; set; } + /// + /// bom产出料数量 + /// + public string qty { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackingSchedulingListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackingSchedulingListOutput.cs index 888e67ae..581be5f6 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackingSchedulingListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackingSchedulingListOutput.cs @@ -11,6 +11,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// public class PackingSchedulingListOutput { + /// + /// 工单Id + /// + public string mo_id { get; set; } + /// + /// 工序Id + /// + public string process_id { get; set; } /// /// 产线Id /// @@ -24,6 +32,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// public string mo_task_code { get; set; } /// + /// 物料Id + /// + public string material_id { get; set; } + /// /// 物料编码 /// public string material_code { get; set; } @@ -32,6 +44,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// public string material_name { get; set; } /// + /// 工序名称 + /// + public string process_name { get; set; } + /// /// 产出数量 /// public string qty { get; set; } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/UnPackSchedlingInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/UnPackSchedlingInput.cs new file mode 100644 index 00000000..ba31a885 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/UnPackSchedlingInput.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 拆解组装包装排产输入参数 + /// + public class UnPackSchedlingInput + { + /// + /// 工单Id + /// + public string mo_id { get; set; } + /// + /// 生产任务Id + /// + public string mo_task_id { get; set; } + /// + /// 生产bom Id + /// + public string bom_id { get; set; } + /// + /// 产线Id + /// + public string workline_id { get; set; } + + /// + /// Desc:预计开始时间 + /// Default: + /// Nullable:True + /// + public DateTime? estimated_start_date { get; set; } + + /// + /// Desc:预计结束时间 + /// Default: + /// Nullable:True + /// + public DateTime? estimated_end_date { get; set; } + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs index 8ec40565..dfd49b6c 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs @@ -177,6 +177,10 @@ namespace Tnb.ProductionMgr.Entities /// Nullable:True /// public string modify_id { get; set; } + /// + /// 模具型号 + /// + public string mold_type_code { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 97cd1577..0e56704d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -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 _dicDefect = new Dictionary(); private static Dictionary _dicWorkLine = new Dictionary(); + private static Dictionary _dicProcess = new Dictionary(); 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().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 /// /// 获取组装包装排产任务列表 /// - /// - /// + /// 拆解bom,生成组装包装任务列表,输入参数 + /// + /// output: + ///
{ + ///
workline_id:产线Id + ///
workline_name:产线名称 + ///
material_code:物料编码 + ///
material_name:物料名称 + ///
qty:输出料数量 + ///
} + ///
[HttpPost] - public async Task GetPackSchedulingTaskList(ProductionSchedulingCrInput input) + public async Task GetPackSchedulingTaskList(UnPackSchedlingInput input) { if (_dicWorkLine.Count < 1) { _dicWorkLine = await _db.Queryable().Where(it => it.Category == "workline").ToDictionaryAsync(x => x.Id, x => x.FullName); } + if (_dicProcess.Count < 1) + { + _dicProcess = await _db.Queryable().Select(it => new { id = it.id, process_name = it.process_name }).Distinct().ToDictionaryAsync(x => x.id, x => x.process_name); + } var outputList = new List(); var bom = await _db.Queryable().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().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().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; } + /// + /// 组装包装排产 + /// + /// + /// + /// + [HttpPost] + public async Task PackSchedling(PackSchedlingCrInput input) + { + if (input.items == null) + { + throw new ArgumentNullException(nameof(input.items)); + } + DbResult 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 taskLogList = new(); + List taskDefectRecordList = new(); + + foreach (var moTask in moTasks) + { + var material = await _db.Queryable().FirstAsync(it => it.id == moTask.material_id); + var mo = await _db.Queryable().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().FirstAsync(it => it.id == moTask.eqp_id))?.code; + taskLog.mold_code = (await _db.Queryable().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; + } /// /// 生产任务下发,开始 、结束、完成