执行代码清理,修复warning
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private static Dictionary<string, Tuple<string, string>> _dicWorkLine = new Dictionary<string, Tuple<string, string>>();
|
||||
private static Dictionary<string, Tuple<string, string>> _dicWorkLine = new();
|
||||
public PrdPackReportService(ISqlSugarRepository<PrdMoTask> repository, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
@@ -44,7 +44,11 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetList(PrdPackReportQueryInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException("input");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(input.stationId))
|
||||
{
|
||||
return new
|
||||
@@ -55,8 +59,8 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
List<PackReportTreeOutput> trees = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
List<OrganizeEntity> list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
if (_dicWorkLine.Count < 1)
|
||||
{
|
||||
|
||||
@@ -80,7 +84,7 @@ namespace Tnb.ProductionMgr
|
||||
endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]);
|
||||
|
||||
}
|
||||
var items = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PrdMoTask> items = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<PrdMoTask>((a, b, c, d) => a.id == d.parent_id)
|
||||
@@ -107,9 +111,15 @@ namespace Tnb.ProductionMgr
|
||||
})
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
if (start)
|
||||
{
|
||||
items.list = items.list.Where(a => startTimes[0] <= a.plan_start_date && startTimes[1] >= a.plan_start_date).ToList();
|
||||
}
|
||||
|
||||
if (end)
|
||||
{
|
||||
items.list = items.list.Where(a => endTimes[0] <= a.plan_end_date && endTimes[1] >= a.plan_end_date).ToList();
|
||||
}
|
||||
|
||||
_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() : "";
|
||||
@@ -117,13 +127,13 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (items != null && items.list != null && items.list.Any())
|
||||
{
|
||||
foreach (var item in items.list)
|
||||
foreach (PrdMoTask? item in items.list)
|
||||
{
|
||||
var node = item.Adapt<PackReportTreeOutput>();
|
||||
PackReportTreeOutput 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;
|
||||
Tuple<string, string>? workLine = _dicWorkLine.ContainsKey(item.workline_id) ? _dicWorkLine[item.workline_id] : null;
|
||||
if (workLine != null)
|
||||
{
|
||||
node.workline_id = $"{workLine.Item1}/{workLine.Item2}";
|
||||
@@ -135,24 +145,30 @@ namespace Tnb.ProductionMgr
|
||||
trees.Add(node);
|
||||
}
|
||||
}
|
||||
var treeList = trees.ToTree();
|
||||
List<PackReportTreeOutput> treeList = trees.ToTree();
|
||||
if (!string.IsNullOrEmpty(input.process))
|
||||
{
|
||||
List<PackReportTreeOutput> removelist = new List<PackReportTreeOutput>();
|
||||
foreach (var item in treeList)
|
||||
List<PackReportTreeOutput> removelist = new();
|
||||
foreach (PackReportTreeOutput item in treeList)
|
||||
{
|
||||
bool flag = false;
|
||||
if (item.process_id != null && item.process_id.Contains(input.process))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (item.children != null && item.children.Count > 0)
|
||||
{
|
||||
var childs = item.children.Adapt<List<PackReportTreeOutput>>();
|
||||
List<PackReportTreeOutput> childs = item.children.Adapt<List<PackReportTreeOutput>>();
|
||||
if (childs.Where(p => p.process_id.Contains(input.process)).Any())
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
removelist.Add(item);
|
||||
|
||||
}
|
||||
}
|
||||
removelist.ForEach(p => treeList.Remove(p));
|
||||
|
||||
@@ -172,16 +188,16 @@ namespace Tnb.ProductionMgr
|
||||
private static DateTime GetDateTimeMilliseconds(long timestamp)
|
||||
{
|
||||
long begtime = timestamp * 10000;
|
||||
DateTime dt_1970 = new DateTime(1970, 1, 1, 8, 0, 0);
|
||||
DateTime dt_1970 = new(1970, 1, 1, 8, 0, 0);
|
||||
long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度
|
||||
long time_tricks = tricks_1970 + begtime;//日志日期刻度
|
||||
DateTime dt = new DateTime(time_tricks);//转化为DateTime
|
||||
DateTime dt = new(time_tricks);//转化为DateTime
|
||||
return dt;
|
||||
|
||||
}
|
||||
private async Task GetChild(string parentId, List<PackReportTreeOutput> nodes, Dictionary<string, object> dic, string stationId)
|
||||
{
|
||||
var items = await _db.Queryable<PrdMoTask>()
|
||||
List<PrdMoTask> items = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<BasMbomProcess>((a, b, c, d) => a.mbom_process_id == d.id)
|
||||
@@ -210,7 +226,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (items?.Count > 0)
|
||||
{
|
||||
var nsChild = items.Adapt<List<PackReportTreeOutput>>();
|
||||
List<PackReportTreeOutput> nsChild = items.Adapt<List<PackReportTreeOutput>>();
|
||||
for (int i = 0; i < nsChild.Count; i++)
|
||||
{
|
||||
nsChild[i].parentId = parentId;
|
||||
@@ -220,7 +236,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (nsChild[i].workline_id.IsNotEmptyOrNull())
|
||||
{
|
||||
var workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? (Tuple<string, string>)_dicWorkLine[nsChild[i].workline_id] : null;
|
||||
Tuple<string, string>? workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? _dicWorkLine[nsChild[i].workline_id] : null;
|
||||
if (workLine != null)
|
||||
{
|
||||
nsChild[i].workline_id = $"{workLine.Item1}/{workLine.Item2}";
|
||||
@@ -229,7 +245,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
nodes.AddRange(nsChild);
|
||||
foreach (var item in items)
|
||||
foreach (PrdMoTask? item in items)
|
||||
{
|
||||
await GetChild(item.id, nodes, dic, stationId);
|
||||
}
|
||||
@@ -252,7 +268,7 @@ namespace Tnb.ProductionMgr
|
||||
};
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, e) => e.DictionaryTypeId == DictConst.PrdTaskStatusTypeId && a.mo_task_status == e.EnCode)
|
||||
@@ -309,7 +325,7 @@ namespace Tnb.ProductionMgr
|
||||
};
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||
@@ -360,11 +376,11 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
|
||||
string? mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string? status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
|
||||
DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null;
|
||||
DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null;
|
||||
List<string> statusList = new List<string>();
|
||||
List<string> statusList = new();
|
||||
if (!string.IsNullOrEmpty(status))
|
||||
{
|
||||
switch (status)
|
||||
@@ -390,7 +406,7 @@ namespace Tnb.ProductionMgr
|
||||
input.sort = "desc";
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||
@@ -469,12 +485,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
BasQrcode basQrcode = await _db.Queryable<BasQrcode>().Where(x => x.source_name == "TOOL_MOLDS" && x.code == input.mold_qrcode).FirstAsync();
|
||||
if (prdMoTask != null && basQrcode != null)
|
||||
{
|
||||
return prdMoTask.mold_id == basQrcode.source_id;
|
||||
}
|
||||
|
||||
return false;
|
||||
return prdMoTask != null && basQrcode != null ? prdMoTask.mold_id == basQrcode.source_id : (dynamic)false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user