组装包装,生产排产代码调整
This commit is contained in:
@@ -8,14 +8,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class ClosedownHistoryOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string eqp_name { get; set; }
|
||||
/// <summary>
|
||||
/// 停机开始时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_start_time { get; set; }
|
||||
public string? closedown_start_time { get; set; }
|
||||
/// <summary>
|
||||
/// 停机结束时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_end_time { get; set; }
|
||||
public string? closedown_end_time { get; set; }
|
||||
/// <summary>
|
||||
/// 停机时间
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class GenSubMoCrInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// 子物料ids
|
||||
/// </summary>
|
||||
public List<string> ids { get; set; }
|
||||
|
||||
}
|
||||
|
||||
//public class SubMo
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 物料id
|
||||
// /// </summary>
|
||||
// public string material_id { get; set; }
|
||||
// /// <summary>
|
||||
// /// 物料编码
|
||||
// /// </summary>
|
||||
// public string material_code { get; set; }
|
||||
// /// <summary>
|
||||
// /// 物料名称
|
||||
// /// </summary>
|
||||
// public string material_name { get; set; }
|
||||
// /// <summary>
|
||||
// /// 物料型号
|
||||
// /// </summary>
|
||||
// public string material_category_code { get; set; }
|
||||
// /// <summary>
|
||||
// ///输出数量
|
||||
// /// </summary>
|
||||
// public int output_qty { get; set; }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Security;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class PrdMotreeOutput : TreeModel
|
||||
{
|
||||
public string? org_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工单id
|
||||
/// </summary>
|
||||
|
||||
public string mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单代码
|
||||
/// </summary>
|
||||
public string mo_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||
/// </summary>
|
||||
public string? mo_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停
|
||||
/// </summary>
|
||||
public string? mo_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划生产数量
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已投入数量
|
||||
/// </summary>
|
||||
public int? input_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已完工数量
|
||||
/// </summary>
|
||||
public int? complete_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int? scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始时间
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划结束时间
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否生派工单
|
||||
/// </summary>
|
||||
public int? is_create_dispatch { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产线代码
|
||||
/// </summary>
|
||||
public string? production_linecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否合并
|
||||
/// </summary>
|
||||
public int? is_merge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组合工单
|
||||
/// </summary>
|
||||
public string? combine_mo_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public string? time_stamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int? scheduled_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string parent_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -218,5 +218,9 @@ public partial class PrdMo : BaseEntity<string>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int? scheduled_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string parent_id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -139,15 +139,17 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var pagedList = await _db.Queryable<PrdCancelClosedownRecord>()
|
||||
.WhereIF(!string.IsNullOrEmpty(input.eqpName), it => it.eqp_name.Contains(input.eqpName))
|
||||
.WhereIF(input.beginTime.HasValue, it => it.closedown_start_time.Value == input.beginTime)
|
||||
.WhereIF(input.endTime.HasValue, it => it.closedown_end_time.Value == input.endTime)
|
||||
.WhereIF(input.beginTime.HasValue, it => it.closedown_start_time.Value >= input.beginTime)
|
||||
.WhereIF(input.endTime.HasValue, it => it.closedown_start_time.Value <= input.endTime)
|
||||
.Select(it => new ClosedownHistoryOutput
|
||||
{
|
||||
closedown_start_time = it.closedown_start_time,
|
||||
closedown_end_time = it.closedown_end_time,
|
||||
eqp_code = it.eqp_code,
|
||||
eqp_name = it.eqp_name,
|
||||
closedown_start_time = it.closedown_start_time.HasValue ? it.closedown_start_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
|
||||
closedown_end_time = it.closedown_end_time.HasValue ? it.closedown_end_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
|
||||
closedown_time = it.closedown_time,
|
||||
})
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
.ToListAsync();
|
||||
return pagedList;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -216,8 +218,9 @@ namespace Tnb.ProductionMgr
|
||||
var mold = await _moldService.GetListById(moldId);
|
||||
var maintaindTask = new ToolMoldMaintainTask();
|
||||
maintaindTask.mold_id = moldId;
|
||||
maintaindTask.code = DictConst.MaintainStatusDWXCode;
|
||||
maintaindTask.code = mold.mold_code;
|
||||
maintaindTask.create_id = _userManager.UserId;
|
||||
maintaindTask.status = DictConst.UnMaintainStatusCode;
|
||||
maintaindTask.create_time = DateTime.Now;
|
||||
|
||||
await _maintainTaskService.Create(maintaindTask);
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly ISqlSugarClient _db;
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
@@ -67,6 +68,7 @@ namespace Tnb.ProductionMgr
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_db = _repository.AsSugarClient();
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
@@ -89,7 +91,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
row.Add("material_name", material.name);
|
||||
row.Add($"material_attribute", material.attribute);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,6 +243,8 @@ namespace Tnb.ProductionMgr
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,6 +466,35 @@ namespace Tnb.ProductionMgr
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取组装、包装 待排产工单树形列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetUnSchedulingList()
|
||||
{
|
||||
List<PrdMotreeOutput> trees = new();
|
||||
var list = await _db.Queryable<PrdMo>().Where(it => string.IsNullOrEmpty(it.parent_id) && it.mo_status == DictConst.ScheduledId).ToListAsync();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var node = item.Adapt<PrdMotreeOutput>();
|
||||
node.mo_id = item.id;
|
||||
node.id = SnowflakeIdHelper.NextId();
|
||||
node.parentId = "0";
|
||||
var items = await _db.Queryable<PrdMo>().Where(it => it.parent_id == item.id).ToListAsync();
|
||||
if (items?.Count() > 0)
|
||||
{
|
||||
var childNodes = items.Adapt<List<PrdMotreeOutput>>();
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
childNodes[i].mo_id = items[i].id;
|
||||
}
|
||||
trees.AddRange(childNodes);
|
||||
}
|
||||
trees.Add(node);
|
||||
}
|
||||
return trees.ToTree();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -653,6 +682,24 @@ namespace Tnb.ProductionMgr
|
||||
taskLog.mo_task_id = moTask.id;
|
||||
taskLog.mo_task_code = moTask.mo_task_code!;
|
||||
row = await _db.Insertable(taskLog).ExecuteCommandAsync();
|
||||
//将生产任务插入到自检报废记录表
|
||||
//var sacipRecord = new PrdMoTaskDefectRecord();
|
||||
//sacipRecord.id = SnowflakeIdHelper.NextId();
|
||||
//sacipRecord.material_code = material?.code!;
|
||||
//sacipRecord.material_name = material?.name!;
|
||||
//sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
|
||||
//sacipRecord.mold_name = (await db.Queryable<ToolMolds>().FirstAsync(it => it.id == moTask.mold_id))?.mold_name!;
|
||||
//sacipRecord.estimated_start_date = moTask.plan_start_date;
|
||||
//sacipRecord.estimated_end_date = moTask.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;
|
||||
//await db.Insertable(sacipRecord).ExecuteCommandAsync();
|
||||
|
||||
//根据工单号获取当前工单包含的已排产数
|
||||
var schedQty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
|
||||
if (mo != null)
|
||||
@@ -1026,6 +1073,54 @@ namespace Tnb.ProductionMgr
|
||||
return row > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成子工单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task GenSubMo(GenSubMoCrInput input)
|
||||
{
|
||||
if (input is null) throw new ArgumentNullException("input");
|
||||
if (input.ids is null || input.ids.Count == 0) throw new ArgumentException($"{nameof(input.ids)} not be null or count zero");
|
||||
var curMo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
if (curMo == null) throw new ArgumentNullException("创建子工单时的父工单不能为null");
|
||||
List<PrdMo> subMoList = new();
|
||||
var outputMaterials = await _db.Queryable<BasMaterial>().LeftJoin<BasMbomOutput>((a, b) => a.id == b.material_id)
|
||||
.Where((a, b) => input.ids.Contains(a.id))
|
||||
.Select((a, b) => new
|
||||
{
|
||||
material_id = a.id,
|
||||
material_code = a.code,
|
||||
num = b.num,
|
||||
})
|
||||
.ToListAsync();
|
||||
foreach (var om in outputMaterials)
|
||||
{
|
||||
PrdMo subMo = new();
|
||||
subMo.material_id = om.material_id;
|
||||
subMo.material_code = om.material_code;
|
||||
subMo.plan_qty = om.num.ParseToInt() * curMo.plan_qty;
|
||||
subMo.mo_type = curMo.mo_type;
|
||||
subMo.parent_id = curMo.id;
|
||||
subMo.plan_start_date = curMo.plan_start_date;
|
||||
subMo.plan_end_date = curMo.plan_end_date;
|
||||
subMo.create_id = _userManager.UserId;
|
||||
subMo.create_time = DateTime.Now;
|
||||
subMo.mo_status = DictConst.WaitProductId;
|
||||
subMoList.Add(subMo);
|
||||
}
|
||||
//生成子工单编码
|
||||
for (int i = 0; i < subMoList.Count; i++)
|
||||
{
|
||||
var num = (i + 1).ToString().PadLeft(2, '0');
|
||||
subMoList[i].mo_code = $"{subMoList[i].mo_code}-{num}";
|
||||
}
|
||||
var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user