大屏接口改造 #51

Merged
root merged 1 commits from zzw-one into master 2024-08-28 11:31:21 +08:00
4 changed files with 12 additions and 3 deletions
Showing only changes of commit 6606826273 - Show all commits

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.datacenter.controller.app.saledata; package cn.iocoder.yudao.module.datacenter.controller.app.saledata;
import cn.iocoder.yudao.module.datacenter.service.saledata.SaleDataService; import cn.iocoder.yudao.module.datacenter.service.saledata.SaleDataService;
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -26,6 +27,8 @@ import java.util.regex.Pattern;
public class SaleDataApi { public class SaleDataApi {
@Resource @Resource
private SaleDataService saleDataService; private SaleDataService saleDataService;
// @Resource
// private WebSocketSenderApi webSocketSenderApi;
@GetMapping() @GetMapping()
@Operation(summary = "获得输入日期的当天总售票数") @Operation(summary = "获得输入日期的当天总售票数")
@ -138,4 +141,10 @@ public class SaleDataApi {
return saleDataService.findyearJun(saleDataService.findEventsLastYear()); return saleDataService.findyearJun(saleDataService.findEventsLastYear());
} }
// @GetMapping("/test")
// public void testMethod(){
//
// webSocketSenderApi.sendObject("1","1","666");
// }
} }

View File

@ -5,5 +5,5 @@ import lombok.Data;
@Data @Data
public class SaleDataItemTypeVo { public class SaleDataItemTypeVo {
// private String itemtype; // private String itemtype;
private String itemtypename; private String itemname;
} }

View File

@ -58,7 +58,7 @@ public interface SaleDataRepository extends MongoRepository<SaleData,String> {
@Query(value = "{}", fields = "{ 'itemtypename': 1 }") @Query(value = "{}", fields = "{ 'itemtypename': 1 }")
List<SaleDataItemTypeVo> findAllByItemtypename(); List<SaleDataItemTypeVo> findAllByItemtypename();
@Query(value = "{'sddate': { $gte: ?0, $lt: ?1 }}", fields = "{ 'itemtypename': 1 }") @Query(value = "{'sddate': { $gte: ?0, $lt: ?1 }}", fields = "{ 'itemname': 1 }")
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 }")

View File

@ -256,7 +256,7 @@ public class SaleDataServiceImpl implements SaleDataService {
public List<Map<String, String>> findByDoItemType(String starTime, String endTime) { public List<Map<String, String>> findByDoItemType(String starTime, String endTime) {
List<SaleDataItemTypeVo> list = saleDataRepository.findAllByItemtypenameTime(starTime, this.publicMethod(endTime)); List<SaleDataItemTypeVo> list = saleDataRepository.findAllByItemtypenameTime(starTime, this.publicMethod(endTime));
Map<String, Long> countMap = list.stream() Map<String, Long> countMap = list.stream()
.collect(Collectors.groupingBy(SaleDataItemTypeVo::getItemtypename, Collectors.counting())); .collect(Collectors.groupingBy(SaleDataItemTypeVo::getItemname, Collectors.counting()));
List<Map<String, String>> mapArrayList = new ArrayList<>(); List<Map<String, String>> mapArrayList = new ArrayList<>();
for (String s : countMap.keySet()) { for (String s : countMap.keySet()) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();