4.7提交修改bug
parent
b4ad3e4f47
commit
78afcf9ecc
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -4,7 +4,9 @@ import com.couplet.common.core.constant.ServiceNameConstants;
|
|||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.VehicleMiddle;
|
||||
import com.couplet.common.domain.request.VehicleListParams;
|
||||
import com.couplet.remote.factory.RemoteVehicleFallbackFactory;
|
||||
import lombok.extern.java.Log;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -62,4 +64,7 @@ public interface RemoteVehicleService {
|
|||
@PostMapping("/vehicleAndLogo/queryByLogoIds/{vehicleId}")
|
||||
public Result<List<Long>> queryByLogoIds(@PathVariable("vehicleId") Long vehicleId);
|
||||
|
||||
@PostMapping("/list")
|
||||
public Result list(@RequestBody VehicleListParams listParams);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.couplet.remote.factory;
|
|||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.VehicleMiddle;
|
||||
import com.couplet.common.domain.request.VehicleListParams;
|
||||
import com.couplet.remote.RemoteVehicleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -61,6 +62,11 @@ public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehic
|
|||
public Result<List<Long>> queryByLogoIds(Long vehicleId) {
|
||||
return Result.error("车辆服务调用失败:"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result list(VehicleListParams listParams) {
|
||||
return Result.error("车辆服务调用失败:"+cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -16,9 +16,10 @@ import com.couplet.common.domain.VehicleType;
|
|||
import com.couplet.common.domain.request.VehicleEditParams;
|
||||
import com.couplet.common.domain.request.VehicleInsertParams;
|
||||
import com.couplet.common.domain.request.VehicleListParams;
|
||||
import com.couplet.mq.remote.RemoteFenceService;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -36,10 +37,12 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
//车辆mapper
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
@Autowired
|
||||
private RedisService redis;
|
||||
|
||||
//远程发送mq
|
||||
@Autowired
|
||||
private RemoteFenceService remoteFenceService;
|
||||
// @Autowired
|
||||
// private RemoteFenceService remoteFenceService;
|
||||
|
||||
//车辆类型服务
|
||||
@Autowired
|
||||
|
@ -133,7 +136,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
String result = "";
|
||||
|
||||
if ((editParams.getLogoIds() == null || editParams.getLogoIds().isEmpty())) {
|
||||
result = "未选择电子围栏";
|
||||
result = "未选择标识";
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
|
@ -172,16 +175,16 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
||||
|
||||
|
||||
//mq
|
||||
List<Long> logoList = getBindLogoById(editParams.getVehicleId());
|
||||
if (0 != logoList.size()) {
|
||||
String ids = "";
|
||||
for (Long l : logoList) {
|
||||
ids = "," + l;
|
||||
}
|
||||
ids = ids.substring(1);
|
||||
remoteFenceService.vehicleQueue(editParams.getVehicleId() + "-" + ids);
|
||||
}
|
||||
// //mq
|
||||
// List<Long> logoList = getBindLogoById(editParams.getVehicleId());
|
||||
// if (0 != logoList.size()) {
|
||||
// String ids = "";
|
||||
// for (Long l : logoList) {
|
||||
// ids = "," + l;
|
||||
// }
|
||||
// ids = ids.substring(1);
|
||||
// remoteFenceService.vehicleQueue(editParams.getVehicleId() + "-" + ids);
|
||||
// }
|
||||
|
||||
|
||||
result = "编辑成功!";
|
||||
|
@ -201,7 +204,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
String result = "";
|
||||
|
||||
if ((insertParams.getLogoIds() == null || insertParams.getLogoIds().isEmpty())) {
|
||||
result = "未选择电子围栏";
|
||||
result = "未选择标识";
|
||||
Result.error(result);
|
||||
}
|
||||
|
||||
|
@ -251,16 +254,16 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
//执行添加电子围栏
|
||||
int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds());
|
||||
|
||||
|
||||
List<Long> logoList = getBindLogoById(vehicle.getVehicleId());
|
||||
if (0 != logoList.size()) {
|
||||
String ids = "";
|
||||
for (Long l : logoList) {
|
||||
ids = "," + l;
|
||||
}
|
||||
ids = ids.substring(1);
|
||||
remoteFenceService.vehicleQueue(vehicle.getVehicleId() + "-" + ids);
|
||||
}
|
||||
//
|
||||
// List<Long> logoList = getBindLogoById(vehicle.getVehicleId());
|
||||
// if (0 != logoList.size()) {
|
||||
// String ids = "";
|
||||
// for (Long l : logoList) {
|
||||
// ids = "," + l;
|
||||
// }
|
||||
// ids = ids.substring(1);
|
||||
// remoteFenceService.vehicleQueue(vehicle.getVehicleId() + "-" + ids);
|
||||
// }
|
||||
|
||||
|
||||
result = "新增成功!";
|
||||
|
@ -334,4 +337,46 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * *")
|
||||
public void aa() {
|
||||
System.out.println("********************************************************");
|
||||
}
|
||||
|
||||
//判断车辆是否下线
|
||||
@Scheduled(cron = "0/1 * * * * *")
|
||||
public void downLine() {
|
||||
log.info("定时器启动");
|
||||
//先查询车辆列表
|
||||
List<Vehicle> list = this.list(new VehicleListParams(null, null, null, null));
|
||||
|
||||
|
||||
list.forEach(vehicle -> {
|
||||
try {
|
||||
//只针对已经上线的车辆
|
||||
if (redis.hasKey(vehicle.getVin())) {
|
||||
|
||||
//如果vin的缓存 时间还剩一秒,则判断为已经下线
|
||||
if (redis.getExpire(vehicle.getVin()) <= 3) {
|
||||
log.info(vehicle.getVin() + "的车辆已经下线");
|
||||
|
||||
//执行修改下线状态的方法
|
||||
// Integer i = this.onOrOutLineByVIN(vehicle.getVin() + "," + 0);
|
||||
Integer i = this.onOrOutLineByVIN(vehicle.getVin() , 0);
|
||||
|
||||
if (0 == i) {
|
||||
log.error("下线状态修改失败");
|
||||
} else {
|
||||
log.info("下线状态修改成功");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
package com.couplet.business.server.time;
|
||||
|
||||
import com.couplet.business.server.service.VehicleService;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.request.VehicleListParams;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
* @CreateTime: 2024/4/4
|
||||
* @Description: 车辆定时器
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class Timer {
|
||||
//redis
|
||||
@Autowired
|
||||
private StringRedisTemplate redis;
|
||||
//查询车辆列表
|
||||
@Autowired
|
||||
private VehicleService vehicleService;
|
||||
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * *")
|
||||
public void aa() {
|
||||
System.out.println("********************************************************");
|
||||
}
|
||||
|
||||
//判断车辆是否下线
|
||||
@Scheduled(cron = "0/1 * * * * *")
|
||||
public void downLine() {
|
||||
log.info("定时器启动");
|
||||
|
||||
//先查询车辆列表
|
||||
List<Vehicle> list = vehicleService.list(new VehicleListParams(null, null, null, null));
|
||||
|
||||
|
||||
list.forEach(vehicle -> {
|
||||
try {
|
||||
//只针对已经上线的车辆
|
||||
if (redis.hasKey(vehicle.getVin())) {
|
||||
|
||||
//如果vin的缓存 时间还剩一秒,则判断为已经下线
|
||||
if (redis.getExpire(vehicle.getVin()) <= 3) {
|
||||
log.info(vehicle.getVin() + "的车辆已经下线");
|
||||
|
||||
//执行修改下线状态的方法
|
||||
Integer i = vehicleService.onOrOutLineByVIN(vehicle.getVin(), 0);
|
||||
|
||||
if (0 == i) {
|
||||
log.error("下线状态修改失败");
|
||||
} else {
|
||||
log.info("下线状态修改成功");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue