CX 6 月之前
父节点
当前提交
d0ea7cea38

+ 8 - 10
src/main/java/com/dashitech/migration/StartApplication.java

@@ -1,5 +1,7 @@
1
 package com.dashitech.migration;
1
 package com.dashitech.migration;
2
 
2
 
3
+import com.dashitech.migration.core.FieldMapper;
4
+import com.dashitech.migration.task.uc.CompanyTask;
3
 import com.dashitech.migration.task.uc.HospitalTask;
5
 import com.dashitech.migration.task.uc.HospitalTask;
4
 import com.dashitech.migration.task.uc.XyGroupTask;
6
 import com.dashitech.migration.task.uc.XyGroupTask;
5
 import org.apache.commons.logging.Log;
7
 import org.apache.commons.logging.Log;
@@ -19,15 +21,14 @@ public class StartApplication {
19
 
21
 
20
     @Autowired
22
     @Autowired
21
     SqlTask groupTask;
23
     SqlTask groupTask;
22
-
23
     @Autowired
24
     @Autowired
24
     SqlTask userTask;
25
     SqlTask userTask;
25
-
26
     @Autowired
26
     @Autowired
27
     HospitalTask hospitalTask;
27
     HospitalTask hospitalTask;
28
-
29
     @Autowired
28
     @Autowired
30
     XyGroupTask xyGroupTask;
29
     XyGroupTask xyGroupTask;
30
+    @Autowired
31
+    CompanyTask companyTask;
31
 
32
 
32
     @Value("${application.name}")
33
     @Value("${application.name}")
33
     private String appName;
34
     private String appName;
@@ -41,16 +42,13 @@ public class StartApplication {
41
             //工作组
42
             //工作组
42
             //xyGroupTask.start();
43
             //xyGroupTask.start();
43
         } else {
44
         } else {
44
-            //工作组
45
-            groupTask.start();
46
-        }
47
-
48
 
45
 
46
+            companyTask.start();
47
+            FieldMapper mapper = companyTask.loadCache();
49
 
48
 
49
+            System.out.println(mapper);
50
+        }
50
 
51
 
51
-        userTask.start();
52
-
53
-        groupTask.loadCache();
54
 
52
 
55
         log.info("########### 迁移任务完成!###########");
53
         log.info("########### 迁移任务完成!###########");
56
     }
54
     }

+ 13 - 3
src/main/java/com/dashitech/migration/task/other/DictionaryTask.java

@@ -25,7 +25,13 @@ public class DictionaryTask extends BaseTask {
25
 
25
 
26
     @Override
26
     @Override
27
     public FieldMapper loadCache() {
27
     public FieldMapper loadCache() {
28
-        return null;
28
+        FieldMapper mapper = null;
29
+        if ("xiangyang".equals(appName)) {
30
+            mapper = loadXiangYangCache();
31
+        } else {
32
+            mapper = loadNanJingCache();
33
+        }
34
+        return mapper;
29
     }
35
     }
30
 
36
 
31
 
37
 
@@ -46,8 +52,12 @@ public class DictionaryTask extends BaseTask {
46
     public FieldMapper loadNanJingCache() {
52
     public FieldMapper loadNanJingCache() {
47
         log.info(" *** 加载南京字典缓存 *** ");
53
         log.info(" *** 加载南京字典缓存 *** ");
48
         FieldMapper mapper = new FieldMapper();
54
         FieldMapper mapper = new FieldMapper();
49
-        Map<Long, Long> dicIdCache = new HashMap<>();
50
-        mapper.setIdCache(dicIdCache);
55
+        Map<Long, Long> idCache = new HashMap<>();
56
+        mapper.setIdCache(idCache);
57
+
58
+        //公司分类
59
+        idCache.put(1709L,20309L);
60
+        idCache.put(1710L,20311L);
51
 
61
 
52
 
62
 
53
         return mapper;
63
         return mapper;

+ 24 - 9
src/main/java/com/dashitech/migration/task/uc/CompanyTask.java

@@ -4,6 +4,7 @@ import com.dashitech.migration.BaseTask;
4
 import com.dashitech.migration.SqlTask;
4
 import com.dashitech.migration.SqlTask;
5
 import com.dashitech.migration.core.DataMigrationter;
5
 import com.dashitech.migration.core.DataMigrationter;
6
 import com.dashitech.migration.core.FieldMapper;
6
 import com.dashitech.migration.core.FieldMapper;
7
+import com.dashitech.migration.task.other.DictionaryTask;
7
 import com.dashitech.migration.util.JdbcUtil;
8
 import com.dashitech.migration.util.JdbcUtil;
8
 import org.apache.commons.logging.Log;
9
 import org.apache.commons.logging.Log;
9
 import org.apache.commons.logging.LogFactory;
10
 import org.apache.commons.logging.LogFactory;
@@ -24,26 +25,31 @@ public class CompanyTask extends BaseTask {
24
 
25
 
25
     @Autowired
26
     @Autowired
26
     SqlTask hospitalTask;
27
     SqlTask hospitalTask;
28
+    @Autowired
29
+    SqlTask dictionaryTask;
30
+
27
 
31
 
28
     @Override
32
     @Override
29
     @Transactional
33
     @Transactional
30
     public void start() {
34
     public void start() {
35
+        log.info(" *** 三方公司CompanyTask转换开始 *** ");
36
+
31
         StringBuffer sb = new StringBuffer();
37
         StringBuffer sb = new StringBuffer();
32
-        sb.append(" select * from itsm_uc_groups ");
38
+        sb.append(" select name,contacts,mphone,service_type_ids as 'company_type_ids', ");
39
+        sb.append(" delete_flag,add_time,branch_id as 'hos_id' ");
40
+        sb.append(" from itsm_uc_company ");
33
 
41
 
34
         List list = jdbcTemplateMdv2.queryForList(sb.toString());
42
         List list = jdbcTemplateMdv2.queryForList(sb.toString());
35
 
43
 
36
-        //测试
37
         FieldMapper mapper = new FieldMapper();
44
         FieldMapper mapper = new FieldMapper();
38
-        mapper.addOperationRemove("id").addOperationRemove("duty_id");
39
-        mapper.addOperationUpdate("_hospital_id", "branch_id");
40
-        mapper.addOperationAdd("type", 3);
45
+        mapper.addOperationAdd("busi_type", 20312L); //公司业务类型-医废
41
         Map<Long, Long> hosIdCache = hospitalTask.loadCache().getIdCache();
46
         Map<Long, Long> hosIdCache = hospitalTask.loadCache().getIdCache();
42
-        mapper.addOperationReplace("branch_id", hosIdCache);
47
+        mapper.addOperationReplace("hos_id", hosIdCache);
48
+        mapper.addOperationReplace("company_type_ids", dictionaryTask.loadCache().getIdCache());
43
         mapper.trans2JdbcRow(list);
49
         mapper.trans2JdbcRow(list);
44
 
50
 
45
         JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
51
         JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
46
-        jdbcUtil.batchPageInsert("itsm_uc_groups", mapper.getRows());
52
+        jdbcUtil.batchPageInsert("itsm_uc_company", mapper.getRows());
47
 
53
 
48
         //clear释放内存
54
         //clear释放内存
49
         mapper.clear();
55
         mapper.clear();
@@ -51,10 +57,19 @@ public class CompanyTask extends BaseTask {
51
 
57
 
52
     @Override
58
     @Override
53
     public FieldMapper loadCache() {
59
     public FieldMapper loadCache() {
54
-        log.info(" *** 加载请求人Requesterl缓存 *** ");
60
+        log.info(" *** 加载三方公司CompanyTask缓存 *** ");
55
 
61
 
62
+        String sql = " select id,name,delete_flag from itsm_uc_company ";
63
+        List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
64
+        sql = " select id,name,delete_flag from itsm_uc_company ";
65
+        List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
66
+
67
+        FieldMapper mapper = new FieldMapper();
68
+        mapper.addFieldMapper("name", "name");
69
+        mapper.addFieldMapper("delete_flag", "delete_flag");
56
 
70
 
71
+        DataMigrationter.loadCache(list, list2, mapper);
57
 
72
 
58
-        return null;
73
+        return mapper;
59
     }
74
     }
60
 }
75
 }

+ 6 - 1
src/main/java/com/dashitech/migration/task/uc/HospitalTask.java

@@ -41,7 +41,12 @@ public class HospitalTask extends BaseTask {
41
     public FieldMapper loadCache() {
41
     public FieldMapper loadCache() {
42
         log.info(" *** 加载院区Hospital缓存 *** ");
42
         log.info(" *** 加载院区Hospital缓存 *** ");
43
 
43
 
44
-        FieldMapper mapper = loadNanjingCache();
44
+        FieldMapper mapper = null;
45
+        if ("xiangyang".equals(appName)) {
46
+            mapper = loadXiangyangCache();
47
+        } else {
48
+            mapper = loadNanjingCache();
49
+        }
45
 
50
 
46
         return mapper;
51
         return mapper;
47
     }
52
     }

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

@@ -38,13 +38,8 @@ public class UserTask extends BaseTask {
38
         List list = jdbcTemplateHsms.queryForList(sb.toString());
38
         List list = jdbcTemplateHsms.queryForList(sb.toString());
39
 
39
 
40
         FieldMapper groupMapper = groupTask.loadCache();
40
         FieldMapper groupMapper = groupTask.loadCache();
41
-        Map<Long, Long> hosIdCache = null;
42
-        if ("xiangyang".equals(appName)) {
43
-            hosIdCache = hospitalTask.loadXiangyangCache().getIdCache();
44
-        } else {
45
-            hosIdCache = hospitalTask.loadNanjingCache().getIdCache();
46
-        }
47
-        System.out.println(groupMapper.getIdCache());
41
+        Map<Long, Long> hosIdCache = hospitalTask.loadXiangyangCache().getIdCache();
42
+        System.out.println(hosIdCache);
48
 
43
 
49
 
44
 
50
     }
45
     }