Преглед изворни кода

给销售exceL导入进行校验判断

胡北宽 пре 1 месец
родитељ
комит
d394fdad9c

+ 249
- 0
src/main/java/com/example/backend/entity/contract/SysUser.java Прегледај датотеку

1
+package com.example.backend.entity.contract;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import lombok.Data;
8
+
9
+import java.time.LocalDateTime;
10
+
11
+/**
12
+ * 系统用户表
13
+ */
14
+@Data
15
+@TableName("SGGMIIP.SYS_USER")
16
+public class SysUser {
17
+    
18
+    /**
19
+     * 主键ID
20
+     */
21
+    @TableId(value = "id", type = IdType.ASSIGN_UUID)
22
+    private String id;
23
+    
24
+    /**
25
+     * 用户代码
26
+     */
27
+    @TableField("USER_CODE")
28
+    private String userCode;
29
+    
30
+    /**
31
+     * 用户名称
32
+     */
33
+    @TableField("USER_NAME")
34
+    private String userName;
35
+    
36
+    /**
37
+     * 用户描述
38
+     */
39
+    @TableField("USER_DESC")
40
+    private String userDesc;
41
+    
42
+    /**
43
+     * 密码
44
+     */
45
+    @TableField("PASSWORD")
46
+    private String password;
47
+    
48
+    /**
49
+     * 是否启用
50
+     */
51
+    @TableField("IS_USED")
52
+    private String isUsed;
53
+    
54
+    /**
55
+     * 身份证号
56
+     */
57
+    @TableField("ID_CARD")
58
+    private String idCard;
59
+    
60
+    /**
61
+     * 电话
62
+     */
63
+    @TableField("PHONE")
64
+    private String phone;
65
+    
66
+    /**
67
+     * 手机
68
+     */
69
+    @TableField("MOBILE")
70
+    private String mobile;
71
+    
72
+    /**
73
+     * 备注
74
+     */
75
+    @TableField("MEMO")
76
+    private String memo;
77
+    
78
+    /**
79
+     * 添加人ID
80
+     */
81
+    @TableField("ADD_ID")
82
+    private String addId;
83
+    
84
+    /**
85
+     * 添加人代码
86
+     */
87
+    @TableField("ADD_CODE")
88
+    private String addCode;
89
+    
90
+    /**
91
+     * 添加人名称
92
+     */
93
+    @TableField("ADD_NAME")
94
+    private String addName;
95
+    
96
+    /**
97
+     * 添加时间
98
+     */
99
+    @TableField("ADD_TIME")
100
+    private LocalDateTime addTime;
101
+    
102
+    /**
103
+     * 修改人ID
104
+     */
105
+    @TableField("MODIFY_ID")
106
+    private String modifyId;
107
+    
108
+    /**
109
+     * 修改人代码
110
+     */
111
+    @TableField("MODIFY_CODE")
112
+    private String modifyCode;
113
+    
114
+    /**
115
+     * 修改人名称
116
+     */
117
+    @TableField("MODIFY_NAME")
118
+    private String modifyName;
119
+    
120
+    /**
121
+     * 修改时间
122
+     */
123
+    @TableField("MODIFY_TIME")
124
+    private LocalDateTime modifyTime;
125
+    
126
+    /**
127
+     * 删除标志 0存在9不存在
128
+     */
129
+    @TableField("CANCEL_FLAG")
130
+    private String cancelFlag;
131
+    
132
+    /**
133
+     * 删除人ID
134
+     */
135
+    @TableField("CANCEL_ID")
136
+    private String cancelId;
137
+    
138
+    /**
139
+     * 删除人代码
140
+     */
141
+    @TableField("CANCEL_CODE")
142
+    private String cancelCode;
143
+    
144
+    /**
145
+     * 删除人名称
146
+     */
147
+    @TableField("CANCEL_NAME")
148
+    private String cancelName;
149
+    
150
+    /**
151
+     * 删除时间
152
+     */
153
+    @TableField("CANCEL_TIME")
154
+    private LocalDateTime cancelTime;
155
+    
156
+    /**
157
+     * 所属ID
158
+     */
159
+    @TableField("BELONG_ID")
160
+    private String belongId;
161
+    
162
+    /**
163
+     * 所属部门代码
164
+     */
165
+    @TableField("BELONG_DEPT_CODE")
166
+    private String belongDeptCode;
167
+    
168
+    /**
169
+     * 所属部门名称
170
+     */
171
+    @TableField("BELONG_DEPT_NAME")
172
+    private String belongDeptName;
173
+    
174
+    /**
175
+     * 管理员标志
176
+     */
177
+    @TableField("ADMIN_FLAG")
178
+    private String adminFlag;
179
+    
180
+    /**
181
+     * 用户类型 区分内外部用户 司机 供应商 等
182
+     */
183
+    @TableField("USER_TYPE")
184
+    private String userType;
185
+    
186
+    /**
187
+     * 邮箱
188
+     */
189
+    @TableField("EMAIL")
190
+    private String email;
191
+    
192
+    /**
193
+     * 密码修改时间
194
+     */
195
+    @TableField("PASSWORD_MODIFY_TIME")
196
+    private LocalDateTime passwordModifyTime;
197
+    
198
+    /**
199
+     * 锁定标记 0未锁定 1锁定自动解锁 2锁定需手动解锁
200
+     */
201
+    @TableField("LOCK_FLAG")
202
+    private String lockFlag;
203
+    
204
+    /**
205
+     * 解锁时间
206
+     */
207
+    @TableField("UNLOCK_TIME")
208
+    private LocalDateTime unlockTime;
209
+    
210
+    /**
211
+     * OA用户代码
212
+     */
213
+    @TableField("OA_USER_CODE")
214
+    private String oaUserCode;
215
+    
216
+    /**
217
+     * 部门名称
218
+     */
219
+    @TableField("dept_name")
220
+    private String deptName;
221
+    
222
+    /**
223
+     * 部门ID
224
+     */
225
+    @TableField("dept_id")
226
+    private String deptId;
227
+    
228
+    /**
229
+     * PLMS对照账号
230
+     */
231
+    @TableField("plmsusercode")
232
+    private String plmsUserCode;
233
+    
234
+    /**
235
+     * 用户自增id调取选择用
236
+     */
237
+    @TableField("user_auto_id")
238
+    private Long userAutoId;
239
+
240
+    @TableField(exist = false)
241
+    private String ctCnNm;
242
+
243
+    @TableField(exist = false)
244
+    private String fno;
245
+
246
+    @TableField(exist = false)
247
+    private String fname;
248
+
249
+}

+ 16
- 16
src/main/java/com/example/backend/excel/SalesContractExcelDTO.java Прегледај датотеку

24
     @ExcelProperty("销售合同号")
24
     @ExcelProperty("销售合同号")
25
     private String sono;
25
     private String sono;
26
 
26
 
27
-    @ExcelProperty("客户订单号")
27
+    @ExcelProperty("客户合同号")
28
     private String ctOrderNo;
28
     private String ctOrderNo;
29
 
29
 
30
-    @ExcelProperty("业务类型")
30
+    @ExcelProperty("合同类型")
31
     private String bizType;
31
     private String bizType;
32
 
32
 
33
     @ExcelProperty("业务账套")
33
     @ExcelProperty("业务账套")
39
     @ExcelProperty("签约日期")
39
     @ExcelProperty("签约日期")
40
     private LocalDateTime signDate;
40
     private LocalDateTime signDate;
41
 
41
 
42
-    @ExcelProperty("代理协议号")
42
+    @ExcelProperty("代理采购协议号")
43
     private String agentNo;
43
     private String agentNo;
44
 
44
 
45
     @ExcelProperty("佣金合同号")
45
     @ExcelProperty("佣金合同号")
57
     @ExcelProperty("合同描述")
57
     @ExcelProperty("合同描述")
58
     private String contrDesc;
58
     private String contrDesc;
59
 
59
 
60
-    @ExcelProperty("我方代码")
60
+    @ExcelProperty("我方编号")
61
     private String fours;
61
     private String fours;
62
 
62
 
63
     @ExcelProperty("我方名称")
63
     @ExcelProperty("我方名称")
87
     @ExcelProperty("币别")
87
     @ExcelProperty("币别")
88
     private String curcy;
88
     private String curcy;
89
 
89
 
90
-    @ExcelProperty("汇率")
90
+    @ExcelProperty("折人民币汇率")
91
     private BigDecimal rate;
91
     private BigDecimal rate;
92
 
92
 
93
     @ExcelProperty("原币总金额")
93
     @ExcelProperty("原币总金额")
156
     @ExcelProperty("计价公式")
156
     @ExcelProperty("计价公式")
157
     private String priceForm;
157
     private String priceForm;
158
 
158
 
159
-    @ExcelProperty("数量溢装")
159
+    @ExcelProperty("数量溢装%")
160
     private BigDecimal qtyOver;
160
     private BigDecimal qtyOver;
161
 
161
 
162
-    @ExcelProperty("数量短装")
162
+    @ExcelProperty("数量短装%")
163
     private BigDecimal qtyShort;
163
     private BigDecimal qtyShort;
164
 
164
 
165
-    @ExcelProperty("金额溢装")
165
+    @ExcelProperty("金额溢装%")
166
     private BigDecimal amtOver;
166
     private BigDecimal amtOver;
167
 
167
 
168
-    @ExcelProperty("金额短装")
168
+    @ExcelProperty("金额短装%")
169
     private BigDecimal amtShort;
169
     private BigDecimal amtShort;
170
 
170
 
171
     @ExcelProperty("预收款比例")
171
     @ExcelProperty("预收款比例")
315
     @ExcelProperty("归档状态")
315
     @ExcelProperty("归档状态")
316
     private String fsaved;
316
     private String fsaved;
317
 
317
 
318
-    @ExcelProperty("备注")
318
+    @ExcelProperty("备注信息")
319
     private String remark;
319
     private String remark;
320
 
320
 
321
     @ExcelProperty("模版名称")
321
     @ExcelProperty("模版名称")
330
     @ExcelProperty("制单人部门名称")
330
     @ExcelProperty("制单人部门名称")
331
     private String deptName;
331
     private String deptName;
332
 
332
 
333
-    @ExcelProperty("创建账号")
333
+    @ExcelProperty("制单人代码")
334
     private String createBy;
334
     private String createBy;
335
 
335
 
336
     @ExcelProperty("创建时间")
336
     @ExcelProperty("创建时间")
337
     private LocalDateTime createTime;
337
     private LocalDateTime createTime;
338
 
338
 
339
-    @ExcelProperty("创建人")
339
+    @ExcelProperty("制单人名称")
340
     private String createByName;
340
     private String createByName;
341
 
341
 
342
     @ExcelProperty("更新账号")
342
     @ExcelProperty("更新账号")
489
     @ExcelProperty("保险种类")
489
     @ExcelProperty("保险种类")
490
     private String insuranceType;
490
     private String insuranceType;
491
 
491
 
492
-    @ExcelProperty("保险金额")
492
+    @ExcelProperty("保险费率%")
493
     private BigDecimal insuranceAmt;
493
     private BigDecimal insuranceAmt;
494
 
494
 
495
     @ExcelProperty("是否借壳")
495
     @ExcelProperty("是否借壳")
498
     @ExcelProperty("借壳单位")
498
     @ExcelProperty("借壳单位")
499
     private String shellCompany;
499
     private String shellCompany;
500
 
500
 
501
-    @ExcelProperty("是否分批")
501
+    @ExcelProperty("是否允许分批")
502
     private String ifBatch;
502
     private String ifBatch;
503
 
503
 
504
-    @ExcelProperty("是否转运")
504
+    @ExcelProperty("是否允许转运")
505
     private String ifTransfer;
505
     private String ifTransfer;
506
 
506
 
507
     @ExcelProperty("钢材产品判断字段")
507
     @ExcelProperty("钢材产品判断字段")
624
     @ExcelProperty("产品名称")
624
     @ExcelProperty("产品名称")
625
     private String mpsdesc;
625
     private String mpsdesc;
626
 
626
 
627
-    @ExcelProperty("未结天数")
627
+    @ExcelProperty("预计客商占款天数")
628
     private Integer outstandingDay;
628
     private Integer outstandingDay;
629
 
629
 
630
     @ExcelProperty("未结金额")
630
     @ExcelProperty("未结金额")

+ 56
- 0
src/main/java/com/example/backend/mapper/contract/SysUserMapper.java Прегледај датотеку

1
+package com.example.backend.mapper.contract;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.example.backend.entity.contract.SalesDtlEntity;
5
+import com.example.backend.entity.contract.SysUser;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+import org.apache.ibatis.annotations.Select;
9
+
10
+import java.util.List;
11
+
12
+/**
13
+ * 销售合同主表Mapper
14
+ */
15
+@Mapper
16
+public interface SysUserMapper extends BaseMapper<SysUser> {
17
+    @Select("select\n" +
18
+            "       b.user_code,b.user_name,b.user_desc\n" +
19
+            "from SGGMIIP.View_Dept_Code a\n" +
20
+            "         left join SGGMIIP.View_User_Code b on a.deptid = b.dept_id\n" +
21
+            "         left join SGGMIIP.addrctrl c on a.fourscode = c.hrDeptCode\n" +
22
+            "where b.user_code =#{userCode}")
23
+    List<SysUser> selectContractByNo(@Param("userCode") String userCode);
24
+
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")
40
+    List<SysUser> selectByCtName(@Param("ctName") String ctName);
41
+
42
+    @Select("select    a.id,a.fname,a.fname1,\n" +
43
+            "          (select rate from SGGMIIP.curcydtl where a.id=rid and targetcode='CNY' and nvl(del_flag,0)<>1) as rate ,\n" +
44
+            "          (select rate from SGGMIIP.curcydtl where a.id=rid and targetcode='USD' and nvl(del_flag,0)<>1) rateUsd ,\n" +
45
+            "          (SELECT b.rate from  SGGMIIP.curcyctrl a\n" +
46
+            "                                   left join SGGMIIP.curcydtl b on a.id=rid\n" +
47
+            "           where targetcode='CNY' and a.fname='USD' and nvl(b.del_flag,0)<>1 and nvl(a.del_flag,0)<>1) as rateUs\n" +
48
+            "from SGGMIIP.curcyctrl A\n" +
49
+            "where ifnull(a.del_flag, 0) <> 1\n" +
50
+            "  and ifnull(a.placed, '') = '2'\n" +
51
+            "  and a.fname =#{curcy}\n" +
52
+            "group by a.id,a.fname,a.fname1")
53
+    List<SysUser> selectByCurcy(@Param("curcy") String curcy);
54
+
55
+
56
+}

+ 69
- 1
src/main/java/com/example/backend/service/contract/impl/SalesContractServiceImpl.java Прегледај датотеку

1
 package com.example.backend.service.contract.impl;
1
 package com.example.backend.service.contract.impl;
2
 
2
 
3
+import com.alibaba.druid.util.StringUtils;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.example.backend.entity.contract.*;
5
 import com.example.backend.entity.contract.*;
4
 import com.example.backend.excel.*;
6
 import com.example.backend.excel.*;
5
 import com.example.backend.mapper.contract.*;
7
 import com.example.backend.mapper.contract.*;
10
 import org.springframework.transaction.annotation.Transactional;
12
 import org.springframework.transaction.annotation.Transactional;
11
 import org.springframework.web.multipart.MultipartFile;
13
 import org.springframework.web.multipart.MultipartFile;
12
 
14
 
15
+import java.sql.Timestamp;
16
+import java.time.LocalDateTime;
13
 import java.util.ArrayList;
17
 import java.util.ArrayList;
18
+import java.util.Date;
14
 import java.util.List;
19
 import java.util.List;
15
 
20
 
21
+
16
 @Service
22
 @Service
17
 public class SalesContractServiceImpl implements SalesContractService {
23
 public class SalesContractServiceImpl implements SalesContractService {
18
 
24
 
31
     @Autowired
37
     @Autowired
32
     private ContractErrorLogMapper contractErrorLogMapper;
38
     private ContractErrorLogMapper contractErrorLogMapper;
33
 
39
 
40
+    @Autowired
41
+    private SysUserMapper sysUserMapper;
42
+
34
     @Override
43
     @Override
35
     @Transactional(rollbackFor = Exception.class)
44
     @Transactional(rollbackFor = Exception.class)
36
     public boolean importExcel(MultipartFile file) {
45
     public boolean importExcel(MultipartFile file) {
49
                     SalesContractExcelDTO dto = mainDataList.size() >= 3 ? mainDataList.get(2) : mainDataList.get(0);
58
                     SalesContractExcelDTO dto = mainDataList.size() >= 3 ? mainDataList.get(2) : mainDataList.get(0);
50
                     SalesContractEntity entity = new SalesContractEntity();
59
                     SalesContractEntity entity = new SalesContractEntity();
51
                     BeanUtils.copyProperties(dto, entity);
60
                     BeanUtils.copyProperties(dto, entity);
61
+                    entity.setCreateTime(LocalDateTime.now());
62
+                    //销售合同主表校验
63
+                    if (StringUtils.isEmpty(entity.getSono())) {
64
+                        errors.add("销售合同号不能为空! ");
65
+                    }
66
+                    if (StringUtils.isEmpty(entity.getPono())) {
67
+                        errors.add("采购合同号不能为空! ");
68
+                    }
69
+                    if (StringUtils.isEmpty(entity.getCreateBy())) {
70
+                        errors.add("制单人代码不能为空! ");
71
+                    }
72
+                    List<SysUser> sysUsers = sysUserMapper.selectList(new QueryWrapper<>(SysUser.class)
73
+                            .eq("cancel_flag", "0")
74
+                            .eq("user_code", entity.getCreateBy())
75
+                    );
76
+                    if (sysUsers == null || sysUsers.isEmpty()) {
77
+                        errors.add("制单人代码有误! ");
78
+                    }
79
+                    if (StringUtils.isEmpty(entity.getBizProductType())) {
80
+                        errors.add("合同产品类型不能为空!");
81
+                    }
82
+                    if (StringUtils.isEmpty(entity.getBizType())) {
83
+                        errors.add("合同类型不能为空!");
84
+                    }
85
+                    if (StringUtils.isEmpty(entity.getContrExecCd())) {
86
+                        errors.add("合同执行人不能为空!");
87
+                    }
88
+                    List<SysUser> contractUserList = sysUserMapper.selectContractByNo(entity.getContrExecCd());
89
+                    if (contractUserList == null || contractUserList.isEmpty()) {
90
+                        errors.add("合同执行人代码有误!");
91
+                    }
92
+                    if (StringUtils.isEmpty(entity.getCtName())) {
93
+                        errors.add("客户名称不能为空!");
94
+                    }
95
+                    if (StringUtils.isEmpty(entity.getCtNo())) {
96
+                        errors.add("客户代码不能为空!");
97
+                    }
98
+
99
+                    List<SysUser> ctNameList = sysUserMapper.selectByCtName(entity.getCtName());
100
+                    if (ctNameList == null || ctNameList.isEmpty()) {
101
+                        errors.add("客户名称有误!");
102
+                    }
103
+                    if (ctNameList != null && !ctNameList.isEmpty() && !ctNameList.get(0).getFno().equals(entity.getCtNo())) {
104
+                        errors.add("客户代码有误!");
105
+                    }
106
+                    if (StringUtils.isEmpty(entity.getCurcy())) {
107
+                        errors.add("币别不能为空!");
108
+                    }
109
+
110
+                    List<SysUser> curcyList = sysUserMapper.selectByCurcy(entity.getCurcy());
111
+                    if (curcyList == null || curcyList.isEmpty()) {
112
+                        errors.add("币别有误!");
113
+                    }
114
+
115
+//                    if(entity.getEstLoadDt()==){
116
+//
117
+//                    }
118
+
119
+
52
 
120
 
53
                     salesContractMapper.insert(entity);
121
                     salesContractMapper.insert(entity);
54
                     contractId = entity.getId();
122
                     contractId = entity.getId();
55
                     if (contractId == null) {
123
                     if (contractId == null) {
56
-                        errors.add("主表ID生成失败(contractId 为 null)");
124
+                        errors.add("主表ID生成失败(contractId 为 null)");
57
                     }
125
                     }
58
                 }
126
                 }
59
             } catch (Exception e) {
127
             } catch (Exception e) {

Loading…
Откажи
Сачувај