胡北宽 il y a 1 mois
Parent
révision
93d9b04520

+ 9
- 0
src/main/java/com/example/backend/entity/common/CustCtrl.java Voir le fichier

@@ -488,6 +488,15 @@ public class CustCtrl {
488 488
     @TableField(exist = false)
489 489
     private String allocationCategory;
490 490
 
491
+    //国家
492
+    @TableField(exist = false)
493
+    private String countryCnNm;
494
+
495
+    //签约地
496
+    @TableField(exist = false)
497
+    private String signLoc;
498
+
499
+
491 500
 
492 501
 
493 502
 

+ 4
- 0
src/main/java/com/example/backend/entity/common/SysUser.java Voir le fichier

@@ -274,6 +274,10 @@ public class SysUser {
274 274
     @TableField(exist = false)
275 275
     private String deptCode;
276 276
 
277
+    //
278
+    @TableField(exist = false)
279
+    private String cpny;
280
+
277 281
 
278 282
 
279 283
 

+ 2
- 2
src/main/java/com/example/backend/excel/SalesContractExcelDTO.java Voir le fichier

@@ -50,7 +50,7 @@ public class SalesContractExcelDTO {
50 50
     @ExcelProperty("币别")
51 51
     private String curcy;
52 52
 
53
-    @ExcelProperty("最迟装运日期")
53
+    @ExcelProperty("最迟装运时间")
54 54
     private Date estLoadDt;
55 55
 
56 56
     @ExcelProperty("价格条款")
@@ -59,7 +59,7 @@ public class SalesContractExcelDTO {
59 59
     @ExcelProperty("运输方式")
60 60
     private String tranWay;
61 61
 
62
-    @ExcelProperty("预计客商占天数")
62
+    @ExcelProperty("预计客商占天数")
63 63
     private Integer outstandingDay;
64 64
 
65 65
 

+ 42
- 31
src/main/java/com/example/backend/service/contract/impl/SalesContractServiceImpl.java Voir le fichier

@@ -202,6 +202,11 @@ public class SalesContractServiceImpl implements SalesContractService {
202 202
                         currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:客户代码不能为空!");
203 203
                         currentContractValid = false;
204 204
                     }
205
+
206
+
207
+
208
+
209
+
205 210
                     if (ctNameList != null && !ctNameList.isEmpty() && !ctNameList.get(0).getFno().isEmpty()) {
206 211
                         entity.setCtNo(ctNameList.get(0).getFno());
207 212
                     }
@@ -217,6 +222,7 @@ public class SalesContractServiceImpl implements SalesContractService {
217 222
                         entity.setCtBankAcct(ctNameList.get(0).getCtBankAcct());
218 223
                     }
219 224
 
225
+
220 226
                     if (StringUtils.isEmpty(entity.getCurcy())) {
221 227
                         currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:币别不能为空!");
222 228
                         currentContractValid = false;
@@ -283,6 +289,10 @@ public class SalesContractServiceImpl implements SalesContractService {
283 289
                         entity.setOurBankAcct(foursnameList.get(0).getOurBankAcct());
284 290
                     }
285 291
 
292
+                    if (foursnameList != null && !foursnameList.isEmpty() && !foursnameList.get(0).getSignLoc().isEmpty()) {
293
+                        entity.setSignLoc(foursnameList.get(0).getSignLoc());
294
+                    }
295
+
286 296
                     if (StringUtils.isEmpty(entity.getIfClearBottom())) {
287 297
                         entity.setIfClearBottom("否");
288 298
                     }
@@ -332,12 +342,12 @@ public class SalesContractServiceImpl implements SalesContractService {
332 342
                         if (lPortList != null && !lPortList.isEmpty() && !lPortList.get(0).getFno().isEmpty()) {
333 343
                             entity.setLpno(lPortList.get(0).getFno());
334 344
                         }
335
-                        if (lPortList != null && !lPortList.isEmpty() && lPortList.get(0).getCountryName().isEmpty()) {
345
+                        if (lPortList != null && !lPortList.isEmpty() && lPortList.get(0).getCountryCnNm().isEmpty()) {
336 346
                             currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:装运国不能为空!");
337 347
                             currentContractValid = false;
338 348
                         }
339
-                        if (lPortList != null && !lPortList.isEmpty() && !lPortList.get(0).getCountryName().isEmpty()) {
340
-                            entity.setLPortCtry(lPortList.get(0).getCountryName());
349
+                        if (lPortList != null && !lPortList.isEmpty() && !lPortList.get(0).getCountryCnNm().isEmpty()) {
350
+                            entity.setLPortCtry(lPortList.get(0).getCountryCnNm());
341 351
                         }
342 352
 
343 353
                         if (StringUtils.isEmpty(entity.getDPort())) {
@@ -352,12 +362,12 @@ public class SalesContractServiceImpl implements SalesContractService {
352 362
                         if (dPortList != null && !dPortList.isEmpty() && !dPortList.get(0).getFno().isEmpty()) {
353 363
                             entity.setDpno(dPortList.get(0).getFno());
354 364
                         }
355
-                        if (dPortList != null && !dPortList.isEmpty() && dPortList.get(0).getCountryName().isEmpty()) {
365
+                        if (dPortList != null && !dPortList.isEmpty() && dPortList.get(0).getCountryCnNm().isEmpty()) {
356 366
                             currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:目的国不能为空!");
357 367
                             currentContractValid = false;
358 368
                         }
359
-                        if (dPortList != null && !dPortList.isEmpty() && !dPortList.get(0).getCountryName().isEmpty()) {
360
-                            entity.setDPortCtry(dPortList.get(0).getCountryName());
369
+                        if (dPortList != null && !dPortList.isEmpty() && !dPortList.get(0).getCountryCnNm().isEmpty()) {
370
+                            entity.setDPortCtry(dPortList.get(0).getCountryCnNm());
361 371
                         }
362 372
                     }
363 373
 
@@ -411,29 +421,30 @@ public class SalesContractServiceImpl implements SalesContractService {
411 421
                             currentContractValid = false;
412 422
                         }
413 423
 
414
-                        if ("出口销售".equals(entity.getBizType()) || "转口销售".equals(entity.getBizType())) {
415
-                            if (StringUtils.isEmpty(entity.getTerms())) {
416
-                                currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:合同类型为出口销售或转口销售时,价格条款不能为空");
424
+
425
+                    }
426
+                    if ("出口销售".equals(entity.getBizType()) || "转口销售".equals(entity.getBizType())) {
427
+                        if (StringUtils.isEmpty(entity.getTerms())) {
428
+                            currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:合同类型为出口销售或转口销售时,价格条款不能为空");
429
+                            currentContractValid = false;
430
+                        }
431
+                        if (!StringUtils.isEmpty(entity.getTerms())) {
432
+                            List<DataDic> termsList = dicMapper.selectDicByTerms(entity.getTerms());
433
+                            if (termsList == null || termsList.isEmpty()) {
434
+                                currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:没有在数据字典中匹配到的该价格条款的类型");
417 435
                                 currentContractValid = false;
418 436
                             }
419
-                            if (!StringUtils.isEmpty(entity.getTerms())) {
420
-                                List<DataDic> termsList = dicMapper.selectDicByTerms(entity.getTerms());
421
-                                if (termsList == null || termsList.isEmpty()) {
422
-                                    currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:没有在数据字典中匹配到的该价格条款的类型");
423
-                                    currentContractValid = false;
424
-                                }
425
-                            }
426 437
                         }
438
+                    }
427 439
 
428
-                        if ("是".equals(entity.getWhetherChartering())) {
429
-                            if (StringUtils.isEmpty(entity.getChnShipName())) {
430
-                                currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:是否租船为是时,中文船名不能为空");
431
-                                currentContractValid = false;
432
-                            }
433
-                            if (StringUtils.isEmpty(entity.getEngShipName())) {
434
-                                currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:是否租船为是时,英文船名不能为空");
435
-                                currentContractValid = false;
436
-                            }
440
+                    if ("是".equals(entity.getWhetherChartering())) {
441
+                        if (StringUtils.isEmpty(entity.getChnShipName())) {
442
+                            currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:是否租船为是时,中文船名不能为空");
443
+                            currentContractValid = false;
444
+                        }
445
+                        if (StringUtils.isEmpty(entity.getEngShipName())) {
446
+                            currentContractErrors.add("主表(Sheet1) 第 " + currentRow + " 行:是否租船为是时,英文船名不能为空");
447
+                            currentContractValid = false;
437 448
                         }
438 449
                     }
439 450
 
@@ -459,12 +470,12 @@ public class SalesContractServiceImpl implements SalesContractService {
459 470
                                 currentContractValid = false;
460 471
                             }
461 472
 
462
-                            if ("出口销售".equals(bizType) || "转口销售".equals(bizType)) {
463
-                                if (StringUtils.isEmpty(entity1.getBatchNo())) {
464
-                                    currentContractErrors.add("产品明细(Sheet2) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:合同类型为出口销售或转口销售时,批次号不能为空!");
465
-                                    currentContractValid = false;
466
-                                }
467
-                            }
473
+//                            if ("出口销售".equals(bizType) || "转口销售".equals(bizType)) {
474
+//                                if (StringUtils.isEmpty(entity1.getBatchNo())) {
475
+//                                    currentContractErrors.add("产品明细(Sheet2) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:合同类型为出口销售或转口销售时,批次号不能为空!");
476
+//                                    currentContractValid = false;
477
+//                                }
478
+//                            }
468 479
 
469 480
                             if (StringUtils.isEmpty(entity1.getItemno())) {
470 481
                                 currentContractErrors.add("产品明细(Sheet2) 合同号 " + currentSono + " 第 " + (i + 1) + " 行:商品编号不能为空!");

+ 73
- 83
src/main/java/com/example/backend/util/ExcelUtil.java Voir le fichier

@@ -3,15 +3,12 @@ package com.example.backend.util;
3 3
 import com.alibaba.excel.EasyExcel;
4 4
 import com.alibaba.excel.context.AnalysisContext;
5 5
 import com.alibaba.excel.event.AnalysisEventListener;
6
-import com.alibaba.excel.metadata.data.ReadCellData;
7 6
 import com.example.backend.excel.*;
8 7
 import org.springframework.web.multipart.MultipartFile;
9 8
 
10 9
 import java.io.IOException;
11 10
 import java.util.ArrayList;
12
-import java.util.HashMap;
13 11
 import java.util.List;
14
-import java.util.Map;
15 12
 
16 13
 /**
17 14
  * Excel解析工具类 - 销售合同专用
@@ -25,12 +22,13 @@ public class ExcelUtil {
25 22
         SimpleDataListener<SalesContractExcelDTO> listener = new SimpleDataListener<>();
26 23
         EasyExcel.read(file.getInputStream(), SalesContractExcelDTO.class, listener)
27 24
                 .sheet() // 不指定sheet名称,读取第一个sheet
28
-                .headRowNumber(2) // 跳过前2行,从第3行开始读取(索引从0开始)
25
+                .headRowNumber(2) // 跳过前1行,从第2行开始读取(索引从0开始)
29 26
                 .doRead();
30 27
 
31 28
         List<SalesContractExcelDTO> dataList = listener.getDataList();
32 29
         System.out.println("主表读取到 " + dataList.size() + " 条数据");
33 30
 
31
+        // 跳过前两条数据
34 32
         return dataList;
35 33
     }
36 34
 
@@ -41,10 +39,13 @@ public class ExcelUtil {
41 39
         SimpleDataListener<SalesDtlExcelDTO> listener = new SimpleDataListener<>();
42 40
         EasyExcel.read(file.getInputStream(), SalesDtlExcelDTO.class, listener)
43 41
                 .sheet(1) // 第二个sheet(索引从0开始)
44
-                .headRowNumber(2) // 跳过前2
42
+                .headRowNumber(1) // 跳过前0
45 43
                 .doRead();
46
-        System.out.println("产品明细读取到 " + listener.getDataList().size() + " 条数据");
47
-        return listener.getDataList();
44
+        List<SalesDtlExcelDTO> dataList = listener.getDataList();
45
+        System.out.println("产品明细读取到 " + dataList.size() + " 条数据");
46
+
47
+        // 跳过前两条数据
48
+        return dataList;
48 49
     }
49 50
 
50 51
     /**
@@ -54,10 +55,13 @@ public class ExcelUtil {
54 55
         SimpleDataListener<SalesCollectExcelDTO> listener = new SimpleDataListener<>();
55 56
         EasyExcel.read(file.getInputStream(), SalesCollectExcelDTO.class, listener)
56 57
                 .sheet(2) // 第三个sheet
57
-                .headRowNumber(2) // 跳过前2
58
+                .headRowNumber(1) // 跳过前0
58 59
                 .doRead();
59
-        System.out.println("收款计划读取到 " + listener.getDataList().size() + " 条数据");
60
-        return listener.getDataList();
60
+        List<SalesCollectExcelDTO> dataList = listener.getDataList();
61
+        System.out.println("收款计划读取到 " + dataList.size() + " 条数据");
62
+
63
+        // 跳过前两条数据
64
+        return dataList;
61 65
     }
62 66
 
63 67
     /**
@@ -67,102 +71,88 @@ public class ExcelUtil {
67 71
         SimpleDataListener<RCenterDtlExcelDTO> listener = new SimpleDataListener<>();
68 72
         EasyExcel.read(file.getInputStream(), RCenterDtlExcelDTO.class, listener)
69 73
                 .sheet(3) // 第四个sheet
70
-                .headRowNumber(2) // 跳过前2
74
+                .headRowNumber(1) // 跳过前0
71 75
                 .doRead();
72
-        System.out.println("责任中心读取到 " + listener.getDataList().size() + " 条数据");
73
-        return listener.getDataList();
76
+        List<RCenterDtlExcelDTO> dataList = listener.getDataList();
77
+        System.out.println("责任中心读取到 " + dataList.size() + " 条数据");
78
+
79
+        // 跳过前两条数据
80
+        return dataList;
74 81
     }
75 82
 
76 83
     /**
77
-     * 读取费用明细sheet - Sheet5
84
+     * 读取服务费率sheet - Sheet5
78 85
      */
79
-    public static List<FeeDtlExcelDTO> readFeelDtlSheet(MultipartFile file) throws IOException {
80
-        SimpleDataListener<FeeDtlExcelDTO> listener = new SimpleDataListener<>();
81
-        EasyExcel.read(file.getInputStream(), FeeDtlExcelDTO.class, listener)
86
+    public static List<ExpSvcRateExcelDTO> readExpSvcRateSheet(MultipartFile file) throws IOException {
87
+        SimpleDataListener<ExpSvcRateExcelDTO> listener = new SimpleDataListener<>();
88
+        EasyExcel.read(file.getInputStream(), ExpSvcRateExcelDTO.class, listener)
82 89
                 .sheet(4) // 第五个sheet
83
-                .headRowNumber(2) // 跳过前2
90
+                .headRowNumber(1) // 跳过前0
84 91
                 .doRead();
85
-        System.out.println("费用明细读取到 " + listener.getDataList().size() + " 条数据");
86
-        return listener.getDataList();
92
+        List<ExpSvcRateExcelDTO> dataList = listener.getDataList();
93
+        System.out.println("服务费率读取到 " + dataList.size() + " 条数据");
94
+
95
+        // 跳过前两条数据
96
+        return dataList;
87 97
     }
88 98
 
89 99
     /**
90
-     * 读取服务费率sheet - Sheet6
100
+     * 跳过列表的前两条数据
101
+     * 如果数据不足2条,返回空列表
91 102
      */
92
-    public static List<ExpSvcRateExcelDTO> readExpSvcRateSheet(MultipartFile file) throws IOException {
93
-        SimpleDataListener<ExpSvcRateExcelDTO> listener = new SimpleDataListener<>();
94
-        EasyExcel.read(file.getInputStream(), ExpSvcRateExcelDTO.class, listener)
95
-                .sheet(5) // 第六个sheet
96
-                .headRowNumber(2) // 跳过前2行
97
-                .doRead();
98
-        System.out.println("服务费率读取到 " + listener.getDataList().size() + " 条数据");
99
-        return listener.getDataList();
103
+    private static <T> List<T> skipFirstTwoRows(List<T> dataList) {
104
+        if (dataList == null || dataList.size() <= 2) {
105
+            System.out.println("数据不足2条,跳过后返回空列表");
106
+            return new ArrayList<>();
107
+        }
108
+
109
+        List<T> filteredList = new ArrayList<>(dataList.subList(2, dataList.size()));
110
+        System.out.println("跳过前2条数据后剩余: " + filteredList.size() + " 条");
111
+
112
+        // 打印跳过后的第一行数据用于调试
113
+        if (!filteredList.isEmpty()) {
114
+            System.out.println("跳过前2条后的第一行数据: " + filteredList.get(0));
115
+        }
116
+
117
+        return filteredList;
100 118
     }
101 119
 
102 120
     /**
103
-     * 调试方法:打印所有sheet的结构信息
121
+     * 读取Excel主表数据 - Sheet1(可配置跳过行数)
122
+     * @param skipRowsAfterHeader 跳过标题行后的行数
104 123
      */
105
-    public static void debugExcelStructure(MultipartFile file) throws IOException {
106
-        System.out.println("=== Excel结构调试信息 ===");
107
-
108
-        EasyExcel.read(file.getInputStream(), new AnalysisEventListener<Object>() {
109
-            private int rowCount = 0;
110
-
111
-            @Override
112
-            public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
113
-                String sheetName = context.readSheetHolder().getSheetName();
114
-                int sheetNo = context.readSheetHolder().getSheetNo();
115
-                System.out.println("Sheet" + sheetNo + " [" + sheetName + "] - 表头信息:");
116
-                headMap.forEach((index, name) -> {
117
-                    System.out.println("  列" + index + ": " + name);
118
-                });
119
-            }
124
+    public static List<SalesContractExcelDTO> readMainSheet(MultipartFile file, int skipRowsAfterHeader) throws IOException {
125
+        SimpleDataListener<SalesContractExcelDTO> listener = new SimpleDataListener<>();
126
+        EasyExcel.read(file.getInputStream(), SalesContractExcelDTO.class, listener)
127
+                .sheet()
128
+                .headRowNumber(1) // 标题行在第2行
129
+                .doRead();
120 130
 
121
-            @Override
122
-            public void invoke(Object data, AnalysisContext context) {
123
-                rowCount++;
124
-                if (rowCount <= 3) { // 只打印前3行数据
125
-                    System.out.println("Sheet: " + context.readSheetHolder().getSheetName() +
126
-                            " - 第" + rowCount + "行: " + data);
127
-                }
128
-            }
131
+        List<SalesContractExcelDTO> dataList = listener.getDataList();
132
+        System.out.println("主表读取到 " + dataList.size() + " 条数据");
129 133
 
130
-            @Override
131
-            public void doAfterAllAnalysed(AnalysisContext context) {
132
-                System.out.println("Sheet: " + context.readSheetHolder().getSheetName() +
133
-                        " 总行数: " + rowCount);
134
-                rowCount = 0; // 重置行计数
135
-            }
136
-        }).doReadAll();
134
+        // 跳过指定行数
135
+        return skipRows(dataList, skipRowsAfterHeader);
137 136
     }
138 137
 
139 138
     /**
140
-     * 获取Excel中所有Sheet的名称(用于调试)
139
+     * 通用跳过行数方法
140
+     * @param skipCount 要跳过的行数
141 141
      */
142
-    public static List<String> getSheetNames(MultipartFile file) throws IOException {
143
-        List<String> sheetNames = new ArrayList<>();
144
-        EasyExcel.read(file.getInputStream(), new AnalysisEventListener<Object>() {
145
-            @Override
146
-            public void invoke(Object data, AnalysisContext context) {
147
-                // 不处理数据,只获取sheet名称
148
-            }
142
+    private static <T> List<T> skipRows(List<T> dataList, int skipCount) {
143
+        if (dataList == null || dataList.size() <= skipCount) {
144
+            System.out.println("数据不足" + skipCount + "条,跳过后返回空列表");
145
+            return new ArrayList<>();
146
+        }
149 147
 
150
-            @Override
151
-            public void doAfterAllAnalysed(AnalysisContext context) {
152
-                // 完成分析
153
-            }
148
+        List<T> filteredList = new ArrayList<>(dataList.subList(skipCount, dataList.size()));
149
+        System.out.println("跳过前" + skipCount + "条数据后剩余: " + filteredList.size() + " 条");
154 150
 
155
-            @Override
156
-            public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
157
-                String sheetName = context.readSheetHolder().getSheetName();
158
-                if (!sheetNames.contains(sheetName)) {
159
-                    sheetNames.add(sheetName);
160
-                    System.out.println("发现Sheet: " + sheetName);
161
-                }
162
-            }
163
-        }).doReadAll();
151
+        if (!filteredList.isEmpty()) {
152
+            System.out.println("跳过前" + skipCount + "条后的第一行数据: " + filteredList.get(0));
153
+        }
164 154
 
165
-        return sheetNames;
155
+        return filteredList;
166 156
     }
167 157
 
168 158
     /**
@@ -176,7 +166,7 @@ public class ExcelUtil {
176 166
             dataList.add(data);
177 167
             // 打印第一行数据用于调试
178 168
             if (dataList.size() == 1) {
179
-                System.out.println("第一行数据示例: " + data.toString());
169
+                System.out.println("原始第一行数据: " + data.toString());
180 170
             }
181 171
         }
182 172
 

+ 1
- 1
src/main/resources/mapper/CustCtrlMapper.xml Voir le fichier

@@ -18,7 +18,7 @@
18 18
         order by a.fno desc
19 19
     </select>
20 20
     <select id="selectLPortByLportName" resultType="com.example.backend.entity.common.CustCtrl">
21
-        select fno,portName,portCd,portNm,country,countryName
21
+        select fno,portName,portCd,portNm,country,countryCnNm
22 22
         from SGGMIIP.portCtrl
23 23
         where nvl(del_flag, 0) !=1
24 24
         and isnull(country,'')!=''

Loading…
Annuler
Enregistrer