1
This commit is contained in:
@@ -19,7 +19,10 @@ public static class DictConst
|
||||
/// 生产任务状态TypeId
|
||||
/// </summary>
|
||||
public const string PrdTaskStatusTypeId = "25572555259157";
|
||||
|
||||
/// <summary>
|
||||
/// 生产工单类型TypeId
|
||||
/// </summary>
|
||||
public const string PrdMoTypeTypeId = "25019155728149";
|
||||
|
||||
/// <summary>
|
||||
/// 工单状态-已排产
|
||||
|
||||
@@ -177,29 +177,7 @@ namespace Tnb.BasicData
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.ToListAsync();
|
||||
#region 注释代码
|
||||
//var result = await _db.Queryable<BasMbom>()
|
||||
// .LeftJoin<BasRouteH>((a, b) => a.route_id == b.id)
|
||||
// .LeftJoin<BasRouteD>((a, b, c) => b.id == c.route_id)
|
||||
// .LeftJoin<BasMbomProcess>((a, b, c, d) => c.process_id == d.process_id)
|
||||
// .LeftJoin<BasMbomOutput>((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
|
||||
// .Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
|
||||
|
||||
// .Select((a, b, c, d, e) => new SubBomListOutput
|
||||
// {
|
||||
// version = a.version,
|
||||
// unit_id = a.unit_id,
|
||||
// route_name = b.name,
|
||||
// process_id = c.process_id,
|
||||
// material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||
// material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
||||
// material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
||||
// material_standard = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.material_standard),
|
||||
// num = e.num,
|
||||
// })
|
||||
// .Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
// .ToListAsync();
|
||||
#endregion
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装,生产任务管理树形输出类
|
||||
/// </summary>
|
||||
public class PackReportTreeOutput : TreeModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务编号
|
||||
/// </summary>
|
||||
public string? mo_task_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单Id
|
||||
/// </summary>
|
||||
public string? mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产线id
|
||||
/// </summary>
|
||||
public string? workline_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string? workstation_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线id
|
||||
/// </summary>
|
||||
public string? workroute_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产bom id
|
||||
/// </summary>
|
||||
public string? bom_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单状态
|
||||
/// </summary>
|
||||
public string? mo_task_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 int? scheduled_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排产类型:1、注塑、挤出2、组装、包装
|
||||
/// </summary>
|
||||
public int? schedule_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始时间
|
||||
/// </summary>
|
||||
public string plan_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划结束时间
|
||||
/// </summary>
|
||||
public string plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际开工日期
|
||||
/// </summary>
|
||||
public DateTime? act_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际完工日期
|
||||
/// </summary>
|
||||
public DateTime? act_end_date { 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>
|
||||
/// 扩展字段
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产顺序
|
||||
/// </summary>
|
||||
public int? prd_order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预计开始时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预计结束时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 父任务Id
|
||||
/// </summary>
|
||||
public string? parent_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序任务量
|
||||
/// </summary>
|
||||
public int? process_task_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Filter;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class PrdPackReportQueryInput : PageInputBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务编号
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -46,5 +46,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 物料属性
|
||||
/// </summary>
|
||||
public string material_property { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,5 +70,20 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_property { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string process_name { get; set; }
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string process_code { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string workline_code { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public partial class PrdMoTaskDefectRecord : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int? scrap_qty { get; set; }
|
||||
public int scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产任务单状态
|
||||
@@ -81,6 +81,6 @@ public partial class PrdMoTaskDefectRecord : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public int mo_task_type { get; set; }
|
||||
public string mo_task_type { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class PrdReportRecord : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 完成数量
|
||||
/// </summary>
|
||||
public int? completed_qty { get; set; }
|
||||
public int completed_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单号
|
||||
@@ -60,5 +60,13 @@ public partial class PrdReportRecord : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public int mo_task_type { get; set; }
|
||||
public string mo_task_type { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务id
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// 已报工数量
|
||||
/// </summary>
|
||||
public int reported_work_qty { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装 生产提报接口
|
||||
/// </summary>
|
||||
public interface IPrdPackReportService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using JNPF.Common.Extension;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -52,6 +53,8 @@ namespace Tnb.ProductionMgr
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
var scheduledTypeField = nameof(PrdMoTask.schedule_type);
|
||||
data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
@@ -589,22 +589,22 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
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 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();
|
||||
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
@@ -804,102 +804,164 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
|
||||
}
|
||||
string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
|
||||
var taskList = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
|
||||
if (taskList?.Count > 0)
|
||||
{
|
||||
PrdTaskBehavior.Release => DictConst.ToBeStartedEnCode,
|
||||
PrdTaskBehavior.Start => DictConst.InProgressEnCode,
|
||||
PrdTaskBehavior.Closed => DictConst.ClosedEnCode,
|
||||
PrdTaskBehavior.Compled => DictConst.ComplatedEnCode,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
PrdTaskBehavior behavior = input.Behavior.ToEnum<PrdTaskBehavior>();
|
||||
var status = SetTaskStatus(behavior);
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
|
||||
if (behavior == PrdTaskBehavior.Compled)
|
||||
{
|
||||
|
||||
if (list?.Count > 0)
|
||||
string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
|
||||
{
|
||||
var schedQtySum = list.Sum(x => x.scheduled_qty);
|
||||
var planQtySum = list.Sum(x => x.plan_qty);
|
||||
if (schedQtySum < planQtySum)
|
||||
PrdTaskBehavior.Release => DictConst.ToBeStartedEnCode,
|
||||
PrdTaskBehavior.Start => DictConst.InProgressEnCode,
|
||||
PrdTaskBehavior.Closed => DictConst.ClosedEnCode,
|
||||
PrdTaskBehavior.Compled => DictConst.ComplatedEnCode,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
PrdTaskBehavior behavior = input.Behavior.ToEnum<PrdTaskBehavior>();
|
||||
var status = SetTaskStatus(behavior);
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
|
||||
if (behavior == PrdTaskBehavior.Compled)
|
||||
{
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
row = await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||
.Where(it => input.TaskIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
//更新子任务
|
||||
var subMoTaskList = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.parent_id)).ToListAsync();
|
||||
if (subMoTaskList?.Count > 0)
|
||||
{
|
||||
var subTaskIds = subMoTaskList.Select(it => it.id).ToList();
|
||||
row = await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||
.Where(it => subTaskIds.Contains(it.id))
|
||||
.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)
|
||||
var schedQtySum = list.Sum(x => x.scheduled_qty);
|
||||
var planQtySum = list.Sum(x => x.plan_qty);
|
||||
if (schedQtySum < planQtySum)
|
||||
{
|
||||
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<ToolMolds>().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;
|
||||
throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
|
||||
}
|
||||
taskLogEntities.Add(taskLog);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
var taskReportLogs = new List<PrdMoTask>();
|
||||
var prdTaskList = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).ToListAsync();
|
||||
if (prdTaskList?.Count > 0)
|
||||
{
|
||||
prdTaskList.ForEach(x => x.mo_task_status = status);
|
||||
row = await db.Updateable(prdTaskList).ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
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))
|
||||
taskReportLogs.AddRange(prdTaskList);
|
||||
}
|
||||
}
|
||||
if (row > 0)
|
||||
{
|
||||
//更新子任务
|
||||
var subMoTaskList = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.parent_id)).ToListAsync();
|
||||
if (subMoTaskList?.Count > 0)
|
||||
{
|
||||
var subTaskIds = subMoTaskList.Select(it => it.id).ToList();
|
||||
row = await db.Updateable<PrdMoTask>()
|
||||
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||
.Where(it => subTaskIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
taskReportLogs.AddRange(subMoTaskList);
|
||||
}
|
||||
}
|
||||
}
|
||||
//插入操作记录日志
|
||||
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();
|
||||
taskLog.status = status;
|
||||
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<ToolMolds>().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();
|
||||
|
||||
List<PrdReportRecord> prdReportLogs = new();
|
||||
List<PrdMoTaskDefectRecord> prdTaskDefectLogs = new();
|
||||
if (taskReportLogs?.Count > 0)
|
||||
{
|
||||
foreach (var taskInfo in taskReportLogs)
|
||||
{
|
||||
//组装生产提报对象
|
||||
var material = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == taskInfo.material_id));
|
||||
var mo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == taskInfo.mo_id);
|
||||
var record = taskInfo.Adapt<PrdReportRecord>();
|
||||
record.masterial_code = material?.code;
|
||||
record.masterial_name = material?.name;
|
||||
record.plan_start_date = taskInfo.estimated_start_date;
|
||||
record.plan_end_date = taskInfo.estimated_end_date;
|
||||
record.plan_qty = taskInfo.plan_qty;
|
||||
record.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskInfo.eqp_id))?.code;
|
||||
record.mo_task_type = mo?.mo_type;
|
||||
record.status = taskInfo.mo_task_status;
|
||||
record.mo_task_id = taskInfo.id;
|
||||
//record.completed_qty = (await db.Queryable<PrdReport>().Where(it => it.mo_task_code == taskInfo.mo_task_code).SumAsync(it => it.reported_work_qty)).Value;
|
||||
prdReportLogs.Add(record);
|
||||
|
||||
//组装自检报废对象
|
||||
var sacipRecord = new PrdMoTaskDefectRecord();
|
||||
sacipRecord.material_code = material?.code!;
|
||||
sacipRecord.material_name = material?.name!;
|
||||
sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskInfo.eqp_id))?.code!;
|
||||
sacipRecord.mold_name = (await db.Queryable<ToolMolds>().FirstAsync(it => it.id == taskInfo.mold_id))?.mold_name!;
|
||||
sacipRecord.estimated_start_date = taskInfo.estimated_start_date;
|
||||
sacipRecord.estimated_end_date = taskInfo.estimated_end_date;
|
||||
sacipRecord.plan_qty = taskInfo.plan_qty;
|
||||
sacipRecord.scrap_qty = taskInfo.scrap_qty.HasValue ? taskInfo.scrap_qty.Value : 0;
|
||||
sacipRecord.status = taskInfo.mo_task_status;
|
||||
sacipRecord.create_id = _userManager.UserId;
|
||||
sacipRecord.create_time = DateTime.Now;
|
||||
sacipRecord.mo_task_id = taskInfo.id;
|
||||
sacipRecord.mo_task_code = taskInfo.mo_task_code;
|
||||
sacipRecord.mo_task_type = mo?.mo_type;
|
||||
sacipRecord.status = taskInfo.mo_task_status;
|
||||
prdTaskDefectLogs.Add(sacipRecord);
|
||||
}
|
||||
}
|
||||
row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
|
||||
row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
|
||||
}
|
||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
@@ -968,38 +1030,31 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_code == input.mo_task_code);
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
|
||||
if (report is not null)
|
||||
{
|
||||
report.mo_task_code = input.mo_task_code;
|
||||
report.mo_task_id = input.mo_task_id;
|
||||
report.reported_work_qty += input.reported_qty;
|
||||
report.prd_qty += input.reported_qty;
|
||||
|
||||
}
|
||||
else
|
||||
//if (report is not null)
|
||||
//{
|
||||
// report.mo_task_code = input.mo_task_code;
|
||||
// report.mo_task_id = input.mo_task_id;
|
||||
// report.reported_work_qty += input.reported_qty;
|
||||
// report.prd_qty += input.reported_qty;
|
||||
//}
|
||||
//else
|
||||
{
|
||||
report = input.Adapt<PrdReport>();
|
||||
report.id = SnowflakeIdHelper.NextId();
|
||||
report.reported_work_qty = input.reported_qty;
|
||||
report.prd_qty = input.reported_qty;
|
||||
report.reported_qty = input.reported_qty;
|
||||
report.create_id = _userManager.UserId;
|
||||
report.create_time = DateTime.Now;
|
||||
|
||||
}
|
||||
row = await db.Storageable(report).ExecuteCommandAsync();
|
||||
var prdTask = await db.Queryable<PrdMoTask>().FirstAsync(it => it.mo_task_code == input.mo_task_code);
|
||||
var record = prdTask.Adapt<PrdReportRecord>();
|
||||
if (prdTask != null)
|
||||
row = await db.Insertable(report).ExecuteCommandAsync();
|
||||
var master = await db.Queryable<PrdReportRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
if (master != null)
|
||||
{
|
||||
var material = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == prdTask.material_id));
|
||||
record.id = SnowflakeIdHelper.NextId();
|
||||
record.masterial_code = material?.code;
|
||||
record.masterial_name = material?.name;
|
||||
record.plan_start_date = prdTask.estimated_start_date;
|
||||
record.plan_end_date = prdTask.estimated_end_date;
|
||||
record.plan_qty = prdTask.plan_qty;
|
||||
record.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == prdTask.eqp_id))?.code;
|
||||
record.completed_qty = input.reported_qty;
|
||||
row = await db.Insertable(record).ExecuteCommandAsync();
|
||||
master.reported_work_qty += input.reported_qty;
|
||||
master.completed_qty += input.reported_qty;
|
||||
await db.Updateable(master).ExecuteCommandAsync();
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
@@ -1060,6 +1115,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
await db.Updateable<PrdMoTask>().SetColumns(it => new PrdMoTask { scrap_qty = scrapQty.Value }).Where(it => it.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
var defectRecord = await db.Queryable<PrdMoTaskDefectRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
if (defectRecord != null)
|
||||
{
|
||||
defectRecord.scrap_qty += input.scrap_qty;
|
||||
await db.Updateable(defectRecord).ExecuteCommandAsync();
|
||||
}
|
||||
var reportMaster = await db.Queryable<PrdReportRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
if (reportMaster != null)
|
||||
{
|
||||
reportMaster.completed_qty += input.scrap_qty;
|
||||
await db.Updateable(reportMaster).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
});
|
||||
return result.IsSuccess;
|
||||
@@ -1110,7 +1177,6 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (outMaterials?.Count > 0)
|
||||
{
|
||||
//var mids = await _db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
|
||||
var ids = outMaterials.Select(x => x.material_id).ToList();
|
||||
await _db.Deleteable<PrdMo>().Where(it => it.parent_id == input.mo_id).ExecuteCommandAsync();
|
||||
if (ids?.Count > 0)
|
||||
@@ -1149,19 +1215,6 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
#endregion
|
||||
|
||||
private static dynamic DictionaryToObject(IDictionary<String, Object> dictionary)
|
||||
{
|
||||
var expandoObj = new ExpandoObject();
|
||||
var expandoObjCollection = (ICollection<KeyValuePair<String, Object>>)expandoObj;
|
||||
|
||||
foreach (var keyValuePair in dictionary)
|
||||
{
|
||||
expandoObjCollection.Add(keyValuePair);
|
||||
}
|
||||
dynamic eoDynamic = expandoObj;
|
||||
return eoDynamic;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string[]> dicProperties = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
|
||||
private static T DictionaryToObject<T>(IDictionary<String, Object> dictionary) where T : class, new()
|
||||
{
|
||||
|
||||
159
ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
Normal file
159
ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.Operations;
|
||||
using NPOI.POIFS.Properties;
|
||||
using Spire.Pdf.Widget;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装生产提报服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
|
||||
public class PrdPackReportService : IPrdPackReportService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private static Dictionary<string, Tuple<string,string>> _dicWorkLine = new Dictionary<string, Tuple<string, string>>();
|
||||
public PrdPackReportService(ISqlSugarRepository<PrdMoTask> repository, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取组装包装生产任务记录,树形结构
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetList(PrdPackReportQueryInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
List<PackReportTreeOutput> trees = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
if (_dicWorkLine.Count < 1)
|
||||
{
|
||||
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
_dicWorkLine = list.ToDictionary(x => x.Id, x => Tuple.Create<string, string>(x.EnCode, x.FullName));
|
||||
}
|
||||
|
||||
var items = await _db.Queryable<PrdMoTask>().LeftJoin<BasProcess>((a, b) => a.process_id == b.id).LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code)
|
||||
.Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
|
||||
.Select((a, b, c) => new PrdMoTask
|
||||
{
|
||||
id = a.id,
|
||||
mo_task_code = a.mo_task_code,
|
||||
workline_id = a.workline_id,
|
||||
process_id = a.process_id,
|
||||
plan_start_date = a.estimated_start_date,
|
||||
plan_end_date = a.estimated_end_date,
|
||||
plan_qty = c.plan_qty,
|
||||
complete_qty = SqlFunc.Subqueryable<PrdReport>().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty),
|
||||
mo_task_status = a.mo_task_status,
|
||||
|
||||
})
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
_db.ThenMapper(items.list, it =>
|
||||
{
|
||||
it.mo_task_status = it.mo_task_status.IsNotEmptyOrNull() && dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
|
||||
});
|
||||
|
||||
if (items != null && items.list != null && items.list.Any())
|
||||
{
|
||||
foreach (var item in items.list)
|
||||
{
|
||||
var node = item.Adapt<PackReportTreeOutput>();
|
||||
node.parentId = "0";
|
||||
if (item.workline_id.IsNotEmptyOrNull())
|
||||
{
|
||||
var workLine = _dicWorkLine.ContainsKey(item.workline_id) ? (Tuple<string, string>)_dicWorkLine[item.workline_id] : null;
|
||||
if (workLine != null)
|
||||
{
|
||||
node.workline_id = $"{workLine.Item1}/{workLine.Item2}";
|
||||
}
|
||||
}
|
||||
node.plan_start_date = item.estimated_start_date.HasValue ? item.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
node.plan_end_date = item.estimated_end_date.HasValue ? item.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
await GetChild(item.id, trees, dic);
|
||||
trees.Add(node);
|
||||
}
|
||||
}
|
||||
var treeList = trees.ToTree();
|
||||
SqlSugarPagedList<PackReportTreeOutput> pagedList = new()
|
||||
{
|
||||
list = treeList,
|
||||
pagination = new Pagination
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = treeList.Count
|
||||
}
|
||||
};
|
||||
return PageResult<PackReportTreeOutput>.SqlSugarPageResult(pagedList);
|
||||
}
|
||||
|
||||
private async Task GetChild(string parentId, List<PackReportTreeOutput> nodes, Dictionary<string, object> dic)
|
||||
{
|
||||
var items = await _db.Queryable<PrdMoTask>().LeftJoin<BasProcess>((a, b) => a.process_id == b.id).LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled")
|
||||
.Select((a, b, c) => new PrdMoTask
|
||||
{
|
||||
id = a.id,
|
||||
mo_task_code = a.mo_task_code,
|
||||
workline_id = a.workline_id,
|
||||
process_id = a.process_id,
|
||||
process_code =b.process_code,
|
||||
process_name = b.process_name,
|
||||
plan_start_date = a.estimated_start_date,
|
||||
plan_end_date = a.estimated_end_date,
|
||||
plan_qty = c.plan_qty,
|
||||
complete_qty = SqlFunc.Subqueryable<PrdReport>().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty),
|
||||
mo_task_status = a.mo_task_status,
|
||||
|
||||
}).ToListAsync();
|
||||
_db.ThenMapper(items, it =>
|
||||
{
|
||||
it.mo_task_status = it.mo_task_status.IsNotEmptyOrNull() && dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
|
||||
});
|
||||
|
||||
if (items?.Count > 0)
|
||||
{
|
||||
var nsChild = items.Adapt<List<PackReportTreeOutput>>();
|
||||
for (int i = 0; i < nsChild.Count; i++)
|
||||
{
|
||||
nsChild[i].parentId = parentId;
|
||||
nsChild[i].process_id = $"{items[i].process_code}/{items[i].process_name}";
|
||||
nsChild[i].plan_start_date = items[i].estimated_start_date.HasValue ? items[i].estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
nsChild[i].plan_end_date = items[i].estimated_end_date.HasValue ? items[i].estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
}
|
||||
|
||||
nodes.AddRange(nsChild);
|
||||
foreach (var item in items)
|
||||
{
|
||||
await GetChild(item.id, nodes, dic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,9 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using DbModels;
|
||||
using JNPF.Common.Extension;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using NPOI.OpenXmlFormats;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using Tnb.BasicData;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -131,6 +134,7 @@ namespace Tnb.ProductionMgr
|
||||
var materialProp = "";
|
||||
if (prdTask != null)
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == prdTask.eqp_id);
|
||||
var mold = await db.Queryable<ToolMolds>().FirstAsync(it => it.id == prdTask.mold_id);
|
||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == prdTask.material_id);
|
||||
@@ -139,6 +143,12 @@ namespace Tnb.ProductionMgr
|
||||
materialCode = material != null ? material.code : "";
|
||||
materialName = material != null ? material.name : "";
|
||||
materialProp = material != null ? material.material_property : "";
|
||||
prdTask.workline_code = (await db.Queryable<OrganizeEntity>().Where(it => it.Id == prdTask.workline_id && it.Category == "workline").FirstAsync())?.EnCode;
|
||||
prdTask.process_code = (await db.Queryable<BasProcess>().Where(it => it.id == prdTask.process_id).FirstAsync())?.process_code;
|
||||
if (dic.ContainsKey(prdTask.mo_task_status))
|
||||
{
|
||||
prdTask.mo_task_status = dic[prdTask.mo_task_status]?.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
var res = await db.Queryable<PrdReport>().Where(it => it.mo_task_code == mo_task_code)
|
||||
@@ -152,7 +162,9 @@ namespace Tnb.ProductionMgr
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
it.icmo_qty = it.icmo_qty ?? (db.Queryable<PrdTask>().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable<PrdTask>().First(it => it.icmo_code == mo_task_code).scheduled_qty);
|
||||
it.icmo_qty = it.icmo_qty ?? (
|
||||
db.Queryable<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty < 1 ? 0 :
|
||||
(it.icmo_qty ?? db.Queryable<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty ?? 0));
|
||||
it.reported_work_qty = it.reported_work_qty ?? 0;
|
||||
it.reported_qty = it.reported_qty ?? 0;
|
||||
it.prd_qty = it.prd_qty ?? 0;
|
||||
@@ -167,7 +179,8 @@ namespace Tnb.ProductionMgr
|
||||
prdTask.reported_work_qty = res?.reported_work_qty ?? 0;
|
||||
prdTask.reported_qty = res?.reported_qty ?? 0;
|
||||
prdTask.prd_qty = res?.prd_qty ?? 0;
|
||||
|
||||
prdTask.scrap_qty = res?.scrap_qty ?? 0;
|
||||
|
||||
return prdTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Tnb.BasicData;
|
||||
using JNPF.Common.Extension;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -32,40 +35,45 @@ namespace Tnb.ProductionMgr
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public ProductionReportRecordService(ISqlSugarRepository<PrdMoTask> repository, IRunService runService, IVisualDevService visualDevService)
|
||||
public ProductionReportRecordService(ISqlSugarRepository<PrdMoTask> repository, IRunService runService, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
var pkName = "material_id_id";
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
//if (material != null)
|
||||
//{
|
||||
// row.Add("material_name", material.name);
|
||||
// row.Add($"material_attribute", material.attribute);
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (data?.list?.Count > 0)
|
||||
//{
|
||||
// var dicMoTaskStatus = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
// foreach (var row in data.list)
|
||||
// {
|
||||
// var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
// //if (dic.ContainsKey(nameof(PrdReportRecord.status)))
|
||||
// //{
|
||||
// // var statusCode = dic[nameof(PrdReportRecord.status)].ToString();
|
||||
// // row[nameof(PrdReportRecord.status)] = dicMoTaskStatus[statusCode];
|
||||
// //}
|
||||
// if (dic.ContainsKey(nameof(PrdReportRecord.mo_task_type)))
|
||||
// {
|
||||
// var moTypeId = dic[nameof(PrdReportRecord.mo_task_type)].ToString();
|
||||
// if (moTypeId.IsNotEmptyOrNull())
|
||||
// {
|
||||
// row[nameof(PrdReportRecord.mo_task_type)] = (await _dictionaryDataService.GetInfo(moTypeId)).FullName;
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
return data!;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user