schangxiang@126.com
2025-07-30 a16904bd86f89e97a5e507e08003506c5dd8642e
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
 
using System.Web.UI.WebControls;
using WZ.Useful.Commons;
 
using System.Windows.Forms;
using WMS.Model;
using Newtonsoft.Json;
using WMS.yunneiWCS;
 
 
namespace WMS.Untils
{
    /// <summary>
    /// WMS公共刮工具类
    /// </summary>
    public class WMSCommon
    {
        /// <summary>
        /// 是否是呆滞库位
        /// </summary>
        /// <param name="basicDataSetForStayMonths"></param>
        /// <param name="store"></param>
        /// <returns></returns>
        public static bool isStatyMonths(string basicDataSetForStayMonths, MyVproductStock store)
        {
            if (store.createTime != null)
            {
                if (store.createTime <= DateTime.Now.AddMonths(-Convert.ToInt32(basicDataSetForStayMonths)))
                {
                    return true;
                }
            }
            return false;
        }
 
        /// <summary>
        /// 是否是空托盘
        /// </summary>
        /// <param name="store"></param>
        /// <returns></returns>
        public static bool isEmptySalver(MyVproductStock store)
        {
            if (!string.IsNullOrEmpty(store.materialCode) && (
                    store.materialCode == "GT-KTP" || store.materialCode == "GG-KTP"
                ))
            {
                return true;
            }
            return false;
        }
 
        /// <summary>
        /// 是否是货物
        /// </summary>
        /// <param name="store"></param>
        /// <returns></returns>
        public static bool isCatogroy(MyVproductStock store)
        {
            if (!string.IsNullOrEmpty(store.materialCode) && (
                    store.materialCode != "GT-KTP" && store.materialCode != "GG-KTP"
                ))
            {
                return true;
            }
            return false;
        }
 
        /// <summary>
        /// 公共处理发送AGV的结果
        /// </summary>
        /// <param name="result"></param>
        public static void SendToAGVResult(string result)
        {
            if (string.IsNullOrEmpty(result))
            {//成功
                //MessageBox.Show("发送AGV任务成功");
            }
            else
            {
                AgvRetModel agvRet = JsonConvert.DeserializeObject<AgvRetModel>(result);
                if (agvRet != null)
                {
                    MessageBox.Show("发送AGV任务失败," + agvRet.message);
                }
                else
                {
                    MessageBox.Show("发送AGV任务失败");
                }
            }
        }
 
        /// <summary>
        /// 根据语言配置分页显示
        /// </summary>
        /// <param name="maxPage"></param>
        /// <param name="dataCount"></param>
        /// <returns></returns>
        public static string ChangeLanguagForPage(int maxPage, int dataCount)
        {
            if (WMSFrmMain.LanguageFlg == 0)
            {
                //中文
                return string.Format("共{0}页,共{1}条", maxPage, dataCount);
            }
            //英文
            return string.Format("page count:{0},data count:{1}", maxPage, dataCount);
        }
        #region 【尝试修改版,周二测试,先将屏幕高度拉平,居中】 出入库提示界面,居中显示到第二个屏幕上
 
 
        /// <summary>
        ///  居中显示到第二个屏幕上
        /// </summary>
        /// <param name="frm"></param>
        public static void ShowScreen2ForCenter(Form frm)
        {
            var screens = Screen.AllScreens;
            if (screens.Length > 1)
            {//如果是两个屏幕,则默认要显示到副屏幕上
                //设置居中屏幕显示
                //if (WMSFrmMain.currentStoreId == 1)
                //{//A区屏幕
                //    var secondeScreen = GetSeconedScreen();
                //    frm.Top = (secondeScreen.Bounds.Height - frm.Height) / 2;
                //    //frm.Left = Screen.PrimaryScreen.WorkingArea.Width + (secondeScreen.Bounds.Width - frm.Width) / 2;
                //    frm.Left = (0 - secondeScreen.WorkingArea.Width * 2) + (secondeScreen.WorkingArea.Width * 2 - frm.Width) / 2;//修改 【EditBy shaocx,2021-07-12】
                //}
                //else
                //{//C区屏幕
                //    var secondeScreen = GetSeconedScreen();
                //    frm.Top = (secondeScreen.Bounds.Height - frm.Height) / 2;
                //    frm.Left = (0 - secondeScreen.WorkingArea.Width * 2) + (secondeScreen.WorkingArea.Width * 2 - frm.Width) / 2;
                //}
            }
            else
            {
                //设置居中屏幕显示
                frm.Top = (screens[0].Bounds.Height - frm.Height) / 2;
                frm.Left = (Screen.PrimaryScreen.WorkingArea.Width - frm.Width) / 2;
            }
        }
 
        //*/
 
        #endregion
 
 
 
        /// <summary>
        ///  显示到第二个屏幕上(副屏上)
        /// </summary>
        /// <param name="frm"></param>
        public static void ShowScreen2(Form frm)
        {
            var screens = Screen.AllScreens;
            if (screens.Length > 1)
            {//如果是两个屏幕,则默认要显示到副屏幕上
                //if (WMSFrmMain.currentStoreId == 1)
                //{//A区屏幕
                //    //设置居中屏幕显示
                //    frm.Top = 0;
                //    //frm.Left = Screen.PrimaryScreen.WorkingArea.Width;
                //    frm.Left = 0 - Screen.PrimaryScreen.WorkingArea.Width;//修改 【EditBy shaocx,2021-07-12】
                //}
                //else
                //{//C区屏幕
                //    //设置居中屏幕显示
                //    frm.Top = 0;
                //    var secondeScreen = GetSeconedScreen();
                //    frm.Left = 0 - secondeScreen.WorkingArea.Width;
                //}
            }
        }
 
        /// <summary>
        /// 获取副屏幕对象
        /// </summary>
        /// <returns></returns>
        private static Screen GetSeconedScreen()
        {
            var screens = Screen.AllScreens;
            if (screens.Length > 1)
            {
                foreach (var item in screens)
                {
                    if (!item.Primary)
                    {
                        return item;
                    }
                }
            }
            return screens[0];
        }
 
        /// <summary>
        /// 下拉框绑定库位号
        /// </summary>
        /// <param name="cb"></param>
        public static void LoadAllSotreId(System.Windows.Forms.ComboBox cb)
        {
            //try
            //{
            //    cb.Items.Clear();
            //    var _StoreEnum = StoreEnum.一号库;
            //    cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
            //    _StoreEnum = StoreEnum.二号库;
            //    cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
            //    return true;
            //}
            //catch (Exception ex)
            //{
            //    MessageUtil.ShowError("绑定库位号出现错误:" + ex.Message);
            //    return false;
            //}
        }
 
        /// <summary>
        /// 下拉框绑定库位号
        /// </summary>
        /// <param name="cb"></param>
        public static bool LoadSotreId(System.Windows.Forms.ComboBox cb)
        {
            try
            {
                //cb.Items.Clear();
                //var _StoreEnum = Convert.ToInt32(StoreEnum.一号库);
                //cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
                //var _StoreEnum2 = Convert.ToInt32(StoreEnum.二号库);
                //cb.Items.Add(new ListItem(_StoreEnum2.ToString(), Convert.ToInt32(_StoreEnum2).ToString()));
                return true;
            }
            catch (Exception ex)
            {
                MessageUtil.ShowError("绑定库位号出现错误:" + ex.Message);
                return false;
            }
        }
 
        /// <summary>
        /// 下拉框绑定库位号
        /// </summary>
        /// <param name="cb"></param>
        public static bool LoadSotreIdLocal(System.Windows.Forms.ComboBox cb)
        {
            try
            {
                //cb.Items.Clear();
                //var _StoreEnum = BBConfigHelper.GetCurrentStoreIdConfig();
                //cb.Items.Add(new ListItem(_StoreEnum.ToString(), Convert.ToInt32(_StoreEnum).ToString()));
                return true;
            }
            catch (Exception ex)
            {
                MessageUtil.ShowError("绑定库位号出现错误:" + ex.Message);
                return false;
            }
        }
 
        /// <summary>
        /// 获取当前程序配置的管理员密码
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentManagerPassword()
        {
            var _ManagerPassword = System.Configuration.ConfigurationManager.AppSettings["ManagerPassword"].ToString();
 
 
            if (string.IsNullOrEmpty(_ManagerPassword))
            {
                throw new Exception("没有找到管理员密码的配置,请检查!");
            }
 
            return _ManagerPassword;
        }
 
        ///// <summary>
        ///// 获取当前程序配置的库位号
        ///// </summary>
        ///// <returns></returns>
        //public static StoreEnum GetCurrentStoreIdConfig(string storeid)
        //{
        //    var currentStoreId = System.Configuration.ConfigurationManager.AppSettings[storeid].ToString();
 
 
        //    if (string.IsNullOrEmpty(currentStoreId))
        //    {
        //        throw new Exception("没有找到库存的配置,请检查!");
        //    }
 
        //    if (!System.Enum.IsDefined(typeof(StoreEnum), Convert.ToInt32(currentStoreId)))
        //    {
        //        throw new Exception("库位代码" + currentStoreId + "不在指定的范围内");
        //    }
        //    return (StoreEnum)System.Enum.Parse(typeof(StoreEnum), currentStoreId);
        //}
    }
}