Merge pull request 'zzw-one' (#31) from zzw-one into master
All checks were successful
continuous-integration/drone/tag Build is passing

Reviewed-on: #31
This commit is contained in:
root 2024-08-23 13:42:48 +08:00
commit 8bee19b948
5 changed files with 44 additions and 0 deletions

View File

@ -79,6 +79,12 @@ public class SaleDataApi {
return saleDataService.findBySaleMethod(); return saleDataService.findBySaleMethod();
} }
@GetMapping("/itemType")
@Operation(summary = "查询各个产品类型的购票人数")
public List<Map<String, String>> findByItemType() {
return saleDataService.findByDoItemType();
}
@GetMapping("/wuyi/{x}") @GetMapping("/wuyi/{x}")
@Operation(summary = "查询最近前几年当年的五一期间的数据") @Operation(summary = "查询最近前几年当年的五一期间的数据")
public List<Map<String, String>> findByWuyi(@PathVariable("x") int x) { public List<Map<String, String>> findByWuyi(@PathVariable("x") int x) {

View File

@ -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;
}

View File

@ -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.AgeVo;
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO; 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.dataobject.saledata.SaleData;
import org.springframework.data.mongodb.repository.Aggregation; import org.springframework.data.mongodb.repository.Aggregation;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
@ -41,4 +42,7 @@ public interface SaleDataRepository extends MongoRepository<SaleData,String> {
}) })
AgeVo findByAge(); AgeVo findByAge();
@Query(value = "{}", fields = "{ 'itemtypename': 1 }")
List<SaleDataItemTypeVo> findAllByItemtypename();
} }

View File

@ -65,6 +65,12 @@ public interface SaleDataService {
*/ */
public List<Map<String, String>> findBySaleMethod(); public List<Map<String, String>> findBySaleMethod();
/**
* 查询各个产品类型的购票人数
* @return
*/
public List<Map<String, String>> findByDoItemType();
/** /**
* 查询最近前x年五一期间的数据 * 查询最近前x年五一期间的数据
* @param x 前几年 * @param x 前几年

View File

@ -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.AgeVo;
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO; 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.dataobject.saledata.SaleData;
import cn.iocoder.yudao.module.datacenter.dal.mongodb.saledata.SaleDataRepository; import cn.iocoder.yudao.module.datacenter.dal.mongodb.saledata.SaleDataRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +18,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
@ -210,6 +212,23 @@ public class SaleDataServiceImpl implements SaleDataService {
return mapList; 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 @Override
public List<Map<String, String>> findWuyi(int x) { public List<Map<String, String>> findWuyi(int x) {
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd"); DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");