同组排产代码调整
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Tnb.BasicData.Entitys.Entity
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string item_code {get;set;}
|
||||
public string product_code { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品分类ID
|
||||
@@ -77,14 +77,14 @@ namespace Tnb.BasicData.Entitys.Entity
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_name {get;set;}
|
||||
public string product_name { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品规格型号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_standard {get;set;}
|
||||
public string product_standard { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料ID,BAS_MATERIAL.ID
|
||||
@@ -98,7 +98,7 @@ namespace Tnb.BasicData.Entitys.Entity
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_type {get;set;}
|
||||
public string product_type { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
public decimal plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:完成数量
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Tnb.ProductionMgr.Entities.Mapper
|
||||
{
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.ForType<ProductionSchedulingCrInput, PrdTask>();
|
||||
config.ForType<PrdTask, PrdTaskLog>()
|
||||
.Map(dest => dest.task_id, src => src.prd_task_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,9 +84,9 @@ namespace Tnb.ProductionMgr
|
||||
id = a.id,
|
||||
mold_code = a.mold_code,
|
||||
mold_name = a.mold_name,
|
||||
item_name = b.item_name,
|
||||
item_name = b.product_name,
|
||||
cavity_qty = a.cavity_qty,
|
||||
item_code = b.item_code,
|
||||
item_code = b.product_code,
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
@@ -117,9 +117,6 @@ namespace Tnb.ProductionMgr
|
||||
x.first_date = x.estimated_end_date.HasValue ? x.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
|
||||
return items;
|
||||
|
||||
}
|
||||
@@ -271,9 +268,9 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> CanelRelevancy(MoCrInput input)
|
||||
{
|
||||
return await _repository.AsSugarClient().Updateable<PrdMo>()
|
||||
.SetColumns(c => new PrdMo { combine_mo_code = "" })
|
||||
.Where(it => input.WorkOrderIds.Contains(it.id))
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
.SetColumns(c => new PrdMo { combine_mo_code = "" })
|
||||
.Where(it => input.WorkOrderIds.Contains(it.id))
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -312,6 +309,7 @@ namespace Tnb.ProductionMgr
|
||||
try
|
||||
{
|
||||
List<PrdMo> entities = new();
|
||||
List<PrdTask> icmoEntities = new();
|
||||
//根据工单Id查询同组工单号,进行同组工单排产处理
|
||||
var combineMoCodes = await db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.combine_mo_code).Distinct().ToListAsync();
|
||||
if (combineMoCodes?.Count > 0)
|
||||
@@ -323,31 +321,47 @@ namespace Tnb.ProductionMgr
|
||||
//同组工单排产
|
||||
if (entities.Count > 0)
|
||||
{
|
||||
var icmoEntities = entities.Adapt<List<PrdTask>>();
|
||||
//var icmoEntities = entities.Adapt<List<PrdTask>>();
|
||||
icmoEntities = entities.Select(x => new PrdTask
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
item_id = x.id,
|
||||
item_code = x.item_code,
|
||||
mo_type = input.mo_type,
|
||||
plan_start_date = x.plan_start_date,
|
||||
plan_end_date = x.plan_end_date,
|
||||
}).ToList();
|
||||
icmoEntities.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.status = DictConst.ToBeStartedEnCode; //任务单状态默认,待排产
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.prd_task_id = input.id;
|
||||
x.prd_task_id = x.id;
|
||||
});
|
||||
row = await db.Storageable(entities).ExecuteCommandAsync();
|
||||
row = await db.Insertable(icmoEntities).ExecuteCommandAsync();
|
||||
var icmoRecords = icmoEntities.Adapt<List<PrdTaskLog>>();
|
||||
icmoRecords.ForEach(x =>
|
||||
{
|
||||
x.id ??= SnowflakeIdHelper.NextId();
|
||||
x.task_id = input.id;
|
||||
x.status ??= "ToBeStarted";
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.status ??= DictConst.ToBeStartedEnCode;
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.operator_name = _userManager.RealName;
|
||||
});
|
||||
var icmoIds = icmoRecords.Select(it => it.id).ToList();
|
||||
var statusMany = icmoRecords.Select(it => it.status).ToList();
|
||||
var icmoIds = icmoRecords.Select(it => it.task_id).Distinct().ToList();
|
||||
var statusMany = icmoRecords.Select(it => it.status).Distinct().ToList();
|
||||
//任务状态变更时插入操作记录
|
||||
var logEntities = await db.Queryable<PrdTaskLog>().Where(it => !icmoIds.Contains(it.id) && !statusMany.Contains(it.status)).ToListAsync();
|
||||
row = await db.Insertable(logEntities).ExecuteCommandAsync();
|
||||
var logEntities = await db.Queryable<PrdTaskLog>().Where(it => icmoIds.Contains(it.task_id)).ToListAsync();
|
||||
if (logEntities?.Count > 0)
|
||||
{
|
||||
var dbTaskStatusList = logEntities.Select(x => x.status).Distinct().ToList();
|
||||
var ultimatelyStatus = statusMany.Except(dbTaskStatusList).ToList();
|
||||
icmoRecords = icmoRecords.Where(x => ultimatelyStatus.Contains(x.status)).ToList();
|
||||
}
|
||||
if (icmoRecords.Count > 0)
|
||||
{
|
||||
row = await db.Insertable(icmoRecords).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -370,15 +384,23 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (row > 0)
|
||||
{
|
||||
if (combineMoCodes?.Count > 0 && combineMoCodes?.FirstOrDefault() is not null)
|
||||
if (icmoEntities?.Count > 0 && combineMoCodes?.FirstOrDefault() is not null)
|
||||
{
|
||||
var moList = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
||||
var icmoList = moList.Adapt<List<PrdTask>>();
|
||||
var combinePlanQty = icmoList.Sum(x => x.plan_qty); //合并工单后的计划数量
|
||||
var combineScheduledQty = icmoList.Sum(x => x.scheduled_qty); //合并后的已排产数量
|
||||
//var icmoList = moList.Select(x => new PrdTask
|
||||
//{
|
||||
// id = SnowflakeIdHelper.NextId(),
|
||||
// item_id = x.item_id,
|
||||
// item_code = x.item_code,
|
||||
// mo_type = input.mo_type,
|
||||
// plan_start_date = x.plan_start_date,
|
||||
// plan_end_date = x.plan_end_date,
|
||||
//}).ToList();
|
||||
var combinePlanQty = icmoEntities?.Sum(x => x.plan_qty); //合并工单后的计划数量
|
||||
var combineScheduledQty = icmoEntities?.Sum(x => x.scheduled_qty); //合并后的已排产数量
|
||||
if (combineScheduledQty < combinePlanQty)
|
||||
{
|
||||
icmoList.ForEach(x =>
|
||||
icmoEntities.ForEach(x =>
|
||||
{
|
||||
var item = moList.Find(xx => xx.id == x.mo_id);
|
||||
if (item != null)
|
||||
@@ -393,7 +415,7 @@ namespace Tnb.ProductionMgr
|
||||
//如果已排产数量大于计划数量,修改工单状态为,待开工
|
||||
if (combineScheduledQty >= combinePlanQty)
|
||||
{
|
||||
icmoList.ForEach(x =>
|
||||
icmoEntities.ForEach(x =>
|
||||
{
|
||||
var item = moList.Find(xx => xx.id == x.mo_id);
|
||||
if (item != null)
|
||||
|
||||
Reference in New Issue
Block a user