Merge remote-tracking branch 'origin/master'
commit
f08b15903d
|
@ -0,0 +1,32 @@
|
||||||
|
package com.god.base.server.common.constants;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆信息
|
||||||
|
*/
|
||||||
|
public class VehicleConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆启动
|
||||||
|
*/
|
||||||
|
public static final Integer VEHICLE_START = 1;
|
||||||
|
/**
|
||||||
|
* 车辆停止
|
||||||
|
*/
|
||||||
|
public static final Integer VEHICLE_END = 0 ;
|
||||||
|
/**
|
||||||
|
* 车辆状态更改队列
|
||||||
|
*/
|
||||||
|
public static final String VEHICLE_STATUS_UPDATE_QUEUE = "vehicle_status_update_queue";
|
||||||
|
/**
|
||||||
|
* 车辆信息前缀
|
||||||
|
*/
|
||||||
|
public static final String VEHICLE_INFO_MAP = "vehicle_info_map";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -12,8 +12,7 @@ import lombok.NoArgsConstructor;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName Car
|
* 车辆信息管理对象
|
||||||
* @Author WenHao.Sao
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -22,6 +21,8 @@ import java.util.Date;
|
||||||
@TableName(value = "t_car")
|
@TableName(value = "t_car")
|
||||||
public class Car {
|
public class Car {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆Vin 主键
|
* 车辆Vin 主键
|
||||||
*/
|
*/
|
||||||
|
@ -123,6 +124,15 @@ public class Car {
|
||||||
@Excel(name = "车辆状态")
|
@Excel(name = "车辆状态")
|
||||||
private int status;
|
private int status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子围栏名称
|
||||||
|
*/
|
||||||
|
private String fenceName;
|
||||||
|
/**
|
||||||
|
* 车辆类型名称
|
||||||
|
*/
|
||||||
|
private String carTypeName;
|
||||||
|
|
||||||
public static Car carBuildAdd(CarRequest carRequest){
|
public static Car carBuildAdd(CarRequest carRequest){
|
||||||
return Car.builder()
|
return Car.builder()
|
||||||
.carVinId(carRequest.getCarVinId())
|
.carVinId(carRequest.getCarVinId())
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.god.base.server.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.god.common.core.annotation.Excel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶记录对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("driving_record")
|
||||||
|
@Builder
|
||||||
|
public class DrivingRecord {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private long id;
|
||||||
|
/**
|
||||||
|
* vin
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "开始时间" , width = 30 , dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date startTime;
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "结束时间" , width = 30 , dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 开始表示
|
||||||
|
*/
|
||||||
|
private String startKey;
|
||||||
|
/**
|
||||||
|
* 结束标识
|
||||||
|
*/
|
||||||
|
private String endKey;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id",getId())
|
||||||
|
.append("vin",getVin())
|
||||||
|
.append("startTime",getStartTime())
|
||||||
|
.append("endTime",getEndKey())
|
||||||
|
.append("startKey",getStartKey())
|
||||||
|
.append("endKey",getEndKey())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,214 @@
|
||||||
|
package com.god.base.server.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文信息实体类
|
||||||
|
* VehicleMessage
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("vehicle_message")
|
||||||
|
public class VehicleMessage {
|
||||||
|
/**
|
||||||
|
* 消息标识
|
||||||
|
*/
|
||||||
|
private String identifier;
|
||||||
|
/**
|
||||||
|
* VIN码
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private String longitude;
|
||||||
|
/**
|
||||||
|
* 维度
|
||||||
|
*/
|
||||||
|
private String latitude;
|
||||||
|
/**
|
||||||
|
* 车速
|
||||||
|
*/
|
||||||
|
private String speed;
|
||||||
|
/**
|
||||||
|
* 总里程
|
||||||
|
*/
|
||||||
|
private String totalDistance;
|
||||||
|
/**
|
||||||
|
* 总电压
|
||||||
|
*/
|
||||||
|
private String totalVoltage;
|
||||||
|
/**
|
||||||
|
* 总电流
|
||||||
|
*/
|
||||||
|
private String joinCurrent;
|
||||||
|
/**
|
||||||
|
* 绝缘电阻
|
||||||
|
*/
|
||||||
|
private String insulationResistance;
|
||||||
|
/**
|
||||||
|
* 档位
|
||||||
|
*/
|
||||||
|
private String gears;
|
||||||
|
/**
|
||||||
|
* 加速踏板行程值
|
||||||
|
*/
|
||||||
|
private String acceleratorPedal;
|
||||||
|
/**
|
||||||
|
* 制动踏板行程值
|
||||||
|
*/
|
||||||
|
private String brakePedal;
|
||||||
|
/**
|
||||||
|
* 燃料消耗率
|
||||||
|
*/
|
||||||
|
private String fuelRate;
|
||||||
|
/**
|
||||||
|
* 电机控制器温度
|
||||||
|
*/
|
||||||
|
private String motorControllerTemperature;
|
||||||
|
/**
|
||||||
|
* 电机转速
|
||||||
|
*/
|
||||||
|
private String motorSpeed;
|
||||||
|
/**
|
||||||
|
* 电机转矩
|
||||||
|
*/
|
||||||
|
private String motorTorque;
|
||||||
|
/**
|
||||||
|
* 电机温度
|
||||||
|
*/
|
||||||
|
private String motorTemperature;
|
||||||
|
/**
|
||||||
|
* 电机电压
|
||||||
|
*/
|
||||||
|
private String motorVoltage;
|
||||||
|
/**
|
||||||
|
* 电机电流
|
||||||
|
*/
|
||||||
|
private String motorCurrent;
|
||||||
|
/**
|
||||||
|
* 动力电池剩余电量SOC
|
||||||
|
*/
|
||||||
|
private String dumpEnergy;
|
||||||
|
/**
|
||||||
|
* 当前状态允许的最大反馈功率
|
||||||
|
*/
|
||||||
|
private String maximumFeedbackPower;
|
||||||
|
/**
|
||||||
|
* 当前状态允许最大放电功率
|
||||||
|
*/
|
||||||
|
private String maximumDischargePower;
|
||||||
|
/**
|
||||||
|
* BMS自检计数器
|
||||||
|
*/
|
||||||
|
private String selfCheckingCounter;
|
||||||
|
/**
|
||||||
|
* 动力电池充放电电流
|
||||||
|
*/
|
||||||
|
private String chargingAndDischargingCurrent;
|
||||||
|
/**
|
||||||
|
* 动力电池负载端总电压V3
|
||||||
|
*/
|
||||||
|
private String totalVoltageAtLoadEnd;
|
||||||
|
/**
|
||||||
|
* 单次最大电压
|
||||||
|
*/
|
||||||
|
private String maximumVoltage;
|
||||||
|
/**
|
||||||
|
* 单体电池最低电压
|
||||||
|
*/
|
||||||
|
private String lowestVoltageBattery;
|
||||||
|
/**
|
||||||
|
* 单体电池最高温度
|
||||||
|
*/
|
||||||
|
private String maximumTemperatureBattery;
|
||||||
|
/**
|
||||||
|
* 单体电池最低温度
|
||||||
|
*/
|
||||||
|
private String lowestTemperatureBattery;
|
||||||
|
/**
|
||||||
|
* 动力电池可用容量
|
||||||
|
*/
|
||||||
|
private String availableBatteryCapacity;
|
||||||
|
/**
|
||||||
|
* 车辆状态
|
||||||
|
*/
|
||||||
|
private Integer vehicleState;
|
||||||
|
/**
|
||||||
|
* 充电状态
|
||||||
|
*/
|
||||||
|
private Integer chargingState;
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
private Integer runningStatus;
|
||||||
|
/**
|
||||||
|
* SOC
|
||||||
|
*/
|
||||||
|
private Integer socStatus;
|
||||||
|
/**
|
||||||
|
* 可充电储能装置工作状态
|
||||||
|
*/
|
||||||
|
private Integer energyStorageDeviceState;
|
||||||
|
/**
|
||||||
|
* 驱动电机状态
|
||||||
|
*/
|
||||||
|
private Integer driveMotorCondition;
|
||||||
|
/**
|
||||||
|
* 定位是否有效
|
||||||
|
*/
|
||||||
|
private Integer positioningState;
|
||||||
|
/**
|
||||||
|
* 电子防窃系统状态
|
||||||
|
*/
|
||||||
|
private Integer easStatus;
|
||||||
|
/**
|
||||||
|
* 传动系统状态
|
||||||
|
*/
|
||||||
|
private Integer ptcStatus;
|
||||||
|
/**
|
||||||
|
* 蓄电池状态
|
||||||
|
*/
|
||||||
|
private Integer epsStatus;
|
||||||
|
/**
|
||||||
|
* 防滑刹车系统状态
|
||||||
|
*/
|
||||||
|
private Integer absStatus;
|
||||||
|
/**
|
||||||
|
* 微处理器状态
|
||||||
|
*/
|
||||||
|
private Integer mcuStatus;
|
||||||
|
/**
|
||||||
|
* 动力电池加热状态
|
||||||
|
*/
|
||||||
|
private Integer batteryHeatingCondition;
|
||||||
|
/**
|
||||||
|
* 动力电池当前状态
|
||||||
|
*/
|
||||||
|
private Integer currentBatteryStatus;
|
||||||
|
/**
|
||||||
|
* 动力电池保温状态
|
||||||
|
*/
|
||||||
|
private Integer batteryInsulationStatus;
|
||||||
|
/**
|
||||||
|
* 电力交换系统状态
|
||||||
|
*/
|
||||||
|
private Integer dcdcStatus;
|
||||||
|
/**
|
||||||
|
* 充电机状态
|
||||||
|
*/
|
||||||
|
private Integer chgStatus;
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private Integer time;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.god.base.server.common.domainConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据解析端
|
||||||
|
*/
|
||||||
|
public class RedisConstant {
|
||||||
|
/**
|
||||||
|
* 实时信息
|
||||||
|
*/
|
||||||
|
public static final String CURRENT_INFO = "current_info";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当日告警数
|
||||||
|
*/
|
||||||
|
public static final String CURRENT_DAY_FAULT = "current_day_fault";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当月告警数
|
||||||
|
*/
|
||||||
|
public static final String CURRENT_MONTH_FAULT = "current_month_fault";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆有关信息标识
|
||||||
|
*/
|
||||||
|
public static final String VEHICLE_INFO_TOKEN = "vehicle_info_token:";
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ server:
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: god-car-management
|
name: god-car-base
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
|
|
|
@ -2,8 +2,10 @@ package com.god.base.server.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.god.base.server.common.domain.Car;
|
import com.god.base.server.common.domain.Car;
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
import com.god.base.server.common.domain.request.CarRequest;
|
import com.god.base.server.common.domain.request.CarRequest;
|
||||||
import com.god.base.server.service.CarService;
|
import com.god.base.server.service.CarService;
|
||||||
|
import com.god.base.server.util.AopConfig;
|
||||||
import com.god.common.core.domain.Result;
|
import com.god.common.core.domain.Result;
|
||||||
import com.god.common.core.utils.poi.ExcelUtil;
|
import com.god.common.core.utils.poi.ExcelUtil;
|
||||||
import com.god.common.core.web.controller.BaseController;
|
import com.god.common.core.web.controller.BaseController;
|
||||||
|
@ -34,6 +36,9 @@ public class CarController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CarService carService;
|
private CarService carService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AopConfig aopConfig;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆信息管理列表
|
* 查询车辆信息管理列表
|
||||||
|
@ -41,19 +46,10 @@ public class CarController extends BaseController {
|
||||||
@RequiresPermissions
|
@RequiresPermissions
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<Car>> list(@RequestBody CarRequest carRequest){
|
public Result<TableDataInfo<Car>> list(@RequestBody CarRequest carRequest){
|
||||||
log.info("功能介绍车辆信息列表查看,请求方式:{},请求路径:{},请求参数:{}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getRequestURL(),
|
|
||||||
JSONObject.toJSONString(carRequest));
|
|
||||||
|
|
||||||
startPage();//设置请求分页数据
|
startPage();//设置请求分页数据
|
||||||
List<Car> list = carService.selectCarInfoList(carRequest);
|
List<Car> list = carService.selectCarInfoList(carRequest);
|
||||||
|
|
||||||
log.info("功能介绍车辆信息列表查看,响应方式:{},响应路径:{},响应参数:{}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getRequestURL(),
|
|
||||||
JSONObject.toJSONString(list));
|
|
||||||
|
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,12 +144,21 @@ public class CarController extends BaseController {
|
||||||
util.exportExcel(response,list,"车辆信息管理");
|
util.exportExcel(response,list,"车辆信息管理");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时轨迹
|
* 获取所有在线车辆
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@GetMapping("/onlineVehicle")
|
||||||
public Result sSgj(){
|
public Result<List<VehicleMessage>> onlineVehicle(){
|
||||||
return null;
|
return carService.onlineVehicle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计车辆
|
||||||
|
*/
|
||||||
|
@GetMapping("/countData")
|
||||||
|
public Result<String> countData(){
|
||||||
|
return carService.countData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,182 @@
|
||||||
|
package com.god.base.server.controller;
|
||||||
|
|
||||||
|
import com.god.base.server.common.domain.DrivingRecord;
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
|
import com.god.base.server.service.IDrivingRecordService;
|
||||||
|
import com.god.common.core.domain.Result;
|
||||||
|
import com.god.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.god.common.core.web.controller.BaseController;
|
||||||
|
import com.god.common.core.web.page.TableDataInfo;
|
||||||
|
import com.god.common.log.annotation.Log;
|
||||||
|
import com.god.common.log.enums.BusinessType;
|
||||||
|
import com.god.common.security.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶记录 DrivingRecordController
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/record")
|
||||||
|
public class DrivingRecordController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IDrivingRecordService drivingRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆行驶记录
|
||||||
|
*
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("record:record:list")
|
||||||
|
@GetMapping("list")
|
||||||
|
public Result<TableDataInfo<DrivingRecord>> list(DrivingRecord drivingRecord){
|
||||||
|
//设置请求分页数据
|
||||||
|
startPage();
|
||||||
|
List<DrivingRecord> list = drivingRecordService.selectDrivingRecordList(drivingRecord);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出车辆行驶记录列表
|
||||||
|
* @param response
|
||||||
|
* @param drivingRecord
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("record:record:export")
|
||||||
|
@Log(title = "车辆行驶记录" , businessType = BusinessType.EXPORT) // 导出
|
||||||
|
@PostMapping("export")
|
||||||
|
public void export(HttpServletResponse response , DrivingRecord drivingRecord)
|
||||||
|
{
|
||||||
|
List<DrivingRecord> list = drivingRecordService.selectDrivingRecordList(drivingRecord);
|
||||||
|
ExcelUtil<DrivingRecord> util = new ExcelUtil<>(DrivingRecord.class);
|
||||||
|
//对list数据源将其里面的数据导入到excel表中
|
||||||
|
util.exportExcel(response , list , "车辆行驶记录数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆行驶记录详细信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result getInfo(@PathVariable("id") Long id){ //操作信息提醒
|
||||||
|
//返回成功数据 | 查询车辆行驶记录
|
||||||
|
return Result.success(drivingRecordService.selectDrivingRecordById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆行驶记录
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("record:record:add")
|
||||||
|
@Log(title = "车辆行驶记录" , businessType = BusinessType.INSERT) // 新增
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody DrivingRecord drivingRecord){
|
||||||
|
//响应返回结果 | 新增车辆行驶记录
|
||||||
|
return Result.success(drivingRecordService.insertDrivingRecord(drivingRecord));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆行驶记录
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("record:record:edit")
|
||||||
|
@Log(title = "车辆行驶记录" , businessType = BusinessType.UPDATE) // 修改
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody DrivingRecord drivingRecord)
|
||||||
|
{
|
||||||
|
//响应返回结果 | 修改车辆行驶记录
|
||||||
|
return Result.success(drivingRecordService.updateDrivingRecord(drivingRecord));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶记录的批量删除
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("record:record:remove")
|
||||||
|
@Log(title = "车辆行驶记录" , businessType = BusinessType.DELETE) // 删除
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
//响应返回结果 | 批量删除车辆行驶记录
|
||||||
|
return Result.success(drivingRecordService.deleteDrivingRecordByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加车辆行驶记录
|
||||||
|
* @param vin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/strtVehocle/{vin}")
|
||||||
|
public Result startVehicle(@PathVariable("vin") String vin){
|
||||||
|
DrivingRecord drivingRecord = new DrivingRecord();
|
||||||
|
drivingRecord.setVin(vin);
|
||||||
|
drivingRecord.setStartTime(new Date());
|
||||||
|
drivingRecordService.insertDrivingRecord(drivingRecord);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单条记录
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/findOne/{id}")
|
||||||
|
public Result<DrivingRecord> findOne(@PathVariable("id") Long id){
|
||||||
|
DrivingRecord drivingRecord = drivingRecordService.selectDrivingRecordById(id);
|
||||||
|
return Result.success(drivingRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回显历史轨迹
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("trackHistory/{id}")
|
||||||
|
public Result<List<VehicleMessage>> trackHistory(@PathVariable Long id){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ import com.god.base.common.domain.request.FenceAddRequest;
|
||||||
import com.god.base.common.domain.request.FenceQueryRequest;
|
import com.god.base.common.domain.request.FenceQueryRequest;
|
||||||
import com.god.base.server.service.FenceService;
|
import com.god.base.server.service.FenceService;
|
||||||
import com.god.common.core.web.page.TableDataInfo;
|
import com.god.common.core.web.page.TableDataInfo;
|
||||||
|
import com.god.common.log.annotation.Log;
|
||||||
|
import com.god.common.log.enums.BusinessType;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -42,15 +44,10 @@ public class FenceController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/insertFence")
|
@PostMapping("/insertFence")
|
||||||
|
@Log(title = "添加围栏", businessType = BusinessType.INSERT)
|
||||||
public Result<String> insertFence(@RequestBody @Validated FenceAddRequest fenceAddRequest){
|
public Result<String> insertFence(@RequestBody @Validated FenceAddRequest fenceAddRequest){
|
||||||
log.info("功能介绍新增电子围栏,请求方式;{},请求路径:{},请求参数:{}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getRequestURL(),
|
|
||||||
JSONObject.toJSONString(fenceAddRequest));
|
|
||||||
|
|
||||||
//围栏添加
|
//围栏添加
|
||||||
fenceService.save(Fence.fenceBuildAdd(fenceAddRequest));
|
fenceService.save(Fence.fenceBuildAdd(fenceAddRequest));
|
||||||
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,12 +58,8 @@ public class FenceController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/updateFence")
|
@PostMapping("/updateFence")
|
||||||
|
@Log(title = "编辑围栏",businessType = BusinessType.UPDATE)
|
||||||
public Result<String> updateFence(@RequestBody @Validated Fence fence){
|
public Result<String> updateFence(@RequestBody @Validated Fence fence){
|
||||||
log.info("功能介绍:编辑围栏信息,请求方式:{},请求路径:{},请求参数:{}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getRequestURL(),
|
|
||||||
JSONObject.toJSONString(fence));
|
|
||||||
|
|
||||||
//编辑电子围栏信息
|
//编辑电子围栏信息
|
||||||
fenceService.updateById(fence);
|
fenceService.updateById(fence);
|
||||||
|
|
||||||
|
@ -80,12 +73,8 @@ public class FenceController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/deleteFence")
|
@GetMapping("/deleteFence")
|
||||||
|
@Log(title = "根据围栏编号删除围栏",businessType = BusinessType.DELETE)
|
||||||
public Result<String> deleteFence(@RequestParam("fenceId") Integer fenceId){
|
public Result<String> deleteFence(@RequestParam("fenceId") Integer fenceId){
|
||||||
log.info("功能介绍:通过围栏编号删除围栏,请求方式:{},请求路径:{},请求参数:{}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getRequestURL(),
|
|
||||||
JSONObject.toJSONString(fenceId));
|
|
||||||
|
|
||||||
//根据围栏编号删除围栏
|
//根据围栏编号删除围栏
|
||||||
fenceService.removeById(fenceId);
|
fenceService.removeById(fenceId);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
|
@ -98,16 +87,10 @@ public class FenceController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/fenceListAndPage")
|
@PostMapping("/fenceListAndPage")
|
||||||
|
@Log(title = "查询围栏信息",businessType = BusinessType.FORCE)
|
||||||
public Result<TableDataInfo<Fence>> fenceListAndPage(@RequestBody FenceQueryRequest fenceQueryRequest){
|
public Result<TableDataInfo<Fence>> fenceListAndPage(@RequestBody FenceQueryRequest fenceQueryRequest){
|
||||||
log.info("功能介绍:查询围栏列表,请求方式:{},请求路径:{},请求参数:{}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getRequestURL(),
|
|
||||||
JSONObject.toJSONString(fenceQueryRequest));
|
|
||||||
|
|
||||||
//分页查询围栏列表
|
//分页查询围栏列表
|
||||||
TableDataInfo<Fence> dataInfo = fenceService.fenceListAndPage(fenceQueryRequest);
|
TableDataInfo<Fence> dataInfo = fenceService.fenceListAndPage(fenceQueryRequest);
|
||||||
|
|
||||||
return Result.success(dataInfo);
|
return Result.success(dataInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,10 @@ public interface CarMapper extends BaseMapper<Car> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Car> selectVehicleInfoList(CarRequest carRequest);
|
List<Car> selectVehicleInfoList(CarRequest carRequest);
|
||||||
|
|
||||||
|
List<String> getOnlineCarIds();
|
||||||
|
|
||||||
|
Integer getOnlineCarCount();
|
||||||
|
|
||||||
|
Integer getUnOnlineCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.god.base.server.mapper;
|
||||||
|
|
||||||
|
import com.god.base.server.common.domain.DrivingRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶轨迹 mapper 层
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DrivingRecordMapper {
|
||||||
|
/**
|
||||||
|
* 查询车辆行驶记录列表
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DrivingRecord> selectDrivingRecordList(DrivingRecord drivingRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆行驶记录
|
||||||
|
* @param id 车辆行驶主键
|
||||||
|
* @return 车辆行驶记录
|
||||||
|
*/
|
||||||
|
DrivingRecord selectDrivingRecordById(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆行驶记录
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertDrivingRecord(DrivingRecord drivingRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆行驶记录
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateDrivingRecord(DrivingRecord drivingRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除车辆行驶记录
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteDrivingRecordByIds(@Param("ids") Long[] ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.god.base.server.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.god.base.server.common.domain.Car;
|
import com.god.base.server.common.domain.Car;
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
import com.god.base.server.common.domain.request.CarRequest;
|
import com.god.base.server.common.domain.request.CarRequest;
|
||||||
import com.god.common.core.domain.Result;
|
import com.god.common.core.domain.Result;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
@ -18,6 +19,15 @@ public interface CarService extends IService<Car> {
|
||||||
|
|
||||||
|
|
||||||
List<Car> selectCarInfoList(CarRequest carRequest);
|
List<Car> selectCarInfoList(CarRequest carRequest);
|
||||||
|
|
||||||
|
Result<List<VehicleMessage>> onlineVehicle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应信息主题
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<String> countData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.god.base.server.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.god.base.server.common.domain.DrivingRecord;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶记录Service接口
|
||||||
|
*/
|
||||||
|
public interface IDrivingRecordService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆行驶记录列表
|
||||||
|
* @param drivingRecord
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DrivingRecord> selectDrivingRecordList(DrivingRecord drivingRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶记录主键
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
DrivingRecord selectDrivingRecordById(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆行驶记录
|
||||||
|
* @param drivingRecord 车辆行驶记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertDrivingRecord(DrivingRecord drivingRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆行驶记录
|
||||||
|
* @param drivingRecord 车辆行驶记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateDrivingRecord(DrivingRecord drivingRecord);
|
||||||
|
|
||||||
|
int deleteDrivingRecordByIds(Long[] ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,21 @@ package com.god.base.server.service.impl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.god.base.server.common.domain.Car;
|
import com.god.base.server.common.domain.Car;
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
import com.god.base.server.common.domain.request.CarRequest;
|
import com.god.base.server.common.domain.request.CarRequest;
|
||||||
|
import com.god.base.server.common.domainConstants.RedisConstant;
|
||||||
import com.god.base.server.mapper.CarMapper;
|
import com.god.base.server.mapper.CarMapper;
|
||||||
import com.god.base.server.service.CarService;
|
import com.god.base.server.service.CarService;
|
||||||
import com.god.common.core.domain.Result;
|
import com.god.common.core.domain.Result;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆管理业务层
|
* 车辆管理业务层
|
||||||
|
@ -25,6 +29,9 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarSe
|
||||||
@Autowired
|
@Autowired
|
||||||
private CarMapper carMapper;
|
private CarMapper carMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆信息
|
* 车辆信息
|
||||||
|
@ -129,5 +136,28 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarSe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有在线车辆
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<List<VehicleMessage>> onlineVehicle() {
|
||||||
|
List<String> ids = carMapper.getOnlineCarIds();
|
||||||
|
List<VehicleMessage> messages = ids.stream().map(id -> {
|
||||||
|
VehicleMessage message = (VehicleMessage) redisTemplate.opsForValue().get(RedisConstant.CURRENT_INFO + ":" + id);
|
||||||
|
return message;
|
||||||
|
}).collect(Collectors.toList());Collectors.toList();
|
||||||
|
return Result.success(messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> countData() {
|
||||||
|
Integer day = (Integer) redisTemplate.opsForValue().get(RedisConstant.VEHICLE_INFO_TOKEN+RedisConstant.CURRENT_DAY_FAULT);
|
||||||
|
Integer month = (Integer) redisTemplate.opsForValue().get(RedisConstant.VEHICLE_INFO_TOKEN+RedisConstant.CURRENT_MONTH_FAULT);
|
||||||
|
Integer onlineCount = carMapper.getOnlineCarCount();
|
||||||
|
Integer unOnlineCount = carMapper.getUnOnlineCount();
|
||||||
|
return Result.success(day + ":" + month + ":" + onlineCount + ":" + unOnlineCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.god.base.server.service.impl;
|
||||||
|
|
||||||
|
import com.god.base.server.common.domain.DrivingRecord;
|
||||||
|
import com.god.base.server.mapper.DrivingRecordMapper;
|
||||||
|
import com.god.base.server.service.IDrivingRecordService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName IDrivingRecordServiceImpl
|
||||||
|
* @Author WenHao.Sao
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆行驶记录Service业务层处理
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class IDrivingRecordServiceImpl implements IDrivingRecordService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DrivingRecordMapper drivingRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DrivingRecord> selectDrivingRecordList(DrivingRecord drivingRecord) {
|
||||||
|
return drivingRecordMapper.selectDrivingRecordList(drivingRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆行驶记录
|
||||||
|
* @param id 车辆行驶记录主键
|
||||||
|
* @return 车辆行驶记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DrivingRecord selectDrivingRecordById(Long id) {
|
||||||
|
return drivingRecordMapper.selectDrivingRecordById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆行驶记录
|
||||||
|
* @param drivingRecord 车辆行驶记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertDrivingRecord(DrivingRecord drivingRecord) {
|
||||||
|
return drivingRecordMapper.insertDrivingRecord(drivingRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆行驶记录
|
||||||
|
* @param drivingRecord 车辆行驶记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateDrivingRecord(DrivingRecord drivingRecord) {
|
||||||
|
//修改车辆行驶记录
|
||||||
|
return drivingRecordMapper.updateDrivingRecord(drivingRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除车辆行驶记录
|
||||||
|
* @param ids
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteDrivingRecordByIds(Long[] ids) {
|
||||||
|
//批量删除车辆行驶记录
|
||||||
|
return drivingRecordMapper.deleteDrivingRecordByIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.god.base.server.util;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aop切面 工具类
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class AopConfig {
|
||||||
|
//日志打印
|
||||||
|
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
ThreadLocal<Long> threadLocal = new ThreadLocal<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 定义切面的那个类
|
||||||
|
*/
|
||||||
|
@Pointcut("execution(* com.god.base.server.controller.*.*(..))")
|
||||||
|
public void print(){}
|
||||||
|
|
||||||
|
|
||||||
|
@Around("print()")
|
||||||
|
public Object LogStart(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||||
|
threadLocal.set(System.currentTimeMillis());
|
||||||
|
//使用ServletRequestAttributes请求上下文获取更多
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
String typeName = proceedingJoinPoint.getSignature().getDeclaringTypeName();
|
||||||
|
String name = proceedingJoinPoint.getSignature().getName();
|
||||||
|
//使用数据来获取参数
|
||||||
|
Object[] pointArgs = proceedingJoinPoint.getArgs();
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
logger.info("—_—方—_—_—法_—_—_—启—_—_—动—_—_—开—_—_—始—_—_—希—_—_—望—_—_—无—_—_—B—_—_—U—_—_—G—_—");
|
||||||
|
logger.info("|调用前是: 【{}】", typeName);
|
||||||
|
logger.info("|方法名称: 【{}】", name);
|
||||||
|
logger.info("|传递参数: 【{}】", objectMapper.writeValueAsString(objectMapper));
|
||||||
|
logger.info("|URL: 【{}】", request.getRequestURI().toString());
|
||||||
|
logger.info("IP: 【{}】", request.getRemoteAddr());
|
||||||
|
logger.info("______________________________________________________________________");
|
||||||
|
|
||||||
|
|
||||||
|
Object proceed = proceedingJoinPoint.proceed();
|
||||||
|
logger.info("|调用前是: 【{}】", typeName);
|
||||||
|
logger.info("|方法名称: 【{}】", name);
|
||||||
|
logger.info("|传递参数: 【{}】", objectMapper.writeValueAsString(objectMapper));
|
||||||
|
logger.info("|URL: 【{}】", request.getRequestURI().toString());
|
||||||
|
logger.info("IP: 【{}】", request.getRemoteAddr());
|
||||||
|
logger.info("|耗时: 【{}】", System.currentTimeMillis() - threadLocal.get());
|
||||||
|
|
||||||
|
return proceed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
//package com.god.base.server.webSocket.config;
|
||||||
|
//import org.springframework.context.annotation.Bean;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.web.server.ServerWebInputException;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * WebSocketConfig
|
||||||
|
// * 开始webSocket
|
||||||
|
// * WenHao.Sao
|
||||||
|
// */
|
||||||
|
//@Configuration
|
||||||
|
//public class WebSocketConfig {
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public ServerEndpointExporter serverEndpointExporter(){
|
||||||
|
// return new ServerEndpointExporter();
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.god.base.server.webSocket.controller;
|
||||||
|
|
||||||
|
import com.god.base.server.webSocket.handler.SocketBatchHandler;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.websocket.OnOpen;
|
||||||
|
import javax.websocket.Session;
|
||||||
|
import javax.websocket.server.ServerEndpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName WebSocketBatchSever
|
||||||
|
* @Author WenHao.Sao
|
||||||
|
*/
|
||||||
|
@ServerEndpoint("/car/batch")
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class WebSocketBatchSever {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接建立成功方法
|
||||||
|
*/
|
||||||
|
@OnOpen
|
||||||
|
public void onOpen(Session session){
|
||||||
|
log.info("车辆大屏新连接" + session.getId());
|
||||||
|
SocketBatchHandler.sessions.add(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.god.base.server.webSocket.controller;
|
||||||
|
import com.god.base.server.webSocket.entity.SocketData;
|
||||||
|
import com.god.base.server.webSocket.handler.SocketHandler;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import javax.websocket.OnOpen;
|
||||||
|
import javax.websocket.Session;
|
||||||
|
import javax.websocket.server.ServerEndpoint;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WebSocketServer服务类
|
||||||
|
*/
|
||||||
|
@ServerEndpoint("/vehicle/realTime/{vin}")
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class WebSocketServer {
|
||||||
|
/**
|
||||||
|
* 连接建立成功调用的方法
|
||||||
|
*/
|
||||||
|
@OnOpen
|
||||||
|
public void onOpen(Session session , @PathVariable("vin") String vin){
|
||||||
|
log.info("车辆实时轨迹,新连接:{}" , session.getId());
|
||||||
|
SocketData socketData = new SocketData();
|
||||||
|
socketData.setVin(vin);
|
||||||
|
socketData.setSession(session);
|
||||||
|
SocketHandler.socketList.add(socketData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.god.base.server.webSocket.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.websocket.Session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SocketData
|
||||||
|
* @Author WenHao.Sao
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SocketData {
|
||||||
|
/**
|
||||||
|
* vin
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
/**
|
||||||
|
*连接对象
|
||||||
|
*/
|
||||||
|
private Session session;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.god.base.server.webSocket.entity;
|
||||||
|
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName VehicleAllData
|
||||||
|
* @Author WenHao.Sao
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class VehicleAllData {
|
||||||
|
private List<VehicleMessage> messages;
|
||||||
|
|
||||||
|
private String info;
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.god.base.server.webSocket.handler;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
|
import com.god.base.server.common.domainConstants.RedisConstant;
|
||||||
|
import com.god.base.server.mapper.CarMapper;
|
||||||
|
import com.god.base.server.webSocket.entity.VehicleAllData;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.websocket.Session;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author swh的mac
|
||||||
|
* @Date 2023/11/20 14:37
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class SocketBatchHandler {
|
||||||
|
public static CopyOnWriteArrayList<Session> sessions = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarMapper carMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0/1 * * * * ?")
|
||||||
|
public void sendMessageFlush(){
|
||||||
|
for (Session session : sessions) {
|
||||||
|
List<String> ids = carMapper.getOnlineCarIds();
|
||||||
|
List<VehicleMessage> messages = ids.stream().map(id -> {
|
||||||
|
VehicleMessage message = (VehicleMessage) redisTemplate.opsForValue().get(RedisConstant.CURRENT_INFO + ":" + id);
|
||||||
|
return message;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
Integer day = (Integer) redisTemplate.opsForValue().get(RedisConstant.VEHICLE_INFO_TOKEN+RedisConstant.CURRENT_DAY_FAULT);
|
||||||
|
Integer month = (Integer) redisTemplate.opsForValue().get(RedisConstant.VEHICLE_INFO_TOKEN+RedisConstant.CURRENT_MONTH_FAULT);
|
||||||
|
Integer onlineCount = carMapper.getOnlineCarCount();
|
||||||
|
Integer unOnlineCount = carMapper.getUnOnlineCount();
|
||||||
|
VehicleAllData vehicleAllData = new VehicleAllData();
|
||||||
|
vehicleAllData.setMessages(messages);
|
||||||
|
vehicleAllData.setInfo(day+":"+month+":"+onlineCount+":"+unOnlineCount);
|
||||||
|
try {
|
||||||
|
session.getBasicRemote().sendText(JSON.toJSONString(vehicleAllData));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("{}:连接中断",session.getId());
|
||||||
|
sessions.remove(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.god.base.server.webSocket.handler;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.god.base.server.common.domain.VehicleMessage;
|
||||||
|
import com.god.base.server.common.domainConstants.RedisConstant;
|
||||||
|
import com.god.base.server.webSocket.entity.SocketData;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.websocket.Session;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author swh的mac
|
||||||
|
* @Date 2023/11/20 15:51
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class SocketHandler {
|
||||||
|
//存放每个客户端对应的MyWebSocket
|
||||||
|
public static CopyOnWriteArrayList<SocketData> socketList = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0/1 * * * * ?")
|
||||||
|
public void sendMessageFlush(){
|
||||||
|
for (SocketData socketData : socketList) {
|
||||||
|
Session session = socketData.getSession();
|
||||||
|
VehicleMessage msg = (VehicleMessage) redisTemplate.opsForValue().get(RedisConstant.CURRENT_INFO + ":" + socketData.getVin());
|
||||||
|
try {
|
||||||
|
session.getBasicRemote().sendText(JSON.toJSONString(msg));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("{}:连接中断",socketData.getSession().getId());
|
||||||
|
socketList.remove(socketData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,4 +40,19 @@
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getOnlineCarIds" resultType="java.lang.String">
|
||||||
|
select vin
|
||||||
|
from car where vehicle_status = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getOnlineCarCount" resultType="java.lang.Integer">
|
||||||
|
select count(*)
|
||||||
|
from t_car where status = 1
|
||||||
|
</select>
|
||||||
|
<select id="getUnOnlineCount" resultType="java.lang.Integer">
|
||||||
|
select count(*)
|
||||||
|
from t_car
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.god.base.server.mapper.DrivingRecordMapper">
|
||||||
|
<resultMap id="DrivingRecordResult" type="com.god.base.server.common.domain.DrivingRecord">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="vin" column="vin"/>
|
||||||
|
<result property="startTime" column="start_time"/>
|
||||||
|
<result property="startKey" column="start_key"/>
|
||||||
|
<result property="endTime" column="end_time"/>
|
||||||
|
<result property="endKey" column="end_key"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="selectDrivingRecordVo">
|
||||||
|
select id , vin ,start_time ,end_time , start_key , end_key , from driving_record
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 查询车辆行驶记录列表-->
|
||||||
|
<select id="selectDrivingRecordList" resultType="com.god.base.server.common.domain.DrivingRecord">
|
||||||
|
<include refid="selectDrivingRecordVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="vin != null and vin != '' "> and vin = #{vin} </if>
|
||||||
|
<if test="startTime != null"> and start_time = #{startTime} </if>
|
||||||
|
<if test="endTime != null"> and endTime = #{endTime} </if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 查询车辆行驶记录-->
|
||||||
|
<select id="selectDrivingRecordById" resultType="com.god.base.server.common.domain.DrivingRecord">
|
||||||
|
<include refid="selectDrivingRecordVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 新增车辆行驶记录 -->
|
||||||
|
<insert id="insertDrivingRecord" parameterType="com.god.base.server.common.domain.DrivingRecord" useGeneratedKeys="true" keyProperty="id" >
|
||||||
|
insert into driving_record
|
||||||
|
<trim prefix="(" suffix= ")" suffixOverrides=",">
|
||||||
|
<if test="vin != null and vin != '' ">vin,</if>
|
||||||
|
<if test="startTime != null">start_time,</if>
|
||||||
|
<if test="endTime != null">end_time,</if>
|
||||||
|
<if test="startTime != null ">start_time,</if>
|
||||||
|
<if test="endKey != null">end_key,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="vin != null and vin != '' ">#{vin},</if>
|
||||||
|
<if test="startTime != null">#{startTime},</if>
|
||||||
|
<if test="endTime != null">#{endTime},</if>
|
||||||
|
<if test="startKey != null ">#{startKey},</if>
|
||||||
|
<if test="endKey != null">#{endKey},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改车辆行驶记录-->
|
||||||
|
<update id="updateDrivingRecord" parameterType="com.god.base.server.common.domain.DrivingRecord">
|
||||||
|
update driving_record
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="vin != null and vin != '' ">vin = #{vin},</if>
|
||||||
|
<if test="startTime != null">start_time = #{startTime},</if>
|
||||||
|
<if test="endTime != null">end_time = #{endTime},</if>
|
||||||
|
<if test="startKey != null ">start_time = #{startKey},</if>
|
||||||
|
<if test="endKey != null">end_key = #{endKey},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 批量删除车辆行驶数据-->
|
||||||
|
<delete id="deleteDrivingRecordByIds" parameterType="String">
|
||||||
|
delete from drving_record where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{ids}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue