소스 검색

优化代码

matianxiang 2 주 전
부모
커밋
7e6002b79e

+ 2 - 2
eitc-admin/src/main/java/com/eitc/common/aspect/DataFilterAspect.java

@@ -39,7 +39,7 @@ public class DataFilterAspect {
39 39
     @Before("dataFilterCut()")
40 40
     public void dataFilter(JoinPoint point) {
41 41
         Object params = point.getArgs()[0];
42
-        if(params != null && params instanceof Map){
42
+        if(params instanceof Map){
43 43
             UserDetail user = SecurityUser.getUser();
44 44
 
45 45
             //如果是超级管理员或超级租户,则不进行数据过滤
@@ -53,7 +53,7 @@ public class DataFilterAspect {
53 53
                 Map map = (Map)params;
54 54
                 String sqlFilter = getSqlFilter(user, point);
55 55
                 map.put(Constant.SQL_FILTER, new DataScope(sqlFilter));
56
-            }catch (Exception e){
56
+            }catch (Exception ignored){
57 57
 
58 58
             }
59 59
 

+ 6 - 6
eitc-admin/src/main/java/com/eitc/modules/activiti/service/ActModelService.java

@@ -18,9 +18,9 @@ import org.activiti.engine.repository.ModelQuery;
18 18
 import org.activiti.engine.repository.ProcessDefinition;
19 19
 import org.apache.commons.io.IOUtils;
20 20
 import org.apache.commons.lang3.StringUtils;
21
-import org.springframework.beans.factory.annotation.Autowired;
22 21
 import org.springframework.stereotype.Service;
23 22
 
23
+import javax.annotation.Resource;
24 24
 import javax.imageio.ImageIO;
25 25
 import javax.servlet.http.HttpServletResponse;
26 26
 import java.awt.image.BufferedImage;
@@ -29,6 +29,7 @@ import java.io.IOException;
29 29
 import java.io.InputStream;
30 30
 import java.io.UnsupportedEncodingException;
31 31
 import java.net.URLEncoder;
32
+import java.nio.charset.StandardCharsets;
32 33
 import java.util.List;
33 34
 import java.util.Map;
34 35
 
@@ -39,9 +40,9 @@ import java.util.Map;
39 40
  */
40 41
 @Service
41 42
 public class ActModelService {
42
-    @Autowired
43
+    @Resource
43 44
     protected RepositoryService repositoryService;
44
-    @Autowired
45
+    @Resource
45 46
     private ObjectMapper objectMapper;
46 47
 
47 48
     public PageData<Model> page(Map<String, Object> params) {
@@ -93,7 +94,7 @@ public class ActModelService {
93 94
         ObjectNode stencilset = objectMapper.createObjectNode();
94 95
         stencilset.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
95 96
         editorNode.set("stencilset", stencilset);
96
-        repositoryService.addModelEditorSource(model.getId(), editorNode.toString().getBytes("utf-8"));
97
+        repositoryService.addModelEditorSource(model.getId(), editorNode.toString().getBytes(StandardCharsets.UTF_8));
97 98
     }
98 99
 
99 100
     public void deploy(String id) {
@@ -158,13 +159,12 @@ public class ActModelService {
158 159
         List <String> names = repositoryService.getDeploymentResourceNames(deploymentId);
159 160
         String imageName = null;
160 161
         for(String name: names){
161
-            if(name.indexOf(".png")>=0){
162
+            if(name.contains(".png")){
162 163
                 imageName = name;
163 164
                 break;
164 165
             }
165 166
         }
166 167
         InputStream in = null;
167
-        InputStream in1 = null;
168 168
         try {
169 169
             if(StringUtils.isNotEmpty(imageName)){
170 170
                 in = repositoryService.getResourceAsStream(deploymentId,imageName);

+ 44 - 45
eitc-admin/src/main/java/com/eitc/modules/activiti/service/ActProcessService.java

@@ -1,17 +1,15 @@
1 1
 package com.eitc.modules.activiti.service;
2 2
 
3
-import com.fasterxml.jackson.databind.ObjectMapper;
4
-import com.fasterxml.jackson.databind.node.ObjectNode;
5 3
 import com.eitc.common.constant.Constant;
6
-import com.eitc.common.exception.ErrorCode;
7 4
 import com.eitc.common.exception.EitcException;
5
+import com.eitc.common.exception.ErrorCode;
8 6
 import com.eitc.common.page.PageData;
7
+import com.fasterxml.jackson.databind.ObjectMapper;
8
+import com.fasterxml.jackson.databind.node.ObjectNode;
9 9
 import org.activiti.bpmn.converter.BpmnXMLConverter;
10 10
 import org.activiti.bpmn.model.BpmnModel;
11 11
 import org.activiti.editor.constants.ModelDataJsonConstants;
12 12
 import org.activiti.editor.language.json.converter.BpmnJsonConverter;
13
-import org.activiti.engine.HistoryService;
14
-import org.activiti.engine.ProcessEngineConfiguration;
15 13
 import org.activiti.engine.RepositoryService;
16 14
 import org.activiti.engine.repository.Deployment;
17 15
 import org.activiti.engine.repository.Model;
@@ -19,17 +17,17 @@ import org.activiti.engine.repository.ProcessDefinition;
19 17
 import org.activiti.engine.repository.ProcessDefinitionQuery;
20 18
 import org.apache.commons.io.FilenameUtils;
21 19
 import org.apache.commons.lang3.StringUtils;
22
-import org.springframework.beans.factory.annotation.Autowired;
23 20
 import org.springframework.stereotype.Service;
24 21
 import org.springframework.web.multipart.MultipartFile;
25 22
 
23
+import javax.annotation.Resource;
26 24
 import javax.xml.stream.XMLInputFactory;
27 25
 import javax.xml.stream.XMLStreamException;
28 26
 import javax.xml.stream.XMLStreamReader;
29 27
 import java.io.IOException;
30 28
 import java.io.InputStream;
31 29
 import java.io.InputStreamReader;
32
-import java.io.UnsupportedEncodingException;
30
+import java.nio.charset.StandardCharsets;
33 31
 import java.util.ArrayList;
34 32
 import java.util.HashMap;
35 33
 import java.util.List;
@@ -43,42 +41,36 @@ import java.util.zip.ZipInputStream;
43 41
  */
44 42
 @Service
45 43
 public class ActProcessService {
46
-    @Autowired
44
+    @Resource
47 45
     protected RepositoryService repositoryService;
48 46
 
49
-    @Autowired
50
-    protected HistoryService historyService;
51
-
52
-    @Autowired
53
-    protected ProcessEngineConfiguration processEngineConfiguration;
54
-
55 47
     /**
56 48
      * 流程列表
57 49
      */
58 50
     public PageData<Map<String, Object>> page(Map<String, Object> params) {
59
-        String key = (String)params.get("key");
60
-        String processName = (String)params.get("processName");
61
-        boolean isLatestVersion = params.get("isLatestVersion")== null? false : (boolean)params.get("isLatestVersion");
51
+        String key = (String) params.get("key");
52
+        String processName = (String) params.get("processName");
53
+        boolean isLatestVersion = params.get("isLatestVersion") != null && (boolean) params.get("isLatestVersion");
62 54
 
63 55
         //分页参数
64 56
         int curPage = 1;
65 57
         int limit = 10;
66
-        if(params.get(Constant.PAGE) != null){
67
-            curPage = Integer.parseInt((String)params.get(Constant.PAGE));
58
+        if (params.get(Constant.PAGE) != null) {
59
+            curPage = Integer.parseInt((String) params.get(Constant.PAGE));
68 60
         }
69
-        if(params.get(Constant.LIMIT) != null){
70
-            limit = Integer.parseInt((String)params.get(Constant.LIMIT));
61
+        if (params.get(Constant.LIMIT) != null) {
62
+            limit = Integer.parseInt((String) params.get(Constant.LIMIT));
71 63
         }
72 64
 
73 65
         ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
74
-            .orderByProcessDefinitionId().desc().orderByProcessDefinitionKey().desc();
75
-        if(isLatestVersion){
66
+                .orderByProcessDefinitionId().desc().orderByProcessDefinitionKey().desc();
67
+        if (isLatestVersion) {
76 68
             processDefinitionQuery.latestVersion();
77 69
         }
78
-        if(StringUtils.isNotEmpty(key)){
70
+        if (StringUtils.isNotEmpty(key)) {
79 71
             processDefinitionQuery.processDefinitionKeyLike(key);
80 72
         }
81
-        if(StringUtils.isNotEmpty(processName)){
73
+        if (StringUtils.isNotEmpty(processName)) {
82 74
             processDefinitionQuery.processDefinitionNameLike(processName);
83 75
         }
84 76
 
@@ -89,7 +81,7 @@ public class ActProcessService {
89 81
             objectList.add(processDefinitionConvert(processDefinition));
90 82
         }
91 83
 
92
-        return new PageData<>(objectList, (int)processDefinitionQuery.count());
84
+        return new PageData<>(objectList, (int) processDefinitionQuery.count());
93 85
     }
94 86
 
95 87
 
@@ -116,49 +108,56 @@ public class ActProcessService {
116 108
 
117 109
     /**
118 110
      * 部署
111
+     *
119 112
      * @param file 文件
120 113
      */
121 114
     public void deploy(MultipartFile file) throws IOException {
122 115
         String fileName = file.getOriginalFilename();
123 116
         String extension = FilenameUtils.getExtension(fileName);
124
-        if("zip".equalsIgnoreCase(extension) || "bar".equalsIgnoreCase(extension)) {
117
+        if ("zip".equalsIgnoreCase(extension) || "bar".equalsIgnoreCase(extension)) {
125 118
             ZipInputStream zip = new ZipInputStream(file.getInputStream());
126 119
             repositoryService.createDeployment().addZipInputStream(zip).deploy();
127
-        }else if(fileName.indexOf("bpmn20.xml") != -1){
128
-            repositoryService.createDeployment().addInputStream(fileName, file.getInputStream()).deploy();
129
-        }else if("bpmn".equalsIgnoreCase(extension)){
130
-            repositoryService.createDeployment().addInputStream(fileName, file.getInputStream()).deploy();
131
-        }else{
132
-            throw new EitcException(ErrorCode.ACT_DEPLOY_FORMAT_ERROR);
120
+        } else {
121
+            assert fileName != null;
122
+            if (fileName.contains("bpmn20.xml")) {
123
+                repositoryService.createDeployment().addInputStream(fileName, file.getInputStream()).deploy();
124
+            } else if ("bpmn".equalsIgnoreCase(extension)) {
125
+                repositoryService.createDeployment().addInputStream(fileName, file.getInputStream()).deploy();
126
+            } else {
127
+                throw new EitcException(ErrorCode.ACT_DEPLOY_FORMAT_ERROR);
128
+            }
133 129
         }
134 130
     }
135 131
 
136 132
     /**
137 133
      * 激活流程
134
+     *
138 135
      * @param id 流程ID
139 136
      */
140
-    public void active(String id){
137
+    public void active(String id) {
141 138
         repositoryService.activateProcessDefinitionById(id, true, null);
142 139
     }
143 140
 
144 141
     /**
145 142
      * 挂起流程
143
+     *
146 144
      * @param id 流程ID
147 145
      */
148
-    public void suspend(String id){
146
+    public void suspend(String id) {
149 147
         repositoryService.suspendProcessDefinitionById(id, true, null);
150 148
     }
151 149
 
152 150
     /**
153 151
      * 将部署的流程转换为模型
152
+     *
154 153
      * @param id 流程ID
155 154
      */
156
-    public Model convertToModel(String id) throws UnsupportedEncodingException, XMLStreamException {
155
+    public Model convertToModel(String id) throws XMLStreamException {
157 156
         ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
158 157
         InputStream bpmnStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),
159 158
                 processDefinition.getResourceName());
160 159
         XMLInputFactory xif = XMLInputFactory.newInstance();
161
-        InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
160
+        InputStreamReader in = new InputStreamReader(bpmnStream, StandardCharsets.UTF_8);
162 161
         XMLStreamReader xtr = xif.createXMLStreamReader(in);
163 162
         BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
164 163
 
@@ -169,7 +168,7 @@ public class ActProcessService {
169 168
         modelData.setName(processDefinition.getResourceName());
170 169
         modelData.setCategory(processDefinition.getCategory());
171 170
         modelData.setDeploymentId(processDefinition.getDeploymentId());
172
-        modelData.setVersion(Integer.parseInt(String.valueOf(repositoryService.createModelQuery().modelKey(modelData.getKey()).count()+1)));
171
+        modelData.setVersion(Integer.parseInt(String.valueOf(repositoryService.createModelQuery().modelKey(modelData.getKey()).count() + 1)));
173 172
 
174 173
         ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
175 174
         modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processDefinition.getName());
@@ -179,28 +178,28 @@ public class ActProcessService {
179 178
 
180 179
         repositoryService.saveModel(modelData);
181 180
 
182
-        repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8"));
181
+        repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes(StandardCharsets.UTF_8));
183 182
 
184 183
         return modelData;
185 184
     }
186 185
 
187 186
     /**
188 187
      * 删除部署
189
-     * @param deploymentId  部署ID
188
+     *
189
+     * @param deploymentId 部署ID
190 190
      */
191
-    public void deleteDeployment(String deploymentId){
191
+    public void deleteDeployment(String deploymentId) {
192 192
         repositoryService.deleteDeployment(deploymentId, true);
193 193
     }
194 194
 
195 195
     /**
196 196
      * 获取资源文件
197
-     * @param deploymentId  部署ID
197
+     *
198
+     * @param deploymentId 部署ID
198 199
      * @param resourceName 资源名称
199 200
      */
200 201
     public InputStream getResourceAsStream(String deploymentId, String resourceName) {
201
-        InputStream resourceAsStream = repositoryService.getResourceAsStream(deploymentId, resourceName);
202
-
203
-        return resourceAsStream;
202
+        return repositoryService.getResourceAsStream(deploymentId, resourceName);
204 203
     }
205 204
 
206 205
 }

+ 4 - 4
eitc-admin/src/main/java/com/eitc/modules/activiti/service/ActRunningService.java

@@ -16,9 +16,9 @@ import org.activiti.engine.impl.pvm.process.ActivityImpl;
16 16
 import org.activiti.engine.runtime.ProcessInstance;
17 17
 import org.activiti.engine.runtime.ProcessInstanceQuery;
18 18
 import org.apache.commons.lang3.StringUtils;
19
-import org.springframework.beans.factory.annotation.Autowired;
20 19
 import org.springframework.stereotype.Service;
21 20
 
21
+import javax.annotation.Resource;
22 22
 import java.util.ArrayList;
23 23
 import java.util.HashMap;
24 24
 import java.util.List;
@@ -31,13 +31,13 @@ import java.util.Map;
31 31
  */
32 32
 @Service
33 33
 public class ActRunningService {
34
-    @Autowired
34
+    @Resource
35 35
     private RuntimeService runtimeService;
36 36
 
37
-    @Autowired
37
+    @Resource
38 38
     private IdentityService identityService;
39 39
 
40
-    @Autowired
40
+    @Resource
41 41
     protected RepositoryService repositoryService;
42 42
 
43 43
     /**

+ 27 - 46
eitc-admin/src/main/java/com/eitc/modules/activiti/service/ActTaskService.java

@@ -33,10 +33,10 @@ import org.activiti.engine.task.Task;
33 33
 import org.activiti.engine.task.TaskInfo;
34 34
 import org.activiti.engine.task.TaskQuery;
35 35
 import org.apache.commons.lang3.StringUtils;
36
-import org.springframework.beans.factory.annotation.Autowired;
37 36
 import org.springframework.stereotype.Service;
38 37
 import org.springframework.transaction.annotation.Transactional;
39 38
 
39
+import javax.annotation.Resource;
40 40
 import java.util.*;
41 41
 
42 42
 /**
@@ -46,15 +46,15 @@ import java.util.*;
46 46
  */
47 47
 @Service
48 48
 public class ActTaskService extends BaseServiceImpl {
49
-    @Autowired
49
+    @Resource
50 50
     protected TaskService taskService;
51
-    @Autowired
51
+    @Resource
52 52
     protected HistoryService historyService;
53
-    @Autowired
53
+    @Resource
54 54
     protected RepositoryService repositoryService;
55
-    @Autowired
55
+    @Resource
56 56
     protected RuntimeService runtimeService;
57
-    @Autowired
57
+    @Resource
58 58
     private SysRoleUserService sysRoleUserService;
59 59
 
60 60
     /**
@@ -65,8 +65,8 @@ public class ActTaskService extends BaseServiceImpl {
65 65
      */
66 66
     public PageData<TaskDTO> page(Map<String, Object> params) {
67 67
         String userId = (String) params.get("userId");
68
-        Integer curPage = 1;
69
-        Integer limit = 10;
68
+        int curPage = 1;
69
+        int limit = 10;
70 70
         if (params.get(Constant.PAGE) != null) {
71 71
             curPage = Integer.parseInt((String) params.get(Constant.PAGE));
72 72
         }
@@ -78,7 +78,7 @@ public class ActTaskService extends BaseServiceImpl {
78 78
             taskQuery.taskAssignee(userId);
79 79
         }
80 80
         if (StringUtils.isNotEmpty((String)params.get("taskName"))){
81
-            taskQuery.taskNameLike("%"+(String)params.get("taskName")+"%");
81
+            taskQuery.taskNameLike("%"+ params.get("taskName") +"%");
82 82
         }
83 83
         if(StringUtils.isNotEmpty((String)params.get("isRoleGroup"))&&"1".equals(params.get("isRoleGroup"))){
84 84
             List<Long> listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId());
@@ -87,11 +87,7 @@ public class ActTaskService extends BaseServiceImpl {
87 87
                 listStr.add(role.toString());
88 88
             }
89 89
             listStr.add(SecurityUser.getUserId().toString());
90
-            if(!listStr.isEmpty()){
91
-                taskQuery.taskCandidateGroupIn(listStr);
92
-            } else {
93
-                return new PageData<>(new ArrayList<>(), 0);
94
-            }
90
+            taskQuery.taskCandidateGroupIn(listStr);
95 91
         }
96 92
         taskQuery.orderByTaskCreateTime().desc();
97 93
         List<Task> list = taskQuery.listPage((curPage - 1) * limit, limit);
@@ -259,10 +255,10 @@ public class ActTaskService extends BaseServiceImpl {
259 255
 
260 256
     public void deleteTaskVariable(String taskId, String variableName, String scope) {
261 257
         if (StringUtils.isNotEmpty(scope)) {
262
-            if ("global".equals(scope.toLowerCase())) {
258
+            if ("global".equalsIgnoreCase(scope)) {
263 259
                 Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
264 260
                 runtimeService.removeVariable(task.getExecutionId(), variableName);
265
-            } else if ("local".equals(scope.toLowerCase())) {
261
+            } else if ("local".equalsIgnoreCase(scope)) {
266 262
                 taskService.removeVariable(taskId, variableName);
267 263
             }
268 264
         } else {
@@ -277,7 +273,7 @@ public class ActTaskService extends BaseServiceImpl {
277 273
      */
278 274
     @Transactional(rollbackFor = Exception.class)
279 275
     public void doBackPreviousTask(String taskId, String comment) {
280
-        Map<String, Object> variables = null;
276
+        Map<String, Object> variables;
281 277
         HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
282 278
         if(this.isMultiInstance(taskId)){
283 279
             throw new EitcException(ErrorCode.BACK_PROCESS_PARALLEL_ERROR);
@@ -291,11 +287,8 @@ public class ActTaskService extends BaseServiceImpl {
291 287
         if(canBackActivitys.isEmpty()) {
292 288
             throw new EitcException(ErrorCode.SUPERIOR_NOT_EXIST);
293 289
         }
294
-        List<PvmTransition> originPvmTransitionList = new ArrayList<PvmTransition>();
295 290
         List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
296
-        for (PvmTransition pvmTransition : pvmTransitionList) {
297
-            originPvmTransitionList.add(pvmTransition);
298
-        }
291
+        List<PvmTransition> originPvmTransitionList = new ArrayList<>(pvmTransitionList);
299 292
         pvmTransitionList.clear();
300 293
         List<HistoricActivityInstance> historicActivityInstances = historyService
301 294
                 .createHistoricActivityInstanceQuery().activityType("userTask")
@@ -408,12 +401,9 @@ public class ActTaskService extends BaseServiceImpl {
408 401
             taskService.complete(taskId);
409 402
         } else {
410 403
             ActivityImpl currActivity = findActivitiImpl(taskId, null);
411
-            List<PvmTransition> oriPvmTransitionList = new ArrayList<PvmTransition>();
412
-            List<PvmTransition> pvmTransitionList = currActivity
413
-                    .getOutgoingTransitions();
414
-            for (PvmTransition pvmTransition : pvmTransitionList) {
415
-                oriPvmTransitionList.add(pvmTransition);
416
-            }
404
+            assert currActivity != null;
405
+            List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
406
+            List<PvmTransition> oriPvmTransitionList = new ArrayList<>(pvmTransitionList);
417 407
             pvmTransitionList.clear();
418 408
             TransitionImpl newTransition = currActivity.createOutgoingTransition();
419 409
             ActivityImpl pointActivity = findActivitiImpl(taskId, endActivity.getId());
@@ -425,12 +415,11 @@ public class ActTaskService extends BaseServiceImpl {
425 415
             comment = message + "["+ comment+ "]";
426 416
             taskService.addComment(task.getId(), task.getProcessInstanceId(), comment);
427 417
             taskService.complete(taskId);
418
+            assert pointActivity != null;
428 419
             pointActivity.getIncomingTransitions().remove(newTransition);
429 420
             List<PvmTransition> pvmTransitionListC = currActivity.getOutgoingTransitions();
430 421
             pvmTransitionListC.clear();
431
-            for (PvmTransition pvmTransition : oriPvmTransitionList) {
432
-                pvmTransitionListC.add(pvmTransition);
433
-            }
422
+            pvmTransitionListC.addAll(oriPvmTransitionList);
434 423
         }
435 424
 
436 425
     }
@@ -447,7 +436,7 @@ public class ActTaskService extends BaseServiceImpl {
447 436
         if (StringUtils.isEmpty(activityId)) {
448 437
             activityId = task.getTaskDefinitionKey();
449 438
         }
450
-        if ("END".equals(activityId.toUpperCase())) {
439
+        if ("END".equalsIgnoreCase(activityId)) {
451 440
             for (ActivityImpl activityImpl : processDefinition.getActivities()) {
452 441
                 String type = (String)activityImpl.getProperty("type");
453 442
                 if("endEvent".equals(type)){
@@ -455,8 +444,7 @@ public class ActTaskService extends BaseServiceImpl {
455 444
                 }
456 445
             }
457 446
         }
458
-        ActivityImpl activityImpl = processDefinition.findActivity(activityId);
459
-        return activityImpl;
447
+        return processDefinition.findActivity(activityId);
460 448
     }
461 449
 
462 450
     /**
@@ -505,17 +493,14 @@ public class ActTaskService extends BaseServiceImpl {
505 493
             throw new EitcException(ErrorCode.REJECT_PROCESS_HANDLEING_ERROR);
506 494
         }
507 495
         ActivityImpl currActivity = processDefinitionEntity.findActivity(currTask.getTaskDefinitionKey());
508
-        List<PvmTransition> originPvmTransitionList = new ArrayList<>();
509 496
         List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
510
-        for (PvmTransition pvmTransition : pvmTransitionList) {
511
-            originPvmTransitionList.add(pvmTransition);
512
-        }
497
+        List<PvmTransition> originPvmTransitionList = new ArrayList<>(pvmTransitionList);
513 498
         pvmTransitionList.clear();
514 499
         List<HistoricActivityInstance> historicActivityInstances = historyService
515 500
                 .createHistoricActivityInstanceQuery().activityType("userTask")
516 501
                 .processInstanceId(processInstance.getId())
517 502
                 .finished().orderByHistoricActivityInstanceEndTime().asc().list();
518
-        TransitionImpl transitionImpl = null;
503
+        TransitionImpl transitionImpl;
519 504
         if (historicActivityInstances.size() > 0) {
520 505
             ActivityImpl lastActivity = processDefinitionEntity.findActivity(historicActivityInstances.get(0).getActivityId());
521 506
             transitionImpl = currActivity.createOutgoingTransition();
@@ -534,18 +519,14 @@ public class ActTaskService extends BaseServiceImpl {
534 519
         }
535 520
         currActivity.getOutgoingTransitions().remove(transitionImpl);
536 521
 
537
-        for (PvmTransition pvmTransition : originPvmTransitionList) {
538
-            pvmTransitionList.add(pvmTransition);
539
-        }
522
+        pvmTransitionList.addAll(originPvmTransitionList);
540 523
     }
541 524
 
542 525
     public void completeTaskByVariables(TaskDTO taskDTO) {
543 526
         if(null != taskDTO.getParams()){
544
-            Set keySet = taskDTO.getParams().keySet();
545
-            Iterator iterator = keySet.iterator();
546
-            while(iterator.hasNext()){
547
-                String key = (String)iterator.next();
548
-                this.setTaskVariable(taskDTO.getTaskId(),key , taskDTO.getParams().get(key));
527
+            Set<String> keySet = taskDTO.getParams().keySet();
528
+            for (String key : keySet) {
529
+                this.setTaskVariable(taskDTO.getTaskId(), key, taskDTO.getParams().get(key));
549 530
             }
550 531
         }
551 532
         this.completeTask(taskDTO.getTaskId(), taskDTO.getComment());

+ 1 - 1
eitc-admin/src/main/java/com/eitc/modules/devtools/service/impl/GeneratorServiceImpl.java

@@ -196,7 +196,7 @@ public class GeneratorServiceImpl implements GeneratorService {
196 196
         //导入的包列表
197 197
         Set<String> imports = fieldTypeService.getPackageListByTableId(tableInfo.getId());
198 198
         //过滤为空的数据
199
-        imports = imports.stream().filter(i -> StringUtils.isNotBlank(i)).collect(Collectors.toSet());
199
+        imports = imports.stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet());
200 200
         dataModel.put("imports", imports);
201 201
 
202 202
         //基类

+ 7 - 7
eitc-admin/src/main/java/com/eitc/modules/message/email/EmailUtils.java

@@ -12,11 +12,11 @@ import com.eitc.modules.sys.service.SysParamsService;
12 12
 import org.apache.commons.io.IOUtils;
13 13
 import org.slf4j.Logger;
14 14
 import org.slf4j.LoggerFactory;
15
-import org.springframework.beans.factory.annotation.Autowired;
16 15
 import org.springframework.mail.javamail.JavaMailSenderImpl;
17 16
 import org.springframework.mail.javamail.MimeMessageHelper;
18 17
 import org.springframework.stereotype.Component;
19 18
 
19
+import javax.annotation.Resource;
20 20
 import javax.mail.internet.MimeMessage;
21 21
 import java.io.StringReader;
22 22
 import java.io.StringWriter;
@@ -31,12 +31,12 @@ import java.util.Properties;
31 31
 @Component
32 32
 public class EmailUtils {
33 33
 
34
-    private Logger logger = LoggerFactory.getLogger(getClass());
35
-    @Autowired
34
+    private final Logger logger = LoggerFactory.getLogger(getClass());
35
+    @Resource
36 36
     private SysParamsService sysParamsService;
37
-    @Autowired
37
+    @Resource
38 38
     private SysMailTemplateService sysMailTemplateService;
39
-    @Autowired
39
+    @Resource
40 40
     private SysMailLogService sysMailLogService;
41 41
 
42 42
     private final static String KEY = Constant.MAIL_CONFIG_KEY;
@@ -101,7 +101,7 @@ public class EmailUtils {
101 101
 
102 102
         sysMailLogService.save(templateId, config.getUsername(), to, cc, template.getSubject(), content, status);
103 103
 
104
-        return status == Constant.SUCCESS ? true : false;
104
+        return status == Constant.SUCCESS;
105 105
     }
106 106
 
107 107
     /**
@@ -166,7 +166,7 @@ public class EmailUtils {
166 166
 
167 167
         sysMailLogService.save(null, config.getUsername(), to, cc, subject, content, status);
168 168
 
169
-        return status == Constant.SUCCESS ? true : false;
169
+        return status == Constant.SUCCESS;
170 170
     }
171 171
 
172 172
 }

+ 1 - 3
eitc-admin/src/main/java/com/eitc/modules/message/sms/QcloudSmsService.java

@@ -34,9 +34,7 @@ public class QcloudSmsService extends AbstractSmsService {
34 34
         //短信参数
35 35
         ArrayList<String> paramsList = new ArrayList<>();
36 36
         if(MapUtil.isNotEmpty(params)){
37
-            for(String value : params.values()){
38
-                paramsList.add(value);
39
-            }
37
+            paramsList.addAll(params.values());
40 38
         }
41 39
         SmsSingleSenderResult result;
42 40
         try {

+ 1 - 3
eitc-admin/src/main/java/com/eitc/modules/oss/cloud/MinioCloudStorageService.java

@@ -26,9 +26,7 @@ public class MinioCloudStorageService extends AbstractCloudStorageService {
26 26
     private void init(){
27 27
         try {
28 28
             minioClient = new MinioClient(config.getMinioEndPoint(), config.getMinioAccessKey(), config.getMinioSecretKey());
29
-        } catch (InvalidEndpointException e) {
30
-            e.printStackTrace();
31
-        } catch (InvalidPortException e) {
29
+        } catch (InvalidEndpointException | InvalidPortException e) {
32 30
             e.printStackTrace();
33 31
         }
34 32
     }

+ 1 - 1
eitc-admin/src/main/java/com/eitc/modules/sys/service/impl/SysDeptServiceImpl.java

@@ -127,7 +127,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
127 127
 	private String getPidList(Long pid){
128 128
 		//顶级部门,无上级部门
129 129
 		if(Constant.DEPT_ROOT.equals(pid)){
130
-			return Constant.DEPT_ROOT + "";
130
+			return String.valueOf(Constant.DEPT_ROOT);
131 131
 		}
132 132
 
133 133
 		//所有部门的id、pid列表

+ 4 - 7
eitc-admin/src/main/java/com/eitc/modules/sys/service/impl/SysMenuServiceImpl.java

@@ -15,26 +15,23 @@ import com.eitc.modules.sys.enums.SuperAdminEnum;
15 15
 import com.eitc.modules.sys.service.SysLanguageService;
16 16
 import com.eitc.modules.sys.service.SysMenuService;
17 17
 import com.eitc.modules.sys.service.SysRoleMenuService;
18
-import org.springframework.beans.factory.annotation.Autowired;
19 18
 import org.springframework.stereotype.Service;
20 19
 import org.springframework.transaction.annotation.Transactional;
21 20
 
21
+import javax.annotation.Resource;
22 22
 import java.util.List;
23 23
 
24 24
 @Service
25 25
 public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntity> implements SysMenuService {
26
-	@Autowired
26
+	@Resource
27 27
 	private SysRoleMenuService sysRoleMenuService;
28
-	@Autowired
28
+	@Resource
29 29
 	private SysLanguageService sysLanguageService;
30 30
 
31 31
 	@Override
32 32
 	public SysMenuDTO get(Long id) {
33 33
 		SysMenuEntity entity = baseDao.getById(id, HttpContextUtils.getLanguage());
34
-
35
-		SysMenuDTO dto = ConvertUtils.sourceToTarget(entity, SysMenuDTO.class);
36
-
37
-		return dto;
34
+		return ConvertUtils.sourceToTarget(entity, SysMenuDTO.class);
38 35
 	}
39 36
 
40 37
 	@Override

+ 1 - 1
eitc-common/src/main/java/com/eitc/common/aspect/RedisAspect.java

@@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
18 18
 @Aspect
19 19
 @Component
20 20
 public class RedisAspect {
21
-    private Logger logger = LoggerFactory.getLogger(getClass());
21
+    private final Logger logger = LoggerFactory.getLogger(getClass());
22 22
     /**
23 23
      * 是否开启redis缓存  true开启   false关闭
24 24
      */

+ 1 - 1
eitc-common/src/main/java/com/eitc/common/xss/SqlFilter.java

@@ -32,7 +32,7 @@ public class SqlFilter {
32 32
 
33 33
         //判断是否包含非法字符
34 34
         for(String keyword : keywords){
35
-            if(str.indexOf(keyword) != -1){
35
+            if(str.contains(keyword)){
36 36
                 throw new EitcException(ErrorCode.INVALID_SYMBOL);
37 37
             }
38 38
         }

+ 1 - 7
eitc-dynamic-datasource/src/main/java/com/eitc/commons/dynamic/datasource/config/DynamicContextHolder.java

@@ -9,13 +9,7 @@ import java.util.Deque;
9 9
  * @author Mark eitc@163.com
10 10
  */
11 11
 public class DynamicContextHolder {
12
-    @SuppressWarnings("unchecked")
13
-    private static final ThreadLocal<Deque<String>> CONTEXT_HOLDER = new ThreadLocal() {
14
-        @Override
15
-        protected Object initialValue() {
16
-            return new ArrayDeque();
17
-        }
18
-    };
12
+    private static final ThreadLocal<Deque<String>> CONTEXT_HOLDER = ThreadLocal.withInitial(ArrayDeque::new);
19 13
 
20 14
     /**
21 15
      * 获得当前线程数据源