组装包装任务管理

This commit is contained in:
qianjiawei
2023-06-27 10:47:34 +08:00
parent d2e7f5a22e
commit af455a64ee
2 changed files with 69 additions and 5 deletions

View File

@@ -14,5 +14,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
/// 生产任务编号
/// </summary>
public string mo_task_code { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public long[] estimated_start_date { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public long[] estimated_end_date { get; set; }
/// <summary>
/// 产线
/// </summary>
public string workline { get; set; }
/// <summary>
/// 工序
/// </summary>
public string process { get; set; }
}
}

View File

@@ -51,14 +51,35 @@ namespace Tnb.ProductionMgr
if (input == null) throw new ArgumentNullException("input");
List<PackReportTreeOutput> trees = new();
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
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));
}
bool start = false;
bool end=false;
DateTime[] startTimes = new DateTime[2];
DateTime[] endTimes = new DateTime[2];
if (input.estimated_start_date != null && input.estimated_start_date.Count() == 2)
{
start=true;
startTimes[0] = GetDateTimeMilliseconds(input.estimated_start_date![0]);
startTimes[1] = GetDateTimeMilliseconds(input.estimated_start_date![1]);
}
if (input.estimated_end_date != null && input.estimated_end_date.Count() == 2)
{
end = true;
endTimes[0] = GetDateTimeMilliseconds(input.estimated_end_date![0]);
endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]);
}
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.Trim())
.WhereIF(start, a => startTimes[0] <= a.estimated_start_date && startTimes[1] >= a.estimated_start_date)
.WhereIF(end, a => endTimes[0] <= a.estimated_end_date && endTimes[1] >= a.estimated_end_date)
.WhereIF(!string.IsNullOrEmpty(input.workline), a => list.Where(p => p.EnCode.Contains(input.workline) || p.FullName.Contains(input.workline)).Select(p => p.Id).ToList().Contains(a.workline_id!))
.Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
.Select((a, b, c) => new PrdMoTask
{
@@ -101,6 +122,23 @@ namespace Tnb.ProductionMgr
}
}
var treeList = trees.ToTree();
if (!string.IsNullOrEmpty(input.process))
{
foreach (var item in treeList)
{
bool flag = false;
if (item.process_id != null && item.process_id.Contains(input.process))
flag = true;
if (item.children != null)
{
List<PackReportTreeOutput> childs = (List<PackReportTreeOutput>)(Object)item.children;
if (childs.Where(p => p.process_id.Contains(input.process)).Any())
flag = true;
}
if (!flag)
treeList.Remove(item);
}
}
SqlSugarPagedList<PackReportTreeOutput> pagedList = new()
{
list = treeList,
@@ -113,15 +151,24 @@ namespace Tnb.ProductionMgr
};
return PageResult<PackReportTreeOutput>.SqlSugarPageResult(pagedList);
}
private static DateTime GetDateTimeMilliseconds(long timestamp)
{
long begtime = timestamp * 10000;
DateTime dt_1970 = new DateTime(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
return dt;
}
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)
.LeftJoin<BasMbomProcess>((a,b,c,d)=>a.mbom_process_id==d.id)
.LeftJoin<BasMbomProcess>((a, b, c, d) => a.mbom_process_id == d.id)
.Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled")
.OrderBy((a,b,c,d)=>d.ordinal)
.OrderBy((a, b, c, d) => d.ordinal)
.Select((a, b, c) => new PrdMoTask
{
id = a.id,
@@ -134,7 +181,7 @@ namespace Tnb.ProductionMgr
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),
complete_qty = a.reported_work_qty+a.scrap_qty,
complete_qty = a.reported_work_qty + a.scrap_qty,
mo_task_status = a.mo_task_status,
}).ToListAsync();
@@ -152,7 +199,7 @@ namespace Tnb.ProductionMgr
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") : "";
if (nsChild[i].workline_id.IsNotEmptyOrNull())
{
var workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? (Tuple<string, string>)_dicWorkLine[nsChild[i].workline_id] : null;