#
mrzhssss
2022-09-22 110f3977b399dd117ce1af49ca792d602e2ba9a9
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DevComponents.DotNetBar.Controls;
using System.Windows.Forms;
using System.Drawing;
using System.Data.SqlClient;
using com.force.json;
 
namespace WCS
{
    public class WcsUpdate
    {
        /// <summary>
        /// 添加ListView界面显示
        /// </summary>
        /// <param name="le">listview</param>
        /// <param name="seq">需要</param>
        /// <param name="Errif">异常信息</param>
        /// <param name="arg_string">显示内容</param>
        public static void add_dw_log(ListViewEx le, string seq, string Errif, string arg_string)
        {
            try
            {
                ListViewItem lvi = new ListViewItem();
                lvi.SubItems[0].Text = "【" + DateTime.Now.ToString() + "】" + seq + arg_string;
                if (Errif == "N")
                {
                    lvi.ForeColor = Color.Black;
                }
                else if (Errif == "E")
                {
                    lvi.ForeColor = Color.Red;
                }
                else if (Errif == "P")
                {
                    lvi.ForeColor = Color.Blue;
                }
                le.Items.Add(lvi);
                le.EnsureVisible(le.Items.Count - 1);
            }
            catch (Exception em)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.SubItems[0].Text = "【" + DateTime.Now.ToString() + "】" + seq + arg_string + "异常:" + em.Message;
                le.Items.Add(lvi);
            }
        }
 
        /// <summary>
        /// 读取wms命令档wms_command表,生成出库工作档
        /// </summary>
        /// <param name="le"></param>
        /// <param name="seq"></param>
        /// <returns></returns>
        public static void ProcOutToWorkData(ListViewEx le, string seq)
        {         
            string s_wmsId = "", s_boxId = "", s_location = "", s_locno = "";
            string ls_error_memo = "", sql = "";
            int i_station = 0, i_wrkno = 0;
            DateTime ldt_date = System.DateTime.Now;
 
            add_dw_log(le, seq, "N", "--处理WMS命令档,生成出库工作档......");
 
            try
            {
                //sql = "select * from asr_wrk_masp where wrk_sts<5 or (wrk_sts>10 and wrk_sts<14)";
                //int count = Common.ExecAsrsSelect1(sql);
                //if (Common.GetWrkOutCount() > 0 || Common.GetWrkInCount() > 0)
                if (Common.plc_s_loading[0, 0] == "Y" || Common.plc_s_loading[0, 1] == "Y")
                {
                    add_dw_log(le, seq, "N", "--站点有物,无法生成出库工作档......");
                    return;
                }
                if (Common.GetWrkCount() > 0)
                {
                    add_dw_log(le, seq, "N", "--工作档中存在未完成资料,无法生成出库工作档......");
                    return;
                }
 
                sql = "select top 1 wmsId,boxId,station,loc_no from wms_command ";
                sql += " where messageName='StackerStoreOut' and status<>'Y' order by status";
                DataView dv = Common.ExecAsrsSelect(sql);
                if (dv.Count <= 0)
                {
                    return;
                }
                foreach (DataRowView drow in dv)
                {
                    s_wmsId = drow[0].ToString();
                    s_boxId = drow[1].ToString();
                    i_station = Int32.Parse(drow[2].ToString());
                    s_location = drow[3].ToString();
                }
                add_dw_log(le, "", "P", "   " + seq + ".1 正在处理周转箱单号:" + s_boxId);
 
                sql = "select loc_no from asr_stk_mast where boxId='" + s_boxId + "' and loc_sts='D'";
                dv = Common.ExecAsrsSelect(sql);
                if (dv.Count <= 0)
                {
                    ls_error_memo = "   " + seq + ".2 编号" + s_boxId + "的周转箱不存在或非在库状态,请检查";
                    add_dw_log(le, "", "E", ls_error_memo);                    
                    goto re;
                }
                foreach (DataRowView drow in dv)
                {                    
                    s_locno = drow[0].ToString();
                }
                if (s_location != s_locno && s_location != "")
                {
                    ls_error_memo = "   " + seq + ".3 WMS下发的周转箱编号(" + s_boxId + ")出库库位(" + s_location + ")与ASRS库存库位(" + s_locno + ")不符";
                    add_dw_log(le, "", "E", ls_error_memo); 
                    goto re;
                }
 
                i_wrkno = Common.GetWrkno(2);
                sql = "insert into asr_wrk_masp(wrk_no,wrk_sts,io_type,crn_no,io_pri,source_loc_no,sta_no,source_sta_no,wmsId,boxId) ";
                sql += " values(" + i_wrkno + ",11,110,1,13.5,'" + s_locno + "',1,2,'" + s_wmsId + "','" + s_boxId + "'); ";
                sql += " update asr_stk_mast set loc_sts='R' where loc_no='" + s_locno + "'; ";
                sql += " update wms_command set status='Y' where wmsId='" + s_wmsId + "' and boxId='" + s_boxId + "';";
                SqlConnection sqlconn = new SqlConnection(Common.sqlcon);
                sqlconn.Open();
                SqlTransaction sqltrans = sqlconn.BeginTransaction();                
                SqlCommand sqlcmd = new SqlCommand(sql, sqlconn);
                sqlcmd.Transaction = sqltrans;
                try
                {
                    sqlcmd.ExecuteNonQuery();
                    sqltrans.Commit();
                }
                catch (SqlException t)
                {
                    sqltrans.Rollback();
                    //sqlcommon.Close();
                    ls_error_memo = "   " + seq + ".4 插入工作主档[asr_wrk_masp]错误 !单号:" + s_boxId + " 异常:" + t.Message;
                    add_dw_log(le, "", "E", ls_error_memo);
                    goto re;
                }
                finally
                {
                    sqlcmd.Dispose();
                    sqlconn.Dispose();
                }
                return;
 
                re:
                sql = "update wms_command set status='X' where wmsId='" + s_wmsId + "' and boxId='" + s_boxId + "'";
                bool result = Common.ExecAsrsModify(sql);
                if (!result)
                {
                    ls_error_memo = "   " + seq + ".5 更新wms命令档失败!wmsId:" + s_wmsId + "boxId:" + s_boxId;
                    add_dw_log(le, "", "E", ls_error_memo);
                }
            }
            catch (Exception em)
            {
                ls_error_memo = "   " + seq + ".6 处理待处理档生成出库工作档失败:" + em.Message;
                add_dw_log(le, "", "E", ls_error_memo);
            }
        }
 
        /// <summary>
        /// 处理工作档中工作状态为4和14、6的资料,更新库存档、待处理档,并添加上报wms任务队列commandQueue
        /// </summary>
        public static void ProcWorkMast(ListViewEx le, string seq)
        {
            string ls_error_memo = "" ,sql = "";
            int li_wrk_no = 0, li_wrk_sts = 0, li_io_type = 0, li_sta_no = 0, li_source_sta_no = 0, li_wrk_model = 1;
            string ls_loc_no = "", ls_source_loc_no = "", ls_wmsId = "", ls_boxId = "";
            DateTime ldt_date = System.DateTime.Now;
            add_dw_log(le, seq, "N", "--处理工作档 (status=4,14)......");
            try
            {
                try
                {
                    DataView dv = Common.ExecAsrsSelect("select getdate() from sys_dual");
                    foreach (System.Data.DataRowView drow in dv)
                    {
                        ldt_date = Convert.ToDateTime(drow[0]);
                    }
                }
                catch (SqlException)
                {
                    return;
                }
 
                sql = "select wrk_no,wrk_sts,io_type,loc_no,sta_no,source_sta_no,source_loc_no,wmsId,boxId,wrk_model ";
                sql += " from asr_wrk_masp where (((wrk_sts = 4 Or wrk_sts = 14 ) and io_type <> 103 and io_type <> 104 and io_type <> 107 ) or (wrk_sts = 2 and io_type=6)) ";
                sql += " order by upd_mk,io_time,wrk_no";
                DataView dv_wrkmast = Common.ExecAsrsSelect(sql);
                if (dv_wrkmast==null || dv_wrkmast.Count < 1)
                {
                    add_dw_log(le, "", "N", "   " + seq + ".1 工作档 [asr_wrk_masp] 没有资料!");
                    return;
                }
                foreach (DataRowView drow_wrkmast in dv_wrkmast)
                {
                    li_wrk_no = Convert.ToInt32(drow_wrkmast[0]);
                    li_wrk_sts = Convert.ToInt32(drow_wrkmast[1]);
                    li_io_type = Convert.ToInt32(drow_wrkmast[2]);
                    ls_loc_no = drow_wrkmast[3].ToString();
                    li_sta_no = Convert.ToInt32(drow_wrkmast[4]);
                    li_source_sta_no = Convert.ToInt32(drow_wrkmast[5]);
                    ls_source_loc_no = drow_wrkmast[6].ToString();
                    ls_wmsId = drow_wrkmast[7].ToString();
                    ls_boxId = drow_wrkmast[8].ToString();
                    li_wrk_model = Convert.ToInt32(drow_wrkmast[9].ToString());
 
                    add_dw_log(le, "", "P", "   " + seq + ".2 处理工作档:" + li_wrk_no.ToString());
                    SqlConnection sqlconn = new SqlConnection(Common.sqlcon);
                    sqlconn.Open();
                    SqlTransaction sqltrans = sqlconn.BeginTransaction();
                    if (li_wrk_sts == 4)
                    {
                        switch (li_io_type)
                        {
                            case 10:
                                sql = "update asr_stk_mast set loc_sts='D',io_time='" + ldt_date + "',wmsId='" + ls_wmsId + "',boxId='" + ls_boxId + "'";
                                sql += " where loc_no='" + ls_loc_no + "' and (loc_sts = 'S' Or loc_sts = 'Q')";
                                SqlCommand cmd_10 = new SqlCommand(sql, sqlconn);
                                cmd_10.Transaction = sqltrans;
                                try
                                {
                                    cmd_10.ExecuteNonQuery();
                                }
                                catch (SqlException t)
                                {
                                    sqltrans.Rollback();
                                    cmd_10.Dispose();
                                    sqlconn.Dispose();
                                    ls_error_memo = "   " + seq + ".2.1 入库-更新库位状态异常 [asr_stk_mast] !工作号:" + li_wrk_no.ToString() + "  库位号:" + ls_loc_no + " 异常:" + t.Message;
                                    add_dw_log(le, "", "E", ls_error_memo);
                                    goto re;
                                }
                                break;
                        }
 
                        sql = "update asr_wrk_masp set wrk_sts=5,modi_time='" + ldt_date + "' where wrk_no=" + li_wrk_no + "; ";
                        if (li_wrk_model == 1)
                        {
                            sql += " update wms_command set Io_status='Y',upd_mk='Y' where wmsId='" + ls_wmsId + "' and boxId='" + ls_boxId + "';";
                        }
                        SqlCommand cmd_wrk = new SqlCommand(sql, sqlconn);
                        cmd_wrk.Transaction = sqltrans;
                        try
                        {
                            cmd_wrk.ExecuteNonQuery();
                        }
                        catch (SqlException t)
                        {
                            sqltrans.Rollback();
                            cmd_wrk.Dispose();
                            sqlconn.Dispose();
                            ls_error_memo = "   " + seq + ".2.2 更新工作状态异常 [asr_wrk_masp] !工作号:" + li_wrk_no.ToString() + " 时间:" + ldt_date.ToString() + " 异常:" + t.Message;
                            add_dw_log(le, "", "E", ls_error_memo);
                            goto re;
                        }
                        //向WMS上报状态
                        JSONObject json = new JSONObject();
                        json.put("messageName", "StackerTaskState");
                        json.put("boxId", ls_boxId);
                        json.put("wmsId", ls_wmsId);
                        json.put("type", "STACKER");
                        json.put("flashId", "1");
                        if (li_wrk_model == 1)
                        {
                            json.put("isInit", 1);
                        }
                        else
                        {
                            json.put("isInit", 0);
                        }
                        json.put("station", "2");
                        JSONObject obj_location = new JSONObject();
                        obj_location.put("s_level", 1);
                        obj_location.put("s_location", 10011);
                        int e_level = int.Parse(ls_loc_no.Substring(6,1));
                        obj_location.put("e_level", e_level);
                        int e_location = int.Parse("1" + ls_loc_no.Substring(2, 3) + ls_loc_no.Substring(1, 1));
                        obj_location.put("e_location", e_location);
                        obj_location.put("r_level", 0);
                        obj_location.put("r_location", 0);
                        json.put("state", 3);
                        json.put("location", obj_location);
                    }
                    else if (li_wrk_sts == 14)
                    {
                        switch (li_io_type)
                        {
                            case 110:
                                sql = "update asr_stk_mast set loc_sts='O',io_time='" + ldt_date + "',wmsId='',boxId=''";
                                sql += " where loc_no='" + ls_source_loc_no + "' and loc_sts = 'R'";
                                SqlCommand cmd_110 = new SqlCommand(sql, sqlconn);
                                cmd_110.Transaction = sqltrans;
                                try
                                {
                                    cmd_110.ExecuteNonQuery();
                                }
                                catch (SqlException t)
                                {
                                    sqltrans.Rollback();
                                    cmd_110.Dispose();
                                    sqlconn.Dispose();
                                    ls_error_memo = "   " + seq + ".2.3 出库-更新库位状态异常[asr_stk_mast] !库位号:" + ls_source_loc_no + " 异常:" + t.Message;
                                    add_dw_log(le, "", "E", ls_error_memo);
                                    goto re;
                                }
                                break;
                        }
 
                        sql = "update asr_wrk_masp set wrk_sts=15,modi_time='" + ldt_date + "' where wrk_no=" + li_wrk_no + "; ";
                        if (li_wrk_model == 1)
                        {
                            sql += " update wms_command set Io_status='Y',upd_mk='Y' where wmsId='" + ls_wmsId + "' and boxId='" + ls_boxId + "';";
                        }
                        SqlCommand cmd_wrk1 = new SqlCommand(sql, sqlconn);
                        cmd_wrk1.Transaction = sqltrans;
                        try
                        {
                            cmd_wrk1.ExecuteNonQuery();
                        }
                        catch (SqlException t)
                        {
                            sqltrans.Rollback();
                            cmd_wrk1.Dispose();
                            sqltrans.Dispose();
                            ls_error_memo = "   " + seq + ".2.4 更新工作状态异常 [asr_wrk_masp] !工作号:" + li_wrk_no.ToString() + " 异常:" + t.Message;
                            add_dw_log(le, "", "E", ls_error_memo);
                            goto re;
                        }
                        JSONObject obj_location = new JSONObject();
                        int s_level = int.Parse(ls_source_loc_no.Substring(6, 1));
                        obj_location.put("s_level", s_level);
                        int s_location = int.Parse("1" + ls_source_loc_no.Substring(2, 3) + ls_source_loc_no.Substring(1, 1));
                        obj_location.put("s_location", s_location);
                        obj_location.put("e_level", 1);
                        obj_location.put("e_location", 10011);                        
                        obj_location.put("r_level", 0);
                        obj_location.put("r_location", 0);
                    }
                    sqltrans.Commit();
                    sqlconn.Dispose();
                }
            }
            catch (SqlException t)
            {
                ls_error_memo = "   " + seq + ".2.5 处理工作档数据失败! 异常:" + t.Message;
                add_dw_log(le, "", "E", ls_error_memo);
            }
 
            re:
            if (ls_error_memo != "")
            {
                try
                {
                    bool bl = Common.ExecAsrsModify("update dbo.asr_wrk_masp set upd_mk ='X',error_time='" + ldt_date + "',error_memo='" + ls_error_memo + "'  where wrk_no =" + li_wrk_no + "");
                }
                catch (SqlException t)
                {
                    ls_error_memo = "   " + seq + ".3.6 更新工作主档状态 [asr_wrk_masp] 异常! 工作号:" + li_wrk_no.ToString() + " 时间:" + ldt_date.ToString();
                    add_dw_log(le, "", "E", ls_error_memo);
                    return;
                }
 
            }
        }
 
        /// <summary>
        /// 处理工作档中工作状态为5和15的资料,转历史档
        /// </summary>
        public static void ProcWorkToLog(ListViewEx le, string seq)
        {
            string ls_error_memo = "";
            add_dw_log(le, seq, "N", "--处理工作档转历史档......");
            int wrkno = 0;
            try
            {
                string sql = "select top 1 wrk_no from asr_wrk_masp where (wrk_sts=5 or wrk_sts=15)";
                DataView dv = Common.ExecAsrsSelect(sql);
                if (dv.Count <= 0)
                {
                    add_dw_log(le, "", "N", "   " + seq + ".1 工作档 [asr_wrk_masp] 没有资料处理!");
                    return;
                }
                foreach (DataRowView drow in dv)
                {
                    wrkno = int.Parse(drow[0].ToString());
                }
                add_dw_log(le, "", "P", "   " + seq + ".1 正在处理转历史档" + wrkno);
 
                sql = "insert into asr_wrk_masp_log select * from asr_wrk_masp where wrk_no=" + wrkno + "; ";
                //sql += " and wrk_no not in (select wrk_no from dbo.asr_bas_devp) ";
                //sql += " and wrk_no not in (select wrk_no from dbo.asr_bas_crnp);";
                sql += " delete from asr_wrk_masp where wrk_no=" + wrkno + "; ";
                //sql += " and wrk_no not in (select wrk_no from dbo.asr_bas_devp) ";
                //sql += " and wrk_no not in (select wrk_no from dbo.asr_bas_crnp);";
                SqlConnection sqlconn = new SqlConnection(Common.sqlcon);
                sqlconn.Open();
                SqlTransaction sqltrans = sqlconn.BeginTransaction();
                SqlCommand sqlcmd = new SqlCommand(sql, sqlconn);
                sqlcmd.Transaction = sqltrans;
                try
                {
                    int result = sqlcmd.ExecuteNonQuery();
                    sqltrans.Commit();                    
                }
                catch (SqlException t)
                {
                    sqltrans.Rollback();
                    //sqlcommon.Close();
                    ls_error_memo = "   " + seq + ".1 工作档[asr_wrk_masp]转历史档错误 ! 异常:" + t.Message;
                    add_dw_log(le, "", "E", ls_error_memo);
                }
                finally
                {
                    sqlcmd.Dispose();
                    sqlconn.Dispose();
                }
                return;
            }
            catch (Exception t)
            {
                ls_error_memo = "   " + seq + ".2 处理工作档转历史档失败! 异常:" + t.Message;
                add_dw_log(le, "", "E", ls_error_memo);
            }
        }
 
        /// <summary>
        /// 处理wms命令档中已完结资料,转历史档
        /// </summary>
        public static void ProcWmsCommandToLog(ListViewEx le, string seq)
        {
            string ls_error_memo = "";
            add_dw_log(le, seq, "N", "--处理WMS命令档转历史档......");
            try
            {
                string sql = "insert into wms_command_log select * from wms_command where Io_status='Y' and upd_mk='Y';";
                sql += " delete from wms_command where Io_status='Y' and upd_mk='Y';";
                SqlConnection sqlconn = new SqlConnection(Common.sqlcon);
                sqlconn.Open();
                SqlTransaction sqltrans = sqlconn.BeginTransaction();
                SqlCommand sqlcmd = new SqlCommand(sql, sqlconn);
                sqlcmd.Transaction = sqltrans;
                try
                {
                    sqlcmd.ExecuteNonQuery();
                    sqltrans.Commit();
                }
                catch (SqlException t)
                {
                    sqltrans.Rollback();
                    //sqlcommon.Close();
                    ls_error_memo = "   " + seq + ".1 WMS命令档转历史档错误 ! 异常:" + t.Message;
                    add_dw_log(le, "", "E", ls_error_memo);
                }
                finally
                {
                    sqlcmd.Dispose();
                    sqlconn.Dispose();
                }
                return;
            }
            catch (Exception t)
            {
                ls_error_memo = "   " + seq + ".2 WMS命令档转历史档失败! 异常:" + t.Message;
                add_dw_log(le, "", "E", ls_error_memo);
            }
        }
 
        /// <summary>
        /// 同步货位信息到WMS
        /// </summary>
        public static void ProcReportLocationsResult(ListViewEx le, string seq)
        {
            string ls_error_memo = "", sql = "";
            string ls_messageName = "", ls_areaIdx = "";
            int li_requestlength = 0, li_totallength = 0, li_currentlength = 0, li_resultlength = 0;
            string ls_loc_no = "", ls_loc_sts = "", ls_boxId = "";
            int li_row1 = 0, li_bay1 = 0, li_lev1 = 0;
            add_dw_log(le, seq, "N", "--处理WMS货位信息同步命令......");
            try
            {
                sql = "select messageName,requestlength,areaIdx,totallength,currentlength ";
                sql += " from wms_command where messageName='InquiryLocations' and Io_status<>'Y' and currentlength<totallength ";
                DataView dv = Common.ExecAsrsSelect(sql);
                if (dv.Count < 1)
                {
                    add_dw_log(le, "", "N", "   " + seq + ".1 命令档 [wms_command] 没有货位同步信息资料!");
                    return;
                }
                foreach (DataRowView drow in dv)
                {
                    ls_messageName = drow[0].ToString();
                    li_requestlength = Convert.ToInt32(drow[1]);
                    ls_areaIdx = drow[2].ToString();
                    li_totallength = Convert.ToInt32(drow[3]);
                    li_currentlength = Convert.ToInt32(drow[4]);
                }
                JSONArray array = new JSONArray(); 
                sql = " select top " + li_requestlength + " loc_no,loc_sts,row1,bay1,lev1,boxId from asr_stk_mast ";
                sql += " where loc_no not in (select top " + li_currentlength + " loc_no from asr_stk_mast order by lev1,bay1,row1) ";
                sql += " order by lev1,bay1,row1";
                DataView dv_stk = Common.ExecAsrsSelect(sql);                
                li_resultlength = dv_stk.Count;
                if (li_resultlength <= 0)
                {
                    return;
                }
                add_dw_log(le, "", "P", "   " + seq + ".2 正在处理货位信息同步,共" + li_resultlength + "笔数据");
                foreach (DataRowView drow in dv_stk)
                {
                    ls_loc_no = drow[0].ToString();
                    ls_loc_sts = drow[1].ToString();
                    li_row1 = Convert.ToInt32(drow[2]);
                    li_bay1 = Convert.ToInt32(drow[3]);
                    li_lev1 = Convert.ToInt32(drow[4]);
                    ls_boxId = drow[5].ToString();
                    JSONObject jsonres = new JSONObject();
                    jsonres.put("level", li_lev1);
                    string location = "1" + li_bay1.ToString().PadLeft(3, '0') + li_row1;
                    jsonres.put("location", long.Parse(location));
                    int li_state = -1;
                    switch (ls_loc_sts)
                    {
                        case "O":
                            li_state = 0;
                            break;
                        case "R":
                            li_state = 1;
                            break;
                        case "S":
                            li_state = 1;
                            break;
                        case "D":
                            li_state = 10;
                            break;
                        case "X":
                            li_state = -1;
                            break;
                    }
                    jsonres.put("state", li_state);
                    jsonres.put("boxId", ls_boxId);
                    array.put(jsonres);
                }
 
                sql = "update wms_command set currentlength=currentlength+" + li_resultlength + ", ";
                sql += " Io_status = case when (currentlength+" + li_resultlength + ">=totallength) then 'Y' else 'N' end ";
                sql += " ,upd_mk = case when (currentlength+" + li_resultlength + ">=totallength) then 'Y' else 'N' end ";
                sql += " where messageName='InquiryLocations' and Io_status<>'Y' and currentlength<totallength ";
                bool bl = Common.ExecAsrsModify(sql);
                if (!bl)
                {
                    ls_error_memo = "   " + seq + ".3 WMS处理货位信息同步失败! ";
                    add_dw_log(le, "", "E", ls_error_memo);
                }
            }
            catch (Exception t)
            {
                ls_error_memo = "   " + seq + ".4 WMS处理货位信息同步失败! 异常:" + t.Message;
                add_dw_log(le, "", "E", ls_error_memo);
            }
        }
 
    }
}