Commit 3a3584a7 authored by caotao's avatar caotao

解决循环依赖问题

parent ea6f6147
......@@ -12,6 +12,7 @@ import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
......@@ -25,27 +26,22 @@ import java.util.stream.Collectors;
/**
* 赋码动作
*
* @author DELL
*/
@Component
@RuleActionBean(beanLabel = "动态预案")
@Slf4j
public class UpdateQrCodeAction {
@Autowired
private ICarService carService;
@Autowired
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
private final String SOURCE_ID = "sourceId";
private final String SOURCE_CAR = "car";
private final String SOURCE_EQUIP = "equip";
/**
* 开闭区间正则表达式
*/
private static final Pattern NUM_RANGE_PATTERN = Pattern.compile("[\\[|\\(]\\s?\\d+\\s?,\\s?\\d+\\s?[\\)|\\]]");
private final String SOURCE_ID = "sourceId";
private final String SOURCE_CAR = "car";
private final String SOURCE_EQUIP = "equip";
@Autowired
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
@RuleMethod(methodLabel = "更新码", project = "车辆更新码颜色")
public void updateCarQrCode(@MethodParam(paramLabel = "判断值") String value, @MethodParam(paramLabel = "赋码颜色") String color,
......@@ -86,7 +82,7 @@ public class UpdateQrCodeAction {
if (!CollectionUtils.isEmpty(collect)) {
switch (source) {
case SOURCE_CAR:
carService.updateCarQrCode(collect, color);
equipmentSpecificSerivce.updateCarQrCode(collect, color);
break;
case SOURCE_EQUIP:
equipmentSpecificSerivce.updateEquipQrCode(collect, color);
......@@ -99,7 +95,7 @@ public class UpdateQrCodeAction {
}
}
private Map<String, String> getId (Map<String, String> map, String rule, String value, String compareValue) {
private Map<String, String> getId(Map<String, String> map, String rule, String value, String compareValue) {
Map<String, String> mapNew = new HashMap<>();
CalculationRulesEnum anEnum = CalculationRulesEnum.getEnum(rule);
switch (anEnum) {
......
......@@ -7,7 +7,7 @@ import com.yeejoin.equipmanage.common.entity.Car;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.utils.CoordinateUtil;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.mapper.CarMapper;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -36,7 +36,7 @@ public class CarIotListener extends EmqxListener {
private IWlCarMileageService iWlCarMileageService;
@Autowired
private ICarService iCarService;
private CarMapper carMapper;
@Autowired
private IotFeign iotFeign;
......@@ -154,7 +154,7 @@ public class CarIotListener extends EmqxListener {
int direction = jsonObject.getIntValue("direction");
// 地图推送消息
Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
Car car = carMapper.selectOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
if (car != null && startLongitude != 0 && startLatitude != 0) {
JSONArray sendArr = new JSONArray();
JSONObject sendObj = new JSONObject();
......@@ -169,7 +169,7 @@ public class CarIotListener extends EmqxListener {
mqttMessage.setPayload(sendArr.toJSONString().getBytes());
car.setLongitude(startLongitude);
car.setLatitude(startLatitude);
iCarService.updateById(car);
carMapper.updateById(car);
emqkeeper.getMqttClient().publish("car/location", mqttMessage);
}
}
......@@ -186,7 +186,6 @@ public class CarIotListener extends EmqxListener {
StringBuilder res = new StringBuilder();
BufferedReader in = null;
try {
System.out.println(api.toString());
URL url = new URL(api.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
......
......@@ -299,4 +299,6 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
String getEquipRealtimeSignal(long id);
EquipmentSpecific getEquipSpecificEntityByCode(String code);
void updateCarQrCode(List<Map<String, String>> carIds, String status);
}
......@@ -68,8 +68,6 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
@Autowired
EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired
IEquipmentSpecificSerivce equipmentSpecificService;
@Autowired
IEquipmentDetailService iEquipmentDetailService;
......@@ -326,7 +324,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
public Map<String, Object> getSpecificInfoById(Long id) {
Map<String, Object> map = new HashMap<>();
EquipmentSpecificAlarmLog alarm = equipmentSpecificAlarmLogMapper.selectById(id);
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(alarm.getEquipmentSpecificId());
EquipmentSpecific equipmentSpecific = equipmentSpecificMapper.selectById(alarm.getEquipmentSpecificId());
Map<String, Object> equipmentSpecificInfo = equipmentSpecificMapper.getEquipSpeInfo(alarm.getEquipmentSpecificId());
// equipmentSpecific.setFullqrCode("01#" + equipmentSpecific.getQrCode());
// EquipmentDetail equipmentDetail = iEquipmentDetailService.getOneById(equipmentSpecific.getEquipmentDetailId());
......@@ -369,7 +367,7 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
public Map<String, Object> getSpecificInfoByCode(String code) {
QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("code", code);
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getOne(queryWrapper);
EquipmentSpecific equipmentSpecific = equipmentSpecificMapper.selectOne(queryWrapper);
if (!ObjectUtils.isEmpty(equipmentSpecific)) {
Map<String, Object> map = new HashMap<>();
Long id = equipmentSpecific.getId();
......
......@@ -11,6 +11,7 @@ import com.yeejoin.equipmanage.common.entity.Car;
import com.yeejoin.equipmanage.common.entity.CarSpeedWarningRecord;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.CarMapper;
import com.yeejoin.equipmanage.mapper.WlCarSpeedWaringRecordMapper;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
......@@ -48,7 +49,7 @@ public class JxiopCarIotListerServiceImpl {
@Autowired
private IWlCarMileageService iWlCarMileageService;
@Autowired
private ICarService iCarService;
private CarMapper carMapper;
@Autowired
private IotFeign iotFeign;
@Autowired
......@@ -179,7 +180,7 @@ public class JxiopCarIotListerServiceImpl {
}
}
// 地图推送消息
Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
Car car = carMapper.selectOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
if (car != null && startLongitude != 0 && startLatitude != 0) {
JSONArray sendArr = new JSONArray();
JSONObject sendObj = new JSONObject();
......@@ -200,7 +201,7 @@ public class JxiopCarIotListerServiceImpl {
}
car.setExtra2(power.toString());
logger.info("----------------更新车辆电池电量信息成功----------------");
iCarService.updateById(car);
carMapper.updateById(car);
logger.info("车牌号::" + car.getCarNum() + "最大车速:" + maxSpeed + "当前车速::" + speed);
if ((speed - maxSpeed)>0) {
List<CarSpeedWarningRecord> list = wlCarSpeedWaringRecordMapper.selectList(new QueryWrapper<CarSpeedWarningRecord>().eq("car_num",car.getCarNum()).
......
......@@ -74,9 +74,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Autowired
IotFeign iotFeign;
@Autowired
ICarService iCarService;
@Autowired
WlCarMileageMapper wlCarMileageMapper;
@Autowired
CarMapper carMapper;
@Value("${car.max.speed:100}")
private Integer CAR_MAX_SPEED;
@Value("${mileage.parameter}")
......@@ -84,12 +84,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Resource
private EmqKeeper emqKeeper;
@Autowired
@Lazy
private IWlCarMileageService iWlCarMileageService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
CarMapper carMapper;
public static List<String> getDayByMonth(Date date) {
List<String> data = new ArrayList<>();
try {
......@@ -268,7 +264,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
public Map<String, Boolean> getCalender(long id, Date date) {
List<String> daylist = new ArrayList<String>();
Map<String, Boolean> map = new HashMap<>();
Car car = iCarService.getById(id);
Car car = carMapper.selectById(id);
if (car == null || car.getIotCode() == null || date == null) {
return map;
}
......@@ -386,7 +382,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
item.setEndLatitude(startLatitude);
item.setEndLongitude(startLongitude);
item.setEndName("无效坐标");
if(travel>0.5){
if (travel > 0.5) {
String address = getAddress(startLongitude, startLatitude);
item.setEndName(address);
}
......@@ -407,7 +403,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
if (ObjectUtils.isEmpty(redisTemplate.opsForValue().get(item.getIotCode()))) {
if (!ObjectUtils.isEmpty(item.getIotCode()) && item.getIotCode().length() > 8) {
// 查询车辆上报信息
Date date =new Date();
Date date = new Date();
ResponseModel<List<Object>> result = iotFeign.getLiveData(item.getIotCode().substring(0, 8), item.getIotCode().substring(8),
item.getStartTime(), new Date(new Date().getTime() + 2000));
List<Object> list1 = result.getResult();
......@@ -459,15 +455,15 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
item.setEndLatitude(startLatitude);
item.setEndLongitude(startLongitude);
item.setEndName("无效坐标");
if(travel>0.5){
if (travel > 0.5) {
String address = getAddress(startLongitude, startLatitude);
item.setEndName(address);
}
item.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
item.setTakeTime(takeTime);
if(travel>0.5){
if (travel > 0.5) {
this.getBaseMapper().updateById(item);
}else {
} else {
this.getBaseMapper().deleteById(item.getId());
}
log.info("-----------正常结束轨迹更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------");
......@@ -535,7 +531,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
wrapper.isNotNull(WlCarMileage::getEndTime);
wrapper.isNotNull(WlCarMileage::getStartTime);
wrapper.like(WlCarMileage::getStartTime, date);
List<WlCarMileage> list = iWlCarMileageService.list(wrapper);
List<WlCarMileage> list = this.list(wrapper);
for (WlCarMileage wl : list) {
//判断当前车辆全程是否异常,如果时速小于阈值 则对数据进行返回 否则不予返回
if (!org.springframework.util.ObjectUtils.isEmpty(wl.getTakeTime()) && !org.springframework.util.ObjectUtils.isEmpty(wl.getTravel()) && ((wl.getTravel() / (wl.getTakeTime() / 3600000.0)) < CAR_MAX_SPEED)) {
......@@ -555,7 +551,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
wrapper.isNotNull(WlCarMileage::getStartTime);
wrapper.ge(WlCarMileage::getDate, startDate);
wrapper.le(WlCarMileage::getDate, endDate);
List<WlCarMileage> list = iWlCarMileageService.list(wrapper);
List<WlCarMileage> list = this.list(wrapper);
for (WlCarMileage wl : list) {
//判断当前车辆全程是否异常,如果时速小于阈值 则对数据进行返回 否则不予返回
if (!org.springframework.util.ObjectUtils.isEmpty(wl.getTakeTime()) && !org.springframework.util.ObjectUtils.isEmpty(wl.getTravel()) && ((wl.getTravel() / (wl.getTakeTime() / 3600000.0)) < CAR_MAX_SPEED)) {
......
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