Przeglądaj źródła

1.创建common包,包里加上通用类 2.新增通过Mapper方法3.对exceL销售主表进行导入校验

胡北宽 2 tygodni temu
rodzic
commit
622412b560

+ 414
- 0
src/main/java/com/example/backend/entity/common/CustCtrl.java Wyświetl plik

@@ -0,0 +1,414 @@
1
+package com.example.backend.entity.common;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+
8
+import lombok.Getter;
9
+import lombok.Setter;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.math.BigDecimal;
13
+import java.util.Date;
14
+
15
+/**
16
+ * 客商管理主表
17
+ */
18
+@Getter
19
+@Setter
20
+@Accessors(chain = true)
21
+@TableName("SGGMIIP.CustCtrl")
22
+public class CustCtrl {
23
+
24
+    // 主键ID
25
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
26
+    private Long id;
27
+
28
+    // 当前版本号
29
+    @TableField("curChangeVer")
30
+    private Integer curChangeVer;
31
+
32
+    // 客户编号
33
+    @TableField("fno")
34
+    private String fno;
35
+
36
+    // 客商性质
37
+    @TableField("ctNature")
38
+    private String ctNature;
39
+
40
+    // 客户中文简称
41
+    @TableField("ctAbbr")
42
+    private String ctAbbr;
43
+
44
+    // 客户中文名称
45
+    @TableField("ctCnNm")
46
+    private String ctCnNm;
47
+
48
+    // 客户中文地址
49
+    @TableField("ctCnAddr")
50
+    private String ctCnAddr;
51
+
52
+    // 客户英文名称
53
+    @TableField("ctEnNm")
54
+    private String ctEnNm;
55
+
56
+    // 客户英文地址
57
+    @TableField("ctEnAddr")
58
+    private String ctEnAddr;
59
+
60
+    // 所有权性质
61
+    @TableField("olNature")
62
+    private String olNature;
63
+
64
+    // 注册国别/地区
65
+    @TableField("ctrylmbAddr")
66
+    private String ctrylmbAddr;
67
+
68
+    // 成立时间
69
+    @TableField("estabDt")
70
+    private Date estabDt;
71
+
72
+    // 客户等级
73
+    @TableField("ctLevel")
74
+    private String ctLevel;
75
+
76
+    // 统一社会信用代码
77
+    @TableField("uniCreCd")
78
+    private String uniCreCd;
79
+
80
+    // 企业类型
81
+    @TableField("entType")
82
+    private String entType;
83
+
84
+    // 营业期限
85
+    @TableField("busiTerm")
86
+    private String busiTerm;
87
+
88
+    // 注册资本
89
+    @TableField("regCapital")
90
+    private String regCapital;
91
+
92
+    // 法人代表
93
+    @TableField("legalRep")
94
+    private String legalRep;
95
+
96
+    // 营业范围
97
+    @TableField("busiScope")
98
+    private String busiScope;
99
+
100
+    // 产品种类
101
+    @TableField("prodCategory")
102
+    private String prodCategory;
103
+
104
+    // 供货方身份
105
+    @TableField("suplDen")
106
+    private String suplDen;
107
+
108
+    // 顾客身份
109
+    @TableField("ctlDen")
110
+    private String ctlDen;
111
+
112
+    // 纳税人识别号
113
+    @TableField("taxPayerId")
114
+    private String taxPayerId;
115
+
116
+    // 开票地址
117
+    @TableField("invAddr")
118
+    private String invAddr;
119
+
120
+    // 电话
121
+    @TableField("phone")
122
+    private String phone;
123
+
124
+    // 开户银行
125
+    @TableField("ctBankNm")
126
+    private String ctBankNm;
127
+
128
+    // 开户账号
129
+    @TableField("ctBankAcct")
130
+    private String ctBankAcct;
131
+
132
+    @TableField("overseaBusLicNo")
133
+    private String overseaBusLicNo;
134
+
135
+    // 公司电话
136
+    @TableField("tel")
137
+    private String tel;
138
+
139
+    // 公司邮箱
140
+    @TableField("email")
141
+    private String email;
142
+
143
+    // 公司网址
144
+    @TableField("website")
145
+    private String website;
146
+
147
+    // 客商六位代码
148
+    @TableField("ctSixCd")
149
+    private String ctSixCd;
150
+
151
+    // 申请方系统代码
152
+    @TableField("sysID")
153
+    private String sysID;
154
+
155
+    // 申请性质
156
+    @TableField("openingType")
157
+    private String openingType;
158
+
159
+    // 属地申请号
160
+    @TableField("tempVendorNum")
161
+    private String tempVendorNum;
162
+
163
+    // 工商登记号
164
+    @TableField("bizNum")
165
+    private String bizNum;
166
+
167
+    // 客户供应商身份证号
168
+    @TableField("idCard")
169
+    private String idCard;
170
+
171
+    // 是否法人标志
172
+    @TableField("corpFlag")
173
+    private String corpFlag;
174
+
175
+    // 宝钢组织机构码
176
+    @TableField("orgCd")
177
+    private String orgCd;
178
+
179
+    // 注册所在地省份
180
+    @TableField("addrReg")
181
+    private String addrReg;
182
+
183
+    // 注册地址
184
+    @TableField("cnAddr")
185
+    private String cnAddr;
186
+
187
+    // 注销原因代码
188
+    @TableField("cancelReason")
189
+    private String cancelReason;
190
+
191
+    // 银行地区码
192
+    @TableField("areaCode")
193
+    private String areaCode;
194
+
195
+    // 客户英文简称
196
+    @TableField("ctEnAbbr")
197
+    private String ctEnAbbr;
198
+
199
+    // 银行代码
200
+    @TableField("ctBankCd")
201
+    private String ctBankCd;
202
+
203
+    // 单据日期
204
+    @TableField("fdate")
205
+    private Date fdate;
206
+
207
+    // 备注
208
+    @TableField("remark")
209
+    private String remark;
210
+
211
+    // 境外企业经营活动证件号
212
+    @TableField("overseasIDCard")
213
+    private String overseasIDCard;
214
+
215
+    // 最大信用销售额度
216
+    @TableField("maxCycleCreditAmt")
217
+    private BigDecimal maxCycleCreditAmt;
218
+
219
+    // 预付金额
220
+    @TableField("prepayAmt")
221
+    private BigDecimal prepayAmt;
222
+
223
+    // 操作标记 N-新增,R-修改,C-代码注销,必输项
224
+    @TableField("OPFLAG")
225
+    private String opflag;
226
+
227
+    // 数据状态 0为未发送,1为已发送,2为已返回
228
+    @TableField("DATA_STATUS")
229
+    private String dataStatus;
230
+
231
+    // 创建人电话
232
+    @TableField("create_tel")
233
+    private String createTel;
234
+
235
+    // 流程实例id
236
+    @TableField("process_instance_id")
237
+    private String processInstanceId;
238
+
239
+    // 单据状态
240
+    @TableField("placed")
241
+    private String placed;
242
+
243
+    // 业务id
244
+    @TableField("fmodalid")
245
+    private Long fmodalid;
246
+
247
+    // 数据来源id
248
+    @TableField("sourceid")
249
+    private Long sourceid;
250
+
251
+    // 数据来源表
252
+    @TableField("sourcetable")
253
+    private String sourcetable;
254
+
255
+    // 图片
256
+    @TableField("img_ids")
257
+    private String imgIds;
258
+
259
+    // 调取次数
260
+    @TableField("inc")
261
+    private Integer inc;
262
+
263
+    // 关联id
264
+    @TableField("rid")
265
+    private String rid;
266
+
267
+    // 归档状态
268
+    @TableField("fsaved")
269
+    private String fsaved;
270
+
271
+    // 模版名称
272
+    @TableField("sys_template_name")
273
+    private String sysTemplateName;
274
+
275
+    // 是否删除
276
+    @TableField("del_flag")
277
+    private Integer delFlag;
278
+
279
+    // 创建账号
280
+    @TableField("create_by")
281
+    private String createBy;
282
+
283
+    // 创建时间
284
+    @TableField("create_time")
285
+    private Date createTime;
286
+
287
+    // 创建人
288
+    @TableField("create_by_name")
289
+    private String createByName;
290
+
291
+    // 更新账号
292
+    @TableField("update_by")
293
+    private String updateBy;
294
+
295
+    // 更新时间
296
+    @TableField("update_time")
297
+    private Date updateTime;
298
+
299
+    // 更新人
300
+    @TableField("update_by_name")
301
+    private String updateByName;
302
+
303
+    // 部门名称
304
+    @TableField("dept_name")
305
+    private String deptName;
306
+
307
+    // 部门ID
308
+    @TableField("dept_id")
309
+    private String deptId;
310
+
311
+    // 托管
312
+    @TableField("rptg")
313
+    private String rptg;
314
+
315
+    // 所属组织
316
+    @TableField("org_abbr")
317
+    private String orgAbbr;
318
+
319
+    // 国别代码
320
+    @TableField("ctrylmbAddrCode")
321
+    private String ctrylmbAddrCode;
322
+
323
+    // 邮编
324
+    @TableField("zipCode")
325
+    private String zipCode;
326
+
327
+    // 银行地区名称
328
+    @TableField("areaname")
329
+    private String areaname;
330
+
331
+    // 提交审批日期
332
+    @TableField("submissionDate")
333
+    private Date submissionDate;
334
+
335
+    // 审批生效日期
336
+    @TableField("appEffectiveDate")
337
+    private Date appEffectiveDate;
338
+
339
+    // 法人
340
+    @TableField("faren")
341
+    private String faren;
342
+
343
+    // 变更标识
344
+    @TableField("curChangeFlag")
345
+    private Integer curChangeFlag;
346
+
347
+    // 变更原因
348
+    @TableField("curChangeReason")
349
+    private String curChangeReason;
350
+
351
+    // 变更时间
352
+    @TableField("curChangeTime")
353
+    private Date curChangeTime;
354
+
355
+    // 变更人
356
+    @TableField("curChangeUser")
357
+    private String curChangeUser;
358
+
359
+    // 六位代码标志
360
+    @TableField("sixflag")
361
+    private String sixflag;
362
+
363
+    // 申请回退意见
364
+    @TableField("RETURN_REASON")
365
+    private String returnReason;
366
+
367
+    // 申请标志
368
+    @TableField("RETURN_CODE")
369
+    private String returnCode;
370
+
371
+    // 数据导入标记
372
+    @TableField("initState")
373
+    private String initState;
374
+
375
+    // 客商状态
376
+    @TableField("ctStatus")
377
+    private String ctStatus;
378
+
379
+    // 首次准入拟开展业务及风险控制措施
380
+    @TableField("fmemo1")
381
+    private String fmemo1;
382
+
383
+    //银行名称
384
+    @TableField(exist = false)
385
+    private String ctBankName;
386
+
387
+    //客户联系人
388
+    @TableField(exist = false)
389
+    private String ctContNm;
390
+
391
+    //我方名称
392
+    @TableField(exist = false)
393
+    private String cpny;
394
+
395
+    //我方银行
396
+    @TableField(exist = false)
397
+    private String ourBankNm;
398
+
399
+    //我方银行账户
400
+    @TableField(exist = false)
401
+    private String ourBankAcct;
402
+
403
+    //装运港/目的港
404
+    @TableField(exist = false)
405
+    private String portName;
406
+
407
+    //装运国/目的国
408
+    @TableField(exist = false)
409
+    private String countryName;
410
+
411
+
412
+
413
+
414
+}

+ 79
- 0
src/main/java/com/example/backend/entity/common/DataDic.java Wyświetl plik

@@ -0,0 +1,79 @@
1
+package com.example.backend.entity.common;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+
8
+import lombok.Getter;
9
+import lombok.Setter;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.util.Date;
13
+
14
+/**
15
+ * 数据字典表
16
+ */
17
+@Getter
18
+@Setter
19
+@Accessors(chain = true)
20
+@TableName("SGGMIIP.data_dic")
21
+public class DataDic {
22
+
23
+    // 主键ID
24
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
25
+    private Long id;
26
+
27
+    // 字典名称
28
+    @TableField("dic_name")
29
+    private String dicName;
30
+
31
+    // 字典描述
32
+    @TableField("dic_desc")
33
+    private String dicDesc;
34
+
35
+    // 字典类型
36
+    @TableField("dic_type")
37
+    private Integer dicType;
38
+
39
+    // 状态
40
+    @TableField("status")
41
+    private Integer status;
42
+
43
+    // 创建时间
44
+    @TableField("create_time")
45
+    private Date createTime;
46
+
47
+    // 创建人
48
+    @TableField("create_by")
49
+    private String createBy;
50
+
51
+    // 更新时间
52
+    @TableField("update_time")
53
+    private Date updateTime;
54
+
55
+    // 更新人
56
+    @TableField("update_by")
57
+    private String updateBy;
58
+
59
+    // 备注
60
+    @TableField("remark")
61
+    private String remark;
62
+
63
+    // 字典编码
64
+    @TableField("dic_code")
65
+    private String dicCode;
66
+
67
+    // 部门名称
68
+    @TableField("dept_name")
69
+    private String deptName;
70
+
71
+    // 部门ID
72
+    @TableField("dept_id")
73
+    private String deptId;
74
+
75
+    //字典值
76
+    @TableField(exist = false)
77
+    private String itemValue;
78
+
79
+}

src/main/java/com/example/backend/entity/contract/SysUser.java → src/main/java/com/example/backend/entity/common/SysUser.java Wyświetl plik

@@ -1,4 +1,4 @@
1
-package com.example.backend.entity.contract;
1
+package com.example.backend.entity.common;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
6 6
 import com.baomidou.mybatisplus.annotation.TableName;
7 7
 import lombok.Data;
8 8
 
9
+import java.math.BigDecimal;
9 10
 import java.time.LocalDateTime;
10 11
 
11 12
 /**
@@ -239,11 +240,36 @@ public class SysUser {
239 240
 
240 241
     @TableField(exist = false)
241 242
     private String ctCnNm;
242
-
243
+    //编码
243 244
     @TableField(exist = false)
244 245
     private String fno;
245 246
 
246 247
     @TableField(exist = false)
247 248
     private String fname;
249
+    //是否审批
250
+    @TableField(exist = false)
251
+    private String placed;
252
+
253
+    //银行名称
254
+    @TableField(exist = false)
255
+    private String ctBankName;
256
+
257
+    //银行账号
258
+    @TableField(exist = false)
259
+    private String ctBankAcct;
260
+
261
+    //客户联系人
262
+    @TableField(exist = false)
263
+    private String ctContNm;
264
+
265
+    //折人民币汇率
266
+    @TableField(exist = false)
267
+    private BigDecimal rate;
268
+
269
+    //折美元汇率
270
+    @TableField(exist = false)
271
+    private BigDecimal rateUsd;
272
+
273
+
248 274
 
249 275
 }

+ 29
- 0
src/main/java/com/example/backend/mapper/contract/CustCtrlMapper.java Wyświetl plik

@@ -0,0 +1,29 @@
1
+package com.example.backend.mapper.contract;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.example.backend.entity.common.CustCtrl;
5
+import com.example.backend.entity.common.DataDic;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * 销售合同主表Mapper
13
+ */
14
+@Mapper
15
+public interface CustCtrlMapper extends BaseMapper<CustCtrl> {
16
+
17
+
18
+    List<CustCtrl> selectOurNameByFoursname(@Param("foursname") String foursname);
19
+
20
+    List<CustCtrl> selectLPortByLportName(@Param("lPort") String lPort);
21
+
22
+    List<CustCtrl> selectByAgentNo(@Param("agentNo") String agentNo);
23
+
24
+
25
+    List<CustCtrl> selectByAgentNoSo(@Param("agentNoSo") String agentNoSo);
26
+
27
+
28
+
29
+}

+ 28
- 0
src/main/java/com/example/backend/mapper/contract/DicMapper.java Wyświetl plik

@@ -0,0 +1,28 @@
1
+package com.example.backend.mapper.contract;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.example.backend.entity.common.CustCtrl;
5
+import com.example.backend.entity.common.DataDic;
6
+import com.example.backend.entity.common.SysUser;
7
+import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+import org.apache.ibatis.annotations.Select;
10
+
11
+import java.util.List;
12
+
13
+/**
14
+ * 销售合同主表Mapper
15
+ */
16
+@Mapper
17
+public interface DicMapper extends BaseMapper<DataDic> {
18
+
19
+
20
+
21
+    List<DataDic> selectDicByBizProductType(@Param("bizProductType") String bizProductType);
22
+
23
+    List<DataDic> selectDicByBizType(@Param("bizType") String bizType);
24
+
25
+    List<DataDic> selectDicByServiceType(@Param("serviceType") String serviceType);
26
+
27
+
28
+}

+ 2
- 17
src/main/java/com/example/backend/mapper/contract/SysUserMapper.java Wyświetl plik

@@ -1,8 +1,7 @@
1 1
 package com.example.backend.mapper.contract;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
-import com.example.backend.entity.contract.SalesDtlEntity;
5
-import com.example.backend.entity.contract.SysUser;
4
+import com.example.backend.entity.common.SysUser;
6 5
 import org.apache.ibatis.annotations.Mapper;
7 6
 import org.apache.ibatis.annotations.Param;
8 7
 import org.apache.ibatis.annotations.Select;
@@ -22,21 +21,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
22 21
             "where b.user_code =#{userCode}")
23 22
     List<SysUser> selectContractByNo(@Param("userCode") String userCode);
24 23
 
25
-    @Select("select a.id, a.fno,a.rptg,a.ctCnNm,a.ctEnNm\n" +
26
-            "\n" +
27
-            "\n" +
28
-            "from SGGMIIP.custctrl a\n" +
29
-            "         LEFT JOIN (\n" +
30
-            "    SELECT  rid , bankNm , bankAcct , ROW_NUMBER() OVER (PARTITION BY rid ORDER BY id) as row_num\n" +
31
-            "    FROM SGGMIIP.custbank   WHERE NVL(del_flag, 0) <> 1\n" +
32
-            ") b ON a.id = b.rid AND b.row_num = 1\n" +
33
-            "         left join SGGMIIP.custattn c on a.id = c.rid\n" +
34
-            "where ifnull(a.del_flag, 0) <> 1\n" +
35
-            "  and INSTR(ctNature, '顾客') > 0\n" +
36
-            "  and nvl(ctStatus,'')='已准入'\n" +
37
-            "  and a.ctCnNm = #{ctName}\n" +
38
-            "\n" +
39
-            "order by a.fno")
24
+
40 25
     List<SysUser> selectByCtName(@Param("ctName") String ctName);
41 26
 
42 27
     @Select("select    a.id,a.fname,a.fname1,\n" +

+ 212
- 18
src/main/java/com/example/backend/service/contract/impl/SalesContractServiceImpl.java Wyświetl plik

@@ -2,6 +2,9 @@ package com.example.backend.service.contract.impl;
2 2
 
3 3
 import com.alibaba.druid.util.StringUtils;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.example.backend.entity.common.CustCtrl;
6
+import com.example.backend.entity.common.DataDic;
7
+import com.example.backend.entity.common.SysUser;
5 8
 import com.example.backend.entity.contract.*;
6 9
 import com.example.backend.excel.*;
7 10
 import com.example.backend.mapper.contract.*;
@@ -12,11 +15,10 @@ import org.springframework.stereotype.Service;
12 15
 import org.springframework.transaction.annotation.Transactional;
13 16
 import org.springframework.web.multipart.MultipartFile;
14 17
 
15
-import java.sql.Timestamp;
16 18
 import java.time.LocalDateTime;
17 19
 import java.util.ArrayList;
18
-import java.util.Date;
19 20
 import java.util.List;
21
+import java.util.Objects;
20 22
 
21 23
 
22 24
 @Service
@@ -40,6 +42,12 @@ public class SalesContractServiceImpl implements SalesContractService {
40 42
     @Autowired
41 43
     private SysUserMapper sysUserMapper;
42 44
 
45
+    @Autowired
46
+    private DicMapper dicMapper;
47
+
48
+    @Autowired
49
+    private CustCtrlMapper custCtrlMapper;
50
+
43 51
     @Override
44 52
     @Transactional(rollbackFor = Exception.class)
45 53
     public boolean importExcel(MultipartFile file) {
@@ -49,7 +57,7 @@ public class SalesContractServiceImpl implements SalesContractService {
49 57
         Long contractId = null;
50 58
 
51 59
         try {
52
-            // ================= 1️⃣ 主表 =================
60
+            // ================= 主表 =================
53 61
             try {
54 62
                 List<SalesContractExcelDTO> mainDataList = ExcelUtils.readMainSheet(file);
55 63
                 if (mainDataList.isEmpty()) {
@@ -76,12 +84,34 @@ public class SalesContractServiceImpl implements SalesContractService {
76 84
                     if (sysUsers == null || sysUsers.isEmpty()) {
77 85
                         errors.add("制单人代码有误! ");
78 86
                     }
87
+                    if (sysUsers != null && !sysUsers.get(0).getUserDesc().isEmpty()) {
88
+                        entity.setCreateByName(sysUsers.get(0).getUserDesc());
89
+                    }
79 90
                     if (StringUtils.isEmpty(entity.getBizProductType())) {
80 91
                         errors.add("合同产品类型不能为空!");
81 92
                     }
93
+
94
+                    List<DataDic> bizProdictTypeList = dicMapper.selectDicByBizProductType(entity.getBizProductType());
95
+                    if (bizProdictTypeList == null || bizProdictTypeList.isEmpty()) {
96
+                        errors.add("输入的合同产品类型在数据字典中不存在!");
97
+                    }
98
+
82 99
                     if (StringUtils.isEmpty(entity.getBizType())) {
83 100
                         errors.add("合同类型不能为空!");
84 101
                     }
102
+                    List<DataDic> bizTypeList = dicMapper.selectDicByBizType(entity.getBizType());
103
+                    if (bizTypeList == null || bizTypeList.isEmpty()) {
104
+                        errors.add("输入的合同类型在数据字典中不存在!");
105
+                    }
106
+                    if (StringUtils.isEmpty(entity.getServiceType())) {
107
+                        errors.add("业务类型不能为空!");
108
+                    }
109
+                    List<DataDic> serviceTypeList = dicMapper.selectDicByServiceType(entity.getServiceType());
110
+                    if (serviceTypeList == null || serviceTypeList.isEmpty()) {
111
+                        errors.add("输入的业务类型在数据字典中不存在!");
112
+                    }
113
+
114
+
85 115
                     if (StringUtils.isEmpty(entity.getContrExecCd())) {
86 116
                         errors.add("合同执行人不能为空!");
87 117
                     }
@@ -89,20 +119,40 @@ public class SalesContractServiceImpl implements SalesContractService {
89 119
                     if (contractUserList == null || contractUserList.isEmpty()) {
90 120
                         errors.add("合同执行人代码有误!");
91 121
                     }
92
-                    if (StringUtils.isEmpty(entity.getCtName())) {
93
-                        errors.add("客户名称不能为空!");
94
-                    }
95
-                    if (StringUtils.isEmpty(entity.getCtNo())) {
96
-                        errors.add("客户代码不能为空!");
122
+                    if (contractUserList != null && !contractUserList.get(0).getUserDesc().isEmpty()) {
123
+                        entity.setContrExecNm(contractUserList.get(0).getUserDesc());
97 124
                     }
125
+                    if (contractUserList == null || contractUserList.isEmpty())
126
+                        if (StringUtils.isEmpty(entity.getCtName())) {
127
+                            errors.add("客户名称不能为空!");
128
+                        }
98 129
 
99 130
                     List<SysUser> ctNameList = sysUserMapper.selectByCtName(entity.getCtName());
100 131
                     if (ctNameList == null || ctNameList.isEmpty()) {
101 132
                         errors.add("客户名称有误!");
102 133
                     }
103
-                    if (ctNameList != null && !ctNameList.isEmpty() && !ctNameList.get(0).getFno().equals(entity.getCtNo())) {
104
-                        errors.add("客户代码有误!");
134
+                    if (ctNameList != null && !ctNameList.get(0).getPlaced().equals("2")) {
135
+                        errors.add("客户名称没有审批通过!");
136
+                    }
137
+
138
+                    if (ctNameList != null && ctNameList.get(0).getFno().isEmpty()) {
139
+                        errors.add("客户代码不能为空!");
140
+                    }
141
+                    if (ctNameList != null && !ctNameList.get(0).getFno().isEmpty()) {
142
+                        entity.setCtNo(ctNameList.get(0).getFno());
105 143
                     }
144
+
145
+                    if (ctNameList != null && !ctNameList.get(0).getCtContNm().isEmpty()) {
146
+                        entity.setCtContNm(ctNameList.get(0).getCtContNm());
147
+                    }
148
+
149
+                    if (ctNameList != null && !ctNameList.get(0).getCtBankName().isEmpty()) {
150
+                        entity.setCtBankName(ctNameList.get(0).getCtBankName());
151
+                    }
152
+                    if (ctNameList != null && !ctNameList.get(0).getCtBankAcct().isEmpty()) {
153
+                        entity.setCtBankAcct(ctNameList.get(0).getCtBankAcct());
154
+                    }
155
+
106 156
                     if (StringUtils.isEmpty(entity.getCurcy())) {
107 157
                         errors.add("币别不能为空!");
108 158
                     }
@@ -111,11 +161,155 @@ public class SalesContractServiceImpl implements SalesContractService {
111 161
                     if (curcyList == null || curcyList.isEmpty()) {
112 162
                         errors.add("币别有误!");
113 163
                     }
164
+                    if (curcyList != null && Objects.isNull(curcyList.get(0).getRate())) {
165
+                        errors.add("折人民币汇率不能为空!");
166
+                    }
167
+                    if (curcyList != null && !Objects.isNull(curcyList.get(0).getRate())) {
168
+                        entity.setRate(curcyList.get(0).getRate());
169
+                    }
170
+
171
+
172
+                    if (curcyList != null && Objects.isNull(curcyList.get(0).getRateUsd())) {
173
+                        errors.add("折美元汇率不能为空!");
174
+                    }
175
+
176
+                    if (curcyList != null && !Objects.isNull(curcyList.get(0).getRateUsd())) {
177
+                        entity.setRateUs(curcyList.get(0).getRateUsd());
178
+                    }
114 179
 
115
-//                    if(entity.getEstLoadDt()==){
116
-//
117
-//                    }
118 180
 
181
+                    if ("出口销售".equals(entity.getBizType()) || "转口销售".equals(entity.getBizType())) {
182
+                        if (entity.getEstLoadDt() == null) {
183
+                            errors.add("合同类型为出口销售或转口销售时,最迟装运日期不能为空!");
184
+
185
+                        }
186
+                    }
187
+
188
+                    if (entity.getServiceType().contains("代理进口") || entity.getServiceType().contains("代理内贸")) {
189
+                        if (Objects.isNull(entity.getOutstandingDay())) {
190
+                            errors.add("业务类型为代理进口或代理内贸时,预计客商占款天数不能为空!");
191
+                        }
192
+                    }
193
+
194
+                    if (StringUtils.isEmpty(entity.getFoursname())) {
195
+                        errors.add("我方名称不能为空!");
196
+                    }
197
+                    List<CustCtrl> foursnameList = custCtrlMapper.selectOurNameByFoursname(entity.getFoursname());
198
+                    if (foursnameList == null || foursnameList.isEmpty()) {
199
+                        errors.add("我方名称有误!");
200
+                    }
201
+                    if (foursnameList != null && foursnameList.get(0).getFno().isEmpty()) {
202
+                        errors.add("我方编号不能为空!");
203
+                    }
204
+
205
+                    if (foursnameList != null && !foursnameList.get(0).getOurBankNm().isEmpty()) {
206
+                        entity.setOurBankNm(foursnameList.get(0).getOurBankNm());
207
+                    }
208
+
209
+                    if (foursnameList != null && !foursnameList.get(0).getOurBankAcct().isEmpty()) {
210
+                        entity.setOurBankAcct(foursnameList.get(0).getOurBankAcct());
211
+                    }
212
+
213
+                    if (StringUtils.isEmpty(entity.getIfClearBottom())) {
214
+                        entity.setIfClearBottom("否");
215
+                    }
216
+
217
+                    if ("铁矿石".equals(entity.getBizProductType()) || "煤炭".equals(entity.getBizProductType())) {
218
+                        if (StringUtils.isEmpty(entity.getIfLongTerm())) {
219
+                            errors.add("合同产品类型为铁矿石或煤炭时,是否长协不能为空");
220
+                        }
221
+                    }
222
+
223
+                    if (!StringUtils.isEmpty(entity.getIfLongTerm()) && "是".equals(entity.getIfLongTerm())) {
224
+                        if (StringUtils.isEmpty(entity.getLongTermContract())) {
225
+                            errors.add("是否长协为是时,长协合同号不能为空!");
226
+                        }
227
+                    }
228
+                    if ("出口销售".equals(entity.getBizType()) || "转口销售".equals(entity.getBizType()) || entity.getServiceType().contains("主业")) {
229
+                        if (StringUtils.isEmpty(entity.getLPort())) {
230
+                            errors.add("合同类型为出口销售或转口销售或业务类型包含主业时,装运港不能为空");
231
+                        }
232
+                        List<CustCtrl> lPortList = custCtrlMapper.selectLPortByLportName(entity.getLPort());
233
+                        if (lPortList == null || lPortList.isEmpty()) {
234
+                            errors.add("装运港有误!");
235
+                        }
236
+                        if (lPortList != null && !lPortList.get(0).getFno().isEmpty()) {
237
+                            entity.setLpno(lPortList.get(0).getFno());
238
+                        }
239
+                        if (lPortList != null && lPortList.get(0).getCountryName().isEmpty()) {
240
+                            errors.add("装运国不能为空!");
241
+                        }
242
+                        if (lPortList != null && !lPortList.get(0).getCountryName().isEmpty()) {
243
+                            entity.setLPortCtry(lPortList.get(0).getCountryName());
244
+                        }
245
+
246
+                        if (StringUtils.isEmpty(entity.getDPort())) {
247
+                            errors.add("合同类型为出口销售或转口销售或业务类型包含主业时,目的港不能为空");
248
+                        }
249
+                        List<CustCtrl> dPortList = custCtrlMapper.selectLPortByLportName(entity.getDPort());
250
+                        if (dPortList == null || dPortList.isEmpty()) {
251
+                            errors.add("目的港有误!");
252
+                        }
253
+                        if (dPortList != null && !dPortList.get(0).getFno().isEmpty()) {
254
+                            entity.setDpno(dPortList.get(0).getFno());
255
+                        }
256
+                        if (dPortList != null && dPortList.get(0).getCountryName().isEmpty()) {
257
+                            errors.add("目的国不能为空!");
258
+                        }
259
+                        if (dPortList != null && !dPortList.get(0).getCountryName().isEmpty()) {
260
+                            entity.setDPortCtry(dPortList.get(0).getCountryName());
261
+                        }
262
+
263
+                    }
264
+
265
+                    if (!entity.getIfClearBottom().isEmpty() && "是".equals(entity.getIfClearBottom())) {
266
+                        if (Objects.isNull(entity.getQtyOver())) {
267
+                            errors.add("是否清底为是时,数量溢装不能为空!");
268
+                        }
269
+
270
+                        if (Objects.isNull(entity.getQtyShort())) {
271
+                            errors.add("是否清底为是时,数量短装不能为空!");
272
+                        }
273
+                    }
274
+
275
+                    if ("出口销售".equals(entity.getBizType()) || "转口销售".equals(entity.getBizType())) {
276
+                        if (StringUtils.isEmpty(entity.getTerms())) {
277
+                            errors.add("合同类型为出口销售或转口销售时,价格条款不能为空");
278
+                        }
279
+                    }
280
+
281
+                    if (StringUtils.isEmpty(entity.getWhetherChartering())) {
282
+                        entity.setWhetherChartering("否");
283
+                    }
284
+
285
+                    if ("是".equals(entity.getWhetherChartering())) {
286
+                        if (StringUtils.isEmpty(entity.getChnShipName())) {
287
+                            errors.add("是否租船为是时,中文船名不能为空");
288
+                        }
289
+                        if (StringUtils.isEmpty(entity.getEngShipName())) {
290
+                            errors.add("是否租船为是时,英文船名不能为空");
291
+                        }
292
+                    }
293
+
294
+                    if ("代理-主业进口".equals(entity.getServiceType())) {
295
+                        if (!StringUtils.isEmpty(entity.getAgentNo())) {
296
+                            List<CustCtrl> agentNoList = custCtrlMapper.selectByAgentNo(entity.getAgentNo());
297
+                            if(agentNoList==null||agentNoList.isEmpty()){
298
+                                errors.add("代理采购协议号有误!");
299
+                            }
300
+                        }
301
+
302
+                    }
303
+
304
+                    if ("代理-主业进口".equals(entity.getServiceType())||"其他/混合分型".equals(entity.getServiceType())) {
305
+                        if (!StringUtils.isEmpty(entity.getAgentNo())) {
306
+                            List<CustCtrl> agentNoSoList = custCtrlMapper.selectByAgentNoSo(entity.getAgentNoSo());
307
+                            if(agentNoSoList==null||agentNoSoList.isEmpty()){
308
+                                errors.add("代理销售协议号 有误!");
309
+                            }
310
+                        }
311
+
312
+                    }
119 313
 
120 314
 
121 315
                     salesContractMapper.insert(entity);
@@ -133,7 +327,7 @@ public class SalesContractServiceImpl implements SalesContractService {
133 327
             final Long cid = contractId;
134 328
 
135 329
 
136
-            // ================= 2️⃣ 产品明细 =================
330
+            // =================  产品明细 =================
137 331
             try {
138 332
                 List<SalesDtlExcelDTO> list = ExcelUtils.readSalesDtlSheet(file);
139 333
                 if (!list.isEmpty() && cid != null) {
@@ -148,7 +342,7 @@ public class SalesContractServiceImpl implements SalesContractService {
148 342
             }
149 343
 
150 344
 
151
-            // ================= 3️⃣ 收款计划 =================
345
+            // ================= 收款计划 =================
152 346
             try {
153 347
                 List<SalesCollectExcelDTO> list = ExcelUtils.readSalesCollectSheet(file);
154 348
                 if (!list.isEmpty() && cid != null) {
@@ -163,7 +357,7 @@ public class SalesContractServiceImpl implements SalesContractService {
163 357
             }
164 358
 
165 359
 
166
-            // ================= 4️⃣ 责任中心 =================
360
+            // ================= 责任中心 =================
167 361
             try {
168 362
                 List<RCenterDtlExcelDTO> list = ExcelUtils.readRCenterDtlSheet(file);
169 363
                 if (!list.isEmpty() && cid != null) {
@@ -178,7 +372,7 @@ public class SalesContractServiceImpl implements SalesContractService {
178 372
             }
179 373
 
180 374
 
181
-            // ================= 5️⃣ 费用明细 =================
375
+            // ================= 费用明细 =================
182 376
             try {
183 377
                 List<FeeDtlExcelDTO> list = ExcelUtils.readFeelDtlSheet(file);
184 378
                 if (!list.isEmpty() && cid != null) {
@@ -193,7 +387,7 @@ public class SalesContractServiceImpl implements SalesContractService {
193 387
             }
194 388
 
195 389
 
196
-            // ================= 6️⃣ 服务费率 =================
390
+            // ================= 服务费率 =================
197 391
             try {
198 392
                 List<ExpSvcRateExcelDTO> list = ExcelUtils.readExpSvcRateSheet(file);
199 393
                 if (!list.isEmpty() && cid != null) {

+ 44
- 0
src/main/resources/mapper/CustCtrlMapper.xml Wyświetl plik

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.example.backend.mapper.contract.CustCtrlMapper">
4
+
5
+
6
+    <select id="selectOurNameByFoursname" resultType="com.example.backend.entity.common.CustCtrl">
7
+        select a.id,a.fno,a.cpal,a.cpny,a.addr,a.namee,a.addrc,a.signLoc ,
8
+        case when nvl(b.bankNm,'')='' then '无' else  nvl(b.bankNm,'')  end  as ourBankNm,
9
+        case when nvl(b.bankAcct,'')='' then '无' else  nvl(b.bankAcct,'')  end  as ourBankAcct
10
+        from SGGMIIP.addrctrl a
11
+        LEFT JOIN (
12
+        SELECT  stopBank,rid , bankNm , bankAcct , ROW_NUMBER() OVER (PARTITION BY rid ORDER BY id) as row_num
13
+        FROM SGGMIIP.custbank   WHERE NVL(del_flag, 0) != 1 and stopBank='否'
14
+        ) b ON a.id = b.rid AND b.row_num = 1
15
+        where ifnull(a.del_flag, 0) != 1
16
+        and NVL(a.placed, '0') = '2'
17
+        and a.cpny = #{foursname}
18
+        order by a.fno desc
19
+    </select>
20
+    <select id="selectLPortByLportName" resultType="com.example.backend.entity.common.CustCtrl">
21
+        select fno,portName,portCd,portNm,country,countryName
22
+        from SGGMIIP.portCtrl
23
+        where nvl(del_flag, 0) <>1
24
+        and isnull(country,'')<>''
25
+        and portName = #{lPort}
26
+        order by fno
27
+    </select>
28
+    <select id="selectByAgentNo" resultType="com.example.backend.entity.common.CustCtrl">
29
+        select a.fno,a.fdate,a.foursname,a.ctName
30
+        from SGGMIIP.ImpAgencyAgt a
31
+        where ifnull(a.del_flag, 0) != 1
32
+        and ifnull(a.placed,'')='2'
33
+        and a.fno = #{agentNo}
34
+        order by a.fdate desc
35
+    </select>
36
+    <select id="selectByAgentNoSo" resultType="com.example.backend.entity.common.CustCtrl">
37
+        select a.fno,a.fdate,a.foursname,a.ctName
38
+        from  SGGMIIP.ExpAgencyAgt  a
39
+        where ifnull(a.del_flag, 0) != 1
40
+        and ifnull(a.placed,'')='2'
41
+        and a.fno =#{agentNoSo}
42
+        order by a.fdate desc
43
+    </select>
44
+</mapper>

+ 33
- 0
src/main/resources/mapper/DicMapper.xml Wyświetl plik

@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.example.backend.mapper.contract.DicMapper">
4
+
5
+
6
+    <select id="selectDicByBizProductType" resultType="com.example.backend.entity.common.DataDic">
7
+        select d.dic_name, i.item_value
8
+        from SGGMIIP.data_dic d
9
+                 left join SGGMIIP.data_item i on d.id = i.dic_id
10
+        where i.item_value = #{bizProductType}
11
+          and d.dic_name = '合同产品类型'
12
+          and i.status = '0'
13
+          and d.status = '0'
14
+    </select>
15
+    <select id="selectDicByBizType" resultType="com.example.backend.entity.common.DataDic">
16
+        select d.dic_name, i.item_value
17
+        from SGGMIIP.data_dic d
18
+                 left join SGGMIIP.data_item i on d.id = i.dic_id
19
+        where i.item_value = #{bizType}
20
+          and d.dic_name = '销售业务类型'
21
+          and i.status = '0'
22
+          and d.status = '0'
23
+    </select>
24
+    <select id="selectDicByServiceType" resultType="com.example.backend.entity.common.DataDic">
25
+        select d.dic_name, i.item_value
26
+        from SGGMIIP.data_dic d
27
+                 left join SGGMIIP.data_item i on d.id = i.dic_id
28
+        where i.item_value = #{serviceType}
29
+          and d.dic_name = '业务类型'
30
+          and i.status = '0'
31
+          and d.status = '0'
32
+    </select>
33
+</mapper>

+ 37
- 0
src/main/resources/mapper/SysUserMapper.xml Wyświetl plik

@@ -0,0 +1,37 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.example.backend.mapper.contract.SysUserMapper">
4
+
5
+
6
+    <select id="selectByCtName" resultType="com.example.backend.entity.common.SysUser">
7
+        select a.id, a.fno,a.rptg,a.ctCnNm,a.ctEnNm,
8
+        case
9
+        when IFNULL(ctAbbr, '') = '' then IFNULL(ctEnAbbr, '')
10
+        else IFNULL(ctAbbr, '')
11
+        end as cpal
12
+        , case
13
+        when IFNULL(ctCnNm, '') = '' then IFNULL(ctEnNm, '')
14
+        else IFNULL(ctCnNm, '')
15
+        end as cpny
16
+        , case
17
+        when IFNULL(ctCnAddr, '') = '' then IFNULL(ctEnAddr, '')
18
+        else IFNULL(ctCnAddr, '')
19
+        end as addr, a.ctrylmbAddr, estabDt, ctLevel, a.tel
20
+        , a.email,
21
+        case when nvl(b.bankNm,'')='' then '' else  nvl(b.bankNm,'')  end  as ctBankName,
22
+        case when nvl(b.bankAcct,'')='' then '' else  nvl(b.bankAcct,'')  end  as ctBankAcct,
23
+        case when nvl(c.name,'')='' then '' else  nvl(c.name,'')  end  as ctContNm
24
+
25
+        from SGGMIIP.custctrl a
26
+        LEFT JOIN (
27
+        SELECT  rid , bankNm , bankAcct , ROW_NUMBER() OVER (PARTITION BY rid ORDER BY id) as row_num
28
+        FROM SGGMIIP.custbank   WHERE NVL(del_flag, 0) != 1
29
+        ) b ON a.id = b.rid AND b.row_num = 1
30
+        left join SGGMIIP.custattn c on a.id = c.rid
31
+        where ifnull(a.del_flag, 0) != 1
32
+        and INSTR(ctNature, '顾客') > 0
33
+        and nvl(ctStatus,'')='已准入'
34
+        and a.ctCnNm = #{ctName}
35
+        order by a.fno
36
+    </select>
37
+</mapper>

Ładowanie…
Anuluj
Zapisz