Commit 76f15050 by 黄小葱

车辆监控-定位部分代码

1 parent 9e26a34c
......@@ -14,4 +14,20 @@ public final class ConstantsDevice {
* 设备绑定车辆状态:2解绑
*/
public static final int UN_BIND_VEHICLE_STATUS = 2;
/**
* 设备在线状态 (0 行驶中)
*/
public static final int DEVICE_STATUS_DRIVING = 0;
/**
* 设备在线状态 (1 静止)
*/
public static final int DEVICE_STATUS_STATIC = 1;
/**
* 设备在线状态 (2 离线)
*/
public static final int DEVICE_STATUS_OFFLINE = 2;
/**
* 设备在线状态 (3 在线)
*/
public static final int DEVICE_STATUS_ONLINE = 3;
}
......@@ -54,28 +54,28 @@ public class VehicleController {
private HttpServletResponse response;
@ApiOperation(value = "试驾车辆列表查询")
@GetMapping("/trialdrive/search")
@GetMapping("/drivevehicle/search")
public R search(VehicleManageSearch search) {
PageInfo<TrialDriveVehiclePageDTO> pageInfo = vehicleService.searchTrialDrive(search);
return R.ok().putPageData(pageInfo);
}
@ApiOperation(value = "新增试驾车辆")
@PostMapping("/trialdrive/add")
@PostMapping("/drivevehicle/add")
public R addDriveVehicle(@RequestBody @Validated(ValidateGroups.Insert.class) TrialDriveVehicleBo driveVehicleBo) {
vehicleService.addDriveVehicle(driveVehicleBo);
return R.ok();
}
@ApiOperation(value = "根据id查询某条试驾车辆数据(数据回显)")
@GetMapping("/trialdrive/findbyid")
@GetMapping("/drivevehicle/findbyid")
public R findDriveVehicleById(@RequestParam(required = true)String tempId) {
TrialDriveVehicleEditDTO vehicleEditDTO = vehicleService.findDriveVehicleById(tempId);
return R.ok().data(vehicleEditDTO);
}
@ApiOperation(value = "编辑试驾车辆")
@PostMapping("/trialdrive/edit")
@PostMapping("/drivevehicle/edit")
public R updateDriveVehicle(@RequestBody @Validated(ValidateGroups.Update.class) TrialDriveVehicleEditBo driveVehicleoBo) {
vehicleService.updateDriveVehicleById(driveVehicleoBo);
return R.ok();
......@@ -89,7 +89,7 @@ public class VehicleController {
}
@ApiOperation(value = "(批量)删除试驾车辆数据")
@GetMapping("/trialdrive/delete")
@GetMapping("/drivevehicle/delete")
public R deleteDriveVehicle(@RequestParam(required = true) List<String> tempIds) {
if (CollectionUtils.isEmpty(tempIds)) {
return R.error("未选择数据");
......@@ -99,7 +99,7 @@ public class VehicleController {
}
@ApiOperation(value = "导出试驾车辆数据")
@GetMapping("/trialdrive/export")
@GetMapping("/drivevehicle/export")
public void exportDriveVehicle(HttpServletResponse response, VehicleManageSearch search) throws Exception {
List<TrialDriveVehicleExport> list = vehicleService.exportDriveVehicle(search);
String fileName = "试驾车辆_" + DateUtils.formatSerial(new Date());
......@@ -108,7 +108,7 @@ public class VehicleController {
}
@ApiOperation(value = "导入试驾车辆数据")
@PostMapping("/trialdrive/import")
@PostMapping("/drivevehicle/import")
public R importDriveVehicle(@RequestParam(value = "file") MultipartFile multipartFile) {
//1.校验导入的文件类型是否正确
String fileType = FileIOUtil.getMultipartFileType(multipartFile);
......@@ -138,7 +138,7 @@ public class VehicleController {
* 试驾车辆管理-下载车辆导入模板
* @throws Exception
*/
@RequestMapping(value = "/trialdrive/downloadtemplate")
@RequestMapping(value = "/drivevehicle/downloadtemplate")
@ResponseBody
// @SysLog("下载车辆管理导入模板")
public void downloadTemplate() throws Exception {
......@@ -147,7 +147,7 @@ public class VehicleController {
FileIOUtil.download(inputStream, FileIOUtil.MimeType.EXCEL2007, fileName, response);
}
@PostMapping("/syncVehicleInfo")
@PostMapping("/drivevehicle/syncVehicleInfo")
@SysLog("包活干同步车辆信息")
@ApiOperation(value = "包活干同步车辆信息")
public R syncVehicleInfoFromBhg(@RequestBody @Validated(ValidateGroups.Insert.class) SyncVehicleBo vehicleBo) {
......
......@@ -44,18 +44,18 @@ public class VehicleMonitorController {
@GetMapping("/areatree")
public R areaTreeList(Integer id, Integer level) {
return null;
}
// @ApiOperation(value = "查询车辆位置信息接口")
// @SysLog("查询车辆位置信息")
// @GetMapping("/vehiclelocation")
// public R vehicleLocationInfo(String sn, int refreshCount) {
//
//
// return null;
// }
@ApiOperation(value = "查询车辆位置信息接口")
@SysLog("查询车辆位置信息")
@GetMapping("/vehiclelocation")
public R vehicleLocationInfo(String sn, int refreshCount) {
vehicleMonitorSevice.getVehicleLocation(sn, refreshCount);
return null;
}
@ApiOperation(value = "轨迹回放")
......
package cn.com.glsx.admin.modules.model.param;
import lombok.Data;
/**
* @Desc:设备定位信息
* @Author huangxc
* @Date 2021/5/24
*/
@Data
public class DeviceLocation {
/**
* 经度
*/
private String lng;
/**
* 纬度
*/
private String lat;
/**
* 类型:gps:1 基站:2
*/
private Integer locatType;
/**
* 最后定位时间
*/
private String time;
}
package cn.com.glsx.admin.modules.model.param;
import lombok.Data;
/**
* @Desc:设备定位信息
* @Author huangxc
* @Date 2021/5/24
*/
@Data
public class DeviceLocationBo {
private String sn;
/**
* 状态(0 行驶中 1 静止 2离线 3 在线)
*/
private Integer status;
/**
* gps位置信息
*/
private DeviceLocation gpsLocation;
/**
* 基站位置信息
*/
private DeviceLocation bsLocation;
/**
* 是否显示 wifi定位按钮 1:显示
*/
private int wifiType;
}
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.common.constants.ConstantsDevice;
import cn.com.glsx.admin.modules.entity.Vehicle;
import cn.com.glsx.admin.modules.entity.VehicleDevice;
import cn.com.glsx.admin.modules.mapper.VehicleDeviceMapper;
import cn.com.glsx.admin.modules.mapper.VehicleMapper;
import cn.com.glsx.admin.modules.model.export.TrackModelExport;
import cn.com.glsx.admin.modules.model.param.DeviceLocationBo;
import cn.com.glsx.admin.modules.model.param.MonitorQueryBo;
import cn.com.glsx.admin.modules.utils.DateUtil;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum;
import cn.com.glsx.devicemonitor.api.feign.GpsBsService;
......@@ -15,6 +18,8 @@ import com.glsx.plat.context.utils.PropertiesUtils;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -31,6 +36,8 @@ import java.util.List;
@Service
public class VehicleMonitorSevice {
protected Log logger = LogFactory.getLog(getClass());
@Autowired
private GpsBsService gpsBsService;
......@@ -110,4 +117,38 @@ public class VehicleMonitorSevice {
}
return trackModelList;
}
/**
* 获取车辆的位置信息
* @param sn
* @param refreshCount
*/
public DeviceLocationBo getVehicleLocation(String sn, int refreshCount) {
DeviceLocationBo retLocation = new DeviceLocationBo();
R gpsBsDataR = gpsBsService.getLastGpsBsBySn(sn, DeviceTypeRelationEnum.GPS.getDeviceCode());
if (!gpsBsDataR.isSuccess()) {
logger.info("获取最后gps和基站数据失败");
return retLocation;
}
if (gpsBsDataR.getData() == null) {
logger.info("获取最后gps和基站数据为空。");
return retLocation;
}
GpsBsData gpsBsData = (GpsBsData) gpsBsDataR.getData();
GpsLocation bsLocation = gpsBsData.getBsLocation();
GpsLocation gpsLocation = gpsBsData.getGpsLocation();
return null;
}
private int parseDeviceStatus(GpsLocation gpsLocation, GpsLocation bsLocation, String sn, long offlineTime) {
if (gpsLocation == null && bsLocation == null) {
return ConstantsDevice.DEVICE_STATUS_OFFLINE;
}
return ConstantsDevice.DEVICE_STATUS_OFFLINE;
}
}
......@@ -27,6 +27,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
......@@ -275,7 +276,8 @@ public class VehicleService {
R<List<User>> userR = userService.findByUser(new FindUserRequest().setUsername(shopName));
Long createId = null;
if (userR != null) {
List<User> userList = userR.getDataList();
List<User> userList = userR.getDataList(new TypeToken<List<User>>() {
}.getType());
if (CollectionUtils.isNotEmpty(userList) && userList.size() == 1) {
createId = userList.get(0).getId();
vehicle.setCreatedBy(createId);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!