xiaojiao
2026-03-23 f02d3a8ffc05a10a64859b2a16d5d43c8abb0fb9
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WIDESEA.Common;
using WIDESEA.Core.Utilities;
using WIDESEA.Entity.DomainModels;
using WIDESEA.Services.Repositories;
 
namespace WIDESEA.Services.Services
{
    public partial class CommonFunction
    {
        public static string[] leftoutboundStation = new string[] { "70114", "70110", "70106", "70103" };
        public static string[] rightoutboundStation = new string[] { "70113", "70109", "70104", "70101" };
        public static WebResponseContent QueryHomeInfo(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                DateTime date = DateTime.Now.Date;
                //空货位
                int emptyCount = Dt_locationinfoRepository.Instance.Find(r => r.location_state == LocationState.LocationState_Empty.ToString() && !r.location_islocked).Count();
                //异常货位
                int errorCount = Dt_locationinfoRepository.Instance.Find(r => r.location_state == LocationState.LocationState_Error.ToString()).Count();
                //入库任务
                int inBoxCount = Dt_taskinfo_htyRepository.Instance.Find(r => r.task_type == TaskType.TaskType_Box_Pallet_Inbound.ToString()
                    && r.task_createtime > date).Count();
                //测量任务
                int measureCount = Dt_taskinfo_htyRepository.Instance.Find(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()
                    && r.task_createtime > date).Count();
 
                //库位使用率
                List<int> locationCount = new List<int>();
                for (int i = 1; i < 9; i++)
                {
                    int lo = Dt_locationinfoRepository.Instance.Find(r => r.location_layer == i && (r.location_state != LocationState.LocationState_Empty.ToString() || r.location_islocked)).Count();
                    locationCount.Add(lo);
                }
                //库存统计
                List<VV_ContainerInfo> listContainer = VV_ContainerInfoRepository.Instance.Find(r => r.location_state == LocationState.LocationState_Stored.ToString());
                List<containerCount> containerCount = new List<containerCount>();
                if (null != listContainer && listContainer.Count > 0)
                {
                    foreach (var item in listContainer.GroupBy(r => new { r.materiel_id, r.containerdtl_type }))
                    {
                        //  item.GroupBy(r => r.containerdtl_standard);
                        containerCount.Add(new containerCount()
                        {
                            materiel_id = item.Key.materiel_id,
                            containerdtl_type = item.Key.containerdtl_type,
                            newCount = item.Where(r => r.containerdtl_standard == "R0").Count(),
                            oldCount = item.Where(r => r.containerdtl_standard == "R1").Count(),
                            count = item.Count()
                        });
                    }
 
                    containerCount = containerCount.OrderByDescending(r => r.count).ToList();
                }
                List<object> leftCount = new List<object>();
                List<object> rightCount = new List<object>();
                foreach (var item in leftoutboundStation)
                {
                    leftCount.Add(Dt_taskinfo_htyRepository.Instance.Find(r => r.task_type == TaskType.TaskType_Box_Pallet_Outbound.ToString() && r.task_endstation == item
                    && r.task_createtime >= date).Count());
                }
 
                foreach (var item in rightoutboundStation)
                {
                    rightCount.Add(Dt_taskinfo_htyRepository.Instance.Find(r => r.task_type == TaskType.TaskType_Box_Pallet_Outbound.ToString() && r.task_endstation == item
                    && r.task_createtime >= date).Count());
                }
 
                //List<object> dateHty = new List<object>();
                //List<object> outboundHty = new List<object>();
                //List<object> inboundHty = new List<object>();
                //List<object> measureHty = new List<object>();
                //int z = -6;
                //for (int i = 0; i < 7; i++)
                //{
                //    DateTime dateTime = date.AddDays(z);
                //    dateHty.Add(dateTime.ToString("MM.dd"));
                //    outboundHty.Add(Dt_taskinfo_htyRepository.Instance.Find(r => r.task_createtime >= dateTime && r.task_createtime < dateTime.AddDays(1) && r.task_type == TaskType.TaskType_Box_Pallet_Outbound.ToString() && r.task_endstation != "20101")?.Count());
                //    inboundHty.Add(Dt_taskinfo_htyRepository.Instance.Find(r => r.task_createtime >= dateTime && r.task_createtime < dateTime.AddDays(1) && r.task_type == TaskType.TaskType_Box_Pallet_Inbound.ToString())?.Count());
                //    measureHty.Add(Dt_taskinfo_htyRepository.Instance.Find(r => r.task_createtime >= dateTime && r.task_createtime < dateTime.AddDays(1) && r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString())?.Count());
                //    z += 1;
                //}
 
                int qty = listContainer.FindAll(r => r.containerdtl_text3 == "合格").Count();
                int unqty = listContainer.FindAll(r => r.containerdtl_text3 == "不合格").Count();
                //int wiatqty = listContainer.FindAll(r => string.IsNullOrEmpty(r.containerdtl_text3)).Count();//
                int wiatqty = listContainer.FindAll(r => r.containerdtl_text1 == "未测量").Count();
 
                List<int> containerTotol = new List<int>() { unqty, qty, wiatqty, listContainer.Count() };
                content.OK(data: new
                {
                    emptyCount = emptyCount,
                    errorCount = errorCount,
                    inBoxCount = inBoxCount,
                    measureCount = measureCount,
                    locationCount = locationCount,
                    leftCount = leftCount,
                    rightCount = rightCount,
                    //dateHty = dateHty,
                    //outboundHty = outboundHty,
                    //inboundHty = inboundHty,
                    //measureHty = measureHty,
                    containerCount = containerCount,
                    containerTotol = containerTotol
                });
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
    }
    public class containerCount
    {
        public string materiel_id { get; set; }
        public string containerdtl_type { get; set; }
        public int newCount { get; set; }
        public int oldCount { get; set; }
 
        public int count { get; set; }
    }
}