jiazx0107@163.com
2023-05-31 7a7ccfd74dbdff086d2aabe5117ec1dc6f804d91
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
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
package com.ld.igds.inout.controller;
 
import ch.qos.logback.classic.pattern.ClassNameOnlyAbbreviator;
import com.bstek.bdf2.core.business.IUser;
import com.ld.igds.check.dto.CheckItemData;
import com.ld.igds.common.manager.CommonManager;
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.data.BaseParam;
import com.ld.igds.data.Page;
import com.ld.igds.data.PageResponse;
import com.ld.igds.data.SimpleDepot;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.*;
import com.ld.igds.inout.manager.InoutCommonManager;
import com.ld.igds.inout.manager.InoutManager;
import com.ld.igds.models.Depot;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutConf;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
 
 
/**
 * @Desc: 出入库业务流程控制层,主要为标准卡车出入库流程控制管理
 * @author: Andy
 */
@Slf4j
@RestController
@RequestMapping("basic/inout")
public class InoutController {
 
    @Resource
    private CommonManager commonManager;
    @Resource
    private InoutManager inoutManager;
    @Resource
    private InoutCommonManager inoutCommonManager;
 
    /**
     * 入库登记
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/in-register")
    public ModelAndView inRegister(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
 
        if (StringUtils.isEmpty(sort)) {
            sort = commonManager.getInoutWeightByClient(httpRequest);
        }
 
        if (StringUtils.isEmpty(sort)) {
            sort = "1";
        }
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("type", InoutConstant.TYPE_IN);
        view.addObject("deptId", deptId);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), ContextUtil.subDeptId(user), InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_REGISTER);
 
        // 获取出入库配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
 
        // 车牌识别参数封装
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_10, InoutConstant.PROGRESS_REGISTER, 1);
        view.addObject("lprDto", conf);
 
        //初始化车牌识别
        inoutManager.initLpr(conf);
 
        view.setViewName("admin/inout/in-register");
        return view;
    }
 
    /**
     * 扦样化验页面
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/in-check")
    public ModelAndView inCheck(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) {
        if (StringUtils.isEmpty(sort)) {
            sort = commonManager.getInoutWeightByClient(httpRequest);
        }
        ModelAndView view = new ModelAndView();
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(true);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
 
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("type", InoutConstant.TYPE_IN);
        view.addObject("deptId", deptId);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
 
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_CHECK);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
 
        view.addObject("endTime",
                DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
        view.addObject("startTime", DateFormatUtils.format(
                DateUtil.getNewByDay(null, -30), "yyyy-MM-dd"));
 
        // 获取出入库配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
 
        // 获取扦样机信息
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_20, InoutConstant.PROGRESS_CHECK, 1);
        view.addObject("checkDto", conf);
        view.setViewName("admin/inout/in-check");
        return view;
    }
 
    /**
     * 入库称重操作,包括空车称重和满车称重,共用一个页面
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/in-weight")
    public ModelAndView inWeight(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) {
 
        //如果没有指定地磅,从用户上一个选择中获取
        if (StringUtils.isEmpty(sort)) {
            sort = commonManager.getInoutWeightByClient(httpRequest);
        }
 
        ModelAndView view = new ModelAndView();
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("type", InoutConstant.TYPE_IN);
        view.addObject("deptId", deptId);
 
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptIn(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        // 当前流程标签
        view.addObject("progress", InoutConstant.PROGRESS_WEIGHT_TAG);
 
        //入库流程配置
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
 
        //称重是否可编辑标签
        String weightEditTag = inoutCommonManager.getWeightEditTag(user.getCompanyId(), deptId);
        view.addObject("weightEditTag", weightEditTag);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 获取出入库设备配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
 
        //根据出入库设备信息筛选地磅配置信息,所有地磅,支持用户手动选择
        List<InoutConf> listWeight = inoutCommonManager.getInoutConf(listInoutConf, InoutConstant.CONF_TYPE_30);
        view.addObject("listWeight", listWeight);
 
        // 获取当前地磅
        InoutConf weightDto = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_30);
        view.addObject("weightDto", weightDto);
 
        // 过程摄像头1
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60, InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        view.addObject("snapDto1", conf);
 
        // 过程摄像头2
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60, InoutConstant.PROGRESS_WEIGHT_TAG, 2);
        view.addObject("snapDto2", conf);
 
        // 过程摄像头3
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60, InoutConstant.PROGRESS_WEIGHT_TAG, 3);
        view.addObject("snapDto3", conf);
 
        // 远程智慧卡
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_80, InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        if (null != conf) conf.setSort(sort);
        view.addObject("cardDto", conf);
 
 
        view.setViewName("admin/inout/in-weight");
        return view;
    }
 
    /**
     * 入库-值仓
     *
     * @return
     */
    @RequestMapping("/in-handle")
    public ModelAndView inHandle() {
 
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("deptId", deptId);
        view.addObject("type", InoutConstant.TYPE_IN);
 
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptIn(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(),
                ContextUtil.subDeptId(user), InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
 
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_HANDLE);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
 
        view.setViewName("admin/inout/in-handle");
        return view;
    }
 
    /**
     * 入库-卡回收
     *
     * @return
     */
    @RequestMapping("/in-card-back")
    public ModelAndView inCardBack() {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("deptId", deptId);
        view.addObject("type", InoutConstant.TYPE_IN);
 
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptIn(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(),
                ContextUtil.subDeptId(user), InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
 
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_CARD_BACK);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
 
        view.setViewName("admin/inout/in-card-back");
        return view;
    }
 
    /**
     * 出库登记
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/out-register")
    public ModelAndView outRegister(@RequestParam(value = "sort", required = false) String sort) {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_OUT.getCode());
        view.addObject("type", InoutConstant.TYPE_OUT);
        view.addObject("deptId", deptId);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), ContextUtil.subDeptId(user), InoutConstant.TYPE_OUT);
        view.addObject("inoutProgress", inoutProgress);
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_REGISTER);
 
        // 获取出入库配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
 
        // 车牌识别参数封装
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_10, InoutConstant.PROGRESS_REGISTER, 1);
        view.addObject("lprDto", conf);
 
        //初始化车牌识别
        inoutManager.initLpr(conf);
 
        view.setViewName("admin/inout/out-register");
        return view;
    }
 
    /**
     * 出库称重,包括空车称重和满车称重,共用一个页面
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/out-weight")
    public ModelAndView outWeight(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) {
 
        //如果没有指定地磅,从用户上一个选择中获取
        if (StringUtils.isEmpty(sort)) {
            sort = commonManager.getInoutWeightByClient(httpRequest);
        }
 
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_OUT.getCode());
        view.addObject("type", InoutConstant.TYPE_OUT);
        view.addObject("deptId", deptId);
 
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        // 当前流程标签
        view.addObject("progress", InoutConstant.PROGRESS_WEIGHT_TAG);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_OUT);
        view.addObject("inoutProgress", inoutProgress);
 
        //称重结果是否可修改
        String weightEditTag = inoutCommonManager.getWeightEditTag(user.getCompanyId(), ContextUtil.subDeptId(user));
        view.addObject("weightEditTag", weightEditTag);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 获取出入库配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
 
        //获取所有的地磅列表用于页面用户选择
        List<InoutConf> listWeight = inoutCommonManager.getInoutConf(listInoutConf, InoutConstant.CONF_TYPE_30);
        view.addObject("listWeight", listWeight);
 
        // 获取当前地磅信息
        InoutConf weightDto = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_30);
        view.addObject("weightDto", weightDto);
 
        // 过程摄像头1
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60,
                InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        view.addObject("snapDto1", conf);
 
        // 过程摄像头2
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60,
                InoutConstant.PROGRESS_WEIGHT_TAG, 2);
        view.addObject("snapDto2", conf);
 
        // 过程摄像头3
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60,
                InoutConstant.PROGRESS_WEIGHT_TAG, 3);
        view.addObject("snapDto3", conf);
 
        view.setViewName("admin/inout/out-weight");
        return view;
    }
 
    /**
     * 出库-值仓
     *
     * @return
     */
    @RequestMapping("/out-handle")
    public ModelAndView outHandle() {
 
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_OUT.getCode());
        view.addObject("deptId", deptId);
        view.addObject("type", InoutConstant.TYPE_OUT);
 
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(),deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        //出库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(),
                ContextUtil.subDeptId(user), InoutConstant.TYPE_OUT);
        view.addObject("inoutProgress", inoutProgress);
 
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_HANDLE);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
 
        view.setViewName("admin/inout/out-handle");
        return view;
    }
 
    /**
     * 出库-卡回收
     *
     * @return
     */
    @RequestMapping("/out-card-back")
    public ModelAndView outCardBack() {
 
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
 
        String deptId =  ContextUtil.subDeptId(user);
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        view.addObject("bizType", BizType.INOUT_OUT.getCode());
        view.addObject("deptId",deptId);
        view.addObject("type", InoutConstant.TYPE_OUT);
 
 
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(),deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
 
        //出库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(),
                ContextUtil.subDeptId(user), InoutConstant.TYPE_OUT);
        view.addObject("inoutProgress", inoutProgress);
 
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_CARD_BACK);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
 
        view.setViewName("admin/inout/out-card-back");
        return view;
    }
 
    /**
     * 出入库数据查询,根据条件查询数据,出入库数据信息
     *
     * @param param
     * @return
     */
    @RequestMapping("/inout-query")
    public PageResponse<InoutData> inoutQuery(@RequestBody InoutParam param) {
        if(null == param.getCompanyId()) param.setCompanyId(ContextUtil.getCompanyId());
        return inoutManager.inoutQuery(param);
    }
 
    /**
     * 卡回收数据查询,没有流程状态的数据直接返回
     *
     * @param param
     * @return
     */
    @RequestMapping("/inout-query-back")
    public PageResponse<InoutData> inoutQueryBack(@RequestBody InoutParam param) {
        param.setProgress(null);
        return inoutManager.inoutQuery(param);
    }
 
    /**
     * 出入库数据更新,提交到下个流程
     *
     * @param data
     * @return
     */
    @RequestMapping("/inout-next-step")
    @Transactional
    public PageResponse<InoutData> inoutNextStep(@RequestBody InoutData data) {
        try {
            IUser user = ContextUtil.getLoginUser();
            if (StringUtils.isEmpty(data.getCompanyId())) {
                data.setCompanyId(user.getCompanyId());
            }
            if (StringUtils.isEmpty(data.getDeptId())) {
                data.setDeptId(ContextUtil.subDeptId(user));
            }
 
            if (InoutConstant.TYPE_IN.equals(data.getType())) {
                return inoutManager.inNextStep(data);
            } else {
                return inoutManager.outNextStep(data);
            }
        } catch (Exception e) {
            log.error("后台异常:{}", e);
 
            //手动回滚
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "后台异常:" + e.getMessage());
        }
    }
 
    /**
     * 出入库数据保存,登记提交
     *
     * @param data
     * @return
     */
    @RequestMapping("/submit-register")
    @Transactional
    public PageResponse<InoutData> submitRegister(@RequestBody InoutData data) throws Exception {
        IUser user = ContextUtil.getLoginUser();
        if (StringUtils.isEmpty(data.getCompanyId())) {
            data.setCompanyId(user.getCompanyId());
        }
        if (StringUtils.isEmpty(data.getDeptId())) {
            data.setDeptId(ContextUtil.subDeptId(user));
        }
 
        //如果注册时候没有使用智慧卡,默认使用身份证号作为智慧卡号
        if (StringUtils.isEmpty(data.getIntelCard())) {
            data.setIntelCard(data.getUserId());
        }
 
        return inoutManager.submitRegisterInout(data);
    }
 
    /**
     * 卡回收页面提交,如果是正常流程卡回收则走正常完成流程,否则执行删除逻辑并回收卡
     *
     * @param data
     * @return
     */
    @RequestMapping("/inout-back-submit")
    public PageResponse<InoutData> inoutBackSubmit(@RequestBody InoutData data) {
        return inoutManager.inoutBack(data);
    }
 
    /**
     * 化验页面数据提交
     *
     * @param data
     * @return
     */
    @RequestMapping("/update-check")
    public PageResponse<InoutData> updateCheck(@RequestBody InoutData data) {
        try {
            return inoutManager.updateCheck(data);
        } catch (Exception e) {
            log.error("后台异常:{}", e);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "后台异常:" + e.getMessage(), null);
        }
    }
 
    /**
     * 根据卡号和类型,直接完成当前流程
     *
     * @param data
     * @return
     */
    @RequestMapping("/inout-to-complete")
    public PageResponse<InoutData> inoutComplete(@RequestBody InoutData data) {
        try {
            return inoutManager.inoutComplete(data);
        } catch (Exception e) {
            log.error("后台异常:{}", e);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "后台异常:" + e.getMessage(), data);
        }
    }
 
    /**
     * 根据入库数据信息,获取检查项信息,如果当前数据已经检测完成,查询检测结果,如果没有检测完成则根据检测项配置获取需要检测的项目信息
     *
     * @param data
     * @return
     */
    @RequestMapping("/get-check-item")
    public PageResponse<List<CheckItemData>> getCheckItem(@RequestBody InoutData data) {
        try {
            return inoutManager.getCheckItem(data);
        } catch (Exception e) {
            log.error("后台异常:{}", e);
            return new PageResponse<List<CheckItemData>>(
                    RespCodeEnum.CODE_1111.getCode(), "后台异常:" + e.getMessage());
        }
    }
 
    /**
     * 分页获取数据信息
     *
     * @param param
     * @return
     */
    @RequestMapping("/page-check-data")
    public PageResponse<Page<InoutData>> pageCheckData(
            @RequestBody InoutParam param) {
        return inoutManager.pageCheckData(param);
    }
 
    /**
     * 道闸控制
     *
     * @param param
     * @return
     */
    @RequestMapping("/gate-ctrl")
    public PageResponse<String> gateCtrl(
            @RequestBody InoutGateDto param) {
 
        return null;
    }
 
    /**
     * 更新用户选择地磅,根据用户IP保存期选择
     *
     * @param param 用参数中的key作为选择
     * @return
     */
    @RequestMapping("/update-select-weight")
    public PageResponse<String> updateWeight(HttpServletRequest request, @RequestBody BaseParam param) {
        try {
 
            if (null == param.getKey()) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "后台异常:没有获取到用户选择地磅");
            }
 
            commonManager.setInoutWeightByClient(request, param.getKey());
 
            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "更新成功");
 
        } catch (Exception e) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "后台异常:" + e.getMessage());
        }
    }
 
 
    /**
     * 扦样页面
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/in-sample")
    public ModelAndView inSample(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) {
        if (StringUtils.isEmpty(sort)) {
            sort = commonManager.getInoutWeightByClient(httpRequest);
        }
        ModelAndView view = new ModelAndView();
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(true);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        String deptId = ContextUtil.subDeptId(user);
 
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("type", InoutConstant.TYPE_IN);
        view.addObject("deptId", deptId);
 
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
 
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_CHECK);
 
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
 
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
 
        view.addObject("endTime",
                DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
        view.addObject("startTime", DateFormatUtils.format(
                DateUtil.getNewByDay(null, -10), "yyyy-MM-dd"));
 
        // 获取出入库配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
 
        // 获取扦样机信息
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_20, InoutConstant.PROGRESS_CHECK, 1);
        view.addObject("checkDto", conf);
        view.setViewName("admin/inout/in-sample");
        return view;
    }
 
    /**
     * 分页获取扦样记录信息
     *
     * @param param
     * @return
     */
    @RequestMapping("/page-sample-data")
    public PageResponse<Page<InoutCheckData>> pageSampleData(@RequestBody InoutCheckParam param) {
        return inoutManager.pageSampleData(param);
    }
 
    /**
     * 扦样页面提交
     *
     * @param data
     * @return
     */
    @RequestMapping("/update-sample")
    public PageResponse<InoutCheckData> updateSample(@RequestBody InoutCheckData data) {
        try {
            return inoutManager.updateSampleData(data);
        } catch (Exception e) {
            log.error("后台异常:{}", e);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "后台异常:" + e.getMessage(), null);
        }
    }
}