|
@@ -1,12 +1,17 @@
|
1
|
1
|
package com.dashitech.migration.task.uc;
|
2
|
2
|
|
3
|
3
|
import com.dashitech.migration.BaseTask;
|
|
4
|
+import com.dashitech.migration.SqlTask;
|
4
|
5
|
import com.dashitech.migration.core.FieldMapper;
|
|
6
|
+import com.dashitech.migration.util.JdbcUtil;
|
5
|
7
|
import org.apache.commons.logging.Log;
|
6
|
8
|
import org.apache.commons.logging.LogFactory;
|
|
9
|
+import org.springframework.beans.factory.annotation.Autowired;
|
7
|
10
|
import org.springframework.stereotype.Component;
|
8
|
11
|
import org.springframework.transaction.annotation.Transactional;
|
9
|
12
|
|
|
13
|
+import java.util.List;
|
|
14
|
+
|
10
|
15
|
/**
|
11
|
16
|
* Created by CX on 2024/10/10.
|
12
|
17
|
*/
|
|
@@ -15,20 +20,40 @@ public class RoleTask extends BaseTask {
|
15
|
20
|
|
16
|
21
|
public static Log log = LogFactory.getLog(RoleTask.class);
|
17
|
22
|
|
|
23
|
+ @Autowired
|
|
24
|
+ SqlTask userTask;
|
|
25
|
+
|
18
|
26
|
@Override
|
19
|
27
|
@Transactional
|
20
|
28
|
public void start() {
|
|
29
|
+ log.info(" *** 加载角色Role缓存 *** ");
|
21
|
30
|
|
22
|
|
- }
|
|
31
|
+ StringBuffer sb = new StringBuffer();
|
|
32
|
+ //只拿运维人员
|
|
33
|
+ sb.append(" SELECT id as 'user_id' from itsm_uc_user where ACCOUNT != 'dsadmin' and delete_flag = 0 ");
|
23
|
34
|
|
24
|
|
- @Override
|
25
|
|
- public FieldMapper loadCache() {
|
26
|
|
- log.info(" *** 加载角色Role缓存 *** ");
|
|
35
|
+ Object roleId = getSingleObj(jdbcTemplateHsms," SELECT id from itsm_uc_role WHERE rolecode = 'first-line support' ");
|
|
36
|
+
|
|
37
|
+ List list = jdbcTemplateMdv2.queryForList(sb.toString());
|
27
|
38
|
|
28
|
39
|
FieldMapper mapper = new FieldMapper();
|
|
40
|
+ FieldMapper userMapper = userTask.loadCache();
|
|
41
|
+ mapper.addOperationAdd("role_id", Long.valueOf(roleId.toString()));
|
|
42
|
+ mapper.addOperationReplace("user_id", userMapper.getIdCache());
|
|
43
|
+ mapper.trans2JdbcRow(list);
|
|
44
|
+
|
|
45
|
+ JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
|
|
46
|
+ jdbcUtil.batchPageInsert("itsm_uc_user_role", mapper.getRows());
|
29
|
47
|
|
|
48
|
+ //clear释放内存
|
|
49
|
+ mapper.clear();
|
|
50
|
+ userMapper.clear();
|
|
51
|
+ }
|
30
|
52
|
|
|
53
|
+ @Override
|
|
54
|
+ public FieldMapper loadCache() {
|
|
55
|
+ log.info(" *** 加载角色Role缓存 *** ");
|
31
|
56
|
|
32
|
|
- return mapper;
|
|
57
|
+ return null;
|
33
|
58
|
}
|
34
|
59
|
}
|