Browse Source

修改bug

song 5 months ago
parent
commit
c6762f78f9

+ 8 - 8
src/main/java/com/dashitech/api/rest/ApiRest.java

@@ -1,11 +1,9 @@
1 1
 package com.dashitech.api.rest;
2 2
 
3 3
 import com.dashitech.migration.StartApplication;
4
+import org.apache.commons.lang.StringUtils;
4 5
 import org.springframework.beans.factory.annotation.Autowired;
5
-import org.springframework.web.bind.annotation.RequestMapping;
6
-import org.springframework.web.bind.annotation.RequestMethod;
7
-import org.springframework.web.bind.annotation.ResponseBody;
8
-import org.springframework.web.bind.annotation.RestController;
6
+import org.springframework.web.bind.annotation.*;
9 7
 
10 8
 @RestController
11 9
 @RequestMapping(value = "/api")
@@ -17,10 +15,12 @@ public class ApiRest {
17 15
 
18 16
     @RequestMapping(value = "/start", method = RequestMethod.GET)
19 17
     @ResponseBody
20
-    public String start() {
21
-
22
-        startApplication.start();
23
-
18
+    public String start(String taskName) {
19
+        if (StringUtils.isNotEmpty(taskName)) {
20
+            startApplication.start(taskName);
21
+        } else {
22
+            startApplication.start();
23
+        }
24 24
         return "ok";
25 25
     }
26 26
 

+ 71 - 58
src/main/java/com/dashitech/migration/StartApplication.java

@@ -21,70 +21,83 @@ public class StartApplication {
21 21
     public void start() {
22 22
         log.info("########### 开始迁移任务!###########");
23 23
         SqlTask task = null;
24
-//        task = SpringContextHolder.getBean("dictionaryTask");
25
-//        task.start();
26
-//        task = SpringContextHolder.getBean("tokenTask");
27
-//        task.start();
28
-//        task = SpringContextHolder.getBean("attachmentTask");
29
-//        task.start();
30
-//        task = SpringContextHolder.getBean("opLogTask");
31
-//        task.start();
32
-//        task = SpringContextHolder.getBean("hospitalTask");
33
-//        task.start();
34
-//        task = SpringContextHolder.getBean("hospitalConfigTask");
35
-//        task.start();
36
-//        task = SpringContextHolder.getBean("groupTask");
37
-//        task.start();
38
-//        task = SpringContextHolder.getBean("departmentTask");
39
-//        task.start();
40
-//        task = SpringContextHolder.getBean("companyTask");
41
-//        task.start();
42
-//        task = SpringContextHolder.getBean("userTask");
43
-//        task.start();
44
-//        task = SpringContextHolder.getBean("userGroupTask");
45
-//        task.start();
46
-//        task = SpringContextHolder.getBean("roleUserTask");
47
-//        task.start();
48
-//        task = SpringContextHolder.getBean("areaTask");
49
-//        task.start();
50
-//        task = SpringContextHolder.getBean("placeTask");
51
-//        task.start();
52
-//        task = SpringContextHolder.getBean("incidentCategoryTask");
53
-//        task.start();
54
-//        task = SpringContextHolder.getBean("incidentCategoryConfigTask");
55
-//        task.start();
56
-//        task = SpringContextHolder.getBean("incidentTask");
57
-//        task.start();
58
-//        task = SpringContextHolder.getBean("incidentLogTask");
59
-//        task.start();
60
-//        task = SpringContextHolder.getBean("incidentSynergeticTask");
61
-//        task.start();
62
-//        task = SpringContextHolder.getBean("incidentAssignManagerTask");
63
-//        task.start();
64
-//        task = SpringContextHolder.getBean("workHourManagementTask");
65
-//        task.start();
66
-//        task = SpringContextHolder.getBean("solutionTask");
67
-//        task.start();
68
-//        task = SpringContextHolder.getBean("solutionIntroduceTask");
69
-//        task.start();
70
-//        task = SpringContextHolder.getBean("productTask");
71
-//        task.start();
24
+        task = SpringContextHolder.getBean("dictionaryTask");
25
+        task.start();
26
+        task = SpringContextHolder.getBean("tokenTask");
27
+        task.start();
28
+        task = SpringContextHolder.getBean("attachmentTask");
29
+        task.start();
30
+        task = SpringContextHolder.getBean("opLogTask");
31
+        task.start();
32
+        task = SpringContextHolder.getBean("hospitalTask");
33
+        task.start();
34
+        task = SpringContextHolder.getBean("hospitalConfigTask");
35
+        task.start();
36
+        task = SpringContextHolder.getBean("areaTask");
37
+        task.start();
38
+        task = SpringContextHolder.getBean("placeTask");
39
+        task.start();
40
+        task = SpringContextHolder.getBean("groupTask");
41
+        task.start();
42
+        task = SpringContextHolder.getBean("departmentTask");
43
+        task.start();
44
+        task = SpringContextHolder.getBean("companyTask");
45
+        task.start();
46
+        task = SpringContextHolder.getBean("userTask");
47
+        task.start();
48
+        task = SpringContextHolder.getBean("userGroupTask");
49
+        task.start();
50
+        task = SpringContextHolder.getBean("roleUserTask");
51
+        task.start();
52
+        task = SpringContextHolder.getBean("incidentCategoryTask");
53
+        task.start();
54
+        task = SpringContextHolder.getBean("incidentCategoryConfigTask");
55
+        task.start();
56
+        task = SpringContextHolder.getBean("incidentTask");
57
+        task.start();
58
+        task = SpringContextHolder.getBean("incidentLogTask");
59
+        task.start();
60
+        task = SpringContextHolder.getBean("incidentSynergeticTask");
61
+        task.start();
62
+        task = SpringContextHolder.getBean("incidentAssignManagerTask");
63
+        task.start();
64
+        task = SpringContextHolder.getBean("workHourManagementTask");
65
+        task.start();
66
+        task = SpringContextHolder.getBean("solutionTask");
67
+        task.start();
68
+        task = SpringContextHolder.getBean("solutionIntroduceTask");
69
+        task.start();
70
+        task = SpringContextHolder.getBean("productTask");
71
+        task.start();
72 72
         task = SpringContextHolder.getBean("consumableTask");
73 73
         task.start();
74
-//        task = SpringContextHolder.getBean("consumableHistoryTask");
75
-//        task.start();
76
-//        task = SpringContextHolder.getBean("repairSummaryTask");
77
-//        task.start();
78
-//        task = SpringContextHolder.getBean("summaryConsumableTask");
79
-//        task.start();
80
-//        task = SpringContextHolder.getBean("callLogTask");
81
-//        task.start();
82
-//        task = SpringContextHolder.getBean("hjzxRecordTask");
83
-//        task.start();
74
+        task = SpringContextHolder.getBean("consumableHistoryTask");
75
+        task.start();
76
+        task = SpringContextHolder.getBean("repairSummaryTask");
77
+        task.start();
78
+        task = SpringContextHolder.getBean("summaryConsumableTask");
79
+        task.start();
80
+        task = SpringContextHolder.getBean("callLogTask");
81
+        task.start();
82
+        task = SpringContextHolder.getBean("hjzxRecordTask");
83
+        task.start();
84 84
 
85 85
 
86 86
         log.info("########### 迁移任务完成!###########");
87 87
     }
88 88
 
89
+    public void start(String taskName) {
90
+        try {
91
+            SqlTask sqlTask = SpringContextHolder.getBean(taskName);
92
+            log.info("########### 开始迁移指定"+taskName+"任务!###########");
93
+            sqlTask.start();
94
+            log.info("########### 迁移指定"+taskName+"任务完成!###########");
95
+        } catch (Exception e) {
96
+            log.error("指定任务" + taskName + "转换有误:" + e.getMessage());
97
+            e.printStackTrace();
98
+        }
99
+
100
+    }
101
+
89 102
 
90 103
 }

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

@@ -7,6 +7,7 @@ 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.beans.factory.annotation.Autowired;
10 11
 import org.springframework.stereotype.Component;
11 12
 import org.springframework.transaction.annotation.Transactional;
12 13
 
@@ -22,18 +23,26 @@ public class DepartmentTask extends BaseTask {
22 23
 
23 24
     public static Log log = LogFactory.getLog(DepartmentTask.class);
24 25
 
26
+    @Autowired
27
+    private AreaTask areaTask;
28
+
29
+    @Autowired
30
+    private PlaceTask placeTask;
31
+
25 32
     @Override
26 33
     @Transactional(rollbackFor = Exception.class)
27 34
     public void start() {
28 35
         if ("xiangyang".equals(appName)) {
29 36
             log.info(" *** DepartmentTask start 开始 *** ");
30
-            StringBuffer sql = new StringBuffer("SELECT dept,CODE,parentId,email,delete_flag,address as _address,place_id as floor_id,area_id as building_id,pinyin,");
37
+            StringBuffer sql = new StringBuffer("SELECT dept,IFNULL(CODE,pinyin) as CODE,parentId,email,delete_flag,address as _address,place_id as floor_id,area_id as building_id,pinyin,");
31 38
             sql.append("branch_id as _hospital_id,dept_alias,input_code,phone as many_phone,qrcode,1 as flag,IF(phone is not null,SUBSTRING_INDEX(phone,',',1),null) as _phone ");
32
-            sql.append(" FROM itsm_uc_dept where id in (select distinct b.id from itsm_incident a join itsm_uc_dept b on a.dept = b.id where a.dept > 1204)");
39
+            sql.append(" FROM itsm_uc_dept ");
33 40
             List<Map<String, Object>> deptList = jdbcTemplateMdv2.queryForList(sql.toString());
34 41
 
35 42
             FieldMapper mapper = new FieldMapper();
36 43
             mapper.addOperationAdd("_type", getDicId(jdbcTemplateHsms, "dept_type", "other"));
44
+            mapper.addOperationReplace("floor_id", placeTask.loadCache().getIdCache());
45
+            mapper.addOperationReplace("building_id", areaTask.loadCache().getIdCache());
37 46
             mapper.trans2JdbcRow(deptList);
38 47
 
39 48
             FieldMapper deptMapper = this.loadCache();

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

@@ -29,6 +29,8 @@ public class UserTask extends BaseTask {
29 29
     SqlTask departmentTask;
30 30
     @Autowired
31 31
     SqlTask dictionaryTask;
32
+    @Autowired
33
+    SqlTask companyTask;
32 34
 
33 35
     public static Log log = LogFactory.getLog(UserTask.class);
34 36
 
@@ -51,6 +53,7 @@ public class UserTask extends BaseTask {
51 53
         mapper.addOperationReplace("hospital_id", hospitalTask.loadCache().getIdCache());
52 54
         mapper.addOperationReplace("duty_dept", hospitalTask.loadCache().getIdCache());
53 55
         mapper.addOperationReplace("GENDER", dictionaryTask.loadCache().getIdCache());
56
+        mapper.addOperationReplace("company_id", companyTask.loadCache().getIdCache());
54 57
         if ("xiangyang".equals(appName)) {
55 58
             mapper.addOperationReplace("DEPTID", departmentTask.loadCache().getIdCache());
56 59
         }