Commit 0063426a authored by caotao's avatar caotao

1.车辆管理-日志调整

parent e900428d
......@@ -12,6 +12,7 @@ import com.yeejoin.equipmanage.common.entity.vo.CarPropertyVo;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO;
import com.yeejoin.equipmanage.common.vo.EquipStateOnCarVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.List;
import java.util.Map;
......@@ -89,4 +90,6 @@ public interface CarMapper extends BaseMapper<Car> {
List<CarEquipAlarmInfoDto> getCarEquipAlarmInfo(Integer batteryNumber);
void updateStatusByIds(List<String> carIds, String status);
@Update("update wl_car set latitude = #{latitude} , longitude = #{longitude} where iot_code = #{iotCode}")
void updateCarLocationByIotCode(String iotCode,Double latitude,Double longitude);
}
......@@ -118,7 +118,6 @@ public class JxiopCarIotListerServiceImpl {
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);
......
......@@ -17,6 +17,7 @@ import com.yeejoin.equipmanage.common.utils.RedisUtil;
import com.yeejoin.equipmanage.controller.Coordinate;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.listener.CarIotNewListener;
import com.yeejoin.equipmanage.mapper.CarMapper;
import com.yeejoin.equipmanage.mapper.WlCarMileageMapper;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
......@@ -87,7 +88,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
private IWlCarMileageService iWlCarMileageService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
CarMapper carMapper;
public static List<String> getDayByMonth(Date date) {
List<String> data = new ArrayList<>();
try {
......@@ -320,24 +322,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
log.info("轨迹切分定时任务数据过滤时间.............{}", nowDate);
List<WlCarMileage> list = this.baseMapper.list(nowDate);
log.info("需要切分数据, {}", list);
//销毁所有线程和所有上次坐标
//销毁所有线程
// log.info("销毁所有有效线程开始");
// JxiopCarIotListerServiceImpl.deviceInfo.keySet().forEach(s -> {
// try {
// JxiopCarIotListerServiceImpl.deviceInfo.get(s).interrupt();
// } catch (Exception e) {
// log.info("销毁有效线程失败" + e.getMessage());
// }
// });
// JxiopCarIotListerServiceImpl.deviceInfo.clear();
// log.info("销毁所有有效线程成功");
// //销毁所有的坐标信息
// log.info("销毁所有坐标信息开始");
// JxiopCarIotListerServiceImpl.deviceLastInfo.clear();
log.info("销毁所有坐标信息成功");
log.info("------------------开始切分里程-------------------------------");
log.info("------------------跨天轨迹切分任开始切分里程-------------------------------");
list.forEach(item -> {
redisTemplate.delete(item.getIotCode());
Calendar calendar = Calendar.getInstance();
......@@ -407,49 +393,10 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
item.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
item.setTakeTime(takeTime);
this.getBaseMapper().updateById(item);
log.info("-----------结束里程成功:::" + JSONObject.toJSONString(item) + "-----------------");
// // 从0点开启新里程
// item.setStartName(address);
// item.setDate(date);
// item.setId(null);
// item.setEndSpeed(null);
// item.setEndTime(null);
// item.setEndLatitude(null);
// item.setEndLongitude(null);
// item.setEndName(null);
// item.setTravel(null);
// item.setTakeTime(null);
// item.setStartSpeed(v.intValue());
// item.setStartTime(item.getDate());
// item.setStartLongitude(startLongitude);
// item.setStartLatitude(startLatitude);
// this.baseMapper.insert(item);
// HashMap<String,String> messageMap = new HashMap<>();
// messageMap.put("FireCar_Latitude", String.valueOf(startLatitude));
// messageMap.put("FireCar_Longitude", String.valueOf(startLongitude));
// messageMap.put("FireCar_Speed",String.valueOf(v.intValue()));
// messageMap.put("time",String.valueOf(item.getDate().getTime()));
// messageMap.put("name","轨迹切分消息!!!");
// log.info("-----------新增开始里程成功:::"+JSONObject.toJSONString(item)+"-----------------");
// try {
// emqKeeper.getMqttClient().publish(item.getIotCode().substring(0, 8)+"/"+item.getIotCode().substring(8)+"/property",JSON.toJSON(messageMap).toString().getBytes("UTF-8"),1,false);
// } catch (Exception e) {
// }
//根据iotcode获取车辆并且同步经纬度到车辆
Car car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", item.getIotCode()));
car.setLongitude(startLongitude);
car.setLatitude(startLatitude);
iCarService.saveOrUpdate(car);
log.info("-----------更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------");
log.info("-----------跨天轨迹切分任更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------");
}
});
log.info("轨迹切分任务执行完成..............");
// log.info("-------------------对于切割完成的数据进行倒计时操作----------------------------------");
// ThreadCarMileageTreatment threadCarMileageTreatment = new ThreadCarMileageTreatment(this,iCarService , iotFeign);
// log.info("-------------------对于切割完成的数据进行倒计时开始----------------------------------");
// threadCarMileageTreatment.start();
// log.info("-------------------对于切割完成的数据进行倒计时结束----------------------------------");
log.info("-------------------跨天轨迹切分任务执行完成..............");
}
@Scheduled(cron = "${mileage.splitmileage.cron}")
......@@ -523,12 +470,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
}else {
this.getBaseMapper().deleteById(item.getId());
}
log.info("-----------结束里程成功:::" + JSONObject.toJSONString(item) + "-----------------");
Car car = iCarService.getOne(new QueryWrapper<Car>().eq("iot_code", item.getIotCode()));
car.setLongitude(startLongitude);
car.setLatitude(startLatitude);
iCarService.saveOrUpdate(car);
log.info("-----------更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------");
log.info("-----------正常结束轨迹更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------");
}
}
});
......
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