Ver código fonte

manual add by UnitId

kerry 5 anos atrás
pai
commit
7493fc8eee

+ 7 - 2
elastic-publish-service/req/main-controller.http Ver arquivo

@@ -21,7 +21,7 @@ Content-Type: application/json
21 21
 
22 22
 {
23 23
   "agencyPath": "/1",
24
-  "keyword": "科苑一区",
24
+  "keyword": "33E9D1",
25 25
   "page": 1,
26 26
   "size": 10,
27 27
   "regulatoryLevelId": "",
@@ -45,4 +45,9 @@ GET http://{{host}}/set-load
45 45
 
46 46
 GET http://{{host}}/loadByAgencyIds?agencyIds=190084,196581
47 47
 
48
-### load data
48
+### load data
49
+
50
+
51
+GET http://{{host}}/loadByUnitIds?unitIds=545775
52
+
53
+### load by unitId

+ 27 - 5
elastic-publish-service/src/main/java/com/vcarecity/publish/controller/MainController.java Ver arquivo

@@ -91,11 +91,8 @@ public class MainController implements PrepareController {
91 91
         return ApiResult.builder().status(20000).message("already load data success!").build();
92 92
     }
93 93
 
94
-
95
-    @ResponseBody
96
-    @RequestMapping(value = "/loadByAgencyIds", method = {RequestMethod.POST, RequestMethod.GET})
97
-    public ApiResult loadByAgencyIds(@RequestParam("agencyIds") String agencyIds) {
98
-        String[] split = agencyIds.split(",");
94
+    private List<Long> toQueryIds(String idStr) {
95
+        String[] split = idStr.split(",");
99 96
         List<Long> ids = new ArrayList<>(split.length);
100 97
         for (String s : split) {
101 98
             try {
@@ -104,6 +101,14 @@ public class MainController implements PrepareController {
104 101
                 e.printStackTrace();
105 102
             }
106 103
         }
104
+        return ids;
105
+    }
106
+
107
+    @ResponseBody
108
+    @RequestMapping(value = "/loadByAgencyIds", method = {RequestMethod.POST, RequestMethod.GET})
109
+    public ApiResult loadByAgencyIds(@RequestParam("agencyIds") String agencyIds) {
110
+        List<Long> ids = toQueryIds(agencyIds);
111
+
107 112
         List<UnitAgencyMergeEntity> result = agencyService.loadByAgencyIds(ids);
108 113
         if (result == null) {
109 114
             return ApiResult.builder().status(ApiStatus.FAILED_CODE).build();
@@ -117,6 +122,23 @@ public class MainController implements PrepareController {
117 122
         }
118 123
     }
119 124
 
125
+    @ResponseBody
126
+    @RequestMapping(value = "/loadByUnitIds", method = {RequestMethod.POST, RequestMethod.GET})
127
+    public ApiResult loadByUnitIds(@RequestParam("unitIds") String unitIds) {
128
+        List<Long> ids = toQueryIds(unitIds);
129
+        List<UnitAgencyMergeEntity> result = unitService.loadByUnitIds(ids);
130
+        if (result == null || result.isEmpty()) {
131
+            return ApiResult.builder().status(ApiStatus.FAILED_CODE).build();
132
+        }
133
+        try {
134
+            elasticUpdateService.handlerDataChange("unitId", result);
135
+            return ApiResult.builder().status(ApiStatus.SUCCESS_CODE).build();
136
+        } catch (IOException e) {
137
+            e.printStackTrace();
138
+            return ApiResult.builder().status(40000).message(e.getMessage()).build();
139
+        }
140
+    }
141
+
120 142
 
121 143
     @PostMapping("/query-unit-agency")
122 144
     public ApiResult queryUnitAgency(@RequestBody @Valid UnitAgencyQuery unitAgencyQuery) throws IOException {

+ 7 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/mapper/UnitMapper.java Ver arquivo

@@ -45,4 +45,11 @@ public interface UnitMapper {
45 45
     List<UnitAgencyMergeEntity> findAllWithPage(@Param("page") int page, @Param("size") int size);
46 46
 
47 47
 
48
+    /**
49
+     * load
50
+     *
51
+     * @param unitIds
52
+     * @return
53
+     */
54
+    List<UnitAgencyMergeEntity> loadByUnitIds(@Param("unitIds") List<Long> unitIds);
48 55
 }

+ 8 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/sql/service/UnitService.java Ver arquivo

@@ -1,5 +1,6 @@
1 1
 package com.vcarecity.publish.sql.service;
2 2
 
3
+import com.vcarecity.publish.entity.UnitAgencyMergeEntity;
3 4
 import com.vcarecity.publish.pojo.dto.TotalResultDTO;
4 5
 import com.vcarecity.publish.pojo.dto.UnitIdDTO;
5 6
 import com.vcarecity.publish.pojo.query.UnitAgencyQuery;
@@ -24,4 +25,11 @@ public interface UnitService {
24 25
      */
25 26
     <T extends UnitIdDTO> TotalResultDTO<List<T>> getUnitAgencyByQuery(UnitAgencyQuery queryParam, Class<T> cls, String... indices) throws IOException;
26 27
 
28
+    /**
29
+     * add by Unit ID
30
+     *
31
+     * @param unitIds
32
+     * @return
33
+     */
34
+    List<UnitAgencyMergeEntity> loadByUnitIds(List<Long> unitIds);
27 35
 }

+ 13 - 1
elastic-publish-service/src/main/java/com/vcarecity/publish/sql/service/impl/UnitServiceImpl.java Ver arquivo

@@ -2,6 +2,8 @@ package com.vcarecity.publish.sql.service.impl;
2 2
 
3 3
 import com.fasterxml.jackson.databind.ObjectMapper;
4 4
 import com.vcarecity.elastic.util.AgencyPathUtil;
5
+import com.vcarecity.publish.entity.UnitAgencyMergeEntity;
6
+import com.vcarecity.publish.mapper.UnitMapper;
5 7
 import com.vcarecity.publish.pojo.dto.TotalResultDTO;
6 8
 import com.vcarecity.publish.pojo.dto.UnitIdDTO;
7 9
 import com.vcarecity.publish.pojo.query.UnitAgencyQuery;
@@ -37,6 +39,7 @@ public class UnitServiceImpl implements UnitService {
37 39
 
38 40
     private final RestHighLevelClient restHighLevelClient;
39 41
     private final ObjectMapper objectMapper;
42
+    private final UnitMapper unitMapper;
40 43
 
41 44
     /*static final String[] SEARCH_KEY_NAMES = new String[]{
42 45
             "dtuNo.keyword",
@@ -64,9 +67,10 @@ public class UnitServiceImpl implements UnitService {
64 67
 
65 68
 
66 69
     public UnitServiceImpl(RestHighLevelClient restHighLevelClient,
67
-                           ObjectMapper objectMapper) {
70
+                           ObjectMapper objectMapper, UnitMapper unitMapper) {
68 71
         this.restHighLevelClient = restHighLevelClient;
69 72
         this.objectMapper = objectMapper;
73
+        this.unitMapper = unitMapper;
70 74
     }
71 75
 
72 76
     @Override
@@ -129,6 +133,14 @@ public class UnitServiceImpl implements UnitService {
129 133
         return new TotalResultDTO<>(res, total);
130 134
     }
131 135
 
136
+    @Override
137
+    public List<UnitAgencyMergeEntity> loadByUnitIds(List<Long> unitIds) {
138
+        if (unitIds == null || unitIds.isEmpty()) {
139
+            return null;
140
+        }
141
+        return unitMapper.loadByUnitIds(unitIds);
142
+    }
143
+
132 144
     /**
133 145
      * agency id
134 146
      * <pre>

+ 33 - 0
elastic-publish-service/src/main/resources/mapper/UnitMapper.xml Ver arquivo

@@ -84,4 +84,37 @@
84 84
                  INNER JOIN T_AGENCY_EXTEND TAE ON TAE.AGENCY_ID = TU.AGENCY_ID
85 85
         limit ${page},${size}
86 86
     </select>
87
+
88
+    <select id="loadByUnitIds" resultMap="unitAgencyMergeEntityMap">
89
+        SELECT TU.UNIT_ID,
90
+        TU.DTU_NO,
91
+        TU.PUSER_CODE,
92
+        TU.USER_CODE,
93
+        TU.POSITIONS,
94
+        TU.ISDELETED,
95
+        TU.UPDATESTAMP UNIT_UPDATE_STAMP,
96
+        TAG.AGENCY_ID,
97
+        TAG.AGENCY_PATH,
98
+        TAG.AGENCY_NAME,
99
+        TB.BUILDING_ID,
100
+        TB.NAME_OF_BUILDING,
101
+        TUT.UNIT_TYPE_ID,
102
+        TUT.UNIT_TYPE,
103
+        TUT.PROPERTY,
104
+        TUT.CLASSIFY,
105
+        TAE.REGULATORY_LEVEL_ID,
106
+        TAE.AGENCY_ATTRIBUTE_CLASS_ID
107
+        FROM (
108
+        SELECT TUI.*
109
+        from T_UNIT TUI
110
+        where TUI.UNIT_ID in
111
+        <foreach item="item" collection="unitIds" separator="," open="(" close=")" index="">
112
+            ${item}
113
+        </foreach>
114
+        ) TU
115
+        INNER JOIN T_AGENCY TAG ON TU.AGENCY_ID = TAG.AGENCY_ID AND TU.ISDELETED = 0
116
+        INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
117
+        INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
118
+        INNER JOIN T_AGENCY_EXTEND TAE ON TAE.AGENCY_ID = TU.AGENCY_ID
119
+    </select>
87 120
 </mapper>

+ 17 - 0
elastic-publish-service/src/test/java/com/vcarecity/publish/service/impl/UnitServiceImplTest.java Ver arquivo

@@ -1,5 +1,7 @@
1 1
 package com.vcarecity.publish.service.impl;
2 2
 
3
+import com.vcarecity.publish.entity.UnitAgencyMergeEntity;
4
+import com.vcarecity.publish.mapper.UnitMapper;
3 5
 import org.elasticsearch.action.update.UpdateRequest;
4 6
 import org.elasticsearch.client.RestHighLevelClient;
5 7
 import org.elasticsearch.script.Script;
@@ -8,7 +10,9 @@ import org.junit.jupiter.api.Test;
8 10
 import org.springframework.beans.factory.annotation.Autowired;
9 11
 import org.springframework.boot.test.context.SpringBootTest;
10 12
 
13
+import java.util.ArrayList;
11 14
 import java.util.HashMap;
15
+import java.util.List;
12 16
 import java.util.Map;
13 17
 
14 18
 
@@ -18,6 +22,9 @@ class UnitServiceImplTest {
18 22
     @Autowired
19 23
     private RestHighLevelClient restHighLevelClient;
20 24
 
25
+    @Autowired
26
+    private UnitMapper unitMapper;
27
+
21 28
     @Test
22 29
     public void getUnitAgencyByQuery() {
23 30
 
@@ -32,4 +39,14 @@ class UnitServiceImplTest {
32 39
 
33 40
         request.script(inline);
34 41
     }
42
+
43
+    @Test
44
+    public void loadByUnitIds() throws Exception {
45
+        List<Long> ids = new ArrayList<>();
46
+        ids.add(545775L);
47
+        final List<UnitAgencyMergeEntity> unitAgencyMergeEntities = unitMapper.loadByUnitIds(ids);
48
+        for (UnitAgencyMergeEntity unitAgencyMergeEntity : unitAgencyMergeEntities) {
49
+            System.out.println(unitAgencyMergeEntity);
50
+        }
51
+    }
35 52
 }

+ 1 - 0
pom.xml Ver arquivo

@@ -163,6 +163,7 @@
163 163
                 <configuration>
164 164
                     <source>8</source>
165 165
                     <target>8</target>
166
+                    <encoding>UTF-8</encoding>
166 167
                 </configuration>
167 168
             </plugin>
168 169
         </plugins>