YYC
2023-09-07 7243e0b4bd9a267a633d2e481e17646509b6868d
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
package com.ld.igds.inout.manager;
 
import com.bstek.bdf2.core.business.IUser;
import com.ld.igds.check.CheckStandardManager;
import com.ld.igds.check.dto.CheckItemData;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.constant.TransType;
import com.ld.igds.data.Page;
import com.ld.igds.data.PageResponse;
import com.ld.igds.file.CoreFileService;
import com.ld.igds.file.dto.FileData;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.dto.InoutRecordItemData;
import com.ld.igds.inout.dto.InoutRecordItemParam;
import com.ld.igds.inout.service.InoutRecordItemService;
import com.ld.igds.inout.service.InoutService;
import com.ld.igds.m.dto.NoticeParam;
import com.ld.igds.m.service.HInoutCarConfService;
import com.ld.igds.m.service.InoutCommonService;
import com.ld.igds.models.Depot;
import com.ld.igds.models.InoutCarConf;
import com.ld.igds.models.InoutNoticeIn;
import com.ld.igds.models.InoutNoticeOut;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
 
/**
 * 出入库相关业务2
 *
 * @author
 */
@Slf4j
@Component
public class InoutManager2 {
 
    @Resource
    private CoreFileService fileService;
    @Resource
    private InoutService inoutService;
    @Autowired
    private CoreCommonService coreCommonService;
    @Resource
    private InoutRecordItemService inoutRecordItemService;
    @Resource
    private CheckStandardManager checkStandardManager;
    @Resource
    private InoutCommonService inoutManagerService;
    @Resource
    private HInoutCarConfService carConfService;
 
    /**
     * 出入库流程中的实时数据,直接从缓存中获取
     *
     * @param param
     * @return
     */
    public PageResponse<Map<String, List<InoutData>>> listProgress(InoutParam param) {
        Map<String, List<InoutData>> result = new HashMap<>();
 
        //当前流程中
        List<InoutData> listProgress = inoutService.getListInoutCache(param.getDeptId());
 
 
        //当前已经完成
        List<InoutData> listComplete = inoutService.getCompleteListInoutCache(param.getDeptId());
 
 
        if (null == listProgress) listProgress = new ArrayList<>();
        if (null == listComplete) listComplete = new ArrayList<>();
 
        result.put("listProgress", listProgress);
        result.put("listComplete", listComplete);
 
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行完成", result);
    }
 
    /**
     * 出入库简易操作-分页获取流程未完成的数据
     *
     * @param param
     * @return
     */
    public PageResponse<Page<InoutData>> pageInoutData(InoutParam param) {
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(ContextUtil.subDeptId(null));
        }
 
        log.debug("分页信息--page={},limit={},cuur={}", param.getPage(),
                param.getLimit(), param.getCurr());
        Page<InoutData> result = inoutService.pageUnCompleteData(param);
 
        if (null == result.getRecords() || result.getRecords().isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                    "获取到数据信息为空");
        }
 
        return new PageResponse<Page<InoutData>>(RespCodeEnum.CODE_0000, result);
    }
 
    /**
     * 入库的往来单位下拉框
     *
     * @param param
     * @return public PageResponse<List<InoutCustomer>> listCustomerIn(InoutParam param) {
 
    if (StringUtils.isEmpty(param.getCompanyId())) {
    param.setCompanyId(ContextUtil.getCompanyId());
    }
    param.setDeptId(ContextUtil.subDeptId(null));
 
    List<InoutCustomer> list;
    // 获取出入库系统配置信息
    InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(param.getCompanyId(), param.getDeptId());
 
    // 判断入库通知单是否启用
    if (Constant.YN_Y.equals(inoutSysConf.getNoticeTagIn())) {
    // 从入库通知单查询客户列表
    list = inoutManagerService.listCustomerByNoticeIn(param);
    } else {
    // 从往来单位表中查询,设置供应商标记
    param.setType(InoutConstant.TYPE_IN);
    list = inoutManagerService.listCustomer(param);
    }
 
    if (null == list || list.isEmpty()) {
    return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
    "查询结果为空!");
    }
 
    return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
     */
 
    /**
     * 出库的往来单位下拉框
     *
     * @param param
     * @return public PageResponse<List<InoutCustomer>> listCustomerOut(InoutParam param) {
 
    if (StringUtils.isEmpty(param.getCompanyId())) {
    param.setCompanyId(ContextUtil.getCompanyId());
    }
    param.setDeptId(ContextUtil.subDeptId(null));
 
    List<InoutCustomer> list;
    // 获取出入库系统配置信息
    InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(param.getCompanyId(), param.getDeptId());
    // 判断出库通知单是否启用
    if (Constant.YN_Y.equals(inoutSysConf.getNoticeTagOut())) {
    // 从出库通知单查询客户列表
    list = inoutManagerService.listCustomerByNoticeOut(param);
    } else {
    // 从往来单位表中查询,设置供应商标记
    param.setType(InoutConstant.TYPE_OUT);
    list = inoutManagerService.listCustomer(param);
    }
 
    if (null == list || list.isEmpty()) {
    return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
    "查询结果为空!");
    }
 
    return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
     */
 
    /**
     * 船运登记提交
     *
     * @param data
     * @return
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public PageResponse<InoutData> inoutShipRegister(InoutData data) throws Exception {
 
        String msg;
        IUser user = ContextUtil.getLoginUser();
        List<FileData> files = data.getFiles();
        List<CheckItemData> checkItems = data.getCheckItems();
        if (null == data.getCompanyId()) {
            data.setCompanyId(user.getCompanyId());
        }
        if (null == data.getDeptId()) {
            data.setDeptId(ContextUtil.subDeptId(user));
        }
        // 如果当前节点是注册,则需要验证下,是否有为完成的流程在执行中
        if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
            if (StringUtils.isEmpty(data.getIntelCard())) {
                data.setIntelCard(data.getUserId());
            }
 
            InoutParam param = new InoutParam();
            param.setCompanyId(data.getCompanyId());
            param.setPlateNum(data.getPlateNum());
            param.setIntelCard(data.getIntelCard());
            param.setType(data.getType());
            InoutData progressData = inoutService.inoutProgressQuery(param);
            if (null != progressData) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "当前卡片/车牌号有流程未结束。", progressData);
            }
        }
        //设置流程为称重
        data.setProgress(InoutConstant.PROGRESS_WEIGHT_TAG);
        data.setRegisterUser(ContextUtil.getLoginUserCName());
        if (InoutConstant.TYPE_IN.equals(data.getType())) {
            data.setCheckUser(ContextUtil.getLoginUserCName());
        }
 
        // 调用保存方法执行
        if (null == data.getIntelCard()) {
            data.setIntelCard(data.getUserId());
        }
        msg = inoutService.insertData(data);
 
        //执行附件信息
        if (null != files) {
            fileService.saveInoutFiles(files, data.getCompanyId(), data.getId(), data.getProgress());
        }
 
        //执行化验信息
        if (null != checkItems) {
            //更新检验项数据
            checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), checkItems);
        }
 
        if (null != msg) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(),
                "执行成功", data);
    }
 
    /**
     * 获取流程未结束的船运流水信息
     *
     * @param param
     * @return
     */
    public PageResponse<List<InoutRecordItemData>> listInoutItem(InoutRecordItemParam param) {
 
        //默认查询当天
        param.setStart(DateUtil.getCurZero(new Date()));
        param.setEnd(DateUtil.getNextZero(new Date()));
 
        List<InoutRecordItemData> result = inoutRecordItemService.listInoutItem(param);
 
        if (null == result || result.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                    "获取到数据信息为空");
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000, result);
    }
 
 
    /**
     * 获取流程未结束的船运流水信息
     *
     * @param param
     * @return
     */
    public PageResponse<InoutRecordItemData> getInoutItemByCarNum(InoutRecordItemParam param) {
 
        InoutRecordItemData result = inoutRecordItemService.getInoutItemByCarNum(param);
 
        if (null == result) {
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                    "获取到数据信息为空");
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000, result);
    }
 
    /**
     * 获取流程未结束的船运流水信息
     *
     * @param param
     * @return
     */
    public PageResponse<InoutRecordItemData> checkCarNum(InoutRecordItemParam param) {
 
        InoutRecordItemData result = inoutRecordItemService.getInoutItemByCarNum(param);
 
        if (null != result) {
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                    "当前车辆流程未完成,无法绑定!");
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000, null);
    }
 
    /**
     * 车辆登记及称重提交
     *
     * @param data
     * @return
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public PageResponse<String> inoutItemNextStep(InoutRecordItemData data) throws Exception {
        String msg;
        if (StringUtils.isEmpty(data.getRecordId()) || StringUtils.isEmpty(data.getPlateNum())) {
            msg = "";
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
        }
 
        List<FileData> files = data.getFiles();
        // 执行附件信息
        if (null != files) {
            fileService.saveInoutFiles(files, data.getCompanyId(), data.getRecordId(), data.getProgress());
        }
        if (InoutConstant.TYPE_IN.equals(data.getType())) {
            if (StringUtils.isEmpty(data.getId())) {
                data.setId(ContextUtil.getTimeId());
                data.setProgress(InoutConstant.PROGRESS_WEIGHT_FULL);
                data.setCreateTime(new Date());
                msg = inoutRecordItemService.insertInoutItem(data);
            } else {
                if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) {
                    data.setProgress(InoutConstant.PROGRESS_WEIGHT_EMPTY);
                    data.setFullWeightTime(new Date());
                    data.setFullWeightUser(ContextUtil.getLoginUserCName());
                } else if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) {
                    data.setProgress(InoutConstant.PROGRESS_RECORD);
                    data.setEmptyWeightTime(new Date());
                    data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
                }
                msg = inoutRecordItemService.updateInoutItem(data);
            }
        } else {
            if (StringUtils.isEmpty(data.getId())) {
                data.setId(ContextUtil.getTimeId());
                data.setProgress(InoutConstant.PROGRESS_WEIGHT_FULL);
                data.setCreateTime(new Date());
                msg = inoutRecordItemService.insertInoutItem(data);
            } else {
                if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) {
                    data.setProgress(InoutConstant.PROGRESS_WEIGHT_EMPTY);
                    data.setFullWeightTime(new Date());
                    data.setFullWeightUser(ContextUtil.getLoginUserCName());
                } else if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) {
                    data.setProgress(InoutConstant.PROGRESS_RECORD);
                    data.setEmptyWeightTime(new Date());
                    data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
                }
                msg = inoutRecordItemService.updateInoutItem(data);
            }
        }
 
        if (null != msg) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg);
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功");
    }
 
    /**
     * 获取流程未结束的船运流水信息
     *
     * @param param
     * @return
     */
    public PageResponse<List<InoutRecordItemData>> unShipInoutRecord(InoutRecordItemParam param) {
 
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(ContextUtil.subDeptId(null));
        }
        //设置运输方式为轮船
        param.setTransType(TransType.TYPE_3.getCode());
        //设置流程为称重
        param.setProgress(InoutConstant.PROGRESS_WEIGHT_TAG);
        if (StringUtils.isNotEmpty(param.getKey())) {
            param.setKey("%" + param.getKey() + "%");
        }
        List<InoutRecordItemData> list = inoutRecordItemService.shipInoutRecord(param);
 
        if (null == list || list.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "查询结果为空!");
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
 
    /**
     * 获取船运车辆配置信息
     *
     * @param companyId
     * @param deptId
     * @return
     */
    public PageResponse<List<InoutCarConf>> listShipCar(String companyId, String deptId) {
 
        if (StringUtils.isEmpty(companyId)) {
            companyId = ContextUtil.getCompanyId();
        }
        if (StringUtils.isEmpty(deptId)) {
            deptId = ContextUtil.subDeptId(null);
        }
 
        List<InoutCarConf> list = carConfService.listCarConf(companyId, deptId);
 
        if (null == list || list.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "查询结果为空!");
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
 
    /**
     * 获取一个月的船运流水信息
     *
     * @param param
     * @return
     */
    public PageResponse<List<InoutRecordItemData>> getShipInoutRecord(InoutRecordItemParam param) {
 
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(ContextUtil.subDeptId(null));
        }
        //设置运输方式为轮船
        param.setTransType(TransType.TYPE_3.getCode());
        //设置时间 -- 默认取一个月以内的船运信息
        param.setEnd(DateUtil.getNextZero(new Date()));
        param.setStart(DateUtil.getNewByDay(new Date(), -30));
 
        List<InoutRecordItemData> list = inoutRecordItemService.shipInoutRecord(param);
 
        if (null == list || list.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "查询结果为空!");
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
 
    /**
     * 结束船运信息流程,统计相关重量信息
     *
     * @param data
     * @return
     * @throws Exception
     */
    public PageResponse<InoutRecordItemData> shipComplete(InoutRecordItemData data) throws Exception {
        if (StringUtils.isEmpty(data.getRecordId())) {
 
            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
                    "没有获取到流水数据信息。", data);
        }
 
        if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
            //说明流程已结束,重新统计数量
            inoutRecordItemService.updateNumByInoutItem(data.getRecordId());
            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
 
        } else {
            //流程未结束,统计数量
            return reSumUnInoutRecord(data);
        }
    }
 
    /**
     * 结束船运信息流程,统计相关重量信息
     *
     * @param data
     * @return
     * @throws Exception
     */
    public PageResponse<String> delShipItem(InoutRecordItemData data) throws Exception {
        if (StringUtils.isEmpty(data.getId())) {
            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), "没有获取到流水数据信息。");
        }
 
        inoutRecordItemService.delShipItem(data.getId(), InoutConstant.RECORD_STATUS_DEL);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null);
    }
 
    /**
     * 结束船运信息流程,统计相关重量信息
     *
     * @param data
     * @return
     * @throws Exception
     */
    public PageResponse<InoutRecordItemData> reSumUnInoutRecord(InoutRecordItemData data) throws Exception {
 
        InoutRecordItemParam param = new InoutRecordItemParam();
        param.setRecordId(data.getRecordId());
        List<InoutRecordItemData> list = inoutRecordItemService.sumInoutItem(param);
 
        if (list == null || list.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
                    "没有获取到该船运相关统计信息", data);
        }
 
        InoutParam inoutParam = new InoutParam();
        inoutParam.setId(data.getRecordId());
        //查询流水信息
        InoutData inoutData = inoutService.inoutQueryById(inoutParam);
 
        Map<String, InoutParam> map = new HashMap<>();
        int temp = 1;
        for (InoutRecordItemData item : list) {
            if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(item.getProgress())
                    || InoutConstant.PROGRESS_WEIGHT_FULL.equals(item.getProgress())) {
                return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
                        "该船运信息尚有未完成称重的车辆信息", data);
            }
            if (StringUtils.isEmpty(item.getDepotId())) {
                return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
                        "该船运信息中有车辆未设置装卸仓库", data);
            }
            inoutParam = new InoutParam();
            if (StringUtils.isEmpty(data.getDepotId())) {
                data.setDepotId(item.getDepotId());
            }
            if (data.getDepotId().equals(item.getDepotId())) {
 
                inoutParam.setId(data.getRecordId());
            } else {
                String newId = data.getRecordId() + temp;
                temp++;
                //新增一条流水
                inoutData.setId(newId);
                inoutData.setDepotId(item.getDepotId());
                inoutService.insertData(inoutData);
                //更新流水子表中的recordId
                inoutRecordItemService.updateInoutItemRecordId(newId, item.getRecordId(), item.getDepotId());
                inoutParam.setId(inoutData.getId());
            }
            inoutParam.setDepotId(item.getDepotId());
            inoutParam.setCompanyId(inoutData.getCompanyId());
            inoutParam.setType(inoutData.getType());
            inoutParam.setDeptId(inoutData.getDeptId());
            inoutParam.setIntelCard(inoutData.getIntelCard());
            inoutParam.setPlateNum(inoutData.getPlateNum());
            inoutParam.setProgress(InoutConstant.PROGRESS_RECORD);
            inoutParam.setFullWeight(item.getFullWeight());
            inoutParam.setFullWeightTime(item.getFullWeightTime());
            inoutParam.setFullWeightUser(ContextUtil.getLoginUserCName());
            inoutParam.setEmptyWeight(item.getEmptyWeight());
            inoutParam.setEmptyWeightTime(item.getEmptyWeightTime());
            inoutParam.setEmptyWeightUser(ContextUtil.getLoginUserCName());
            inoutParam.setDe(item.getDe());
            inoutParam.setNetWeight(item.getNetWeight());
            inoutParam.setSettleWeight(item.getSettleWeight());
            inoutParam.setRecordWeight(item.getRecordWeight());
            inoutParam.setCompleteTime(new Date());
            map.put(inoutParam.getId(), inoutParam);
        }
        InoutParam par;
        for (String key : map.keySet()) {
            par = map.get(key);
            if (par != null) {
                //更新流水数据(包含重量信息以及流程进度信息)
                inoutService.toComplete(par);
 
//                //更新仓库库存
//                if (InoutConstant.TYPE_IN.equals(par.getType())) {
//                    commonService.addStorage(par.getCompanyId(), par.getDepotId(),
//                            par.getSettleWeight());
//                }
//
//                if (InoutConstant.TYPE_OUT.equals(par.getType())) {
//                    commonService.reduceStorage(par.getCompanyId(), par.getDepotId(),
//                            par.getSettleWeight());
//                }
            }
        }
 
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data);
    }
 
    /**
     * 根据参数获取出入库的图片,文件流展示
     *
     * @param param
     * @return
     */
    public PageResponse<List<FileData>> cutImgList(InoutParam param) {
 
        if (null == param.getId())
            return null;
        if (null == param.getCompanyId()) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        List<FileData> files = fileService.listFile(param.getCompanyId(), param.getId());
 
        if (null == files) {
            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
                    "当前出入库信息下没有获取到可视化信息!!");
        }
 
        String bathPath;
        File imgFile;
        for (FileData file : files) {
 
            //设置文件路径,通过文件流来展示图片
            bathPath = fileService.getInoutFilePath(file.getCreateTime());
            imgFile = new File(bathPath + file.getFileName());
            if (imgFile.exists()) {
                file.setFilePath(bathPath + file.getFileName());
            }
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000, files);
    }
 
 
    public PageResponse<List<InoutNoticeIn>> listNoticeIn(NoticeParam param) {
 
        IUser user = ContextUtil.getLoginUser();
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(user.getCompanyId());
        }
        param.setDeptId(ContextUtil.subDeptId(user));
        param.setCompleteStatus(InoutConstant.COMPLETE_STATUS_NONE);
 
        List<InoutNoticeIn> list = inoutManagerService.listNoticeIn(param);
 
        if (null == list || list.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "查询结果为空!");
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
 
    /**
     * 获取出库通知单列表
     *
     * @param param
     * @return
     */
    public PageResponse<List<InoutNoticeOut>> listNoticeOut(NoticeParam param) {
        IUser user = ContextUtil.getLoginUser();
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(user.getCompanyId());
        }
        param.setDeptId(ContextUtil.subDeptId(user));
 
        param.setCompleteStatus(InoutConstant.COMPLETE_STATUS_NONE);
 
        List<InoutNoticeOut> list = inoutManagerService.listNoticeOut(param);
 
        if (null == list || list.isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "查询结果为空!");
        }
 
        //获取仓库信息
        List<Depot> depotList = coreCommonService.getCacheDepotList(param.getCompanyId(), param.getDeptId());
        Map<String,String> map = new HashMap<>();
        if(depotList != null && depotList.size() > 0){
            for (Depot depot : depotList) {
                map.put(depot.getId(), depot.getName());
            }
        }
 
        //赋值仓库名称
        for (InoutNoticeOut inoutNoticeOut : list) {
            if(map.get(inoutNoticeOut.getDepotId()) != null){
                inoutNoticeOut.setDepotName(map.get(inoutNoticeOut.getDepotId()));
            }
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000, list);
    }
}