Pārlūkot izejas kodu

第一次提交

QGC 4 gadi atpakaļ
vecāks
revīzija
e28460ebd4

+ 17 - 0
common/fire-common/pom.xml

@@ -9,5 +9,22 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.blue</groupId>
+            <artifactId>fire-dto</artifactId>
+            <version>1.0</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
     <artifactId>fire-common</artifactId>
 </project>

+ 44 - 0
common/fire-common/src/main/java/com.fire.common/esdemo/config/EsConfig.java

@@ -0,0 +1,44 @@
+package com.fire.common.esdemo.config;
+
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.index.fielddata.ScriptDocValues;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.elasticsearch.client.ClientConfiguration;
+import org.springframework.data.elasticsearch.client.RestClients;
+import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
+import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
+
+
+import java.time.Duration;
+
+
+@Configuration
+public class EsConfig {
+
+    @Value("${elasticsearch.rest.uris}")
+    private String hostAndPort;
+
+
+    @Bean
+    public RestHighLevelClient elasticsearchClient() {
+        ClientConfiguration clientConfiguration = ClientConfiguration.builder()
+                .connectedTo(hostAndPort)
+                .withConnectTimeout(Duration.ofSeconds(5))
+                .withSocketTimeout(Duration.ofSeconds(3))
+                .build();
+        return RestClients.create(clientConfiguration).rest();
+//        String[] res = hostAndPort.split(":");
+//        RestClientBuilder builder = RestClient.builder(new HttpHost(res[0],Integer.valueOf(res[1])));
+//        return new RestHighLevelClient(builder);
+    }
+
+    @Bean
+    public ElasticsearchRestTemplate elasticsearchTemplate() {
+        return new ElasticsearchRestTemplate(elasticsearchClient());
+    }
+}

+ 4 - 0
common/fire-dto/pom.xml

@@ -34,6 +34,10 @@
             <groupId>io.swagger</groupId>
             <artifactId>swagger-annotations</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 218 - 0
common/fire-dto/src/main/java/com/fire/es/OrderEsDto.java

@@ -0,0 +1,218 @@
+package com.fire.es;
+
+
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.elasticsearch.annotations.Document;
+import org.springframework.data.elasticsearch.annotations.Field;
+import org.springframework.data.elasticsearch.annotations.FieldType;
+
+import java.util.Date;
+
+@Data
+@Document(indexName = "flow_order_info", shards = 6)
+public class OrderEsDto {
+    /**
+     * 订单ID
+     */
+    @Id
+    private String orderId;
+
+    /**
+     * 接入ID号
+     */
+    @Field(type = FieldType.Keyword)
+    private String flowAppId;
+
+    /**
+     * 流量包ID号
+     */
+    @Field(type = FieldType.Keyword)
+    private String packageId;
+
+    /**
+     * 客户ID号
+     */
+    @Field(type = FieldType.Integer)
+    private Integer enterpriseId;
+
+    /**
+     * 订单类型 2:流量 3:话费
+     */
+    @Field(type = FieldType.Integer)
+    private Integer orderType;
+
+    /**
+     * 用户手机号
+     */
+    @Field(type = FieldType.Keyword)
+    private String usedMobile;
+
+    /**
+     * 客户订单号
+     */
+    @Field(type = FieldType.Keyword)
+    private String extorderId;
+
+    /**
+     * 分发记录号
+     */
+    @Field(type = FieldType.Keyword)
+    private String recId;
+
+    /**
+     * 下单时间
+     */
+    @Field(type = FieldType.Date)
+    private Date applyDate;
+    /**
+     * 激活日期
+     */
+    @Field(type = FieldType.Date)
+    private Date activeDate;
+    /**
+     * 订单超时
+     */
+    @Field(type = FieldType.Date)
+    private Date limitedDate;
+    /**
+     * 订单状态 1-待发 2-已发 3-成功
+     *   4-失败 5-风控
+     */
+    @Field(type = FieldType.Integer)
+    private Integer status;
+    /**
+     * 订单备注
+     */
+    @Field(type = FieldType.Keyword)
+    private String note;
+    /**
+     * 归属运营商
+     */
+    @Field(type = FieldType.Keyword)
+    private String mobileOperator;
+    /**
+     * 归属地市
+     */
+    @Field(type = FieldType.Text, analyzer = "ik_max_word")
+    private String mobileHome;
+    /**
+     * 供应商返回订单号
+     */
+    @Field(type = FieldType.Keyword)
+    private String gwSeqNo;
+    /**
+     * 供应商返回状态
+     */
+    @Field(type = FieldType.Keyword)
+    private String gwStatus;
+    /**
+     * 最后修改日期
+     */
+    @Field(type = FieldType.Date)
+    private Date lastModifyDate;
+    /**
+     * 供应商网关错误代码
+     */
+    @Field(type = FieldType.Keyword)
+    private String gwErrorCode;
+    /**
+     * 面额
+     */
+    @Field(type = FieldType.Integer)
+    private Integer flowAmount;
+
+    /**
+     * 回调状态
+     */
+    @Field(type = FieldType.Keyword)
+    private String dealFlag;
+
+    /**
+     * 未知
+     */
+    @Field(type = FieldType.Keyword)
+    private String oprCode;
+
+    /**
+     * 成本
+     */
+    @Field(type = FieldType.Integer)
+    private Integer usageLimit;
+
+    /**
+     * 分发组发送次数
+     */
+    @Field(type = FieldType.Integer)
+    private Integer batchCount;
+
+    /**
+     * 总发送次数
+     */
+    @Field(type = FieldType.Integer)
+    private Integer sendCount;
+    /**
+     * 省级行政编码
+     */
+    @Field(type = FieldType.Keyword)
+    private String areaCode;
+    /**
+     * 客户结算价格
+     */
+    @Field(type = FieldType.Integer)
+    private Integer price;
+    /**
+     * 代理商结算价格
+     */
+    @Field(type = FieldType.Integer)
+    private Integer partnerBalancePrice;
+    /**
+     * 运行商成本价格
+     */
+    @Field(type = FieldType.Integer)
+    private Integer operatorBalancePrice;
+
+    /**
+     * 客户产品
+     */
+    @Field(type = FieldType.Integer)
+    private Integer orderDetailId;
+
+    /**
+     * 通道ID
+     */
+    @Field(type = FieldType.Integer)
+    private Integer channelId;
+
+    /**
+     * 回调时间
+     */
+    @Field(type = FieldType.Date)
+    private Date checkTime;
+
+    /**
+     * 产品ID
+     */
+    @Field(type = FieldType.Keyword)
+    private String productId;
+
+    /**
+     * 备用1
+     */
+    @Field(type = FieldType.Keyword)
+    private String attr1;
+    /**
+     * 备用2
+     */
+    @Field(type = FieldType.Keyword)
+    private String attr2;
+
+    /**
+     * 备用3
+     */
+    @Field(type = FieldType.Keyword)
+    private String attr3;
+
+
+
+}

+ 11 - 2
modules/admin/pom.xml

@@ -8,9 +8,18 @@
         <version>1.0</version>
     </parent>
     <artifactId>admin</artifactId>
-
-
     <dependencies>
+        <!-- ==================ES配置================== start-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
+        </dependency>
+        <!-- ==================ES配置================== end-->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.20</version>
+        </dependency>
 
         <dependency>
             <groupId>org.springframework.security</groupId>

+ 11 - 0
modules/admin/src/main/java/com/fire/admin/repository/OrderRepository.java

@@ -0,0 +1,11 @@
+package com.fire.admin.repository;
+
+
+import com.fire.es.OrderEsDto;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface OrderRepository extends ElasticsearchRepository<OrderEsDto, String> {
+
+}

+ 59 - 0
modules/admin/src/main/java/com/fire/admin/request/OrderSearchPram.java

@@ -0,0 +1,59 @@
+package com.fire.admin.request;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@ApiModel(value = "订单查询请求头")
+@Data
+public class OrderSearchPram {
+
+    @ApiModelProperty(value = "订单号")
+    private String orderId;
+
+    @ApiModelProperty(value = "商户订单号")
+    private String extorderId;
+
+    @ApiModelProperty(value = "充值手机号")
+    private String usedMobile;
+
+    @ApiModelProperty(value = "查询下单时间范围开始")
+    private Date applyDateStart;
+
+    @ApiModelProperty(value = "查询下单时间范围结束")
+    private Date applyDateEnd;
+
+    @ApiModelProperty(value = "客户名称")
+    private String enterpriseIdDesc;
+
+    @ApiModelProperty(value = "通道名称")
+    private String channelIdDesc;
+
+    @ApiModelProperty(value = "订单状态")
+    private String status;
+
+    @ApiModelProperty(value = "运营商")
+    private String mobileOperator;
+
+    @ApiModelProperty(value = "面额")
+    private String flowAmount;
+
+    @ApiModelProperty(value = "回调时间开始范围")
+    private Date checkTimeStart;
+
+    @ApiModelProperty(value = "回调时间结束范围")
+    private Date checkTimeEnd;
+
+    @ApiModelProperty(value ="归属地")
+    private String mobileHome;
+
+    @ApiModelProperty(value ="查询页数")
+    private Integer page;
+
+    @ApiModelProperty(value ="每页显示条数")
+    private Integer size;
+
+}

+ 41 - 0
modules/admin/src/main/java/com/fire/admin/rest/OrderRest.java

@@ -0,0 +1,41 @@
+package com.fire.admin.rest;
+
+import com.fire.admin.request.OrderSearchPram;
+import com.fire.admin.service.OrderManagementService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Api(tags = "订单管理")
+@RestController
+@RequestMapping("/orderManagement")
+public class OrderRest {
+
+
+    @Autowired
+    private OrderManagementService orderManagementService;
+
+    /**
+     * 订单查询
+     *
+     * @param orderSearchPram 下单参数
+     * @return OrderSearchResponse( 下单响应对象
+     */
+    @PostMapping("/search")
+    @ApiOperation(value = "订单查询", notes = "order_search.py")
+    public String orderSearch(@RequestBody OrderSearchPram orderSearchPram) {
+
+        return orderManagementService.orderSearch(orderSearchPram);
+    }
+
+
+
+
+
+
+}

+ 125 - 0
modules/admin/src/main/java/com/fire/admin/service/OrderManagementService.java

@@ -0,0 +1,125 @@
+package com.fire.admin.service;
+
+import com.fire.admin.request.OrderSearchPram;
+import com.fire.es.OrderEsDto;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.util.Strings;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.index.query.RangeQueryBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
+import org.springframework.data.elasticsearch.core.SearchHit;
+import org.springframework.data.elasticsearch.core.SearchHits;
+import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
+import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+@Slf4j
+public class OrderManagementService {
+    @Autowired
+    private ElasticsearchRestTemplate restTemplate;
+
+    public String orderSearch(OrderSearchPram orderSearchPram) {
+        //以创建时间倒序排列
+        Sort sort = Sort.by(Sort.Direction.DESC, "applyDate");
+        Date applyDateStart = orderSearchPram.getApplyDateStart();
+        Date applyDateEnd = orderSearchPram.getApplyDateEnd();
+
+        int page = 0;
+        int size = 10;
+        if (null != orderSearchPram.getPage()) {
+            page = orderSearchPram.getPage();
+        }
+        if (null != orderSearchPram.getSize()) {
+            size = orderSearchPram.getSize();
+        }
+        //分页条件
+        Pageable pageable = PageRequest.of(page, size, sort);
+        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
+        RangeQueryBuilder rangeQueryBuilder = null;
+        //判断回调时间参数是否为空 不为空以回调时间来查询 否则用创建时间来查询
+        if (null != orderSearchPram.getCheckTimeStart()) {
+            rangeQueryBuilder = QueryBuilders.rangeQuery("checkTime")
+                    .gte(orderSearchPram.getCheckTimeStart().getTime())
+                    .lte(orderSearchPram.getCheckTimeEnd().getTime());
+        } else {
+            rangeQueryBuilder = QueryBuilders.rangeQuery("applyDate")
+                    .gte(applyDateStart.getTime())
+                    .lte(applyDateEnd.getTime());
+        }
+        //筛选条件
+        //订单号
+        if (Strings.isNotBlank(orderSearchPram.getOrderId())) {
+            boolQuery.must(QueryBuilders.termQuery("orderId", orderSearchPram.getOrderId()));
+        }
+        //商户订单号
+        if (Strings.isNotBlank(orderSearchPram.getExtorderId())) {
+            boolQuery.must(QueryBuilders.termQuery("extorderId", orderSearchPram.getExtorderId()));
+        }
+        //电话号码
+        if (Strings.isNotBlank(orderSearchPram.getUsedMobile())) {
+            boolQuery.must(QueryBuilders.termQuery("usedMobile", orderSearchPram.getUsedMobile()));
+        }
+        //电话号码
+        if (Strings.isNotBlank(orderSearchPram.getUsedMobile())) {
+            boolQuery.must(QueryBuilders.termQuery("usedMobile", orderSearchPram.getUsedMobile()));
+        }
+        //客户名称 暂时用的ID
+        if (Strings.isNotBlank(orderSearchPram.getEnterpriseIdDesc())) {
+            boolQuery.must(QueryBuilders.termQuery("enterpriseId", orderSearchPram.getEnterpriseIdDesc()));
+        }
+        //通道名称 暂时用的ID
+        if (Strings.isNotBlank(orderSearchPram.getChannelIdDesc())) {
+            boolQuery.must(QueryBuilders.termQuery("channelId", orderSearchPram.getChannelIdDesc()));
+        }
+        //订单状态
+        if (Strings.isNotBlank(orderSearchPram.getStatus())) {
+            boolQuery.must(QueryBuilders.termQuery("status", orderSearchPram.getStatus()));
+        }
+        //运营商
+        if (Strings.isNotBlank(orderSearchPram.getMobileOperator())) {
+            boolQuery.must(QueryBuilders.termQuery("mobileOperator", orderSearchPram.getMobileOperator()));
+        }
+        //面额
+        if (Strings.isNotBlank(orderSearchPram.getFlowAmount())) {
+            boolQuery.must(QueryBuilders.termQuery("flowAmount", orderSearchPram.getFlowAmount()));
+        }
+        //归属地
+        if (Strings.isNotBlank(orderSearchPram.getMobileHome())) {
+            BoolQueryBuilder tempQueryBuilder = QueryBuilders.boolQuery();
+            tempQueryBuilder.should(QueryBuilders.wildcardQuery("mobileHome.keyword", orderSearchPram.getMobileHome()));
+            boolQuery.must(tempQueryBuilder);
+        }
+
+        NativeSearchQuery query = new NativeSearchQueryBuilder()
+                .withPageable(pageable)
+                .withQuery(boolQuery.must(rangeQueryBuilder))
+                .build();
+        //查询数据
+        SearchHits<OrderEsDto> hits = restTemplate.search(query, OrderEsDto.class);
+        long total = hits.getTotalHits();
+        List<SearchHit<OrderEsDto>> searchHits = hits.getSearchHits();
+        System.out.println("一共" + total + "个");
+        System.out.println("搜索结果" + searchHits.size() + "个");
+        for (SearchHit<OrderEsDto> searchHit : searchHits) {
+            OrderEsDto stuEntity = searchHit.getContent();
+            log.info(stuEntity.toString());
+        }
+        return "success";
+    }
+}
+
+
+
+
+
+
+

+ 1 - 1
modules/admin/src/main/resources/bootstrap.yml

@@ -1,5 +1,5 @@
 server:
-  port: 8083
+  port: 8081
 
 spring:
   application:

+ 1 - 1
modules/admin/src/main/resources/mapper/SysUserMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace=" com.fire.admin.modules.mapper.SysUserMapper">
+<mapper namespace="com.fire.admin.modules.mapper.SysUserMapper">
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.fire.dto.system.SysUser">