Yansen hace 2 años
padre
commit
dcf698e11b

+ 17
- 0
src/main/java/com/example/civilizedcity/common/BaseController.java Ver fichero

@@ -3,6 +3,7 @@ package com.example.civilizedcity.common;
3 3
 import cn.dev33.satoken.stp.StpUtil;
4 4
 import com.example.civilizedcity.entity.SysUser;
5 5
 import com.example.civilizedcity.entity.TaPerson;
6
+import com.example.civilizedcity.service.SysUserDutyService;
6 7
 import com.example.civilizedcity.service.SysUserService;
7 8
 import com.example.civilizedcity.service.TaPersonService;
8 9
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Component;
10 11
 
11 12
 import javax.annotation.Resource;
12 13
 import javax.servlet.http.HttpServletRequest;
14
+import java.util.List;
13 15
 
14 16
 @Component
15 17
 public class BaseController {
@@ -23,6 +25,9 @@ public class BaseController {
23 25
     @Autowired
24 26
     protected TaPersonService taPersonService;
25 27
 
28
+    @Autowired
29
+    protected SysUserDutyService sysUserDutyService;
30
+
26 31
     public SysUser currentUser() throws Exception {
27 32
         String loginId = StpUtil.getLoginIdAsString();
28 33
         if (StringUtils.isEmpty(loginId)) {
@@ -52,4 +57,16 @@ public class BaseController {
52 57
 
53 58
         return taPerson;
54 59
     }
60
+
61
+    public boolean isManager(SysUser sysUser) throws Exception {
62
+        if (Constants.ROOT_ORG.equals(sysUser.getOrgId())) return true;
63
+
64
+        List<String> dutyList = sysUserDutyService.getListByUser(sysUser.getUserId());
65
+        sysUser.setDutyList(dutyList);  // 添加了一点副作用
66
+        if (null != dutyList && (dutyList.contains(Constants.DUTY_MANAGER) || dutyList.contains(Constants.DUTY_QUERY_PERSON))) {
67
+            return true;
68
+        }
69
+
70
+        return false;
71
+    }
55 72
 }

+ 17
- 1
src/main/java/com/example/civilizedcity/controller/SysOrgController.java Ver fichero

@@ -12,6 +12,7 @@ import java.util.List;
12 12
 
13 13
 import com.example.civilizedcity.common.StringUtils;
14 14
 import com.example.civilizedcity.entity.SysRole;
15
+import com.example.civilizedcity.entity.SysUser;
15 16
 import io.swagger.annotations.Api;
16 17
 import io.swagger.annotations.ApiOperation;
17 18
 import io.swagger.annotations.ApiParam;
@@ -145,7 +146,22 @@ public class SysOrgController extends BaseController {
145 146
      */
146 147
     @ApiOperation("通过主键删除数据")
147 148
     @DeleteMapping("/sysOrg/{id}")
148
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
149
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
150
+        SysUser sysUser = currentUser();
151
+
152
+        if (Constants.ROOT_ID.equals(id)) {
153
+            return ResponseBean.error("系统机构, 禁止删除");
154
+        }
155
+
156
+        long count = sysOrgService.countBy("org_p_id", id, true);
157
+        if (count > 0) {
158
+            return ResponseBean.error("请先删除子级单位");
159
+        }
160
+
161
+        if (!Constants.ROOT_ORG.equals(sysUser.getOrgId())) {
162
+            return ResponseBean.error("暂无权限");
163
+        }
164
+
149 165
         sysOrgService.removeLogicById(id);
150 166
         return ResponseBean.success("success");
151 167
     }

+ 20
- 4
src/main/java/com/example/civilizedcity/controller/TaIssueApplyController.java Ver fichero

@@ -13,6 +13,7 @@ import java.util.List;
13 13
 import com.example.civilizedcity.common.StringUtils;
14 14
 import com.example.civilizedcity.entity.SysUser;
15 15
 import com.example.civilizedcity.event.MessagEvent;
16
+import com.example.civilizedcity.service.SysUserDutyService;
16 17
 import com.example.civilizedcity.service.TaIssueService;
17 18
 import io.swagger.annotations.Api;
18 19
 import io.swagger.annotations.ApiOperation;
@@ -40,6 +41,9 @@ public class TaIssueApplyController extends BaseController {
40 41
     @Autowired
41 42
     private TaIssueService taIssueService;
42 43
 
44
+    @Autowired
45
+    private SysUserDutyService sysUserDutyService;
46
+
43 47
     @Autowired
44 48
     ApplicationEventPublisher applicationEventPublisher;
45 49
 
@@ -66,11 +70,14 @@ public class TaIssueApplyController extends BaseController {
66 70
                                        @ApiParam("申请类型") @RequestParam("applyType") String applyType) throws Exception {
67 71
 
68 72
         SysUser sysUser = currentUser();
73
+        boolean isManager = isManager(sysUser);
69 74
 
70 75
         QueryWrapper<TaIssueApply> queryWrapper = new QueryWrapper<>();
71 76
         queryWrapper.eq("issue_id", issueId);
72 77
         queryWrapper.eq("apply_type", applyType);
73
-        queryWrapper.eq("org_id", sysUser.getOrgId());
78
+        if (!isManager) {
79
+            queryWrapper.eq("org_id", sysUser.getOrgId());
80
+        }
74 81
         queryWrapper.gt("status", Constants.STATUS_DELETE);
75 82
         queryWrapper.orderByDesc("create_date");
76 83
         queryWrapper.last("limit 1");
@@ -91,14 +98,15 @@ public class TaIssueApplyController extends BaseController {
91 98
     @GetMapping("/taIssueApply")
92 99
     public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
93 100
                              @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
101
+                             @ApiParam("问题单ID") @RequestParam(value = "issueId", required = false) Integer issueId,
94 102
                              @ApiParam("申请类型") @RequestParam(value = "applyType", required = false) String applyType,
95 103
                              @ApiParam("问题单来源") @RequestParam(value = "sourceType", required = false) String sourceType) throws Exception {
96 104
 
97 105
         SysUser sysUser = currentUser();
98
-        String orgId = Constants.ROOT_ORG.equals(sysUser.getOrgId()) ? null : sysUser.getOrgId();
106
+        String orgId = isManager(sysUser) ? null : sysUser.getOrgId();
99 107
 
100 108
         IPage<TaIssueApply> pg = new Page<>(pageNum, pageSize);
101
-        IPage<TaIssueApply> result = taIssueApplyService.getPageBy(pg, applyType, orgId, sourceType);
109
+        IPage<TaIssueApply> result = taIssueApplyService.getPageBy(pg, issueId, applyType, orgId, sourceType);
102 110
 
103 111
         return ResponseBean.success(result);
104 112
     }
@@ -150,9 +158,17 @@ public class TaIssueApplyController extends BaseController {
150 158
 
151 159
         taIssueApplyService.updateById(origin);
152 160
 
153
-        // 清空当前申请 - 表示申请流程已走完
161
+        //
154 162
         taIssueService.updateApply(taIssueApply.getIssueId(), null, null);
155 163
 
164
+        // 如果是销单申请
165
+        if (Constants.APPLY_END.equals(origin.getApplyType())) {
166
+            if (Constants.APPLY_STATUS_PASS.equals(taIssueApply.getVerifyStatus())) {
167
+                // 如果通过
168
+                taIssueService.updateEnd(sysUser, taIssueApply.getOrgId(), taIssueApply.getIssueId());
169
+            }
170
+        }
171
+
156 172
 //        if (Constants.APPLY_VERIFY.equals(origin.getApplyType())) {
157 173
 //            int validateStatus = Constants.APPLY_STATUS_REJECT.equals(taIssueApply.getVerifyStatus()) ? Constants.VERIFY_REJECT : Constants.VERIFY_PASS;
158 174
 //            taIssueService.updateValidateStatus(taIssueApply.getIssueId(), validateStatus);

+ 1
- 0
src/main/java/com/example/civilizedcity/controller/TaIssueProcessController.java Ver fichero

@@ -74,6 +74,7 @@ public class TaIssueProcessController extends BaseController {
74 74
         IPage<TaIssueProcess> pg = new Page<>(pageNum, pageSize);
75 75
         QueryWrapper<TaIssueProcess> queryWrapper = new QueryWrapper<>();
76 76
         queryWrapper.eq("issue_id", issueId);
77
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
77 78
         queryWrapper.orderByDesc("create_date");
78 79
         IPage<TaIssueProcess> result = taIssueProcessService.page(pg, queryWrapper);
79 80
 

+ 1
- 0
src/main/java/com/example/civilizedcity/mapper/TaIssueApplyMapper.java Ver fichero

@@ -15,6 +15,7 @@ import com.example.civilizedcity.entity.TaIssueApply;
15 15
 public interface TaIssueApplyMapper  extends BaseMapper<TaIssueApply>{
16 16
 
17 17
      IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg,
18
+                                   @Param("issueId") Integer issueId,
18 19
                                    @Param("applyType") String applyType,
19 20
                                    @Param("orgId") String orgId,
20 21
                                    @Param("sourceType") String sourceType);

+ 5
- 1
src/main/java/com/example/civilizedcity/mapper/TaIssueMapper.java Ver fichero

@@ -3,7 +3,6 @@ package com.example.civilizedcity.mapper;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.example.civilizedcity.vo.StatVo;
6
-import org.apache.ibatis.annotations.MapKey;
7 6
 import org.apache.ibatis.annotations.Mapper;
8 7
 import org.apache.ibatis.annotations.Param;
9 8
 import com.example.civilizedcity.entity.TaIssue;
@@ -34,4 +33,9 @@ public interface TaIssueMapper  extends BaseMapper<TaIssue>{
34 33
      Map<String, Object> statIssueOrg(@Param("orgId") String orgId);
35 34
 
36 35
      List<StatVo> statIssueType();
36
+
37
+    int updateProcess(@Param("issueId") Integer issueId,
38
+                      @Param("userId") String userId,
39
+                      @Param("processNode") String processNode,
40
+                      @Param("processStatus") String processStatus);
37 41
 }

+ 3
- 1
src/main/java/com/example/civilizedcity/mapper/TaOrgIssueMapper.java Ver fichero

@@ -28,4 +28,6 @@ public interface TaOrgIssueMapper  extends BaseMapper<TaOrgIssue>{
28 28
      TaOrgIssue getByIssueAndOrg(@Param("issueId") Integer issueId, @Param("orgId") String orgId);
29 29
 
30 30
      Map<String, Object> statMaIndex(@Param("orgId") String orgId);
31
- }
31
+
32
+    int updateProcess(@Param("issueId") Integer issueId,@Param("orgId") String orgId,@Param("processStatus") String processStatus);
33
+}

+ 1
- 1
src/main/java/com/example/civilizedcity/service/TaIssueApplyService.java Ver fichero

@@ -14,5 +14,5 @@ public interface TaIssueApplyService extends IBaseService<TaIssueApply> {
14 14
 
15 15
      void createNewApply(TaIssueApply taIssueApply, SysUser sysUser) throws Exception;
16 16
 
17
-     IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, String applyType, String orgId, String sourceType);
17
+     IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, Integer issueId, String applyType, String orgId, String sourceType);
18 18
  }

+ 3
- 2
src/main/java/com/example/civilizedcity/service/TaIssueService.java Ver fichero

@@ -1,7 +1,6 @@
1 1
 package com.example.civilizedcity.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
-import com.baomidou.mybatisplus.extension.service.IService;
5 4
 import com.example.civilizedcity.entity.SysUser;
6 5
 import com.example.civilizedcity.entity.TaIssue;
7 6
 import com.example.civilizedcity.entity.TaPerson;
@@ -23,4 +22,6 @@ public interface TaIssueService extends IBaseService<TaIssue> {
23 22
      void updateApply(Integer issueId, String applyType, Integer applyId);
24 23
 
25 24
      List<StatVo> statMaIndex(SysUser user, TaPerson person, String duty);
26
- }
25
+
26
+    void updateEnd(SysUser sysUser, String orgId, Integer issueId);
27
+}

+ 1
- 1
src/main/java/com/example/civilizedcity/service/impl/SysResourceServiceImpl.java Ver fichero

@@ -20,7 +20,7 @@ public class SysResourceServiceImpl extends BaseServiceImpl<SysResourceMapper, S
20 20
 
21 21
     @Override
22 22
     public List<SysResource> getByUser(String userId) {
23
-        if (userId == Constants.ROOT_ID) {
23
+        if (Constants.ROOT_ID.equals(userId)) {
24 24
             QueryWrapper<SysResource> queryWrapper = new QueryWrapper<>();
25 25
             queryWrapper.gt("status", Constants.STATUS_DELETE);
26 26
             return list(queryWrapper);

+ 1
- 1
src/main/java/com/example/civilizedcity/service/impl/SysRoleServiceImpl.java Ver fichero

@@ -21,7 +21,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
21 21
 
22 22
     @Override
23 23
     public List<SysRole> getByUser(String userId) {
24
-        if (userId == Constants.ROOT_ID) {
24
+        if (Constants.ROOT_ID.equals(userId)) {
25 25
             QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
26 26
             queryWrapper.gt("status", Constants.STATUS_DELETE);
27 27
             return list(queryWrapper);

+ 1
- 0
src/main/java/com/example/civilizedcity/service/impl/SysUserDutyServiceImpl.java Ver fichero

@@ -1,5 +1,6 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3
+import com.example.civilizedcity.common.Constants;
3 4
 import org.springframework.beans.factory.annotation.Autowired;
4 5
 import org.springframework.stereotype.Service;
5 6
 import com.example.civilizedcity.entity.SysUserDuty;

+ 2
- 4
src/main/java/com/example/civilizedcity/service/impl/TaIssueApplyServiceImpl.java Ver fichero

@@ -49,8 +49,6 @@ public class TaIssueApplyServiceImpl extends BaseServiceImpl<TaIssueApplyMapper,
49 49
                 throw new Exception("未找到交办单位问题单");
50 50
             }
51 51
 
52
-            // 标记在申请中
53
-            taOrgIssue.setResult(taIssueApply.getApplyType());
54 52
             taOrgIssueMapper.updateById(taOrgIssue);
55 53
         }
56 54
 
@@ -73,7 +71,7 @@ public class TaIssueApplyServiceImpl extends BaseServiceImpl<TaIssueApplyMapper,
73 71
     }
74 72
 
75 73
     @Override
76
-    public IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, String applyType, String orgId, String sourceType) {
77
-        return baseMapper.getPageBy(pg, applyType, orgId, sourceType);
74
+    public IPage<TaIssueApply> getPageBy(IPage<TaIssueApply> pg, Integer issueId, String applyType, String orgId, String sourceType) {
75
+        return baseMapper.getPageBy(pg, issueId, applyType, orgId, sourceType);
78 76
     }
79 77
 }

+ 27
- 1
src/main/java/com/example/civilizedcity/service/impl/TaIssueServiceImpl.java Ver fichero

@@ -2,10 +2,11 @@ package com.example.civilizedcity.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.example.civilizedcity.common.Constants;
5
-import com.example.civilizedcity.common.StringUtils;
6 5
 import com.example.civilizedcity.entity.SysUser;
6
+import com.example.civilizedcity.entity.TaIssueProcess;
7 7
 import com.example.civilizedcity.entity.TaPerson;
8 8
 import com.example.civilizedcity.mapper.TaFeedbackMapper;
9
+import com.example.civilizedcity.mapper.TaIssueProcessMapper;
9 10
 import com.example.civilizedcity.mapper.TaOrgIssueMapper;
10 11
 import com.example.civilizedcity.vo.StatVo;
11 12
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +15,7 @@ import com.example.civilizedcity.entity.TaIssue;
14 15
 import com.example.civilizedcity.mapper.TaIssueMapper;
15 16
 import com.example.civilizedcity.service.TaIssueService;
16 17
 
18
+import java.time.LocalDateTime;
17 19
 import java.util.ArrayList;
18 20
 import java.util.List;
19 21
 import java.util.Map;
@@ -33,6 +35,9 @@ public class TaIssueServiceImpl extends BaseServiceImpl<TaIssueMapper, TaIssue>
33 35
     @Autowired
34 36
     TaFeedbackMapper taFeedbackMapper;
35 37
 
38
+    @Autowired
39
+    TaIssueProcessMapper taIssueProcessMapper;
40
+
36 41
     @Override
37 42
     public IPage<TaIssue> getPageBy(IPage<TaIssue> pg, String orgId) {
38 43
         if (null == orgId) {
@@ -100,6 +105,27 @@ public class TaIssueServiceImpl extends BaseServiceImpl<TaIssueMapper, TaIssue>
100 105
         return result;
101 106
     }
102 107
 
108
+    @Override
109
+    public void updateEnd(SysUser sysUser, String orgId, Integer issueId) {
110
+        // 问题单完成
111
+        baseMapper.updateProcess(issueId, sysUser.getUserId(), Constants.PROCESS_END, Constants.PROCESS_END);
112
+
113
+        // 机构问题单完成
114
+        taOrgIssueMapper.updateProcess(issueId, orgId, Constants.PROCESS_END);
115
+
116
+        // 流程完成
117
+        TaIssueProcess taIssueProcess = new TaIssueProcess();
118
+        taIssueProcess.setIssueId(issueId);
119
+        taIssueProcess.setOrgId(orgId);
120
+        taIssueProcess.setProcessNode(Constants.PROCESS_END);
121
+        taIssueProcess.setProcessStatus(Constants.PROCESS_END);
122
+        taIssueProcess.setCreateUser(sysUser.getUserId());
123
+        taIssueProcess.setCreateDate(LocalDateTime.now());
124
+        taIssueProcess.setStatus(Constants.STATUS_NORMAL);
125
+        taIssueProcessMapper.insert(taIssueProcess);
126
+
127
+    }
128
+
103 129
     Integer getStatValueBy(Object v, Integer def) {
104 130
         if (null == v) return def;
105 131
         return Integer.valueOf(v.toString());

+ 3
- 0
src/main/resources/mapper/TaIssueApplyMapper.xml Ver fichero

@@ -13,6 +13,9 @@
13 13
                 INNER JOIN ta_issue s ON t.issue_id = s.issue_id
14 14
         WHERE
15 15
             t.`status` &gt; -1
16
+        <if test="issueId != null">
17
+            AND t.issue_id = #{issueId}
18
+        </if>
16 19
         <if test="applyType != null and applyType != ''">
17 20
             AND t.apply_type = #{applyType}
18 21
         </if>

+ 9
- 0
src/main/resources/mapper/TaIssueMapper.xml Ver fichero

@@ -15,6 +15,15 @@
15 15
         WHERE
16 16
             t.issue_id = #{issueId}
17 17
     </update>
18
+    <update id="updateProcess">
19
+        UPDATE ta_issue t
20
+        SET t.process_node = #{processNode},
21
+            t.process_status = #{processStatus},
22
+            t.update_user = #{userId},
23
+            t.update_date = now( )
24
+        WHERE
25
+            t.issue_id = #{issueId}
26
+    </update>
18 27
 
19 28
     <select id="getPageBy" resultType="com.example.civilizedcity.entity.TaIssue">
20 29
         SELECT

+ 7
- 0
src/main/resources/mapper/TaOrgIssueMapper.xml Ver fichero

@@ -2,6 +2,13 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.example.civilizedcity.mapper.TaOrgIssueMapper">
5
+    <update id="updateProcess">
6
+        UPDATE ta_org_issue t
7
+        SET t.process_status = #{processStatus}
8
+        WHERE
9
+            t.org_id = #{orgId}
10
+          AND t.issue_id = #{issueId}
11
+    </update>
5 12
 
6 13
     <select id="getIssuePageBy" resultType="com.example.civilizedcity.entity.TaIssue">
7 14
         SELECT