王佳豪
2021-07-15 581df534cbf44938438189bc6fa8e376427ed238
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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
package com.slcf.controller;
 
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import com.slcf.controller.param.SetEmsParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import com.slcf.pojo.UserBean;
import com.slcf.bean.WaitPakOutCondition;
import com.slcf.pojo.WaitPakOutBean;
import com.slcf.pojo.LocationBean;
import com.slcf.pojo.MatCodeBean;
import com.slcf.pojo.SysLogBean;
import com.slcf.service.WaitPakOutService;
import com.slcf.service.WorkFileService;
import com.slcf.service.WorkNoService;
import com.slcf.util.AuthorityCode;
import com.slcf.util.CommonMethod;
import com.slcf.util.Constants;
import com.slcf.util.DateTimeUtil;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import sun.misc.BASE64Encoder;
 
import com.slcf.service.CrnService;
import com.slcf.service.LocDetailService;
import com.slcf.service.LocationService;
import com.slcf.service.MatCodeService;
import com.slcf.service.OperateService;
import com.slcf.service.RoleService;
import com.slcf.service.RowNoService;
import com.slcf.service.StaDescService;
import com.slcf.service.StationService;
import com.slcf.service.SysLogService;
 
/**
 * 出库通知档控制器层
 * @author admin
 * @date 2018年11月21日
 */
@Controller
@RequestMapping("/work")
public class WaitPakOutController {
 
    @Resource
    WaitPakOutService waitPakOutService;
    @Autowired
    SysLogService sysLogService;
    @Autowired
    MatCodeService matCodeService;
    @Autowired
    LocDetailService locDetailService;
    @Autowired
    RoleService roleService;
    @Autowired
    LocationService locationService;
    @Autowired
    StaDescService staDescService;
    @Autowired
    StationService stationService;
    @Autowired
    WorkNoService workNoService;
    @Autowired
    WorkFileService workFileService;
    @Autowired
    RowNoService rowNoService;
    @Autowired
    CrnService crnService;
    @Autowired
    OperateService operateService;
    
    @RequestMapping("/goWaitPakOut.action")
    public String goWaitPakOutPage(HttpServletRequest request){
        try {
            String rid = request.getSession().getAttribute("ROLEID").toString();
            String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid), 
                    AuthorityCode.WaitPakOutCode);
            request.getSession().setAttribute("AUTHCODE",authCode);
            // 插入日志
            UserBean user = (UserBean) request.getSession().getAttribute("USER");
            SysLogBean sysLog = new SysLogBean();
            sysLog.setLogin_no(user.getUser_account());
            sysLog.setMachine_ip(request.getRemoteAddr());
            sysLog.setForm_no("goWaitPakOut.action");
            sysLog.setTts_keyname("访问:出库通知档");
            sysLog.setModi_user(user.getUser_account());
            sysLogService.insertSysLog(sysLog);
        }catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return "waitPakOut";
    }
    
    /**
     * 添加
     * @param WaitPakOut
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/addWaitPakOut.action")
    public Integer insertWaitPakOut(WaitPakOutBean waitPakOut,HttpServletRequest request){
        int result=0;
        try {
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            if(waitPakOut.getSheet_no()==null || waitPakOut.getSheet_no().equals("")) {
                int random = (int)(Math.random()*900 + 100);
                String seq = Integer.toString(random);
                String sheet_no = DateTimeUtil.getStringDateTime(14);                
                waitPakOut.setSheet_no(sheet_no+seq);                
            }
            waitPakOut.setSheet_no(waitPakOut.getSheet_no().trim());
            waitPakOut.setModi_user(user.getUser_account());
            result = waitPakOutService.insertWaitPakOut(waitPakOut);                                
 
            if(result>0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("addWaitPakOut.action");
                sysLog.setTts_keyname("插入通知档:" + waitPakOut.getSheet_no() + "-" + waitPakOut.getMat_no());
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
            result=0;
        }
        return result;
    }
    
    /**
     * 分页查询所有
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping("/waitPakOutList.action")
    public Map<String,Object> queryWaitPakOutListByPages(WaitPakOutCondition waitPakOutCon){
        Map<String,Object>map=waitPakOutService.queryWaitPakOutList(waitPakOutCon);
        return map;
    }
 
    /**
     * 出库通知档设置任务为紧急状态
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/waitPakOutSetEms.action", produces = "text/html; charset=UTF-8")
    public String syncStocksFromSap(@RequestBody List<SetEmsParam> list) throws Exception {
        Integer i = 0;
        String errorTxt = "";
        if (list.size() > 0) {
            // 设置任务为紧急状态
            for (SetEmsParam item : list) {
                if (waitPakOutService.waitPakOutSetEms(item) > 0) {
                    i++;
                }
            }
//            // 判断紧急任务数量是否已经超过3个,超出3个不允许继续新增紧急任务
//            Integer emsNum = waitPakOutService.countEmsNum();
//            if (emsNum < 3) {
//                // 设置任务为紧急状态
//                for (SetEmsParam item : list) {
//                    if (waitPakOutService.waitPakOutSetEms(item) > 0) {
//                        i++;
//                    }
//                }
//            } else {
//                errorTxt = "紧急任务已超出3个,请耐心等待任务完成";
//            }
        } else {
            throw new Error("数据异常");
        }
        return (i == 0) ? errorTxt : i.toString();
    }
 
    /**
     * 验证物料编号是否存在
     * @param did
     * @return
     */
    @ResponseBody
    @RequestMapping("/checkCodeOut.action")
    public Map<String,Object> checkMatCodeOut(@RequestParam("did")String id){        
        Map<String,Object> map=new HashMap<String, Object>();
//        boolean flag=userService.validUserAccount(account, uid);
        try {
            MatCodeBean matCode = matCodeService.queryMatCodeById(id);
//            count = locDetailService.getLocStockCount(mat_no); 
            if(matCode!=null){
                map.put("msg", "代号可用");
                map.put("mat_name_add",matCode.getMat_name());
            }else{
                map.put("msg", "物料号不存在");
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return map;
    }
    
    /**
     * 根据id查询信息
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryWaitPakOutById.action")
    public WaitPakOutBean queryWaitPakOutById(@RequestParam("sheet_no")String sheet_no,
            @RequestParam("mat_no")String mat_no,HttpServletRequest request){
        try {
            return waitPakOutService.queryWaitPakOutById(sheet_no,mat_no);
        }catch(Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
    }
    
//    /**
//     * 验证工作代号是否唯一
//     * @param did
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/checkWaitPakOut.action")
//    public Map<String,Object> checkWaitPakOut(@RequestParam("did")int id){        
//        Map<String,Object> map=new HashMap<String, Object>();
////        boolean flag=userService.validUserAccount(account, uid);
//        try {
//            WaitPakOutBean WaitPakOut = waitPakOutService.queryWaitPakOutById(id);
//            if(WaitPakOut==null){
//                map.put("msg", "代号可用");
//            }else{
//                map.put("msg", "代号不可用");
//            }
//        }catch(Exception e) {
//            System.out.println(e.getMessage());
//        }
//        return map;
//    }
    
    /**
     * 手工完结入库通知档,反馈ERP
     * @param WaitPakInEntity
     * @return
     */
    @ResponseBody
    @RequestMapping("/overWaitPakOut.action")
    public Integer overWaitPakOut(WaitPakOutBean waitPakout,HttpServletRequest request){
        int result = 0;
        try {
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            waitPakout.setModi_user(user.getUser_account());
            
            WaitPakOutBean waitPakOutBean = waitPakOutService.queryWaitPakOutByNum(waitPakout);
            String httpUrl = Constants.SAP_URL + "/sap/opu/odata/SAP/Z_WM_H5_SRV/ToConHeadSet";
            result = sendPakOutStatus(httpUrl,waitPakOutBean);
//            result=waitPakInService.upWaitPakIn(waitPakIn);
            if(result>0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("upWaitPakIn.action");
                sysLog.setTts_keyname("修改入库通知档:" + waitPakout.getSheet_no());
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 出库完成,调用sap接口上传完成信息
     */
    private int sendPakOutStatus(String httpUrl,WaitPakOutBean waitPakOut) {
        int result = 0;
//        String token = getXCsrfToken(httpUrl);
        String input = Constants.SAP_USER + ":" + Constants.SAP_PASSWORD;//"ZHANGX:654321";
        BASE64Encoder base = new BASE64Encoder();
        String encodedPassword;
        String token="";
        String session_value="";
        try {
            encodedPassword = base.encode(input.getBytes("UTF-8"));
            URL url1 = new URL(httpUrl);
            HttpURLConnection connection1 = (HttpURLConnection) url1.openConnection();
            connection1.setDoOutput(true);
            connection1.setDoInput(true);
            connection1.setRequestMethod("GET");
            connection1.setRequestProperty("Authorization", "Basic " + encodedPassword);
            connection1.setRequestProperty("x-csrf-token","Fetch");
            String sessionCookie = connection1.getHeaderField("Set-Cookie");
            String[] sessionId = sessionCookie.split(";");
            session_value = sessionId[0];
            token = connection1.getHeaderField("x-csrf-token");
//            Map<String, List<String>> map = connection1.getHeaderFields();
//            token = map.get("x-csrf-token").toString();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        
        try {
            JSONObject jsObj = new JSONObject();
            JSONArray arr = new JSONArray();
            for(int i=0;i<1;i++) {
                JSONObject json = new JSONObject();
                json.put("lgnum",waitPakOut.getLgnum());
                json.put("tanum",Long.toString(waitPakOut.getTanum()));
                json.put("tapos",Integer.toString(waitPakOut.getTapos()));
                
//                json.put("nista",Double.toString(waitPakOut.getVsolm()));
//                json.put("ndifa","0");
                json.put("altme",waitPakOut.getMeins());
                json.put("nltyp","A01");
                json.put("nlpla",waitPakOut.getNlpla());
                arr.add(json);
            }
            jsObj.put("item", arr);
            byte[] buff = jsObj.toString().getBytes();
            int buffLen = buff.length;
            //创建连接
            try {
//                String input = "ZHANGX:654321";
//                BASE64Encoder base = new BASE64Encoder();
//                String encodedPassword = base.encode(input.getBytes("UTF-8"));
                
                URL url = new URL(httpUrl);
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setDoOutput(true);
                connection.setDoInput(true);
                connection.setRequestMethod("POST");
        //        connection.setUseCaches(false);            
        //        connection.setInstanceFollowRedirects(true);
//                connection.setRequestProperty("Content-Type","text/json;charset=gb2312");
                connection.setRequestProperty("Cookie", session_value);
                connection.setRequestProperty("Content-Type","application/json");
                connection.setRequestProperty("Accept","application/json");
                connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8");
                connection.setRequestProperty("Content-Length","" + buffLen);
//                connection.setRequestProperty("Authorization", "Basic " + encodedPassword);
                connection.setRequestProperty("x-csrf-token",token);
                
                //POST请求
                OutputStream out = connection.getOutputStream();
                out.write(buff);
                out.close();
                
                //读取响应
                BufferedReader reader = new BufferedReader(new InputStreamReader(
                        connection.getInputStream()));
                String lines;
                StringBuffer sb = new StringBuffer("");
                while ((lines = reader.readLine()) != null) {
                    lines = new String(lines.getBytes(), "utf-8");
                    sb.append(lines);
                }
                System.out.println(sb.toString());
                result = 1;
            }catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 修改信息
     * @param WaitPakOutEntity
     * @return
     */
    @ResponseBody
    @RequestMapping("/upWaitPakOut.action")
    public Integer upWaitPakOut(WaitPakOutBean waitPakOut,HttpServletRequest request){
        int result = 0;
        try {
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            waitPakOut.setModi_user(user.getUser_account());
            
            result=waitPakOutService.upWaitPakOut(waitPakOut,1);
            if(result>0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("upWaitPakOut.action");
                sysLog.setTts_keyname("修改出库通知档:" + waitPakOut.getSheet_no());
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 删除信息
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/delWaitPakOut.action")
    public int delWaitPakOut(WaitPakOutBean waitPakout,HttpServletRequest request){
        int result = 0;
        try {
            result=waitPakOutService.delWaitPakOut(waitPakout);
            
            if(result>0) {
                // 插入日志
                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("delWaitPakOut.action");
                sysLog.setTts_keyname("删除通知档资料:" + waitPakout.getLgnum() + "-" + waitPakout.getTanum());
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 查询所有
     * @return
     */
    @ResponseBody
    @RequestMapping("/getWaitPakOut.action")
    public List<WaitPakOutBean> getWaitPakOut(){
        try {
            return waitPakOutService.getWaitPakOutList();
        }catch(Exception e) {
            System.out.println(e.getMessage());
            return null;
        }        
    }
    
    /**
     * 通知档资料转历史档
     * @return
     */
    @ResponseBody
    @RequestMapping("/movePakOutToLog.action")
    public int movePakOutToLog(@RequestParam("ids")String[] sheetNos,@RequestParam("matStr")String[] matNos,
            @RequestParam("locStr")String[] locNos,HttpServletRequest request){
        int result = 0;
        try {
            String sheet_no="", mat_no="",loc_no="";
//            for(int i=0;i<sheetNos.length;i++) {
//                result=waitPakOutService.moveToLog(sheetNos[i], matNos[i]);
//            }            
            for(int i=0;i<matNos.length;i++) {
                mat_no = matNos[i];
                sheet_no=sheetNos[i];
                loc_no=locNos[i];
                LocationBean location = locationService.queryLocationById(loc_no);
                if(location!=null) {
                    location.setLoc_sts("F");
                    result = locationService.upLocation(location);
                }
                if(result>0) {
                    WaitPakOutBean waitPakOut = new WaitPakOutBean();
                    waitPakOut.setSheet_no(sheet_no);
                    waitPakOut.setMat_no(mat_no);
                    result = waitPakOutService.delWaitPakOut(waitPakOut);
                }
            }
            if(result>0) {
                // 插入日志
                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("movePakInToLog.action");
                sysLog.setTts_keyname("取消出库:" + sheet_no + "-" + mat_no);
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 添加出库单
     * @param sheet_no
     * @param locstr
     * @param request
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/addPakOutData.action")
    public Map<String,Object> addPakOutData(@RequestParam("sheet_no")String sheet_no,
            @RequestParam("locstr")String[] locstr,HttpServletRequest request) throws Exception{
        Map<String,Object> map=new HashMap<String, Object>();
        try {
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            if(locstr!=null) {
                for(String ids:locstr) {
                    String[] arr = ids.split(";");
                    if(arr==null || arr.length<2) {
                        continue;
                    }
                    String loc_no = arr[0];
                    String mat_no = arr[1];
                    WaitPakOutBean waitPakOutBean = waitPakOutService.queryWaitPakOutByMatNo(mat_no);
                    if(waitPakOutBean!=null) {//待出库档中物料号已存在
                        map.put("code", 1);
                        map.put("msg", "出库档中物料号已存在");
                        continue;
                    }
                    LocationBean location = locationService.queryLocationById(loc_no);
                    if(location==null || !location.getLoc_sts().equals("F")){
                        map.put("code", 1);
                        map.put("msg", "库位不是在库状态");
                        continue;
                    }
                    
                    //插入出库通知档,更新库存库位状态
                    WaitPakOutBean waitPakOut = new WaitPakOutBean();
                    waitPakOut.setSheet_no(sheet_no);
                    waitPakOut.setLoc_no(loc_no);
                    waitPakOut.setCtns(13);  //代替优先级
                    waitPakOut.setIo_status("1");
                    waitPakOut.setMemo(DateTimeUtil.getStringDateTime(10));
                    waitPakOut.setMat_no(mat_no);
                    waitPakOut.setModi_user(user.getUser_account());
                    int result = waitPakOutService.insertWaitPakOut(waitPakOut);
                    if(result>0) {
                        location.setLoc_sts("L");
                        result=locationService.upLocation(location);
                        if(result>0) {
                            map.put("code", 0);
                            map.put("msg", "");
                        }
                    }else {
                        map.put("code", 1);
                        map.put("msg", "添加到出库单失败");
                        continue;
                    }
                }
            }else {
                map.put("code", 1);
                map.put("msg", "没有选择库位");
                return map;
            }
            
            if((Integer)map.get("code")==0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("addPakOutData.action");
                sysLog.setTts_keyname("添加出库单");
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(RuntimeException e) {
            System.out.println(e.getMessage());
        }
        return map;
    }
    
    /**
     * 出库启动
     * @param ids
     * @param locstr
     * @param stn_no
     * @param stn_no1
     * @param request
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/confirmRetrieve.action")
    public Map<String,Object> confirmRetrieve(@RequestParam("ids")String[] ids,@RequestParam("locstr")String[] locstr,
            @RequestParam("stn_no")int stn_no,HttpServletRequest request) throws Exception{
        Map<String,Object> map=new HashMap<String, Object>();
        try {
            CommonMethod commonMethod = new CommonMethod(workFileService,workNoService,crnService,
                    stationService,locationService,rowNoService,staDescService);
            
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            if(locstr!=null && ids!=null) {
                for(String loc_no:locstr) {
                    LocationBean location = locationService.queryLocationById(loc_no);
                    if(location==null || !location.getLoc_sts().equals("L")){
                        continue;
                    }
                    map = operateService.insertPakRetrieve1(loc_no, ids, stn_no, user, commonMethod);
                }
            }else {
                map.put("code", 1);
                map.put("msg", "没有选择出库库位");
                return map;
            }
            
            if((Integer)map.get("code")==0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("confirmRetrieve.action");
                sysLog.setTts_keyname("启动出库");
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(RuntimeException e) {
            System.out.println(e.getMessage());
        }
        return map;
    }
 
    /**
     * 调整优先级
     * @param locstr
     * @param request
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/addDataIopri.action")
    public Map<String,Object> addDataIopri(@RequestParam("pri")String pri,
            @RequestParam("locstr")String[] locstr,HttpServletRequest request) throws Exception{
        Map<String,Object> map=new HashMap<String, Object>();
        try {
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            if(locstr!=null) {
                for(String ids:locstr) {
                    String[] arr = ids.split(";");
                    if(arr==null || arr.length<2) {
                        continue;
                    }
                    String loc_no = arr[0];
                    String mat_no = arr[1];
                    WaitPakOutBean waitPakOutBean = waitPakOutService.queryWaitPakOutByMatNo(mat_no);
                    if(waitPakOutBean!=null) {//待出库档中物料号已存在
                        int ctns = waitPakOutBean.getCtns() + Integer.parseInt(pri);
                        waitPakOutBean.setCtns(ctns);
                        int result = waitPakOutService.upWaitPakOut(waitPakOutBean,2);
                        if(result>0) {
                            map.put("code", 0);
                            map.put("msg", "调整成功");
                        }else {
                            map.put("code", 1);
                            map.put("msg", "出库档中物料号已存在");
                            continue;
                        }
                    }
                    
                }
            }else {
                map.put("code", 1);
                map.put("msg", "没有选择库位");
                return map;
            }
            
            if((Integer)map.get("code")==0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("addDataIopri.action");
                sysLog.setTts_keyname("调整优先级");
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(RuntimeException e) {
            System.out.println(e.getMessage());
        }
        return map;
    }
    
    /**
     * 查询所有单号
     * @return
     */
    @ResponseBody
    @RequestMapping("/getSheetNo.action")
    public Map<String,Object> getSheetNo(){
        Map<String,Object> map=new HashMap<String, Object>();
        try {
            map.put("rows",waitPakOutService.getSheetNoList()); 
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }    
        return map;
    }
    
}