浏览代码

Merge branch 'wq1' of SH-Arbitrate/Mediation-Backend into dev

wangqiong123 2 年前
父节点
当前提交
b6de7d9111
共有 27 个文件被更改,包括 694 次插入513 次删除
  1. 22
    13
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
  2. 39
    3
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java
  3. 9
    14
      ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
  4. 35
    27
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  5. 2
    14
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
  6. 4
    0
      ruoyi-common/src/main/java/com/ruoyi/common/enums/AnnexTypeEnum.java
  7. 64
    0
      ruoyi-common/src/main/java/com/ruoyi/common/enums/MediationMethodEnum.java
  8. 1
    14
      ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
  9. 9
    8
      ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
  10. 1
    1
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
  11. 2
    10
      ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java
  12. 11
    2
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
  13. 2
    3
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserDeptMapper.java
  14. 0
    4
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java
  15. 31
    43
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
  16. 10
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java
  17. 3
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseMediator.java
  18. 0
    5
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/BookingVO.java
  19. 7
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java
  20. 0
    10
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java
  21. 2
    1
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/dept/impl/DeptIdentifyServiceImpl.java
  22. 37
    0
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java
  23. 266
    203
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java
  24. 3
    4
      ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java
  25. 6
    0
      ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
  26. 4
    4
      ruoyi-system/src/main/resources/mapper/system/SysUserDeptMapper.xml
  27. 124
    129
      ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

+ 22
- 13
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java 查看文件

@@ -1,19 +1,7 @@
1 1
 package com.ruoyi.web.controller.system;
2 2
 
3
-import java.util.List;
4
-import java.util.stream.Collectors;
5
-import javax.servlet.http.HttpServletResponse;
6
-
7
-import cn.hutool.core.util.StrUtil;
3
+import cn.hutool.core.collection.CollectionUtil;
8 4
 import com.ruoyi.common.annotation.Anonymous;
9
-import io.swagger.annotations.Api;
10
-import io.swagger.annotations.ApiOperation;
11
-import org.apache.commons.lang3.ArrayUtils;
12
-import org.springframework.beans.factory.annotation.Autowired;
13
-import org.springframework.security.access.prepost.PreAuthorize;
14
-import org.springframework.validation.annotation.Validated;
15
-import org.springframework.web.bind.annotation.*;
16
-import org.springframework.web.multipart.MultipartFile;
17 5
 import com.ruoyi.common.annotation.Log;
18 6
 import com.ruoyi.common.core.controller.BaseController;
19 7
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -25,10 +13,23 @@ import com.ruoyi.common.enums.BusinessType;
25 13
 import com.ruoyi.common.utils.SecurityUtils;
26 14
 import com.ruoyi.common.utils.StringUtils;
27 15
 import com.ruoyi.common.utils.poi.ExcelUtil;
16
+import com.ruoyi.system.mapper.SysDeptMapper;
28 17
 import com.ruoyi.system.service.ISysDeptService;
29 18
 import com.ruoyi.system.service.ISysPostService;
30 19
 import com.ruoyi.system.service.ISysRoleService;
31 20
 import com.ruoyi.system.service.ISysUserService;
21
+import io.swagger.annotations.Api;
22
+import io.swagger.annotations.ApiOperation;
23
+import org.apache.commons.lang3.ArrayUtils;
24
+import org.springframework.beans.factory.annotation.Autowired;
25
+import org.springframework.security.access.prepost.PreAuthorize;
26
+import org.springframework.validation.annotation.Validated;
27
+import org.springframework.web.bind.annotation.*;
28
+import org.springframework.web.multipart.MultipartFile;
29
+
30
+import javax.servlet.http.HttpServletResponse;
31
+import java.util.List;
32
+import java.util.stream.Collectors;
32 33
 
33 34
 /**
34 35
  * 用户信息
@@ -51,6 +52,8 @@ public class SysUserController extends BaseController
51 52
 
52 53
     @Autowired
53 54
     private ISysPostService postService;
55
+    @Autowired
56
+    private SysDeptMapper deptMapper;
54 57
 
55 58
     /**
56 59
      * 获取用户列表
@@ -106,12 +109,18 @@ public class SysUserController extends BaseController
106 109
         List<SysRole> roles = roleService.selectRoleAll();
107 110
         ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
108 111
         ajax.put("posts", postService.selectPostAll());
112
+
109 113
         if (StringUtils.isNotNull(userId))
110 114
         {
111 115
             SysUser sysUser = userService.selectUserById(userId);
112 116
             ajax.put(AjaxResult.DATA_TAG, sysUser);
113 117
             ajax.put("postIds", postService.selectPostListByUserId(userId));
114 118
             ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
119
+            List<SysDept> sysUserDepts = deptMapper.selectDeptByUserId(userId);
120
+            if(CollectionUtil.isNotEmpty(sysUserDepts)) {
121
+                    ajax.put("deptId", sysUserDepts.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
122
+
123
+            }
115 124
         }
116 125
         return ajax;
117 126
     }

+ 39
- 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java 查看文件

@@ -2,12 +2,14 @@ package com.ruoyi.web.controller.wisdomarbitrate.mscase;
2 2
 
3 3
 
4 4
 import cn.hutool.core.collection.CollectionUtil;
5
+import cn.hutool.core.util.IdcardUtil;
5 6
 import cn.hutool.core.util.StrUtil;
6 7
 import com.ruoyi.common.annotation.Anonymous;
7 8
 import com.ruoyi.common.core.controller.BaseController;
8 9
 import com.ruoyi.common.core.domain.AjaxResult;
9 10
 import com.ruoyi.common.core.page.TableDataInfo;
10 11
 import com.ruoyi.common.exception.EsignDemoException;
12
+import com.ruoyi.common.utils.IdCardUtils;
11 13
 import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
12 14
 import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
13 15
 import com.ruoyi.wisdomarbitrate.domain.vo.mscase.*;
@@ -20,7 +22,11 @@ import org.springframework.web.multipart.MultipartFile;
20 22
 
21 23
 import javax.annotation.Resource;
22 24
 import java.io.IOException;
25
+import java.text.SimpleDateFormat;
26
+import java.util.Date;
23 27
 import java.util.List;
28
+import java.util.Map;
29
+
24 30
 /**
25 31
  * 案件列表控制层
26 32
  * @Author wangqiong
@@ -57,6 +63,36 @@ public class MsCaseApplicationController extends BaseController {
57 63
 
58 64
         return success(caseApplicationService.insert(caseApplication));
59 65
     }
66
+    /**
67
+     * 根据身份证号获取性别和出生日期
68
+     */
69
+    @GetMapping("/getInfoByIdCard")
70
+    public AjaxResult getInfoByIdCard(@RequestParam("idCard") String idCard)
71
+    {
72
+        if(StrUtil.isEmpty(idCard)){
73
+            error("参数校验失败");
74
+        }
75
+        if(!IdcardUtil.isValidCard(idCard)){
76
+            error("身份证不合法,请输入正确的身份证号");
77
+        }
78
+        AjaxResult ajax = AjaxResult.success();
79
+        Map<String, String> identityNumMap = IdCardUtils.getBirAgeSex(idCard);
80
+        String birthday = identityNumMap.get("birthday");
81
+        if (StrUtil.isNotEmpty(birthday)) {
82
+            SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd");
83
+
84
+            Date birthdayDate = null;
85
+            try {
86
+                birthdayDate = yyyymmddFormat.parse(birthday);
87
+            } catch (Exception e) {
88
+                e.printStackTrace();
89
+            }
90
+            ajax.put("respondentBirth",birthdayDate);
91
+        }
92
+        //从身份证抓取性别
93
+        ajax.put("respondentSex",identityNumMap.get("sexCode"));
94
+        return ajax;
95
+    }
60 96
 
61 97
     /**
62 98
      * 修改案件
@@ -67,7 +103,7 @@ public class MsCaseApplicationController extends BaseController {
67 103
         if(caseApplication.getId()==null){
68 104
             error("id不能为空");
69 105
         }
70
-        return caseApplicationService.update(caseApplication);
106
+        return success(caseApplicationService.update(caseApplication));
71 107
     }
72 108
     /**
73 109
      * 根据id查询案件
@@ -168,7 +204,7 @@ public class MsCaseApplicationController extends BaseController {
168 204
      */
169 205
     @PostMapping("/updateBooking")
170 206
     public AjaxResult updateBooking(@RequestBody BookingVO vo ) {
171
-        if(vo.getId()==null || CollectionUtil.isEmpty(vo.getUserList())){
207
+        if(vo.getId()==null || CollectionUtil.isEmpty(vo.getMediatorList())){
172 208
             return error("参数校验失败");
173 209
         }
174 210
         return caseApplicationService.updateBooking(vo);
@@ -218,7 +254,7 @@ public class MsCaseApplicationController extends BaseController {
218 254
      */
219 255
     @PostMapping("/mediation")
220 256
     public AjaxResult mediation(@RequestBody MsCaseApplicationReq req)   {
221
-        if (req.getCaseFlowId() == null || (req.getId() == null && StrUtil.isEmpty(req.getBatchNumber()))) {
257
+        if (req.getCaseFlowId() == null || req.getId() == null) {
222 258
             return error("参数校验失败");
223 259
         }
224 260
 

+ 9
- 14
ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java 查看文件

@@ -1,12 +1,5 @@
1 1
 package com.ruoyi.common.core.controller;
2 2
 
3
-import java.beans.PropertyEditorSupport;
4
-import java.util.Date;
5
-import java.util.List;
6
-import org.slf4j.Logger;
7
-import org.slf4j.LoggerFactory;
8
-import org.springframework.web.bind.WebDataBinder;
9
-import org.springframework.web.bind.annotation.InitBinder;
10 3
 import com.github.pagehelper.PageHelper;
11 4
 import com.github.pagehelper.PageInfo;
12 5
 import com.ruoyi.common.constant.HttpStatus;
@@ -20,6 +13,14 @@ import com.ruoyi.common.utils.PageUtils;
20 13
 import com.ruoyi.common.utils.SecurityUtils;
21 14
 import com.ruoyi.common.utils.StringUtils;
22 15
 import com.ruoyi.common.utils.sql.SqlUtil;
16
+import org.slf4j.Logger;
17
+import org.slf4j.LoggerFactory;
18
+import org.springframework.web.bind.WebDataBinder;
19
+import org.springframework.web.bind.annotation.InitBinder;
20
+
21
+import java.beans.PropertyEditorSupport;
22
+import java.util.Date;
23
+import java.util.List;
23 24
 
24 25
 /**
25 26
  * web层通用数据处理
@@ -184,13 +185,7 @@ public class BaseController
184 185
         return getLoginUser().getUserId();
185 186
     }
186 187
 
187
-    /**
188
-     * 获取登录部门id
189
-     */
190
-    public Long getDeptId()
191
-    {
192
-        return getLoginUser().getDeptId();
193
-    }
188
+
194 189
 
195 190
     /**
196 191
      * 获取登录用户名

+ 35
- 27
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java 查看文件

@@ -1,18 +1,19 @@
1 1
 package com.ruoyi.common.core.domain.entity;
2 2
 
3
-import java.util.Date;
4
-import java.util.List;
5
-import javax.validation.constraints.*;
6
-
7 3
 import com.ruoyi.common.annotation.DictConvert;
8
-import org.apache.commons.lang3.builder.ToStringBuilder;
9
-import org.apache.commons.lang3.builder.ToStringStyle;
10 4
 import com.ruoyi.common.annotation.Excel;
11 5
 import com.ruoyi.common.annotation.Excel.ColumnType;
12 6
 import com.ruoyi.common.annotation.Excel.Type;
13
-import com.ruoyi.common.annotation.Excels;
14 7
 import com.ruoyi.common.core.domain.BaseEntity;
15 8
 import com.ruoyi.common.xss.Xss;
9
+import org.apache.commons.lang3.builder.ToStringBuilder;
10
+import org.apache.commons.lang3.builder.ToStringStyle;
11
+
12
+import javax.validation.constraints.Email;
13
+import javax.validation.constraints.NotBlank;
14
+import javax.validation.constraints.Size;
15
+import java.util.Date;
16
+import java.util.List;
16 17
 
17 18
 /**
18 19
  * 用户对象 sys_user
@@ -27,9 +28,9 @@ public class SysUser extends BaseEntity
27 28
     @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
28 29
     private Long userId;
29 30
 
30
-    /** 部门ID */
31
-    @Excel(name = "部门编号", type = Type.IMPORT)
32
-    private Long deptId;
31
+    /** 部门IDs */
32
+//    @Excel(name = "部门编号", type = Type.IMPORT)
33
+    private List<Long> deptIds;
33 34
 
34 35
     /** 用户账号 */
35 36
     @Excel(name = "登录名称")
@@ -52,6 +53,15 @@ public class SysUser extends BaseEntity
52 53
         this.nickNameAndNum = nickNameAndNum;
53 54
     }
54 55
 
56
+    public List<Long> getDeptIds() {
57
+        return deptIds;
58
+    }
59
+
60
+    public void setDeptIds(List<Long> deptIds) {
61
+        this.deptIds = deptIds;
62
+    }
63
+
64
+
55 65
     /** 用户身份证号 */
56 66
     @Excel(name = "身份证号")
57 67
     private String idCard;
@@ -96,11 +106,11 @@ public class SysUser extends BaseEntity
96 106
     private Date loginDate;
97 107
 
98 108
     /** 部门对象 */
99
-    @Excels({
100
-        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
101
-        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
102
-    })
103
-    private SysDept dept;
109
+//    @Excels({
110
+//        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
111
+//        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
112
+//    })
113
+    private List<SysDept> depts;
104 114
 
105 115
     /** 角色对象 */
106 116
     private List<SysRole> roles;
@@ -119,6 +129,8 @@ public class SysUser extends BaseEntity
119 129
 
120 130
     }
121 131
 
132
+
133
+
122 134
     public SysUser(Long userId)
123 135
     {
124 136
         this.userId = userId;
@@ -144,11 +156,6 @@ public class SysUser extends BaseEntity
144 156
         return userId != null && 1L == userId;
145 157
     }
146 158
 
147
-    public Long getDeptId()
148
-    {
149
-        return deptId;
150
-    }
151
-
152 159
     public String getSexName() {
153 160
         return sexName;
154 161
     }
@@ -165,9 +172,9 @@ public class SysUser extends BaseEntity
165 172
         this.specialty = specialty;
166 173
     }
167 174
 
168
-    public void setDeptId(Long deptId)
175
+    public void setDeptId(List<Long> deptId)
169 176
     {
170
-        this.deptId = deptId;
177
+        this.deptIds = deptId;
171 178
     }
172 179
 
173 180
     @Xss(message = "用户昵称不能包含脚本字符")
@@ -288,14 +295,14 @@ public class SysUser extends BaseEntity
288 295
         this.loginDate = loginDate;
289 296
     }
290 297
 
291
-    public SysDept getDept()
298
+    public List<SysDept> getDept()
292 299
     {
293
-        return dept;
300
+        return depts;
294 301
     }
295 302
 
296
-    public void setDept(SysDept dept)
303
+    public void setDept(List<SysDept> depts)
297 304
     {
298
-        this.dept = dept;
305
+        this.depts = depts;
299 306
     }
300 307
 
301 308
     public List<SysRole> getRoles()
@@ -346,11 +353,12 @@ public class SysUser extends BaseEntity
346 353
         this.idCard = idCard;
347 354
     }
348 355
 
356
+
349 357
     @Override
350 358
     public String toString() {
351 359
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
352 360
             .append("userId", getUserId())
353
-            .append("deptId", getDeptId())
361
+            .append("deptIds", getDeptIds())
354 362
             .append("userName", getUserName())
355 363
             .append("idCard", getIdCard())
356 364
             .append("nickName", getNickName())

+ 2
- 14
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java 查看文件

@@ -21,10 +21,7 @@ public class LoginUser implements UserDetails
21 21
      */
22 22
     private Long userId;
23 23
 
24
-    /**
25
-     * 部门ID
26
-     */
27
-    private Long deptId;
24
+
28 25
 
29 26
     /**
30 27
      * 用户唯一标识
@@ -81,10 +78,9 @@ public class LoginUser implements UserDetails
81 78
         this.permissions = permissions;
82 79
     }
83 80
 
84
-    public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
81
+    public LoginUser(Long userId,  SysUser user, Set<String> permissions)
85 82
     {
86 83
         this.userId = userId;
87
-        this.deptId = deptId;
88 84
         this.user = user;
89 85
         this.permissions = permissions;
90 86
     }
@@ -99,15 +95,7 @@ public class LoginUser implements UserDetails
99 95
         this.userId = userId;
100 96
     }
101 97
 
102
-    public Long getDeptId()
103
-    {
104
-        return deptId;
105
-    }
106 98
 
107
-    public void setDeptId(Long deptId)
108
-    {
109
-        this.deptId = deptId;
110
-    }
111 99
 
112 100
     public String getToken()
113 101
     {

+ 4
- 0
ruoyi-common/src/main/java/com/ruoyi/common/enums/AnnexTypeEnum.java 查看文件

@@ -17,6 +17,10 @@ public enum AnnexTypeEnum implements EnumsInterface {
17 17
     MEETING_VIDEO(5, "会议视频"),
18 18
     MEDIATE(6, "庭审笔录"),
19 19
     MEDIATE_BOOK(7, "调解书"),
20
+    MEDIATION_FILES(8, "调解资料"),
21
+
22
+    SEAL_PICTURE(10, "印章图片"),
23
+
20 24
 
21 25
     ;
22 26
 

+ 64
- 0
ruoyi-common/src/main/java/com/ruoyi/common/enums/MediationMethodEnum.java 查看文件

@@ -0,0 +1,64 @@
1
+package com.ruoyi.common.enums;
2
+
3
+import com.ruoyi.common.interfaces.EnumsInterface;
4
+
5
+/**
6
+ * @Classname AnnexTypeEnum
7
+ * @Description 调解方式枚举
8
+ * @Version 1.0.0
9
+ * @Date 2024/1/12 17:50
10
+ * @Created wangqiong
11
+ */
12
+public enum MediationMethodEnum implements EnumsInterface {
13
+    ON_LINE("1", "线上调解"),
14
+    OFF_LINE("2", "线下调解"),
15
+
16
+    ;
17
+
18
+    private final String code;
19
+    private final String text;
20
+
21
+    MediationMethodEnum(String code, String text)
22
+    {
23
+        this.code = code;
24
+        this.text = text;
25
+    }
26
+
27
+    public String getCode()
28
+    {
29
+        return code;
30
+    }
31
+
32
+    public String getText()
33
+    {
34
+        return text;
35
+    }
36
+
37
+    /**
38
+     * 根据code获取text
39
+     * @param codeNo
40
+     * @return
41
+     */
42
+    public static String getTextByCode(String codeNo){
43
+        for (MediationMethodEnum value : MediationMethodEnum.values()) {
44
+            if (value.getCode().equals(codeNo)){
45
+                return value.getText();
46
+            }
47
+        }
48
+        return codeNo;
49
+    }
50
+
51
+    /**
52
+     * 根据text获取code
53
+     * @param textStr
54
+     * @return
55
+     */
56
+    public static String getCodeByText(String textStr){
57
+        for (MediationMethodEnum value : MediationMethodEnum.values()) {
58
+            if (value.getText().equals(textStr)){
59
+                return value.getText();
60
+            }
61
+        }
62
+        return textStr;
63
+    }
64
+}

+ 1
- 14
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java 查看文件

@@ -29,20 +29,7 @@ public class SecurityUtils
29 29
         }
30 30
     }
31 31
 
32
-    /**
33
-     * 获取部门ID
34
-     **/
35
-    public static Long getDeptId()
36
-    {
37
-        try
38
-        {
39
-            return getLoginUser().getDeptId();
40
-        }
41
-        catch (Exception e)
42
-        {
43
-            throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
44
-        }
45
-    }
32
+
46 33
     
47 34
     /**
48 35
      * 获取用户账户

+ 9
- 8
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java 查看文件

@@ -1,11 +1,5 @@
1 1
 package com.ruoyi.framework.aspectj;
2 2
 
3
-import java.util.ArrayList;
4
-import java.util.List;
5
-import org.aspectj.lang.JoinPoint;
6
-import org.aspectj.lang.annotation.Aspect;
7
-import org.aspectj.lang.annotation.Before;
8
-import org.springframework.stereotype.Component;
9 3
 import com.ruoyi.common.annotation.DataScope;
10 4
 import com.ruoyi.common.core.domain.BaseEntity;
11 5
 import com.ruoyi.common.core.domain.entity.SysRole;
@@ -15,6 +9,13 @@ import com.ruoyi.common.core.text.Convert;
15 9
 import com.ruoyi.common.utils.SecurityUtils;
16 10
 import com.ruoyi.common.utils.StringUtils;
17 11
 import com.ruoyi.framework.security.context.PermissionContextHolder;
12
+import org.aspectj.lang.JoinPoint;
13
+import org.aspectj.lang.annotation.Aspect;
14
+import org.aspectj.lang.annotation.Before;
15
+import org.springframework.stereotype.Component;
16
+
17
+import java.util.ArrayList;
18
+import java.util.List;
18 19
 
19 20
 /**
20 21
  * 数据过滤处理
@@ -119,13 +120,13 @@ public class DataScopeAspect
119 120
             }
120 121
             else if (DATA_SCOPE_DEPT.equals(dataScope))
121 122
             {
122
-                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
123
+                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDept()));
123 124
             }
124 125
             else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
125 126
             {
126 127
                 sqlString.append(StringUtils.format(
127 128
                         " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
128
-                        deptAlias, user.getDeptId(), user.getDeptId()));
129
+                        deptAlias, user.getDept(), user.getDept()));
129 130
             }
130 131
             else if (DATA_SCOPE_SELF.equals(dataScope))
131 132
             {

+ 1
- 1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java 查看文件

@@ -61,6 +61,6 @@ public class UserDetailsServiceImpl implements UserDetailsService
61 61
 
62 62
     public UserDetails createLoginUser(SysUser user)
63 63
     {
64
-        return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
64
+        return new LoginUser(user.getUserId(),  user, permissionService.getMenuPermission(user));
65 65
     }
66 66
 }

+ 2
- 10
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java 查看文件

@@ -1,5 +1,7 @@
1 1
 package com.ruoyi.system.domain;
2 2
 
3
+import java.util.List;
4
+
3 5
 /**
4 6
  * 当前在线会话
5 7
  * 
@@ -10,8 +12,6 @@ public class SysUserOnline
10 12
     /** 会话编号 */
11 13
     private String tokenId;
12 14
 
13
-    /** 部门名称 */
14
-    private String deptName;
15 15
 
16 16
     /** 用户名称 */
17 17
     private String userName;
@@ -41,15 +41,7 @@ public class SysUserOnline
41 41
         this.tokenId = tokenId;
42 42
     }
43 43
 
44
-    public String getDeptName()
45
-    {
46
-        return deptName;
47
-    }
48 44
 
49
-    public void setDeptName(String deptName)
50
-    {
51
-        this.deptName = deptName;
52
-    }
53 45
 
54 46
     public String getUserName()
55 47
     {

+ 11
- 2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java 查看文件

@@ -1,8 +1,9 @@
1 1
 package com.ruoyi.system.mapper;
2 2
 
3
-import java.util.List;
4
-import org.apache.ibatis.annotations.Param;
5 3
 import com.ruoyi.common.core.domain.entity.SysDept;
4
+import org.apache.ibatis.annotations.Param;
5
+
6
+import java.util.List;
6 7
 
7 8
 /**
8 9
  * 部门管理 数据层
@@ -124,4 +125,12 @@ public interface SysDeptMapper
124 125
      * @return
125 126
      */
126 127
     int batchSave(@Param("list")List<SysDept> sysDepts);
128
+
129
+    /**
130
+     * 根据用户id查询部门信息
131
+     * @param userId
132
+     * @return
133
+     */
134
+
135
+    List<SysDept> selectDeptByUserId(Long userId);
127 136
 }

+ 2
- 3
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserDeptMapper.java 查看文件

@@ -18,7 +18,7 @@ public interface SysUserDeptMapper
18 18
      * @param userId 用户ID
19 19
      * @return 用户对象信息
20 20
      */
21
-    public List<SysUserDept> selectUserById(Long userId);
21
+    public List<SysUserDept> selectUserDeptById(Long userId);
22 22
 
23 23
     /**
24 24
      * 新增
@@ -41,7 +41,7 @@ public interface SysUserDeptMapper
41 41
      * @param userId 用户ID
42 42
      * @return 结果
43 43
      */
44
-    public int deleteUserById(@Param("userId)") Long userId);
44
+    public int deleteUserById(Long userId);
45 45
 
46 46
     /**
47 47
      * 批量删除
@@ -50,5 +50,4 @@ public interface SysUserDeptMapper
50 50
      * @return 结果
51 51
      */
52 52
     public int deleteUserByIds(@Param("ids") Long[] userIds);
53
-
54 53
 }

+ 0
- 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java 查看文件

@@ -87,10 +87,6 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
87 87
         sysUserOnline.setBrowser(user.getBrowser());
88 88
         sysUserOnline.setOs(user.getOs());
89 89
         sysUserOnline.setLoginTime(user.getLoginTime());
90
-        if (StringUtils.isNotNull(user.getUser().getDept()))
91
-        {
92
-            sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
93
-        }
94 90
         return sysUserOnline;
95 91
     }
96 92
 }

+ 31
- 43
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java 查看文件

@@ -1,11 +1,12 @@
1 1
 package com.ruoyi.system.service.impl;
2 2
 
3
+import cn.hutool.core.collection.CollectionUtil;
3 4
 import com.ruoyi.common.annotation.DataScope;
4 5
 import com.ruoyi.common.constant.UserConstants;
5 6
 import com.ruoyi.common.core.domain.AjaxResult;
6
-import com.ruoyi.common.core.domain.entity.SysDept;
7 7
 import com.ruoyi.common.core.domain.entity.SysRole;
8 8
 import com.ruoyi.common.core.domain.entity.SysUser;
9
+import com.ruoyi.common.core.domain.entity.SysUserDept;
9 10
 import com.ruoyi.common.exception.ServiceException;
10 11
 import com.ruoyi.common.utils.SecurityUtils;
11 12
 import com.ruoyi.common.utils.StringUtils;
@@ -26,7 +27,6 @@ import org.springframework.util.CollectionUtils;
26 27
 
27 28
 import javax.validation.Validator;
28 29
 import java.util.ArrayList;
29
-import java.util.Arrays;
30 30
 import java.util.List;
31 31
 import java.util.stream.Collectors;
32 32
 
@@ -53,6 +53,8 @@ public class SysUserServiceImpl implements ISysUserService {
53 53
 
54 54
     @Autowired
55 55
     private SysUserRoleMapper userRoleMapper;
56
+    @Autowired
57
+    private SysUserDeptMapper userDeptMapper;
56 58
 
57 59
     @Autowired
58 60
     private SysUserPostMapper userPostMapper;
@@ -238,28 +240,21 @@ public class SysUserServiceImpl implements ISysUserService {
238 240
     @Override
239 241
     @Transactional
240 242
     public AjaxResult insertUser(SysUser user) {
241
-        Long deptId = user.getDeptId();
242
-        Long[] postIds = user.getPostIds();
243
-        if (deptId != null) {
244
-            SysDept dept = sysDeptMapper.selectDeptById(deptId);
245
-            Integer deptType = dept.getDeptType();
246
-            if (deptType!=null && deptType.intValue() == 1) {
247
-                SysPost sysPost = postMapper.selectPostByPostCode("jbr");
248
-                Long postId = sysPost.getPostId();
249
-                if (postIds.length > 0) {
250
-                    boolean isContain = Arrays.asList(postIds).contains(postId);
251
-                    if (isContain) {
252
-                        List<SysUser> sysUsers = userMapper.selectUserByDeptId(deptId);
253
-                        if (sysUsers != null && sysUsers.size() > 0) {
254
-                            return AjaxResult.error("部门类型为仲裁机构的部门的岗位为经办人的用户只能有一个!");
255
-                        }
256
-                    }
257
-                }
258
-            }
259
-        }
260
-
261 243
         // 新增用户信息
262 244
         int rows = userMapper.insertUser(user);
245
+        // 新增用户部门关联
246
+        if(CollectionUtil.isNotEmpty(user.getDeptIds())) {
247
+            // 先删除用户与部门关联
248
+            userDeptMapper.deleteUserById(user.getUserId());
249
+            List<SysUserDept> userDepts = new ArrayList<>();
250
+            for (Long userDeptId : user.getDeptIds()) {
251
+                SysUserDept userDept = new SysUserDept();
252
+                userDept.setUserId(user.getUserId());
253
+                userDept.setDeptId(userDeptId);
254
+                userDepts.add(userDept);
255
+            }
256
+            userDeptMapper.batchSave(userDepts);
257
+        }
263 258
         // 新增用户岗位关联
264 259
         insertUserPost(user);
265 260
         // 新增用户与角色管理
@@ -287,29 +282,20 @@ public class SysUserServiceImpl implements ISysUserService {
287 282
     @Override
288 283
     @Transactional
289 284
     public AjaxResult updateUser(SysUser user) {
290
-        Long deptId = user.getDeptId();
291
-        Long[] postIds = user.getPostIds();
292
-        if (deptId != null) {
293
-            SysDept dept = sysDeptMapper.selectDeptById(deptId);
294
-            Integer deptType = dept.getDeptType();
295
-            if (deptType != null && deptType.intValue() == 1) {
296
-                SysPost sysPost = postMapper.selectPostByPostCode("jbr");
297
-                if(sysPost!=null) {
298
-                    Long postId = sysPost.getPostId();
299
-                    if (postId!=null&&postIds.length > 0) {
300
-                        boolean isContain = Arrays.asList(postIds).contains(postId);
301
-                        if (isContain) {
302
-                            List<SysUser> sysUsers = userMapper.selectUserByDeptId(deptId);
303
-                            if (sysUsers != null && sysUsers.size() > 0) {
304
-                                return AjaxResult.error("部门类型为仲裁机构的部门的岗位为经办人的用户只能有一个!");
305
-                            }
306
-                        }
307
-                    }
308
-                }
285
+        Long userId = user.getUserId();
286
+        // 新增用户部门关联
287
+        if(CollectionUtil.isNotEmpty(user.getDeptIds())) {
288
+            // 先删除用户与部门关联
289
+            userDeptMapper.deleteUserById(user.getUserId());
290
+            List<SysUserDept> userDepts = new ArrayList<>();
291
+            for (Long userDeptId : user.getDeptIds()) {
292
+                SysUserDept userDept = new SysUserDept();
293
+                userDept.setUserId(user.getUserId());
294
+                userDept.setDeptId(userDeptId);
295
+                userDepts.add(userDept);
309 296
             }
297
+            userDeptMapper.batchSave(userDepts);
310 298
         }
311
-
312
-        Long userId = user.getUserId();
313 299
         // 删除用户与角色关联
314 300
         userRoleMapper.deleteUserRoleByUserId(userId);
315 301
         // 新增用户与角色管理
@@ -474,6 +460,8 @@ public class SysUserServiceImpl implements ISysUserService {
474 460
         userRoleMapper.deleteUserRole(userIds);
475 461
         // 删除用户与岗位关联
476 462
         userPostMapper.deleteUserPost(userIds);
463
+        // 删除用户部门关联
464
+        userDeptMapper.deleteUserByIds(userIds);
477 465
         return userMapper.deleteUserByIds(userIds);
478 466
     }
479 467
 

+ 10
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java 查看文件

@@ -44,6 +44,16 @@ public class MsCaseAffiliate {
44 44
      */
45 45
     @Column(name = "code")
46 46
     private String code;
47
+    /**
48
+     * 申请人联系电话
49
+     */
50
+    @Column(name = "application_phone")
51
+    private String applicationPhone;
52
+    /**
53
+     * 申请人邮箱
54
+     */
55
+    @Column(name = "application_email")
56
+    private String applicationEmail;
47 57
 
48 58
     /**
49 59
      * 法定代表人

+ 3
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseMediator.java 查看文件

@@ -8,6 +8,7 @@ import javax.persistence.Column;
8 8
 import javax.persistence.GeneratedValue;
9 9
 import javax.persistence.Id;
10 10
 import javax.persistence.Table;
11
+import java.io.Serializable;
11 12
 
12 13
 /**
13 14
  * 案件预约表
@@ -16,7 +17,8 @@ import javax.persistence.Table;
16 17
 @Setter
17 18
 @ToString
18 19
 @Table(name = "ms_case_mediator")
19
-public class MsCaseMediator {
20
+public class MsCaseMediator implements Serializable {
21
+    private static final long serialVersionUID = 1L;
20 22
     @Id
21 23
     @GeneratedValue(generator = "JDBC")
22 24
     private Long id;

+ 0
- 5
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/BookingVO.java 查看文件

@@ -1,6 +1,5 @@
1 1
 package com.ruoyi.wisdomarbitrate.domain.vo.mscase;
2 2
 
3
-import com.ruoyi.common.core.domain.entity.SysUser;
4 3
 import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseMediator;
5 4
 import lombok.Data;
6 5
 
@@ -15,10 +14,6 @@ import java.util.List;
15 14
  */
16 15
 @Data
17 16
 public class BookingVO {
18
-    /**
19
-     * 申请人调解员列表
20
-     */
21
-    private List<SysUser> userList;
22 17
     /**
23 18
      * 申请人调解员列表
24 19
      */

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java 查看文件

@@ -1,9 +1,12 @@
1 1
 package com.ruoyi.wisdomarbitrate.domain.vo.mscase;
2 2
 
3
+import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach;
3 4
 import lombok.AllArgsConstructor;
4 5
 import lombok.Data;
5 6
 import lombok.NoArgsConstructor;
6 7
 
8
+import java.util.List;
9
+
7 10
 @NoArgsConstructor
8 11
 @AllArgsConstructor
9 12
 @Data
@@ -80,5 +83,9 @@ public class MsCaseApplicationReq {
80 83
      * 是否小程序,1-是
81 84
      */
82 85
     private Integer miniProgressFlag ;
86
+    /**
87
+     * 附件
88
+     */
89
+    private List<MsCaseAttach> attachList;
83 90
 
84 91
 }

+ 0
- 10
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java 查看文件

@@ -51,10 +51,6 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
51 51
             "</if> " +
52 52
             "<if test=\"req.caseNum != null and req.caseNum != ''\">" +
53 53
             "    AND c.case_num = #{req.caseNum} " +
54
-            "</if> " +
55
-
56
-            "<if test=\"req.applicantFlag != null \">" +
57
-            "    AND a.application_id = #{req.applicationId} " +
58 54
             "</if> "
59 55
             + "<if test=\"req.respondentIdentityNum != null and req.respondentIdentityNum != ''\">" +
60 56
             "    AND a.respondent_identity_num = #{req.respondentIdentityNum} " +
@@ -90,9 +86,6 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
90 86
             "</if> " +
91 87
             "<if test=\"req.caseNum != null and req.caseNum != ''\">" +
92 88
             "    AND c1.case_num = #{req.caseNum} " +
93
-            "</if> " +
94
-            "<if test=\"req.applicantFlag != null \">" +
95
-            "    AND a1.application_id = #{req.applicationId} " +
96 89
             "</if> "
97 90
             + "<if test=\"req.respondentIdentityNum != null and req.respondentIdentityNum != ''\">" +
98 91
             "    AND a1.respondent_identity_num = #{req.respondentIdentityNum} " +
@@ -124,9 +117,6 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
124 117
             "</if> " +
125 118
             "<if test=\"req.caseNum != null and req.caseNum != ''\">" +
126 119
             "    AND c.case_num = #{req.caseNum} " +
127
-            "</if> " +
128
-            "<if test=\"req.applicantFlag != null \">" +
129
-            "    AND a.application_id = #{req.applicationId} " +
130 120
             "</if> "
131 121
             + "<if test=\"req.respondentIdentityNum != null and req.respondentIdentityNum != ''\">" +
132 122
             "    AND a.respondent_identity_num = #{req.respondentIdentityNum} " +

+ 2
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/dept/impl/DeptIdentifyServiceImpl.java 查看文件

@@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
12 12
 import com.ruoyi.common.core.domain.entity.SysDept;
13 13
 import com.ruoyi.common.core.domain.entity.SysDictData;
14 14
 import com.ruoyi.common.core.domain.entity.SysUser;
15
+import com.ruoyi.common.enums.AnnexTypeEnum;
15 16
 import com.ruoyi.common.exception.EsignDemoException;
16 17
 import com.ruoyi.common.exception.ServiceException;
17 18
 import com.ruoyi.common.utils.SealUtil;
@@ -248,7 +249,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
248 249
                             boolean downLoadFile = FileTransformation.downLoadFileByUrl(sealImageDownloadUrl, resultFilePath);
249 250
                             if (downLoadFile) {
250 251
                                 MsCaseAttach caseAttach = new MsCaseAttach();
251
-                                caseAttach.setAnnexType(10);  //10代表印章图片
252
+                                caseAttach.setAnnexType(AnnexTypeEnum.SEAL_PICTURE.getCode());  //10代表印章图片
252 253
                                 caseAttach.setAnnexPath(savePath);
253 254
                                 caseAttach.setAnnexName(saveName);
254 255
                                 int i1 = msCaseAttachMapper.save(caseAttach);

+ 37
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java 查看文件

@@ -1,6 +1,7 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.mscase;
2 2
 
3 3
 import com.ruoyi.common.core.domain.AjaxResult;
4
+import com.ruoyi.common.core.domain.entity.SysDictData;
4 5
 import com.ruoyi.common.exception.EsignDemoException;
5 6
 import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
6 7
 import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate;
@@ -13,6 +14,7 @@ import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseAttachVO;
13 14
 import org.springframework.web.multipart.MultipartFile;
14 15
 
15 16
 import java.util.List;
17
+import java.util.Map;
16 18
 
17 19
 /**
18 20
  * @Classname MsCaseApplicationService
@@ -42,6 +44,13 @@ public interface MsCaseApplicationService {
42 44
      * @return
43 45
      */
44 46
     int insert(MsCaseApplicationVO caseApplication);
47
+    /**
48
+     * 新增用户
49
+     * @param affiliate
50
+     * @param agentFlag 是否代理人,0-否,1-是
51
+     * @param roleId
52
+     */
53
+     void insertApplicantUser( MsCaseAffiliate affiliate,boolean agentFlag, Long roleId);
45 54
     /**
46 55
      * 新增申请机构代理人
47 56
      * @param affiliate
@@ -165,4 +174,32 @@ public interface MsCaseApplicationService {
165 174
      */
166 175
 
167 176
     AjaxResult confirmMediation(MsCaseAttachVO attach) throws EsignDemoException, InterruptedException ;
177
+    /**
178
+     * 生成调解申请书
179
+     * @param application 案件基本信息
180
+     * @param affiliate 案件相关人员
181
+     * @param templatePath 模板路径
182
+     * @param bookmarkList 标签
183
+     * @param dictDataList 内置字段
184
+     */
185
+     void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList, Integer templateType) ;
186
+    /**
187
+     * 案件受理
188
+     * @param application
189
+     * @param req
190
+     * @param affiliateMap
191
+     */
192
+     void accept(MsCaseApplication application, MsCaseApplication req, Map<Long, MsCaseAffiliate> affiliateMap) ;
193
+    /**
194
+     * 判断申请人/被申请人是否预约
195
+     * @param vo
196
+     * @param userIds 选择的调解员ids
197
+     */
198
+    void isReservation( BookingVO vo,  List<Long> userIds );
199
+    /**
200
+     * 核实调解员
201
+     * @param
202
+     * @return
203
+     */
204
+     void verifyMediator(MsCaseApplication application,BookingVO vo);
168 205
 }

+ 266
- 203
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java 查看文件

@@ -83,6 +83,8 @@ import static com.ruoyi.common.utils.SecurityUtils.getUsername;
83 83
  */
84 84
 @Service
85 85
 public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
86
+    @Autowired
87
+    MsCaseApplicationService caseApplicationService;
86 88
     @Autowired
87 89
     MsCaseApplicationMapper msCaseApplicationMapper;
88 90
     @Autowired
@@ -110,6 +112,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
110 112
     @Autowired
111 113
     SysUserMapper userMapper;
112 114
     @Autowired
115
+    SysUserDeptMapper userDeptMapper;
116
+    @Autowired
113 117
     SysUserRoleMapper userRoleMapper;
114 118
     @Autowired
115 119
     FatchRuleMapper fatchRuleMapper;
@@ -181,9 +185,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
181 185
         List<String> caseStatusNames = caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList());
182 186
         for (SysRole role : roles) {
183 187
             if(StrUtil.isNotEmpty(role.getRoleName())&&StrUtil.equals(role.getRoleName(),"申请人")){
184
-                if(sysUser.getDeptId()!=null) {
185
-                    req.setApplicationOrganId(String.valueOf(sysUser.getDeptId()));
186
-                }
187 188
                 req.setApplicantFlag(1);
188 189
                 break;
189 190
 
@@ -244,6 +245,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
244 245
         if (caseApplication.getId() == null) {
245 246
             caseApplication.setId(IdWorkerUtil.getId());
246 247
         }
248
+
247 249
         // 根据角色获取案件流程
248 250
         List<MsCaseFlow> caseFlows=  selectCaseFlows();
249 251
         if (CollectionUtil.isEmpty(caseFlows)) {
@@ -265,20 +267,25 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
265 267
         caseApplication.setUpdateBy(SecurityUtils.getUsername());
266 268
         caseApplication.setVersion(1);
267 269
         MsCaseAffiliate affiliate = caseApplication.getAffiliate();
270
+        affiliate.setCaseAppliId(caseApplication.getId());
268 271
         // 保存案件基本信息
269 272
         if (msCaseApplicationMapper.insertSelective(caseApplication) > 0) {
270 273
             List<MsCaseAttach> caseAttachList = caseApplication.getCaseAttachList();
271 274
             // 保存案件相关人员
272
-            if (affiliate != null) {
273 275
                 // 设置申请机构
274 276
                 if (StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==1) {
275 277
                     // 组装申请机构
276
-                    insertDept(affiliate);
277
-                    // 新增申请机构代理人
278
-                    insertAgentUser(affiliate);
278
+                   // insertDept(affiliate);
279
+                    // 新增申请机构代理人
280
+                    caseApplicationService.insertAgentUser(affiliate);
279 281
                 }else if(StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==0){
280
-                    // 申请人为自然人
281
-                    //
282
+                    // todo 申请人为自然人,如果系统不存在申请人和代理人用户,分别新增用户,新增完用户需要发送短信
283
+                    // 查询申请人角色id
284
+                    Long roleId = roleMapper.selectRoleIdByName("申请人");
285
+                    caseApplicationService.insertApplicantUser(affiliate,false,roleId);
286
+                    caseApplicationService.insertApplicantUser(affiliate,true,roleId);
287
+
288
+
282 289
                 }
283 290
                 // 压缩包导入,则根据身份证号获取性别和出生日期
284 291
                 String identityNum = affiliate.getRespondentIdentityNum();
@@ -286,18 +293,20 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
286 293
 
287 294
                     identityNum = identityNum.replace("\n", "");
288 295
                     Map<String, String> identityNumMap = IdCardUtils.getBirAgeSex(identityNum);
289
-                    String birthday = identityNumMap.get("birthday");
290
-                    if (StrUtil.isNotEmpty(birthday)) {
291
-                        Date birthdayDate = null;
292
-                        try {
293
-                            birthdayDate = yyyymmddFormat.parse(birthday);
294
-                        } catch (Exception e) {
295
-                            e.printStackTrace();
296
+                    if (identityNumMap != null) {
297
+                        String birthday = identityNumMap.get("birthday");
298
+                        if (StrUtil.isNotEmpty(birthday)) {
299
+                            Date birthdayDate = null;
300
+                            try {
301
+                                birthdayDate = yyyymmddFormat.parse(birthday);
302
+                            } catch (Exception e) {
303
+                                e.printStackTrace();
304
+                            }
305
+                            affiliate.setRespondentBirth(birthdayDate);
296 306
                         }
297
-                        affiliate.setRespondentBirth(birthdayDate);
307
+                        //从身份证抓取性别
308
+                        affiliate.setRespondentSex(identityNumMap.get("sexCode"));
298 309
                     }
299
-                    //从身份证抓取性别
300
-                    affiliate.setRespondentSex(identityNumMap.get("sexCode"));
301 310
                 }
302 311
                 if (StrUtil.isNotEmpty(affiliate.getAgentEmail())) {
303 312
                     affiliate.setAgentEmail(affiliate.getAgentEmail().replace("\n", "").replaceAll("\\s", ""));
@@ -305,7 +314,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
305 314
                 if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
306 315
                     affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
307 316
                 }
308
-                affiliate.setCaseAppliId(caseApplication.getId());
317
+
309 318
                 msCaseAffiliateMapper.insert(affiliate);
310 319
                 // 查询调解申请书模板id
311 320
                 TemplateManage templateManage=templateManageMapper.selectByType(2);
@@ -321,10 +330,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
321 330
                     }
322 331
                     // 生成调解申请书
323 332
                         req.setTemplateId(String.valueOf(templateManage.getId()));
324
-                        generateApplication(req);
333
+                    // todo 部署放开
334
+                   // caseApplicationService.generateApplication(req);
325 335
 
326 336
                 }
327
-            }
337
+
328 338
             // 保存案件附件
329 339
 
330 340
             if (CollectionUtil.isNotEmpty(caseAttachList)) {
@@ -354,6 +364,65 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
354 364
         return 0;
355 365
     }
356 366
 
367
+    /**
368
+     * 新增用户
369
+     * @param affiliate
370
+     * @param agentFlag 是否代理人,0-否,1-是
371
+     * @param roleId
372
+     */
373
+    @Transactional
374
+    public void insertApplicantUser( MsCaseAffiliate affiliate,boolean agentFlag, Long roleId) {
375
+        String phone="";
376
+        String name="";
377
+        if(agentFlag){
378
+            // 代理人
379
+            phone=affiliate.getContactTelphoneAgent();
380
+            name=affiliate.getNameAgent();
381
+
382
+        }else {
383
+            // 申请人
384
+            phone=affiliate.getApplicationPhone();
385
+            name=affiliate.getApplicationName();
386
+        }
387
+        if(StrUtil.isNotEmpty(phone) && StrUtil.isNotEmpty(name)){
388
+            // 查询用户是否存在
389
+            SysUser   sysUser = sysUserMapper.selectUserByUserName(name);
390
+            if(sysUser==null){
391
+                // 新增用户
392
+                sysUser = new SysUser();
393
+                sysUser.setUserName(phone);
394
+                sysUser.setNickName(name);
395
+                sysUser.setPhonenumber(phone);
396
+                sysUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
397
+                sysUser.setCreateBy(SecurityUtils.getUsername());
398
+                userMapper.insertUser(sysUser);
399
+                userRoleMapper.insertUserRole(sysUser.getUserId(), roleId);
400
+                // 发送短信 2064355 调解系统自动创建用户短信通知    尊敬的用户,您的案件已经创建,请使用账号为{1},密码为{2}登录调解系统,请知晓,如非本人操作,请忽略本短信。
401
+                Boolean smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2064355", phone, new String[]{phone, "abc123456"});
402
+
403
+            }else {
404
+                // 用户不为空,查询角色是否为申请人
405
+                if (CollectionUtil.isNotEmpty(sysUser.getRoles())) {
406
+                  List<Long>  longList = sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
407
+                    if (!longList.contains(roleId)) {
408
+                        userRoleMapper.insertUserRole(sysUser.getUserId(), roleId);
409
+                    }
410
+                } else {
411
+                    userRoleMapper.insertUserRole(sysUser.getUserId(), roleId);
412
+                }
413
+
414
+            }
415
+            if(!agentFlag){
416
+                // 自然人,将用户id设为申请人id
417
+                affiliate.setApplicationId(String.valueOf(sysUser.getUserId()));
418
+                affiliate.setApplicationName(sysUser.getNickName());
419
+
420
+            }
421
+
422
+
423
+        }
424
+    }
425
+
357 426
     /**
358 427
      * 查询案件流程
359 428
      * @return
@@ -415,9 +484,19 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
415 484
             // 设置申请人
416 485
             if (StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==1) {
417 486
                 // 组装申请机构
418
-                insertDept(affiliate);
487
+               // insertDept(affiliate);
419 488
                 // 新增申请机构代理人
420
-                insertAgentUser(affiliate);
489
+                caseApplicationService.insertAgentUser(affiliate);
490
+            }else if(StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==0){
491
+                // todo 申请人为自然人,如果系统不存在申请人和代理人用户,分别新增用户,新增完用户需要发送短信
492
+                // 查询申请人角色id
493
+                Long roleId = roleMapper.selectRoleIdByName("申请人");
494
+                caseApplicationService.insertApplicantUser(affiliate,false,roleId);
495
+                caseApplicationService.insertApplicantUser(affiliate,true,roleId);
496
+
497
+            }
498
+            if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) {
499
+                affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", ""));
421 500
             }
422 501
             msCaseAffiliateMapper.updateByPrimaryKeySelective(affiliate);
423 502
         }
@@ -558,7 +637,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
558 637
                         caseApplicationVO.setCaseAttachList(attachList);
559 638
                         caseApplicationVO.setColumnValueList(columnValueList);
560 639
                         caseApplicationVO.setImportFlag(true);
561
-                        insert(caseApplicationVO);
640
+                        caseApplicationService.insert(caseApplicationVO);
562 641
                         caseCount++;
563 642
 
564 643
                     }
@@ -567,21 +646,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
567 646
 
568 647
         }
569 648
         if(caseCount>0) {
570
-
571
-//            // 查询调解申请书模板id
572
-//            TemplateManage templateManage=templateManageMapper.selectByType(2);
573
-//            if(templateManage!=null) {
574
-//                List<MsCaseFlow> caseFlows = selectCaseFlows();
575
-//                // 批量生成调解申请书
576
-//                MsCaseApplicationReq req = new MsCaseApplicationReq();
577
-//                if (CollectionUtil.isNotEmpty(caseFlows)) {
578
-//                    MsCaseFlow caseFlow = caseFlows.get(0);
579
-//                    req.setCaseFlowId(caseFlow.getId());
580
-//                    req.setBatchNumber(batchNumber);
581
-//                    req.setTemplateId(String.valueOf(templateManage.getId()));
582
-//                    generateApplication(req);
583
-//                }
584
-//            }
585 649
             return AjaxResult.success();
586 650
         }else {
587 651
             return AjaxResult.error("请检查压缩包!");
@@ -647,7 +711,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
647 711
                 if(affiliate==null){
648 712
                     continue;
649 713
                 }
650
-                createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
714
+                caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
651 715
 
652 716
             }
653 717
         }else {
@@ -660,7 +724,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
660 724
                 throw new ServiceException("该案件不存在");
661 725
             }
662 726
 
663
-            createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
727
+            caseApplicationService.createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType());
664 728
         }
665 729
 
666 730
 
@@ -690,6 +754,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
690 754
      * @param req
691 755
      * @return
692 756
      */
757
+    @Transactional
693 758
     @Override
694 759
     public AjaxResult batchUpdateAttach(MsCaseApplicationVO req) {
695 760
         for (MsCaseAttach attach : req.getCaseAttachList()) {
@@ -706,6 +771,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
706 771
      * @param id
707 772
      * @return
708 773
      */
774
+    @Transactional
709 775
     @Override
710 776
     public AjaxResult batchUpload(MultipartFile[] files, Integer annexType, Long id) {
711 777
         List<MsCaseAttach> successList = new ArrayList<>();
@@ -745,6 +811,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
745 811
      * @param req
746 812
      * @return
747 813
      */
814
+    @Transactional
748 815
     @Override
749 816
     public AjaxResult accept(MsCaseApplication req) {
750 817
         if (StrUtil.isNotEmpty(req.getBatchNumber())) {
@@ -762,7 +829,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
762 829
             }
763 830
             Map<Long, MsCaseAffiliate> affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity()));
764 831
             for (MsCaseApplication application : applicationList) {
765
-                accept(application,req,affiliateMap);
832
+                caseApplicationService.accept(application,req,affiliateMap);
766 833
             }
767 834
 
768 835
         } else {
@@ -777,7 +844,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
777 844
             application.setLockStatus(YesOrNoEnum.YES.getCode());
778 845
             Map<Long, MsCaseAffiliate> affiliateMap=new HashMap<>();
779 846
             affiliateMap.put(req.getId(),caseAffiliate);
780
-            accept(application,req,affiliateMap);
847
+            caseApplicationService.accept(application,req,affiliateMap);
781 848
         }
782 849
 
783 850
         return AjaxResult.success("受理成功");
@@ -788,7 +855,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
788 855
      * @param req
789 856
      * @param affiliateMap
790 857
      */
791
-    private void accept(MsCaseApplication application, MsCaseApplication req, Map<Long, MsCaseAffiliate> affiliateMap) {
858
+    @Transactional
859
+    public void accept(MsCaseApplication application, MsCaseApplication req, Map<Long, MsCaseAffiliate> affiliateMap) {
792 860
         application.setPaperFlag(req.getPaperFlag());
793 861
         application.setArbitrateConfirm(req.getArbitrateConfirm());
794 862
         application.setMediationMethod(req.getMediationMethod());
@@ -796,7 +864,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
796 864
         application.setUpdateTime(new Date());
797 865
         application.setBatchNumber(null);
798 866
         msCaseApplicationMapper.updateByPrimaryKeySelective(application);
799
-        MsCaseFlow caseFlow = nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus());
867
+        MsCaseFlow caseFlow = caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus());
800 868
         // 给申请人被申请人发送短信
801 869
         if (affiliateMap.containsKey(application.getId())) {
802 870
             MsCaseAffiliate affiliate = affiliateMap.get(application.getId());
@@ -846,12 +914,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
846 914
                 return AjaxResult.error("该批次号下未找到案件");
847 915
             }
848 916
             for (MsCaseApplication application : list) {
849
-                MsCaseFlow caseFlow = nextFlow(application.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
917
+                MsCaseFlow caseFlow = caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
850 918
                 // todo 发送短信
851 919
 //                CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "提交成功");
852 920
             }
853 921
         }else {
854
-            MsCaseFlow caseFlow = nextFlow(req.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
922
+            MsCaseFlow caseFlow = caseApplicationService.nextFlow(req.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode());
855 923
             // todo 发送短信
856 924
 //            CaseLogUtils.insertCaseLog(req.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), "提交成功");
857 925
 
@@ -927,13 +995,13 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
927 995
         msCaseMediatorMapper.deleteByExample(mediatorExample);
928 996
 
929 997
         // 获取选择的调解员id
930
-        List<Long> userIds = vo.getUserList().stream().map(SysUser::getUserId).collect(Collectors.toList());
998
+        List<Long> userIds = vo.getMediatorList().stream().map(MsCaseMediator::getMediatorId).collect(Collectors.toList());
931 999
         // 新增案件预约表
932
-        for (SysUser sysUser : vo.getUserList()) {
1000
+        for (MsCaseMediator sysUser : vo.getMediatorList()) {
933 1001
             MsCaseMediator mediator = new MsCaseMediator();
934 1002
             mediator.setCaseAppliId(vo.getId());
935
-            mediator.setMediatorId(sysUser.getUserId());
936
-            mediator.setMediatorName(sysUser.getNickName());
1003
+            mediator.setMediatorId(sysUser.getMediatorId());
1004
+            mediator.setMediatorName(sysUser.getMediatorName());
937 1005
             mediator.setType(miniProgressFlag);
938 1006
             msCaseMediatorMapper.insert(mediator);
939 1007
         }
@@ -946,13 +1014,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
946 1014
             if (StrUtil.isEmpty(msCaseAffiliate.getRespondentIdentityNum())) {
947 1015
                 return AjaxResult.error("被申请人身份证为空");
948 1016
             }
949
-
950
-         //   SysUser user = userMapper.selectUserByIdCard(msCaseAffiliate.getRespondentIdentityNum());
951
-            // 被申请人存在
952
-        //    if (user != null) {
953 1017
                 // 判断被申请人信息查询案件预约表
954 1018
                 isReservation( vo,userIds);
955
-         //   }
956 1019
 
957 1020
         } else {
958 1021
             // 被申请人预约
@@ -961,12 +1024,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
961 1024
             if (StrUtil.isEmpty(msCaseAffiliate.getContactTelphoneAgent())) {
962 1025
                 return AjaxResult.error("申请代理人手机号为空");
963 1026
             }
964
-
965
-         //   SysUser user = userMapper.selectUserByPhone(msCaseAffiliate.getContactTelphoneAgent());
966
-          //  if(user!=null){
967
-                // 判断申请人是否预约
968
-                isReservation( vo,userIds);
969
-         //   }
1027
+            // 判断申请人是否预约
1028
+            caseApplicationService. isReservation( vo,userIds);
970 1029
 
971 1030
         }
972 1031
         return AjaxResult.success();
@@ -977,7 +1036,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
977 1036
      * @param vo
978 1037
      * @param userIds 选择的调解员ids
979 1038
      */
980
-    private void isReservation( BookingVO vo,  List<Long> userIds ) {
1039
+    @Transactional
1040
+    public void isReservation( BookingVO vo,  List<Long> userIds ) {
981 1041
         // 查询所有调解员
982 1042
         List<SysUser> mediatorUsers = sysUserMapper.selectUserByRole("调解员");
983 1043
         if (CollectionUtil.isEmpty(mediatorUsers)) {
@@ -1055,32 +1115,13 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1055 1115
         }
1056 1116
     }
1057 1117
 
1058
-    /**
1059
-     * 设置调解员调解时间
1060
-     * @param application
1061
-     * @param vo
1062
-     */
1063
-//    private void setMediatorAndDate(MsCaseApplication application, BookingVO vo) {
1064
-//        if(CollectionUtil.isNotEmpty(vo.getUserList())) {
1065
-//            List<SysUser> userList = vo.getUserList();
1066
-//            List<Long> userIds = userList.stream().map(SysUser::getUserId).collect(Collectors.toList());
1067
-//            List<String> userNames = userList.stream().map(SysUser::getUserName).collect(Collectors.toList());
1068
-//            String mediatorIds = StrUtil.join(",", userIds);
1069
-//            String mediatorNames = StrUtil.join(",", userNames);
1070
-//            application.setMediatorId(mediatorIds);
1071
-//            application.setMediatorName(mediatorNames);
1072
-//        }
1073
-//        if(CollectionUtil.isNotEmpty( vo.getHerDates())) {
1074
-//            String herDates = StrUtil.join(",", vo.getHerDates());
1075
-//            application.setHearDate(herDates);
1076
-//        }
1077
-//    }
1078 1118
 
1079 1119
     /**
1080 1120
      * 核实调解员
1081 1121
      * @param vo
1082 1122
      * @return
1083 1123
      */
1124
+    @Transactional
1084 1125
     @Override
1085 1126
     public AjaxResult verifyMediator(BookingVO vo) {
1086 1127
         if(StrUtil.isNotEmpty(vo.getBatchNumber())){
@@ -1099,12 +1140,39 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1099 1140
         }
1100 1141
         return AjaxResult.success();
1101 1142
     }
1143
+    /**
1144
+     * 核实调解员
1145
+     * @param
1146
+     * @return
1147
+     */
1148
+    @Transactional
1149
+    public void verifyMediator(MsCaseApplication application,BookingVO vo) {
1150
+        MsCaseFlow nextFlow = caseFlowMapper.nextFlow(vo.getCaseFlowId());
1151
+        if (nextFlow == null) {
1152
+            throw new ServiceException("未找到下一个流程节点");
1153
+        }
1154
+        if(vo.getMediatorId()!=null) {
1155
+            //   setMediatorAndDate(application,vo);
1156
+            application.setMediatorId(vo.getMediatorId());
1157
+            application.setMediatorName(vo.getMediatorName());
1158
+        }
1159
+        if(CollectionUtil.isNotEmpty(vo.getHerDates())){
1160
+            application.setHearDate(vo.getHerDates().get(0));
1161
+        }
1162
+        application.setCaseFlowId(nextFlow.getNodeId());
1163
+        application.setCaseStatusName(nextFlow.getCaseStatusName());
1164
+        msCaseApplicationMapper.updateByPrimaryKeySelective(application);
1165
+        // todo 发送短信
1166
+        // 新增日志
1167
+        CaseLogUtils.insertCaseLog(application.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(), "");
1102 1168
 
1169
+    }
1103 1170
     /**
1104 1171
      * 查询预约信息
1105 1172
      * @param id
1106 1173
      * @return
1107 1174
      */
1175
+    @Transactional
1108 1176
     @Override
1109 1177
     public AjaxResult selectReservation(Long id) {
1110 1178
         // 查询案件主表
@@ -1122,43 +1190,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1122 1190
             return AjaxResult.success(result);
1123 1191
         }
1124 1192
         Map<Integer, List<MsCaseMediator>> mediatorMap = msCaseMediators.stream().collect(Collectors.groupingBy(MsCaseMediator::getType));
1125
-        // 申请人
1193
+        // todo 申请人
1126 1194
         result.setMediatorList(mediatorMap.get(MediatorTypeEnum.PC.getCode()));
1127 1195
         result.setResMediatorList(mediatorMap.get(MediatorTypeEnum.MI_NI_PROGRESS.getCode()));
1128
-
1129
-            // 查询用户
1130
-//            SysUser user = userMapper.selectUserById(Long.valueOf(msCaseMediator.getMediatorId()));
1131
-//            if(user==null){
1132
-//                return AjaxResult.error("调解员已被删除");
1133
-//            }
1134
-//            // 查询待办数量
1135
-//            List<Long> mediatorIds = new ArrayList<>();
1136
-//            mediatorIds.add(user.getUserId());
1137
-//            Map<Long, List<MsCaseApplication>> caseMap=null;
1138
-//            List<MsCaseApplication> caseApplicationList = msCaseApplicationMapper.listMediator(mediatorIds);
1139
-//            if (CollectionUtil.isNotEmpty(caseApplicationList)) {
1140
-//                caseMap = caseApplicationList.stream().collect(Collectors.groupingBy(MsCaseApplication::getMediatorId, Collectors.toList()));
1141
-//
1142
-//            }
1143
-//            MediatorVO mediatorVO = new MediatorVO();
1144
-//            mediatorVO.setMediatorId(user.getUserId());
1145
-//            mediatorVO.setMediatorName(user.getNickName());
1146
-//            mediatorVO.setSpecialty(user.getSpecialty());
1147
-//            if(caseMap==null){
1148
-//                mediatorVO.setTodoAmount(0L);
1149
-//                mediatorVO.setCompleteAmount(0L);
1150
-//            }
1151
-//
1152
-//            else if(caseMap.containsKey(String.valueOf(user.getUserId()))) {
1153
-//                List<MsCaseApplication> applications = caseMap.get(String.valueOf(user.getUserId()));
1154
-//                // 已办案件
1155
-//                long count = applications.stream().filter(caseApplication -> !caseApplication.getCaseStatusName().equals("结束")).count();
1156
-//                mediatorVO.setTodoAmount(applications.size()-count);
1157
-//                mediatorVO.setCompleteAmount(count);
1158
-//            }
1159
-
1160
-
1161
-
1162 1196
         return AjaxResult.success(result);
1163 1197
     }
1164 1198
 
@@ -1170,36 +1204,50 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1170 1204
     @Transactional
1171 1205
     @Override
1172 1206
     public AjaxResult mediation(MsCaseApplicationReq req) {
1173
-        String templateId=null;
1174
-        // 批量
1175
-        if(StrUtil.isNotEmpty(req.getBatchNumber())){
1176
-            // 查询调解书模板是否存在
1177
-            Example example = new Example(MsCaseApplication.class);
1178
-            Example.Criteria criteria = example.createCriteria();
1179
-            criteria.andEqualTo("batchNumber", req.getBatchNumber());
1180
-            criteria.andIsNotNull("templateId");
1181
-            MsCaseApplication caseApplication = msCaseApplicationMapper.selectOneByExample(example);
1182
-            if(caseApplication==null||caseApplication.getTemplateId()==null){
1207
+        // 查询案件是否存在
1208
+        MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId());
1209
+        if (application == null) {
1210
+            return AjaxResult.error("未找到案件");
1211
+        }
1212
+        if (StrUtil.isEmpty(application.getMediationMethod())) {
1213
+            return AjaxResult.error("未选择调解方式");
1214
+        }
1215
+        if (application.getMediationMethod().equals("1")) {
1216
+            // 线上调解
1217
+            if (application.getTemplateId() == null) {
1183 1218
                 return AjaxResult.error("未找到模板");
1184 1219
             }
1185
-            templateId= String.valueOf(caseApplication.getTemplateId());
1186
-
1187
-        }else {
1188
-            // 单独生成
1189
-            // 查询调解书模板是否存在
1190
-            MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId());
1191
-            if(application==null||application.getTemplateId()==null){
1192
-                return AjaxResult.error("未找到模板");
1220
+            String templateId = String.valueOf(application.getTemplateId());
1221
+            req.setTemplateId(templateId);
1222
+            req.setTemplateType(1);
1223
+            AjaxResult result = generateApplication(req);
1224
+            if (result != null && result.isSuccess()) {
1225
+                return result;
1193 1226
             }
1194
-            templateId= String.valueOf(application.getTemplateId());
1195
-        }
1196
-        req.setTemplateId(templateId);
1197
-        req.setTemplateType(1);
1198
-        AjaxResult result = generateApplication(req);
1199
-        if(result!=null && result.isSuccess()){
1200
-            return result;
1227
+        } else {
1228
+            // 线下调解
1229
+            List<MsCaseAttach> attachList = req.getAttachList();
1230
+            if(CollectionUtil.isEmpty(attachList)){
1231
+                return AjaxResult.error("请上传调解资料");
1232
+            }
1233
+            for (MsCaseAttach attach : attachList) {
1234
+                attach.setCaseAppliId(req.getId());
1235
+            }
1236
+            msCaseAttachMapper.batchSave(attachList);
1237
+            // 修改案件状态为待送达
1238
+            Example flowExample = new Example(MsCaseFlow.class);
1239
+            flowExample.createCriteria().andEqualTo("caseStatusName", "待送达");
1240
+            MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample);
1241
+            if(caseFlow != null){
1242
+                application.setCaseFlowId(caseFlow.getId());
1243
+                application.setCaseStatusName(caseFlow.getCaseStatusName());
1244
+                msCaseApplicationMapper.updateByPrimaryKey(application);
1245
+            }
1246
+            return AjaxResult.success();
1201 1247
         }
1202
-        return AjaxResult.error("生成失败");
1248
+
1249
+
1250
+        return AjaxResult.error();
1203 1251
     }
1204 1252
 
1205 1253
     /**
@@ -1232,7 +1280,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1232 1280
         }
1233 1281
         // todo 发送短信
1234 1282
         // 更新流程节点
1235
-        nextFlow(attach.getCaseAppliId(),attach.getCaseFlowId(),YesOrNoEnum.YES.getCode());
1283
+        caseApplicationService.nextFlow(attach.getCaseAppliId(),attach.getCaseFlowId(),YesOrNoEnum.YES.getCode());
1236 1284
 
1237 1285
         Long id = attach.getCaseAppliId();
1238 1286
         MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id);
@@ -1901,29 +1949,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1901 1949
     }
1902 1950
 
1903 1951
 
1904
-    /**
1905
-     * 核实调解员
1906
-     * @param
1907
-     * @return
1908
-     */
1909
-    private void verifyMediator(MsCaseApplication application,BookingVO vo) {
1910
-        MsCaseFlow nextFlow = caseFlowMapper.nextFlow(vo.getCaseFlowId());
1911
-        if (nextFlow == null) {
1912
-            throw new ServiceException("未找到下一个流程节点");
1913
-        }
1914
-     //   setMediatorAndDate(application,vo);
1915
-        application.setMediatorId(vo.getMediatorId());
1916
-        application.setMediatorName(vo.getMediatorName());
1917
-        application.setCaseFlowId(nextFlow.getNodeId());
1918
-        application.setCaseStatusName(nextFlow.getCaseStatusName());
1919
-        msCaseApplicationMapper.updateByPrimaryKeySelective(application);
1920
-        // todo 发送短信
1921
-        // 新增日志
1922
-        CaseLogUtils.insertCaseLog(application.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(), "");
1923
-
1924
-    }
1925
-
1926
-
1927 1952
 
1928 1953
     /**
1929 1954
      * 流向下一个流程节点
@@ -1932,6 +1957,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1932 1957
      * @param lockStatus '是否锁定,0-否,1-是',单独操作案件时需要锁定
1933 1958
      * @return
1934 1959
      */
1960
+    @Transactional
1935 1961
     @Override
1936 1962
     public MsCaseFlow nextFlow(Long caseId,Integer caseFlowId,Integer lockStatus) {
1937 1963
         // 查询当前流程节点
@@ -1964,7 +1990,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
1964 1990
      * @param bookmarkList 标签
1965 1991
      * @param dictDataList 内置字段
1966 1992
      */
1967
-    private void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList,Integer templateType) {
1993
+    @Transactional
1994
+    public void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List<String> bookmarkList, List<SysDictData> dictDataList,Integer templateType) {
1968 1995
         // 申请书需要的字段和内容,valueMap<占位符,替换的值>
1969 1996
         Map<String, String> valueMap = new HashMap<>();
1970 1997
         for (SysDictData dictData : dictDataList) {
@@ -2018,7 +2045,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2018 2045
         msCaseAttachMapper.save(caseAttach);
2019 2046
         // 生成调解书成功,需要更新流程节点
2020 2047
         if (templateType!=null&&templateType==1) {
2021
-            nextFlow(application.getId(), application.getCaseFlowId(), application.getLockStatus());
2048
+            caseApplicationService.nextFlow(application.getId(), application.getCaseFlowId(), application.getLockStatus());
2022 2049
             // todo 发送短信
2023 2050
         }
2024 2051
     }
@@ -2086,16 +2113,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2086 2113
                 continue;
2087 2114
             }
2088 2115
             // 上传
2089
-            //  String filePath = RuoYiConfig.getUploadPath();
2090 2116
             MsCaseAttach caseAttach = new MsCaseAttach();
2091 2117
             caseAttach.setCaseAppliId(caseApplication.getId());
2092 2118
             caseAttach.setAnnexPath(fileUrl.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX));
2093 2119
             caseAttach.setAnnexName(entry.getKey());
2094
-            // todo
2095
-//                                    if (StrUtil.isNotEmpty(fileUrl)) {
2096
-//                                        String fileName = fileUrl.replace(filePath, "/profile/upload");
2097
-//                                        caseAttach.setAnnexName(entry.getKey());
2098
-//                                    }
2099 2120
             // 申请人提供的证据材料
2100 2121
             caseAttach.setAnnexType(AnnexTypeEnum.APPLICATION_EVIDENCE.getCode());
2101 2122
             attachList.add(caseAttach);
@@ -2263,37 +2284,79 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2263 2284
             agentUser.setNickName(affiliate.getNameAgent());
2264 2285
             agentUser.setPhonenumber(affiliate.getContactTelphoneAgent());
2265 2286
             agentUser.setPassword(SecurityUtils.encryptPassword("abc123456"));
2266
-            agentUser.setDeptId(Long.valueOf(affiliate.getApplicationId()));
2287
+         //   agentUser.setDeptId(Long.valueOf(affiliate.getApplicationId()));
2267 2288
             userMapper.insertUser(agentUser);
2268 2289
             userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
2269 2290
             // 新增部门用户关联表
2270
-//            sysUserMapper.insertUser()
2271
-        } else if (null == agentUser.getDeptId() ) {
2272
-            // todo 未关联部门,关联部门
2273
-            agentUser.setDeptId(Long.valueOf(affiliate.getApplicationId()));
2274
-            userMapper.updateUser(agentUser);
2275
-        }else if (null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationId())) {
2276
-            if (null != agentUser.getDept() && StrUtil.isNotEmpty(agentUser.getDept().getDeptName())) {
2277
-                throw new ServiceException("该申请代理人已在【" + agentUser.getDept().getDeptName() + "】申请机构下存在,请检查填写信息是否正确");
2278
-            } else {
2279
-                throw new ServiceException("该申请代理人已存在,与申请机构不匹配,请检查填写信息是否正确");
2291
+            SysUserDept sysUserDept = new SysUserDept();
2292
+            sysUserDept.setUserId(agentUser.getUserId());
2293
+            sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId()));
2294
+            userDeptMapper.insert(sysUserDept);
2295
+            // 发送短信 2064355 调解系统自动创建用户短信通知    尊敬的用户,您的案件已经创建,请使用账号为{1},密码为{2}登录调解系统,请知晓,如非本人操作,请忽略本短信。
2296
+            Boolean smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2064355", affiliate.getContactTelphoneAgent(), new String[]{affiliate.getContactTelphoneAgent(), "abc123456"});
2297
+        } else {
2298
+            // 查询所有部门
2299
+            List<SysDept> sysDepts = sysDeptMapper.selectDeptList(new SysDept());
2300
+            Map<String, List<SysDept>> deptMap=new HashMap<>();
2301
+            if(CollectionUtil.isNotEmpty(sysDepts)){
2302
+                 deptMap = sysDepts.stream().collect(Collectors.groupingBy(SysDept::getDeptName));
2280 2303
             }
2281
-        } else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(affiliate.getApplicationId())) {
2282
-            // 同步用户表和案件关联人表的手机号和名称
2283
-            affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber()) ? agentUser.getPhonenumber() : affiliate.getContactTelphoneAgent());
2284
-            affiliate.setNameAgent(agentUser.getNickName());
2285
-            affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail()) ? agentUser.getEmail() : affiliate.getAgentEmail());
2286
-            List<Long> longList = new ArrayList<>();
2287
-            // 新增角色为申请人
2288
-            if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
2289
-                longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
2290
-                if (!longList.contains(roleId)) {
2291
-                    userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
2292
-                }
2293
-            } else {
2294
-                userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
2304
+
2305
+            if(!deptMap.containsKey(affiliate.getApplicationName())){
2306
+                // 如果不存在则新增
2307
+                SysDept dept = new SysDept();
2308
+                dept.setParentId(0L);
2309
+                dept.setDeptName(affiliate.getApplicationName());
2310
+                dept.setAncestors("0");
2311
+                dept.setOrderNum(1);
2312
+                dept.setStatus("0");
2313
+                dept.setDelFlag("0");
2314
+                dept.setCreateBy(getUsername());
2315
+                dept.setUpdateBy(getUsername());
2316
+                sysDeptMapper.insertDept(dept);
2317
+                List<SysDept> depts = new ArrayList<>();
2318
+                depts.add(dept);
2319
+                deptMap.put(dept.getDeptName(), depts);
2320
+                affiliate.setApplicationId(String.valueOf(dept.getDeptId()));
2321
+                affiliate.setApplicationName(affiliate.getApplicationName());
2322
+            }else {
2323
+                // 将组织机构id设为申请人名称
2324
+                affiliate.setApplicationId(deptMap.get(affiliate.getApplicationName()).get(0).getDeptId().toString());
2325
+                affiliate.setApplicationName(affiliate.getApplicationName());
2295 2326
             }
2327
+            // 根据userId查询部门
2328
+            List<SysUserDept> userDeptList = userDeptMapper.selectUserDeptById(agentUser.getUserId());
2329
+            if(CollectionUtil.isEmpty(userDeptList)){
2330
+                // 未关联部门,关联部门,新增部门用户关联表
2331
+                SysUserDept sysUserDept = new SysUserDept();
2332
+                sysUserDept.setUserId(agentUser.getUserId());
2333
+                sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId()));
2334
+                userDeptMapper.insert(sysUserDept);
2335
+            }else {
2336
+                List<Long> deptIdList = userDeptList.stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
2337
+                if(!deptIdList.contains(Long.valueOf(affiliate.getApplicationId()))){
2338
+                    // 未关联该部门,关联部门,新增部门用户关联表
2339
+                    SysUserDept sysUserDept = new SysUserDept();
2340
+                    sysUserDept.setUserId(agentUser.getUserId());
2341
+                    sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId()));
2342
+                    userDeptMapper.insert(sysUserDept);
2343
+                    // 同步用户表和案件关联人表的手机号和名称
2344
+                    affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber()) ? agentUser.getPhonenumber() : affiliate.getContactTelphoneAgent());
2345
+                    affiliate.setNameAgent(agentUser.getNickName());
2346
+                    affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail()) ? agentUser.getEmail() : affiliate.getAgentEmail());
2347
+                    List<Long> longList = new ArrayList<>();
2348
+                    // 新增角色为申请人
2349
+                    if (CollectionUtil.isNotEmpty(agentUser.getRoles())) {
2350
+                        longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
2351
+                        if (!longList.contains(roleId)) {
2352
+                            userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
2353
+                        }
2354
+                    } else {
2355
+                        userRoleMapper.insertUserRole(agentUser.getUserId(), roleId);
2356
+                    }
2296 2357
 
2358
+                }
2359
+            }
2297 2360
         }
2298 2361
     }
2299 2362
 
@@ -2303,7 +2366,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
2303 2366
      * @param affiliate
2304 2367
      */
2305 2368
     @Transactional
2306
-    void insertDept(MsCaseAffiliate affiliate) {
2369
+    public   void insertDept(MsCaseAffiliate affiliate) {
2307 2370
         // 查询所有的组织机构,组装成map
2308 2371
         List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
2309 2372
         if (CollectionUtil.isEmpty(deptList)) {

+ 3
- 4
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java 查看文件

@@ -5,9 +5,9 @@ import com.alibaba.fastjson.JSONObject;
5 5
 import com.google.gson.Gson;
6 6
 import com.google.gson.JsonArray;
7 7
 import com.google.gson.JsonObject;
8
-import com.ruoyi.common.constant.CaseApplicationConstants;
9 8
 import com.ruoyi.common.constant.FileTransformation;
10 9
 import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
10
+import com.ruoyi.common.enums.AnnexTypeEnum;
11 11
 import com.ruoyi.common.exception.EsignDemoException;
12 12
 import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
13 13
 import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.annotation.Autowired;
27 27
 import org.springframework.scheduling.annotation.Scheduled;
28 28
 import org.springframework.stereotype.Component;
29 29
 import org.springframework.transaction.annotation.Transactional;
30
-import tk.mybatis.mapper.entity.Example;
31 30
 
32 31
 import java.io.File;
33 32
 import java.io.IOException;
@@ -119,7 +118,7 @@ public class FixSelectFlowDetailUtils {
119 118
                                             boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
120 119
                                             if (downLoadFile) {
121 120
                                                 MsCaseAttach caseAttach = new MsCaseAttach();
122
-                                                caseAttach.setAnnexType(10);  //10代表印章图片
121
+                                                caseAttach.setAnnexType(AnnexTypeEnum.SEAL_PICTURE.getCode());  //10代表印章图片
123 122
                                                 caseAttach.setAnnexPath(savePath);
124 123
                                                 caseAttach.setAnnexName(saveName);
125 124
                                                 int i1 = caseAttachMapper.save(caseAttach);
@@ -214,7 +213,7 @@ public class FixSelectFlowDetailUtils {
214 213
                                     boolean downLoadFile = FileTransformation.downLoadFileByUrl(sealImageDownloadUrl, resultFilePath);
215 214
                                     if (downLoadFile) {
216 215
                                         MsCaseAttach caseAttach = new MsCaseAttach();
217
-                                        caseAttach.setAnnexType(10);  //10代表印章图片
216
+                                        caseAttach.setAnnexType(AnnexTypeEnum.SEAL_PICTURE.getCode());  //10代表印章图片
218 217
                                         caseAttach.setAnnexPath(savePath);
219 218
                                         caseAttach.setAnnexName(saveName);
220 219
                                         int i1 = caseAttachMapper.save(caseAttach);

+ 6
- 0
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml 查看文件

@@ -91,6 +91,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
91 91
 		select u.dept_id from ms_sys_user_role r
92 92
 		join ms_sys_user u on r.role_id=#{roleId} and r.user_id=u.user_id
93 93
 	</select>
94
+	<select id="selectDeptByUserId" resultMap="SysDeptResult">
95
+		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_type,d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
96
+		from ms_sys_dept d join ms_sys_user_dept ud on ud.dept_id=d.dept_id
97
+		where ud.user_id=#{userId} and d.del_flag = '0'
98
+
99
+	</select>
94 100
 
95 101
 	<insert id="insertDept" parameterType="com.ruoyi.common.core.domain.entity.SysDept" useGeneratedKeys="true" keyColumn="dept_id" keyProperty="deptId">
96 102
  		insert into ms_sys_dept(

+ 4
- 4
ruoyi-system/src/main/resources/mapper/system/SysUserDeptMapper.xml 查看文件

@@ -13,14 +13,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
13 13
 
14 14
 
15 15
 
16
-	<select id="selectUserById" parameterType="Long" resultMap="resultMap">
16
+	<select id="selectUserDeptById"  resultMap="resultMap">
17 17
 		select * from ms_sys_user_dept
18 18
 		where user_id = #{userId}
19 19
 	</select>
20 20
 
21 21
 
22 22
 
23
-    <insert id="insert" parameterType="com.ruoyi.common.core.domain.entity.SysUserDept">
23
+	<insert id="insert" parameterType="com.ruoyi.common.core.domain.entity.SysUserDept">
24 24
  		insert into ms_sys_user_dept(
25 25
  			user_id,
26 26
  			dept_id
@@ -43,11 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
43 43
 	</insert>
44 44
 
45 45
 
46
-	<delete id="deleteUserById" parameterType="Long">
46
+	<delete id="deleteUserById" >
47 47
 		delete from ms_sys_user_dept  where user_id = #{userId}
48 48
  	</delete>
49 49
 
50
- 	<delete id="deleteUserByIds" parameterType="Long">
50
+ 	<delete id="deleteUserByIds">
51 51
 		delete from ms_sys_user_dept  where user_id in
52 52
  		<foreach collection="ids" item="userId" open="(" separator="," close=")">
53 53
  			#{userId}

+ 124
- 129
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml 查看文件

@@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
6 6
 
7 7
     <resultMap type="com.ruoyi.common.core.domain.entity.SysUser" id="SysUserResult">
8 8
         <id     property="userId"       column="user_id"      />
9
-        <result property="deptId"       column="dept_id"      />
10 9
         <result property="userName"     column="user_name"    />
11 10
         <result property="nickName"     column="nick_name"    />
12 11
 		<result property="idCard"    column="id_card" />
@@ -25,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
25 24
         <result property="updateTime"   column="update_time"  />
26 25
         <result property="remark"       column="remark"       />
27 26
         <result property="specialty"       column="specialty"       />
28
-        <association property="dept"    javaType="com.ruoyi.common.core.domain.entity.SysDept"         resultMap="deptResult" />
27
+        <collection property="dept"    javaType="com.ruoyi.common.core.domain.entity.SysDept"         resultMap="deptResult" />
29 28
         <collection  property="roles"   javaType="java.util.List"  resultMap="RoleResult" />
30 29
     </resultMap>
31 30
 	
@@ -50,20 +49,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
50 49
     </resultMap>
51 50
 	
52 51
 	<sql id="selectUserVo">
53
-        select u.user_id, u.dept_id, u.user_name, u.nick_name,u.specialty, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
54
-        d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
52
+        select u.user_id, u.user_name, u.nick_name,u.specialty, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
55 53
         r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.id_card
56 54
         from ms_sys_user u
57
-		    left join ms_sys_dept d on u.dept_id = d.dept_id
58 55
 		    left join ms_sys_user_role ur on u.user_id = ur.user_id
59 56
 		    left join ms_sys_role r on r.role_id = ur.role_id
60 57
     </sql>
61 58
     
62 59
     <select id="selectUserList" parameterType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult">
63
-		select u.user_id, u.dept_id, u.nick_name, u.user_name,u.specialty,u.id_card, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name,
64
-		 d.leader , r.role_id, r.role_name, d.dept_id
60
+		select u.user_id, u.nick_name, u.user_name,u.specialty,u.id_card, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
61
+		r.role_id, r.role_name
65 62
 		from ms_sys_user u
66
-		left join ms_sys_dept d on u.dept_id = d.dept_id
63
+
67 64
 		left join ms_sys_user_role ur on u.user_id = ur.user_id
68 65
 		left join ms_sys_role r on r.role_id = ur.role_id
69 66
 		where u.del_flag = '0'
@@ -85,17 +82,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
85 82
 		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
86 83
 			AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
87 84
 		</if>
88
-		<if test="deptId != null and deptId != 0">
89
-			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM ms_sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
90
-		</if>
85
+
91 86
 		<!-- 数据范围过滤 -->
92 87
 		${params.dataScope}
93 88
 	</select>
94 89
 	
95 90
 	<select id="selectAllocatedList" parameterType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult">
96
-	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name,u.specialty,u.id_card, u.email, u.phonenumber, u.status, u.create_time
91
+	    select distinct u.user_id, u.user_name, u.nick_name,u.specialty,u.id_card, u.email, u.phonenumber, u.status, u.create_time
97 92
 	    from ms_sys_user u
98
-			 left join ms_sys_dept d on u.dept_id = d.dept_id
93
+
99 94
 			 left join ms_sys_user_role ur on u.user_id = ur.user_id
100 95
 			 left join ms_sys_role r on r.role_id = ur.role_id
101 96
 	    where u.del_flag = '0' and r.role_id = #{roleId}
@@ -110,9 +105,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
110 105
 	</select>
111 106
 	
112 107
 	<select id="selectUnallocatedList" parameterType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult">
113
-	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name,u.specialty,u.id_card, u.email, u.phonenumber, u.status, u.create_time
108
+	    select distinct u.user_id,  u.user_name, u.nick_name,u.specialty,u.id_card, u.email, u.phonenumber, u.status, u.create_time
114 109
 	    from ms_sys_user u
115
-			 left join ms_sys_dept d on u.dept_id = d.dept_id
116 110
 			 left join ms_sys_user_role ur on u.user_id = ur.user_id
117 111
 			 left join ms_sys_role r on r.role_id = ur.role_id
118 112
 	    where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
@@ -139,10 +133,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
139 133
 
140 134
 	<select id="selectUserByDeptId" parameterType="Long" resultMap="SysUserResult">
141 135
 		SELECT  ud.user_id , ud.nick_name ,u.specialty,ud.phonenumber ,ud.dept_id ,d.dept_name
142
-        FROM  (SELECT u.user_id , u.nick_name ,u.phonenumber ,u.dept_id
136
+        FROM  (SELECT u.user_id , u.nick_name ,u.phonenumber ,ud.dept_id
143 137
         FROM ms_sys_user_post up left join ms_sys_user  u on u.user_id  = up.user_id
138
+								 left join ms_sys_user_dept ud on ud.user_id = u.user_id
144 139
             left join  ms_sys_post  sp on up.post_id  = sp.post_id
145
-        where sp.post_code = 'jbr') ud left join ms_sys_dept d on ud.dept_id = d.dept_id
140
+        where sp.post_code = 'jbr' and  u.del_flag = '0') ud left join ms_sys_dept d on ud.dept_id = d.dept_id
146 141
 		where d.dept_id = #{deptId}
147 142
 	</select>
148 143
 	
@@ -173,9 +168,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
173 168
 	</select>
174 169
 
175 170
 	<select id="selectUserByIdCard" parameterType="String" resultMap="SysUserResult">
176
-		select u.*,d.dept_name,ur.role_id
171
+		select u.*,ur.role_id
177 172
 			from ms_sys_user u
178
-		    left join ms_sys_dept d on u.dept_id = d.dept_id
173
+
179 174
 			left join ms_sys_user_role ur on u.user_id = ur.user_id
180 175
 			left join ms_sys_role r on r.role_id = ur.role_id
181 176
 		where u.id_card = #{idCard} and u.del_flag = '0' and u.status='0' order by u.create_time limit 1
@@ -183,7 +178,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
183 178
 	<select id="selectUserByPhone" parameterType="String" resultMap="SysUserResult">
184 179
 		select u.*,d.dept_name,ur.role_id
185 180
 			from ms_sys_user u
186
-		    left join ms_sys_dept d on u.dept_id = d.dept_id
187 181
 			left join ms_sys_user_role ur on u.user_id = ur.user_id
188 182
 			left join ms_sys_role r on r.role_id = ur.role_id
189 183
 		where u.phonenumber = #{phone} and u.del_flag = '0' and u.status='0' order by u.create_time limit 1
@@ -191,16 +185,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
191 185
     <select id="selectByDeptIdAndRole" resultMap="SysUserResult">
192 186
 		select u.* from
193 187
 		               ms_sys_user u
188
+						join ms_sys_user_dept ud on ud.user_id = u.user_id
194 189
 		                join ms_sys_user_role ur on u.user_id = ur.user_id
190
+
195 191
 		                join ms_sys_role r on ur.role_id = r.role_id
196
-		where u.dept_id = #{deptId} and r.role_name = #{roleName} and u.del_flag = '0' and r.del_flag='0'
192
+		where ud.dept_id = #{deptId} and r.role_name = #{roleName} and u.del_flag = '0' and r.del_flag='0'
197 193
 	</select>
198 194
 
199 195
 
200 196
     <insert id="insertUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser" useGeneratedKeys="true" keyProperty="userId">
201 197
  		insert into ms_sys_user(
202 198
  			<if test="userId != null and userId != 0">user_id,</if>
203
- 			<if test="deptId != null and deptId != 0">dept_id,</if>
199
+ 		<!--	<if test="deptId != null and deptId != 0">dept_id,</if> -->
204 200
  			<if test="userName != null and userName != ''">user_name,</if>
205 201
  			<if test="nickName != null and nickName != ''">nick_name,</if>
206 202
  			<if test="idCard != null and idCard != ''">id_card,</if>
@@ -216,113 +212,112 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
216 212
  			create_time
217 213
  		)values(
218 214
  			<if test="userId != null and userId != ''">#{userId},</if>
219
- 			<if test="deptId != null and deptId != ''">#{deptId},</if>
220
- 			<if test="userName != null and userName != ''">#{userName},</if>
221
- 			<if test="nickName != null and nickName != ''">#{nickName},</if>
222
- 			<if test="idCard != null and idCard != ''">#{idCard},</if>
223
- 			<if test="email != null and email != ''">#{email},</if>
224
- 			<if test="avatar != null and avatar != ''">#{avatar},</if>
225
- 			<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
226
- 			<if test="sex != null and sex != ''">#{sex},</if>
227
- 			<if test="password != null and password != ''">#{password},</if>
228
- 			<if test="status != null and status != ''">#{status},</if>
229
- 			<if test="createBy != null and createBy != ''">#{createBy},</if>
230
- 			<if test="remark != null and remark != ''">#{remark},</if>
231
- 			<if test="specialty != null and specialty != ''">#{specialty},</if>
232
- 			sysdate()
233
- 		)
234
-	</insert>
235
-    <insert id="batchSave">
236
-		insert into ms_sys_user(
237
-		user_id,
238
-		dept_id,
239
-		user_name,
240
-		nick_name,
241
-		id_card,
242
-		email,
243
-		avatar,
244
-		phonenumber,
245
-		sex,
246
-		password,
247
-		status,
248
-		create_by,
249
-		remark,
250
-		specialty,
251
-		create_time
252
-		)values
253
-		<foreach item="item" index="index" collection="list" separator=",">
254
-		(
255
-		#{item.userId},
256
-		#{item.deptId},
257
-		#{item.userName},
258
-		#{item.nickName},
259
-		#{item.idCard},
260
-		#{item.email},
261
-		#{item.avatar},
262
-		#{item.phonenumber},
263
-		#{item.sex},
264
-		#{item.password},
265
-		#{item.status},
266
-		#{item.createBy},
267
-		#{item.remark},
268
-		#{item.specialty},
269
-		sysdate()
270
-		)
271
-		</foreach>;
272
-	</insert>
215
+		<!--	<if test="deptId != null and deptId != ''">#{deptId},</if> -->
216
+            <if test="userName != null and userName != ''">#{userName},</if>
217
+            <if test="nickName != null and nickName != ''">#{nickName},</if>
218
+            <if test="idCard != null and idCard != ''">#{idCard},</if>
219
+            <if test="email != null and email != ''">#{email},</if>
220
+            <if test="avatar != null and avatar != ''">#{avatar},</if>
221
+            <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
222
+            <if test="sex != null and sex != ''">#{sex},</if>
223
+            <if test="password != null and password != ''">#{password},</if>
224
+            <if test="status != null and status != ''">#{status},</if>
225
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
226
+            <if test="remark != null and remark != ''">#{remark},</if>
227
+            <if test="specialty != null and specialty != ''">#{specialty},</if>
228
+            sysdate()
229
+        )
230
+   </insert>
231
+   <insert id="batchSave">
232
+       insert into ms_sys_user(
233
+       user_id,
234
+       user_name,
235
+       nick_name,
236
+       id_card,
237
+       email,
238
+       avatar,
239
+       phonenumber,
240
+       sex,
241
+       password,
242
+       status,
243
+       create_by,
244
+       remark,
245
+       specialty,
246
+       create_time
247
+       )values
248
+       <foreach item="item" index="index" collection="list" separator=",">
249
+       (
250
+       #{item.userId},
251
+       #{item.userName},
252
+       #{item.nickName},
253
+       #{item.idCard},
254
+       #{item.email},
255
+       #{item.avatar},
256
+       #{item.phonenumber},
257
+       #{item.sex},
258
+       #{item.password},
259
+       #{item.status},
260
+       #{item.createBy},
261
+       #{item.remark},
262
+       #{item.specialty},
263
+       sysdate()
264
+       )
265
+       </foreach>;
266
+   </insert>
273 267
 
274
-    <update id="updateUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
275
- 		update ms_sys_user
276
- 		<set>
277
-			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
278
-			<if test="userName != null and userName != ''">user_name = #{userName},</if>
279
-			<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
280
-			<if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
281
-			<if test="email != null ">email = #{email},</if>
282
-			<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
283
-			<if test="sex != null and sex != ''">sex = #{sex},</if>
284
-			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
285
-			<if test="password != null and password != ''">password = #{password},</if>
286
-			<if test="status != null and status != ''">status = #{status},</if>
287
-			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
288
-			<if test="loginDate != null">login_date = #{loginDate},</if>
289
-			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
290
-			<if test="remark != null">remark = #{remark},</if>
291
-			<if test="specialty != null">specialty = #{specialty},</if>
292
- 			update_time = sysdate()
293
- 		</set>
294
- 		where user_id = #{userId}
295
-	</update>
296
-	
297
-	<update id="updateUserAvatar" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
298
- 		update ms_sys_user set avatar = #{avatar} where user_name = #{userName}
299
-	</update>
300
-	
301
-	<update id="resetUserPwd" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
302
- 		update ms_sys_user set password = #{password} where user_name = #{userName}
303
-	</update>
304
-	
305
-	<delete id="deleteUserById" parameterType="Long">
306
- 		update ms_sys_user set del_flag = '2' where user_id = #{userId}
307
- 	</delete>
308
- 	
309
- 	<delete id="deleteUserByIds" parameterType="Long">
310
- 		update ms_sys_user set del_flag = '2' where user_id in
311
- 		<foreach collection="array" item="userId" open="(" separator="," close=")">
312
- 			#{userId}
313
-        </foreach> 
314
- 	</delete>
315
-	<select id="selectRoleUserByDeptId" parameterType="long" resultMap="SysUserResult">
316
-		SELECT u.* FROM ms_sys_user u
317
-		INNER JOIN ms_sys_user_role ur ON u.user_id = ur.user_id
318
-		INNER JOIN ms_sys_dept d ON u.dept_id = d.dept_id
319
-		WHERE ur.role_id = #{roleId} AND d.dept_id = #{deptId};
320
-	</select>
268
+   <update id="updateUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
269
+        update ms_sys_user
270
+        <set>
271
+
272
+           <if test="userName != null and userName != ''">user_name = #{userName},</if>
273
+           <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
274
+           <if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
275
+           <if test="email != null ">email = #{email},</if>
276
+           <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
277
+           <if test="sex != null and sex != ''">sex = #{sex},</if>
278
+           <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
279
+           <if test="password != null and password != ''">password = #{password},</if>
280
+           <if test="status != null and status != ''">status = #{status},</if>
281
+           <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
282
+           <if test="loginDate != null">login_date = #{loginDate},</if>
283
+           <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
284
+           <if test="remark != null">remark = #{remark},</if>
285
+           <if test="specialty != null">specialty = #{specialty},</if>
286
+            update_time = sysdate()
287
+        </set>
288
+        where user_id = #{userId}
289
+   </update>
290
+
291
+   <update id="updateUserAvatar" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
292
+        update ms_sys_user set avatar = #{avatar} where user_name = #{userName}
293
+   </update>
294
+
295
+   <update id="resetUserPwd" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
296
+        update ms_sys_user set password = #{password} where user_name = #{userName}
297
+   </update>
298
+
299
+   <delete id="deleteUserById" parameterType="Long">
300
+        update ms_sys_user set del_flag = '2' where user_id = #{userId}
301
+    </delete>
302
+
303
+    <delete id="deleteUserByIds" parameterType="Long">
304
+        update ms_sys_user set del_flag = '2' where user_id in
305
+        <foreach collection="array" item="userId" open="(" separator="," close=")">
306
+            #{userId}
307
+       </foreach>
308
+    </delete>
309
+   <select id="selectRoleUserByDeptId" parameterType="long" resultMap="SysUserResult">
310
+       SELECT u.* FROM ms_sys_user u
311
+       INNER JOIN ms_sys_user_role ur ON u.user_id = ur.user_id
312
+       INNER JOIN ms_sys_user_dept ud on ud.user_id = u.user_id
313
+       INNER join ms_sys_dept d on ud.dept_id = d.dept_id
314
+       WHERE ur.role_id = #{roleId} AND d.dept_id = #{deptId};
315
+   </select>
321 316
 
322
-    <select id="selectUserByRole" resultType="com.ruoyi.common.core.domain.entity.SysUser">
323
-		select u.user_id userId,u.user_name userName,u.nick_name nickName,u.specialty  from ms_sys_user u
324
-		    join ms_sys_user_role ur on ur.user_id =u.user_id
325
-		    join ms_sys_role r on ur.role_id = r.role_id and r.role_name='调解员'
326
-		    where r.del_flag = '0' and r.status='0' and u.del_flag = '0' and u.status='0'
327
-    </select>
317
+   <select id="selectUserByRole" resultType="com.ruoyi.common.core.domain.entity.SysUser">
318
+       select u.user_id userId,u.user_name userName,u.nick_name nickName,u.specialty  from ms_sys_user u
319
+           join ms_sys_user_role ur on ur.user_id =u.user_id
320
+           join ms_sys_role r on ur.role_id = r.role_id and r.role_name='调解员'
321
+           where r.del_flag = '0' and r.status='0' and u.del_flag = '0' and u.status='0'
322
+   </select>
328 323
 </mapper>