一、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>