心跳数据推送 #69

Merged
root merged 1 commits from zzw-one into master 2024-09-03 10:03:28 +08:00
3 changed files with 60 additions and 7 deletions
Showing only changes of commit d6687f97f1 - Show all commits

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.infra.clients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
@ -9,5 +10,11 @@ import java.util.Map;
@FeignClient("datacenter-server")
public interface LargeScreenClient {
@GetMapping("/api/asset/type")
List<Object> assetMethod1();
Object assetMethod1();
@GetMapping("/api/saledata")
Object saleDataTotal(@RequestParam("starTime") String starTime, @RequestParam("endTime") String endTime);
@GetMapping("/api/checkticket")
Object checkTicketTotal(@RequestParam("starTime") String starTime, @RequestParam("endTime") String endTime);
}

View File

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.infra.controller.admin.ticketing;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.date.TickingDateUtils;
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
import cn.iocoder.yudao.module.infra.clients.LargeScreenClient;
import cn.iocoder.yudao.module.infra.job.ticketing.TicketDataMigration;
import cn.iocoder.yudao.module.infra.service.checkticket.CheckTicketService;
import cn.iocoder.yudao.module.infra.service.saledata.SaleDataService;
@ -10,9 +12,10 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* @Description 测试抽数接口
@ -31,6 +34,12 @@ public class TicketingController {
@Resource
SaleDataService saleDataService;
@Resource
private WebSocketSenderApi webSocketSenderApi;
@Resource
private LargeScreenClient largeScreenClient;
@GetMapping
public CommonResult<String> testTicketing(@RequestParam("startDate") String startDate, @RequestParam("endDate")String endDate, @RequestParam("method") String method) throws Exception {
Calendar startCalendar = Calendar.getInstance();
@ -39,10 +48,29 @@ public class TicketingController {
endCalendar.setTime(TickingDateUtils.parse(endDate));
return CommonResult.success(ticketDataMigration.getTicketDataByTimeZonesToMongo(startCalendar, endCalendar, method));
}
@GetMapping("/test")
@GetMapping("/test1")
public CommonResult<List<String>> testAll(){
return CommonResult.success(checkTicketService.deleteTwoYearLastMonthAgo());
}
private void methodUtils(Map<String, Object> map, String name, Object list){
map.put(name,list);
}
private String methodDataUtils(){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
@GetMapping("/test")
public void test(){
Map<String, Object> map = new HashMap<>();
String dataUtils = this.methodDataUtils();
this.methodUtils(map, "assetCount", largeScreenClient.assetMethod1());
this.methodUtils(map,"saleDataTotal",largeScreenClient.saleDataTotal(dataUtils,dataUtils));
this.methodUtils(map,"checkTicketTotal",largeScreenClient.checkTicketTotal(dataUtils,dataUtils));
webSocketSenderApi.sendObject(2,1L,"1",map);
}
@GetMapping("/testa")
public CommonResult<List<String>> testAlla(){
return CommonResult.success(saleDataService.deleteTwoYearLastMonthAgo());

View File

@ -7,6 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -19,10 +22,25 @@ public class LargeScreenHeartbeat {
@Resource
private LargeScreenClient largeScreenClient;
private void methodUtils(Map<String, Object> map, String name, Object list){
map.put(name,list);
}
private String methodDataUtils(){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
@XxlJob("largeScreen")
public void largeScreenToWebSocket(){
List<Object> maps = largeScreenClient.assetMethod1();
webSocketSenderApi.sendObject(1,"1",maps);
Map<String, Object> map = new HashMap<>();
String dataUtils = this.methodDataUtils();
this.methodUtils(map, "assetCount", largeScreenClient.assetMethod1());
this.methodUtils(map,"saleDataTotal",largeScreenClient.saleDataTotal(dataUtils,dataUtils));
this.methodUtils(map,"checkTicketTotal",largeScreenClient.checkTicketTotal(dataUtils,dataUtils));
webSocketSenderApi.sendObject(2,1L,"1",map);
}
}