42 lines
1.2 KiB
Java
42 lines
1.2 KiB
Java
package com.zcloud.util;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.zcloud.plugins.websocketPositioning.PositioningServerPool;
|
|
import com.zcloud.service.bus.PositioningService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Component
|
|
public class PositioningScheduled {
|
|
|
|
@Autowired
|
|
private PositioningService positioningService;
|
|
|
|
@Scheduled(cron ="0/10 * * * * ? ")
|
|
public void syncPositioning(){
|
|
try {
|
|
System.out.println("==========定时发送人员定位信息==========");
|
|
List<String> varList = positioningService.findRedisAll();
|
|
PositioningServerPool.sendMessage(varList.toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Scheduled(cron ="0 0 2 * * ? ") // 凌晨两点
|
|
public void syncCardNo(){
|
|
try {
|
|
System.out.println("==========定时同步定位卡号==========");
|
|
positioningService.syncCardNo();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|