|
|
@@ -6,17 +6,12 @@ import com.github.pagehelper.PageHelper;
|
|
6
|
6
|
import com.github.pagehelper.PageInfo;
|
|
7
|
7
|
import com.th.demo.mapping.maint.CustomerMapper;
|
|
8
|
8
|
import com.th.demo.mapping.maint.StackMapper;
|
|
9
|
|
-import com.th.demo.mapping.ware.ChangeRecordMapper;
|
|
10
|
|
-import com.th.demo.mapping.ware.MoveRecordMapper;
|
|
11
|
|
-import com.th.demo.mapping.ware.StoreMapper;
|
|
|
9
|
+import com.th.demo.mapping.ware.*;
|
|
12
|
10
|
import com.th.demo.model.maint.Customer;
|
|
13
|
11
|
import com.th.demo.model.maint.Stack;
|
|
14
|
12
|
import com.th.demo.model.system.SysUser;
|
|
15
|
13
|
import com.th.demo.model.system.Type;
|
|
16
|
|
-import com.th.demo.model.ware.ChangeRecord;
|
|
17
|
|
-import com.th.demo.model.ware.MoveRecord;
|
|
18
|
|
-import com.th.demo.model.ware.SplitRecord;
|
|
19
|
|
-import com.th.demo.model.ware.Store;
|
|
|
14
|
+import com.th.demo.model.ware.*;
|
|
20
|
15
|
import com.th.demo.service.maint.CustomerService;
|
|
21
|
16
|
import com.th.demo.service.ware.MoveService;
|
|
22
|
17
|
import com.th.demo.service.ware.StoreService;
|
|
|
@@ -26,10 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
26
|
21
|
import org.springframework.stereotype.Service;
|
|
27
|
22
|
|
|
28
|
23
|
import java.text.SimpleDateFormat;
|
|
29
|
|
-import java.util.ArrayList;
|
|
30
|
|
-import java.util.Arrays;
|
|
31
|
|
-import java.util.Date;
|
|
32
|
|
-import java.util.List;
|
|
|
24
|
+import java.util.*;
|
|
33
|
25
|
|
|
34
|
26
|
@Service("StoreService")
|
|
35
|
27
|
public class StoreServiceImpl implements StoreService {
|
|
|
@@ -44,6 +36,10 @@ public class StoreServiceImpl implements StoreService {
|
|
44
|
36
|
public MoveRecordMapper moveRecordMapper;
|
|
45
|
37
|
@Autowired//自动注入Mapper
|
|
46
|
38
|
public CustomerMapper customerMapper;
|
|
|
39
|
+ @Autowired
|
|
|
40
|
+ public InRecordMapper inRecordMapper;
|
|
|
41
|
+ @Autowired
|
|
|
42
|
+ public OutRecordMapper outRecordMapper;
|
|
47
|
43
|
String result = Type.FAIL;
|
|
48
|
44
|
int num = 0;
|
|
49
|
45
|
|
|
|
@@ -386,5 +382,298 @@ public class StoreServiceImpl implements StoreService {
|
|
386
|
382
|
// 修改入库表收货地址
|
|
387
|
383
|
int i1 = storeMapper.updateInAddressById(inId, newCustomerAddress);
|
|
388
|
384
|
return result;
|
|
|
385
|
+ }
|
|
|
386
|
+
|
|
|
387
|
+ /**
|
|
|
388
|
+ * 导出库存Excel
|
|
|
389
|
+ */
|
|
|
390
|
+ @Override
|
|
|
391
|
+ public List<Map<String, Object>> exportStoreExcel(int page, int rows,
|
|
|
392
|
+ String wareName, String stackName, String model, String materialName, String standard, String customerName,
|
|
|
393
|
+ String plateNo, Date fromDate, Date toDate, String userId, String belongId,
|
|
|
394
|
+ String ordNo, String carNo, String tallyPeople, String fkComponyName,String remark1,String contractNo) {
|
|
|
395
|
+
|
|
|
396
|
+ // 调用分批查询方法
|
|
|
397
|
+ return exportStoreExcelBatch(page, rows, wareName, stackName, model, materialName, standard, customerName,
|
|
|
398
|
+ plateNo, fromDate, toDate, userId, belongId, ordNo, carNo, tallyPeople, fkComponyName, remark1, contractNo, 0, -1);
|
|
|
399
|
+ }
|
|
|
400
|
+
|
|
|
401
|
+ /**
|
|
|
402
|
+ * 分批导出库存Excel(解决大数据量内存溢出问题)
|
|
|
403
|
+ */
|
|
|
404
|
+ @Override
|
|
|
405
|
+ public List<Map<String, Object>> exportStoreExcelBatch(int page, int rows,
|
|
|
406
|
+ String wareName, String stackName, String model, String materialName, String standard, String customerName,
|
|
|
407
|
+ String plateNo, Date fromDate, Date toDate, String userId, String belongId,
|
|
|
408
|
+ String ordNo, String carNo, String tallyPeople, String fkComponyName,String remark1,String contractNo,
|
|
|
409
|
+ int offset, int limit) {
|
|
|
410
|
+
|
|
|
411
|
+ // ========== 1. 所有字符串入参统一把 null 转为空串 ==========
|
|
|
412
|
+ wareName = wareName == null ? "" : wareName;
|
|
|
413
|
+ stackName = stackName == null ? "" : stackName;
|
|
|
414
|
+ model = model == null ? "" : model;
|
|
|
415
|
+ materialName = materialName == null ? "" : materialName;
|
|
|
416
|
+ standard = standard == null ? "" : standard;
|
|
|
417
|
+ customerName = customerName == null ? "" : customerName;
|
|
|
418
|
+ plateNo = plateNo == null ? "" : plateNo;
|
|
|
419
|
+ userId = userId == null ? "" : userId;
|
|
|
420
|
+ belongId = belongId == null ? "" : belongId;
|
|
|
421
|
+ ordNo = ordNo == null ? "" : ordNo;
|
|
|
422
|
+ carNo = carNo == null ? "" : carNo;
|
|
|
423
|
+ tallyPeople = tallyPeople == null ? "" : tallyPeople;
|
|
|
424
|
+ fkComponyName = fkComponyName == null ? "" : fkComponyName;
|
|
|
425
|
+ remark1 = remark1 == null ? "" : remark1;
|
|
|
426
|
+ contractNo = contractNo == null ? "" : contractNo;
|
|
|
427
|
+
|
|
|
428
|
+ List<String> pltNos = new ArrayList<>();
|
|
|
429
|
+ List<String> ordNos = new ArrayList<>();
|
|
|
430
|
+ List<String> contractNos =new ArrayList<>() ;
|
|
|
431
|
+
|
|
|
432
|
+ // 现在plateNo一定不为null,直接判断逗号
|
|
|
433
|
+ if (plateNo.contains(",")) {
|
|
|
434
|
+ pltNos = Arrays.asList(plateNo.split(","));
|
|
|
435
|
+ }
|
|
|
436
|
+ if (contractNo.contains(",")){
|
|
|
437
|
+ contractNos = Arrays.asList(contractNo.split(","));
|
|
|
438
|
+ }
|
|
|
439
|
+ if (ordNo.contains(",")) {
|
|
|
440
|
+ ordNos = Arrays.asList(ordNo.split(","));
|
|
|
441
|
+ }
|
|
|
442
|
+
|
|
|
443
|
+ List<InRecord> storeList;
|
|
|
444
|
+ // 如果 limit <= 0,使用原来的全量查询
|
|
|
445
|
+ if (limit <= 0) {
|
|
|
446
|
+ storeList = inRecordMapper.select(
|
|
|
447
|
+ wareName, stackName, model, materialName, standard, customerName,
|
|
|
448
|
+ plateNo, fromDate, toDate, userId, belongId, ordNo, carNo,
|
|
|
449
|
+ tallyPeople, fkComponyName, pltNos, ordNos, remark1, contractNo, contractNos);
|
|
|
450
|
+ } else {
|
|
|
451
|
+ // 分批查询
|
|
|
452
|
+ storeList = inRecordMapper.selectForExport(
|
|
|
453
|
+ wareName, stackName, model, materialName, standard, customerName,
|
|
|
454
|
+ plateNo, fromDate, toDate, userId, belongId, ordNo, carNo,
|
|
|
455
|
+ tallyPeople, fkComponyName, pltNos, ordNos, remark1, contractNo, contractNos,
|
|
|
456
|
+ limit, offset);
|
|
|
457
|
+ }
|
|
|
458
|
+
|
|
|
459
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
460
|
+ for (InRecord store : storeList) {
|
|
|
461
|
+ Map<String, Object> map = new LinkedHashMap<>();
|
|
|
462
|
+ // 仓库名称
|
|
|
463
|
+ map.put("wareName", store.getWareName() != null ? store.getWareName() : "");
|
|
|
464
|
+ // 垛位
|
|
|
465
|
+ map.put("stackName", store.getStackName() != null ? store.getStackName() : "");
|
|
|
466
|
+ // 层号
|
|
|
467
|
+ map.put("layer", store.getLayer() != null ? store.getLayer() : "");
|
|
|
468
|
+ // 品名
|
|
|
469
|
+ map.put("materialName", store.getMaterialName() != null ? store.getMaterialName() : "");
|
|
|
470
|
+ // 订单号
|
|
|
471
|
+ map.put("ordNo", store.getOrdNo() != null ? store.getOrdNo() : "");
|
|
|
472
|
+ // 规格型号
|
|
|
473
|
+ map.put("model", store.getModel() != null ? store.getModel() : "");
|
|
|
474
|
+ // 钢种
|
|
|
475
|
+ map.put("standard", store.getStandard() != null ? store.getStandard() : "");
|
|
|
476
|
+ // 数量
|
|
|
477
|
+ map.put("count", store.getCount() != null ? store.getCount() : "");
|
|
|
478
|
+ // 重量
|
|
|
479
|
+ map.put("weight", store.getWeight() != null ? store.getWeight() : "");
|
|
|
480
|
+ // 钢板号
|
|
|
481
|
+ map.put("plateNo", store.getPlateNo() != null ? store.getPlateNo() : "");
|
|
|
482
|
+ // 客户
|
|
|
483
|
+ map.put("customerName", store.getCustomerName() != null ? store.getCustomerName() : "");
|
|
|
484
|
+ // 货权单位
|
|
|
485
|
+ map.put("fkComponyName", store.getFkComponyName() != null ? store.getFkComponyName() : "");
|
|
|
486
|
+ // 收货地址
|
|
|
487
|
+ map.put("receiveAddress", store.getReceiveAddress() != null ? store.getReceiveAddress() : "");
|
|
|
488
|
+ // 计量方式
|
|
|
489
|
+ map.put("wgtDcnMtcCd", store.getWgtDcnMtcCd() != null ? store.getWgtDcnMtcCd() : "");
|
|
|
490
|
+ // 切边类型
|
|
|
491
|
+ map.put("edgeTy", store.getEdgeTy() != null ? store.getEdgeTy() : "");
|
|
|
492
|
+ // 产地
|
|
|
493
|
+ map.put("productionPlace", store.getProductionPlace() != null ? store.getProductionPlace() : "");
|
|
|
494
|
+ // 入库车号
|
|
|
495
|
+ map.put("carNo", store.getCarNo() != null ? store.getCarNo() : "");
|
|
|
496
|
+ // 入库理货人员
|
|
|
497
|
+ map.put("tallyPeople", store.getTallyPeople() != null ? store.getTallyPeople() : "");
|
|
|
498
|
+
|
|
|
499
|
+ // ========== 修复空指针核心:addUser判空 ==========
|
|
|
500
|
+ String addUserDesc = "";
|
|
|
501
|
+ if(store.getAddUser() != null){
|
|
|
502
|
+ addUserDesc = store.getAddUser().getUserDesc() != null ? store.getAddUser().getUserDesc() : "";
|
|
|
503
|
+ }
|
|
|
504
|
+ map.put("addUserUserDesc", addUserDesc);
|
|
|
505
|
+
|
|
|
506
|
+ // 入库时间
|
|
|
507
|
+ map.put("addTime", store.getAddTime() != null ? store.getAddTime() : "");
|
|
|
508
|
+ // 垛位备注
|
|
|
509
|
+ map.put("remark1", store.getRemark1() != null ? store.getRemark1() : "");
|
|
|
510
|
+ // 类型
|
|
|
511
|
+ map.put("recordType", store.getRecordType() != null ? store.getRecordType() : "");
|
|
|
512
|
+ // 备注
|
|
|
513
|
+ map.put("remark", store.getRemark() != null ? store.getRemark() : "");
|
|
|
514
|
+ // 合约号
|
|
|
515
|
+ map.put("contractNo", store.getContractNo() != null ? store.getContractNo() : "");
|
|
|
516
|
+
|
|
|
517
|
+ resultList.add(map);
|
|
|
518
|
+ }
|
|
|
519
|
+ return resultList;
|
|
|
520
|
+ }
|
|
|
521
|
+
|
|
|
522
|
+ /**
|
|
|
523
|
+ * 导出出库Excel
|
|
|
524
|
+ */
|
|
|
525
|
+ public List<Map<String, Object>> outExportStoreExcel(int page, int rows,
|
|
|
526
|
+ String wareName, String stackName, String model, String materialName, String standard,
|
|
|
527
|
+ String customerName, String plateNo, String carNo, String tallyPeople, String ordNo,
|
|
|
528
|
+ String fkComponyName, String remark1, String contractNo, Date fromDate, Date toDate, String userId, String belongId) {
|
|
|
529
|
+ // 调用分批查询方法
|
|
|
530
|
+ return outExportStoreExcelBatch(page, rows, wareName, stackName, model, materialName, standard,
|
|
|
531
|
+ customerName, plateNo, carNo, tallyPeople, ordNo, fkComponyName, remark1, contractNo, fromDate, toDate, userId, belongId, 0, -1);
|
|
|
532
|
+ }
|
|
|
533
|
+
|
|
|
534
|
+ /**
|
|
|
535
|
+ * 分批导出出库Excel(解决大数据量内存溢出问题)
|
|
|
536
|
+ */
|
|
|
537
|
+ public List<Map<String, Object>> outExportStoreExcelBatch(int page, int rows,
|
|
|
538
|
+ String wareName, String stackName, String model, String materialName, String standard,
|
|
|
539
|
+ String customerName, String plateNo, String carNo, String tallyPeople, String ordNo,
|
|
|
540
|
+ String fkComponyName, String remark1, String contractNo, Date fromDate, Date toDate, String userId, String belongId,
|
|
|
541
|
+ int offset, int limit) {
|
|
|
542
|
+ // 入参空值处理
|
|
|
543
|
+ wareName = wareName == null ? "" : wareName;
|
|
|
544
|
+ stackName = stackName == null ? "" : stackName;
|
|
|
545
|
+ model = model == null ? "" : model;
|
|
|
546
|
+ materialName = materialName == null ? "" : materialName;
|
|
|
547
|
+ standard = standard == null ? "" : standard;
|
|
|
548
|
+ customerName = customerName == null ? "" : customerName;
|
|
|
549
|
+ plateNo = plateNo == null ? "" : plateNo;
|
|
|
550
|
+ carNo = carNo == null ? "" : carNo;
|
|
|
551
|
+ tallyPeople = tallyPeople == null ? "" : tallyPeople;
|
|
|
552
|
+ ordNo = ordNo == null ? "" : ordNo;
|
|
|
553
|
+ fkComponyName = fkComponyName == null ? "" : fkComponyName;
|
|
|
554
|
+ remark1 = remark1 == null ? "" : remark1;
|
|
|
555
|
+ contractNo = contractNo == null ? "" : contractNo;
|
|
|
556
|
+
|
|
|
557
|
+ List<String> pltNos =new ArrayList<>() ;
|
|
|
558
|
+ List<String> ordNos =new ArrayList<>() ;
|
|
|
559
|
+ List<String> contractNos =new ArrayList<>() ;
|
|
|
560
|
+ if (plateNo.indexOf(",") != -1){
|
|
|
561
|
+ pltNos = Arrays.asList(plateNo.split(","));
|
|
|
562
|
+ }
|
|
|
563
|
+ if (contractNo.indexOf(",") != -1){
|
|
|
564
|
+ contractNos = Arrays.asList(contractNo.split(","));
|
|
|
565
|
+ }
|
|
|
566
|
+ if (ordNo.indexOf(",") != -1){
|
|
|
567
|
+ ordNos = Arrays.asList(ordNo.split(","));
|
|
|
568
|
+ }
|
|
|
569
|
+
|
|
|
570
|
+ List<OutRecord> list;
|
|
|
571
|
+ // 如果 limit <= 0,使用原来的全量查询
|
|
|
572
|
+ if (limit <= 0) {
|
|
|
573
|
+ list = outRecordMapper.selectExpt(wareName, stackName, model, materialName, standard, customerName,
|
|
|
574
|
+ plateNo, fromDate, toDate, userId, belongId, carNo, tallyPeople, ordNo, fkComponyName, pltNos, ordNos, remark1, contractNo, contractNos);
|
|
|
575
|
+ } else {
|
|
|
576
|
+ // 分批查询
|
|
|
577
|
+ list = outRecordMapper.selectForExport(wareName, stackName, model, materialName, standard, customerName,
|
|
|
578
|
+ plateNo, fromDate, toDate, userId, belongId, carNo, tallyPeople, ordNo, fkComponyName, pltNos, ordNos, remark1, contractNo, contractNos,
|
|
|
579
|
+ limit, offset);
|
|
|
580
|
+ }
|
|
|
581
|
+
|
|
|
582
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
583
|
+ for (OutRecord record : list) {
|
|
|
584
|
+ Map<String, Object> map = new LinkedHashMap<>();
|
|
|
585
|
+ // 仓库名称
|
|
|
586
|
+ map.put("wareName", record.getWareName() != null ? record.getWareName() : "");
|
|
|
587
|
+ // 垛位
|
|
|
588
|
+ map.put("stackName", record.getStackName() != null ? record.getStackName() : "");
|
|
|
589
|
+ // 层号
|
|
|
590
|
+ map.put("layer", record.getLayer() != null ? record.getLayer() : "");
|
|
|
591
|
+ // 品名
|
|
|
592
|
+ map.put("materialName", record.getMaterialName() != null ? record.getMaterialName() : "");
|
|
|
593
|
+ // 订单号
|
|
|
594
|
+ map.put("ordNo", record.getOrdNo() != null ? record.getOrdNo() : "");
|
|
|
595
|
+ // 入库人
|
|
|
596
|
+ map.put("inUser", record.getInUser() != null ? record.getInUser() : "");
|
|
|
597
|
+ // 入库车号
|
|
|
598
|
+ map.put("inCarNo", record.getInCarNo() != null ? record.getInCarNo() : "");
|
|
|
599
|
+ // 入库时间
|
|
|
600
|
+ map.put("inTime", record.getInTime() != null ? record.getInTime() : "");
|
|
|
601
|
+ // 规格型号
|
|
|
602
|
+ map.put("model", record.getModel() != null ? record.getModel() : "");
|
|
|
603
|
+ // 钢种/规格
|
|
|
604
|
+ map.put("standard", record.getStandard() != null ? record.getStandard() : "");
|
|
|
605
|
+ // 出库数量
|
|
|
606
|
+ map.put("count", record.getCount() != null ? record.getCount() : "");
|
|
|
607
|
+ // 出库重量
|
|
|
608
|
+ map.put("weight", record.getWeight() != null ? record.getWeight() : "");
|
|
|
609
|
+ // 钢板号
|
|
|
610
|
+ map.put("plateNo", record.getPlateNo() != null ? record.getPlateNo() : "");
|
|
|
611
|
+ // 订单客户
|
|
|
612
|
+ map.put("customerName", record.getCustomerName() != null ? record.getCustomerName() : "");
|
|
|
613
|
+ // 客户单位
|
|
|
614
|
+ map.put("fkComponyName", record.getFkComponyName() != null ? record.getFkComponyName() : "");
|
|
|
615
|
+ // 收货地址
|
|
|
616
|
+ map.put("receiveAddress", record.getReceiveAddress() != null ? record.getReceiveAddress() : "");
|
|
|
617
|
+ // 计量方式
|
|
|
618
|
+ map.put("wgtDcnMtcCd", record.getWgtDcnMtcCd() != null ? record.getWgtDcnMtcCd() : "");
|
|
|
619
|
+ // 切边类型
|
|
|
620
|
+ map.put("edgeTy", record.getEdgeTy() != null ? record.getEdgeTy() : "");
|
|
|
621
|
+ // 产地
|
|
|
622
|
+ map.put("productionPlace", record.getProductionPlace() != null ? record.getProductionPlace() : "");
|
|
|
623
|
+ // 出库车号
|
|
|
624
|
+ map.put("outCarNo", record.getOutCarNo() != null ? record.getOutCarNo() : "");
|
|
|
625
|
+ // 出库理货人员
|
|
|
626
|
+ map.put("tallyPeople", record.getTallyPeople() != null ? record.getTallyPeople() : "");
|
|
|
627
|
+ // 出库操作人
|
|
|
628
|
+ map.put("addId", record.getAddId() != null ? record.getAddId() : "");
|
|
|
629
|
+ // 出库时间
|
|
|
630
|
+ map.put("addTime", record.getAddTime() != null ? record.getAddTime() : "");
|
|
|
631
|
+ // 备注
|
|
|
632
|
+ map.put("remark", record.getRemark() != null ? record.getRemark() : "");
|
|
|
633
|
+ // 垛位备注
|
|
|
634
|
+ map.put("remark1", record.getRemark1() != null ? record.getRemark1() : "");
|
|
|
635
|
+ // 类型
|
|
|
636
|
+ map.put("recordType", record.getRecordType() != null ? record.getRecordType() : "");
|
|
|
637
|
+ // 合约号
|
|
|
638
|
+ map.put("contractNo", record.getContractNo() != null ? record.getContractNo() : "");
|
|
|
639
|
+ resultList.add(map);
|
|
|
640
|
+ }
|
|
|
641
|
+ return resultList;
|
|
389
|
642
|
}
|
|
|
643
|
+
|
|
|
644
|
+ /**
|
|
|
645
|
+ * 导出库存Excel(使用StoreMapper查询,与入库/出库导出独立)
|
|
|
646
|
+ */
|
|
|
647
|
+ @Override
|
|
|
648
|
+ public List<Map<String, Object>> exportStoreForExcel(String wareName, String stackName, String model, String materialName, String standard,
|
|
|
649
|
+ String customerName, String plateNo, String ordNo, String remark1, String fkcustmerName,
|
|
|
650
|
+ String userId, String belongId, int offset, int limit) {
|
|
|
651
|
+ // 空值处理
|
|
|
652
|
+ wareName = wareName == null ? "" : wareName;
|
|
|
653
|
+ stackName = stackName == null ? "" : stackName;
|
|
|
654
|
+ model = model == null ? "" : model;
|
|
|
655
|
+ materialName = materialName == null ? "" : materialName;
|
|
|
656
|
+ standard = standard == null ? "" : standard;
|
|
|
657
|
+ customerName = customerName == null ? "" : customerName;
|
|
|
658
|
+ plateNo = plateNo == null ? "" : plateNo;
|
|
|
659
|
+ ordNo = ordNo == null ? "" : ordNo;
|
|
|
660
|
+ remark1 = remark1 == null ? "" : remark1;
|
|
|
661
|
+ fkcustmerName = fkcustmerName == null ? "" : fkcustmerName;
|
|
|
662
|
+ userId = userId == null ? "" : userId;
|
|
|
663
|
+ belongId = belongId == null ? "" : belongId;
|
|
|
664
|
+
|
|
|
665
|
+ List<String> pltNos = new ArrayList<>();
|
|
|
666
|
+ List<String> ordNos = new ArrayList<>();
|
|
|
667
|
+ if (plateNo.indexOf(",") != -1) {
|
|
|
668
|
+ pltNos = Arrays.asList(plateNo.split(","));
|
|
|
669
|
+ }
|
|
|
670
|
+ if (ordNo.indexOf(",") != -1) {
|
|
|
671
|
+ ordNos = Arrays.asList(ordNo.split(","));
|
|
|
672
|
+ }
|
|
|
673
|
+
|
|
|
674
|
+ // 直接使用 selectStoreForExport 查询,返回 List<Map>
|
|
|
675
|
+ return storeMapper.selectStoreForExport(wareName, stackName, model, materialName, standard,
|
|
|
676
|
+ customerName, plateNo, ordNo, pltNos, ordNos, userId, belongId, remark1, fkcustmerName, limit, offset);
|
|
|
677
|
+ }
|
|
|
678
|
+
|
|
390
|
679
|
}
|