分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-03-14 73a926018601d9a5a5a3d3f4c051537f45a8eff4
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Core.FreeDB;
using WIDESEA_Entity.DomainModels;
 
namespace WIDESEA_WCS.JobsPart.Common
{
    public class RestockHCJ
    {
        static FreeDB freeDB = new FreeDB();
        public static Dictionary<string, List<string>> areaForList;
        public RestockHCJ()
        {
            if (areaForList == null || areaForList.Count == 0)
            {
                areaForList = new Dictionary<string, List<string>>();
                var stationList = freeDB.Select<dt_stationinfo>().Where(x => true).ToList();
                areaForList.Add("下料区", stationList.Where(x => x.stationCode.Contains("X")).Select(x => x.stationCode).ToList());
            }
        }
        /// <summary>
        /// 更新补空托任务
        /// </summary>
        public static void HCJGetBarcode()
        {
            var tasks = freeDB.Select<dt_agvtask>().Where(x => x.agv_taskstate == "Queue").ToList();
            foreach (var task in tasks)
            {
                if (task.agv_tasktype == "TaskType_EmptyPallet")//空托任务
                {
                    if (task.agv_fromaddress == "")
                    {
                        var area = task.agv_Traytype == "SmallTray" ? "11" : "10";
                        //找1库区的空托位
                        var EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("A") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable)
                            .OrderByDescending(x => x.column).OrderBy(x => x.line).First();
                        if (EmptyStation == null)
                            EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("C") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable)
                            .OrderBy(x => x.line).OrderByDescending(x => x.column).First();
                        if (EmptyStation != null)
                        {
                            task.agv_fromaddress = EmptyStation.stationCode;
                            task.agv_taskstate = "Create";
                            freeDB.Update(task);
                        }
                    }
                }
            }
        }
    }
}