大屏接口改造
This commit is contained in:
parent
9c789c67ae
commit
c3026428fa
@ -20,15 +20,19 @@ import java.util.Map;
|
|||||||
public class CheckTicketApi {
|
public class CheckTicketApi {
|
||||||
@Resource
|
@Resource
|
||||||
private CheckTicketService checkTicketService;
|
private CheckTicketService checkTicketService;
|
||||||
@GetMapping("/{day}")
|
@GetMapping()
|
||||||
@Operation(summary = "获得日期当天的检票人数")
|
@Operation(summary = "获得日期当天的检票人数")
|
||||||
public Long checkTicketTotal(@PathVariable("day") String day) {
|
public Long checkTicketTotal(String starTime, String endTime) {
|
||||||
return checkTicketService.checkTicketTotal(day);
|
String replace = starTime.replace("-", "");
|
||||||
|
String replace1 = endTime.replace("-", "");
|
||||||
|
return checkTicketService.checkTicketTotal(replace,replace1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/qushi/{day}")
|
@GetMapping("/qushi")
|
||||||
@Operation(summary = "获取日期当天各个时段的检票人数")
|
@Operation(summary = "获取日期当天各个时段的检票人数")
|
||||||
public List<Map<String, String>> findbytimetemp(@PathVariable("day") String day) {
|
public List<Map<String, String>> findbytimetemp(String starTime, String endTime) {
|
||||||
return checkTicketService.findbytimetemp(day);
|
String replace = starTime.replace("-", "");
|
||||||
|
String replace1 = endTime.replace("-", "");
|
||||||
|
return checkTicketService.findbytimetemp(replace,replace1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,89 +27,76 @@ public class SaleDataApi {
|
|||||||
@Resource
|
@Resource
|
||||||
private SaleDataService saleDataService;
|
private SaleDataService saleDataService;
|
||||||
|
|
||||||
@GetMapping("/{day}")
|
@GetMapping()
|
||||||
@Operation(summary = "获得输入日期的当天总售票数")
|
@Operation(summary = "获得输入日期的当天总售票数")
|
||||||
public Long checkTicketTotal(@PathVariable("day") String day) {
|
public Long checkTicketTotal(String starTime, String endTime) {
|
||||||
return saleDataService.countBySddate(day);
|
String replace = starTime.replace("-", "");
|
||||||
|
String replace1 = endTime.replace("-", "");
|
||||||
|
return saleDataService.countBySddate(replace, replace1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/thisyear/{startTime}")
|
@GetMapping("/thisyear")
|
||||||
@Operation(summary = "获得今年日期往前十天内的数据")
|
@Operation(summary = "获得今年日期往前十天内的数据")
|
||||||
public List<Map<String, String>> thisyearNum(@PathVariable("startTime") String startTime) {
|
public List<Map<String, String>> thisyearNum(String starTime, String endTime) {
|
||||||
return saleDataService.findCheckticketcountBytime(startTime);
|
String replace = starTime.replace("-", "");
|
||||||
|
String replace1 = endTime.replace("-", "");
|
||||||
|
return saleDataService.findCheckticketcountBytime(replace, replace1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/lastyear/{startTime}")
|
@GetMapping("/lastyear")
|
||||||
@Operation(summary = "获得去年日期往前推十天的数据")
|
@Operation(summary = "获得去年日期往前推十天的数据")
|
||||||
public List<Map<String, String>> lastyearNum(@PathVariable("startTime") String startTime) {
|
public List<Map<String, String>> lastyearNum(String starTime, String endTime) {
|
||||||
String resultStr = startTime.replaceAll("-", "");
|
String replace = starTime.replace("-", "");
|
||||||
// 正则表达式匹配 yyyyMMdd 格式
|
String replace1 = endTime.replace("-", "");
|
||||||
Pattern pattern = Pattern.compile("^\\d{8}$");
|
return saleDataService.findCheckticketcountBytime(replace, replace1);
|
||||||
Matcher matcher = pattern.matcher(resultStr);
|
|
||||||
if (matcher.matches()){
|
|
||||||
return saleDataService.findCheckticketcountBytime(resultStr);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/gender")
|
@GetMapping("/gender")
|
||||||
@Operation(summary = "获得所有数据的男女数量")
|
@Operation(summary = "获得所有数据的男女数量")
|
||||||
public List<Map<String, String>> findByGender(String starTime, String endTime) {
|
public List<Map<String, String>> findByGender(String starTime, String endTime) {
|
||||||
if (starTime != null && endTime != null){
|
|
||||||
String replace = starTime.replace("-", "");
|
String replace = starTime.replace("-", "");
|
||||||
String replace1 = endTime.replace("-", "");
|
String replace1 = endTime.replace("-", "");
|
||||||
return saleDataService.findByGender(replace, replace1);
|
return saleDataService.findByGender(replace, replace1);
|
||||||
}else{
|
|
||||||
return saleDataService.findByGender(starTime, endTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/age")
|
@GetMapping("/age")
|
||||||
@Operation(summary = "获得所有数据的年龄分段和数量")
|
@Operation(summary = "获得所有数据的年龄分段和数量")
|
||||||
public List<Map<String, String>> findByage(String starTime, String endTime) {
|
public List<Map<String, String>> findByage(String starTime, String endTime) {
|
||||||
if (starTime != null && endTime != null){
|
|
||||||
String replace = starTime.replace("-", "");
|
String replace = starTime.replace("-", "");
|
||||||
String replace1 = endTime.replace("-", "");
|
String replace1 = endTime.replace("-", "");
|
||||||
return saleDataService.findByAge(replace, replace1);
|
return saleDataService.findByAge(replace, replace1);
|
||||||
}else{
|
|
||||||
return saleDataService.findByAge(starTime, endTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/lastyear/region")
|
@GetMapping("/lastyear/region")
|
||||||
@Operation(summary = "查询去年各个省份的人数")
|
@Operation(summary = "查询去年各个省份的人数")
|
||||||
public List<Map<String, String>> lastyearfindByregion() {
|
public List<Map<String, String>> lastyearfindByregion(String starTime, String endTime) {
|
||||||
return saleDataService.findByregion(saleDataService.findEventsLastYear());
|
String replace = starTime.replace("-", "");
|
||||||
|
String replace1 = endTime.replace("-", "");
|
||||||
|
return saleDataService.findByregion(saleDataService.findEventsLastYear(replace, replace1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/thisyear/region")
|
@GetMapping("/thisyear/region")
|
||||||
@Operation(summary = "查询今年各个省份的人数")
|
@Operation(summary = "查询今年各个省份的人数")
|
||||||
public List<Map<String, String>> thisyearfindByregion() {
|
public List<Map<String, String>> thisyearfindByregion(String starTime, String endTime) {
|
||||||
return saleDataService.findByregion(saleDataService.findEventsThisYear());
|
String replace = starTime.replace("-", "");
|
||||||
|
String replace1 = endTime.replace("-", "");
|
||||||
|
return saleDataService.findByregion(saleDataService.findEventsThisYear(replace, replace1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/salemethod")
|
@GetMapping("/salemethod")
|
||||||
@Operation(summary = "查询各个销售渠道的购票人数")
|
@Operation(summary = "查询各个销售渠道的购票人数")
|
||||||
public List<Map<String, String>> findBysaleMethod(String starTime, String endTime) {
|
public List<Map<String, String>> findBysaleMethod(String starTime, String endTime) {
|
||||||
if (starTime != null && endTime != null){
|
|
||||||
String replace = starTime.replace("-", "");
|
String replace = starTime.replace("-", "");
|
||||||
String replace1 = endTime.replace("-", "");
|
String replace1 = endTime.replace("-", "");
|
||||||
return saleDataService.findBySaleMethod(replace, replace1);
|
return saleDataService.findBySaleMethod(replace, replace1);
|
||||||
}else{
|
|
||||||
return saleDataService.findBySaleMethod(starTime, endTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/itemType")
|
@GetMapping("/itemType")
|
||||||
@Operation(summary = "查询各个产品类型的购票人数")
|
@Operation(summary = "查询各个产品类型的购票人数")
|
||||||
public List<Map<String, String>> findByItemType(String starTime, String endTime) {
|
public List<Map<String, String>> findByItemType(String starTime, String endTime) {
|
||||||
if (starTime != null && endTime != null){
|
|
||||||
String replace = starTime.replace("-", "");
|
String replace = starTime.replace("-", "");
|
||||||
String replace1 = endTime.replace("-", "");
|
String replace1 = endTime.replace("-", "");
|
||||||
return saleDataService.findByDoItemType(replace, replace1);
|
return saleDataService.findByDoItemType(replace, replace1);
|
||||||
}else{
|
|
||||||
return saleDataService.findByDoItemType(starTime, endTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/wuyi/{x}")
|
@GetMapping("/wuyi/{x}")
|
||||||
@ -140,6 +127,8 @@ public class SaleDataApi {
|
|||||||
@GetMapping("/thisyear/nianjun")
|
@GetMapping("/thisyear/nianjun")
|
||||||
@Operation(summary = "查询今年年度售票平均金额")
|
@Operation(summary = "查询今年年度售票平均金额")
|
||||||
public BigDecimal findmoneythisyear() {
|
public BigDecimal findmoneythisyear() {
|
||||||
|
// String replace = starTime.replace("-", "");
|
||||||
|
// String replace1 = endTime.replace("-", "");
|
||||||
return saleDataService.findyearJun(saleDataService.findEventsThisYear());
|
return saleDataService.findyearJun(saleDataService.findEventsThisYear());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,14 @@ public interface CheckTicketRepository extends MongoRepository<CheckTicket,Strin
|
|||||||
@Query("{'name': {'$regex': '?0', '$options': 'i'}}")
|
@Query("{'name': {'$regex': '?0', '$options': 'i'}}")
|
||||||
Page<CheckTicket> findByName(String q, PageRequest pageable);
|
Page<CheckTicket> findByName(String q, PageRequest pageable);
|
||||||
|
|
||||||
int countByCheckticketdate(String day);
|
@Query("{'checkticketdate':{'$gte': ?0, '$lt': ?1}}")
|
||||||
|
List<CheckTicket> countByCheckticketdateBetween(String starTime, String endTime);
|
||||||
|
|
||||||
@Query("{'checktickettime':{'$gte': ?0, '$lt': ?1},'checkticketdate':{'$dt': ?2}}")
|
@Query("{'checktickettime':{'$gte': ?0, '$lt': ?1},'checkticketdate':{'$dt': ?2}}")
|
||||||
List<CheckTicket> findByTimestampBetweenAndCheckticketdate(String startTime, String endTime,String day);
|
List<CheckTicket> findByTimestampBetweenAndCheckticketdate(String startTime, String endTime,String day);
|
||||||
|
|
||||||
List<CheckTicket> findByCheckticketdateAndChecktickettimeBetween(String day,String startTime, String endTime);
|
List<CheckTicket> findByCheckticketdateAndChecktickettimeBetween(String day,String startTime, String endTime);
|
||||||
|
|
||||||
|
@Query("{'checkticketdate':{'$gte': ?0, '$lt': ?1} , 'checktickettime':{'$gte': ?2, '$lt': ?3}}")
|
||||||
|
List<CheckTicket> findByCheckticketdateBetweenAndChecktickettimeBetween(String startTime, String endTime,String beingTime, String resultTime);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ public interface SaleDataRepository extends MongoRepository<SaleData,String> {
|
|||||||
Page<SaleData> findByName(String q, PageRequest pageable);*/
|
Page<SaleData> findByName(String q, PageRequest pageable);*/
|
||||||
int countBySddate(String day);
|
int countBySddate(String day);
|
||||||
|
|
||||||
|
@Query(value = "{'sddate': { $gte: ?0, $lt: ?1 }}", fields = "{ 'sddate': 1 }")
|
||||||
|
List<String> countBySddateToTime(String starTime, String endTime);
|
||||||
|
|
||||||
|
|
||||||
// @Query("{ 'sddate' : { $gte: ?0, $lte: ?1 } }")
|
// @Query("{ 'sddate' : { $gte: ?0, $lte: ?1 } }")
|
||||||
@Query(value = "{ 'sddate': { $gte: ?0, $lte: ?1 } }", fields = "{ 'certificateno': 1, 'amount': 1}")
|
@Query(value = "{ 'sddate': { $gte: ?0, $lte: ?1 } }", fields = "{ 'certificateno': 1, 'amount': 1}")
|
||||||
@ -59,6 +62,6 @@ public interface SaleDataRepository extends MongoRepository<SaleData,String> {
|
|||||||
List<SaleDataItemTypeVo> findAllByItemtypenameTime(String starTime, String endTime);
|
List<SaleDataItemTypeVo> findAllByItemtypenameTime(String starTime, String endTime);
|
||||||
|
|
||||||
@Query(value = "{'sddate': { $gte: ?0, $lt: ?1 }}", fields = "{ 'transactiontypeno': 1 }")
|
@Query(value = "{'sddate': { $gte: ?0, $lt: ?1 }}", fields = "{ 'transactiontypeno': 1 }")
|
||||||
List<String> findAllByTransactiontypenoTime(String starTime, String endTime);
|
List<SaleData> findAllByTransactiontypenoTime(String starTime, String endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,15 @@ public interface CheckTicketService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取日期当天各个时段的检票人数
|
* 获取日期当天各个时段的检票人数
|
||||||
* @param day
|
* @param starTime
|
||||||
* @return java.util.List<java.util.Map<java.lang.String,java.lang.String>>
|
* @return java.util.List<java.util.Map<java.lang.String,java.lang.String>>
|
||||||
*/
|
*/
|
||||||
public List<Map<String, String>> findbytimetemp(String day);
|
public List<Map<String, String>> findbytimetemp(String starTime, String endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得日期当天的检票人数
|
* 获得日期当天的检票人数
|
||||||
* @param day 日期
|
* @param starTime 日期
|
||||||
* @return long 检票人数
|
* @return long 检票人数
|
||||||
*/
|
*/
|
||||||
public long checkTicketTotal(String day);
|
public long checkTicketTotal(String starTime, String endTime);
|
||||||
}
|
}
|
@ -2,12 +2,14 @@ package cn.iocoder.yudao.module.datacenter.service.checkticket;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.datacenter.controller.app.saledata.vo.AggregationVO;
|
||||||
import cn.iocoder.yudao.module.datacenter.dal.dataobject.checkticket.CheckTicket;
|
import cn.iocoder.yudao.module.datacenter.dal.dataobject.checkticket.CheckTicket;
|
||||||
import cn.iocoder.yudao.module.datacenter.dal.mongodb.checkticket.CheckTicketRepository;
|
import cn.iocoder.yudao.module.datacenter.dal.mongodb.checkticket.CheckTicketRepository;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -31,7 +33,7 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findbytimetemp(String day) {
|
public List<Map<String, String>> findbytimetemp(String starTime, String endTime) {
|
||||||
LocalDateTime startTime = LocalDateTime.now();
|
LocalDateTime startTime = LocalDateTime.now();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||||
List<Map<String, String>> mapList = new ArrayList<>();
|
List<Map<String, String>> mapList = new ArrayList<>();
|
||||||
@ -41,9 +43,14 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
|||||||
LocalDateTime hourStartTime = startTime.withHour(i).withMinute(0).withSecond(0).withNano(0);
|
LocalDateTime hourStartTime = startTime.withHour(i).withMinute(0).withSecond(0).withNano(0);
|
||||||
LocalDateTime hourEndTime = hourStartTime.plusHours(1);
|
LocalDateTime hourEndTime = hourStartTime.plusHours(1);
|
||||||
String begintime = formatter.format(hourStartTime);
|
String begintime = formatter.format(hourStartTime);
|
||||||
String endtime = formatter.format(hourEndTime);
|
String resulttime = formatter.format(hourEndTime);
|
||||||
List<CheckTicket> checkTickets = checkTicketRepository.findByCheckticketdateAndChecktickettimeBetween(day,begintime,endtime);
|
List<CheckTicket> checkTickets;
|
||||||
map.put("date",begintime+"-"+endtime);
|
if (starTime != null && endTime != null && starTime.equals(endTime)){
|
||||||
|
checkTickets = checkTicketRepository.findByCheckticketdateAndChecktickettimeBetween(starTime,begintime,resulttime);
|
||||||
|
}else {
|
||||||
|
checkTickets = checkTicketRepository.findByCheckticketdateBetweenAndChecktickettimeBetween(starTime,endTime,begintime,resulttime);
|
||||||
|
}
|
||||||
|
map.put("date",begintime+"-"+resulttime);
|
||||||
map.put("count", String.valueOf(checkTickets.stream().count()));
|
map.put("count", String.valueOf(checkTickets.stream().count()));
|
||||||
mapList.add(map);
|
mapList.add(map);
|
||||||
}
|
}
|
||||||
@ -52,8 +59,17 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long checkTicketTotal(String day) {
|
public long checkTicketTotal(String starTime, String endTime) {
|
||||||
return checkTicketRepository.countByCheckticketdate(day);
|
// 创建 DateTimeFormatter 实例以解析指定日期的格式
|
||||||
|
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
// 解析指定日期字符串为 LocalDate 对象
|
||||||
|
LocalDate specifiedDate = LocalDate.parse(endTime, inputFormatter);
|
||||||
|
// 获取指定日期的下一天
|
||||||
|
LocalDate nextDay = specifiedDate.plusDays(1);
|
||||||
|
// 格式化指定日期和下一天
|
||||||
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
String formattedNextDay = nextDay.format(outputFormatter);
|
||||||
|
return checkTicketRepository.countByCheckticketdateBetween(starTime,formattedNextDay).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,14 +18,14 @@ public interface SaleDataService {
|
|||||||
* @param day 日期
|
* @param day 日期
|
||||||
* @return 当天总售票数
|
* @return 当天总售票数
|
||||||
*/
|
*/
|
||||||
public long countBySddate(String day);
|
public long countBySddate(String starTime, String endTime);
|
||||||
/**
|
/**
|
||||||
* 日期往前十天内的数据
|
* 日期往前十天内的数据
|
||||||
* @param startTime 起始日期
|
* @param starTime 起始日期
|
||||||
* @return java.util.List<java.util.Map>
|
* @return java.util.List<java.util.Map>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public List<Map<String,String>> findCheckticketcountBytime(String startTime);
|
public List<Map<String,String>> findCheckticketcountBytime(String starTime, String endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询男女人数
|
* 查询男女人数
|
||||||
@ -44,11 +44,13 @@ public interface SaleDataService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SaleData> findEventsLastYear();
|
public List<SaleData> findEventsLastYear();
|
||||||
|
public List<SaleData> findEventsLastYear(String starTime, String endTime);
|
||||||
/**
|
/**
|
||||||
* 查询今年1月1日到12月31日的全部数据
|
* 查询今年1月1日到12月31日的全部数据
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SaleData> findEventsThisYear();
|
public List<SaleData> findEventsThisYear();
|
||||||
|
public List<SaleData> findEventsThisYear(String starTime, String endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询各个省份和人数
|
* 查询各个省份和人数
|
||||||
|
@ -33,30 +33,48 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SaleDataRepository saleDataRepository;
|
private SaleDataRepository saleDataRepository;
|
||||||
@Override
|
|
||||||
public long countBySddate(String day) {
|
public String publicMethod(String endTime){
|
||||||
return saleDataRepository.countBySddate(day);
|
// 创建 DateTimeFormatter 实例以解析指定日期的格式
|
||||||
|
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
// 解析指定日期字符串为 LocalDate 对象
|
||||||
|
LocalDate specifiedDate = LocalDate.parse(endTime, inputFormatter);
|
||||||
|
// 获取指定日期的下一天
|
||||||
|
LocalDate nextDay = specifiedDate.plusDays(1);
|
||||||
|
// 格式化指定日期和下一天
|
||||||
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
String formattedNextDay = nextDay.format(outputFormatter);
|
||||||
|
return formattedNextDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String,String>> findCheckticketcountBytime(String startTime) {
|
public long countBySddate(String starTime, String endTime) {
|
||||||
|
return saleDataRepository.countBySddateToTime(starTime, this.publicMethod(endTime)).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String,String>> findCheckticketcountBytime(String starTime, String endTime) {
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
Calendar calendar2 = Calendar.getInstance();
|
||||||
Date date1= null;
|
Date date1= null;
|
||||||
|
Date date2= null;
|
||||||
try {
|
try {
|
||||||
date1 = inputFormat.parse(startTime);
|
date1 = inputFormat.parse(starTime);
|
||||||
|
date2 = inputFormat.parse(endTime);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
calendar.setTime(date1);
|
calendar.setTime(date1);
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, -9);
|
calendar2.setTime(date2);
|
||||||
|
// calendar.add(Calendar.DAY_OF_YEAR, -9);
|
||||||
List<Map<String,String>>map = new ArrayList<>();
|
List<Map<String,String>>map = new ArrayList<>();
|
||||||
while (!calendar.getTime().after(date1)){
|
while (!calendar.getTime().after(date2)){
|
||||||
Map<String,String>map1= new HashMap<>();
|
Map<String,String>map1= new HashMap<>();
|
||||||
String date = inputFormat.format(calendar.getTime());
|
String date = inputFormat.format(calendar.getTime());
|
||||||
map1.put("date",outputFormat.format(calendar.getTime()));
|
map1.put("date",outputFormat.format(calendar.getTime()));
|
||||||
map1.put("count", String.valueOf(this.countBySddate(date)));
|
map1.put("count", String.valueOf(saleDataRepository.countBySddate(date)));
|
||||||
map.add(map1);
|
map.add(map1);
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||||
}
|
}
|
||||||
@ -65,19 +83,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findByGender(String starTime, String endTime) {
|
public List<Map<String, String>> findByGender(String starTime, String endTime) {
|
||||||
AggregationVO allByCertificateno;
|
AggregationVO allByCertificateno = saleDataRepository.findAllByCertificatenoSDTime(starTime, this.publicMethod(endTime));
|
||||||
if (starTime == null || endTime == null){
|
|
||||||
// 获取当前日期
|
|
||||||
LocalDate currentDate = LocalDate.now();
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
||||||
String formattedDate = currentDate.format(formatter);
|
|
||||||
// 将当前日期加一天
|
|
||||||
LocalDate nextDay = currentDate.plusDays(1);
|
|
||||||
String nextDayFormatter = nextDay.format(formatter);
|
|
||||||
allByCertificateno = saleDataRepository.findAllByCertificatenoSDTime(formattedDate, nextDayFormatter);
|
|
||||||
}else {
|
|
||||||
allByCertificateno = saleDataRepository.findAllByCertificatenoSDTime(starTime, endTime);
|
|
||||||
}
|
|
||||||
List<Map<String, String>> map = new ArrayList<>();
|
List<Map<String, String>> map = new ArrayList<>();
|
||||||
Map<String,String>map1=new HashMap<>();
|
Map<String,String>map1=new HashMap<>();
|
||||||
Map<String,String>map2=new HashMap<>();
|
Map<String,String>map2=new HashMap<>();
|
||||||
@ -92,19 +98,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findByAge(String starTime, String endTime) {
|
public List<Map<String, String>> findByAge(String starTime, String endTime) {
|
||||||
AgeVo byAge;
|
AgeVo byAge = saleDataRepository.findByAge(starTime,this.publicMethod(endTime));
|
||||||
if (starTime == null || endTime == null){
|
|
||||||
// 获取当前日期
|
|
||||||
LocalDate currentDate = LocalDate.now();
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
||||||
String formattedDate = currentDate.format(formatter);
|
|
||||||
// 将当前日期加一天
|
|
||||||
LocalDate nextDay = currentDate.plusDays(1);
|
|
||||||
String nextDayFormatter = nextDay.format(formatter);
|
|
||||||
byAge = saleDataRepository.findByAge(formattedDate,nextDayFormatter);
|
|
||||||
}else {
|
|
||||||
byAge = saleDataRepository.findByAge(starTime,endTime);
|
|
||||||
}
|
|
||||||
List<Map<String,String>>map=new ArrayList<>();
|
List<Map<String,String>>map=new ArrayList<>();
|
||||||
Map<String,String>map1=new LinkedHashMap<>();
|
Map<String,String>map1=new LinkedHashMap<>();
|
||||||
Map<String,String>map2=new LinkedHashMap<>();
|
Map<String,String>map2=new LinkedHashMap<>();
|
||||||
@ -145,6 +139,16 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
return saleDataRepository.findBySddateBetween(start, end);
|
return saleDataRepository.findBySddateBetween(start, end);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
public List<SaleData> findEventsLastYear(String starTime, String endTime) {
|
||||||
|
// DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
// LocalDate lastYear = LocalDate.now().minusYears(1);
|
||||||
|
// LocalDate startOfYear = lastYear.withDayOfYear(1);
|
||||||
|
// LocalDate endOfYear = lastYear.withDayOfYear(lastYear.lengthOfYear());
|
||||||
|
// String start = date.format(startOfYear);
|
||||||
|
// String end = date.format(endOfYear);
|
||||||
|
return saleDataRepository.findBySddateBetween(starTime, endTime);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
public List<SaleData> findEventsThisYear() {
|
public List<SaleData> findEventsThisYear() {
|
||||||
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
LocalDate thisYear = LocalDate.now().minusYears(0);
|
LocalDate thisYear = LocalDate.now().minusYears(0);
|
||||||
@ -154,6 +158,16 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
String end = date.format(endOfYear);
|
String end = date.format(endOfYear);
|
||||||
return saleDataRepository.findBySddateBetween(start,end);
|
return saleDataRepository.findBySddateBetween(start,end);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public List<SaleData> findEventsThisYear(String starTime, String endTime) {
|
||||||
|
// DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
// LocalDate thisYear = LocalDate.now().minusYears(0);
|
||||||
|
// LocalDate startOfYear = thisYear.withDayOfYear(1);
|
||||||
|
// LocalDate endOfYear = thisYear.withDayOfYear(thisYear.lengthOfYear());
|
||||||
|
// String start = date.format(startOfYear);
|
||||||
|
// String end = date.format(endOfYear);
|
||||||
|
return saleDataRepository.findBySddateBetween(starTime,endTime);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findByregion(List<SaleData> list) {
|
public List<Map<String, String>> findByregion(List<SaleData> list) {
|
||||||
@ -198,24 +212,12 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findBySaleMethod(String starTime, String endTime) {
|
public List<Map<String, String>> findBySaleMethod(String starTime, String endTime) {
|
||||||
List<String> saleDataList;
|
List<SaleData> saleDataList = saleDataRepository.findAllByTransactiontypenoTime(starTime, this.publicMethod(endTime));
|
||||||
if (starTime == null || endTime == null){
|
|
||||||
// 获取当前日期
|
|
||||||
LocalDate currentDate = LocalDate.now();
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
||||||
String formattedDate = currentDate.format(formatter);
|
|
||||||
// 将当前日期加一天
|
|
||||||
LocalDate nextDay = currentDate.plusDays(1);
|
|
||||||
String nextDayFormatter = nextDay.format(formatter);
|
|
||||||
saleDataList = saleDataRepository.findAllByTransactiontypenoTime(formattedDate, nextDayFormatter);
|
|
||||||
}else {
|
|
||||||
saleDataList = saleDataRepository.findAllByTransactiontypenoTime(starTime, endTime);
|
|
||||||
}
|
|
||||||
int[] saleMethodCounts = new int[5];
|
int[] saleMethodCounts = new int[5];
|
||||||
Map<String,String>map=new LinkedHashMap<>();
|
Map<String,String>map=new LinkedHashMap<>();
|
||||||
for (String saleData : saleDataList) {
|
for (SaleData saleData : saleDataList) {
|
||||||
// String transactiontypeno = saleData.getTransactiontypeno();
|
String transactiontypeno = saleData.getTransactiontypeno();
|
||||||
switch (saleData){
|
switch (transactiontypeno){
|
||||||
case "SD01":
|
case "SD01":
|
||||||
saleMethodCounts[0]++;
|
saleMethodCounts[0]++;
|
||||||
break;
|
break;
|
||||||
@ -252,19 +254,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> findByDoItemType(String starTime, String endTime) {
|
public List<Map<String, String>> findByDoItemType(String starTime, String endTime) {
|
||||||
List<SaleDataItemTypeVo> list;
|
List<SaleDataItemTypeVo> list = saleDataRepository.findAllByItemtypenameTime(starTime, this.publicMethod(endTime));
|
||||||
if (starTime == null || endTime == null){
|
|
||||||
// 获取当前日期
|
|
||||||
LocalDate currentDate = LocalDate.now();
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
||||||
String formattedDate = currentDate.format(formatter);
|
|
||||||
// 将当前日期加一天
|
|
||||||
LocalDate nextDay = currentDate.plusDays(1);
|
|
||||||
String nextDayFormatter = nextDay.format(formatter);
|
|
||||||
list = saleDataRepository.findAllByItemtypenameTime(formattedDate, nextDayFormatter);
|
|
||||||
}else {
|
|
||||||
list = saleDataRepository.findAllByItemtypenameTime(starTime, endTime);
|
|
||||||
}
|
|
||||||
Map<String, Long> countMap = list.stream()
|
Map<String, Long> countMap = list.stream()
|
||||||
.collect(Collectors.groupingBy(SaleDataItemTypeVo::getItemtypename, Collectors.counting()));
|
.collect(Collectors.groupingBy(SaleDataItemTypeVo::getItemtypename, Collectors.counting()));
|
||||||
List<Map<String, String>> mapArrayList = new ArrayList<>();
|
List<Map<String, String>> mapArrayList = new ArrayList<>();
|
||||||
@ -419,7 +409,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
while (!calendar.getTime().after(date1)){
|
while (!calendar.getTime().after(date1)){
|
||||||
String date = inputFormat.format(calendar.getTime());
|
String date = inputFormat.format(calendar.getTime());
|
||||||
long i = this.countBySddate(date);
|
long i = saleDataRepository.countBySddate(date);
|
||||||
count+=i;
|
count+=i;
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user