This commit is contained in:
2023-07-05 09:52:49 +08:00
parent 6779adab6f
commit af948e482d
2 changed files with 107 additions and 25 deletions

View File

@@ -0,0 +1,31 @@
namespace Tnb.ProductionMgr.Entities.Dto
{
public class ReportRecordListOutput
{
public string id { get; set; }
public string? masterial_code { get; set; } = string.Empty;
public string? masterial_name { get; set; } = string.Empty;
public string? mo_task_code { get; set; } = string.Empty;
public string? mo_task_id { get; set; } = string.Empty;
public string? mo_task_id_id { get; set; } = string.Empty;
public string? mo_task_type { get; set; } = string.Empty;
public string? plan_end_date { get; set; } = string.Empty;
public int? plan_qty { get; set; }
public int? completed_qty { get; set; }
public string? plan_start_date { get; set; } = string.Empty;
public int? reported_work_qty { get; set; }
public string? status { get; set; } = string.Empty;
public List<ReportRecordListChildrenOutput>? tablefield107 { get; set; } = new List<ReportRecordListChildrenOutput>();
}
public class ReportRecordListChildrenOutput
{
public int? reported_qty { get; set; }
public string? create_id { get; set; } = string.Empty;
public string? create_id_id { get; set; } = string.Empty;
public string? create_time { get; set; } = string.Empty;
}
}

View File

@@ -20,7 +20,12 @@ using Tnb.ProductionMgr.Interfaces;
using JNPF.Systems.Interfaces.System;
using Tnb.BasicData;
using JNPF.Common.Extension;
using JNPF.Common.Filter;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Tnb.ProductionMgr.Entities.Dto;
namespace Tnb.ProductionMgr
{
@@ -51,34 +56,80 @@ namespace Tnb.ProductionMgr
}
// 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)
// //{
// // 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!;
// }
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)
//{
// 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!;
string moTaskCode = "";
if (!string.IsNullOrEmpty(input.queryJson))
{
Dictionary<string, string> queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
if (queryJson.TryGetValue("mo_task_code", out var value))
{
moTaskCode = value;
}
}
var db = _repository.AsSugarClient();
var result = await db.Queryable<PrdReportRecord>()
.LeftJoin<DictionaryDataEntity>((a,b)=>a.mo_task_type==b.Id)
.LeftJoin<DictionaryDataEntity>((a,b,c)=>a.status==c.EnCode)
.LeftJoin<PrdMoTask>((a,b,c,d)=>a.mo_task_id==d.id)
.WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c)=>a.mo_task_code.Contains(moTaskCode))
.Select((a,b,c,d)=>new ReportRecordListOutput
{
id = a.id,
masterial_code = a.masterial_code,
masterial_name = a.masterial_name,
mo_task_code = a.mo_task_code,
mo_task_id = a.mo_task_code,
mo_task_id_id = a.mo_task_id,
mo_task_type = b.FullName,
plan_end_date = a.plan_end_date==null ? "" : a.plan_end_date.Value.ToString("yyyy-mm-dd"),
plan_start_date = a.plan_start_date==null ? "" : a.plan_start_date.Value.ToString("yyyy-mm-dd"),
plan_qty = d.scheduled_qty,
reported_work_qty = a.reported_work_qty,
completed_qty = SqlFunc.IsNull(d.reported_work_qty,0) + SqlFunc.IsNull(d.scrap_qty,0),
status = c.FullName,
tablefield107 = SqlFunc.Subqueryable<PrdReport>()
.LeftJoin<UserEntity>((x,y)=>x.create_id==y.Id)
.Where(x=>x.mo_task_code==a.mo_task_code).ToList((x,y)=>new ReportRecordListChildrenOutput
{
reported_qty = x.reported_qty,
create_id = y.RealName,
create_id_id = x.create_id,
create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm")
})
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<ReportRecordListOutput>.SqlSugarPageResult(result);
}
private async Task<dynamic> AddRecord(string id,VisualDevModelDataUpInput input)