EchartsDataApp.cs
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Infrastructure;
using Microsoft.AspNetCore.Hosting;
using System;
using System.Dynamic;
using System.Linq;
using WebRepository;
namespace WebApp
{
/// <summary>
/// 仓库地图
/// </summary>
public class EchartsDataApp
{
private IUnitWork _unitWork;
TableData result = new TableData();
public EchartsDataApp(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public TableData GetWeekTask()
{
DateTime dt = DateTime.Now.AddDays(-6).Date;
dynamic sp = new ExpandoObject();
var weektask = _unitWork.Find<InventoryTransaction>(a => a.CreateTime > dt).GroupBy(a =>a.Type).SelectMany(g => g.GroupBy(b => ((DateTime)b.CreateTime).ToString("yyyy-MM-dd"))).Select(g => (new { name = g.Key, count = g.Count(),type=g.AsQueryable().Select(u=>u.Type).First() })).OrderBy(a => a.name);
result.data = weektask.ToList();
return result;
}
public TableData GetWareCellCount()
{
var lct = _unitWork.Find<Location>(null).GroupBy(a => a.Status).SelectMany(g => g.GroupBy(b => b.Status)).Select(g => (new { name = g.Key, count = g.Count(), Status = g.AsQueryable().Select(u => u.Status).First() })).OrderBy(a => a.name);
result.data = lct.ToList();
return result;
}
public TableData GetWaitTask()
{
//var task = _unitWork.Find<TaskDetail>(null).GroupBy(a => a.TaskType ).SelectMany(g => g.GroupBy(b => b.TaskType )).Select(g => (new { name = g.Key, count = g.Count(), TaskType = g.AsQueryable().Select(u => u.TaskType).First() })).OrderBy(a => a.name);
var task = from t in _unitWork.Find<TaskDetail>(null)
group t by new { t.TaskType, t.ContainerCode} into g
select new
{
value = g.Count(),
name = g.Key.TaskType,
};
result.data = task.ToList();
return result;
}
public TableData GetMaterielByGroup()
{
var mcdata = from it in _unitWork.Find <Inventory>(null)
group it by it.MaterialCode into g
select new
{
value = g.Sum(p => decimal.Parse(p.Qty.ToString())),
name = g.Key,
};
result.data = mcdata.ToList().OrderByDescending(u=>u.value);
return result;
}
}
}