生产相关列表倒叙,生产工单列表重写
This commit is contained in:
@@ -1,28 +1,16 @@
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using Aop.Api.Domain;
|
||||
using DbModels;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Extensitions.EventBus;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Crypto.Generators;
|
||||
using Senparc.Weixin.Work.AdvancedAPIs.MailList;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
@@ -74,43 +62,103 @@ namespace Tnb.ProductionMgr
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
// private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
// {
|
||||
// var db = _repository.AsSugarClient();
|
||||
// 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 (dic.ContainsKey("material_id"))
|
||||
// {
|
||||
// row["material_id"] = material.code + "/" + material.name;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (dic.ContainsKey("unit_id"))
|
||||
// {
|
||||
// string unitId = dic["unit_id"]?.ToString() ?? "";
|
||||
// var unit = await db.Queryable<DictionaryDataEntity>().SingleAsync(x => x.Id == unitId);
|
||||
// row["unit_id"] = unit?.FullName ?? "";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return data!;
|
||||
// }
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
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)
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string moCode = queryJson.ContainsKey("mo_code") ? queryJson["mo_code"].ToString() : "";
|
||||
string moStatus = queryJson.ContainsKey("mo_status") ? queryJson["mo_status"].ToString() : "";
|
||||
string combineMoCode = queryJson.ContainsKey("combine_mo_code") ? queryJson["combine_mo_code"].ToString() : "";
|
||||
var result = await db.Queryable<PrdMo>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b, c) => c.EnCode == DictConst.MeasurementUnit)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d) => c.Id == d.DictionaryTypeId && a.unit_id == d.Id)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e) => a.mo_status == e.Id)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e,f) => a.mo_type==f.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(moCode), (a, b, c, d, e) => a.mo_code.Contains(moCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(combineMoCode),
|
||||
(a, b, c, d, e) => a.combine_mo_code.Contains(combineMoCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(moStatus), (a, b, c, d, e) => a.mo_status == moStatus)
|
||||
.Where(a=>SqlFunc.IsNullOrEmpty(a.parent_id))
|
||||
.OrderByDescending(a=>a.create_time)
|
||||
.Select((a, b, c, d, e,f) => new PrdMoListOuput
|
||||
{
|
||||
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)
|
||||
id = a.id,
|
||||
mo_type = f.FullName,
|
||||
mo_source = a.mo_source=="1" ? "ERP同步" : "新建/导入",
|
||||
mo_code = a.mo_code,
|
||||
plan_start_date = a.plan_start_date==null ? "" : a.plan_start_date.Value.ToString("yyyy-MM-dd"),
|
||||
plan_end_date = a.plan_end_date==null ? "" : a.plan_end_date.Value.ToString("yyyy-MM-dd"),
|
||||
material_id = b.code+"/"+b.name,
|
||||
material_id_id = b.id,
|
||||
plan_qty = a.plan_qty,
|
||||
unit_id = d.FullName,
|
||||
mo_status = e.FullName,
|
||||
remark = a.remark,
|
||||
children = SqlFunc.Subqueryable<PrdMo>()
|
||||
.LeftJoin<BasMaterial>((aa, bb) => aa.material_id == bb.id)
|
||||
.LeftJoin<DictionaryTypeEntity>((aa, bb, cc) => cc.EnCode == DictConst.MeasurementUnit)
|
||||
.LeftJoin<DictionaryDataEntity>((aa, bb, cc, dd) => cc.Id == dd.DictionaryTypeId && aa.unit_id == dd.Id)
|
||||
.LeftJoin<DictionaryDataEntity>((aa, bb, cc, dd, ee) => aa.mo_status == ee.Id)
|
||||
.LeftJoin<DictionaryDataEntity>((aa, bb, cc, dd, ee,ff) => aa.mo_type==ff.Id)
|
||||
.Where(aa=>aa.parent_id==a.id)
|
||||
.ToList((aa,bb,cc,dd,ee,ff)=>new PrdMoListOuput
|
||||
{
|
||||
row.Add("material_name", material.name);
|
||||
row.Add($"material_attribute", material.attribute);
|
||||
if (dic.ContainsKey("material_id"))
|
||||
{
|
||||
row["material_id"] = material.code + "/" + material.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (dic.ContainsKey("unit_id"))
|
||||
{
|
||||
string unitId = dic["unit_id"]?.ToString() ?? "";
|
||||
var unit = await db.Queryable<DictionaryDataEntity>().SingleAsync(x => x.Id == unitId);
|
||||
row["unit_id"] = unit?.FullName ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
id = aa.id,
|
||||
mo_type = ff.FullName,
|
||||
mo_source = aa.mo_source=="1" ? "ERP同步" : "新建/导入",
|
||||
mo_code = aa.mo_code,
|
||||
plan_start_date = aa.plan_start_date==null ? "" : aa.plan_start_date.Value.ToString("yyyy-MM-dd"),
|
||||
plan_end_date = aa.plan_end_date==null ? "" : aa.plan_end_date.Value.ToString("yyyy-MM-dd"),
|
||||
material_id = bb.code+"/"+bb.name,
|
||||
material_id_id = bb.id,
|
||||
plan_qty = aa.plan_qty,
|
||||
unit_id = dd.FullName,
|
||||
mo_status = ee.FullName,
|
||||
remark = aa.remark,
|
||||
})
|
||||
}).ToPagedListAsync(input.currentPage, int.MaxValue);
|
||||
return PageResult<PrdMoListOuput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
|
||||
#region Get
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user