基于Flink的个人装扮商城群体用户画像与数据实时统计系统 - 其余模块代码

一、RegisterCenter

  • pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>RegisterCenter</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

  • application.yml
server:
  port: 8761

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

spring:
  application:
    name: RegiterCenter
  • EurekaServerApplication.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

/**
 * @author 32098
 */
@EnableAutoConfiguration
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}

二、StaticsInfoObtainModule

  • pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>StaticsInfoObtainModule</artifactId>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.44</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.49</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>
  • application.yml
server:
  port: 8763

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

spring:
  application:
    name: StaticsInfoObtainModule
  main:
    allow-bean-definition-overriding: true
  datasource:
    url: jdbc:mysql://master:3306/user_portrait?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
    username: root
    password: Hive@2020
    driver-class-name: com.mysql.jdbc.Driver

mybatis:
  configuration:
    map-underscore-to-camel-case: true

  • entity
package cn.edu.neu.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 32098
 *
 * 用户画像 Statics
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class StaticsInfo {
    private String staticName;
    private String staticDetail;
    private Long staticData;
}

package cn.edu.neu.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 32098
 *
 * 产品浏览计数Bean
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class SingleTypeScanCount {
    private String dealtTime;
    private long scanCount;
}


package cn.edu.neu.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 * @author 32098
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ProductTypeScanCount {
    private Map<String, List<SingleTypeScanCount>> typeAndScanCount;
}

package cn.edu.neu.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 32098
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ProductTypeSale {
    private String productType;
    private Double totalSale;
}


package cn.edu.neu.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 * @author 32098
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ConsumptionLevelDetail {
    private String userId;
    private String avgAmount;
    private String level;
}

  • control
package cn.edu.neu.control;

import cn.edu.neu.entity.*;
import cn.edu.neu.service.MysqlDataServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * @author 32098
 */
@RestController
@RequestMapping("mysqlData")
public class MysqlDataControl {
    @Autowired
    private MysqlDataServiceImpl mysqlDataServiceImpl;

    @RequestMapping(value = "yearBase", method = RequestMethod.POST)
    public List<StaticsInfo> getYearBaseStatics(){
        return mysqlDataServiceImpl.getStaticsBy("yearBase");
    }

    @RequestMapping(value = "useTypeLike",method = RequestMethod.POST)
    public List<StaticsInfo> getUseTypeStatics(){
        return mysqlDataServiceImpl.getStaticsBy("useType");
    }

    @RequestMapping(value = "payTypeLike",method = RequestMethod.POST)
    public List<StaticsInfo> getPayTypeStatics(){
        return mysqlDataServiceImpl.getStaticsBy("payType");
    }

    @RequestMapping(value = "emailLike", method = RequestMethod.POST)
    public List<StaticsInfo> getEmailLikeStatics(){
        return mysqlDataServiceImpl.getStaticsBy("email");
    }

    @RequestMapping(value = "carrierLike", method = RequestMethod.POST)
    public List<StaticsInfo> getCarrierLikeStatics(){
        return mysqlDataServiceImpl.getStaticsBy("carrier");
    }

    @RequestMapping(value = "brandLikeOfClothes", method = RequestMethod.POST)
    public List<StaticsInfo> getBrandLikeOfClothesStatics(){
        return mysqlDataServiceImpl.getStaticsBy("brandLikeOfClothes");
    }

    @RequestMapping(value = "brandLikeOfBags", method = RequestMethod.POST)
    public List<StaticsInfo> getBrandLikeOfBagsStatics(){
        return mysqlDataServiceImpl.getStaticsBy("brandLikeOfBags");
    }

    @RequestMapping(value = "brandLikeOfShoes", method = RequestMethod.POST)
    public List<StaticsInfo> getBrandLikeOfShoesStatics(){
        return mysqlDataServiceImpl.getStaticsBy("brandLikeOfShoes");
    }

    @RequestMapping(value = "consumptionLevel",method = RequestMethod.POST)
    public List<StaticsInfo> searchConsumptionLevel(){
        return mysqlDataServiceImpl.getConsumptionLevelStatics();
    }

    @RequestMapping(value = "bagTypeScanCount", method = RequestMethod.POST)
    public List<SingleTypeScanCount> getBagTypeScanCount(){
        return mysqlDataServiceImpl.getSingleTypeScanCount("Bags");
    }

    @RequestMapping(value = "clothTypeScanCount", method = RequestMethod.POST)
    public List<SingleTypeScanCount> getClothTypeScanCount(){
        return mysqlDataServiceImpl.getSingleTypeScanCount("Clothes");
    }

    @RequestMapping(value = "shoeTypeScanCount", method = RequestMethod.POST)
    public List<SingleTypeScanCount> getShoeTypeCount(){
        return mysqlDataServiceImpl.getSingleTypeScanCount("Shoes");
    }

    @RequestMapping(value = "productTypeScanCount", method = RequestMethod.POST)
    public ProductTypeScanCount getProductTypeScanCount(){
        return mysqlDataServiceImpl.getProductTypeScanCount();
    }

    @RequestMapping(value = "consumptionLevelDetail", method = RequestMethod.POST)
    public List<ConsumptionLevelDetail> getConsumptionLevelDetail(){
        return mysqlDataServiceImpl.getConsumptionLevelDetail();
    }

    @RequestMapping(value = "productTypeSale", method = RequestMethod.POST)
    public List<ProductTypeSale> getProductTypeSale(){
        return mysqlDataServiceImpl.getProductTypeSale();
    }
}

  • service
package cn.edu.neu.service;

import cn.edu.neu.dao.MysqlDao;
import cn.edu.neu.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 *
 * @author 32098
 */
@Service
public class MysqlDataServiceImpl{
    @Autowired
    private MysqlDao mysqlDao;

    public List<StaticsInfo> getStaticsBy(String staticName) {
        return mysqlDao.getStaticByName(staticName);
    }

    public List<StaticsInfo> getConsumptionLevelStatics(){
        return mysqlDao.getConsumptionLevelStatic();
    }

    public List<SingleTypeScanCount> getSingleTypeScanCount(String productType){
        return mysqlDao.getSingleTypeScanCount(productType);
    }

    public ProductTypeScanCount getProductTypeScanCount(){
        List<SingleTypeScanCount> bagTypeScanCount = this.getSingleTypeScanCount("Bags");
        List<SingleTypeScanCount> clothTypeScanCount = this.getSingleTypeScanCount("Clothes");
        List<SingleTypeScanCount> shoeTypeScanCount = this.getSingleTypeScanCount("Shoes");

        Collections.reverse(bagTypeScanCount);
        Collections.reverse(clothTypeScanCount);
        Collections.reverse(clothTypeScanCount);

        Map<String, List<SingleTypeScanCount>> productTypeScanCounts = new HashMap<>();
        productTypeScanCounts.put("Bags", bagTypeScanCount);
        productTypeScanCounts.put("Clothes", clothTypeScanCount);
        productTypeScanCounts.put("Shoes", shoeTypeScanCount);

        return new ProductTypeScanCount(productTypeScanCounts);
    }

    public List<ConsumptionLevelDetail> getConsumptionLevelDetail(){
        return mysqlDao.getConsumptionLevelDetail();
    }

    public List<ProductTypeSale> getProductTypeSale(){
        return mysqlDao.getProductTypeSale();
    }
}

  • dao
package cn.edu.neu.dao;

import cn.edu.neu.entity.ConsumptionLevelDetail;
import cn.edu.neu.entity.ProductTypeSale;
import cn.edu.neu.entity.SingleTypeScanCount;
import cn.edu.neu.entity.StaticsInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 32098
 */
@Repository
public interface MysqlDao {
    @Select("select * from statics where static_name=#{name}")
    List<StaticsInfo> getStaticByName(String name);

    @Select("select 'consumptionLevel' as static_name, level as static_detail, count(*) as static_data from user_consumption_level group by level")
    List<StaticsInfo> getConsumptionLevelStatic();

    @Select("select dealt_time, scan_count from product_type_scan_count where product_type=#{productType} order by dealt_time desc limit 6")
    List<SingleTypeScanCount> getSingleTypeScanCount(String productType);

    @Select("select * from user_consumption_level")
    List<ConsumptionLevelDetail> getConsumptionLevelDetail();

    @Select("select * from product_type_total_sale order by total_sale desc")
    List<ProductTypeSale> getProductTypeSale();
}

  • StartupMain.java
package cn.edu.neu;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

/**
 *
 * @author 32098
 */
@MapperScan("cn.edu.neu.dao")
@SpringBootApplication
@EnableEurekaClient
public class StartupMain {
    public static void main(String[] args) {
        SpringApplication.run( StartupMain.class, args );
    }
}


三、StaticsViewModule

  • pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>StaticsViewModule</artifactId>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.44</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.49</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>

  • application.yml
server:
  port: 8765

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

spring:
  application:
    name: StaticsViewModule
  main:
    allow-bean-definition-overriding: true
  datasource:
    url: jdbc:mysql://localhost:3306/user_portrait?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
    username: root
    password: Hive@2020
    driver-class-name: com.mysql.jdbc.Driver

mybatis:
  configuration:
    map-underscore-to-camel-case: true


  • po: entity above
  • vo
package cn.edu.neu.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 *
 * @author 32098
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Charts {
    /**
     * x轴的值
     */
    private List<String> xAxisData;
    /**
     * y轴的值
     */
    private List<Long> yAxisData;
}

package cn.edu.neu.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author 32098
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class SaleCharts {
    /**
     * x轴的值
     */
    private List<String> xAxisData;
    /**
     * y轴的值
     */
    private List<Double> yAxisData;
}

package cn.edu.neu.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author 32098
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ScanCountView {
    private List<String> legends;
    private List<String> bagScanTimes;
    private List<String> clothScanTimes;
    private List<String> shoeScanTimes;
    private List<Long> bagScanCounts;
    private List<Long> clothScanCounts;
    private List<Long> shoeScanCounts;
    private List<Long> totalCounts;
}

  • control
package cn.edu.neu.control;

import cn.edu.neu.po.*;
import cn.edu.neu.vo.*;
import com.alibaba.fastjson.JSONObject;
import cn.edu.neu.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 *
 * @author 32098
 */
@RestController
@RequestMapping("mysqlData")
@CrossOrigin
public class DataViewControl {
    private final List<String> staticNames = Arrays.asList("yearBase", "useTypeLike", "emailLike", "carrierLike", "brandLikeOfClothes", "brandLikeOfBags", "brandLikeOfShoes", "consumptionLevel", "payTypeLike");

    @Autowired
    private DataService dataService;

    @RequestMapping(value = "resultInfoView", method = RequestMethod.POST)
    public String resultInfoView(@RequestBody Map<String, String> staticNameMap){
        String staticName = staticNameMap.get("staticName");
        List<StaticsInfo> list = new ArrayList<StaticsInfo>();

        System.out.println(staticName);

        int i = 0;
        for (String name : staticNames) {
            if(name.equals(staticName)){
                switch (i){
                    case 0: list = dataService.yearBaseStatics();break;
                    case 1: list = dataService.useTypeStatics();break;
                    case 2: list = dataService.emailStatics();break;
                    case 3: list = dataService.carrierStatics();break;
                    case 4: list = dataService.brandLikeOfClothesStatics();break;
                    case 5: list = dataService.brandLikeOfBagsStatics();break;
                    case 6: list = dataService.brandLikeOfShoesStatics();break;
                    case 7: list = dataService.consumptionLevelStatics();break;
                    case 8: list = dataService.payTypeStatics();break;
                    default: break;
                }
            }
            i++;
        }

        Charts charts = new Charts();
        // 存储x轴的值
        List<String> xList = new ArrayList<String>();
        // 存储y轴的值
        List<Long> yList =new ArrayList<Long>();

        for(StaticsInfo result: list){
            System.out.println(result.getStaticName()+" "+result.getStaticDetail()+" "+result.getStaticData());
            xList.add(result.getStaticDetail());
            yList.add(result.getStaticData());
        }

        charts.setXAxisData(xList);
        charts.setYAxisData(yList);

        return JSONObject.toJSONString(charts);
    }

    @RequestMapping(value = "consumptionLevelDetail",method = RequestMethod.POST)
    public List<ConsumptionLevelDetail> consumptionLevelDetail(){
        return dataService.getConsumptionLevelDetail();
    }

    @RequestMapping(value = "productTypeScanCount", method = RequestMethod.POST)
    public ProductTypeScanCount productTypeScanCount(){
        ProductTypeScanCount productTypeScanCount = dataService.productTypeScanCount();
        Map<String, List<SingleTypeScanCount>> map = productTypeScanCount.getTypeAndScanCount();
        map.forEach((k,v)->{
            System.out.println(k);
            for (SingleTypeScanCount singleTypeScanCount : v) {
                System.out.println(singleTypeScanCount.getDealtTime()+" "+singleTypeScanCount.getScanCount());
            }
            System.out.println("###############");
        });
        return productTypeScanCount;
    }

    @RequestMapping(value = "productTypeScanCountNew", method = RequestMethod.POST)
    public ScanCountView productTypeScanCountView(){
        ProductTypeScanCount productTypeScanCount = dataService.productTypeScanCount();
        Map<String, List<SingleTypeScanCount>> map = productTypeScanCount.getTypeAndScanCount();

        List<String> legends = new ArrayList<>();
        // 接下来3个List最终值与顺序一样
        List<String> bagScanTime = new ArrayList<>();
        List<String> clothScanTime = new ArrayList<>();
        List<String> shoeScanTime = new ArrayList<>();
        List<Long> bagScanCount = new ArrayList<>();
        List<Long> clothScanCount = new ArrayList<>();
        List<Long> shoeScanCount = new ArrayList<>();
        List<Long> totalCount = new ArrayList<>();

        map.forEach((k, v)->{
            if("Bags".equals(k)){
                legends.add(k);
                for (SingleTypeScanCount singleTypeScanCount : v) {
                    bagScanTime.add(singleTypeScanCount.getDealtTime());
                    bagScanCount.add(singleTypeScanCount.getScanCount());
                }
            }
            if("Clothes".equals(k)){
                legends.add(k);
                for (SingleTypeScanCount singleTypeScanCount : v) {
                    clothScanTime.add(singleTypeScanCount.getDealtTime());
                    clothScanCount.add(singleTypeScanCount.getScanCount());
                }
            }
            if("Shoes".equals(k)){
                legends.add(k);
                for (SingleTypeScanCount singleTypeScanCount : v) {
                    shoeScanTime.add(singleTypeScanCount.getDealtTime());
                    shoeScanCount.add(singleTypeScanCount.getScanCount());
                }
            }
        });

        for(int i=0; i<bagScanCount.size(); i++){
            totalCount.add(bagScanCount.get(i)+clothScanCount.get(i)+shoeScanCount.get(i));
        }

        return new ScanCountView(legends, bagScanTime, clothScanTime, shoeScanTime, bagScanCount, clothScanCount, shoeScanCount, totalCount);
    }

    @RequestMapping(value = "productTypeSale",method = RequestMethod.POST)
    public SaleCharts productTypeSales(@RequestBody Map<String, Integer> topN){
        int top = topN.get("topN");

        // 存储x轴的值
        List<String> xList = new ArrayList<>();
        // 存储y轴的值
        List<Double> yList =new ArrayList<>();
        List<ProductTypeSale> productTypeSales = dataService.getProductTypeSale();
        int stop = Math.min(top, productTypeSales.size());
        for(int i=0;i<stop;i++){
            System.out.println(productTypeSales.get(i).getProductType());
            xList.add(productTypeSales.get(i).getProductType());
            yList.add(productTypeSales.get(i).getTotalSale());
        }
        return new SaleCharts(xList, yList);
    }
}


  • service
package cn.edu.neu.service;

import cn.edu.neu.po.ProductTypeScanCount;
import cn.edu.neu.po.SingleTypeScanCount;
import cn.edu.neu.po.ConsumptionLevelDetail;
import cn.edu.neu.po.ProductTypeSale;
import cn.edu.neu.po.StaticsInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 *
 * @author 32098
 */
@FeignClient(value = "StaticsInfoObtainModule")
public interface DataService {

    @RequestMapping(value = "mysqlData/yearBase", method = RequestMethod.POST)
    public List<StaticsInfo> yearBaseStatics();

    @RequestMapping(value = "mysqlData/useTypeLike", method = RequestMethod.POST)
    public List<StaticsInfo> useTypeStatics();

    @RequestMapping(value = "mysqlData/payTypeLike", method = RequestMethod.POST)
    public List<StaticsInfo> payTypeStatics();

    @RequestMapping(value = "mysqlData/emailLike", method = RequestMethod.POST)
    public List<StaticsInfo> emailStatics();

    @RequestMapping(value = "mysqlData/carrierLike",method = RequestMethod.POST)
    public List<StaticsInfo> carrierStatics();

    @RequestMapping(value = "mysqlData/brandLikeOfClothes",method = RequestMethod.POST)
    public List<StaticsInfo> brandLikeOfClothesStatics();

    @RequestMapping(value = "mysqlData/brandLikeOfBags",method = RequestMethod.POST)
    public List<StaticsInfo> brandLikeOfBagsStatics();

    @RequestMapping(value = "mysqlData/brandLikeOfShoes",method = RequestMethod.POST)
    public List<StaticsInfo> brandLikeOfShoesStatics();

    @RequestMapping(value = "mysqlData/consumptionLevel",method = RequestMethod.POST)
    public List<StaticsInfo> consumptionLevelStatics();

    @RequestMapping(value = "mysqlData/bagTypeScanCount",method = RequestMethod.POST)
    public List<SingleTypeScanCount> bagTypeScanCount();

    @RequestMapping(value = "mysqlData/clothTypeScanCount",method = RequestMethod.POST)
    public List<SingleTypeScanCount> clothTypeScanCount();

    @RequestMapping(value = "mysqlData/shoeTypeScanCount",method = RequestMethod.POST)
    public List<SingleTypeScanCount> shoeTypeScanCount();

    @RequestMapping(value = "mysqlData/productTypeScanCount",method = RequestMethod.POST)
    public ProductTypeScanCount productTypeScanCount();

    @RequestMapping(value = "mysqlData/consumptionLevelDetail",method = RequestMethod.POST)
    public List<ConsumptionLevelDetail> getConsumptionLevelDetail();

    @RequestMapping(value = "mysqlData/productTypeSale",method = RequestMethod.POST)
    public List<ProductTypeSale> getProductTypeSale();
}


  • StartupViewMain.java
package cn.edu.neu;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

/**
 *
 * @author 32098
 */
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableDiscoveryClient
public class StartupViewMain {
    public static void main(String[] args) {
        SpringApplication.run(StartupViewMain.class, args);
    }
}


附:后端项目依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>UserPortrait</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>RegisterCenter</module>
        <module>StaticsInfoGenerateModule</module>
        <module>StaticsInfoObtainModule</module>
        <module>StaticsViewModule</module>
    </modules>
</project>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
用户画像作为大数据的根基,它抽象出一个用户的信息全貌,为进一步精准、快速地分析用户行为习惯、消费习惯等重要信息,提供了足够的数据基础,奠定了大数据时代的基石。 用户画像,即用户信息标签化,就是企业通过收集与分析消费者社会属性、生活习惯、消费行为等主要信息的数据之后,抽象出一个用户的商业全貌作是企业应用大数据技术的基本方式。用户画像为企业提供了足够的信息基础,能够帮助企业快速找到精准用户群体以及用户需求等更为广泛的反馈信息。 用户画像系统能很好地帮助企业分析用户的行为与消费习惯,可以预测商品的发展的趋势,提高产品质量,同时提高用户满意度。构建一个用户画像,包括数据源端数据收集、数据预处理、行为建模、构建用户画像。有些标签是可以直接获取到的,有些标签需要通过数据挖掘分析到!本套课程会带着你一步一步的实现用户画像案例,掌握了本套课程内容,可以让你感受到Flink+ClickHouse技术架构的强大和大数据应用的广泛性。 在这个数据爆发的时代,像大型电商的数据量达到百亿级别,我们往往无法对海量的明细数据做进一步层次的预聚合,大量的业务数据都是好几亿数据关联,并且我们需要聚合结果能在秒级返回。 包括我们的画像数据,也是有这方便的需求,那怎么才能达到秒级返回呢?ClickHouse正好满足我们的需求,它是非常的强大的。 本课程采用Flink+ClickHouse技术架构实现我们的画像系统,通过学习完本课程可以节省你摸索的时间,节省企业成本,提高企业开发效率。希望本课程对一些企业开发人员和对新技术栈有兴趣的伙伴有所帮助,如对我录制的教程内容有建议请及时交流。项目中采用到的算法包含Logistic Regression、Kmeans、TF-IDF等,Flink暂时支持的算法比较少,对于以上算法,本课程将带大家用Flink实现,并且结合真实场景,学完即用。系统包含所有终端的数据(移动端、PC端、小程序端),支持亿级数据量的分析和查询,并且是实时和近实时的对用户进行画像计算。本课程包含的画像指标包含:概况趋势,基础属性,行为特征,兴趣爱好,风险特征,消费特征,营销敏感度,用户标签信息,用户群里,商品关键字等几大指标模块,每个指标都会带大家实现。课程所涵盖的知识点包括:开发工具为:IDEA FlinkClickhouseHadoopHbaseKafkaCanalbinlogSpringBootSpringCloudHDFSVue.jsNode.jsElemntUIEcharts等等 课程亮点: 1.企业级实战、真实工业界产品 2.ClickHouse高性能列式存储数据库 3.提供原始日志数据进行效果检测 4.Flink join企业级实战演练 5.第四代计算引擎Flink+ClickHouse技术架构6.微服务架构技术SpringBoot+SpringCloud技术架构7.算法处理包含Logistic Regression、Kmeans、TF-IDF等8.数据实时同步落地方案实操9.统计终端的数据(移动端、PC端、小程序端) 10.支撑亿级海量数据用户画像平台11.实时和近实时的对用户进行画像计算12.后端+大数据技术栈+前端可视化13.提供技术落地指导支持 14.课程凝聚讲师多年实战经验,经验直接复制15.掌握全部内容能独立进行大数据用户平台的设计和实操企业一线架构师讲授,代码在老师的指导下企业可以复用,提供企业解决方案。  版权归作者所有,盗版将进行法律维权。 

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值