diff --git a/BasicData/Tnb.BasicData.Entitys/Entity/BasItem.cs b/BasicData/Tnb.BasicData.Entitys/Entity/BasItem.cs
index 66c54c43..6070e9d0 100644
--- a/BasicData/Tnb.BasicData.Entitys/Entity/BasItem.cs
+++ b/BasicData/Tnb.BasicData.Entitys/Entity/BasItem.cs
@@ -28,7 +28,7 @@ namespace Tnb.BasicData.Entitys.Entity
/// Default:
/// Nullable:False
///
- public string item_code {get;set;}
+ public string product_code { get;set;}
///
/// Desc:产品分类ID
@@ -77,14 +77,14 @@ namespace Tnb.BasicData.Entitys.Entity
/// Default:NULL::character varying
/// Nullable:True
///
- public string item_name {get;set;}
+ public string product_name { get;set;}
///
/// Desc:产品规格型号
/// Default:NULL::character varying
/// Nullable:True
///
- public string item_standard {get;set;}
+ public string product_standard { get;set;}
///
/// Desc:物料ID,BAS_MATERIAL.ID
@@ -98,7 +98,7 @@ namespace Tnb.BasicData.Entitys.Entity
/// Default:NULL::character varying
/// Nullable:True
///
- public string item_type {get;set;}
+ public string product_type { get;set;}
///
/// Desc:备注
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs
index 3f78ed61..2d464bb2 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Entity/PrdTask.cs
@@ -106,7 +106,7 @@ namespace Tnb.ProductionMgr.Entities
/// Default:
/// Nullable:True
///
- public int? plan_qty { get; set; }
+ public decimal plan_qty { get; set; }
///
/// Desc:完成数量
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entitys/Mapper/Mapper.cs b/ProductionMgr/Tnb.ProductionMgr.Entitys/Mapper/Mapper.cs
index 13297e3d..8b8a1671 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entitys/Mapper/Mapper.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entitys/Mapper/Mapper.cs
@@ -8,7 +8,8 @@ namespace Tnb.ProductionMgr.Entities.Mapper
{
public void Register(TypeAdapterConfig config)
{
- config.ForType();
+ config.ForType()
+ .Map(dest => dest.task_id, src => src.prd_task_id);
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs
index beaf0da5..8821bb78 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs
@@ -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 CanelRelevancy(MoCrInput input)
{
return await _repository.AsSugarClient().Updateable()
- .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();
}
///
@@ -312,6 +309,7 @@ namespace Tnb.ProductionMgr
try
{
List entities = new();
+ List icmoEntities = new();
//根据工单Id查询同组工单号,进行同组工单排产处理
var combineMoCodes = await db.Queryable().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>();
+ //var icmoEntities = entities.Adapt>();
+ 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>();
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().Where(it => !icmoIds.Contains(it.id) && !statusMany.Contains(it.status)).ToListAsync();
- row = await db.Insertable(logEntities).ExecuteCommandAsync();
+ var logEntities = await db.Queryable().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().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
- var icmoList = moList.Adapt>();
- 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)