Browse Source

创建Excel解析时间格式的工具类,创建解析数字类型的工具类,并根据测试不断修改代码

胡北宽 4 months ago
parent
commit
da3d2f018c

+ 2
- 0
src/main/java/com/example/backend/BackendApplication.java View File

3
 import org.springframework.boot.SpringApplication;
3
 import org.springframework.boot.SpringApplication;
4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5
 import org.mybatis.spring.annotation.MapperScan;
5
 import org.mybatis.spring.annotation.MapperScan;
6
+import org.springframework.context.annotation.ComponentScan;
6
 
7
 
7
 @SpringBootApplication
8
 @SpringBootApplication
8
 @MapperScan({"com.example.backend.mapper", "com.example.backend.mapper.contract"})
9
 @MapperScan({"com.example.backend.mapper", "com.example.backend.mapper.contract"})
10
+// 确保扫描整个包
9
 public class BackendApplication {
11
 public class BackendApplication {
10
 
12
 
11
     public static void main(String[] args) {
13
     public static void main(String[] args) {

+ 1
- 1
src/main/java/com/example/backend/controller/contract/SalesContractController.java View File

13
  * 销售合同控制器
13
  * 销售合同控制器
14
  */
14
  */
15
 @RestController
15
 @RestController
16
-@RequestMapping("/api/contract")
16
+@RequestMapping("/salesContract")
17
 public class SalesContractController {
17
 public class SalesContractController {
18
 
18
 
19
     @Autowired
19
     @Autowired

+ 18
- 18
src/main/java/com/example/backend/entity/contract/SalesContractEntity.java View File

10
 
10
 
11
 import com.baomidou.mybatisplus.annotation.*;
11
 import com.baomidou.mybatisplus.annotation.*;
12
 
12
 
13
-import java.time.LocalDateTime;
13
+import java.util.Date;
14
 
14
 
15
 
15
 
16
 /**
16
 /**
30
 
30
 
31
     // 单据日期
31
     // 单据日期
32
     @TableField("fdate")
32
     @TableField("fdate")
33
-    private LocalDateTime fdate;
33
+    private Date fdate;
34
 
34
 
35
     // 销售合同号
35
     // 销售合同号
36
     @TableField("sono")
36
     @TableField("sono")
54
 
54
 
55
     // 签约日期
55
     // 签约日期
56
     @TableField("signDate")
56
     @TableField("signDate")
57
-    private LocalDateTime signDate;
57
+    private Date signDate;
58
 
58
 
59
     // 代理协议号
59
     // 代理协议号
60
     @TableField("agentNo")
60
     @TableField("agentNo")
66
 
66
 
67
     // 合同起始有效期
67
     // 合同起始有效期
68
     @TableField("contrStart")
68
     @TableField("contrStart")
69
-    private LocalDateTime contrStart;
69
+    private Date contrStart;
70
 
70
 
71
     // 合同截止有效期
71
     // 合同截止有效期
72
     @TableField("contrEnd")
72
     @TableField("contrEnd")
73
-    private LocalDateTime contrEnd;
73
+    private Date contrEnd;
74
 
74
 
75
     // 销售交货日期
75
     // 销售交货日期
76
     @TableField("sDelivDt")
76
     @TableField("sDelivDt")
77
-    private LocalDateTime sDelivDt;
77
+    private Date sDelivDt;
78
 
78
 
79
     // 合同描述
79
     // 合同描述
80
     @TableField("contrDesc")
80
     @TableField("contrDesc")
246
 
246
 
247
     // 客户履约保证金支付日期
247
     // 客户履约保证金支付日期
248
     @TableField("ctPerfPayDt")
248
     @TableField("ctPerfPayDt")
249
-    private LocalDateTime ctPerfPayDt;
249
+    private Date ctPerfPayDt;
250
 
250
 
251
     // 客户履约保证金比例
251
     // 客户履约保证金比例
252
     @TableField("ctPerfRatio")
252
     @TableField("ctPerfRatio")
254
 
254
 
255
     // 合同完结付款日期
255
     // 合同完结付款日期
256
     @TableField("contrFinalPayDt")
256
     @TableField("contrFinalPayDt")
257
-    private LocalDateTime contrFinalPayDt;
257
+    private Date contrFinalPayDt;
258
 
258
 
259
     // 合同违约金比例
259
     // 合同违约金比例
260
     @TableField("contrPenaltyRatio")
260
     @TableField("contrPenaltyRatio")
362
 
362
 
363
     // 合同变更日期
363
     // 合同变更日期
364
     @TableField("changeDate")
364
     @TableField("changeDate")
365
-    private LocalDateTime changeDate;
365
+    private Date changeDate;
366
 
366
 
367
     // 变更协议号
367
     // 变更协议号
368
     @TableField("changeAgreementNo")
368
     @TableField("changeAgreementNo")
450
 
450
 
451
     // 创建时间
451
     // 创建时间
452
     @TableField("create_time")
452
     @TableField("create_time")
453
-    private LocalDateTime createTime;
453
+    private Date createTime;
454
 
454
 
455
     // 创建人
455
     // 创建人
456
     @TableField("create_by_name")
456
     @TableField("create_by_name")
462
 
462
 
463
     // 更新时间
463
     // 更新时间
464
     @TableField("update_time")
464
     @TableField("update_time")
465
-    private LocalDateTime updateTime;
465
+    private Date updateTime;
466
 
466
 
467
     // 更新人
467
     // 更新人
468
     @TableField("update_by_name")
468
     @TableField("update_by_name")
530
 
530
 
531
     // 签约日期
531
     // 签约日期
532
     @TableField("signDt")
532
     @TableField("signDt")
533
-    private LocalDateTime signDt;
533
+    private Date signDt;
534
 
534
 
535
     // 合同生效日期
535
     // 合同生效日期
536
     @TableField("validDate")
536
     @TableField("validDate")
537
-    private LocalDateTime validDate;
537
+    private Date validDate;
538
 
538
 
539
     // 合同执行人机构代码
539
     // 合同执行人机构代码
540
     @TableField("contrExecCdInstitutionId")
540
     @TableField("contrExecCdInstitutionId")
598
 
598
 
599
     // 变更时间
599
     // 变更时间
600
     @TableField("curChangeTime")
600
     @TableField("curChangeTime")
601
-    private LocalDateTime curChangeTime;
601
+    private Date curChangeTime;
602
 
602
 
603
     // 变更人
603
     // 变更人
604
     @TableField("curChangeUser")
604
     @TableField("curChangeUser")
686
 
686
 
687
     // 最迟装运日期
687
     // 最迟装运日期
688
     @TableField("estLoadDt")
688
     @TableField("estLoadDt")
689
-    private LocalDateTime estLoadDt;
689
+    private Date estLoadDt;
690
 
690
 
691
     // 最迟集港日期
691
     // 最迟集港日期
692
     @TableField("estArrDt")
692
     @TableField("estArrDt")
693
-    private LocalDateTime estArrDt;
693
+    private Date estArrDt;
694
 
694
 
695
     // 合同借壳评审人
695
     // 合同借壳评审人
696
     @TableField("reviewer")
696
     @TableField("reviewer")
710
 
710
 
711
     // 提交审批日期
711
     // 提交审批日期
712
     @TableField("submissionDate")
712
     @TableField("submissionDate")
713
-    private LocalDateTime submissionDate;
713
+    private Date submissionDate;
714
 
714
 
715
     // 审批生效日期
715
     // 审批生效日期
716
     @TableField("appEffectiveDate")
716
     @TableField("appEffectiveDate")
717
-    private LocalDateTime appEffectiveDate;
717
+    private Date appEffectiveDate;
718
 
718
 
719
     // 保供合同一键三联类型
719
     // 保供合同一键三联类型
720
     @TableField("oneClickSourcetype")
720
     @TableField("oneClickSourcetype")

+ 95
- 0
src/main/java/com/example/backend/excel/DateUtils.java View File

1
+package com.example.backend.excel;
2
+
3
+import java.time.LocalDateTime;
4
+import java.time.format.DateTimeFormatter;
5
+import java.time.format.DateTimeParseException;
6
+import java.util.ArrayList;
7
+import java.util.Date;
8
+import java.util.List;
9
+
10
+public class DateUtils {
11
+
12
+    private static final List<DateTimeFormatter> FORMATTERS = new ArrayList<>();
13
+
14
+    static {
15
+        FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
16
+        FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
17
+        FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
18
+        FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
19
+        FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"));
20
+        FORMATTERS.add(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
21
+        FORMATTERS.add(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
22
+        FORMATTERS.add(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
23
+        FORMATTERS.add(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
24
+        FORMATTERS.add(DateTimeFormatter.ISO_LOCAL_DATE);
25
+    }
26
+
27
+    /**
28
+     * 将字符串转换为 LocalDateTime
29
+     */
30
+    public static LocalDateTime parseToLocalDateTime(String dateStr) {
31
+        if (dateStr == null || dateStr.trim().isEmpty()) {
32
+            return null;
33
+        }
34
+
35
+        String trimmedStr = dateStr.trim();
36
+
37
+        // 尝试所有格式
38
+        for (DateTimeFormatter formatter : FORMATTERS) {
39
+            try {
40
+                return LocalDateTime.parse(trimmedStr, formatter);
41
+            } catch (DateTimeParseException e) {
42
+                // 继续尝试下一个格式
43
+            }
44
+        }
45
+
46
+        System.err.println("无法解析日期字符串: " + dateStr);
47
+        return null;
48
+    }
49
+
50
+    /**
51
+     * 将字符串直接转换为 Date
52
+     */
53
+    public static Date parseToDate(String dateStr) {
54
+        if (dateStr == null || dateStr.trim().isEmpty()) {
55
+            return null;
56
+        }
57
+
58
+        String trimmedStr = dateStr.trim();
59
+
60
+        // 尝试所有格式
61
+        for (DateTimeFormatter formatter : FORMATTERS) {
62
+            try {
63
+                LocalDateTime localDateTime = LocalDateTime.parse(trimmedStr, formatter);
64
+                return java.sql.Timestamp.valueOf(localDateTime);
65
+            } catch (DateTimeParseException e) {
66
+                // 继续尝试下一个格式
67
+            }
68
+        }
69
+
70
+        System.err.println("无法解析日期字符串: " + dateStr);
71
+        return null;
72
+    }
73
+
74
+    /**
75
+     * 将 LocalDateTime 转换为 Date
76
+     */
77
+    public static Date toDate(LocalDateTime localDateTime) {
78
+        if (localDateTime == null) {
79
+            return null;
80
+        }
81
+        return java.sql.Timestamp.valueOf(localDateTime);
82
+    }
83
+
84
+    /**
85
+     * 将 Date 转换为 LocalDateTime
86
+     */
87
+    public static LocalDateTime toLocalDateTime(Date date) {
88
+        if (date == null) {
89
+            return null;
90
+        }
91
+        return date.toInstant()
92
+                .atZone(java.time.ZoneId.systemDefault())
93
+                .toLocalDateTime();
94
+    }
95
+}

+ 206
- 0
src/main/java/com/example/backend/excel/ExcelUtil.java View File

1
+package com.example.backend.excel;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.context.AnalysisContext;
5
+import com.alibaba.excel.event.AnalysisEventListener;
6
+import com.alibaba.excel.metadata.data.ReadCellData;
7
+import org.springframework.web.multipart.MultipartFile;
8
+
9
+import java.io.IOException;
10
+import java.util.ArrayList;
11
+import java.util.HashMap;
12
+import java.util.List;
13
+import java.util.Map;
14
+
15
+/**
16
+ * Excel解析工具类 - 销售合同专用
17
+ */
18
+public class ExcelUtil {
19
+
20
+    /**
21
+     * 读取Excel主表数据 - Sheet1
22
+     */
23
+    public static List<SalesContractExcelDTO> readMainSheet(MultipartFile file) throws IOException {
24
+        SimpleDataListener<SalesContractExcelDTO> listener = new SimpleDataListener<>();
25
+        EasyExcel.read(file.getInputStream(), SalesContractExcelDTO.class, listener)
26
+                .sheet() // 不指定sheet名称,读取第一个sheet
27
+                .headRowNumber(2) // 跳过前2行,从第3行开始读取(索引从0开始)
28
+                .doRead();
29
+
30
+        List<SalesContractExcelDTO> dataList = listener.getDataList();
31
+        System.out.println("主表读取到 " + dataList.size() + " 条数据");
32
+
33
+        // 打印表头信息用于调试
34
+        if (!dataList.isEmpty()) {
35
+            SalesContractExcelDTO firstRow = dataList.get(0);
36
+            System.out.println("=== 第一行数据详情 ===");
37
+            System.out.println("销售合同号: " + firstRow.getSono());
38
+            System.out.println("制单人代码: " + firstRow.getCreateBy());
39
+            System.out.println("业务类型: " + firstRow.getServiceType());
40
+            System.out.println("合同类型: " + firstRow.getBizType());
41
+            System.out.println("合同产品类型: " + firstRow.getBizProductType());
42
+            System.out.println("最迟集港日期: " + firstRow.getEstArrDt());
43
+            System.out.println("最迟装运日期: " + firstRow.getEstLoadDt());
44
+            System.out.println("预计客商占款天数: " + firstRow.getOutstandingDay());
45
+            // 可以根据需要打印更多字段...
46
+        }
47
+
48
+        return dataList;
49
+    }
50
+
51
+    /**
52
+     * 读取产品明细sheet - Sheet2
53
+     */
54
+    public static List<SalesDtlExcelDTO> readSalesDtlSheet(MultipartFile file) throws IOException {
55
+        SimpleDataListener<SalesDtlExcelDTO> listener = new SimpleDataListener<>();
56
+        EasyExcel.read(file.getInputStream(), SalesDtlExcelDTO.class, listener)
57
+                .sheet(1) // 第二个sheet(索引从0开始)
58
+                .headRowNumber(2) // 跳过前2行
59
+                .doRead();
60
+        System.out.println("产品明细读取到 " + listener.getDataList().size() + " 条数据");
61
+        return listener.getDataList();
62
+    }
63
+
64
+    /**
65
+     * 读取收款计划sheet - Sheet3
66
+     */
67
+    public static List<SalesCollectExcelDTO> readSalesCollectSheet(MultipartFile file) throws IOException {
68
+        SimpleDataListener<SalesCollectExcelDTO> listener = new SimpleDataListener<>();
69
+        EasyExcel.read(file.getInputStream(), SalesCollectExcelDTO.class, listener)
70
+                .sheet(2) // 第三个sheet
71
+                .headRowNumber(2) // 跳过前2行
72
+                .doRead();
73
+        System.out.println("收款计划读取到 " + listener.getDataList().size() + " 条数据");
74
+        return listener.getDataList();
75
+    }
76
+
77
+    /**
78
+     * 读取责任中心sheet - Sheet4
79
+     */
80
+    public static List<RCenterDtlExcelDTO> readRCenterDtlSheet(MultipartFile file) throws IOException {
81
+        SimpleDataListener<RCenterDtlExcelDTO> listener = new SimpleDataListener<>();
82
+        EasyExcel.read(file.getInputStream(), RCenterDtlExcelDTO.class, listener)
83
+                .sheet(3) // 第四个sheet
84
+                .headRowNumber(2) // 跳过前2行
85
+                .doRead();
86
+        System.out.println("责任中心读取到 " + listener.getDataList().size() + " 条数据");
87
+        return listener.getDataList();
88
+    }
89
+
90
+    /**
91
+     * 读取费用明细sheet - Sheet5
92
+     */
93
+    public static List<FeeDtlExcelDTO> readFeelDtlSheet(MultipartFile file) throws IOException {
94
+        SimpleDataListener<FeeDtlExcelDTO> listener = new SimpleDataListener<>();
95
+        EasyExcel.read(file.getInputStream(), FeeDtlExcelDTO.class, listener)
96
+                .sheet(4) // 第五个sheet
97
+                .headRowNumber(2) // 跳过前2行
98
+                .doRead();
99
+        System.out.println("费用明细读取到 " + listener.getDataList().size() + " 条数据");
100
+        return listener.getDataList();
101
+    }
102
+
103
+    /**
104
+     * 读取服务费率sheet - Sheet6
105
+     */
106
+    public static List<ExpSvcRateExcelDTO> readExpSvcRateSheet(MultipartFile file) throws IOException {
107
+        SimpleDataListener<ExpSvcRateExcelDTO> listener = new SimpleDataListener<>();
108
+        EasyExcel.read(file.getInputStream(), ExpSvcRateExcelDTO.class, listener)
109
+                .sheet(5) // 第六个sheet
110
+                .headRowNumber(2) // 跳过前2行
111
+                .doRead();
112
+        System.out.println("服务费率读取到 " + listener.getDataList().size() + " 条数据");
113
+        return listener.getDataList();
114
+    }
115
+
116
+    /**
117
+     * 调试方法:打印所有sheet的结构信息
118
+     */
119
+    public static void debugExcelStructure(MultipartFile file) throws IOException {
120
+        System.out.println("=== Excel结构调试信息 ===");
121
+
122
+        EasyExcel.read(file.getInputStream(), new AnalysisEventListener<Object>() {
123
+            private int rowCount = 0;
124
+
125
+            @Override
126
+            public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
127
+                String sheetName = context.readSheetHolder().getSheetName();
128
+                int sheetNo = context.readSheetHolder().getSheetNo();
129
+                System.out.println("Sheet" + sheetNo + " [" + sheetName + "] - 表头信息:");
130
+                headMap.forEach((index, name) -> {
131
+                    System.out.println("  列" + index + ": " + name);
132
+                });
133
+            }
134
+
135
+            @Override
136
+            public void invoke(Object data, AnalysisContext context) {
137
+                rowCount++;
138
+                if (rowCount <= 3) { // 只打印前3行数据
139
+                    System.out.println("Sheet: " + context.readSheetHolder().getSheetName() +
140
+                            " - 第" + rowCount + "行: " + data);
141
+                }
142
+            }
143
+
144
+            @Override
145
+            public void doAfterAllAnalysed(AnalysisContext context) {
146
+                System.out.println("Sheet: " + context.readSheetHolder().getSheetName() +
147
+                        " 总行数: " + rowCount);
148
+                rowCount = 0; // 重置行计数
149
+            }
150
+        }).doReadAll();
151
+    }
152
+
153
+    /**
154
+     * 获取Excel中所有Sheet的名称(用于调试)
155
+     */
156
+    public static List<String> getSheetNames(MultipartFile file) throws IOException {
157
+        List<String> sheetNames = new ArrayList<>();
158
+        EasyExcel.read(file.getInputStream(), new AnalysisEventListener<Object>() {
159
+            @Override
160
+            public void invoke(Object data, AnalysisContext context) {
161
+                // 不处理数据,只获取sheet名称
162
+            }
163
+
164
+            @Override
165
+            public void doAfterAllAnalysed(AnalysisContext context) {
166
+                // 完成分析
167
+            }
168
+
169
+            @Override
170
+            public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
171
+                String sheetName = context.readSheetHolder().getSheetName();
172
+                if (!sheetNames.contains(sheetName)) {
173
+                    sheetNames.add(sheetName);
174
+                    System.out.println("发现Sheet: " + sheetName);
175
+                }
176
+            }
177
+        }).doReadAll();
178
+
179
+        return sheetNames;
180
+    }
181
+
182
+    /**
183
+     * 简单的数据监听器
184
+     */
185
+    private static class SimpleDataListener<T> extends AnalysisEventListener<T> {
186
+        private final List<T> dataList = new ArrayList<>();
187
+
188
+        @Override
189
+        public void invoke(T data, AnalysisContext context) {
190
+            dataList.add(data);
191
+            // 打印第一行数据用于调试
192
+            if (dataList.size() == 1) {
193
+                System.out.println("第一行数据示例: " + data.toString());
194
+            }
195
+        }
196
+
197
+        @Override
198
+        public void doAfterAllAnalysed(AnalysisContext context) {
199
+            // 所有数据解析完成
200
+        }
201
+
202
+        public List<T> getDataList() {
203
+            return dataList;
204
+        }
205
+    }
206
+}

+ 15
- 20
src/main/java/com/example/backend/excel/ExcelUtils.java View File

76
         SimpleDataListener<SalesContractExcelDTO> listener = new SimpleDataListener<SalesContractExcelDTO>();
76
         SimpleDataListener<SalesContractExcelDTO> listener = new SimpleDataListener<SalesContractExcelDTO>();
77
         EasyExcel.read(file.getInputStream(), SalesContractExcelDTO.class, listener)
77
         EasyExcel.read(file.getInputStream(), SalesContractExcelDTO.class, listener)
78
                 .sheet(0) // 第一个sheet
78
                 .sheet(0) // 第一个sheet
79
+                .headRowNumber(1) // 从第二行开始读取(跳过标题行)
79
                 .doRead();
80
                 .doRead();
80
         return listener.getDataList();
81
         return listener.getDataList();
81
     }
82
     }
137
     }
138
     }
138
 
139
 
139
 
140
 
140
-    /**
141
-     *读取合同产品明细sheet
142
-     */
141
+    // 产品明细Sheet
143
     public static List<SalesDtlExcelDTO> readSalesDtlSheet(MultipartFile file) throws IOException {
142
     public static List<SalesDtlExcelDTO> readSalesDtlSheet(MultipartFile file) throws IOException {
144
         SimpleDataListener<SalesDtlExcelDTO> listener = new SimpleDataListener<SalesDtlExcelDTO>();
143
         SimpleDataListener<SalesDtlExcelDTO> listener = new SimpleDataListener<SalesDtlExcelDTO>();
145
         EasyExcel.read(file.getInputStream(), SalesDtlExcelDTO.class, listener)
144
         EasyExcel.read(file.getInputStream(), SalesDtlExcelDTO.class, listener)
146
-                .sheet(5) // 第六个sheet
145
+                .sheet(1) // 第二个sheet
146
+                .headRowNumber(1) // 从第二行开始读取
147
                 .doRead();
147
                 .doRead();
148
         return listener.getDataList();
148
         return listener.getDataList();
149
     }
149
     }
150
 
150
 
151
-    /**
152
-     *读取收款计划sheet
153
-     */
151
+    // 收款计划Sheet
154
     public static List<SalesCollectExcelDTO> readSalesCollectSheet(MultipartFile file) throws IOException {
152
     public static List<SalesCollectExcelDTO> readSalesCollectSheet(MultipartFile file) throws IOException {
155
         SimpleDataListener<SalesCollectExcelDTO> listener = new SimpleDataListener<SalesCollectExcelDTO>();
153
         SimpleDataListener<SalesCollectExcelDTO> listener = new SimpleDataListener<SalesCollectExcelDTO>();
156
         EasyExcel.read(file.getInputStream(), SalesCollectExcelDTO.class, listener)
154
         EasyExcel.read(file.getInputStream(), SalesCollectExcelDTO.class, listener)
157
-                .sheet(5) // 第六个sheet
155
+                .sheet(2) // 第三个sheet
156
+                .headRowNumber(1) // 从第二行开始读取
158
                 .doRead();
157
                 .doRead();
159
         return listener.getDataList();
158
         return listener.getDataList();
160
     }
159
     }
161
 
160
 
162
-
163
-    /**
164
-     *读取责任中心sheet
165
-     */
161
+    // 责任中心Sheet
166
     public static List<RCenterDtlExcelDTO> readRCenterDtlSheet(MultipartFile file) throws IOException {
162
     public static List<RCenterDtlExcelDTO> readRCenterDtlSheet(MultipartFile file) throws IOException {
167
         SimpleDataListener<RCenterDtlExcelDTO> listener = new SimpleDataListener<RCenterDtlExcelDTO>();
163
         SimpleDataListener<RCenterDtlExcelDTO> listener = new SimpleDataListener<RCenterDtlExcelDTO>();
168
         EasyExcel.read(file.getInputStream(), RCenterDtlExcelDTO.class, listener)
164
         EasyExcel.read(file.getInputStream(), RCenterDtlExcelDTO.class, listener)
169
-                .sheet(5) // 第六个sheet
165
+                .sheet(3) // 第四个sheet
166
+                .headRowNumber(1) // 从第二行开始读取
170
                 .doRead();
167
                 .doRead();
171
         return listener.getDataList();
168
         return listener.getDataList();
172
     }
169
     }
173
 
170
 
174
-    /**
175
-     *读取费用明细sheet
176
-     */
171
+    // 费用明细Sheet
177
     public static List<FeeDtlExcelDTO> readFeelDtlSheet(MultipartFile file) throws IOException {
172
     public static List<FeeDtlExcelDTO> readFeelDtlSheet(MultipartFile file) throws IOException {
178
         SimpleDataListener<FeeDtlExcelDTO> listener = new SimpleDataListener<FeeDtlExcelDTO>();
173
         SimpleDataListener<FeeDtlExcelDTO> listener = new SimpleDataListener<FeeDtlExcelDTO>();
179
         EasyExcel.read(file.getInputStream(), FeeDtlExcelDTO.class, listener)
174
         EasyExcel.read(file.getInputStream(), FeeDtlExcelDTO.class, listener)
180
-                .sheet(5) // 第六个sheet
175
+                .sheet(4) // 第五个sheet
176
+                .headRowNumber(1) // 从第二行开始读取
181
                 .doRead();
177
                 .doRead();
182
         return listener.getDataList();
178
         return listener.getDataList();
183
     }
179
     }
184
 
180
 
185
-    /**
186
-     *读取服务费率sheet
187
-     */
181
+    // 服务费率Sheet
188
     public static List<ExpSvcRateExcelDTO> readExpSvcRateSheet(MultipartFile file) throws IOException {
182
     public static List<ExpSvcRateExcelDTO> readExpSvcRateSheet(MultipartFile file) throws IOException {
189
         SimpleDataListener<ExpSvcRateExcelDTO> listener = new SimpleDataListener<ExpSvcRateExcelDTO>();
183
         SimpleDataListener<ExpSvcRateExcelDTO> listener = new SimpleDataListener<ExpSvcRateExcelDTO>();
190
         EasyExcel.read(file.getInputStream(), ExpSvcRateExcelDTO.class, listener)
184
         EasyExcel.read(file.getInputStream(), ExpSvcRateExcelDTO.class, listener)
191
                 .sheet(5) // 第六个sheet
185
                 .sheet(5) // 第六个sheet
186
+                .headRowNumber(1) // 从第二行开始读取
192
                 .doRead();
187
                 .doRead();
193
         return listener.getDataList();
188
         return listener.getDataList();
194
     }
189
     }

+ 67
- 0
src/main/java/com/example/backend/excel/LocalDateTimeConverter.java View File

1
+package com.example.backend.excel;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.converters.ReadConverterContext;
5
+import com.alibaba.excel.converters.WriteConverterContext;
6
+import com.alibaba.excel.enums.CellDataTypeEnum;
7
+import com.alibaba.excel.metadata.data.WriteCellData;
8
+import org.springframework.stereotype.Service;
9
+
10
+import java.time.LocalDateTime;
11
+import java.time.ZoneId;
12
+import java.time.format.DateTimeFormatter;
13
+import java.util.Date;
14
+@Service
15
+public class LocalDateTimeConverter implements Converter<LocalDateTime> {
16
+    
17
+    private static final DateTimeFormatter FORMatter = 
18
+        DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
19
+
20
+    @Override
21
+    public Class<?> supportJavaTypeKey() {
22
+        return LocalDateTime.class;
23
+    }
24
+
25
+    @Override
26
+    public CellDataTypeEnum supportExcelTypeKey() {
27
+        return CellDataTypeEnum.STRING;
28
+    }
29
+
30
+    @Override
31
+    public LocalDateTime convertToJavaData(ReadConverterContext<?> context) throws Exception {
32
+        // 处理数字格式的日期(Excel日期存储为数字)
33
+        if (context.getReadCellData().getType() == CellDataTypeEnum.NUMBER) {
34
+            Date date = org.apache.poi.ss.usermodel.DateUtil
35
+                .getJavaDate(context.getReadCellData().getNumberValue().doubleValue());
36
+            return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
37
+        }
38
+        
39
+        // 处理字符串格式的日期
40
+        String stringValue = context.getReadCellData().getStringValue();
41
+        if (stringValue == null || stringValue.trim().isEmpty()) {
42
+            return null;
43
+        }
44
+        
45
+        try {
46
+            // 根据你的Excel实际日期格式调整
47
+            return LocalDateTime.parse(stringValue, FORMatter);
48
+        } catch (Exception e) {
49
+            // 如果解析失败,尝试其他格式
50
+            try {
51
+                DateTimeFormatter alternativeFormatter = 
52
+                    DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
53
+                return LocalDateTime.parse(stringValue, alternativeFormatter);
54
+            } catch (Exception ex) {
55
+                throw new RuntimeException("日期格式解析失败: " + stringValue, ex);
56
+            }
57
+        }
58
+    }
59
+
60
+    @Override
61
+    public WriteCellData<?> convertToExcelData(WriteConverterContext<LocalDateTime> context) {
62
+        if (context.getValue() == null) {
63
+            return new WriteCellData<>("");
64
+        }
65
+        return new WriteCellData<>(context.getValue().format(FORMatter));
66
+    }
67
+}

+ 54
- 0
src/main/java/com/example/backend/excel/NumberUtils.java View File

1
+package com.example.backend.excel;
2
+
3
+import java.math.BigDecimal;
4
+
5
+public class NumberUtils {
6
+    
7
+    /**
8
+     * 将字符串转换为Integer
9
+     */
10
+    public static Integer parseToInteger(String str) {
11
+        if (str == null || str.trim().isEmpty()) {
12
+            return null;
13
+        }
14
+        
15
+        try {
16
+            return Integer.valueOf(str.trim());
17
+        } catch (NumberFormatException e) {
18
+            System.err.println("无法转换为Integer: " + str);
19
+            return null;
20
+        }
21
+    }
22
+    
23
+    /**
24
+     * 将字符串转换为BigDecimal
25
+     */
26
+    public static BigDecimal parseToBigDecimal(String str) {
27
+        if (str == null || str.trim().isEmpty()) {
28
+            return null;
29
+        }
30
+        
31
+        try {
32
+            return new BigDecimal(str.trim());
33
+        } catch (NumberFormatException e) {
34
+            System.err.println("无法转换为BigDecimal: " + str);
35
+            return null;
36
+        }
37
+    }
38
+    
39
+    /**
40
+     * 将字符串转换为Double
41
+     */
42
+    public static Double parseToDouble(String str) {
43
+        if (str == null || str.trim().isEmpty()) {
44
+            return null;
45
+        }
46
+        
47
+        try {
48
+            return Double.valueOf(str.trim());
49
+        } catch (NumberFormatException e) {
50
+            System.err.println("无法转换为Double: " + str);
51
+            return null;
52
+        }
53
+    }
54
+}

+ 115
- 578
src/main/java/com/example/backend/excel/SalesContractExcelDTO.java View File

1
 package com.example.backend.excel;
1
 package com.example.backend.excel;
2
-
3
 import com.alibaba.excel.annotation.ExcelProperty;
2
 import com.alibaba.excel.annotation.ExcelProperty;
4
 import lombok.Data;
3
 import lombok.Data;
5
 
4
 
6
-import java.math.BigDecimal;
7
-import java.time.LocalDateTime;
8
-
9
 /**
5
 /**
10
- * 销售合同主表
6
+ * 销售合同主表 - 跳过标题列
11
  */
7
  */
12
 @Data
8
 @Data
13
 public class SalesContractExcelDTO {
9
 public class SalesContractExcelDTO {
14
 
10
 
15
-    @ExcelProperty("主键ID")
16
-    private Long id;
17
-
18
-    @ExcelProperty("销售合同号")
19
-    private String fno;
20
-
21
-    @ExcelProperty("单据日期")
22
-    private LocalDateTime fdate;
23
-
24
-    @ExcelProperty("销售合同号1")
25
-    private String sono;
26
-
27
-    @ExcelProperty("客户合同号")
28
-    private String ctOrderNo;
29
-
30
-    @ExcelProperty("合同类型")
31
-    private String bizType;
32
-
33
-    @ExcelProperty("业务账套")
34
-    private String acctSet;
35
-
36
-    @ExcelProperty("条款类型")
37
-    private String clauseType;
38
-
39
-    @ExcelProperty("签约日期")
40
-    private LocalDateTime signDate;
41
-
42
-    @ExcelProperty("代理采购协议号")
43
-    private String agentNo;
44
-
45
-    @ExcelProperty("佣金合同号")
46
-    private String commContrNo;
47
-
48
-    @ExcelProperty("合同起始有效期")
49
-    private LocalDateTime contrStart;
50
-
51
-    @ExcelProperty("合同截止有效期")
52
-    private LocalDateTime contrEnd;
53
-
54
-    @ExcelProperty("销售交货日期")
55
-    private LocalDateTime sDelivDt;
56
-
57
-    @ExcelProperty("合同描述")
58
-    private String contrDesc;
59
-
60
-    @ExcelProperty("我方编号")
61
-    private String fours;
62
-
63
-    @ExcelProperty("我方名称")
64
-    private String foursname;
65
-
66
-    @ExcelProperty("我方开户银行")
67
-    private String ourBankNm;
68
-
69
-    @ExcelProperty("我方银行账号")
70
-    private String ourBankAcct;
71
-
72
-    @ExcelProperty("客户代码")
73
-    private String ctNo;
74
-
75
-    @ExcelProperty("客户名称")
76
-    private String ctName;
77
-
78
-    @ExcelProperty("客户开户银行")
79
-    private String ctBankName;
80
-
81
-    @ExcelProperty("客户银行账户")
82
-    private String ctBankAcct;
83
-
84
-    @ExcelProperty("客户联系人名称")
85
-    private String ctContNm;
86
-
87
-    @ExcelProperty("币别")
88
-    private String curcy;
89
-
90
-    @ExcelProperty("折人民币汇率")
91
-    private BigDecimal rate;
92
-
93
-    @ExcelProperty("原币总金额")
94
-    private BigDecimal totalAmt;
95
-
96
-    @ExcelProperty("人民币总金额")
97
-    private BigDecimal totalCnyAmt;
98
-
99
-    @ExcelProperty("美元总金额")
100
-    private BigDecimal totalUsdAmt;
101
-
102
-    @ExcelProperty("总数量")
103
-    private BigDecimal totalQty;
104
-
105
-    @ExcelProperty("放货仓库代码")
106
-    private String stockno;
107
-
108
-    @ExcelProperty("放货仓库名称")
109
-    private String stockname;
110
-
111
-    @ExcelProperty("预估毛利率")
112
-    private BigDecimal estGrossMR;
113
-
114
-    @ExcelProperty("预估毛利金额")
115
-    private BigDecimal estGrossMA;
116
-
117
-    @ExcelProperty("预估成本总金额")
118
-    private BigDecimal estTotCost;
119
-
120
-    @ExcelProperty("预估费用总金额")
121
-    private BigDecimal estTotFee;
122
-
123
-    @ExcelProperty("预估回款周期")
124
-    private BigDecimal estPayCycle;
125
-
126
-    @ExcelProperty("预估资金成本")
127
-    private BigDecimal estFundCost;
128
-
129
-    @ExcelProperty("价格条款")
130
-    private String terms;
131
-
132
-    @ExcelProperty("签约地点")
133
-    private String signLoc;
134
-
135
-    @ExcelProperty("交货地点")
136
-    private String delivLoc;
137
-
138
-    @ExcelProperty("装运港")
139
-    private String lPort;
140
-
141
-    @ExcelProperty("目的港")
142
-    private String dPort;
143
-
144
-    @ExcelProperty("贸易国别")
145
-    private String trdCtry;
146
-
147
-    @ExcelProperty("收款方式")
148
-    private String rcptMtd;
149
-
150
-    @ExcelProperty("运输方式")
151
-    private String tranWay;
152
-
153
-    @ExcelProperty("价格说明")
154
-    private String priceDesc;
155
-
156
-    @ExcelProperty("计价公式")
157
-    private String priceForm;
158
-
159
-    @ExcelProperty("数量溢装%")
160
-    private BigDecimal qtyOver;
161
-
162
-    @ExcelProperty("数量短装%")
163
-    private BigDecimal qtyShort;
164
-
165
-    @ExcelProperty("金额溢装%")
166
-    private BigDecimal amtOver;
167
-
168
-    @ExcelProperty("金额短装%")
169
-    private BigDecimal amtShort;
170
-
171
-    @ExcelProperty("预收款比例")
172
-    private BigDecimal prepayRatio;
173
-
174
-    @ExcelProperty("预收款金额")
175
-    private BigDecimal prepayAmt;
176
-
177
-    @ExcelProperty("产地")
178
-    private String origin;
179
-
180
-    @ExcelProperty("结算指标")
181
-    private String settIndex;
182
-
183
-    @ExcelProperty("客户履约保证金支付日期")
184
-    private LocalDateTime ctPerfPayDt;
185
-
186
-    @ExcelProperty("客户履约保证金比例")
187
-    private BigDecimal ctPerfRatio;
188
-
189
-    @ExcelProperty("合同完结付款日期")
190
-    private LocalDateTime contrFinalPayDt;
191
-
192
-    @ExcelProperty("合同违约金比例")
193
-    private BigDecimal contrPenaltyRatio;
194
-
195
-    @ExcelProperty("提货期限")
196
-    private BigDecimal pickDueDays;
197
-
198
-    @ExcelProperty("开票天数")
199
-    private BigDecimal invDays;
200
-
201
-    @ExcelProperty("责任中心")
202
-    private String respCtrName;
203
-
204
-    @ExcelProperty("考核占比")
205
-    private BigDecimal assessRatio;
206
-
207
-    @ExcelProperty("占比金额")
208
-    private BigDecimal assessAmt;
209
-
210
-    @ExcelProperty("代理费计费方式")
211
-    private String billingMode;
212
-
213
-    @ExcelProperty("代理费计费比例/单价")
214
-    private BigDecimal billingRate;
215
-
216
-    @ExcelProperty("代理费计费金额")
217
-    private BigDecimal billingAmount;
218
-
219
-    @ExcelProperty("是否租船")
220
-    private String whetherChartering;
221
-
222
-    @ExcelProperty("合同执行人代码")
223
-    private String contrExecCd;
224
-
225
-    @ExcelProperty("合同执行人名称")
226
-    private String contrExecNm;
227
-
228
-    @ExcelProperty("合同名称")
229
-    private String contractName;
230
-
231
-    @ExcelProperty("合同标的")
232
-    private String contractSubjectMatter;
233
-
234
-    @ExcelProperty("合同大类")
235
-    private String bpoTypeS;
236
-
237
-    @ExcelProperty("合同细类")
238
-    private String bpoTypeT;
239
-
240
-    @ExcelProperty("是否法务格式合同")
241
-    private String ifLegalCheckFormat;
242
-
243
-    @ExcelProperty("是否经过法审")
244
-    private String ifLegalCheck;
245
-
246
-    @ExcelProperty("是否多次结算")
247
-    private String ifPayMultiple;
248
-
249
-    @ExcelProperty("是否阳光采购")
250
-    private String ifSunPurchase;
251
-
252
-    @ExcelProperty("未阳光采购理由")
253
-    private String sunPurInfo;
254
-
255
-    @ExcelProperty("未阳光采购理由(自定义)")
256
-    private String sunPurInfoCus;
257
-
258
-    @ExcelProperty("是否招投标")
259
-    private String ifBidding;
260
-
261
-    @ExcelProperty("是否集团外贸")
262
-    private String ifForeignTrade;
263
-
264
-    @ExcelProperty("变更说明")
265
-    private String changeDesc;
266
-
267
-    @ExcelProperty("合同变更人")
268
-    private String changePeople;
269
-
270
-    @ExcelProperty("合同变更日期")
271
-    private LocalDateTime changeDate;
272
-
273
-    @ExcelProperty("变更协议号")
274
-    private String changeAgreementNo;
275
-
276
-    @ExcelProperty("变更前合同版本号")
277
-    private String beforeChangeVer;
278
-
279
-    @ExcelProperty("保证金比例")
280
-    private BigDecimal ctmarginRatio;
281
-
282
-    @ExcelProperty("保证金金额")
283
-    private BigDecimal ctmarginAmount;
284
-
285
-    @ExcelProperty("中文船名")
286
-    private String chnShipName;
287
-
288
-    @ExcelProperty("英文船名")
289
-    private String engShipName;
290
-
291
-    @ExcelProperty("流程实例id")
292
-    private String processInstanceId;
293
-
294
-    @ExcelProperty("单据状态")
295
-    private String placed;
296
-
297
-    @ExcelProperty("业务id")
298
-    private Long fmodalid;
299
-
300
-    @ExcelProperty("数据来源id")
301
-    private Long sourceid;
302
-
303
-    @ExcelProperty("数据来源表")
304
-    private String sourcetable;
305
-
306
-    @ExcelProperty("图片")
307
-    private String imgIds;
308
-
309
-    @ExcelProperty("调取次数")
310
-    private Integer inc;
311
-
312
-    @ExcelProperty("关联id")
313
-    private Long rid;
314
-
315
-    @ExcelProperty("归档状态")
316
-    private String fsaved;
317
-
318
-    @ExcelProperty("备注信息")
319
-    private String remark;
320
-
321
-    @ExcelProperty("模版名称")
322
-    private String sysTemplateName;
323
-
324
-    @ExcelProperty("是否删除")
325
-    private Integer delFlag;
326
-
327
-    @ExcelProperty("制单人部门代码")
328
-    private String deptId;
329
-
330
-    @ExcelProperty("制单人部门名称")
331
-    private String deptName;
332
-
333
-    @ExcelProperty("制单人代码")
334
-    private String createBy;
335
-
336
-    @ExcelProperty("创建时间")
337
-    private LocalDateTime createTime;
338
-
339
-    @ExcelProperty("制单人名称")
340
-    private String createByName;
341
-
342
-    @ExcelProperty("更新账号")
343
-    private String updateBy;
344
-
345
-    @ExcelProperty("更新时间")
346
-    private LocalDateTime updateTime;
347
-
348
-    @ExcelProperty("更新人")
349
-    private String updateByName;
350
-
351
-    @ExcelProperty("贸易方式")
352
-    private String tradeway;
353
-
354
-    @ExcelProperty("美元汇率")
355
-    private BigDecimal rateUsd;
356
-
357
-    @ExcelProperty("付款方式")
358
-    private String payment;
359
-
360
-    @ExcelProperty("预估资金利息")
361
-    private BigDecimal estFundInt;
362
-
363
-    @ExcelProperty("计费单价")
364
-    private BigDecimal billPrice;
365
-
366
-    @ExcelProperty("计费方式")
367
-    private String billMode;
368
-
369
-    @ExcelProperty("计费比例")
370
-    private BigDecimal billRate;
371
-
372
-    @ExcelProperty("计费金额")
373
-    private BigDecimal billAmt;
374
-
375
-    @ExcelProperty("变更次数")
376
-    private Integer fchno;
377
-
378
-    @ExcelProperty("IMP同步PLMS接口状态")
379
-    private String impToPLMSStatus;
380
-
381
-    @ExcelProperty("IMP同步PLMS接口数据状态")
382
-    private String impToPLMSFlag;
383
-
384
-    @ExcelProperty("首款质量依据")
385
-    private String firstQmGt;
386
-
387
-    @ExcelProperty("尾款质量依据")
388
-    private String endQmGist;
389
-
390
-    @ExcelProperty("结算方式")
391
-    private String settlementMethod;
392
-
393
-    @ExcelProperty("品种大类")
394
-    private String materialClass;
395
-
396
-    @ExcelProperty("签约日期")
397
-    private LocalDateTime signDt;
398
-
399
-    @ExcelProperty("合同生效日期")
400
-    private LocalDateTime validDate;
401
-
402
-    @ExcelProperty("合同执行人机构代码")
403
-    private String contrExecCdInstitutionId;
404
-
405
-    @ExcelProperty("合同执行人机构名称")
406
-    private String contrExecCdInstitutionNm;
407
-
408
-    @ExcelProperty("合同执行人部门代码")
409
-    private String contrExecCdDeptId;
410
-
411
-    @ExcelProperty("合同执行人部门名称")
412
-    private String contrExecCdDeptNm;
413
-
414
-    @ExcelProperty("IMP同步PLMS接口来源系统代码")
415
-    private String sysid;
416
-
417
-    @ExcelProperty("IMP同步PLMS接口账套代码")
418
-    private String bookId;
419
-
420
-    @ExcelProperty("IMP同步PLMS接口PLMS组织ID")
421
-    private String orgId;
422
-
423
-    @ExcelProperty("赊销预付标识")
424
-    private String ifpayAdvanceSellCredit;
425
-
426
-    @ExcelProperty("业务类型")
427
-    private String serviceType;
428
-
429
-    @ExcelProperty("审批摘要")
430
-    private String reviewAbstract;
431
-
432
-    @ExcelProperty("是否清底")
433
-    private String ifClearBottom;
434
-
435
-    @ExcelProperty("关闭状态")
436
-    private String fclosed;
437
-
438
-    @ExcelProperty("当前版本号")
439
-    private Integer curChangeVer;
440
-
441
-    @ExcelProperty("变更标识")
442
-    private Integer curChangeFlag;
443
-
444
-    @ExcelProperty("变更原因")
445
-    private String curChangeReason;
446
-
447
-    @ExcelProperty("变更时间")
448
-    private LocalDateTime curChangeTime;
449
-
450
-    @ExcelProperty("变更人")
451
-    private String curChangeUser;
452
-
453
-    @ExcelProperty("合同产品类型")
454
-    private String bizProductType;
455
-
456
-    @ExcelProperty("PLMS合同大类")
457
-    private String contractType;
458
-
459
-    @ExcelProperty("是否赊销")
460
-    private String ifSellCredit;
461
-
462
-    @ExcelProperty("预付白名单")
463
-    private String ifpayAdvanceWhitelist;
464
-
465
-    @ExcelProperty("装卸条款")
466
-    private String loadUnloadTerms;
467
-
468
-    @ExcelProperty("赊销白名单")
469
-    private String ifSellCreditWhitelist;
470
-
471
-    @ExcelProperty("装运港编号")
472
-    private String lpno;
473
-
474
-    @ExcelProperty("目的港编号")
475
-    private String dpno;
11
+    @ExcelProperty(index = 1)
12
+    private String sono; // 销售合同号
476
 
13
 
477
-    @ExcelProperty("长协合同号")
478
-    private String longTermContract;
14
+    @ExcelProperty(index = 2)
15
+    private String createBy; // 制单人代码
479
 
16
 
480
-    @ExcelProperty("是否长协")
481
-    private String ifLongTerm;
17
+    @ExcelProperty(index = 3)
18
+    private String createByName; // 制单人名称
482
 
19
 
483
-    @ExcelProperty("是否确认")
484
-    private Integer isConfirm;
20
+    @ExcelProperty(index = 4)
21
+    private String serviceType; // 业务类型
485
 
22
 
486
-    @ExcelProperty("交货方式")
487
-    private String delivMtd;
23
+    @ExcelProperty(index = 5)
24
+    private String bizType; // 合同类型
488
 
25
 
489
-    @ExcelProperty("保险种类")
490
-    private String insuranceType;
26
+    @ExcelProperty(index = 6)
27
+    private String bizProductType; // 合同产品类型
491
 
28
 
492
-    @ExcelProperty("保险费率%")
493
-    private BigDecimal insuranceAmt;
29
+    @ExcelProperty(index = 7)
30
+    private String contrExecCd; // 合同执行人代码
494
 
31
 
495
-    @ExcelProperty("是否借壳")
496
-    private String ifShell;
32
+    @ExcelProperty(index = 8)
33
+    private String contrExecNm; // 合同执行人名称
497
 
34
 
498
-    @ExcelProperty("借壳单位")
499
-    private String shellCompany;
35
+    @ExcelProperty(index = 9)
36
+    private String ctName; // 客户名称
500
 
37
 
501
-    @ExcelProperty("是否允许分批")
502
-    private String ifBatch;
38
+    @ExcelProperty(index = 10)
39
+    private String ctNo; // 客户代码
503
 
40
 
504
-    @ExcelProperty("是否允许转运")
505
-    private String ifTransfer;
41
+    @ExcelProperty(index = 11)
42
+    private String ctContNm; // 客户联系人名称
506
 
43
 
507
-    @ExcelProperty("钢材产品判断字段")
508
-    private String ifgc;
44
+    @ExcelProperty(index = 12)
45
+    private String ctBankName; // 客户开户银行
509
 
46
 
510
-    @ExcelProperty("执行美元汇率")
511
-    private BigDecimal rateUs;
47
+    @ExcelProperty(index = 13)
48
+    private String ctBankAcct; // 客户银行账户
512
 
49
 
513
-    @ExcelProperty("最迟装运日期")
514
-    private LocalDateTime estLoadDt;
50
+    @ExcelProperty(index = 14)
51
+    private String ctOrderNo; // 客户合同号
515
 
52
 
516
-    @ExcelProperty("最迟集港日期")
517
-    private LocalDateTime estArrDt;
53
+    @ExcelProperty(index = 15)
54
+    private String curcy; // 币别
518
 
55
 
519
-    @ExcelProperty("合同借壳评审人")
520
-    private String reviewer;
56
+    @ExcelProperty(index = 16)
57
+    private String estArrDt; // 最迟集港日期
521
 
58
 
522
-    @ExcelProperty("来源类型")
523
-    private String sourceType;
59
+    @ExcelProperty(index = 17)
60
+    private String estLoadDt; // 最迟装运日期
524
 
61
 
525
-    @ExcelProperty("来源类型")
526
-    private String sourceno;
62
+    @ExcelProperty(index = 18)
63
+    private String outstandingDay; // 预计客商占款天数
527
 
64
 
528
-    @ExcelProperty("平均单价")
529
-    private BigDecimal avePrice;
65
+    @ExcelProperty(index = 19)
66
+    private String fours; // 我方编号 ← 新增
530
 
67
 
531
-    @ExcelProperty("提交审批日期")
532
-    private LocalDateTime submissionDate;
68
+    @ExcelProperty(index = 20)
69
+    private String foursname; // 我方名称
533
 
70
 
534
-    @ExcelProperty("审批生效日期")
535
-    private LocalDateTime appEffectiveDate;
71
+    @ExcelProperty(index = 21)
72
+    private String ourBankAcct; // 我方银行账号
536
 
73
 
537
-    @ExcelProperty("保供合同一键三联类型")
538
-    private String oneClickSourcetype;
74
+    @ExcelProperty(index = 22)
75
+    private String ourBankNm; // 我方开户银行
539
 
76
 
540
-    @ExcelProperty("保供合同一键三联id")
541
-    private Long oneClickSourceid;
77
+    @ExcelProperty(index = 23)
78
+    private String ifClearBottom; // 是否清底
542
 
79
 
543
-    @ExcelProperty("海外公司名称")
544
-    private String overSeasName;
80
+    @ExcelProperty(index = 24)
81
+    private String ifLongTerm; // 是否长协
545
 
82
 
546
-    @ExcelProperty("海外公司代码")
547
-    private String overSeasNo;
83
+    @ExcelProperty(index = 25)
84
+    private String longTermContract; // 长协合同号
548
 
85
 
549
-    @ExcelProperty("装运国")
550
-    private String lPortCtry;
86
+    @ExcelProperty(index = 26)
87
+    private String lPort; // 装运港
551
 
88
 
552
-    @ExcelProperty("目的国")
553
-    private String dPortCtry;
89
+    @ExcelProperty(index = 27)
90
+    private String lPortCtry; // 装运国 ← 新增
554
 
91
 
555
-    @ExcelProperty("托管")
556
-    private String rptg;
92
+    @ExcelProperty(index = 28)
93
+    private String dPort; // 目的港
557
 
94
 
558
-    @ExcelProperty("合同不含税总金额")
559
-    private BigDecimal totalNtAmt;
95
+    @ExcelProperty(index = 29)
96
+    private String dPortCtry; // 目的国 ← 新增
560
 
97
 
561
-    @ExcelProperty("项目计划书单号")
562
-    private String ppRefNo;
98
+    @ExcelProperty(index = 30)
99
+    private String qtyOver; // 数量溢装%
563
 
100
 
564
-    @ExcelProperty("是否过磅数量结算")
565
-    private String ifWeighedSalesQty;
101
+    @ExcelProperty(index = 31)
102
+    private String qtyShort; // 数量短装%
566
 
103
 
567
-    @ExcelProperty("限价类别")
568
-    private String limitType;
104
+    @ExcelProperty(index = 32)
105
+    private String amtOver; // 金额溢装%
569
 
106
 
570
-    @ExcelProperty("电子合同标识")
571
-    private String electronicsFlag;
107
+    @ExcelProperty(index = 33)
108
+    private String amtShort; // 金额短装%
572
 
109
 
573
-    @ExcelProperty("合同文本类别")
574
-    private String contractTextType;
110
+    @ExcelProperty(index = 34)
111
+    private String insuranceType; // 保险种类
575
 
112
 
576
-    @ExcelProperty("合同状态")
577
-    private String contractStatus;
113
+    @ExcelProperty(index = 35)
114
+    private String insuranceAmt; // 保险费率%
578
 
115
 
579
-    @ExcelProperty("合同大类")
580
-    private String contractType2;
116
+    @ExcelProperty(index = 36)
117
+    private String rate; // 折人民币汇率 ← 新增
581
 
118
 
582
-    @ExcelProperty("单价类别")
583
-    private String unitPriceType;
119
+    @ExcelProperty(index = 37)
120
+    private String rateUs; // 执行美元汇率 ← 新增
584
 
121
 
585
-    @ExcelProperty("增值税率")
586
-    private BigDecimal inTaxRate;
122
+    @ExcelProperty(index = 38)
123
+    private String signLoc; // 签约地点
587
 
124
 
588
-    @ExcelProperty("是否含税标记")
589
-    private String iftax;
125
+    @ExcelProperty(index = 39)
126
+    private String terms; // 价格条款
590
 
127
 
591
-    @ExcelProperty("PLMS合同id")
592
-    private String plmscontractId;
128
+    @ExcelProperty(index = 40)
129
+    private String loadUnloadTerms; // 装卸条款
593
 
130
 
594
-    @ExcelProperty("PLMS合同编号")
595
-    private String plmscontractCode;
131
+    @ExcelProperty(index = 41)
132
+    private String delivLoc; // 交货地点
596
 
133
 
597
-    @ExcelProperty("是否指数合同")
598
-    private String contractIndexFlag;
134
+    @ExcelProperty(index = 42)
135
+    private String delivMtd; // 交货方式
599
 
136
 
600
-    @ExcelProperty("备用字段1")
601
-    private String extCol1;
137
+    @ExcelProperty(index = 43)
138
+    private String tranWay; // 运输方式
602
 
139
 
603
-    @ExcelProperty("计量单位代码")
604
-    private String measureUnitCode;
140
+    @ExcelProperty(index = 44)
141
+    private String whetherChartering; // 是否租船
605
 
142
 
606
-    @ExcelProperty("采购合同号")
607
-    private String pono;
143
+    @ExcelProperty(index = 45)
144
+    private String chnShipName; // 中文船名
608
 
145
 
609
-    @ExcelProperty("销售合同信用销售比例")
610
-    private BigDecimal prepayTrustRatio;
146
+    @ExcelProperty(index = 46)
147
+    private String engShipName; // 英文船名
611
 
148
 
612
-    @ExcelProperty("销售合同信用销售金额")
613
-    private BigDecimal prepayTrustAmt;
149
+    @ExcelProperty(index = 47)
150
+    private String agentNo; // 代理采购协议号
614
 
151
 
615
-    @ExcelProperty("代理销售协议号")
616
-    private String agentNoSo;
152
+    @ExcelProperty(index = 48)
153
+    private String agentNoSo; // 代理销售协议号
617
 
154
 
618
-    @ExcelProperty("印花税金额")
619
-    private BigDecimal stampTaxAmt;
155
+    @ExcelProperty(index = 49)
156
+    private String commContrNo; // 佣金合同号
620
 
157
 
621
-    @ExcelProperty("合同取消状态")
622
-    private String fclosedType;
158
+    @ExcelProperty(index = 50)
159
+    private String sDelivDt; // 销售交货日期
623
 
160
 
624
-    @ExcelProperty("产品名称")
625
-    private String mpsdesc;
161
+    @ExcelProperty(index = 51)
162
+    private String ifWeighedSalesQty; // 是否过磅数量结算
626
 
163
 
627
-    @ExcelProperty("预计客商占款天数")
628
-    private Integer outstandingDay;
164
+    @ExcelProperty(index = 52)
165
+    private String settIndex; // 结算指标
629
 
166
 
630
-    @ExcelProperty("未结金额")
631
-    private BigDecimal outstandingamt;
167
+    @ExcelProperty(index = 53)
168
+    private String ifBatch; // 是否允许分批
632
 
169
 
633
-    @ExcelProperty("我方英文名称")
634
-    private String foursnamee;
170
+    @ExcelProperty(index = 54)
171
+    private String ifTransfer; // 是否允许转运
635
 
172
 
636
-    @ExcelProperty("客户英文名称")
637
-    private String ctnamee;
173
+    @ExcelProperty(index = 55)
174
+    private String contrDesc; // 合同描述
638
 
175
 
639
-    @ExcelProperty("未税平均单价")
640
-    private BigDecimal avgNtprice;
176
+    @ExcelProperty(index = 56)
177
+    private String remark; // 备注信息
641
 
178
 
642
-    @ExcelProperty("英文品名")
643
-    private String edesc;
179
+    @ExcelProperty(index = 57)
180
+    private String pono; // 采购合同号
644
 }
181
 }

+ 3
- 0
src/main/java/com/example/backend/service/contract/SalesContractService.java View File

1
 package com.example.backend.service.contract;
1
 package com.example.backend.service.contract;
2
 
2
 
3
 import com.example.backend.entity.contract.SalesContractEntity;
3
 import com.example.backend.entity.contract.SalesContractEntity;
4
+import org.springframework.stereotype.Component;
5
+import org.springframework.stereotype.Service;
4
 import org.springframework.web.multipart.MultipartFile;
6
 import org.springframework.web.multipart.MultipartFile;
5
 
7
 
6
 import java.util.List;
8
 import java.util.List;
8
 /**
10
 /**
9
  * 销售合同服务接口
11
  * 销售合同服务接口
10
  */
12
  */
13
+
11
 public interface SalesContractService {
14
 public interface SalesContractService {
12
 
15
 
13
     /**
16
     /**

+ 29
- 10
src/main/java/com/example/backend/service/contract/impl/SalesContractServiceImpl.java View File

63
         try {
63
         try {
64
             // ================= 主表 =================
64
             // ================= 主表 =================
65
             try {
65
             try {
66
-                List<SalesContractExcelDTO> mainDataList = ExcelUtils.readMainSheet(file);
66
+                List<SalesContractExcelDTO> mainDataList = ExcelUtil.readMainSheet(file);
67
                 if (mainDataList.isEmpty()) {
67
                 if (mainDataList.isEmpty()) {
68
                     errors.add("主表(Sheet1) 数据为空");
68
                     errors.add("主表(Sheet1) 数据为空");
69
                 } else {
69
                 } else {
76
                             SalesContractExcelDTO dto = mainDataList.get(i);
76
                             SalesContractExcelDTO dto = mainDataList.get(i);
77
                             SalesContractEntity entity = new SalesContractEntity();
77
                             SalesContractEntity entity = new SalesContractEntity();
78
                             BeanUtils.copyProperties(dto, entity);
78
                             BeanUtils.copyProperties(dto, entity);
79
-                            entity.setCreateTime(LocalDateTime.now());
79
+                            entity.setCreateTime(new Date());
80
+
81
+                            // === 日期字段转换 ===
82
+                            entity.setEstArrDt(DateUtils.parseToDate(dto.getEstArrDt()));
83
+                            entity.setEstLoadDt(DateUtils.parseToDate(dto.getEstLoadDt()));
84
+                            entity.setSDelivDt(DateUtils.parseToDate(dto.getSDelivDt()));
85
+
86
+                            // === 数值字段转换 ===
87
+                            entity.setOutstandingDay(NumberUtils.parseToInteger(dto.getOutstandingDay()));
88
+                            entity.setQtyOver(NumberUtils.parseToBigDecimal(dto.getQtyOver()));
89
+                            entity.setQtyShort(NumberUtils.parseToBigDecimal(dto.getQtyShort()));
90
+                            entity.setAmtOver(NumberUtils.parseToBigDecimal(dto.getAmtOver()));
91
+                            entity.setAmtShort(NumberUtils.parseToBigDecimal(dto.getAmtShort()));
92
+                            entity.setInsuranceAmt(NumberUtils.parseToBigDecimal(dto.getInsuranceAmt()));
80
 
93
 
81
                             // 记录当前处理的行号,用于错误提示
94
                             // 记录当前处理的行号,用于错误提示
82
                             int currentRow = i + 1; // Excel行号从1开始
95
                             int currentRow = i + 1; // Excel行号从1开始
167
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:客户名称有误!");
180
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:客户名称有误!");
168
                                 currentRowValid = false;
181
                                 currentRowValid = false;
169
                             }
182
                             }
170
-                            if (ctNameList != null && !ctNameList.get(0).getPlaced().equals("2")) {
183
+                            if (ctNameList != null && !ctNameList.isEmpty()&& !"2".equals(ctNameList.get(0).getPlaced())) {
171
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:客户名称没有审批通过!");
184
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:客户名称没有审批通过!");
172
                                 currentRowValid = false;
185
                                 currentRowValid = false;
173
                             }
186
                             }
231
                                     currentRowValid = false;
244
                                     currentRowValid = false;
232
                                 }
245
                                 }
233
                             }
246
                             }
247
+                            if(StringUtils.isEmpty(entity.getFours())){
248
+                                errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方编号不能为空!");
249
+                                currentRowValid = false;
250
+                            }
234
 
251
 
235
                             if (StringUtils.isEmpty(entity.getFoursname())) {
252
                             if (StringUtils.isEmpty(entity.getFoursname())) {
236
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方名称不能为空!");
253
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方名称不能为空!");
241
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方名称有误!");
258
                                 errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方名称有误!");
242
                                 currentRowValid = false;
259
                                 currentRowValid = false;
243
                             }
260
                             }
244
-                            if (foursnameList != null && foursnameList.get(0).getFno().isEmpty()) {
245
-                                errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方编号不能为空!");
261
+                            if (foursnameList != null && !foursnameList.get(0).getFno().isEmpty()) {
262
+                                if(!entity.getFours().equals(foursnameList.get(0).getFno())){
263
+                                    errors.add("主表(Sheet1) 第 " + currentRow + " 行:我方编号与匹配到的不符合!");
264
+                                }
246
                                 currentRowValid = false;
265
                                 currentRowValid = false;
247
                             }
266
                             }
248
 
267
 
423
 
442
 
424
             // =================  产品明细 =================
443
             // =================  产品明细 =================
425
             try {
444
             try {
426
-                List<SalesDtlExcelDTO> list = ExcelUtils.readSalesDtlSheet(file);
445
+                List<SalesDtlExcelDTO> list = ExcelUtil.readSalesDtlSheet(file);
427
                 if (!list.isEmpty() && cid != null) {
446
                 if (!list.isEmpty() && cid != null) {
428
                     List<SalesDtlEntity> validEntities = new ArrayList<>(); // 存储校验通过的实体
447
                     List<SalesDtlEntity> validEntities = new ArrayList<>(); // 存储校验通过的实体
429
 
448
 
644
 
663
 
645
             // ================= 收款计划 =================
664
             // ================= 收款计划 =================
646
             try {
665
             try {
647
-                List<SalesCollectExcelDTO> list = ExcelUtils.readSalesCollectSheet(file);
666
+                List<SalesCollectExcelDTO> list = ExcelUtil.readSalesCollectSheet(file);
648
                 if (!list.isEmpty() && cid != null) {
667
                 if (!list.isEmpty() && cid != null) {
649
                     // 先进行所有校验
668
                     // 先进行所有校验
650
                     Map<String, List<SalesCollectExcelDTO>> groupedByFno = list.stream()
669
                     Map<String, List<SalesCollectExcelDTO>> groupedByFno = list.stream()
725
 
744
 
726
             // ================= 责任中心 =================
745
             // ================= 责任中心 =================
727
             try {
746
             try {
728
-                List<RCenterDtlExcelDTO> list = ExcelUtils.readRCenterDtlSheet(file);
747
+                List<RCenterDtlExcelDTO> list = ExcelUtil.readRCenterDtlSheet(file);
729
                 if (!list.isEmpty() && cid != null) {
748
                 if (!list.isEmpty() && cid != null) {
730
                     // 按合同号分组
749
                     // 按合同号分组
731
                     Map<String, List<RCenterDtlExcelDTO>> groupedByContract = list.stream()
750
                     Map<String, List<RCenterDtlExcelDTO>> groupedByContract = list.stream()
839
 
858
 
840
 // ================= 费用明细 =================
859
 // ================= 费用明细 =================
841
             try {
860
             try {
842
-                List<FeeDtlExcelDTO> list = ExcelUtils.readFeelDtlSheet(file);
861
+                List<FeeDtlExcelDTO> list = ExcelUtil.readFeelDtlSheet(file);
843
                 if (!list.isEmpty() && cid != null) {
862
                 if (!list.isEmpty() && cid != null) {
844
                     // 校验单个记录
863
                     // 校验单个记录
845
                     for (int i = 0; i < list.size(); i++) {
864
                     for (int i = 0; i < list.size(); i++) {
891
 
910
 
892
 // ================= 服务费率 =================
911
 // ================= 服务费率 =================
893
             try {
912
             try {
894
-                List<ExpSvcRateExcelDTO> list = ExcelUtils.readExpSvcRateSheet(file);
913
+                List<ExpSvcRateExcelDTO> list = ExcelUtil.readExpSvcRateSheet(file);
895
                 if (!list.isEmpty() && cid != null) {
914
                 if (!list.isEmpty() && cid != null) {
896
                     // 定义不需要校验服务费率的客户名单
915
                     // 定义不需要校验服务费率的客户名单
897
                     Set<String> excludedCustomers = new HashSet<>(Arrays.asList(
916
                     Set<String> excludedCustomers = new HashSet<>(Arrays.asList(

+ 6
- 0
src/main/resources/application.yml View File

4
     context-path: /api
4
     context-path: /api
5
 
5
 
6
 spring:
6
 spring:
7
+  servlet:
8
+    multipart:
9
+      max-file-size: 10MB
10
+      max-request-size: 10MB
7
   datasource:
11
   datasource:
8
     driver-class-name: dm.jdbc.driver.DmDriver
12
     driver-class-name: dm.jdbc.driver.DmDriver
9
     url: jdbc:dm://10.19.13.211:5236
13
     url: jdbc:dm://10.19.13.211:5236
21
       test-on-borrow: false
25
       test-on-borrow: false
22
       test-on-return: false
26
       test-on-return: false
23
 
27
 
28
+
29
+
24
 mybatis-plus:
30
 mybatis-plus:
25
   mapper-locations: classpath:mapper/*.xml,classpath:mapper/contract/*.xml
31
   mapper-locations: classpath:mapper/*.xml,classpath:mapper/contract/*.xml
26
   type-aliases-package: com.example.backend.entity
32
   type-aliases-package: com.example.backend.entity

+ 1
- 1
src/main/resources/mapper/SysUserMapper.xml View File

4
 
4
 
5
 
5
 
6
     <select id="selectByCtName" resultType="com.example.backend.entity.common.SysUser">
6
     <select id="selectByCtName" resultType="com.example.backend.entity.common.SysUser">
7
-        select a.id, a.fno,a.rptg,a.ctCnNm,a.ctEnNm,
7
+        select a.id, a.fno,a.rptg,a.ctCnNm,a.ctEnNm,a.placed,
8
         case
8
         case
9
         when IFNULL(ctAbbr, '') = '' then IFNULL(ctEnAbbr, '')
9
         when IFNULL(ctAbbr, '') = '' then IFNULL(ctEnAbbr, '')
10
         else IFNULL(ctAbbr, '')
10
         else IFNULL(ctAbbr, '')

Loading…
Cancel
Save