Merge pull request 'zzw-one' (#31) from zzw-one into master
All checks were successful
continuous-integration/drone/tag Build is passing
All checks were successful
continuous-integration/drone/tag Build is passing
Reviewed-on: #31
This commit is contained in:
commit
8bee19b948
@ -79,6 +79,12 @@ public class SaleDataApi {
|
||||
return saleDataService.findBySaleMethod();
|
||||
}
|
||||
|
||||
@GetMapping("/itemType")
|
||||
@Operation(summary = "查询各个产品类型的购票人数")
|
||||
public List<Map<String, String>> findByItemType() {
|
||||
return saleDataService.findByDoItemType();
|
||||
}
|
||||
|
||||
@GetMapping("/wuyi/{x}")
|
||||
@Operation(summary = "查询最近前几年当年的五一期间的数据")
|
||||
public List<Map<String, String>> findByWuyi(@PathVariable("x") int x) {
|
||||
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SaleDataItemTypeVo {
|
||||
// private String itemtype;
|
||||
private String itemtypename;
|
||||
}
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.datacenter.dal.mongodb.saledata;
|
||||
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AgeVo;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.SaleDataItemTypeVo;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.dataobject.saledata.SaleData;
|
||||
import org.springframework.data.mongodb.repository.Aggregation;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
@ -41,4 +42,7 @@ public interface SaleDataRepository extends MongoRepository<SaleData,String> {
|
||||
})
|
||||
AgeVo findByAge();
|
||||
|
||||
@Query(value = "{}", fields = "{ 'itemtypename': 1 }")
|
||||
List<SaleDataItemTypeVo> findAllByItemtypename();
|
||||
|
||||
}
|
||||
|
@ -65,6 +65,12 @@ public interface SaleDataService {
|
||||
*/
|
||||
public List<Map<String, String>> findBySaleMethod();
|
||||
|
||||
/**
|
||||
* 查询各个产品类型的购票人数
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, String>> findByDoItemType();
|
||||
|
||||
/**
|
||||
* 查询最近前x年五一期间的数据
|
||||
* @param x 前几年
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.util.ticket.IdCardUtil;
|
||||
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AgeVo;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO;
|
||||
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.SaleDataItemTypeVo;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.dataobject.saledata.SaleData;
|
||||
import cn.iocoder.yudao.module.datacenter.dal.mongodb.saledata.SaleDataRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -17,6 +18,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -210,6 +212,23 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
return mapList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> findByDoItemType() {
|
||||
List<SaleDataItemTypeVo> list = saleDataRepository.findAllByItemtypename();
|
||||
Map<String, Long> countMap = list.stream()
|
||||
.collect(Collectors.groupingBy(SaleDataItemTypeVo::getItemtypename, Collectors.counting()));
|
||||
List<Map<String, String>> mapArrayList = new ArrayList<>();
|
||||
for (String s : countMap.keySet()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("TypeName",s);
|
||||
map.put("count",countMap.get(s).toString());
|
||||
mapArrayList.add(map);
|
||||
// map.clear();
|
||||
}
|
||||
|
||||
return mapArrayList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> findWuyi(int x) {
|
||||
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
Loading…
Reference in New Issue
Block a user