生产提报代码提交
This commit is contained in:
@@ -75,6 +75,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 预计完工时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
public string process_code { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
public string process_name { get; set;}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料规格型号
|
||||
/// </summary>
|
||||
public string material_standard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||
|
||||
@@ -168,5 +168,8 @@ public partial class PrdMoTask : BaseEntity<string>
|
||||
/// 工序任务量
|
||||
/// </summary>
|
||||
public int? process_task_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
}
|
||||
|
||||
@@ -31,5 +31,44 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? mold_cavity_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务计划数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? icmo_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 已报工数量
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? reported_work_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 提报数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? reported_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 生产数量
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? prd_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料属性
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_property { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,6 @@ public partial class PrdMoTaskDefect : BaseEntity<string>
|
||||
/// </summary>
|
||||
public int scrap_qty { get; set; }
|
||||
|
||||
public int mo_task_type { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -78,5 +78,9 @@ public partial class PrdMoTaskDefectRecord : BaseEntity<string>
|
||||
/// 任务单编号
|
||||
/// </summary>
|
||||
public string? mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public int mo_task_type { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -53,5 +53,12 @@ public partial class PrdReportRecord : BaseEntity<string>
|
||||
/// 任务单号
|
||||
/// </summary>
|
||||
public string? mo_task_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单状态
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public int mo_task_type { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
public interface IProductionReportRecordService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace Tnb.ProductionMgr
|
||||
.Where((a, b, c) => a.material_id == materialId)
|
||||
.Select((a, b, c) => new Tnb.ProductionMgr.Entities.Dto.MoldListOutput
|
||||
{
|
||||
mold_id = a.id,
|
||||
mold_id = b.id,
|
||||
mold_code = b.mold_code,
|
||||
mold_name = b.mold_name,
|
||||
mold_type_code = b.mold_type_code,
|
||||
@@ -217,71 +217,6 @@ namespace Tnb.ProductionMgr
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据任务单号获取提报记录明细
|
||||
/// </summary>
|
||||
/// <param name="icmoCode">任务单号</param>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
///<br/> {
|
||||
///<br/> icmo_qty:任务计划数量
|
||||
///<br/> reported_work_qty:已报工数量
|
||||
///<br/> reported_qty:报工数量
|
||||
///<br/> prd_qty:生产数量
|
||||
///<br/> }
|
||||
/// </remarks>
|
||||
[HttpGet("{mo_task_code}")]
|
||||
public async Task<dynamic> GetPrdReportByIcmoCode(string mo_task_code)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var prdTask = await db.Queryable<PrdMoTask>().FirstAsync(it => it.mo_task_code == mo_task_code);
|
||||
var eqpCode = "";
|
||||
var moldCode = "";
|
||||
var materialCode = "";
|
||||
var materialName = "";
|
||||
var materialProp = "";
|
||||
if (prdTask != null)
|
||||
{
|
||||
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);
|
||||
eqpCode = eqp != null ? eqp.code : "";
|
||||
moldCode = mold != null ? mold.mold_code : "";
|
||||
materialCode = material != null ? material.code : "";
|
||||
materialName = material != null ? material.name : "";
|
||||
materialProp = material != null ? material.material_property : "";
|
||||
}
|
||||
|
||||
var res = await db.Queryable<PrdReport>().Where(it => it.mo_task_code == mo_task_code)
|
||||
.Select(it => new PrdReportOutput
|
||||
{
|
||||
icmo_qty = it.icmo_qty,
|
||||
reported_work_qty = it.reported_work_qty,
|
||||
eqp_code = eqpCode,
|
||||
mold_code = moldCode,
|
||||
material_code = materialCode,
|
||||
material_name = materialName,
|
||||
prd_qty = it.prd_qty,
|
||||
scrap_qty = SqlFunc.Subqueryable<PrdMoTaskDefect>().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(x => x.scrap_qty),
|
||||
})
|
||||
.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.reported_work_qty = it.reported_work_qty ?? 0;
|
||||
//it.reported_qty = it.reported_qty ?? 0;
|
||||
it.prd_qty = it.prd_qty ?? 0;
|
||||
it.scrap_qty = it.scrap_qty ?? 0;
|
||||
})
|
||||
.FirstAsync();
|
||||
res ??= new PrdReportOutput
|
||||
{
|
||||
icmo_qty = db.Queryable<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty,
|
||||
reported_work_qty = 0,
|
||||
prd_qty = 0,
|
||||
scrap_qty = 0,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取自检报废批次记录
|
||||
/// </summary>
|
||||
/// <param name="moTaskId">任务单Id</param>
|
||||
@@ -343,7 +278,6 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet("{moId}")]
|
||||
public async Task<dynamic> GetPrdTaskInfoByMoId(string moId, int schedType = 1)
|
||||
{
|
||||
|
||||
List<PrdMoTaskOutput> result = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
if (schedType == 1)
|
||||
@@ -369,6 +303,8 @@ namespace Tnb.ProductionMgr
|
||||
estimated_end_date = a.estimated_end_date,
|
||||
plan_qty = b.plan_qty,
|
||||
complete_qty = a.complete_qty,
|
||||
process_code = SqlFunc.Subqueryable<BasProcess>().Where(it => it.id == a.process_id).Select(it => it.process_code),
|
||||
process_name = SqlFunc.Subqueryable<BasProcess>().Where(it => it.id == a.process_id).Select(it => it.process_name),
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
@@ -381,7 +317,7 @@ namespace Tnb.ProductionMgr
|
||||
result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||
.Where((a, b, c, d) => a.mo_id == moId && string.IsNullOrEmpty(a.parent_id))
|
||||
.Where((a, b, c, d) => b.id == moId || b.parent_id == moId)
|
||||
.Select((a, b, c, d) => new PrdMoTaskOutput
|
||||
{
|
||||
mo_task_code = a.mo_task_code,
|
||||
@@ -505,8 +441,12 @@ namespace Tnb.ProductionMgr
|
||||
node.material_id_id = materialId;
|
||||
node.material_code = material?.code;
|
||||
node.material_name = material?.name;
|
||||
node.material_standard = material?.material_standard;
|
||||
}
|
||||
//
|
||||
var scheldQtyCol = nameof(PrdMo.scheduled_qty);
|
||||
|
||||
node.scheduled_qty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString();
|
||||
var queryObj = new { parent_id = node.id };
|
||||
input.superQueryJson = "";
|
||||
input.queryJson = queryObj.ToJsonString();
|
||||
@@ -527,7 +467,9 @@ namespace Tnb.ProductionMgr
|
||||
subNode.material_id_id = materialId;
|
||||
subNode.material_code = material?.code;
|
||||
subNode.material_name = material?.name;
|
||||
subNode.material_standard = material?.material_standard;
|
||||
}
|
||||
node.scheduled_qty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString();
|
||||
childNodes.Add(subNode);
|
||||
}
|
||||
trees.AddRange(childNodes);
|
||||
@@ -696,6 +638,7 @@ namespace Tnb.ProductionMgr
|
||||
moTask.id = SnowflakeIdHelper.NextId();
|
||||
moTask.create_id = _userManager.UserId;
|
||||
moTask.bom_id = input.bom_id;
|
||||
moTask.workroute_id = (await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id))?.route_id;
|
||||
moTask.workline_id = input.workline_id;
|
||||
moTask.create_time = DateTime.Now;
|
||||
moTask.schedule_type = 2;
|
||||
@@ -726,7 +669,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
row = await _db.Insertable(moTask).ExecuteCommandAsync();
|
||||
var material_h = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
|
||||
//添加生产任务操作记录日志s
|
||||
//添加生产任务操作记录日志
|
||||
var taskLog = new PrdTaskLog();
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.mo_code = (await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id))?.mo_code!;
|
||||
@@ -775,43 +718,41 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
//根据生产bomId 拆解生产子任务
|
||||
var outputList = new List<PackingSchedulingListOutput>();
|
||||
var subTaskList = await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||
.Where((a, b, c, d, e) => a.id == input.bom_id && d.ordinal < SqlFunc.Subqueryable<BasRouteD>().Where(it => it.route_id == a.route_id).OrderByDesc(it => it.ordinal).Select(it => it.ordinal))
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
{
|
||||
version = a.version,
|
||||
unit_id = a.unit_id,
|
||||
route_id = c.id,
|
||||
route_name = c.name,
|
||||
process_id = b.process_id,
|
||||
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||
num = e.num,
|
||||
ordinal = d.ordinal,
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.ToListAsync();
|
||||
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||
.Where((a, b, c, d, e) => a.id == input.bom_id)
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
{
|
||||
version = a.version,
|
||||
unit_id = a.unit_id,
|
||||
route_id = c.id,
|
||||
process_id = b.process_id,
|
||||
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||
num = e.num,
|
||||
ordinal = d.ordinal,
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.ToListAsync();
|
||||
if (subTaskList?.Count > 0)
|
||||
{
|
||||
List<PrdMoTask> subMoTasks = new();
|
||||
foreach (var item in subTaskList)
|
||||
{
|
||||
PrdMoTask subMoTask = new();
|
||||
subMoTask.schedule_type = 2;
|
||||
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||
subMoTask.parent_id = moTask.id;
|
||||
subMoTask.mo_id = input.mo_id;
|
||||
//subMoTask.bom_id = input.bom_id;
|
||||
subMoTask.material_id = item.material_id;
|
||||
subMoTask.schedule_type = 2;
|
||||
subMoTask.parent_id = moTask.id;
|
||||
subMoTask.bom_id = input.bom_id;
|
||||
subMoTask.process_id = item.process_id;
|
||||
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||
subMoTask.workroute_id = item.route_id;
|
||||
subMoTask.workline_id = input.workline_id;
|
||||
subMoTask.material_id = item.material_id;
|
||||
subMoTask.workroute_id = item.route_id;
|
||||
subMoTask.scheduled_qty = item.output_qty * moTask.scheduled_qty;
|
||||
subMoTask.scheduled_qty = input.scheduled_qty;
|
||||
subMoTask.process_task_qty = item.output_qty * moTask.scheduled_qty;
|
||||
subMoTask.estimated_start_date = input.estimated_start_date;
|
||||
subMoTask.estimated_end_date = input.estimated_end_date;
|
||||
@@ -830,45 +771,6 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
|
||||
}
|
||||
#region 注释代码
|
||||
//var bom = await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id);
|
||||
//if (bom != null && bom.route_id.IsNotEmptyOrNull())
|
||||
//{
|
||||
// var mbomProcesses = await _db.Queryable<BasMbomProcess>().Where(it => it.mbom_id == bom.id).ToListAsync();
|
||||
// var routes = await _db.Queryable<BasRouteD>().Where(it => it.route_id == bom.route_id).ToListAsync();
|
||||
// if (routes?.Count > 0)
|
||||
// {
|
||||
// var processIds = routes.Select(x => x.process_id).ToList();
|
||||
// if (processIds?.Count > 0)
|
||||
// {
|
||||
// var bomOutputs = await _db.Queryable<BasMbomOutput>().Where(it => processIds.Contains(it.process_id)).ToListAsync();
|
||||
// if (bomOutputs?.Count > 0)
|
||||
// {
|
||||
// List<PrdMoTask> subMoTasks = new();
|
||||
// foreach (var item in bomOutputs)
|
||||
// {
|
||||
// var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == item.material_id);
|
||||
// PrdMoTask subMoTask = new();
|
||||
// subMoTask.id = SnowflakeIdHelper.NextId();
|
||||
// subMoTask.schedule_type = 2;
|
||||
// subMoTask.parent_id = moTask.id;
|
||||
// subMoTask.bom_id = input.bom_id;
|
||||
// subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||
// subMoTask.workline_id = input.workline_id;
|
||||
// subMoTask.material_id = item.material_id;
|
||||
// subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
|
||||
// subMoTask.estimated_start_date = input.estimated_start_date;
|
||||
// subMoTask.estimated_end_date = input.estimated_end_date;
|
||||
// subMoTask.create_id = _userManager.UserId;
|
||||
// subMoTask.create_time = DateTime.Now;
|
||||
// subMoTasks.Add(subMoTask);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1088,7 +990,13 @@ namespace Tnb.ProductionMgr
|
||||
var record = prdTask.Adapt<PrdReportRecord>();
|
||||
if (prdTask != 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();
|
||||
@@ -1202,11 +1110,12 @@ 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).Except(mids).ToList();
|
||||
//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)
|
||||
{
|
||||
var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
|
||||
var dicOutMaterialNum = outMaterials.DistinctBy(x => x.material_id).ToDictionary(x => x.material_id, x => x.num.ParseToInt());
|
||||
List<PrdMo> subMoList = new();
|
||||
var outputMaterials = await _db.Queryable<BasMaterial>().Where(it => ids.Contains(it.id)).ToListAsync();
|
||||
foreach (var om in outputMaterials)
|
||||
|
||||
@@ -21,6 +21,8 @@ using Tnb.ProductionMgr.Interfaces;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using DbModels;
|
||||
using JNPF.Common.Extension;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -60,6 +62,12 @@ namespace Tnb.ProductionMgr
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
var statusField = "mo_task_status";
|
||||
var scheduledTypeField = nameof(PrdMoTask.schedule_type);
|
||||
data.list = data.list.Where(it => it.ContainsKey(statusField) &&
|
||||
it[statusField].IsNotEmptyOrNull() && it[statusField].ToString() != "待下发" &&
|
||||
it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1
|
||||
).ToList();
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
@@ -98,6 +106,70 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据任务单号获取提报记录明细
|
||||
/// </summary>
|
||||
/// <param name="icmoCode">任务单号</param>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
///<br/> {
|
||||
///<br/> icmo_qty:任务计划数量
|
||||
///<br/> reported_work_qty:已报工数量
|
||||
///<br/> reported_qty:报工数量
|
||||
///<br/> prd_qty:生产数量
|
||||
///<br/> }
|
||||
/// </remarks>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetPrdReportByIcmoCode([FromRoute] string mo_task_code)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var prdTask = await db.Queryable<PrdMoTask>().FirstAsync(it => it.mo_task_code == mo_task_code);
|
||||
var eqpCode = "";
|
||||
var moldCode = "";
|
||||
var materialCode = "";
|
||||
var materialName = "";
|
||||
var materialProp = "";
|
||||
if (prdTask != null)
|
||||
{
|
||||
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);
|
||||
eqpCode = eqp != null ? eqp.code : "";
|
||||
moldCode = mold != null ? mold.mold_code : "";
|
||||
materialCode = material != null ? material.code : "";
|
||||
materialName = material != null ? material.name : "";
|
||||
materialProp = material != null ? material.material_property : "";
|
||||
|
||||
}
|
||||
var res = await db.Queryable<PrdReport>().Where(it => it.mo_task_code == mo_task_code)
|
||||
.Select(it => new PrdReportOutput
|
||||
{
|
||||
icmo_qty = it.icmo_qty,
|
||||
reported_work_qty = it.reported_work_qty,
|
||||
reported_qty = it.reported_qty,
|
||||
prd_qty = it.prd_qty,
|
||||
scrap_qty = SqlFunc.Subqueryable<PrdMoTaskDefect>().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(pmtd => pmtd.scrap_qty),
|
||||
})
|
||||
.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.reported_work_qty = it.reported_work_qty ?? 0;
|
||||
it.reported_qty = it.reported_qty ?? 0;
|
||||
it.prd_qty = it.prd_qty ?? 0;
|
||||
it.scrap_qty = it.scrap_qty ?? 0;
|
||||
})
|
||||
.FirstAsync();
|
||||
prdTask.eqp_code = eqpCode;
|
||||
prdTask.mold_code = moldCode;
|
||||
prdTask.material_code = materialCode;
|
||||
prdTask.material_name = materialName;
|
||||
prdTask.icmo_qty = res?.icmo_qty;
|
||||
prdTask.reported_work_qty = res?.reported_work_qty ?? 0;
|
||||
prdTask.reported_qty = res?.reported_qty ?? 0;
|
||||
prdTask.prd_qty = res?.prd_qty ?? 0;
|
||||
|
||||
return prdTask;
|
||||
}
|
||||
|
||||
//public async Task<dynamic> GetPrdMoTaskList()
|
||||
//{
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产提报记录
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class ProductionReportRecordService : IOverideVisualDevService, IProductionReportRecordService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "25568191969061";
|
||||
private readonly ISqlSugarRepository<PrdMoTask> _repository;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public ProductionReportRecordService(ISqlSugarRepository<PrdMoTask> repository, IRunService runService, IVisualDevService visualDevService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user