Browse Source

Merge branch 'wq' of SH-Arbitrate/Arbitrate-Backend into dev

wangqiong123 2 years ago
parent
commit
a262b3cc4b

+ 8
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java View File

49
      */
49
      */
50
     public SysRole selectRoleById(Long roleId);
50
     public SysRole selectRoleById(Long roleId);
51
 
51
 
52
+    /**
53
+     * 根据角色名称查询角色id
54
+     * @param roleName
55
+     * @return
56
+     */
57
+    public Long selectRoleIdByName(String roleName);
58
+
59
+
52
     /**
60
     /**
53
      * 根据用户ID查询角色
61
      * 根据用户ID查询角色
54
      * 
62
      * 

+ 73
- 12
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java View File

28
 import com.ruoyi.common.core.domain.entity.SysUser;
28
 import com.ruoyi.common.core.domain.entity.SysUser;
29
 import com.ruoyi.common.exception.EsignDemoException;
29
 import com.ruoyi.common.exception.EsignDemoException;
30
 import com.ruoyi.common.exception.ServiceException;
30
 import com.ruoyi.common.exception.ServiceException;
31
+import com.ruoyi.system.domain.SysUserRole;
32
+import com.ruoyi.system.mapper.SysRoleMapper;
31
 import com.ruoyi.system.mapper.SysUserMapper;
33
 import com.ruoyi.system.mapper.SysUserMapper;
34
+import com.ruoyi.system.mapper.SysUserRoleMapper;
32
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
35
 import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
33
 import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
36
 import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
34
 import com.ruoyi.common.utils.bean.BeanUtils;
37
 import com.ruoyi.common.utils.bean.BeanUtils;
81
     @Autowired
84
     @Autowired
82
     private SysUserMapper sysUserMapper;
85
     private SysUserMapper sysUserMapper;
83
     @Autowired
86
     @Autowired
87
+    private SysUserRoleMapper userRoleMapper;
88
+    @Autowired
89
+    private SysRoleMapper roleMapper;
90
+    @Autowired
84
     private SealSignRecordMapper sealSignRecordMapper;
91
     private SealSignRecordMapper sealSignRecordMapper;
85
     @Autowired
92
     @Autowired
86
     private CaseLogRecordMapper caseLogRecordMapper;
93
     private CaseLogRecordMapper caseLogRecordMapper;
126
                 caseStatusList.add(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
133
                 caseStatusList.add(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
127
                 caseStatusList.add(CaseApplicationConstants.SIGN_ARBITRATION);
134
                 caseStatusList.add(CaseApplicationConstants.SIGN_ARBITRATION);
128
                 caseStatusList.add(CaseApplicationConstants.ARBITRATED_SEAL);
135
                 caseStatusList.add(CaseApplicationConstants.ARBITRATED_SEAL);
129
-                return caseApplicationMapper.selectDeptHeadCaseApplicationList(caseApplication,caseStatusList);
136
+                caseApplication.setDeptHeadStatus(caseStatusList);
130
             }
137
             }
131
             if(role.getRoleName().equals("仲裁员")){
138
             if(role.getRoleName().equals("仲裁员")){
132
                 caseApplication.setUserId(String.valueOf(userId));
139
                 caseApplication.setUserId(String.valueOf(userId));
133
             }
140
             }
141
+            if(role.getRoleName().equals("财务")){
142
+                caseApplication.setFinanceStatus(CaseApplicationConstants.PENDING_PAYMENT_CONFIRM);
143
+            }
134
             if(role.getRoleName().equals("法律顾问")){
144
             if(role.getRoleName().equals("法律顾问")){
135
                 // 查询角色有关的用户部门
145
                 // 查询角色有关的用户部门
136
                 List<Long> deptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
146
                 List<Long> deptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
174
             ){
184
             ){
175
                 return caseApplicationMapper.selectAdminCaseToDoCount();
185
                 return caseApplicationMapper.selectAdminCaseToDoCount();
176
             }
186
             }
177
-
178
-            // 查看所有案件
179
             if(role.getRoleName().equals("仲裁委")
187
             if(role.getRoleName().equals("仲裁委")
180
                     ||role.getRoleName().equals("部门长")){
188
                     ||role.getRoleName().equals("部门长")){
189
+
181
                 caseStatusList.add(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
190
                 caseStatusList.add(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
182
                 caseStatusList.add(CaseApplicationConstants.SIGN_ARBITRATION);
191
                 caseStatusList.add(CaseApplicationConstants.SIGN_ARBITRATION);
183
                 caseStatusList.add(CaseApplicationConstants.ARBITRATED_SEAL);
192
                 caseStatusList.add(CaseApplicationConstants.ARBITRATED_SEAL);
205
         }
214
         }
206
 
215
 
207
 
216
 
217
+
218
+
208
         // 根据条件查询申请人,被申请人,仲裁员,法律顾问案件
219
         // 根据条件查询申请人,被申请人,仲裁员,法律顾问案件
209
         return caseApplicationMapper.selectTodoCountByRole(caseApplication);
220
         return caseApplicationMapper.selectTodoCountByRole(caseApplication);
210
     }
221
     }
264
 
275
 
265
                     }
276
                     }
266
                     // 组装申请代理人信息
277
                     // 组装申请代理人信息
267
-                    buildAgentInfo(caseAffiliate);
278
+                    String agentInfoFlag = buildAgentInfo(caseAffiliate);
279
+                    if(StrUtil.isNotEmpty(agentInfoFlag)){
280
+                        throw new ServiceException(agentInfoFlag);
281
+                    }
268
                 }
282
                 }
269
             }
283
             }
270
 
284
 
352
                         caseAffiliate.setApplicationOrganId(String.valueOf(dept.getDeptId()));
366
                         caseAffiliate.setApplicationOrganId(String.valueOf(dept.getDeptId()));
353
 
367
 
354
                     }
368
                     }
355
-                    buildAgentInfo(caseAffiliate);
369
+                    String agentInfoFlag = buildAgentInfo(caseAffiliate);
370
+                    if(StrUtil.isNotEmpty(agentInfoFlag)){
371
+                        throw new ServiceException(agentInfoFlag);
372
+                    }
356
 
373
 
357
                 }
374
                 }
358
 
375
 
376
      * 组装申请代理人信息
393
      * 组装申请代理人信息
377
      * @param caseAffiliate
394
      * @param caseAffiliate
378
      */
395
      */
379
-    private void buildAgentInfo(CaseAffiliate caseAffiliate) {
380
-        if(StrUtil.isNotEmpty(caseAffiliate.getNameAgent())){
396
+    private String buildAgentInfo(CaseAffiliate caseAffiliate) {
397
+        if (caseAffiliate.getIdentityType()==1&&StrUtil.isNotEmpty(caseAffiliate.getNameAgent())) {
398
+            // 查询申请人角色id
399
+            Long roleId = roleMapper.selectRoleIdByName("申请人");
381
             // 组装申请机构代理人信息,用户表新增并且和部门关联
400
             // 组装申请机构代理人信息,用户表新增并且和部门关联
382
             // 根据代理人身份证去用户表查询,有修改,么有新增
401
             // 根据代理人身份证去用户表查询,有修改,么有新增
383
             SysUser agentUser = sysUserMapper.selectUserByIdCard(caseAffiliate.getIdentityNumAgent());
402
             SysUser agentUser = sysUserMapper.selectUserByIdCard(caseAffiliate.getIdentityNumAgent());
384
-            if(agentUser==null){
403
+            if (agentUser == null) {
385
                 agentUser = new SysUser();
404
                 agentUser = new SysUser();
386
                 agentUser.setIdCard(caseAffiliate.getIdentityNumAgent());
405
                 agentUser.setIdCard(caseAffiliate.getIdentityNumAgent());
387
                 agentUser.setNickName(caseAffiliate.getNameAgent());
406
                 agentUser.setNickName(caseAffiliate.getNameAgent());
390
                 agentUser.setPassword(SecurityUtils.encryptPassword(Constants.DEFAULT_PASSWORD));
409
                 agentUser.setPassword(SecurityUtils.encryptPassword(Constants.DEFAULT_PASSWORD));
391
                 agentUser.setDeptId(Long.valueOf(caseAffiliate.getApplicationOrganId()));
410
                 agentUser.setDeptId(Long.valueOf(caseAffiliate.getApplicationOrganId()));
392
                 int insertUserRow = sysUserMapper.insertUser(agentUser);
411
                 int insertUserRow = sysUserMapper.insertUser(agentUser);
393
-                if(insertUserRow>0) {
412
+                // 新增角色为申请人
413
+                ArrayList<SysUserRole> sysUserRoles = new ArrayList<>();
414
+                SysUserRole sysUserRole = new SysUserRole();
415
+                sysUserRole.setUserId(agentUser.getUserId());
416
+                sysUserRole.setRoleId(roleId);
417
+                sysUserRoles.add(sysUserRole);
418
+                if(CollectionUtil.isNotEmpty(sysUserRoles)) {
419
+                    userRoleMapper.batchUserRole(sysUserRoles);
420
+                }
421
+                if (insertUserRow > 0) {
394
                     caseAffiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
422
                     caseAffiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
395
                     // 发送短信 todo
423
                     // 发送短信 todo
396
                 }
424
                 }
397
-            }else {
425
+            } else if (null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(caseAffiliate.getApplicationOrganId())) {
426
+               return "申请机构与申请代理人不匹配";
427
+            } else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(caseAffiliate.getApplicationOrganId())){
398
                 // 同步用户表和案件关联人表的手机号和名称
428
                 // 同步用户表和案件关联人表的手机号和名称
399
                 caseAffiliate.setContactTelphoneAgent(agentUser.getPhonenumber());
429
                 caseAffiliate.setContactTelphoneAgent(agentUser.getPhonenumber());
400
                 caseAffiliate.setNameAgent(agentUser.getNickName());
430
                 caseAffiliate.setNameAgent(agentUser.getNickName());
401
                 caseAffiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
431
                 caseAffiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
432
+                // 新增角色为申请人
433
+                if(agentUser.getRoleIds()!=null) {
434
+                    List<Long> longList = Arrays.asList(agentUser.getRoleIds());
435
+                    if(!longList.contains(roleId)) {
436
+                        ArrayList<SysUserRole> sysUserRoles = new ArrayList<>();
437
+                        SysUserRole sysUserRole = new SysUserRole();
438
+                        sysUserRole.setUserId(agentUser.getUserId());
439
+                        sysUserRole.setRoleId(roleId);
440
+                        sysUserRoles.add(sysUserRole);
441
+                        if (CollectionUtil.isNotEmpty(sysUserRoles)) {
442
+                            userRoleMapper.batchUserRole(sysUserRoles);
443
+                        }
444
+                    }
445
+                }
446
+
402
             }
447
             }
403
 
448
 
449
+
404
         }
450
         }
451
+        return null;
405
     }
452
     }
406
 
453
 
407
     @Override
454
     @Override
529
 //                }else {
576
 //                }else {
530
 //                    caseApplicationListinsert.add(caseApplication);
577
 //                    caseApplicationListinsert.add(caseApplication);
531
 //                }
578
 //                }
532
-                    caseApplicationListinsert.add(caseApplication);
579
+                    if(StrUtil.isEmpty(caseApplication.getErrorMsg())) {
580
+                        caseApplicationListinsert.add(caseApplication);
581
+                    }else {
582
+                        // 拼接错误信息
583
+                        failureMsg.append("<br/>").append("第").append(i+2).append("行:").append(caseApplication.getErrorMsg().toString());
584
+
585
+                    }
533
                 }else {
586
                 }else {
534
                     // 拼接错误信息
587
                     // 拼接错误信息
535
                     failureMsg.append("<br/>").append("第").append(i+2).append("行:").append(caseApplication.getErrorMsg().toString());
588
                     failureMsg.append("<br/>").append("第").append(i+2).append("行:").append(caseApplication.getErrorMsg().toString());
577
                             if(caseAffiliates!=null&&caseAffiliates.size()>0){
630
                             if(caseAffiliates!=null&&caseAffiliates.size()>0){
578
                                 for (CaseAffiliate caseAffiliate : caseAffiliates){
631
                                 for (CaseAffiliate caseAffiliate : caseAffiliates){
579
                                     caseAffiliate.setCaseAppliId(caseApplicationItera.getId());
632
                                     caseAffiliate.setCaseAppliId(caseApplicationItera.getId());
580
-                                    buildAgentInfo(caseAffiliate);
581
 
633
 
582
                                 }
634
                                 }
583
                                 caseAffiliateMapper.batchCaseAffiliate(caseAffiliates);
635
                                 caseAffiliateMapper.batchCaseAffiliate(caseAffiliates);
1444
         if(StrUtil.isNotEmpty(caseApplication.getName())){
1496
         if(StrUtil.isNotEmpty(caseApplication.getName())){
1445
             setApplicantOrganization(caseAffiliate, caseApplication, deptMap);
1497
             setApplicantOrganization(caseAffiliate, caseApplication, deptMap);
1446
         }
1498
         }
1499
+        String s = buildAgentInfo(caseAffiliate);
1500
+        if(StrUtil.isNotEmpty(s)){
1501
+            StringBuilder errorMsg = caseApplication.getErrorMsg();
1502
+            if(StrUtil.isEmpty(errorMsg)){
1503
+             errorMsg=new StringBuilder();
1504
+            }
1505
+            errorMsg.append(s);
1506
+            caseApplication.setErrorMsg(errorMsg);
1507
+        }
1447
         caseAffiliatesnew.add(caseAffiliate);
1508
         caseAffiliatesnew.add(caseAffiliate);
1448
 
1509
 
1449
         // 组装被申请人信息
1510
         // 组装被申请人信息

+ 5
- 2
ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml View File

92
 		<include refid="selectRoleVo"/>
92
 		<include refid="selectRoleVo"/>
93
 		 where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
93
 		 where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
94
 	</select>
94
 	</select>
95
-	
96
- 	<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
95
+    <select id="selectRoleIdByName" resultType="java.lang.Long" >
96
+		select role_id from sys_role where role_name=#{roleName}
97
+	</select>
98
+
99
+	<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
97
  		insert into sys_role(
100
  		insert into sys_role(
98
  			<if test="roleId != null and roleId != 0">role_id,</if>
101
  			<if test="roleId != null and roleId != 0">role_id,</if>
99
  			<if test="roleName != null and roleName != ''">role_name,</if>
102
  			<if test="roleName != null and roleName != ''">role_name,</if>

+ 13
- 1
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseApplicationMapper.xml View File

118
                 #{caseStatus}
118
                 #{caseStatus}
119
             </foreach>
119
             </foreach>
120
             </if>
120
             </if>
121
-            <!--申请人-->
121
+            <!--财务-->
122
             <if test="financeStatus != null and financeStatus != ''">
122
             <if test="financeStatus != null and financeStatus != ''">
123
                 or( t.case_status =#{financeStatus})
123
                 or( t.case_status =#{financeStatus})
124
 
124
 
203
                 and t.case_status in (0,2))
203
                 and t.case_status in (0,2))
204
                 )
204
                 )
205
             </if>
205
             </if>
206
+            <!--部门长-->
207
+            <if test="deptHeadStatus != null and deptHeadStatus.size() > 0">
208
+                or t.case_status in
209
+                <foreach item="caseStatus" collection="deptHeadStatus" open="(" separator="," close=")">
210
+                    #{caseStatus}
211
+                </foreach>
212
+            </if>
213
+            <!--财务-->
214
+            <if test="financeStatus != null and financeStatus != ''">
215
+                or( t.case_status =#{financeStatus})
216
+
217
+            </if>
206
         </where>
218
         </where>
207
         ) t1
219
         ) t1
208
 --         <where>
220
 --         <where>