Commit 34102153 authored by wujiang's avatar wujiang

提交

parent f4bfa9eb
...@@ -69,7 +69,7 @@ public class CompanyAndPersonTask { ...@@ -69,7 +69,7 @@ public class CompanyAndPersonTask {
/** /**
* 每天凌晨2点 * 每天凌晨2点
*/ */
@Scheduled(cron = "0 0 2 * * ?") //@Scheduled(cron = "0 0 2 * * ?")
public void run() { public void run() {
log.info("启动完成后执行rides缓存数据任务开始--------------->"); log.info("启动完成后执行rides缓存数据任务开始--------------->");
try { try {
......
...@@ -18,7 +18,7 @@ public class PlatFormTokenTask { ...@@ -18,7 +18,7 @@ public class PlatFormTokenTask {
@Autowired @Autowired
StartPlatformTokenService startPlatformTokenService; StartPlatformTokenService startPlatformTokenService;
@Scheduled(cron = "0 0 1 * * ?") //@Scheduled(cron = "0 0 1 * * ?")
public void getToken() { public void getToken() {
log.info("定时任务刷新token开始--------------->"); log.info("定时任务刷新token开始--------------->");
startPlatformTokenService.getToken(); startPlatformTokenService.getToken();
......
...@@ -34,7 +34,7 @@ public class JxiopCarReCountTimeBean { ...@@ -34,7 +34,7 @@ public class JxiopCarReCountTimeBean {
Car car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileageList.get(i).getIotCode())); Car car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", wlCarMileageList.get(i).getIotCode()));
if(ObjectUtils.isNotEmpty(car)){ if(ObjectUtils.isNotEmpty(car)){
String coordinate = String.valueOf(car.getLongitude()) + "," + String.valueOf(car.getLatitude()); String coordinate = String.valueOf(car.getLongitude()) + "," + String.valueOf(car.getLatitude());
redisTemplate.opsForValue().set(car.getIotCode(), coordinate, 10, TimeUnit.MINUTES); redisTemplate.opsForValue().set(car.getIotCode(), coordinate, 5, TimeUnit.MINUTES);
} }
} }
log.info("---------------------车辆重新开始计时::结束-------------------------"); log.info("---------------------车辆重新开始计时::结束-------------------------");
......
...@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; ...@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
...@@ -35,13 +36,19 @@ import java.text.ParseException; ...@@ -35,13 +36,19 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component @Component
@EnableAsync
public class CarIotNewListener extends EmqxListener { public class CarIotNewListener extends EmqxListener {
Logger logger = LoggerFactory.getLogger(CarIotNewListener.class); Logger logger = LoggerFactory.getLogger(CarIotNewListener.class);
@Autowired @Autowired
private JxiopCarIotListerServiceImpl jxiopCarIotListerServiceImpl; private JxiopCarIotListerServiceImpl jxiopCarIotListerServiceImpl;
public final static ExecutorService pooledExecutor =
Executors.newFixedThreadPool(100 + Runtime.getRuntime().availableProcessors());
// @Autowired // @Autowired
// private IWlCarMileageService iWlCarMileageService; // private IWlCarMileageService iWlCarMileageService;
// //
...@@ -74,10 +81,11 @@ public class CarIotNewListener extends EmqxListener { ...@@ -74,10 +81,11 @@ public class CarIotNewListener extends EmqxListener {
@Async @Async
public void processMessage(String topic, MqttMessage message) throws Exception { public void processMessage(String topic, MqttMessage message) throws Exception {
logger.info("----收到物联消息::topic---------------" + topic); //logger.info("----收到物联消息::topic---------------" + topic);
logger.info("----收到物联消息::message---------------" + message); logger.info("----收到物联消息::message---------------" + message);
pooledExecutor.submit(() -> {
jxiopCarIotListerServiceImpl.processMessage(topic,message); jxiopCarIotListerServiceImpl.processMessage(topic,message);
});
// String measurement = topic.split("/")[0]; // String measurement = topic.split("/")[0];
// String deviceName = topic.split("/")[1]; // String deviceName = topic.split("/")[1];
// //根据topic 组装iotCode // //根据topic 组装iotCode
......
...@@ -101,12 +101,12 @@ public class JxiopCarIotListerServiceImpl { ...@@ -101,12 +101,12 @@ public class JxiopCarIotListerServiceImpl {
this.updateCarLocation(jsonObject, iotCode); this.updateCarLocation(jsonObject, iotCode);
String coordinate = jsonObject.getString("FireCar_Longitude") + "," + jsonObject.getString("FireCar_Latitude"); String coordinate = jsonObject.getString("FireCar_Longitude") + "," + jsonObject.getString("FireCar_Latitude");
if (ObjectUtils.isEmpty(redisTemplate.opsForValue().get(iotCode))) { if (ObjectUtils.isEmpty(redisTemplate.opsForValue().get(iotCode))) {
redisTemplate.opsForValue().set(iotCode, coordinate, 10, TimeUnit.MINUTES); redisTemplate.opsForValue().set(iotCode, coordinate, 5, TimeUnit.MINUTES);
logger.info("插入数据到::redis"); logger.info("首次入库redis:{}", iotCode);
} else { } else {
if (!String.valueOf(redisTemplate.opsForValue().get(iotCode)).equals(coordinate)) { if (!String.valueOf(redisTemplate.opsForValue().get(iotCode)).equals(coordinate)) {
redisTemplate.opsForValue().set(iotCode, coordinate, 10, TimeUnit.MINUTES); logger.info("更新入库redis:{},旧:{},新:{}", iotCode, redisTemplate.opsForValue().get(iotCode), coordinate);
logger.info("插入数据到::redis"); redisTemplate.opsForValue().set(iotCode, coordinate, 5, TimeUnit.MINUTES);
} }
} }
} }
......
...@@ -409,14 +409,14 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -409,14 +409,14 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Scheduled(cron = "${mileage.splitmileage.cron}") @Scheduled(cron = "${mileage.splitmileage.cron}")
@Async @Async
public void endCarMileageTask() { public void endCarMileageTask() {
log.info("========开始轨迹切分任务===========");
List<WlCarMileage> list = wlCarMileageMapper.selectList(new QueryWrapper<WlCarMileage>().isNull("end_time").isNotNull("start_time")); List<WlCarMileage> list = wlCarMileageMapper.selectList(new QueryWrapper<WlCarMileage>().isNull("end_time").isNotNull("start_time"));
list.forEach(item -> { list.forEach(item -> {
log.info("1获取code:{}", item.getIotCode()); log.info("1获取code:{}", item.getIotCode());
log.info("2获取值:{}", redisTemplate.opsForValue().get(item.getIotCode())); log.info("2获取结果:{}", ObjectUtils.isEmpty(redisTemplate.opsForValue().get(item.getIotCode())));
log.info("3获取结果:{}", ObjectUtils.isEmpty(redisTemplate.opsForValue().get(item.getIotCode())));
if (ObjectUtils.isEmpty(redisTemplate.opsForValue().get(item.getIotCode()))) { if (ObjectUtils.isEmpty(redisTemplate.opsForValue().get(item.getIotCode()))) {
if (!ObjectUtils.isEmpty(item.getIotCode()) && item.getIotCode().length() > 8) { if (!ObjectUtils.isEmpty(item.getIotCode()) && item.getIotCode().length() > 8) {
log.info("4处理结束坐标轨迹iocCode:{}", item.getIotCode()); log.info("3处理结束坐标轨迹iocCode:{}", item.getIotCode());
// 查询车辆上报信息 // 查询车辆上报信息
Date date = new Date(); Date date = new Date();
ResponseModel<List<Object>> result = iotFeign.getLiveData(item.getIotCode().substring(0, 8), item.getIotCode().substring(8), ResponseModel<List<Object>> result = iotFeign.getLiveData(item.getIotCode().substring(0, 8), item.getIotCode().substring(8),
......
...@@ -55,7 +55,7 @@ public class RsDataQueue { ...@@ -55,7 +55,7 @@ public class RsDataQueue {
public void start() { public void start() {
service_apdu = Executors.newSingleThreadScheduledExecutor(); service_apdu = Executors.newSingleThreadScheduledExecutor();
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间 // 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
service_apdu.execute(task_runnable); // service_apdu.execute(task_runnable);
} }
public void addUpdateMessage(Long fmeaId,String userName) { public void addUpdateMessage(Long fmeaId,String userName) {
......
...@@ -143,7 +143,7 @@ message.alarm.char=\u51FA\u73B0 ...@@ -143,7 +143,7 @@ message.alarm.char=\u51FA\u73B0
mileage.parameter=0.5 mileage.parameter=0.5
# 电建项目配置 # 电建项目配置
mileage.segmentation.cron=0 0 0 * * ? mileage.segmentation.cron=0 0 0 * * ?
mileage.splitmileage.cron=0 0/1 * * * ? mileage.splitmileage.cron=0/30 * * * * ?
mileage.clippingtime=600000 mileage.clippingtime=600000
equip.car.alarmBattery= 10 equip.car.alarmBattery= 10
equip.car.maxTravel=400 equip.car.maxTravel=400
......
...@@ -88,6 +88,6 @@ public class FireAutoSysApplication implements ApplicationContextAware { ...@@ -88,6 +88,6 @@ public class FireAutoSysApplication implements ApplicationContextAware {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// 缓存spring上下文 // 缓存spring上下文
IotContext.getInstance().setApplicationContext(applicationContext); IotContext.getInstance().setApplicationContext(applicationContext);
RsDataQueue.getInstance().start(); //RsDataQueue.getInstance().start();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment