song 5 months ago
parent
commit
48bb6ab044

+ 14 - 22
src/main/java/com/dashitech/migration/StartApplication.java

@@ -5,12 +5,8 @@ import org.apache.commons.logging.Log;
5 5
 import org.apache.commons.logging.LogFactory;
6 6
 import org.springframework.beans.factory.annotation.Autowired;
7 7
 import org.springframework.beans.factory.annotation.Value;
8
-import org.springframework.context.ApplicationContext;
9 8
 import org.springframework.stereotype.Service;
10 9
 
11
-import java.util.List;
12
-import java.util.Map;
13
-
14 10
 /**
15 11
  * 迁移数据启动类
16 12
  * Created by CX on 2024/10/10.
@@ -29,15 +25,17 @@ public class StartApplication {
29 25
     public void start() {
30 26
         log.info("########### 开始迁移任务!###########");
31 27
         SqlTask task = null;
32
-        task = SpringContextHolder.getBean("dictionaryTask");
33
-        task.start();
34
-//        task = SpringContextHolder.getBean("attachmentTask");
35
-//        task.start();
36
-        task = SpringContextHolder.getBean("hospitalTask");
37
-        task.start();
38
-//        task = SpringContextHolder.getBean("hospitalConfigTask");
39
-//        task.start();
40
-        task = SpringContextHolder.getBean("groupTask");
28
+        //task = SpringContextHolder.getBean("dictionaryTask");
29
+        //task.start();
30
+        //task = SpringContextHolder.getBean("attachmentTask");
31
+        //task.start();
32
+        //task = SpringContextHolder.getBean("tokenTask");
33
+        //task.start();
34
+        //task = SpringContextHolder.getBean("hospitalTask");
35
+        //task.start();
36
+        task = SpringContextHolder.getBean("hospitalConfigTask");
37
+        task.start();
38
+        /*task = SpringContextHolder.getBean("groupTask");
41 39
         task.start();
42 40
         task = SpringContextHolder.getBean("departmentTask");
43 41
         task.start();
@@ -53,8 +51,8 @@ public class StartApplication {
53 51
         task.start();
54 52
         task = SpringContextHolder.getBean("incidentCategoryConfigTask");
55 53
         task.start();
56
-//        task = SpringContextHolder.getBean("incidentTask");
57
-//        task.start();
54
+        task = SpringContextHolder.getBean("incidentTask");
55
+        task.start();
58 56
         task = SpringContextHolder.getBean("workHourManagementTask");
59 57
         task.start();
60 58
         task = SpringContextHolder.getBean("solutionTask");
@@ -72,17 +70,11 @@ public class StartApplication {
72 70
         task = SpringContextHolder.getBean("callLogTask");
73 71
         task.start();
74 72
         task = SpringContextHolder.getBean("hjzxRecordTask");
75
-        task.start();
76
-
73
+        task.start();*/
77 74
 
78 75
 
79
-//        test();
80
-
81 76
         log.info("########### 迁移任务完成!###########");
82 77
     }
83 78
 
84
-    public void startOrder() {
85
-        hospitalTask.start();
86
-    }
87 79
 
88 80
 }

+ 11 - 0
src/main/java/com/dashitech/migration/task/other/AttachmentTask.java

@@ -2,11 +2,15 @@ package com.dashitech.migration.task.other;
2 2
 
3 3
 import com.dashitech.migration.BaseTask;
4 4
 import com.dashitech.migration.core.FieldMapper;
5
+import com.dashitech.migration.util.JdbcUtil;
5 6
 import org.apache.commons.logging.Log;
6 7
 import org.apache.commons.logging.LogFactory;
7 8
 import org.springframework.stereotype.Component;
8 9
 import org.springframework.transaction.annotation.Transactional;
9 10
 
11
+import java.util.List;
12
+import java.util.Map;
13
+
10 14
 /**
11 15
  * Created by CX on 2024/10/10.
12 16
  */
@@ -19,8 +23,15 @@ public class AttachmentTask extends BaseTask {
19 23
     @Transactional(rollbackFor = Exception.class)
20 24
     public void start() {
21 25
         log.info(" *** AttachmentTask start开始 *** ");
26
+        StringBuffer sql = new StringBuffer("select * from itsm_base_attachment");
27
+        List<Map<String, Object>> attachmentList = jdbcTemplateMdv2.queryForList(sql.toString());
28
+
22 29
         FieldMapper mapper = new FieldMapper();
30
+        mapper.addOperationRemove("id");
31
+        mapper.trans2JdbcRow(attachmentList);
23 32
 
33
+        JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
34
+        jdbcUtil.batchPageInsert("itsm_base_attachment", mapper.getRows());
24 35
         //clear释放内存
25 36
         mapper.clear();
26 37
     }

+ 50 - 0
src/main/java/com/dashitech/migration/task/other/TokenTask.java

@@ -0,0 +1,50 @@
1
+package com.dashitech.migration.task.other;
2
+
3
+import com.dashitech.migration.BaseTask;
4
+import com.dashitech.migration.core.FieldMapper;
5
+import com.dashitech.migration.util.JdbcUtil;
6
+import org.apache.commons.logging.Log;
7
+import org.apache.commons.logging.LogFactory;
8
+import org.springframework.stereotype.Component;
9
+import org.springframework.transaction.annotation.Transactional;
10
+
11
+import java.util.List;
12
+import java.util.Map;
13
+
14
+/**
15
+ * Created by CX on 2024/10/10.
16
+ */
17
+@Component
18
+public class TokenTask extends BaseTask {
19
+
20
+    public static Log log = LogFactory.getLog(TokenTask.class);
21
+
22
+    @Override
23
+    @Transactional(rollbackFor = Exception.class)
24
+    public void start() {
25
+        log.info(" *** TokenTask start开始 *** ");
26
+        StringBuffer sql = new StringBuffer("select * from itsm_base_token");
27
+        List<Map<String, Object>> tokenList = jdbcTemplateMdv2.queryForList(sql.toString());
28
+
29
+        FieldMapper mapper = new FieldMapper();
30
+        mapper.addOperationRemove("id");
31
+        mapper.trans2JdbcRow(tokenList);
32
+
33
+        JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
34
+        jdbcUtil.batchPageInsert("itsm_base_token", mapper.getRows());
35
+
36
+        //clear释放内存
37
+        mapper.clear();
38
+    }
39
+
40
+    @Override
41
+    public FieldMapper loadCache() {
42
+        log.info(" *** AttachmentTask loadCache开始 *** ");
43
+        FieldMapper mapper = new FieldMapper();
44
+
45
+
46
+        return mapper;
47
+    }
48
+
49
+
50
+}

+ 1 - 1
src/main/java/com/dashitech/migration/task/solution/SolutionIntroduceTask.java

@@ -30,7 +30,7 @@ public class SolutionIntroduceTask extends BaseTask {
30 30
     public void start() {
31 31
         log.info("知识库引用数据SolutionIntroduceTask转换开始");
32 32
 
33
-        StringBuffer sql = new StringBuffer("select * from itsm_itsm_solution_introduce");
33
+        StringBuffer sql = new StringBuffer("select * from itsm_solution_introduce");
34 34
         List<Map<String, Object>> solutionStarList = jdbcTemplateMdv2.queryForList(sql.toString());
35 35
         FieldMapper mapper = new FieldMapper();
36 36
         Map<Long, Long> userIdCache = userTask.loadCache().getIdCache();

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/CompanyTask.java

@@ -8,7 +8,6 @@ import com.dashitech.migration.util.JdbcUtil;
8 8
 import org.apache.commons.logging.Log;
9 9
 import org.apache.commons.logging.LogFactory;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11
-import org.springframework.core.annotation.Order;
12 11
 import org.springframework.stereotype.Component;
13 12
 import org.springframework.transaction.annotation.Transactional;
14 13
 
@@ -19,7 +18,6 @@ import java.util.Map;
19 18
  * Created by CX on 2024/10/10.
20 19
  */
21 20
 @Component
22
-@Order(3)
23 21
 public class CompanyTask extends BaseTask {
24 22
 
25 23
     public static Log log = LogFactory.getLog(CompanyTask.class);

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/DepartmentTask.java

@@ -7,7 +7,6 @@ import com.dashitech.migration.core.RowsWrap;
7 7
 import com.dashitech.migration.util.JdbcUtil;
8 8
 import org.apache.commons.logging.Log;
9 9
 import org.apache.commons.logging.LogFactory;
10
-import org.springframework.core.annotation.Order;
11 10
 import org.springframework.stereotype.Component;
12 11
 import org.springframework.transaction.annotation.Transactional;
13 12
 
@@ -19,7 +18,6 @@ import java.util.Map;
19 18
  * @date 2024年10月12日
20 19
  */
21 20
 @Component
22
-@Order(3)
23 21
 public class DepartmentTask extends BaseTask {
24 22
 
25 23
     public static Log log = LogFactory.getLog(DepartmentTask.class);

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/GroupTask.java

@@ -8,7 +8,6 @@ import com.dashitech.migration.util.JdbcUtil;
8 8
 import org.apache.commons.logging.Log;
9 9
 import org.apache.commons.logging.LogFactory;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11
-import org.springframework.core.annotation.Order;
12 11
 import org.springframework.stereotype.Component;
13 12
 import org.springframework.transaction.annotation.Transactional;
14 13
 
@@ -19,7 +18,6 @@ import java.util.Map;
19 18
  * Created by CX on 2024/10/10.
20 19
  */
21 20
 @Component
22
-@Order(2)
23 21
 public class GroupTask extends BaseTask {
24 22
 
25 23
     public static Log log = LogFactory.getLog(GroupTask.class);

+ 11 - 4
src/main/java/com/dashitech/migration/task/uc/HospitalConfigTask.java

@@ -1,24 +1,21 @@
1 1
 package com.dashitech.migration.task.uc;
2 2
 
3 3
 import com.dashitech.migration.BaseTask;
4
-import com.dashitech.migration.core.DataMigrationter;
5 4
 import com.dashitech.migration.core.FieldMapper;
6 5
 import com.dashitech.migration.util.JdbcUtil;
7 6
 import org.apache.commons.logging.Log;
8 7
 import org.apache.commons.logging.LogFactory;
9
-import org.springframework.core.annotation.Order;
10 8
 import org.springframework.stereotype.Component;
11 9
 import org.springframework.transaction.annotation.Transactional;
12 10
 
13
-import java.util.HashMap;
14 11
 import java.util.List;
15 12
 import java.util.Map;
16 13
 
17 14
 /**
15
+ * 必须在HospitalTask转后执行
18 16
  * Created by CX on 2024/10/10.
19 17
  */
20 18
 @Component
21
-@Order(1)
22 19
 public class HospitalConfigTask extends BaseTask {
23 20
 
24 21
     public static Log log = LogFactory.getLog(HospitalConfigTask.class);
@@ -27,7 +24,17 @@ public class HospitalConfigTask extends BaseTask {
27 24
     @Transactional(rollbackFor = Exception.class)
28 25
     public void start() {
29 26
         log.info(" *** HospitalConfigTask start开始 *** ");
27
+        //查询维修科室 院区和院区配置def表笛卡尔积数据
28
+        StringBuffer sql = new StringBuffer("SELECT 0 AS version,b._key,b._value,b._value2,b._value3,");
29
+        sql.append("b._value4,b._desc,b._orders,b._active,b.id AS def_id,a.id AS hos_id, b.model as model");
30
+        sql.append(" FROM itsm_uc_hospital a JOIN itsm_system_hospital_config_def b where a.delete_flag = 0 ");
31
+        sql.append(" and a.type = (select id from itsm_base_dictionary where _key = 'hospital_type' and _value = '6') ");
32
+        List<Map<String, Object>> hosConfigList = jdbcTemplateHsms.queryForList(sql.toString());
30 33
         FieldMapper mapper = new FieldMapper();
34
+        mapper.trans2JdbcRow(hosConfigList);
35
+
36
+        JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
37
+        jdbcUtil.batchPageInsert("itsm_system_hospital_config", mapper.getRows());
31 38
 
32 39
         //clear释放内存
33 40
         mapper.clear();

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/HospitalTask.java

@@ -6,7 +6,6 @@ import com.dashitech.migration.core.FieldMapper;
6 6
 import com.dashitech.migration.util.JdbcUtil;
7 7
 import org.apache.commons.logging.Log;
8 8
 import org.apache.commons.logging.LogFactory;
9
-import org.springframework.core.annotation.Order;
10 9
 import org.springframework.stereotype.Component;
11 10
 import org.springframework.transaction.annotation.Transactional;
12 11
 
@@ -18,7 +17,6 @@ import java.util.Map;
18 17
  * Created by CX on 2024/10/10.
19 18
  */
20 19
 @Component
21
-@Order(1)
22 20
 public class HospitalTask extends BaseTask {
23 21
 
24 22
     public static Log log = LogFactory.getLog(HospitalTask.class);

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/RoleUserTask.java

@@ -7,7 +7,6 @@ import com.dashitech.migration.util.JdbcUtil;
7 7
 import org.apache.commons.logging.Log;
8 8
 import org.apache.commons.logging.LogFactory;
9 9
 import org.springframework.beans.factory.annotation.Autowired;
10
-import org.springframework.core.annotation.Order;
11 10
 import org.springframework.stereotype.Component;
12 11
 import org.springframework.transaction.annotation.Transactional;
13 12
 
@@ -17,7 +16,6 @@ import java.util.List;
17 16
  * Created by CX on 2024/10/10.
18 17
  */
19 18
 @Component
20
-@Order(6)
21 19
 public class RoleUserTask extends BaseTask {
22 20
 
23 21
     public static Log log = LogFactory.getLog(RoleUserTask.class);

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/UserGroupTask.java

@@ -7,7 +7,6 @@ import com.dashitech.migration.util.JdbcUtil;
7 7
 import org.apache.commons.logging.Log;
8 8
 import org.apache.commons.logging.LogFactory;
9 9
 import org.springframework.beans.factory.annotation.Autowired;
10
-import org.springframework.core.annotation.Order;
11 10
 import org.springframework.stereotype.Component;
12 11
 import org.springframework.transaction.annotation.Transactional;
13 12
 
@@ -17,7 +16,6 @@ import java.util.List;
17 16
  * Created by CX on 2024/10/10.
18 17
  */
19 18
 @Component
20
-@Order(5)
21 19
 public class UserGroupTask extends BaseTask {
22 20
 
23 21
     @Autowired

+ 0 - 2
src/main/java/com/dashitech/migration/task/uc/UserTask.java

@@ -9,7 +9,6 @@ import com.dashitech.migration.util.JdbcUtil;
9 9
 import org.apache.commons.logging.Log;
10 10
 import org.apache.commons.logging.LogFactory;
11 11
 import org.springframework.beans.factory.annotation.Autowired;
12
-import org.springframework.core.annotation.Order;
13 12
 import org.springframework.stereotype.Component;
14 13
 import org.springframework.transaction.annotation.Transactional;
15 14
 
@@ -20,7 +19,6 @@ import java.util.Map;
20 19
  * Created by CX on 2024/10/10.
21 20
  */
22 21
 @Component
23
-@Order(4)
24 22
 public class UserTask extends BaseTask {
25 23
 
26 24
     @Autowired