Admin
5 小时以前 1cd9280bbecf557f8978ad3839f14827ff9f4d34
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
using System;
using System.Collections.Generic;
using System.Text;
using WIDESEA.Common;
using WIDESEA.Core.ManageUser;
using WIDESEA.Entity.DomainModels;
using WIDESEA.Services.Repositories;
 
namespace WIDESEA.Services.Services
{
    public partial class CommonFunction
    {
 
        /// <summary>
        /// 创建空托盘入库功能
        /// </summary>
        /// <param name="locationinfo">目的货位</param>
        /// <param name="barcode">托盘码</param>
        /// <param name="dbcontext">dbcontext</param>
        /// <returns></returns>
        public static Dt_taskinfo AddWMSTask_EmptyPalletIn(Dt_locationinfo locationinfo, string barcode)
        {
            Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true);
            string currentModel = general_Info.general_box_empty_flag;
            if (!"empty".Equals(currentModel))
                throw new Exception("当前非空托盘入库模式,请切换模式后进行入库.");
 
            string targetAddress = GetInboundAddress(general_Info, locationinfo.location_layer);
 
            Dt_taskinfo taskinfo = new Dt_taskinfo();
            taskinfo.task_id = Guid.NewGuid();
            taskinfo.task_type = TaskType.TaskType_Empty_Pallet_Inbound.ToString();
            taskinfo.task_state = TaskState.TaskState_Create.ToString();
            taskinfo.task_barcode = barcode;
            //taskinfo.task_sn = currentModel;  //该条任务时处于正常模式下的任务还是应急模式下的任务
            taskinfo.task_materielid = "100";
            //起始货位,就是目的站台
            taskinfo.task_fromlocationid = targetAddress;
            //目的货位
            taskinfo.task_tolocationid = locationinfo.location_id;
            //起始站台
            taskinfo.task_beginstation = "20101";
            //目的站台
            taskinfo.task_endstation = targetAddress;
            taskinfo.task_grade = 0;
            taskinfo.task_isunpacked = false;
            taskinfo.task_creator = UserContext.Current.UserTrueName;
            taskinfo.task_createtime = DateTime.Now;
            Dt_taskinfoRepository.Instance.Add(taskinfo, true);
 
            return taskinfo;
        }
 
 
 
        /// <summary>
        /// 创建【组盘实托】入库功能
        /// </summary>
        /// <param name="locationinfo">目的货位</param>
        /// <param name="barcode">托盘码</param>
        /// <param name="dbcontext">dbcontext</param>
        /// <returns></returns>
        public static Dt_taskinfo AddWMSTask_BoxPalletIn(Dt_locationinfo locationinfo, string barcode, string materielid, string goodsQrCode, string task_materielType)
        {
            Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true);
            string currentModel = general_Info.general_box_empty_flag;
            if (!"box".Equals(currentModel))
                throw new Exception("当前非轴承入库模式,请切换模式后进行入库.");
 
            string targetAddress = GetInboundAddress(general_Info, locationinfo.location_layer);
 
            Dt_taskinfo taskinfo = new Dt_taskinfo();
            taskinfo.task_id = Guid.NewGuid();
            taskinfo.task_type = TaskType.TaskType_Box_Pallet_Inbound.ToString();
            taskinfo.task_state = TaskState.TaskState_Create.ToString();
            taskinfo.task_barcode = barcode;
            taskinfo.task_sn = goodsQrCode;
            taskinfo.task_materielid = materielid;
            //起始货位,就是目的站台
            taskinfo.task_fromlocationid = LayerToStation.OutLayerToStation(locationinfo.location_layer);
            //目的货位
            taskinfo.task_tolocationid = locationinfo.location_id;
            //起始站台
            taskinfo.task_beginstation = "20101";
            //目的站台
            taskinfo.task_endstation = LayerToStation.OutLayerToStation(locationinfo.location_layer);
            taskinfo.task_grade = 0;
            taskinfo.task_isunpacked = false;
            taskinfo.task_createtime = DateTime.Now;
            taskinfo.task_creator = UserContext.Current.UserTrueName;
            taskinfo.task_materielType = task_materielType;
            Dt_taskinfoRepository.Instance.Add(taskinfo, true);
 
            return taskinfo;
        }
 
 
 
        /// <summary>
        /// 创建空托盘出库功能
        /// </summary>
        /// <param name="locationinfo">目的货位</param>
        /// <param name="barcode">托盘码</param>
        /// <param name="dbcontext">dbcontext</param>
        /// <returns></returns>
        public static Dt_taskinfo AddWMSTask_EmptyPalletOut(Dt_locationinfo locationinfo, string barcode, string weight, Dt_general_info general_Info)
        {
 
            string targetAddress = GetOutboundAddress(general_Info, locationinfo.location_layer);
 
            Dt_taskinfo taskinfo = new Dt_taskinfo();
            taskinfo.task_id = Guid.NewGuid();
            taskinfo.task_type = TaskType.TaskType_Empty_Pallet_Outbound.ToString();
            taskinfo.task_state = TaskState.TaskState_Create.ToString();
            taskinfo.task_barcode = barcode;
            taskinfo.task_materielid = "100";
            //起始货位
            taskinfo.task_fromlocationid = locationinfo.location_id;
            //目的货位
            taskinfo.task_tolocationid = targetAddress;
            //起始站台
            taskinfo.task_beginstation = targetAddress;
            //目的站台
            taskinfo.task_endstation = "20101";
            taskinfo.task_grade = 0;
            taskinfo.task_isunpacked = false;
            taskinfo.task_creator = UserContext.Current.UserTrueName;
            taskinfo.task_createtime = DateTime.Now;
            taskinfo.task_weight = weight;
            Dt_taskinfoRepository.Instance.Add(taskinfo, true);
            return taskinfo;
        }
        /// <summary>
        /// 获取层
        /// </summary>
        /// <param name="general_Info"></param>
        /// <param name="layer"></param>
        /// <returns></returns>
        public static string GetInboundAddress(Dt_general_info general_Info, int layer)
        {
            string targetAddress = string.Empty;
            if ("应急模式".Equals(general_Info.general_inline_current_model))
            {
                if ("left".Equals(general_Info.general_bak_2))
                    targetAddress = LayerToStation.EmptyPalletOutLayerToStation(layer);
                else if ("right".Equals(general_Info.general_bak_2))
                    targetAddress = LayerToStation.OutLayerToStation(layer);
                else
                    throw new Exception("应急模式找不到可用提升机.");
            }
            else
                targetAddress = LayerToStation.OutLayerToStation(layer);
            return targetAddress;
        }
 
        public static string GetOutboundAddress(Dt_general_info general_Info, int layer)
        {
            string targetAddress = string.Empty;
            if ("应急模式".Equals(general_Info.general_inline_current_model))
            {
                if ("left".Equals(general_Info.general_bak_2))
                    targetAddress = LayerToStation.EmptyPalletOutLayerToStation(layer);
                else if ("right".Equals(general_Info.general_bak_2))
                    targetAddress = LayerToStation.OutLayerToStation(layer);
                else
                    throw new Exception("应急模式找不到可用提升机.");
            }
            else
                targetAddress = LayerToStation.EmptyPalletOutLayerToStation(layer);
 
            return targetAddress;
        }
    }
}