CX 6 ay önce
ebeveyn
işleme
fda83a90df

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

@@ -25,17 +25,17 @@ public class StartApplication {
25 25
     public void start() {
26 26
         log.info("########### 开始迁移任务!###########");
27 27
         SqlTask task = null;
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();
28
+        task = SpringContextHolder.getBean("dictionaryTask");
29
+        task.start();
30
+        task = SpringContextHolder.getBean("tokenTask");
31
+        task.start();
32
+        task = SpringContextHolder.getBean("attachmentTask");
33
+        task.start();
34
+        task = SpringContextHolder.getBean("hospitalTask");
35
+        task.start();
36 36
         task = SpringContextHolder.getBean("hospitalConfigTask");
37 37
         task.start();
38
-        /*task = SpringContextHolder.getBean("groupTask");
38
+        task = SpringContextHolder.getBean("groupTask");
39 39
         task.start();
40 40
         task = SpringContextHolder.getBean("departmentTask");
41 41
         task.start();
@@ -70,7 +70,7 @@ public class StartApplication {
70 70
         task = SpringContextHolder.getBean("callLogTask");
71 71
         task.start();
72 72
         task = SpringContextHolder.getBean("hjzxRecordTask");
73
-        task.start();*/
73
+        task.start();
74 74
 
75 75
 
76 76
         log.info("########### 迁移任务完成!###########");

+ 1 - 1
src/main/java/com/dashitech/migration/task/consumable/ConsumableHistoryTask.java

@@ -44,7 +44,7 @@ public class ConsumableHistoryTask extends BaseTask {
44 44
         if ("xiangyang".equals(appName)) {
45 45
             sql.append("if(repair_duty=4,10,repair_duty) as repair_duty,IF(branch_id=4,3,branch_id) as hos_id ");
46 46
         } else {
47
-            sql.append("repair_duty,hos_id ");
47
+            sql.append("repair_duty,branch_id as 'hos_id' ");
48 48
         }
49 49
         sql.append(" FROM itsm_asset_consumables_history ");
50 50
         List<Map<String, Object>> consumableHistoryList = jdbcTemplateMdv2.queryForList(sql.toString());

+ 72 - 0
src/main/java/com/dashitech/migration/task/incident/IncidentAssignManagerTask.java

@@ -0,0 +1,72 @@
1
+package com.dashitech.migration.task.incident;
2
+
3
+import com.dashitech.migration.BaseTask;
4
+import com.dashitech.migration.SqlTask;
5
+import com.dashitech.migration.core.DataMigrationter;
6
+import com.dashitech.migration.core.FieldMapper;
7
+import com.dashitech.migration.util.JdbcUtil;
8
+import org.apache.commons.logging.Log;
9
+import org.apache.commons.logging.LogFactory;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.core.annotation.Order;
12
+import org.springframework.stereotype.Component;
13
+import org.springframework.transaction.annotation.Transactional;
14
+
15
+import java.util.List;
16
+import java.util.Map;
17
+
18
+/**
19
+ * Created by CX on 2024/10/10.
20
+ */
21
+@Component
22
+public class IncidentAssignManagerTask extends BaseTask {
23
+
24
+    @Autowired
25
+    SqlTask hospitalTask;
26
+
27
+    @Autowired
28
+    SqlTask departmentTask;
29
+
30
+    public static Log log = LogFactory.getLog(IncidentAssignManagerTask.class);
31
+
32
+    @Override
33
+    @Transactional(rollbackFor = Exception.class)
34
+    public void start() {
35
+        log.info(" *** IncidentAssignManagerTask start 开始 *** ");
36
+
37
+        StringBuffer sb = new StringBuffer();
38
+        sb.append(" select * from itsm_incident ");
39
+
40
+        List list = jdbcTemplateMdv2.queryForList(sb.toString());
41
+
42
+        FieldMapper mapper = new FieldMapper();
43
+        mapper.addOperationRemove("id").addOperationRemove("version");
44
+        mapper.trans2JdbcRow(list);
45
+
46
+        FieldMapper userMapper = loadCache();
47
+        JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
48
+        jdbcUtil.batchPageInsert("itsm_itsm_incident", mapper.getRows());
49
+
50
+        //clear释放内存
51
+        mapper.clear();
52
+        userMapper.clear();
53
+    }
54
+
55
+    @Override
56
+    public FieldMapper loadCache() {
57
+        log.info(" *** IncidentAssignManagerTask loadCache 开始 *** ");
58
+
59
+        String sql = " select id,ACCOUNT,delete_flag from itsm_incident ";
60
+        List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
61
+        sql = " select id,ACCOUNT,delete_flag from itsm_itsm_incident ";
62
+        List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
63
+
64
+        FieldMapper mapper = new FieldMapper();
65
+        mapper.addFieldMapper("ACCOUNT", "ACCOUNT");
66
+        mapper.addFieldMapper("delete_flag", "delete_flag");
67
+
68
+        DataMigrationter.loadCache(list, list2, mapper);
69
+
70
+        return mapper;
71
+    }
72
+}

+ 72 - 0
src/main/java/com/dashitech/migration/task/incident/IncidentLogTask.java

@@ -0,0 +1,72 @@
1
+package com.dashitech.migration.task.incident;
2
+
3
+import com.dashitech.migration.BaseTask;
4
+import com.dashitech.migration.SqlTask;
5
+import com.dashitech.migration.core.DataMigrationter;
6
+import com.dashitech.migration.core.FieldMapper;
7
+import com.dashitech.migration.util.JdbcUtil;
8
+import org.apache.commons.logging.Log;
9
+import org.apache.commons.logging.LogFactory;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.core.annotation.Order;
12
+import org.springframework.stereotype.Component;
13
+import org.springframework.transaction.annotation.Transactional;
14
+
15
+import java.util.List;
16
+import java.util.Map;
17
+
18
+/**
19
+ * Created by CX on 2024/10/10.
20
+ */
21
+@Component
22
+public class IncidentLogTask extends BaseTask {
23
+
24
+    @Autowired
25
+    SqlTask hospitalTask;
26
+
27
+    @Autowired
28
+    SqlTask departmentTask;
29
+
30
+    public static Log log = LogFactory.getLog(IncidentLogTask.class);
31
+
32
+    @Override
33
+    @Transactional(rollbackFor = Exception.class)
34
+    public void start() {
35
+        log.info(" *** IncidentLogTask start 开始 *** ");
36
+
37
+        StringBuffer sb = new StringBuffer();
38
+        sb.append(" select * from itsm_incident ");
39
+
40
+        List list = jdbcTemplateMdv2.queryForList(sb.toString());
41
+
42
+        FieldMapper mapper = new FieldMapper();
43
+        mapper.addOperationRemove("id").addOperationRemove("version");
44
+        mapper.trans2JdbcRow(list);
45
+
46
+        FieldMapper userMapper = loadCache();
47
+        JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
48
+        jdbcUtil.batchPageInsert("itsm_itsm_incident", mapper.getRows());
49
+
50
+        //clear释放内存
51
+        mapper.clear();
52
+        userMapper.clear();
53
+    }
54
+
55
+    @Override
56
+    public FieldMapper loadCache() {
57
+        log.info(" *** IncidentLogTask loadCache 开始 *** ");
58
+
59
+        String sql = " select id,ACCOUNT,delete_flag from itsm_incident ";
60
+        List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
61
+        sql = " select id,ACCOUNT,delete_flag from itsm_itsm_incident ";
62
+        List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
63
+
64
+        FieldMapper mapper = new FieldMapper();
65
+        mapper.addFieldMapper("ACCOUNT", "ACCOUNT");
66
+        mapper.addFieldMapper("delete_flag", "delete_flag");
67
+
68
+        DataMigrationter.loadCache(list, list2, mapper);
69
+
70
+        return mapper;
71
+    }
72
+}

+ 72 - 0
src/main/java/com/dashitech/migration/task/incident/IncidentSynergeticTask.java

@@ -0,0 +1,72 @@
1
+package com.dashitech.migration.task.incident;
2
+
3
+import com.dashitech.migration.BaseTask;
4
+import com.dashitech.migration.SqlTask;
5
+import com.dashitech.migration.core.DataMigrationter;
6
+import com.dashitech.migration.core.FieldMapper;
7
+import com.dashitech.migration.util.JdbcUtil;
8
+import org.apache.commons.logging.Log;
9
+import org.apache.commons.logging.LogFactory;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.core.annotation.Order;
12
+import org.springframework.stereotype.Component;
13
+import org.springframework.transaction.annotation.Transactional;
14
+
15
+import java.util.List;
16
+import java.util.Map;
17
+
18
+/**
19
+ * Created by CX on 2024/10/10.
20
+ */
21
+@Component
22
+public class IncidentSynergeticTask extends BaseTask {
23
+
24
+    @Autowired
25
+    SqlTask hospitalTask;
26
+
27
+    @Autowired
28
+    SqlTask departmentTask;
29
+
30
+    public static Log log = LogFactory.getLog(IncidentSynergeticTask.class);
31
+
32
+    @Override
33
+    @Transactional(rollbackFor = Exception.class)
34
+    public void start() {
35
+        log.info(" *** IncidentSynergeticTask start 开始 *** ");
36
+
37
+        StringBuffer sb = new StringBuffer();
38
+        sb.append(" select * from itsm_incident ");
39
+
40
+        List list = jdbcTemplateMdv2.queryForList(sb.toString());
41
+
42
+        FieldMapper mapper = new FieldMapper();
43
+        mapper.addOperationRemove("id").addOperationRemove("version");
44
+        mapper.trans2JdbcRow(list);
45
+
46
+        FieldMapper userMapper = loadCache();
47
+        JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
48
+        jdbcUtil.batchPageInsert("itsm_itsm_incident", mapper.getRows());
49
+
50
+        //clear释放内存
51
+        mapper.clear();
52
+        userMapper.clear();
53
+    }
54
+
55
+    @Override
56
+    public FieldMapper loadCache() {
57
+        log.info(" *** IncidentSynergeticTask loadCache 开始 *** ");
58
+
59
+        String sql = " select id,ACCOUNT,delete_flag from itsm_incident ";
60
+        List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
61
+        sql = " select id,ACCOUNT,delete_flag from itsm_itsm_incident ";
62
+        List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
63
+
64
+        FieldMapper mapper = new FieldMapper();
65
+        mapper.addFieldMapper("ACCOUNT", "ACCOUNT");
66
+        mapper.addFieldMapper("delete_flag", "delete_flag");
67
+
68
+        DataMigrationter.loadCache(list, list2, mapper);
69
+
70
+        return mapper;
71
+    }
72
+}

+ 28 - 20
src/main/java/com/dashitech/migration/task/incident/IncidentTask.java

@@ -27,56 +27,64 @@ public class IncidentTask extends BaseTask {
27 27
     SqlTask hospitalTask;
28 28
 
29 29
     @Autowired
30
+    SqlTask userTask;
31
+
32
+    @Autowired
30 33
     SqlTask departmentTask;
31 34
 
35
+    @Autowired
36
+    SqlTask incidentCategoryTask;
37
+
32 38
     public static Log log = LogFactory.getLog(IncidentTask.class);
33 39
 
34 40
     @Override
35 41
     @Transactional(rollbackFor = Exception.class)
36 42
     public void start() {
37
-        log.info(" *** DepartmentTask start 开始 *** ");
43
+        log.info(" *** IncidentTask start 开始 *** ");
38 44
 
39 45
         StringBuffer sb = new StringBuffer();
40
-        sb.append(" select version,ACCOUNT,GENDER,NAME,PHONE,PWD,WEIXIN,DEPTID,delete_flag, ");
41
-        sb.append(" pinyin,py as 'input_code',online,branch_id as 'hospital_id', ");
42
-        sb.append(" duty_id as 'duty_dept',company as 'company_id',engineer ");
43
-        sb.append(" from itsm_uc_user ");
44
-        sb.append(" where ACCOUNT != 'dsadmin' ");
46
+        sb.append(" select * from itsm_incident limit 0,1000 ");
45 47
 
46 48
         List list = jdbcTemplateMdv2.queryForList(sb.toString());
47 49
 
48 50
         FieldMapper mapper = new FieldMapper();
49
-        mapper.addOperationAdd("usertype", getDicId(jdbcTemplateHsms,"usertype","4")); //用户类型-默认三方人员
50
-        mapper.addOperationReplace("hospital_id", hospitalTask.loadCache().getIdCache());
51
-        mapper.addOperationReplace("duty_dept", hospitalTask.loadCache().getIdCache());
51
+        Map<Long, Long> userCache = userTask.loadCache().getIdCache();
52
+
53
+        mapper.addOperationRemove("id").addOperationRemove("version");
54
+        mapper.addOperationRemove("emergencyid").addOperationRemove("influenceid");
55
+        mapper.addOperationUpdate("priority_id", "priorityid");
56
+        mapper.addOperationUpdate("hos_id", "branch_id");
57
+        //襄阳id4-
58
+        mapper.addOperationReplace("userid", userCache);
59
+        mapper.addOperationReplace("close_userid", userCache);
60
+        mapper.addOperationReplace("requesterid", userCache);
61
+        mapper.addOperationReplace("handleruserid", userCache);
62
+        mapper.addOperationReplace("handlingPersonnelUserId", userCache);
63
+        mapper.addOperationReplace("duty_id", hospitalTask.loadCache().getIdCache());
64
+        //只有襄阳需要处理科室,南京不用
52 65
         if ("xiangyang".equals(appName)) {
53
-            mapper.addOperationReplace("DEPTID", departmentTask.loadCache().getIdCache());
66
+            mapper.addOperationReplace("dept", departmentTask.loadCache().getIdCache());
54 67
         }
55 68
         mapper.trans2JdbcRow(list);
56 69
 
57
-        FieldMapper userMapper = loadCache();
58
-        RowsWrap rw = DataMigrationter.getRowsWrap(mapper,userMapper);
59 70
         JdbcUtil jdbcUtil = new JdbcUtil(jdbcTemplateHsms);
60
-        jdbcUtil.batchPageInsert("itsm_uc_user", rw.getInsertRows());
61
-        jdbcUtil.batchPageUpdate("itsm_uc_user", rw.getUpdateRows());
71
+        jdbcUtil.batchPageInsert("itsm_itsm_incident", mapper.getRows());
62 72
 
63 73
         //clear释放内存
64 74
         mapper.clear();
65
-        userMapper.clear();
66 75
     }
67 76
 
68 77
     @Override
69 78
     public FieldMapper loadCache() {
70
-        log.info(" *** DepartmentTask loadCache 开始 *** ");
79
+        log.info(" *** IncidentTask loadCache 开始 *** ");
71 80
 
72
-        String sql = " select id,ACCOUNT,delete_flag from itsm_uc_user ";
81
+        String sql = " select id,incidentsign from itsm_itsm_incident ";
73 82
         List<Map<String, Object>> list = jdbcTemplateHsms.queryForList(sql);
74
-        sql = " select id,ACCOUNT,delete_flag from itsm_uc_user ";
83
+        sql = " select id,incidentsign from itsm_incident ";
75 84
         List<Map<String, Object>> list2 = jdbcTemplateMdv2.queryForList(sql);
76 85
 
77 86
         FieldMapper mapper = new FieldMapper();
78
-        mapper.addFieldMapper("ACCOUNT", "ACCOUNT");
79
-        mapper.addFieldMapper("delete_flag", "delete_flag");
87
+        mapper.addFieldMapper("incidentsign", "incidentsign");
80 88
 
81 89
         DataMigrationter.loadCache(list, list2, mapper);
82 90
 

+ 55 - 0
src/main/java/com/dashitech/migration/task/other/DictionaryTask.java

@@ -66,6 +66,61 @@ public class DictionaryTask extends BaseTask {
66 66
         idCache.put(279L,1609L);
67 67
         idCache.put(280L,1610L);
68 68
 
69
+        //事件-关闭代码
70
+        idCache.put(1572L,20419L);
71
+        idCache.put(1573L,20420L);
72
+        idCache.put(1575L,20421L);
73
+        idCache.put(1574L,20422L);
74
+        idCache.put(1576L,20422L);
75
+        idCache.put(1577L,20422L);
76
+
77
+        //事件-满意度
78
+        idCache.put(1578L,20414L);
79
+        idCache.put(1579L,20415L);
80
+        idCache.put(1580L,20416L);
81
+        idCache.put(1581L,20417L);
82
+        idCache.put(1582L,20418L);
83
+
84
+        //事件-优先级
85
+        idCache.put(1560L,5L);
86
+        idCache.put(1561L,4L);
87
+        idCache.put(1562L,3L);
88
+        idCache.put(1563L,2L);
89
+        idCache.put(1704L,1L);
90
+
91
+        //事件-incident_source
92
+        idCache.put(1547L,20402L);
93
+        idCache.put(1548L,20403L);
94
+        idCache.put(1549L,1549L);
95
+        idCache.put(1550L,20406L);
96
+        idCache.put(1551L,20405L);
97
+        idCache.put(1552L,20406L);
98
+        idCache.put(1700L,20406L);
99
+        idCache.put(1747L,20406L);
100
+
101
+        //事件-incident_status
102
+        idCache.put(1479L,20423L);
103
+        idCache.put(1543L,20424L);
104
+        idCache.put(1544L,20425L);
105
+        idCache.put(1545L,20426L);
106
+        idCache.put(1546L,20426L);
107
+        idCache.put(1674L,20427L);
108
+        idCache.put(1748L,20428L);
109
+        idCache.put(1749L,20429L);
110
+        idCache.put(1750L,20430L);
111
+
112
+        //事件-incident_handleresult
113
+        idCache.put(1568L,20401L);
114
+        idCache.put(1569L,20401L);
115
+        idCache.put(1570L,20401L);
116
+        idCache.put(1571L,20401L);
117
+
118
+        //事件-wxincident_degree
119
+        idCache.put(1598L,20414L);
120
+        idCache.put(1599L,20415L);
121
+        idCache.put(1600L,20416L);
122
+        idCache.put(1601L,20417L);
123
+        idCache.put(1602L,20418L);
69 124
 
70 125
         return mapper;
71 126
     }

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

@@ -88,14 +88,14 @@ public class HospitalTask extends BaseTask {
88 88
     }
89 89
 
90 90
     public FieldMapper loadNanjingCache() {
91
+        StringBuffer sql = new StringBuffer("SELECT id,dept FROM `itsm_uc_duty_dept` ");
92
+        List<Map<String, Object>> dutyList = jdbcTemplateMdv2.queryForList(sql.toString());
93
+        sql = new StringBuffer("select id,_hos_name from itsm_uc_hospital ");
94
+        List<Map<String, Object>> hosList = jdbcTemplateHsms.queryForList(sql.toString());
91 95
         FieldMapper mapper = new FieldMapper();
92
-        Map<Long, Long> hosIdCache = new HashMap<>();
93
-        mapper.setIdCache(hosIdCache);
96
+        mapper.addFieldMapper("_hos_name", "dept");
94 97
 
95
-        hosIdCache.put(1L, 4L); //总务科
96
-        hosIdCache.put(2L, 4L); //总务科
97
-        hosIdCache.put(3L, 5L); //信息科
98
-        hosIdCache.put(4L, 6L); //设备科
98
+        DataMigrationter.loadCache(hosList, dutyList, mapper);
99 99
 
100 100
         return mapper;
101 101
     }

+ 4 - 4
src/main/java/com/dashitech/migration/util/JdbcUtil.java

@@ -181,13 +181,13 @@ public class JdbcUtil {
181 181
 
182 182
 
183 183
     /**
184
-     * 分批执行批量操作,默认10000
184
+     * 分批执行批量操作,默认1000条
185 185
      */
186 186
     public boolean batchPageInsert(String table, final List<JdbcRow> rows) {
187 187
         if (table == null || table.length()== 0 || rows == null || rows.size() == 0) {
188 188
             return false;
189 189
         }
190
-        List<List<JdbcRow>> pageList = pageList(rows, 10000);
190
+        List<List<JdbcRow>> pageList = pageList(rows, 1000);
191 191
         for (List<JdbcRow> jdbcRows : pageList) {
192 192
             batchInsert(table, jdbcRows);
193 193
         }
@@ -195,13 +195,13 @@ public class JdbcUtil {
195 195
     }
196 196
 
197 197
     /**
198
-     * 分批执行批量操作,默认10000
198
+     * 分批执行批量操作,默认1000条
199 199
      */
200 200
     public boolean batchPageUpdate(String table, final List<JdbcRow> rows) {
201 201
         if (table == null || table.length()== 0 || rows == null || rows.size() == 0) {
202 202
             return false;
203 203
         }
204
-        List<List<JdbcRow>> pageList = pageList(rows, 10000);
204
+        List<List<JdbcRow>> pageList = pageList(rows, 1000);
205 205
         for (List<JdbcRow> jdbcRows : pageList) {
206 206
             batchUpdate(table, jdbcRows);
207 207
         }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 3 - 656
src/main/resources/migration.sql