Browse Source

ADD req fields

kerry 5 years ago
parent
commit
698e732291
26 changed files with 398 additions and 49 deletions
  1. 10 2
      elastic-publish-service/req/main-controller.http
  2. 0 2
      elastic-publish-service/src/main/java/com/vcarecity/publish/ElasticPublishApplication.java
  3. 1 2
      elastic-publish-service/src/main/java/com/vcarecity/publish/config/MapperConfig.java
  4. 11 0
      elastic-publish-service/src/main/java/com/vcarecity/publish/config/SchedulingConfiguration.java
  5. 3 4
      elastic-publish-service/src/main/java/com/vcarecity/publish/controller/MainController.java
  6. 12 2
      elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/ElasticIndexService.java
  7. 8 0
      elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/ElasticQueryService.java
  8. 13 5
      elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticIndexServiceImpl.java
  9. 11 1
      elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticLoadDataServiceImpl.java
  10. 37 1
      elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticQueryServiceImpl.java
  11. 7 2
      elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticUpdateServiceImpl.java
  12. 8 0
      elastic-publish-service/src/main/java/com/vcarecity/publish/entity/UnitAgencyMergeEntity.java
  13. 4 0
      elastic-publish-service/src/main/java/com/vcarecity/publish/pojo/dto/UnitAgencyDTO.java
  14. 5 0
      elastic-publish-service/src/main/java/com/vcarecity/publish/pojo/query/UnitAgencyQuery.java
  15. 3 5
      elastic-publish-service/src/main/java/com/vcarecity/publish/sql/service/UnitService.java
  16. 59 13
      elastic-publish-service/src/main/java/com/vcarecity/publish/sql/service/impl/UnitServiceImpl.java
  17. 32 0
      elastic-publish-service/src/main/java/com/vcarecity/publish/util/Utils.java
  18. 5 5
      elastic-publish-service/src/main/resources/application-dev.yml
  19. 38 0
      elastic-publish-service/src/main/resources/logback-spring.xml
  20. 10 1
      elastic-publish-service/src/main/resources/mapper/AgencyMapper.xml
  21. 18 4
      elastic-publish-service/src/main/resources/mapper/UnitMapper.xml
  22. 41 0
      elastic-publish-service/src/test/java/com/vcarecity/publish/config/MapperConfigTest.java
  23. 20 0
      elastic-publish-service/src/test/java/com/vcarecity/publish/elastic/service/impl/ElasticLoadDataServiceImplTest.java
  24. 21 0
      elastic-publish-service/src/test/java/com/vcarecity/publish/elastic/service/impl/ElasticQueryServiceImplTest.java
  25. 18 0
      elastic-publish-service/src/test/java/com/vcarecity/publish/mapper/AgencyMapperTest.java
  26. 3 0
      elastic-publish-service/src/test/java/com/vcarecity/publish/service/impl/ElasticUpdateServiceImplTest.java

+ 10 - 2
elastic-publish-service/req/main-controller.http View File

5
   "agencyPath": "/1",
5
   "agencyPath": "/1",
6
   "keyword": "鱼峰区",
6
   "keyword": "鱼峰区",
7
   "page": 2,
7
   "page": 2,
8
-  "size": 10
8
+  "size": 10,
9
+  "regulatoryLevelId": "27,28",
10
+  "property": "",
11
+  "classify": "",
12
+  "agencyAttributeClassId": ""
9
 }
13
 }
10
 
14
 
11
 ### unitId 信息
15
 ### unitId 信息
18
   "agencyPath": "/1",
22
   "agencyPath": "/1",
19
   "keyword": "鱼峰区",
23
   "keyword": "鱼峰区",
20
   "page": 2,
24
   "page": 2,
21
-  "size": 10
25
+  "size": 10,
26
+  "regulatoryLevelId": "27,28",
27
+  "property": "",
28
+  "classify": "",
29
+  "agencyAttributeClassId": ""
22
 }
30
 }
23
 
31
 
24
 ### 详情信息
32
 ### 详情信息

+ 0 - 2
elastic-publish-service/src/main/java/com/vcarecity/publish/ElasticPublishApplication.java View File

3
 import org.mybatis.spring.annotation.MapperScan;
3
 import org.mybatis.spring.annotation.MapperScan;
4
 import org.springframework.boot.SpringApplication;
4
 import org.springframework.boot.SpringApplication;
5
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5
 import org.springframework.boot.autoconfigure.SpringBootApplication;
6
-import org.springframework.scheduling.annotation.EnableScheduling;
7
 
6
 
8
 /**
7
 /**
9
  * @author Kerry on 19/12/11
8
  * @author Kerry on 19/12/11
10
  */
9
  */
11
 
10
 
12
 
11
 
13
-@EnableScheduling
14
 @MapperScan("com.vcarecity.publish.mapper")
12
 @MapperScan("com.vcarecity.publish.mapper")
15
 @SpringBootApplication
13
 @SpringBootApplication
16
 public class ElasticPublishApplication {
14
 public class ElasticPublishApplication {

+ 1 - 2
elastic-publish-service/src/main/java/com/vcarecity/publish/config/MapperConfig.java View File

1
 package com.vcarecity.publish.config;
1
 package com.vcarecity.publish.config;
2
 
2
 
3
-import com.fasterxml.jackson.annotation.JsonInclude;
4
 import com.fasterxml.jackson.databind.DeserializationFeature;
3
 import com.fasterxml.jackson.databind.DeserializationFeature;
5
 import com.fasterxml.jackson.databind.ObjectMapper;
4
 import com.fasterxml.jackson.databind.ObjectMapper;
6
 import org.springframework.context.annotation.Bean;
5
 import org.springframework.context.annotation.Bean;
16
     @Bean
15
     @Bean
17
     public ObjectMapper objectMapper() {
16
     public ObjectMapper objectMapper() {
18
         ObjectMapper objectMapper = new ObjectMapper();
17
         ObjectMapper objectMapper = new ObjectMapper();
19
-        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
18
+        // objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
20
         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
19
         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
21
         return objectMapper;
20
         return objectMapper;
22
     }
21
     }

+ 11 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/config/SchedulingConfiguration.java View File

1
+package com.vcarecity.publish.config;
2
+
3
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.scheduling.annotation.EnableScheduling;
6
+
7
+@ConditionalOnProperty(value = "app.scheduling.enable", havingValue = "true", matchIfMissing = true)
8
+@Configuration
9
+@EnableScheduling
10
+public class SchedulingConfiguration {
11
+}

+ 3 - 4
elastic-publish-service/src/main/java/com/vcarecity/publish/controller/MainController.java View File

30
 
30
 
31
     @PostMapping("/query-unit-agency")
31
     @PostMapping("/query-unit-agency")
32
     public ApiResult queryUnitAgency(@RequestBody @Valid UnitAgencyQuery unitAgencyQuery) throws IOException {
32
     public ApiResult queryUnitAgency(@RequestBody @Valid UnitAgencyQuery unitAgencyQuery) throws IOException {
33
-        final List<UnitAgencyDTO> unitAgencyByQuery = unitService.getUnitAgencyByQuery(unitAgencyQuery.getAgencyPath(), unitAgencyQuery.getKeyword(),
34
-                unitAgencyQuery.getPage(), unitAgencyQuery.getSize(), ElasticConstant.UNIT_AGENCY_INDEX);
33
+        final List<UnitAgencyDTO> unitAgencyByQuery = unitService.getUnitAgencyByQuery(unitAgencyQuery, ElasticConstant.UNIT_AGENCY_INDEX);
34
+
35
         List<Long> data = unitAgencyByQuery.stream().map(UnitAgencyDTO::getUnitId).collect(Collectors.toList());
35
         List<Long> data = unitAgencyByQuery.stream().map(UnitAgencyDTO::getUnitId).collect(Collectors.toList());
36
         return ApiResult.builder().status(ApiStatus.SUCCESS_CODE).data(data).build();
36
         return ApiResult.builder().status(ApiStatus.SUCCESS_CODE).data(data).build();
37
     }
37
     }
38
 
38
 
39
     @PostMapping("/test/query-unit-agency")
39
     @PostMapping("/test/query-unit-agency")
40
     public ApiResult testQueryUnitAgency(@RequestBody @Valid UnitAgencyQuery unitAgencyQuery) throws IOException {
40
     public ApiResult testQueryUnitAgency(@RequestBody @Valid UnitAgencyQuery unitAgencyQuery) throws IOException {
41
-        List<UnitAgencyDTO> data = unitService.getUnitAgencyByQuery(unitAgencyQuery.getAgencyPath(), unitAgencyQuery.getKeyword(),
42
-                unitAgencyQuery.getPage(), unitAgencyQuery.getSize(), ElasticConstant.UNIT_AGENCY_INDEX);
41
+        List<UnitAgencyDTO> data = unitService.getUnitAgencyByQuery(unitAgencyQuery, ElasticConstant.UNIT_AGENCY_INDEX);
43
         return ApiResult.builder().status(ApiStatus.SUCCESS_CODE).data(data).build();
42
         return ApiResult.builder().status(ApiStatus.SUCCESS_CODE).data(data).build();
44
     }
43
     }
45
 
44
 

+ 12 - 2
elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/ElasticIndexService.java View File

1
 package com.vcarecity.publish.elastic.service;
1
 package com.vcarecity.publish.elastic.service;
2
 
2
 
3
+import java.io.IOException;
3
 import java.util.List;
4
 import java.util.List;
4
 
5
 
5
 /**
6
 /**
10
 
11
 
11
     /**
12
     /**
12
      * index 是否存在
13
      * index 是否存在
14
+     * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-indices-exists.html">
15
+     * API
16
+     * </a>
13
      *
17
      *
14
      * @param index
18
      * @param index
15
      * @return
19
      * @return
20
+     * @throws IOException
16
      */
21
      */
17
-    boolean indexExist(String index);
22
+    boolean indexExist(String index) throws IOException;
18
 
23
 
19
     /**
24
     /**
20
      * create index
25
      * create index
26
     /**
31
     /**
27
      * delete index
32
      * delete index
28
      *
33
      *
34
+     * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-delete-index.html">
35
+     * API
36
+     * </a>
37
+     *
29
      * @param indices
38
      * @param indices
39
+     * @throws IOException
30
      */
40
      */
31
-    void deleteIndex(String... indices);
41
+    void deleteIndex(String... indices) throws IOException;
32
 
42
 
33
 
43
 
34
     /**
44
     /**

+ 8 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/ElasticQueryService.java View File

1
 package com.vcarecity.publish.elastic.service;
1
 package com.vcarecity.publish.elastic.service;
2
 
2
 
3
+import java.io.IOException;
4
+
3
 /**
5
 /**
4
  * @author VcKerry on 12/17/19
6
  * @author VcKerry on 12/17/19
5
  */
7
  */
6
 
8
 
7
 public interface ElasticQueryService {
9
 public interface ElasticQueryService {
8
 
10
 
11
+    /**
12
+     * for test
13
+     *
14
+     * @throws IOException
15
+     */
16
+    void testQuery() throws IOException;
9
 
17
 
10
 }
18
 }

+ 13 - 5
elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticIndexServiceImpl.java View File

1
 package com.vcarecity.publish.elastic.service.impl;
1
 package com.vcarecity.publish.elastic.service.impl;
2
 
2
 
3
 import com.vcarecity.publish.elastic.service.ElasticIndexService;
3
 import com.vcarecity.publish.elastic.service.ElasticIndexService;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
6
+import org.elasticsearch.client.RequestOptions;
4
 import org.elasticsearch.client.RestHighLevelClient;
7
 import org.elasticsearch.client.RestHighLevelClient;
8
+import org.elasticsearch.client.indices.GetIndexRequest;
5
 import org.springframework.stereotype.Service;
9
 import org.springframework.stereotype.Service;
6
 
10
 
11
+import java.io.IOException;
7
 import java.util.List;
12
 import java.util.List;
8
 
13
 
9
 /**
14
 /**
10
  * @author kerryzhang on 2019/12/17
15
  * @author kerryzhang on 2019/12/17
11
  */
16
  */
12
 
17
 
18
+@Slf4j
13
 @Service
19
 @Service
14
 public class ElasticIndexServiceImpl implements ElasticIndexService {
20
 public class ElasticIndexServiceImpl implements ElasticIndexService {
15
 
21
 
20
     }
26
     }
21
 
27
 
22
     @Override
28
     @Override
23
-    public boolean indexExist(String index) {
24
-
25
-        return false;
29
+    public boolean indexExist(String index) throws IOException {
30
+        GetIndexRequest request = new GetIndexRequest(index);
31
+        return restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);
26
     }
32
     }
27
 
33
 
28
     @Override
34
     @Override
31
     }
37
     }
32
 
38
 
33
     @Override
39
     @Override
34
-    public void deleteIndex(String... indices) {
35
-
40
+    public void deleteIndex(String... indices) throws IOException {
41
+        logger.warn("delete elastic index = {}", indices);
42
+        DeleteIndexRequest request = new DeleteIndexRequest(indices);
43
+        restHighLevelClient.indices().delete(request, RequestOptions.DEFAULT);
36
     }
44
     }
37
 
45
 
38
     @Override
46
     @Override

+ 11 - 1
elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticLoadDataServiceImpl.java View File

1
 package com.vcarecity.publish.elastic.service.impl;
1
 package com.vcarecity.publish.elastic.service.impl;
2
 
2
 
3
 import com.vcarecity.publish.constants.ElasticConstant;
3
 import com.vcarecity.publish.constants.ElasticConstant;
4
+import com.vcarecity.publish.elastic.service.ElasticIndexService;
4
 import com.vcarecity.publish.elastic.service.ElasticLoadDataService;
5
 import com.vcarecity.publish.elastic.service.ElasticLoadDataService;
5
 import com.vcarecity.publish.elastic.service.ElasticUpdateService;
6
 import com.vcarecity.publish.elastic.service.ElasticUpdateService;
6
 import com.vcarecity.publish.entity.UnitAgencyMergeEntity;
7
 import com.vcarecity.publish.entity.UnitAgencyMergeEntity;
22
 
23
 
23
     private final UnitMapper unitMapper;
24
     private final UnitMapper unitMapper;
24
     private final ElasticUpdateService elasticUpdateService;
25
     private final ElasticUpdateService elasticUpdateService;
26
+    private final ElasticIndexService elasticIndexService;
25
     private final int pageCount;
27
     private final int pageCount;
26
 
28
 
27
     public ElasticLoadDataServiceImpl(UnitMapper unitMapper,
29
     public ElasticLoadDataServiceImpl(UnitMapper unitMapper,
28
-                                      ElasticUpdateService elasticUpdateService) {
30
+                                      ElasticUpdateService elasticUpdateService,
31
+                                      ElasticIndexService elasticIndexService) {
29
         this.unitMapper = unitMapper;
32
         this.unitMapper = unitMapper;
30
         this.elasticUpdateService = elasticUpdateService;
33
         this.elasticUpdateService = elasticUpdateService;
34
+        this.elasticIndexService = elasticIndexService;
31
         this.pageCount = ElasticConstant.QUERY_PAGE_COUNT;
35
         this.pageCount = ElasticConstant.QUERY_PAGE_COUNT;
32
     }
36
     }
33
 
37
 
35
     @Override
39
     @Override
36
     public void loadData() throws IOException {
40
     public void loadData() throws IOException {
37
 
41
 
42
+        boolean exist = elasticIndexService.indexExist(ElasticConstant.UNIT_AGENCY_INDEX);
43
+        if (exist) {
44
+            logger.warn("elastic index = [{}] already exits", ElasticConstant.UNIT_AGENCY_INDEX);
45
+            elasticIndexService.deleteIndex(ElasticConstant.UNIT_AGENCY_INDEX);
46
+        }
47
+
38
         long allTime = System.currentTimeMillis();
48
         long allTime = System.currentTimeMillis();
39
 
49
 
40
         // calc handler count
50
         // calc handler count

+ 37 - 1
elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticQueryServiceImpl.java View File

1
 package com.vcarecity.publish.elastic.service.impl;
1
 package com.vcarecity.publish.elastic.service.impl;
2
 
2
 
3
+import com.vcarecity.publish.constants.ElasticConstant;
3
 import com.vcarecity.publish.elastic.service.ElasticQueryService;
4
 import com.vcarecity.publish.elastic.service.ElasticQueryService;
5
+import lombok.extern.slf4j.Slf4j;
6
+import org.elasticsearch.action.search.SearchRequest;
7
+import org.elasticsearch.action.search.SearchResponse;
8
+import org.elasticsearch.client.RequestOptions;
9
+import org.elasticsearch.client.RestHighLevelClient;
10
+import org.elasticsearch.index.query.QueryBuilders;
11
+import org.elasticsearch.index.query.TermQueryBuilder;
12
+import org.elasticsearch.search.SearchHit;
13
+import org.elasticsearch.search.builder.SearchSourceBuilder;
4
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
5
 
15
 
6
-import java.util.List;
16
+import java.io.IOException;
7
 
17
 
8
 /**
18
 /**
9
  * @author VcKerry on 12/17/19
19
  * @author VcKerry on 12/17/19
10
  */
20
  */
11
 
21
 
22
+@Slf4j
12
 @Service
23
 @Service
13
 public class ElasticQueryServiceImpl implements ElasticQueryService {
24
 public class ElasticQueryServiceImpl implements ElasticQueryService {
14
 
25
 
26
+    private final RestHighLevelClient restHighLevelClient;
27
+
28
+    public ElasticQueryServiceImpl(RestHighLevelClient restHighLevelClient) {
29
+        this.restHighLevelClient = restHighLevelClient;
30
+    }
31
+
32
+    @Override
33
+    public void testQuery() throws IOException {
34
+
35
+        TermQueryBuilder unitId = QueryBuilders.termQuery("unitId", 39746);
36
+
37
+
38
+        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
39
+        searchSourceBuilder.query(unitId);
40
+
41
+
42
+        SearchRequest request = new SearchRequest(ElasticConstant.UNIT_AGENCY_INDEX);
43
+        request.source(searchSourceBuilder);
44
+
45
+        SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
46
+        for (SearchHit hit : response.getHits()) {
47
+            logger.debug("{}", hit.getSourceAsString());
48
+        }
49
+
50
+    }
15
 }
51
 }

+ 7 - 2
elastic-publish-service/src/main/java/com/vcarecity/publish/elastic/service/impl/ElasticUpdateServiceImpl.java View File

1
 package com.vcarecity.publish.elastic.service.impl;
1
 package com.vcarecity.publish.elastic.service.impl;
2
 
2
 
3
+import com.fasterxml.jackson.annotation.JsonInclude;
3
 import com.fasterxml.jackson.core.type.TypeReference;
4
 import com.fasterxml.jackson.core.type.TypeReference;
5
+import com.fasterxml.jackson.databind.DeserializationFeature;
4
 import com.fasterxml.jackson.databind.ObjectMapper;
6
 import com.fasterxml.jackson.databind.ObjectMapper;
5
 import com.vcarecity.elastic.util.AgencyPathUtil;
7
 import com.vcarecity.elastic.util.AgencyPathUtil;
6
 import com.vcarecity.elastic.util.SnowFlake;
8
 import com.vcarecity.elastic.util.SnowFlake;
47
     private final AgencyService agencyService;
49
     private final AgencyService agencyService;
48
 
50
 
49
     public ElasticUpdateServiceImpl(RestHighLevelClient restHighLevelClient,
51
     public ElasticUpdateServiceImpl(RestHighLevelClient restHighLevelClient,
50
-                                    ObjectMapper objectMapper,
51
                                     AgencyService agencyService) {
52
                                     AgencyService agencyService) {
52
         this.restHighLevelClient = restHighLevelClient;
53
         this.restHighLevelClient = restHighLevelClient;
53
-        this.objectMapper = objectMapper;
54
         this.agencyService = agencyService;
54
         this.agencyService = agencyService;
55
 
55
 
56
+        ObjectMapper objectMapper = new ObjectMapper();
57
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
58
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
59
+
60
+        this.objectMapper = objectMapper;
56
         this.index = ElasticConstant.UNIT_AGENCY_INDEX;
61
         this.index = ElasticConstant.UNIT_AGENCY_INDEX;
57
     }
62
     }
58
 
63
 

+ 8 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/entity/UnitAgencyMergeEntity.java View File

30
     private String unitType;
30
     private String unitType;
31
 
31
 
32
     private Integer isDeleted;
32
     private Integer isDeleted;
33
+
34
+    private Integer property;
35
+
36
+    private Integer classify;
37
+
38
+    private Integer regulatoryLevelId;
39
+
40
+    private Integer agencyAttributeClassId;
33
 }
41
 }

+ 4 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/pojo/dto/UnitAgencyDTO.java View File

12
     private String agencyName;
12
     private String agencyName;
13
     private String agencyDetail;
13
     private String agencyDetail;
14
     private String nameOfBuilding;
14
     private String nameOfBuilding;
15
+    private Long classify;
16
+    private Long property;
17
+    private Long regulatoryLevelId;
18
+    private Long agencyAttributeClassId;
15
 }
19
 }

+ 5 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/pojo/query/UnitAgencyQuery.java View File

23
     @Min(1)
23
     @Min(1)
24
     private int size = 100;
24
     private int size = 100;
25
 
25
 
26
+    private String property;
27
+    private String classify;
28
+    private String regulatoryLevelId;
29
+    private String agencyAttributeClassId;
30
+
26
 }
31
 }

+ 3 - 5
elastic-publish-service/src/main/java/com/vcarecity/publish/sql/service/UnitService.java View File

1
 package com.vcarecity.publish.sql.service;
1
 package com.vcarecity.publish.sql.service;
2
 
2
 
3
 import com.vcarecity.publish.pojo.dto.UnitAgencyDTO;
3
 import com.vcarecity.publish.pojo.dto.UnitAgencyDTO;
4
+import com.vcarecity.publish.pojo.query.UnitAgencyQuery;
4
 
5
 
5
 import java.io.IOException;
6
 import java.io.IOException;
6
 import java.util.List;
7
 import java.util.List;
14
     /**
15
     /**
15
      * test
16
      * test
16
      *
17
      *
17
-     * @param agencyPath
18
-     * @param inputKeyword
19
-     * @param page
20
-     * @param size
18
+     * @param queryParam
21
      * @param indices
19
      * @param indices
22
      * @return
20
      * @return
23
      * @throws IOException
21
      * @throws IOException
24
      */
22
      */
25
-    List<UnitAgencyDTO> getUnitAgencyByQuery(String agencyPath, String inputKeyword, int page, int size, String... indices) throws IOException;
23
+    List<UnitAgencyDTO> getUnitAgencyByQuery(UnitAgencyQuery queryParam, String... indices) throws IOException;
26
 
24
 
27
 }
25
 }

+ 59 - 13
elastic-publish-service/src/main/java/com/vcarecity/publish/sql/service/impl/UnitServiceImpl.java View File

1
 package com.vcarecity.publish.sql.service.impl;
1
 package com.vcarecity.publish.sql.service.impl;
2
 
2
 
3
 import com.fasterxml.jackson.databind.ObjectMapper;
3
 import com.fasterxml.jackson.databind.ObjectMapper;
4
+import com.vcarecity.elastic.util.AgencyPathUtil;
4
 import com.vcarecity.publish.pojo.dto.UnitAgencyDTO;
5
 import com.vcarecity.publish.pojo.dto.UnitAgencyDTO;
6
+import com.vcarecity.publish.pojo.query.UnitAgencyQuery;
5
 import com.vcarecity.publish.sql.service.UnitService;
7
 import com.vcarecity.publish.sql.service.UnitService;
6
-import com.vcarecity.elastic.util.AgencyPathUtil;
8
+import com.vcarecity.publish.util.Utils;
7
 import lombok.extern.slf4j.Slf4j;
9
 import lombok.extern.slf4j.Slf4j;
8
 import org.elasticsearch.action.search.SearchRequest;
10
 import org.elasticsearch.action.search.SearchRequest;
9
 import org.elasticsearch.action.search.SearchResponse;
11
 import org.elasticsearch.action.search.SearchResponse;
10
 import org.elasticsearch.client.RequestOptions;
12
 import org.elasticsearch.client.RequestOptions;
11
 import org.elasticsearch.client.RestHighLevelClient;
13
 import org.elasticsearch.client.RestHighLevelClient;
12
-import org.elasticsearch.index.query.BoolQueryBuilder;
13
-import org.elasticsearch.index.query.QueryBuilder;
14
-import org.elasticsearch.index.query.QueryBuilders;
15
-import org.elasticsearch.index.query.TermQueryBuilder;
14
+import org.elasticsearch.index.query.*;
16
 import org.elasticsearch.search.SearchHit;
15
 import org.elasticsearch.search.SearchHit;
17
 import org.elasticsearch.search.SearchHits;
16
 import org.elasticsearch.search.SearchHits;
18
 import org.elasticsearch.search.builder.SearchSourceBuilder;
17
 import org.elasticsearch.search.builder.SearchSourceBuilder;
19
 import org.springframework.stereotype.Service;
18
 import org.springframework.stereotype.Service;
20
 
19
 
21
 import java.io.IOException;
20
 import java.io.IOException;
21
+import java.lang.reflect.Field;
22
 import java.util.ArrayList;
22
 import java.util.ArrayList;
23
 import java.util.Collections;
23
 import java.util.Collections;
24
 import java.util.List;
24
 import java.util.List;
35
     private final RestHighLevelClient restHighLevelClient;
35
     private final RestHighLevelClient restHighLevelClient;
36
     private final ObjectMapper objectMapper;
36
     private final ObjectMapper objectMapper;
37
 
37
 
38
-    static final String[] keyNames = new String[]{
38
+    static final String[] SEARCH_KEY_NAMES = new String[]{
39
             "agencyName.keyword",
39
             "agencyName.keyword",
40
             "agencyDetail.keyword",
40
             "agencyDetail.keyword",
41
             "unitType.keyword",
41
             "unitType.keyword",
42
             "nameOfBuilding.keyword",
42
             "nameOfBuilding.keyword",
43
     };
43
     };
44
 
44
 
45
-    static String[] queryColumns = new String[]{"unitId", "nameOfBuilding", "agencyDetail", "agencyName"};
45
+    static final String[] MATCH_KEY_NAMES = new String[]{
46
+            "agencyAttributeClassId",
47
+            "regulatoryLevelId",
48
+            "property",
49
+            "classify"
50
+    };
51
+
52
+    static String[] queryColumns = new String[]{"unitId", "nameOfBuilding", "agencyDetail", "agencyName", "agencyAttributeClassId", "regulatoryLevelId", "property", "classify"};
46
 
53
 
47
     public UnitServiceImpl(RestHighLevelClient restHighLevelClient,
54
     public UnitServiceImpl(RestHighLevelClient restHighLevelClient,
48
                            ObjectMapper objectMapper) {
55
                            ObjectMapper objectMapper) {
51
     }
58
     }
52
 
59
 
53
     @Override
60
     @Override
54
-    public List<UnitAgencyDTO> getUnitAgencyByQuery(String agencyPath, String inputKeyword, int page, int size, String... indices) throws IOException {
55
-        List<Integer> agencyIdList = AgencyPathUtil.splitAgencyId(agencyPath);
61
+    public List<UnitAgencyDTO> getUnitAgencyByQuery(UnitAgencyQuery queryParam, String... indices) throws IOException {
62
+        List<Integer> agencyIdList = AgencyPathUtil.splitAgencyId(queryParam.getAgencyPath());
56
         if (agencyIdList.isEmpty()) {
63
         if (agencyIdList.isEmpty()) {
57
             return Collections.emptyList();
64
             return Collections.emptyList();
58
         }
65
         }
59
         QueryBuilder agencyIdBoolQuery = agencyIdListCondition(agencyIdList);
66
         QueryBuilder agencyIdBoolQuery = agencyIdListCondition(agencyIdList);
60
-        QueryBuilder keywordBoolQuery = multiInputParamKeywordBool(inputKeyword);
67
+        QueryBuilder keywordBoolQuery = multiInputParamKeywordBool(queryParam.getKeyword());
61
 
68
 
62
         BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery().must(agencyIdBoolQuery);
69
         BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery().must(agencyIdBoolQuery);
63
 
70
 
65
             queryBuilder.must(keywordBoolQuery);
72
             queryBuilder.must(keywordBoolQuery);
66
         }
73
         }
67
 
74
 
75
+        List<QueryBuilder> queryBuilders = arrayParamQuery(queryParam);
76
+        for (QueryBuilder builder : queryBuilders) {
77
+            queryBuilder.must(builder);
78
+        }
79
+
80
+        int from = (queryParam.getPage() - 1) * queryParam.getSize();
68
 
81
 
69
         SearchRequest searchRequest = new SearchRequest();
82
         SearchRequest searchRequest = new SearchRequest();
70
         SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
83
         SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
71
         searchSourceBuilder.query(queryBuilder);
84
         searchSourceBuilder.query(queryBuilder);
72
         searchSourceBuilder.fetchSource(queryColumns, new String[]{});
85
         searchSourceBuilder.fetchSource(queryColumns, new String[]{});
73
-        searchSourceBuilder.from((page - 1) * size);
74
-        searchSourceBuilder.size(size);
86
+        searchSourceBuilder.from(from);
87
+        searchSourceBuilder.size(queryParam.getSize());
75
         searchRequest.source(searchSourceBuilder);
88
         searchRequest.source(searchSourceBuilder);
76
         searchRequest.indices(indices);
89
         searchRequest.indices(indices);
77
 
90
 
296
 
309
 
297
         final BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
310
         final BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
298
 
311
 
299
-        for (String kn : keyNames) {
312
+        for (String kn : SEARCH_KEY_NAMES) {
300
             QueryBuilder queryBuilder = QueryBuilders.wildcardQuery(kn, "*" + keyword + "*");
313
             QueryBuilder queryBuilder = QueryBuilders.wildcardQuery(kn, "*" + keyword + "*");
301
             // QueryBuilder queryBuilder = QueryBuilders.matchQuery(kn, keyword);
314
             // QueryBuilder queryBuilder = QueryBuilders.matchQuery(kn, keyword);
302
             boolQueryBuilder.should(queryBuilder);
315
             boolQueryBuilder.should(queryBuilder);
304
         return boolQueryBuilder;
317
         return boolQueryBuilder;
305
     }
318
     }
306
 
319
 
320
+
321
+    private List<QueryBuilder> arrayParamQuery(UnitAgencyQuery queryParam) {
322
+        List<QueryBuilder> queryArray = new ArrayList<>(MATCH_KEY_NAMES.length);
323
+
324
+        for (String matchKeyName : MATCH_KEY_NAMES) {
325
+
326
+            Object value = null;
327
+            try {
328
+                Field declaredField = UnitAgencyQuery.class.getDeclaredField(matchKeyName);
329
+                declaredField.setAccessible(true);
330
+                value = declaredField.get(queryParam);
331
+
332
+            } catch (NoSuchFieldException | IllegalAccessException e) {
333
+                e.printStackTrace();
334
+            }
335
+            if (value == null) {
336
+                continue;
337
+            }
338
+            String listString = value.toString();
339
+            int[] ints = Utils.paramToArray(listString);
340
+            if (ints.length == 1) {
341
+                TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery(matchKeyName, ints[0]);
342
+                queryArray.add(termQueryBuilder);
343
+            } else if (ints.length > 1) {
344
+                TermsQueryBuilder termsQueryBuilder = QueryBuilders.termsQuery(matchKeyName, ints);
345
+                queryArray.add(termsQueryBuilder);
346
+            }
347
+
348
+        }
349
+
350
+        return queryArray;
351
+    }
352
+
307
 }
353
 }

+ 32 - 0
elastic-publish-service/src/main/java/com/vcarecity/publish/util/Utils.java View File

1
+package com.vcarecity.publish.util;
2
+
3
+/**
4
+ * @author VcKerry on 12/19/19
5
+ */
6
+
7
+public class Utils {
8
+
9
+    public static final int[] EMPTY_PARAM = new int[0];
10
+
11
+    public static int[] paramToArray(String input) {
12
+        if (input == null) {
13
+            return EMPTY_PARAM;
14
+        }
15
+        input = input.trim();
16
+        if (input.length() == 0) {
17
+            return EMPTY_PARAM;
18
+        }
19
+
20
+        String[] split = input.split(",");
21
+        if (split.length == 0) {
22
+            return EMPTY_PARAM;
23
+        }
24
+        int[] res = new int[split.length];
25
+        for (int i = 0; i < split.length; i++) {
26
+            res[i] = Integer.parseInt(split[i]);
27
+        }
28
+        return res;
29
+    }
30
+
31
+
32
+}

+ 5 - 5
elastic-publish-service/src/main/resources/application-dev.yml View File

18
     host: 192.168.10.112
18
     host: 192.168.10.112
19
     port: 6379
19
     port: 6379
20
     password: admin~1(^-^)
20
     password: admin~1(^-^)
21
-logging:
22
-  level:
23
-    com:
24
-      vcarecity: debug
25
 mybatis:
21
 mybatis:
26
   type-aliases-package: com.vcarecity.publish.entity
22
   type-aliases-package: com.vcarecity.publish.entity
27
   mapper-locations: classpath:mapper/*.xml
23
   mapper-locations: classpath:mapper/*.xml
28
-
24
+  configuration:
25
+    map-underscore-to-camel-case: true
29
 debug: true
26
 debug: true
27
+app:
28
+  scheduling:
29
+    enable: false

+ 38 - 0
elastic-publish-service/src/main/resources/logback-spring.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<configuration scan="true" scanPeriod="120 seconds">
3
+
4
+    <!--spring-boot-2.0.3.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml-->
5
+    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
6
+
7
+
8
+    <!--默认 Appender-->
9
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
10
+        <encoder>
11
+            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
12
+            <charset>utf8</charset>
13
+        </encoder>
14
+    </appender>
15
+
16
+
17
+    <root level="INFO">
18
+        <appender-ref ref="CONSOLE"/>
19
+    </root>
20
+
21
+
22
+    <springProfile name="dev">
23
+
24
+
25
+        <logger name="com.vcarecity" level="DEBUG" additivity="false">
26
+            <appender-ref ref="CONSOLE"/>
27
+        </logger>
28
+
29
+
30
+        <logger name="com.vcarecity.publish.mapper.AgencyMapper" level="INFO" additivity="false">
31
+            <appender-ref ref="CONSOLE"/>
32
+        </logger>
33
+
34
+
35
+    </springProfile>
36
+
37
+
38
+</configuration>

+ 10 - 1
elastic-publish-service/src/main/resources/mapper/AgencyMapper.xml View File

23
         <result column="NAME_OF_BUILDING" property="nameOfBuilding"/>
23
         <result column="NAME_OF_BUILDING" property="nameOfBuilding"/>
24
         <result column="UNIT_TYPE_ID" property="unitTypeId"/>
24
         <result column="UNIT_TYPE_ID" property="unitTypeId"/>
25
         <result column="UNIT_TYPE" property="unitType"/>
25
         <result column="UNIT_TYPE" property="unitType"/>
26
+        <result column="PROPERTY" property="property"/>
27
+        <result column="CLASSIFY" property="classify"/>
28
+        <result column="REGULATORY_LEVEL_ID" property="regulatoryLevelId"/>
29
+        <result column="AGENCY_ATTRIBUTE_CLASS_ID" property="agencyAttributeClassId"/>
26
     </resultMap>
30
     </resultMap>
27
 
31
 
28
 
32
 
37
                TB.BUILDING_ID,
41
                TB.BUILDING_ID,
38
                TB.NAME_OF_BUILDING,
42
                TB.NAME_OF_BUILDING,
39
                TUT.UNIT_TYPE_ID,
43
                TUT.UNIT_TYPE_ID,
40
-               TUT.UNIT_TYPE
44
+               TUT.UNIT_TYPE,
45
+               TUT.PROPERTY,
46
+               TUT.CLASSIFY,
47
+               TAE.REGULATORY_LEVEL_ID,
48
+               TAE.AGENCY_ATTRIBUTE_CLASS_ID
41
         FROM (select *
49
         FROM (select *
42
               from T_AGENCY I_TAG
50
               from T_AGENCY I_TAG
43
               where UPDATESTAMP between '${fromDate}' and '${toDate}'
51
               where UPDATESTAMP between '${fromDate}' and '${toDate}'
45
                  INNER JOIN T_UNIT TU ON TU.AGENCY_ID = TAG.AGENCY_ID
53
                  INNER JOIN T_UNIT TU ON TU.AGENCY_ID = TAG.AGENCY_ID
46
                  INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
54
                  INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
47
                  INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
55
                  INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
56
+                 INNER JOIN T_AGENCY_EXTEND TAE ON TAE.AGENCY_ID = TU.AGENCY_ID
48
     </select>
57
     </select>
49
 
58
 
50
     <select id="findAgencyNameByAgencyIdList" resultType="agencyEntity" parameterType="list">
59
     <select id="findAgencyNameByAgencyIdList" resultType="agencyEntity" parameterType="list">

+ 18 - 4
elastic-publish-service/src/main/resources/mapper/UnitMapper.xml View File

13
         <result column="NAME_OF_BUILDING" property="nameOfBuilding"/>
13
         <result column="NAME_OF_BUILDING" property="nameOfBuilding"/>
14
         <result column="UNIT_TYPE_ID" property="unitTypeId"/>
14
         <result column="UNIT_TYPE_ID" property="unitTypeId"/>
15
         <result column="UNIT_TYPE" property="unitType"/>
15
         <result column="UNIT_TYPE" property="unitType"/>
16
+        <result column="PROPERTY" property="property"/>
17
+        <result column="CLASSIFY" property="classify"/>
18
+        <result column="REGULATORY_LEVEL_ID" property="regulatoryLevelId"/>
19
+        <result column="AGENCY_ATTRIBUTE_CLASS_ID" property="agencyAttributeClassId"/>
16
     </resultMap>
20
     </resultMap>
17
 
21
 
18
     <select id="findUpdateList" resultType="unitEntity">
22
     <select id="findUpdateList" resultType="unitEntity">
33
                TB.BUILDING_ID,
37
                TB.BUILDING_ID,
34
                TB.NAME_OF_BUILDING,
38
                TB.NAME_OF_BUILDING,
35
                TUT.UNIT_TYPE_ID,
39
                TUT.UNIT_TYPE_ID,
36
-               TUT.UNIT_TYPE
40
+               TUT.UNIT_TYPE,
41
+               TUT.PROPERTY,
42
+               TUT.CLASSIFY,
43
+               TAE.REGULATORY_LEVEL_ID,
44
+               TAE.AGENCY_ATTRIBUTE_CLASS_ID
37
         FROM (select *
45
         FROM (select *
38
               from T_UNIT I_TU
46
               from T_UNIT I_TU
39
               where UPDATESTAMP between '${fromDate}' and '${toDate}'
47
               where UPDATESTAMP between '${fromDate}' and '${toDate}'
41
                  INNER JOIN T_AGENCY TAG ON TU.AGENCY_ID = TAG.AGENCY_ID
49
                  INNER JOIN T_AGENCY TAG ON TU.AGENCY_ID = TAG.AGENCY_ID
42
                  INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
50
                  INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
43
                  INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
51
                  INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
52
+                 INNER JOIN T_AGENCY_EXTEND TAE ON TAE.AGENCY_ID = TU.AGENCY_ID
44
     </select>
53
     </select>
45
 
54
 
46
-    <select id="findAllWithPage" resultType="unitAgencyMergeEntity">
55
+    <select id="findAllWithPage" resultMap="unitAgencyMergeEntityMap">
47
         SELECT TU.UNIT_ID,
56
         SELECT TU.UNIT_ID,
48
                TU.DTU_NO,
57
                TU.DTU_NO,
49
                TU.PUSER_CODE,
58
                TU.PUSER_CODE,
53
                TB.BUILDING_ID,
62
                TB.BUILDING_ID,
54
                TB.NAME_OF_BUILDING,
63
                TB.NAME_OF_BUILDING,
55
                TUT.UNIT_TYPE_ID,
64
                TUT.UNIT_TYPE_ID,
56
-               TUT.UNIT_TYPE
65
+               TUT.UNIT_TYPE,
66
+               TUT.PROPERTY,
67
+               TUT.CLASSIFY,
68
+               TAE.REGULATORY_LEVEL_ID,
69
+               TAE.AGENCY_ATTRIBUTE_CLASS_ID
57
         FROM T_UNIT TU
70
         FROM T_UNIT TU
58
                  INNER JOIN T_AGENCY TAG ON TU.AGENCY_ID = TAG.AGENCY_ID AND TU.ISDELETED = 0
71
                  INNER JOIN T_AGENCY TAG ON TU.AGENCY_ID = TAG.AGENCY_ID AND TU.ISDELETED = 0
59
                  INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
72
                  INNER JOIN T_BUILDING TB ON TB.BUILDING_ID = TU.BUILDING_ID
60
                  INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
73
                  INNER JOIN T_UNIT_TYPE TUT ON TUT.UNIT_TYPE_ID = TU.UNIT_TYPE_ID
61
-        limit ?,?
74
+                 INNER JOIN T_AGENCY_EXTEND TAE ON TAE.AGENCY_ID = TU.AGENCY_ID
75
+        limit ${page},${size}
62
     </select>
76
     </select>
63
 </mapper>
77
 </mapper>

+ 41 - 0
elastic-publish-service/src/test/java/com/vcarecity/publish/config/MapperConfigTest.java View File

1
+package com.vcarecity.publish.config;
2
+
3
+import com.fasterxml.jackson.core.type.TypeReference;
4
+import com.fasterxml.jackson.databind.DeserializationFeature;
5
+import com.fasterxml.jackson.databind.ObjectMapper;
6
+import com.vcarecity.publish.entity.AgencyEntity;
7
+import org.junit.jupiter.api.Test;
8
+
9
+import java.lang.reflect.Type;
10
+import java.util.Map;
11
+
12
+class MapperConfigTest {
13
+    @Test
14
+    public void objectMapper() throws Exception {
15
+        ObjectMapper objectMapper = new ObjectMapper();
16
+        // objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
17
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
18
+
19
+
20
+        AgencyEntity ae = new AgencyEntity();
21
+        ae.setAgencyId(11L);
22
+        ae.setIsDeleted(0);
23
+
24
+        String s = objectMapper.writeValueAsString(ae);
25
+        System.out.println(s);
26
+
27
+        Map<String, Object> map = objectMapper.convertValue(ae, new TypeReference<Map<String, Object>>() {
28
+            @Override
29
+            public Type getType() {
30
+                return super.getType();
31
+            }
32
+        });
33
+        System.out.println(map);
34
+
35
+        String value = "{\"agencyId\":11,\"agencyPath\":null,\"agencyName\":null,\"isDeleted\":0}";
36
+
37
+        AgencyEntity agencyEntity = objectMapper.readValue(value, AgencyEntity.class);
38
+        System.out.println(agencyEntity);
39
+
40
+    }
41
+}

+ 20 - 0
elastic-publish-service/src/test/java/com/vcarecity/publish/elastic/service/impl/ElasticLoadDataServiceImplTest.java View File

1
+package com.vcarecity.publish.elastic.service.impl;
2
+
3
+import com.vcarecity.publish.elastic.service.ElasticLoadDataService;
4
+import org.junit.jupiter.api.Test;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.boot.test.context.SpringBootTest;
7
+
8
+import java.io.IOException;
9
+
10
+@SpringBootTest
11
+class ElasticLoadDataServiceImplTest {
12
+
13
+    @Autowired
14
+    private ElasticLoadDataService elasticLoadDataService;
15
+
16
+    @Test
17
+    void loadData() throws IOException {
18
+        elasticLoadDataService.loadData();
19
+    }
20
+}

+ 21 - 0
elastic-publish-service/src/test/java/com/vcarecity/publish/elastic/service/impl/ElasticQueryServiceImplTest.java View File

1
+package com.vcarecity.publish.elastic.service.impl;
2
+
3
+import com.vcarecity.publish.elastic.service.ElasticQueryService;
4
+import org.junit.jupiter.api.Test;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.boot.test.context.SpringBootTest;
7
+
8
+import java.io.IOException;
9
+
10
+
11
+@SpringBootTest
12
+class ElasticQueryServiceImplTest {
13
+
14
+    @Autowired
15
+    private ElasticQueryService elasticQueryService;
16
+
17
+    @Test
18
+    void testQuery() throws IOException {
19
+        elasticQueryService.testQuery();
20
+    }
21
+}

+ 18 - 0
elastic-publish-service/src/test/java/com/vcarecity/publish/mapper/AgencyMapperTest.java View File

1
 package com.vcarecity.publish.mapper;
1
 package com.vcarecity.publish.mapper;
2
 
2
 
3
+import com.vcarecity.publish.entity.AgencyEntity;
3
 import org.junit.jupiter.api.Test;
4
 import org.junit.jupiter.api.Test;
4
 import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.boot.test.context.SpringBootTest;
6
 import org.springframework.boot.test.context.SpringBootTest;
7
+import org.springframework.test.context.TestPropertySource;
6
 
8
 
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+
12
+@TestPropertySource(properties = "app.scheduling.enable=false")
7
 @SpringBootTest
13
 @SpringBootTest
8
 public class AgencyMapperTest {
14
 public class AgencyMapperTest {
9
 
15
 
26
 
32
 
27
         agencyMapper.findUpdateUaList(from, to);
33
         agencyMapper.findUpdateUaList(from, to);
28
     }
34
     }
35
+
36
+    @Test
37
+    public void findAgencyNameByAgencyIdList() {
38
+        List<Integer> id = new ArrayList<>();
39
+        id.add(1);
40
+        id.add(297);
41
+        id.add(80424);
42
+        List<AgencyEntity> agencyNameByAgencyIdList = agencyMapper.findAgencyNameByAgencyIdList(id);
43
+        for (AgencyEntity agencyEntity : agencyNameByAgencyIdList) {
44
+            System.out.println(agencyEntity);
45
+        }
46
+    }
29
 }
47
 }

+ 3 - 0
elastic-publish-service/src/test/java/com/vcarecity/publish/service/impl/ElasticUpdateServiceImplTest.java View File

12
     @Autowired
12
     @Autowired
13
     private ElasticUpdateService elasticUpdateService;
13
     private ElasticUpdateService elasticUpdateService;
14
 
14
 
15
+
15
     @Test
16
     @Test
16
     void updateTest() throws Exception {
17
     void updateTest() throws Exception {
18
+
17
         elasticUpdateService.updateTest();
19
         elasticUpdateService.updateTest();
20
+
18
     }
21
     }
19
 
22
 
20
 
23