GPS数据转换接收

master
Yangwl 2 years ago
parent 79771ee6e5
commit 5fbe3be8d2

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs" />
<property name="log.path" value="../mesnac/print/logs" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

@ -59,6 +59,8 @@ public class BaseCarController extends BaseController
return getDataTable(list);
}
/**
*
*/
@ -147,4 +149,10 @@ public class BaseCarController extends BaseController
return getDataTable(baseDeviceList);
}
@GetMapping("/getCarGpsList")
public AjaxResult getCarGpsList(BaseCar baseCar){
List<BaseCar> baseCarList = baseCarService.selectGpsCarList(baseCar);
return success(baseCarList);
}
}

@ -47,6 +47,15 @@ public class BaseCarQueueController extends BaseController
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('carqueue:carqueue:list')")
@GetMapping("/carQueuelist")
public TableDataInfo carQueuelist(BaseCarQueue baseCarQueue)
{
startPage();
List<BaseCarQueue> list = baseCarQueueService.carQueuelist(baseCarQueue);
return getDataTable(list);
}
/**
*
*/

@ -2,6 +2,8 @@ package com.ruoyi.basetyre.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.uuid.UUID;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -22,10 +24,10 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
* Controller
*
* @author Yangwl
* @date 2023-02-15
* @date 2023-02-27
*/
@RestController
@RequestMapping("/basetyre/tyre")
@ -35,7 +37,7 @@ public class BaseTyreController extends BaseController
private IBaseTyreService baseTyreService;
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('basetyre:tyre:list')")
@GetMapping("/list")
@ -47,20 +49,20 @@ public class BaseTyreController extends BaseController
}
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('basetyre:tyre:export')")
@Log(title = "轮胎", businessType = BusinessType.EXPORT)
@Log(title = "轮胎基础", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BaseTyre baseTyre)
{
List<BaseTyre> list = baseTyreService.selectBaseTyreList(baseTyre);
ExcelUtil<BaseTyre> util = new ExcelUtil<BaseTyre>(BaseTyre.class);
util.exportExcel(response, list, "轮胎数据");
util.exportExcel(response, list, "轮胎基础数据");
}
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('basetyre:tyre:query')")
@GetMapping(value = "/{id}")
@ -70,10 +72,10 @@ public class BaseTyreController extends BaseController
}
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('basetyre:tyre:add')")
@Log(title = "轮胎", businessType = BusinessType.INSERT)
@Log(title = "轮胎基础", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BaseTyre baseTyre)
{
@ -81,10 +83,10 @@ public class BaseTyreController extends BaseController
}
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('basetyre:tyre:edit')")
@Log(title = "轮胎", businessType = BusinessType.UPDATE)
@Log(title = "轮胎基础", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BaseTyre baseTyre)
{
@ -92,13 +94,15 @@ public class BaseTyreController extends BaseController
}
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('basetyre:tyre:remove')")
@Log(title = "轮胎", businessType = BusinessType.DELETE)
@Log(title = "轮胎基础", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(baseTyreService.deleteBaseTyreByIds(ids));
}
}

@ -0,0 +1,104 @@
package com.ruoyi.basetyre.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basetyre.domain.CollectMachineGps;
import com.ruoyi.basetyre.service.ICollectMachineGpsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* GPSController
*
* @author Yangwl
* @date 2023-02-28
*/
@RestController
@RequestMapping("/basetyre/CollectMachineGps")
public class CollectMachineGpsController extends BaseController
{
@Autowired
private ICollectMachineGpsService collectMachineGpsService;
/**
* GPS
*/
@PreAuthorize("@ss.hasPermi('basetyre:CollectMachineGps:list')")
@GetMapping("/list")
public TableDataInfo list(CollectMachineGps collectMachineGps)
{
startPage();
List<CollectMachineGps> list = collectMachineGpsService.selectCollectMachineGpsList(collectMachineGps);
return getDataTable(list);
}
/**
* GPS
*/
@PreAuthorize("@ss.hasPermi('basetyre:CollectMachineGps:export')")
@Log(title = "GPS记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CollectMachineGps collectMachineGps)
{
List<CollectMachineGps> list = collectMachineGpsService.selectCollectMachineGpsList(collectMachineGps);
ExcelUtil<CollectMachineGps> util = new ExcelUtil<CollectMachineGps>(CollectMachineGps.class);
util.exportExcel(response, list, "GPS记录数据");
}
/**
* GPS
*/
@PreAuthorize("@ss.hasPermi('basetyre:CollectMachineGps:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(collectMachineGpsService.selectCollectMachineGpsById(id));
}
/**
* GPS
*/
@PreAuthorize("@ss.hasPermi('basetyre:CollectMachineGps:add')")
@Log(title = "GPS记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CollectMachineGps collectMachineGps)
{
return toAjax(collectMachineGpsService.insertCollectMachineGps(collectMachineGps));
}
/**
* GPS
*/
@PreAuthorize("@ss.hasPermi('basetyre:CollectMachineGps:edit')")
@Log(title = "GPS记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CollectMachineGps collectMachineGps)
{
return toAjax(collectMachineGpsService.updateCollectMachineGps(collectMachineGps));
}
/**
* GPS
*/
@PreAuthorize("@ss.hasPermi('basetyre:CollectMachineGps:remove')")
@Log(title = "GPS记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(collectMachineGpsService.deleteCollectMachineGpsByIds(ids));
}
}

@ -1,5 +1,6 @@
package com.ruoyi.basetyre.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -87,11 +88,11 @@ public class BaseCar extends BaseEntity
/** 最新GPS经度 */
@Excel(name = "最新GPS经度")
private Long longitude;
private BigDecimal longitude;
/** 最新GPS纬度 */
@Excel(name = "最新GPS纬度")
private Long latitude;
private BigDecimal latitude;
/** 轮胎数 */
@Excel(name = "轮胎数")
@ -121,8 +122,39 @@ public class BaseCar extends BaseEntity
/** 编辑人 */
@Excel(name = "编辑人")
private String modifyBy;
//状态
private int state;
//最后通讯时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date laseRuntime;
//车队id
private String queueId;
public void setId(String id)
public String getQueueId() {
return queueId;
}
public void setQueueId(String queueId) {
this.queueId = queueId;
}
public Date getLaseRuntime() {
return laseRuntime;
}
public void setLaseRuntime(Date laseRuntime) {
this.laseRuntime = laseRuntime;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public void setId(String id)
{
this.id = id;
}
@ -262,25 +294,25 @@ public class BaseCar extends BaseEntity
this.isHasDevice = isHasDevice;
}
public Long getIsHasDevice()
public Long getIsHasDevice()
{
return isHasDevice;
}
public void setLongitude(Long longitude)
public void setLongitude(BigDecimal longitude)
{
this.longitude = longitude;
}
public Long getLongitude()
public BigDecimal getLongitude()
{
return longitude;
}
public void setLatitude(Long latitude)
public void setLatitude(BigDecimal latitude)
{
this.latitude = latitude;
}
public Long getLatitude()
public BigDecimal getLatitude()
{
return latitude;
}

@ -1,12 +1,19 @@
package com.ruoyi.basetyre.domain;
import java.awt.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.entity.SysRole;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import javax.management.BadAttributeValueExpException;
/**
* base_car_queue
*
@ -73,6 +80,8 @@ public class BaseCarQueue extends BaseEntity
@Excel(name = "编辑者姓名")
private String modifyName;
private List<BaseCar> baseCarList;
public void setId(String id)
{
this.id = id;
@ -200,6 +209,14 @@ public class BaseCarQueue extends BaseEntity
return modifyName;
}
public List<BaseCar> getBaseCarList() {
return baseCarList;
}
public void setBaseCarList(List<BaseCar> baseCarList) {
this.baseCarList = baseCarList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -1,5 +1,6 @@
package com.ruoyi.basetyre.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -8,10 +9,10 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* base_tyre
* base_tyre
*
* @author Yangwl
* @date 2023-02-15
* @date 2023-02-27
*/
public class BaseTyre extends BaseEntity
{
@ -20,41 +21,141 @@ public class BaseTyre extends BaseEntity
/** $column.columnComment */
private String id;
/** 轮胎厂编码 */
@Excel(name = "轮胎厂编码")
private String tyreFacCode;
/** 轮胎厂名称 */
@Excel(name = "轮胎厂名称")
private String tyreFactory;
/** 企业编码 */
@Excel(name = "企业编码")
private String companyCode;
/** 外胎号 */
@Excel(name = "外胎号")
private String outerTireNumber;
/** 车辆ID */
@Excel(name = "车辆ID")
private String carId;
/** 物料编码 */
@Excel(name = "物料编码")
private String materialCode;
/** 车牌号 */
@Excel(name = "车牌号")
private String carLicense;
/** 物料编码 */
@Excel(name = "物料编码")
private String materialName;
/** 轮胎编号 */
@Excel(name = "轮胎编号")
private String tureCode;
/** 质控状态 */
@Excel(name = "质控状态")
private String qualityStatus;
/** 轮胎型号 */
@Excel(name = "轮胎型号")
private String tureModel;
/** 单位 */
@Excel(name = "单位")
private String unit;
/** 轮胎型号表ID */
@Excel(name = "轮胎型号表ID")
private String tureModelId;
/** 物料类型 */
@Excel(name = "物料类型")
private String materialType;
/** 品牌ID */
@Excel(name = "品牌ID")
private String tureBrandId;
/** 物料组 */
@Excel(name = "物料组")
private String materialGroup;
/** 产品组 */
@Excel(name = "产品组")
private String productGroup;
/** 品牌 */
@Excel(name = "品牌")
private String brand;
/** 品类 */
@Excel(name = "品类")
private String category;
/** 规格 */
@Excel(name = "规格")
private String size;
/** 花纹 */
@Excel(name = "花纹")
private String tyrePattern;
private String pattern;
/** 施工花纹 */
@Excel(name = "施工花纹")
private String consPattern;
/** 层级 */
@Excel(name = "层级")
private String hierarchy;
/** 速度级别 */
@Excel(name = "速度级别")
private String speedLevel;
/** 负荷指数 */
@Excel(name = "负荷指数")
private Long loadIndex;
/** 轮辋尺寸 */
@Excel(name = "轮辋尺寸")
private Long rimSize;
/** 标准重量 */
@Excel(name = "标准重量")
private Long weight;
/** 断面宽 */
@Excel(name = "断面宽")
private Long sectionWidth;
/** 外直径 */
@Excel(name = "外直径")
private Long outerDiameter;
/** 扁平率 */
@Excel(name = "扁平率")
private Long flattening;
/** 加强型 */
@Excel(name = "加强型")
private String enhanced;
/** 有无内胎 */
@Excel(name = "有无内胎")
private String innerTube;
/** 标准花纹深度 */
@Excel(name = "标准花纹深度")
private Long patternDepth;
/** 装箱量 */
@Excel(name = "装箱量")
private Long ctn;
/** 轮胎类型 */
@Excel(name = "轮胎类型")
private String type;
/** 认证信息 */
@Excel(name = "认证信息")
private String certInfo;
/** 报关规格 */
@Excel(name = "报关规格")
private String customsSpe;
/** 胎胚编码 */
@Excel(name = "胎胚编码")
private String feCode;
/** 胎胚描述 */
@Excel(name = "胎胚描述")
private String feDesc;
/** 生产工厂 */
@Excel(name = "生产工厂")
private String produceFactory;
/** 车辆ID */
@Excel(name = "车辆ID")
private String carId;
/** 车牌号 */
@Excel(name = "车牌号")
private String carLicense;
/** 轮位拼四段式1-1-1-21第一轴左侧外总第21个胎 */
@Excel(name = "轮位", readConverterExp = "拼=四段式1-1-1-21")
@ -66,7 +167,7 @@ public class BaseTyre extends BaseEntity
/** 当前花纹深度 */
@Excel(name = "当前花纹深度")
private Long currentTextureDepth;
private BigDecimal currentTextureDepth;
/** 状态 */
@Excel(name = "状态")
@ -110,86 +211,311 @@ public class BaseTyre extends BaseEntity
{
return id;
}
public void setTyreFacCode(String tyreFacCode)
public void setTyreFactory(String tyreFactory)
{
this.tyreFacCode = tyreFacCode;
this.tyreFactory = tyreFactory;
}
public String getTyreFacCode()
public String getTyreFactory()
{
return tyreFacCode;
return tyreFactory;
}
public void setCompanyCode(String companyCode)
public void setOuterTireNumber(String outerTireNumber)
{
this.companyCode = companyCode;
this.outerTireNumber = outerTireNumber;
}
public String getCompanyCode()
public String getOuterTireNumber()
{
return companyCode;
return outerTireNumber;
}
public void setCarId(String carId)
public void setMaterialCode(String materialCode)
{
this.carId = carId;
this.materialCode = materialCode;
}
public String getCarId()
public String getMaterialCode()
{
return carId;
return materialCode;
}
public void setCarLicense(String carLicense)
public void setMaterialName(String materialName)
{
this.carLicense = carLicense;
this.materialName = materialName;
}
public String getCarLicense()
public String getMaterialName()
{
return carLicense;
return materialName;
}
public void setQualityStatus(String qualityStatus)
{
this.qualityStatus = qualityStatus;
}
public String getQualityStatus()
{
return qualityStatus;
}
public void setUnit(String unit)
{
this.unit = unit;
}
public String getUnit()
{
return unit;
}
public void setMaterialType(String materialType)
{
this.materialType = materialType;
}
public String getMaterialType()
{
return materialType;
}
public void setMaterialGroup(String materialGroup)
{
this.materialGroup = materialGroup;
}
public String getMaterialGroup()
{
return materialGroup;
}
public void setProductGroup(String productGroup)
{
this.productGroup = productGroup;
}
public String getProductGroup()
{
return productGroup;
}
public void setBrand(String brand)
{
this.brand = brand;
}
public String getBrand()
{
return brand;
}
public void setCategory(String category)
{
this.category = category;
}
public String getCategory()
{
return category;
}
public void setSize(String size)
{
this.size = size;
}
public String getSize()
{
return size;
}
public void setPattern(String pattern)
{
this.pattern = pattern;
}
public String getPattern()
{
return pattern;
}
public void setConsPattern(String consPattern)
{
this.consPattern = consPattern;
}
public String getConsPattern()
{
return consPattern;
}
public void setTureCode(String tureCode)
public void setHierarchy(String hierarchy)
{
this.tureCode = tureCode;
this.hierarchy = hierarchy;
}
public String getTureCode()
public String getHierarchy()
{
return tureCode;
return hierarchy;
}
public void setTureModel(String tureModel)
public void setSpeedLevel(String speedLevel)
{
this.tureModel = tureModel;
this.speedLevel = speedLevel;
}
public String getTureModel()
public String getSpeedLevel()
{
return tureModel;
return speedLevel;
}
public void setTureModelId(String tureModelId)
public void setLoadIndex(Long loadIndex)
{
this.tureModelId = tureModelId;
this.loadIndex = loadIndex;
}
public String getTureModelId()
public Long getLoadIndex()
{
return tureModelId;
return loadIndex;
}
public void setTureBrandId(String tureBrandId)
public void setRimSize(Long rimSize)
{
this.tureBrandId = tureBrandId;
this.rimSize = rimSize;
}
public String getTureBrandId()
public Long getRimSize()
{
return tureBrandId;
return rimSize;
}
public void setTyrePattern(String tyrePattern)
public void setWeight(Long weight)
{
this.tyrePattern = tyrePattern;
this.weight = weight;
}
public String getTyrePattern()
public Long getWeight()
{
return weight;
}
public void setSectionWidth(Long sectionWidth)
{
this.sectionWidth = sectionWidth;
}
public Long getSectionWidth()
{
return sectionWidth;
}
public void setOuterDiameter(Long outerDiameter)
{
this.outerDiameter = outerDiameter;
}
public Long getOuterDiameter()
{
return outerDiameter;
}
public void setFlattening(Long flattening)
{
this.flattening = flattening;
}
public Long getFlattening()
{
return flattening;
}
public void setEnhanced(String enhanced)
{
return tyrePattern;
this.enhanced = enhanced;
}
public String getEnhanced()
{
return enhanced;
}
public void setInnerTube(String innerTube)
{
this.innerTube = innerTube;
}
public String getInnerTube()
{
return innerTube;
}
public void setPatternDepth(Long patternDepth)
{
this.patternDepth = patternDepth;
}
public Long getPatternDepth()
{
return patternDepth;
}
public void setCtn(Long ctn)
{
this.ctn = ctn;
}
public Long getCtn()
{
return ctn;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setCertInfo(String certInfo)
{
this.certInfo = certInfo;
}
public String getCertInfo()
{
return certInfo;
}
public void setCustomsSpe(String customsSpe)
{
this.customsSpe = customsSpe;
}
public String getCustomsSpe()
{
return customsSpe;
}
public void setFeCode(String feCode)
{
this.feCode = feCode;
}
public String getFeCode()
{
return feCode;
}
public void setFeDesc(String feDesc)
{
this.feDesc = feDesc;
}
public String getFeDesc()
{
return feDesc;
}
public void setProduceFactory(String produceFactory)
{
this.produceFactory = produceFactory;
}
public String getProduceFactory()
{
return produceFactory;
}
public void setCarId(String carId)
{
this.carId = carId;
}
public String getCarId()
{
return carId;
}
public void setCarLicense(String carLicense)
{
this.carLicense = carLicense;
}
public String getCarLicense()
{
return carLicense;
}
public void setTyrePosition(String tyrePosition)
{
@ -209,12 +535,12 @@ public class BaseTyre extends BaseEntity
{
return sensorId;
}
public void setCurrentTextureDepth(Long currentTextureDepth)
public void setCurrentTextureDepth(BigDecimal currentTextureDepth)
{
this.currentTextureDepth = currentTextureDepth;
}
public Long getCurrentTextureDepth()
public BigDecimal getCurrentTextureDepth()
{
return currentTextureDepth;
}
@ -295,15 +621,40 @@ public class BaseTyre extends BaseEntity
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("tyreFacCode", getTyreFacCode())
.append("companyCode", getCompanyCode())
.append("tyreFactory", getTyreFactory())
.append("outerTireNumber", getOuterTireNumber())
.append("materialCode", getMaterialCode())
.append("materialName", getMaterialName())
.append("qualityStatus", getQualityStatus())
.append("unit", getUnit())
.append("materialType", getMaterialType())
.append("materialGroup", getMaterialGroup())
.append("productGroup", getProductGroup())
.append("brand", getBrand())
.append("category", getCategory())
.append("size", getSize())
.append("pattern", getPattern())
.append("consPattern", getConsPattern())
.append("hierarchy", getHierarchy())
.append("speedLevel", getSpeedLevel())
.append("loadIndex", getLoadIndex())
.append("rimSize", getRimSize())
.append("weight", getWeight())
.append("sectionWidth", getSectionWidth())
.append("outerDiameter", getOuterDiameter())
.append("flattening", getFlattening())
.append("enhanced", getEnhanced())
.append("innerTube", getInnerTube())
.append("patternDepth", getPatternDepth())
.append("ctn", getCtn())
.append("type", getType())
.append("certInfo", getCertInfo())
.append("customsSpe", getCustomsSpe())
.append("feCode", getFeCode())
.append("feDesc", getFeDesc())
.append("produceFactory", getProduceFactory())
.append("carId", getCarId())
.append("carLicense", getCarLicense())
.append("tureCode", getTureCode())
.append("tureModel", getTureModel())
.append("tureModelId", getTureModelId())
.append("tureBrandId", getTureBrandId())
.append("tyrePattern ", getTyrePattern())
.append("tyrePosition", getTyrePosition())
.append("sensorId", getSensorId())
.append("currentTextureDepth", getCurrentTextureDepth())
@ -317,6 +668,7 @@ public class BaseTyre extends BaseEntity
.append("modifyId", getModifyId())
.append("modifyBy", getModifyBy())
.append("modifyName", getModifyName())
.append("remark", getRemark())
.toString();
}
}

@ -0,0 +1,432 @@
package com.ruoyi.basetyre.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.math.BigDecimal;
/**
* GPS collect_machine_gps
*
* @author Yangwl
* @date 2023-02-28
*/
public class CollectMachineGps extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private String id;
/** 收发器id */
@Excel(name = "收发器id")
private String machineId;
/** 车辆id */
@Excel(name = "车辆id")
private String carId;
/** 车牌号 */
@Excel(name = "车牌号")
private String carLicense;
/** 紧急报警 */
@Excel(name = "紧急报警")
private Long emergencyAlarm;
/** 超速预警 */
@Excel(name = "超速预警")
private Long speedAlarm;
/** 疲劳驾驶 */
@Excel(name = "疲劳驾驶")
private Long fatigueDrivingAlarm;
/** 危险预警 */
@Excel(name = "危险预警")
private Long riskEarlyAlarm;
/** gnss模块 */
@Excel(name = "gnss模块")
private Long gnssModule;
/** 天线缺失 */
@Excel(name = "天线缺失")
private Long gnssLossAntenna;
/** 天线短路 */
@Excel(name = "天线短路")
private Long gnssAntennaShortcircuit;
/** 终端主电源欠压 */
@Excel(name = "终端主电源欠压")
private Long mainPowerLake;
/** 终端主电源掉电 */
@Excel(name = "终端主电源掉电")
private Long mainpowerloss;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long accclose;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long unpositioned;
/** 0北纬1南纬 */
@Excel(name = "0北纬1南纬")
private Long dimensionalNOrS;
/** 0东经1西经 */
@Excel(name = "0东经1西经")
private Long longitudinalEOrW;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long dLIsencryption;
/** 纬度 */
@Excel(name = "纬度")
private double latitude;
/** 经度 */
@Excel(name = "经度")
private double longitude;
/** 海拔 */
@Excel(name = "海拔")
private Long altitude;
/** 速度 */
@Excel(name = "速度")
private Long speed;
/** 方向 */
@Excel(name = "方向")
private Long course;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long gpsIntensity;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long gpsSatellites;
/** GPS里程 */
@Excel(name = "GPS里程")
private Long gpsMileage;
/** 是否外接电源 */
@Excel(name = "是否外接电源")
private Long isOutPower;
/** 设备上传电池电压 */
@Excel(name = "设备上传电池电压")
private Long carPower;
/** 胎压设备是否正常工作 */
@Excel(name = "胎压设备是否正常工作")
private Long isSensorRun;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setMachineId(String machineId)
{
this.machineId = machineId;
}
public String getMachineId()
{
return machineId;
}
public void setCarId(String carId)
{
this.carId = carId;
}
public String getCarId()
{
return carId;
}
public void setCarLicense(String carLicense)
{
this.carLicense = carLicense;
}
public String getCarLicense()
{
return carLicense;
}
public void setEmergencyAlarm(Long emergencyAlarm)
{
this.emergencyAlarm = emergencyAlarm;
}
public Long getEmergencyAlarm()
{
return emergencyAlarm;
}
public void setSpeedAlarm(Long speedAlarm)
{
this.speedAlarm = speedAlarm;
}
public Long getSpeedAlarm()
{
return speedAlarm;
}
public void setFatigueDrivingAlarm(Long fatigueDrivingAlarm)
{
this.fatigueDrivingAlarm = fatigueDrivingAlarm;
}
public Long getFatigueDrivingAlarm()
{
return fatigueDrivingAlarm;
}
public void setRiskEarlyAlarm(Long riskEarlyAlarm)
{
this.riskEarlyAlarm = riskEarlyAlarm;
}
public Long getRiskEarlyAlarm()
{
return riskEarlyAlarm;
}
public void setGnssModule(Long gnssModule)
{
this.gnssModule = gnssModule;
}
public Long getGnssModule()
{
return gnssModule;
}
public void setGnssLossAntenna(Long gnssLossAntenna)
{
this.gnssLossAntenna = gnssLossAntenna;
}
public Long getGnssLossAntenna()
{
return gnssLossAntenna;
}
public void setGnssAntennaShortcircuit(Long gnssAntennaShortcircuit)
{
this.gnssAntennaShortcircuit = gnssAntennaShortcircuit;
}
public Long getGnssAntennaShortcircuit()
{
return gnssAntennaShortcircuit;
}
public void setMainPowerLake(Long mainPowerLake)
{
this.mainPowerLake = mainPowerLake;
}
public Long getMainPowerLake()
{
return mainPowerLake;
}
public void setMainpowerloss(Long mainpowerloss)
{
this.mainpowerloss = mainpowerloss;
}
public Long getMainpowerloss()
{
return mainpowerloss;
}
public void setAccclose(Long accclose)
{
this.accclose = accclose;
}
public Long getAccclose()
{
return accclose;
}
public void setUnpositioned(Long unpositioned)
{
this.unpositioned = unpositioned;
}
public Long getUnpositioned()
{
return unpositioned;
}
public void setDimensionalNOrS(Long dimensionalNOrS)
{
this.dimensionalNOrS = dimensionalNOrS;
}
public Long getDimensionalNOrS()
{
return dimensionalNOrS;
}
public void setLongitudinalEOrW(Long longitudinalEOrW)
{
this.longitudinalEOrW = longitudinalEOrW;
}
public Long getLongitudinalEOrW()
{
return longitudinalEOrW;
}
public void setdLIsencryption(Long dLIsencryption)
{
this.dLIsencryption = dLIsencryption;
}
public Long getdLIsencryption()
{
return dLIsencryption;
}
public void setLatitude(double latitude)
{
this.latitude = latitude;
}
public double getLatitude()
{
return latitude;
}
public void setLongitude(double longitude)
{
this.longitude = longitude;
}
public double getLongitude()
{
return longitude;
}
public void setAltitude(Long altitude)
{
this.altitude = altitude;
}
public Long getAltitude()
{
return altitude;
}
public void setSpeed(Long speed)
{
this.speed = speed;
}
public Long getSpeed()
{
return speed;
}
public void setCourse(Long course)
{
this.course = course;
}
public Long getCourse()
{
return course;
}
public void setGpsIntensity(Long gpsIntensity)
{
this.gpsIntensity = gpsIntensity;
}
public Long getGpsIntensity()
{
return gpsIntensity;
}
public void setGpsSatellites(Long gpsSatellites)
{
this.gpsSatellites = gpsSatellites;
}
public Long getGpsSatellites()
{
return gpsSatellites;
}
public void setGpsMileage(Long gpsMileage)
{
this.gpsMileage = gpsMileage;
}
public Long getGpsMileage()
{
return gpsMileage;
}
public void setIsOutPower(Long isOutPower)
{
this.isOutPower = isOutPower;
}
public Long getIsOutPower()
{
return isOutPower;
}
public void setCarPower(Long carPower)
{
this.carPower = carPower;
}
public Long getCarPower()
{
return carPower;
}
public void setIsSensorRun(Long isSensorRun)
{
this.isSensorRun = isSensorRun;
}
public Long getIsSensorRun()
{
return isSensorRun;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("machineId", getMachineId())
.append("carId", getCarId())
.append("carLicense", getCarLicense())
.append("emergencyAlarm", getEmergencyAlarm())
.append("speedAlarm", getSpeedAlarm())
.append("fatigueDrivingAlarm", getFatigueDrivingAlarm())
.append("riskEarlyAlarm", getRiskEarlyAlarm())
.append("gnssModule", getGnssModule())
.append("gnssLossAntenna", getGnssLossAntenna())
.append("gnssAntennaShortcircuit", getGnssAntennaShortcircuit())
.append("mainPowerLake", getMainPowerLake())
.append("mainpowerloss", getMainpowerloss())
.append("accclose", getAccclose())
.append("unpositioned", getUnpositioned())
.append("dimensionalNOrS", getDimensionalNOrS())
.append("longitudinalEOrW", getLongitudinalEOrW())
.append("dLIsencryption", getdLIsencryption())
.append("latitude", getLatitude())
.append("longitude", getLongitude())
.append("altitude", getAltitude())
.append("speed", getSpeed())
.append("course", getCourse())
.append("createTime", getCreateTime())
.append("gpsIntensity", getGpsIntensity())
.append("gpsSatellites", getGpsSatellites())
.append("gpsMileage", getGpsMileage())
.append("isOutPower", getIsOutPower())
.append("carPower", getCarPower())
.append("isSensorRun", getIsSensorRun())
.toString();
}
}

@ -60,4 +60,6 @@ public interface BaseCarMapper
public int deleteBaseCarByIds(String[] ids);
List<BaseCar> queryList(BaseCar baseCar);
List<BaseCar> selectGpsCarList(BaseCar baseCar);
}

@ -59,4 +59,6 @@ public interface BaseCarQueueMapper
* @return
*/
public int deleteBaseCarQueueByIds(String[] ids);
List<BaseCarQueue> carQueuelist(BaseCarQueue baseCarQueue);
}

@ -4,55 +4,55 @@ import java.util.List;
import com.ruoyi.basetyre.domain.BaseTyre;
/**
* Mapper
* Mapper
*
* @author Yangwl
* @date 2023-02-06
* @date 2023-02-27
*/
public interface BaseTyreMapper
{
/**
*
*
*
* @param id
* @return
* @param id
* @return
*/
public BaseTyre selectBaseTyreById(String id);
/**
*
*
*
* @param baseTyre
* @return
* @param baseTyre
* @return
*/
public List<BaseTyre> selectBaseTyreList(BaseTyre baseTyre);
/**
*
*
*
* @param baseTyre
* @param baseTyre
* @return
*/
public int insertBaseTyre(BaseTyre baseTyre);
/**
*
*
*
* @param baseTyre
* @param baseTyre
* @return
*/
public int updateBaseTyre(BaseTyre baseTyre);
/**
*
*
*
* @param id
* @param id
* @return
*/
public int deleteBaseTyreById(String id);
/**
*
*
*
* @param ids
* @return

@ -0,0 +1,61 @@
package com.ruoyi.basetyre.mapper;
import java.util.List;
import com.ruoyi.basetyre.domain.CollectMachineGps;
/**
* GPSMapper
*
* @author Yangwl
* @date 2023-02-28
*/
public interface CollectMachineGpsMapper
{
/**
* GPS
*
* @param id GPS
* @return GPS
*/
public CollectMachineGps selectCollectMachineGpsById(String id);
/**
* GPS
*
* @param collectMachineGps GPS
* @return GPS
*/
public List<CollectMachineGps> selectCollectMachineGpsList(CollectMachineGps collectMachineGps);
/**
* GPS
*
* @param collectMachineGps GPS
* @return
*/
public int insertCollectMachineGps(CollectMachineGps collectMachineGps);
/**
* GPS
*
* @param collectMachineGps GPS
* @return
*/
public int updateCollectMachineGps(CollectMachineGps collectMachineGps);
/**
* GPS
*
* @param id GPS
* @return
*/
public int deleteCollectMachineGpsById(String id);
/**
* GPS
*
* @param ids
* @return
*/
public int deleteCollectMachineGpsByIds(String[] ids);
}

@ -0,0 +1,74 @@
package com.ruoyi.basetyre.redislistener;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.basetyre.domain.CollectMachineGps;
import com.ruoyi.basetyre.service.ICollectMachineGpsService;
import com.ruoyi.common.t808.model.T0200;
import com.ruoyi.common.t808.model.T0704;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.List;
@Component
public class RedisMessageListener implements MessageListener {
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private ICollectMachineGpsService iCollectMachineGpsService;
@Override
public void onMessage(Message message, byte[] pattern) {
// 获取消息
byte[] messageBody = message.getBody();
// 使用值序列化器转换
Object msg = redisTemplate.getValueSerializer().deserialize(messageBody);
// 获取监听的频道
byte[] channelByte = message.getChannel();
// 使用字符串序列化器转换
Object channel = redisTemplate.getStringSerializer().deserialize(channelByte);
// 渠道名称转换
String patternStr = new String(pattern);
System.out.println(patternStr);
System.out.println("---频道---: " + channel);
System.out.println("---消息内容---: " + msg);
CollectMachineGps collectMachineGps =new CollectMachineGps();
switch (patternStr){
case "0704":
T0704 t0704 = JSON.parseObject(JSON.toJSONString(msg),T0704.class);
for (T0200 t0200:t0704.getItems()) {
collectMachineGps.setId(UUID.randomUUID().toString());
collectMachineGps.setMachineId(t0704.getClientId());
collectMachineGps.setLatitude(((double)t0200.getLatitude()/1000000));
collectMachineGps.setLongitude(((double)t0200.getLongitude()/1000000));
collectMachineGps.setAltitude((long) t0200.getAltitude());
collectMachineGps.setSpeed((long) t0200.getSpeed());
collectMachineGps.setCreateTime(DateUtils.getNowDate());
iCollectMachineGpsService.insertCollectMachineGps(collectMachineGps);
}
break;
case "0200":
List<T0200> t0200List = JSON.parseArray(JSON.toJSONString(msg),T0200.class);
T0200 t0200 = t0200List.get(0);
collectMachineGps.setId(UUID.randomUUID().toString());
collectMachineGps.setMachineId(t0200.getClientId());
collectMachineGps.setLatitude(((double)t0200.getLatitude()/1000000));
collectMachineGps.setLongitude(((double)t0200.getLongitude()/1000000));
collectMachineGps.setAltitude((long) t0200.getAltitude());
collectMachineGps.setSpeed((long) t0200.getSpeed());
collectMachineGps.setCreateTime(DateUtils.getNowDate());
iCollectMachineGpsService.insertCollectMachineGps(collectMachineGps);
break;
}
}
}

@ -60,4 +60,5 @@ public interface IBaseCarQueueService
*/
public int deleteBaseCarQueueById(String id);
List<BaseCarQueue> carQueuelist(BaseCarQueue baseCarQueue);
}

@ -35,6 +35,9 @@ public interface IBaseCarService
public List<BaseCar> queryList(BaseCar baseCar);
/**
*
*
@ -74,4 +77,6 @@ public interface IBaseCarService
* @return
*/
public String checkCarLicenseUnique(BaseCar baseCar);
List<BaseCar> selectGpsCarList(BaseCar baseCar);
}

@ -4,57 +4,57 @@ import java.util.List;
import com.ruoyi.basetyre.domain.BaseTyre;
/**
* Service
* Service
*
* @author Yangwl
* @date 2023-02-15
* @date 2023-02-27
*/
public interface IBaseTyreService
{
/**
*
*
*
* @param id
* @return
* @param id
* @return
*/
public BaseTyre selectBaseTyreById(String id);
/**
*
*
*
* @param baseTyre
* @return
* @param baseTyre
* @return
*/
public List<BaseTyre> selectBaseTyreList(BaseTyre baseTyre);
/**
*
*
*
* @param baseTyre
* @param baseTyre
* @return
*/
public int insertBaseTyre(BaseTyre baseTyre);
/**
*
*
*
* @param baseTyre
* @param baseTyre
* @return
*/
public int updateBaseTyre(BaseTyre baseTyre);
/**
*
*
*
* @param ids
* @param ids
* @return
*/
public int deleteBaseTyreByIds(String[] ids);
/**
*
*
*
* @param id
* @param id
* @return
*/
public int deleteBaseTyreById(String id);

@ -0,0 +1,61 @@
package com.ruoyi.basetyre.service;
import java.util.List;
import com.ruoyi.basetyre.domain.CollectMachineGps;
/**
* GPSService
*
* @author Yangwl
* @date 2023-02-28
*/
public interface ICollectMachineGpsService
{
/**
* GPS
*
* @param id GPS
* @return GPS
*/
public CollectMachineGps selectCollectMachineGpsById(String id);
/**
* GPS
*
* @param collectMachineGps GPS
* @return GPS
*/
public List<CollectMachineGps> selectCollectMachineGpsList(CollectMachineGps collectMachineGps);
/**
* GPS
*
* @param collectMachineGps GPS
* @return
*/
public int insertCollectMachineGps(CollectMachineGps collectMachineGps);
/**
* GPS
*
* @param collectMachineGps GPS
* @return
*/
public int updateCollectMachineGps(CollectMachineGps collectMachineGps);
/**
* GPS
*
* @param ids GPS
* @return
*/
public int deleteCollectMachineGpsByIds(String[] ids);
/**
* GPS
*
* @param id GPS
* @return
*/
public int deleteCollectMachineGpsById(String id);
}

@ -62,8 +62,7 @@ public class BaseCarQueueServiceImpl implements IBaseCarQueueService
LoginUser loginUser= SecurityUtils.getLoginUser();
baseCarQueue.setCreateBy(loginUser.getUserId().toString());
baseCarQueue.setCreateName(loginUser.getUsername());
baseCarQueue.setModifyBy(loginUser.getUserId().toString());
baseCarQueue.setModifyTime(DateUtils.getNowDate());
return baseCarQueueMapper.insertBaseCarQueue(baseCarQueue);
}
@ -76,6 +75,9 @@ public class BaseCarQueueServiceImpl implements IBaseCarQueueService
@Override
public int updateBaseCarQueue(BaseCarQueue baseCarQueue)
{
LoginUser loginUser= SecurityUtils.getLoginUser();
baseCarQueue.setModifyBy(loginUser.getUserId().toString());
baseCarQueue.setModifyTime(DateUtils.getNowDate());
return baseCarQueueMapper.updateBaseCarQueue(baseCarQueue);
}
@ -102,4 +104,9 @@ public class BaseCarQueueServiceImpl implements IBaseCarQueueService
{
return baseCarQueueMapper.deleteBaseCarQueueById(id);
}
@Override
public List<BaseCarQueue> carQueuelist(BaseCarQueue baseCarQueue) {
return baseCarQueueMapper.carQueuelist(baseCarQueue);
}
}

@ -53,6 +53,7 @@ public class BaseCarServiceImpl implements IBaseCarService
return baseCarMapper.queryList(baseCar);
}
/**
*
*
@ -114,4 +115,9 @@ public class BaseCarServiceImpl implements IBaseCarService
public String checkCarLicenseUnique(BaseCar baseCar) {
return null;
}
@Override
public List<BaseCar> selectGpsCarList(BaseCar baseCar) {
return baseCarMapper.selectGpsCarList(baseCar);
}
}

@ -1,11 +1,7 @@
package com.ruoyi.basetyre.service.impl;
import java.util.List;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basetyre.mapper.BaseTyreMapper;
@ -13,10 +9,10 @@ import com.ruoyi.basetyre.domain.BaseTyre;
import com.ruoyi.basetyre.service.IBaseTyreService;
/**
* Service
* Service
*
* @author Yangwl
* @date 2023-02-15
* @date 2023-02-27
*/
@Service
public class BaseTyreServiceImpl implements IBaseTyreService
@ -25,10 +21,10 @@ public class BaseTyreServiceImpl implements IBaseTyreService
private BaseTyreMapper baseTyreMapper;
/**
*
*
*
* @param id
* @return
* @param id
* @return
*/
@Override
public BaseTyre selectBaseTyreById(String id)
@ -37,10 +33,10 @@ public class BaseTyreServiceImpl implements IBaseTyreService
}
/**
*
*
*
* @param baseTyre
* @return
* @param baseTyre
* @return
*/
@Override
public List<BaseTyre> selectBaseTyreList(BaseTyre baseTyre)
@ -49,25 +45,22 @@ public class BaseTyreServiceImpl implements IBaseTyreService
}
/**
*
*
*
* @param baseTyre
* @param baseTyre
* @return
*/
@Override
public int insertBaseTyre(BaseTyre baseTyre)
{
baseTyre.setCreateTime(DateUtils.getNowDate());
LoginUser loginUser= SecurityUtils.getLoginUser();
baseTyre.setCreateBy(loginUser.getUserId().toString());
baseTyre.setCreateName(loginUser.getUsername());
return baseTyreMapper.insertBaseTyre(baseTyre);
}
/**
*
*
*
* @param baseTyre
* @param baseTyre
* @return
*/
@Override
@ -77,9 +70,9 @@ public class BaseTyreServiceImpl implements IBaseTyreService
}
/**
*
*
*
* @param ids
* @param ids
* @return
*/
@Override
@ -89,9 +82,9 @@ public class BaseTyreServiceImpl implements IBaseTyreService
}
/**
*
*
*
* @param id
* @param id
* @return
*/
@Override

@ -0,0 +1,93 @@
package com.ruoyi.basetyre.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basetyre.mapper.CollectMachineGpsMapper;
import com.ruoyi.basetyre.domain.CollectMachineGps;
import com.ruoyi.basetyre.service.ICollectMachineGpsService;
/**
* GPSService
*
* @author Yangwl
* @date 2023-02-28
*/
@Service
public class CollectMachineGpsServiceImpl implements ICollectMachineGpsService
{
@Autowired
private CollectMachineGpsMapper collectMachineGpsMapper;
/**
* GPS
*
* @param id GPS
* @return GPS
*/
@Override
public CollectMachineGps selectCollectMachineGpsById(String id)
{
return collectMachineGpsMapper.selectCollectMachineGpsById(id);
}
/**
* GPS
*
* @param collectMachineGps GPS
* @return GPS
*/
@Override
public List<CollectMachineGps> selectCollectMachineGpsList(CollectMachineGps collectMachineGps)
{
return collectMachineGpsMapper.selectCollectMachineGpsList(collectMachineGps);
}
/**
* GPS
*
* @param collectMachineGps GPS
* @return
*/
@Override
public int insertCollectMachineGps(CollectMachineGps collectMachineGps)
{
return collectMachineGpsMapper.insertCollectMachineGps(collectMachineGps);
}
/**
* GPS
*
* @param collectMachineGps GPS
* @return
*/
@Override
public int updateCollectMachineGps(CollectMachineGps collectMachineGps)
{
return collectMachineGpsMapper.updateCollectMachineGps(collectMachineGps);
}
/**
* GPS
*
* @param ids GPS
* @return
*/
@Override
public int deleteCollectMachineGpsByIds(String[] ids)
{
return collectMachineGpsMapper.deleteCollectMachineGpsByIds(ids);
}
/**
* GPS
*
* @param id GPS
* @return
*/
@Override
public int deleteCollectMachineGpsById(String id)
{
return collectMachineGpsMapper.deleteCollectMachineGpsById(id);
}
}

@ -32,6 +32,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="modifyTime" column="modify_time" />
<result property="modifyId" column="modify_id" />
<result property="modifyBy" column="modify_by" />
<result property="state" column="state" />
<result property="laseRuntime" column="last_run_time" />
</resultMap>
<sql id="selectBaseCarVo">
@ -87,12 +89,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modifyBy != null and modifyBy != ''"> and modify_by = #{modifyBy}</if>
</where>
</select>
<select id="selectBaseCarById" parameterType="String" resultMap="BaseCarResult">
<include refid="selectBaseCarVo"/>
where id = #{id}
</select>
<select id="selectGpsCarList" resultMap="BaseCarResult" parameterType="BaseCar">
SELECT
bc.*,
bd.state,
bd.last_run_time
FROM
base_car bc
LEFT JOIN base_device bd ON bc.device_id = bd.internet_things_no
<where>
bc.is_delete != '1'
<if test="id != null "> and bc.id = #{id}</if>
<if test="isDelete != null "> and bc.is_delete = #{isDelete}</if>
<if test="queueId != null "> and bc.car_queue_id = #{queueId}</if>
</where>
</select>
<insert id="insertBaseCar" parameterType="BaseCar">
insert into base_car
<trim prefix="(" suffix=")" suffixOverrides=",">

@ -21,6 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="modifyId" column="modify_id" />
<result property="modifyBy" column="modify_by" />
<result property="modifyName" column="modify__name" />
<collection property="baseCarList" javaType="java.util.List" resultMap="baseCarResult" />
</resultMap>
<resultMap type="BaseCar" id="baseCarResult">
<result property="id" column="car_id" />
<result property="carLicense" column="car_license" />
<result property="isDelete" column="is_delete" />
</resultMap>
<sql id="selectBaseCarQueueVo">
@ -50,7 +56,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectBaseCarQueueVo"/>
where id = #{id}
</select>
<select id="carQueuelist" parameterType="BaseCarQueue" resultMap="BaseCarQueueResult">
SELECT
bcq.id,
bcq.title,
bcq.state,
bcq.create_time,
bcq.create_by,
bcq.create_name,
bc.id as car_id,
bc.car_license,
bc.is_delete
FROM
base_car_queue bcq
LEFT JOIN base_car bc on bcq.id = bc.car_queue_id
</select>
<insert id="insertBaseCarQueue" parameterType="BaseCarQueue">
insert into base_car_queue
<trim prefix="(" suffix=")" suffixOverrides=",">

@ -6,15 +6,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="BaseTyre" id="BaseTyreResult">
<result property="id" column="id" />
<result property="tyreFacCode" column="tyre_fac_code" />
<result property="companyCode" column="company_code" />
<result property="tyreFactory" column="tyre_factory" />
<result property="outerTireNumber" column="outer_tire_number" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="qualityStatus" column="quality_status" />
<result property="unit" column="unit" />
<result property="materialType" column="material_type" />
<result property="materialGroup" column="material_group" />
<result property="productGroup" column="product_group" />
<result property="brand" column="brand" />
<result property="category" column="category" />
<result property="size" column="size" />
<result property="pattern" column="pattern" />
<result property="consPattern" column="cons_pattern" />
<result property="hierarchy" column="hierarchy" />
<result property="speedLevel" column="speed_level" />
<result property="loadIndex" column="load_index" />
<result property="rimSize" column="rim_size" />
<result property="weight" column="weight" />
<result property="sectionWidth" column="section_width" />
<result property="outerDiameter" column="outer_diameter" />
<result property="flattening" column="flattening" />
<result property="enhanced" column="enhanced" />
<result property="innerTube" column="inner_tube" />
<result property="patternDepth" column="pattern_depth" />
<result property="ctn" column="ctn" />
<result property="type" column="type" />
<result property="certInfo" column="cert_info" />
<result property="customsSpe" column="customs_spe" />
<result property="feCode" column="fe_code" />
<result property="feDesc" column="fe_desc" />
<result property="produceFactory" column="produce_factory" />
<result property="carId" column="car_id" />
<result property="carLicense" column="car_license" />
<result property="tureCode" column="ture_code" />
<result property="tureModel" column="ture_model" />
<result property="tureModelId" column="ture_model_id" />
<result property="tureBrandId" column="ture_brand_id" />
<result property="tyrePattern" column="tyre_pattern" />
<result property="tyrePosition" column="tyre_position" />
<result property="sensorId" column="sensor_id" />
<result property="currentTextureDepth" column="current_texture_depth" />
@ -28,24 +53,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="modifyId" column="modify_id" />
<result property="modifyBy" column="modify_by" />
<result property="modifyName" column="modify__name" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectBaseTyreVo">
select id, tyre_fac_code, company_code, car_id, car_license, ture_code, ture_model, ture_model_id, ture_brand_id, tyre_pattern, tyre_position, sensor_id, current_texture_depth, state, is_delete, create_time, create_id, create_by, create_name, modify_time, modify_id, modify_by, modify__name from base_tyre
select id, tyre_factory, outer_tire_number, material_code, material_name, quality_status, unit, material_type, material_group, product_group, brand, category, size, pattern, cons_pattern, hierarchy, speed_level, load_index, rim_size, weight, section_width, outer_diameter, flattening, enhanced, inner_tube, pattern_depth, ctn, type, cert_info, customs_spe, fe_code, fe_desc, produce_factory, car_id, car_license, tyre_position, sensor_id, current_texture_depth, state, is_delete, create_time, create_id, create_by, create_name, modify_time, modify_id, modify_by, modify__name, remark from base_tyre
</sql>
<select id="selectBaseTyreList" parameterType="BaseTyre" resultMap="BaseTyreResult">
<include refid="selectBaseTyreVo"/>
<where>
<if test="tyreFacCode != null and tyreFacCode != ''"> and tyre_fac_code = #{tyreFacCode}</if>
<if test="companyCode != null and companyCode != ''"> and company_code = #{companyCode}</if>
<if test="tyreFactory != null and tyreFactory != ''"> and tyre_factory = #{tyreFactory}</if>
<if test="outerTireNumber != null and outerTireNumber != ''"> and outer_tire_number = #{outerTireNumber}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="qualityStatus != null and qualityStatus != ''"> and quality_status = #{qualityStatus}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="materialType != null and materialType != ''"> and material_type = #{materialType}</if>
<if test="materialGroup != null and materialGroup != ''"> and material_group = #{materialGroup}</if>
<if test="productGroup != null and productGroup != ''"> and product_group = #{productGroup}</if>
<if test="brand != null and brand != ''"> and brand = #{brand}</if>
<if test="category != null and category != ''"> and category = #{category}</if>
<if test="size != null and size != ''"> and size = #{size}</if>
<if test="pattern != null and pattern != ''"> and pattern = #{pattern}</if>
<if test="consPattern != null and consPattern != ''"> and cons_pattern = #{consPattern}</if>
<if test="hierarchy != null and hierarchy != ''"> and hierarchy = #{hierarchy}</if>
<if test="speedLevel != null and speedLevel != ''"> and speed_level = #{speedLevel}</if>
<if test="loadIndex != null "> and load_index = #{loadIndex}</if>
<if test="rimSize != null "> and rim_size = #{rimSize}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="sectionWidth != null "> and section_width = #{sectionWidth}</if>
<if test="outerDiameter != null "> and outer_diameter = #{outerDiameter}</if>
<if test="flattening != null "> and flattening = #{flattening}</if>
<if test="enhanced != null and enhanced != ''"> and enhanced = #{enhanced}</if>
<if test="innerTube != null and innerTube != ''"> and inner_tube = #{innerTube}</if>
<if test="patternDepth != null "> and pattern_depth = #{patternDepth}</if>
<if test="ctn != null "> and ctn = #{ctn}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="certInfo != null and certInfo != ''"> and cert_info = #{certInfo}</if>
<if test="customsSpe != null and customsSpe != ''"> and customs_spe = #{customsSpe}</if>
<if test="feCode != null and feCode != ''"> and fe_code = #{feCode}</if>
<if test="feDesc != null and feDesc != ''"> and fe_desc = #{feDesc}</if>
<if test="produceFactory != null and produceFactory != ''"> and produce_factory = #{produceFactory}</if>
<if test="carId != null and carId != ''"> and car_id = #{carId}</if>
<if test="carLicense != null and carLicense != ''"> and car_license = #{carLicense}</if>
<if test="tureCode != null and tureCode != ''"> and ture_code = #{tureCode}</if>
<if test="tureModel != null and tureModel != ''"> and ture_model = #{tureModel}</if>
<if test="tureModelId != null and tureModelId != ''"> and ture_model_id = #{tureModelId}</if>
<if test="tureBrandId != null and tureBrandId != ''"> and ture_brand_id = #{tureBrandId}</if>
<if test="tyrePattern != null and tyrePattern != ''"> and tyre_pattern = #{tyrePattern}</if>
<if test="tyrePosition != null and tyrePosition != ''"> and tyre_position = #{tyrePosition}</if>
<if test="sensorId != null and sensorId != ''"> and sensor_id = #{sensorId}</if>
<if test="currentTextureDepth != null "> and current_texture_depth = #{currentTextureDepth}</if>
@ -69,15 +120,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into base_tyre
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="tyreFacCode != null">tyre_fac_code,</if>
<if test="companyCode != null">company_code,</if>
<if test="tyreFactory != null">tyre_factory,</if>
<if test="outerTireNumber != null">outer_tire_number,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="qualityStatus != null">quality_status,</if>
<if test="unit != null">unit,</if>
<if test="materialType != null">material_type,</if>
<if test="materialGroup != null">material_group,</if>
<if test="productGroup != null">product_group,</if>
<if test="brand != null">brand,</if>
<if test="category != null">category,</if>
<if test="size != null">size,</if>
<if test="pattern != null">pattern,</if>
<if test="consPattern != null">cons_pattern,</if>
<if test="hierarchy != null">hierarchy,</if>
<if test="speedLevel != null">speed_level,</if>
<if test="loadIndex != null">load_index,</if>
<if test="rimSize != null">rim_size,</if>
<if test="weight != null">weight,</if>
<if test="sectionWidth != null">section_width,</if>
<if test="outerDiameter != null">outer_diameter,</if>
<if test="flattening != null">flattening,</if>
<if test="enhanced != null">enhanced,</if>
<if test="innerTube != null">inner_tube,</if>
<if test="patternDepth != null">pattern_depth,</if>
<if test="ctn != null">ctn,</if>
<if test="type != null">type,</if>
<if test="certInfo != null">cert_info,</if>
<if test="customsSpe != null">customs_spe,</if>
<if test="feCode != null">fe_code,</if>
<if test="feDesc != null">fe_desc,</if>
<if test="produceFactory != null">produce_factory,</if>
<if test="carId != null">car_id,</if>
<if test="carLicense != null">car_license,</if>
<if test="tureCode != null">ture_code,</if>
<if test="tureModel != null">ture_model,</if>
<if test="tureModelId != null">ture_model_id,</if>
<if test="tureBrandId != null">ture_brand_id,</if>
<if test="tyrePattern != null">tyre_pattern,</if>
<if test="tyrePosition != null">tyre_position,</if>
<if test="sensorId != null">sensor_id,</if>
<if test="currentTextureDepth != null">current_texture_depth,</if>
@ -91,18 +167,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modifyId != null">modify_id,</if>
<if test="modifyBy != null">modify_by,</if>
<if test="modifyName != null">modify__name,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="tyreFacCode != null">#{tyreFacCode},</if>
<if test="companyCode != null">#{companyCode},</if>
<if test="tyreFactory != null">#{tyreFactory},</if>
<if test="outerTireNumber != null">#{outerTireNumber},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="qualityStatus != null">#{qualityStatus},</if>
<if test="unit != null">#{unit},</if>
<if test="materialType != null">#{materialType},</if>
<if test="materialGroup != null">#{materialGroup},</if>
<if test="productGroup != null">#{productGroup},</if>
<if test="brand != null">#{brand},</if>
<if test="category != null">#{category},</if>
<if test="size != null">#{size},</if>
<if test="pattern != null">#{pattern},</if>
<if test="consPattern != null">#{consPattern},</if>
<if test="hierarchy != null">#{hierarchy},</if>
<if test="speedLevel != null">#{speedLevel},</if>
<if test="loadIndex != null">#{loadIndex},</if>
<if test="rimSize != null">#{rimSize},</if>
<if test="weight != null">#{weight},</if>
<if test="sectionWidth != null">#{sectionWidth},</if>
<if test="outerDiameter != null">#{outerDiameter},</if>
<if test="flattening != null">#{flattening},</if>
<if test="enhanced != null">#{enhanced},</if>
<if test="innerTube != null">#{innerTube},</if>
<if test="patternDepth != null">#{patternDepth},</if>
<if test="ctn != null">#{ctn},</if>
<if test="type != null">#{type},</if>
<if test="certInfo != null">#{certInfo},</if>
<if test="customsSpe != null">#{customsSpe},</if>
<if test="feCode != null">#{feCode},</if>
<if test="feDesc != null">#{feDesc},</if>
<if test="produceFactory != null">#{produceFactory},</if>
<if test="carId != null">#{carId},</if>
<if test="carLicense != null">#{carLicense},</if>
<if test="tureCode != null">#{tureCode},</if>
<if test="tureModel != null">#{tureModel},</if>
<if test="tureModelId != null">#{tureModelId},</if>
<if test="tureBrandId != null">#{tureBrandId},</if>
<if test="tyrePattern != null">#{tyrePattern},</if>
<if test="tyrePosition != null">#{tyrePosition},</if>
<if test="sensorId != null">#{sensorId},</if>
<if test="currentTextureDepth != null">#{currentTextureDepth},</if>
@ -116,21 +218,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modifyId != null">#{modifyId},</if>
<if test="modifyBy != null">#{modifyBy},</if>
<if test="modifyName != null">#{modifyName},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateBaseTyre" parameterType="BaseTyre">
update base_tyre
<trim prefix="SET" suffixOverrides=",">
<if test="tyreFacCode != null">tyre_fac_code = #{tyreFacCode},</if>
<if test="companyCode != null">company_code = #{companyCode},</if>
<if test="tyreFactory != null">tyre_factory = #{tyreFactory},</if>
<if test="outerTireNumber != null">outer_tire_number = #{outerTireNumber},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="qualityStatus != null">quality_status = #{qualityStatus},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="materialType != null">material_type = #{materialType},</if>
<if test="materialGroup != null">material_group = #{materialGroup},</if>
<if test="productGroup != null">product_group = #{productGroup},</if>
<if test="brand != null">brand = #{brand},</if>
<if test="category != null">category = #{category},</if>
<if test="size != null">size = #{size},</if>
<if test="pattern != null">pattern = #{pattern},</if>
<if test="consPattern != null">cons_pattern = #{consPattern},</if>
<if test="hierarchy != null">hierarchy = #{hierarchy},</if>
<if test="speedLevel != null">speed_level = #{speedLevel},</if>
<if test="loadIndex != null">load_index = #{loadIndex},</if>
<if test="rimSize != null">rim_size = #{rimSize},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="sectionWidth != null">section_width = #{sectionWidth},</if>
<if test="outerDiameter != null">outer_diameter = #{outerDiameter},</if>
<if test="flattening != null">flattening = #{flattening},</if>
<if test="enhanced != null">enhanced = #{enhanced},</if>
<if test="innerTube != null">inner_tube = #{innerTube},</if>
<if test="patternDepth != null">pattern_depth = #{patternDepth},</if>
<if test="ctn != null">ctn = #{ctn},</if>
<if test="type != null">type = #{type},</if>
<if test="certInfo != null">cert_info = #{certInfo},</if>
<if test="customsSpe != null">customs_spe = #{customsSpe},</if>
<if test="feCode != null">fe_code = #{feCode},</if>
<if test="feDesc != null">fe_desc = #{feDesc},</if>
<if test="produceFactory != null">produce_factory = #{produceFactory},</if>
<if test="carId != null">car_id = #{carId},</if>
<if test="carLicense != null">car_license = #{carLicense},</if>
<if test="tureCode != null">ture_code = #{tureCode},</if>
<if test="tureModel != null">ture_model = #{tureModel},</if>
<if test="tureModelId != null">ture_model_id = #{tureModelId},</if>
<if test="tureBrandId != null">ture_brand_id = #{tureBrandId},</if>
<if test="tyrePattern!= null">tyre_pattern = #{tyrePattern},</if>
<if test="tyrePosition != null">tyre_position = #{tyrePosition},</if>
<if test="sensorId != null">sensor_id = #{sensorId},</if>
<if test="currentTextureDepth != null">current_texture_depth = #{currentTextureDepth},</if>
@ -144,6 +272,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modifyId != null">modify_id = #{modifyId},</if>
<if test="modifyBy != null">modify_by = #{modifyBy},</if>
<if test="modifyName != null">modify__name = #{modifyName},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>

@ -0,0 +1,198 @@
<?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.ruoyi.basetyre.mapper.CollectMachineGpsMapper">
<resultMap type="CollectMachineGps" id="CollectMachineGpsResult">
<result property="id" column="id" />
<result property="machineId" column="machine_id" />
<result property="carId" column="car_id" />
<result property="carLicense" column="car_license" />
<result property="emergencyAlarm" column="emergency_alarm" />
<result property="speedAlarm" column="speed_alarm" />
<result property="fatigueDrivingAlarm" column="fatigue_driving_alarm" />
<result property="riskEarlyAlarm" column="risk_early_alarm" />
<result property="gnssModule" column="gnss_module" />
<result property="gnssLossAntenna" column="gnss_loss_antenna" />
<result property="gnssAntennaShortcircuit" column="gnss_antenna_shortcircuit" />
<result property="mainPowerLake" column="main_power_lake" />
<result property="mainpowerloss" column="mainpowerloss" />
<result property="accclose" column="accclose" />
<result property="unpositioned" column="unpositioned" />
<result property="dimensionalNOrS" column="dimensional_n_or_s" />
<result property="longitudinalEOrW" column="longitudinal_e_or_w" />
<result property="dLIsencryption" column="d_l_isencryption" />
<result property="latitude" column="latitude" />
<result property="longitude" column="longitude" />
<result property="altitude" column="altitude" />
<result property="speed" column="speed" />
<result property="course" column="course" />
<result property="createTime" column="create_time" />
<result property="gpsIntensity" column="gps_intensity" />
<result property="gpsSatellites" column="gps_satellites" />
<result property="gpsMileage" column="gps_mileage" />
<result property="isOutPower" column="is_out_power" />
<result property="carPower" column="car_power" />
<result property="isSensorRun" column="is_sensor_run" />
</resultMap>
<sql id="selectCollectMachineGpsVo">
select id, machine_id, car_id, car_license, emergency_alarm, speed_alarm, fatigue_driving_alarm, risk_early_alarm, gnss_module, gnss_loss_antenna, gnss_antenna_shortcircuit, main_power_lake, mainpowerloss, accclose, unpositioned, dimensional_n_or_s, longitudinal_e_or_w, d_l_isencryption, latitude, longitude, altitude, speed, course, create_time, gps_intensity, gps_satellites, gps_mileage, is_out_power, car_power, is_sensor_run from collect_machine_gps
</sql>
<select id="selectCollectMachineGpsList" parameterType="CollectMachineGps" resultMap="CollectMachineGpsResult">
<include refid="selectCollectMachineGpsVo"/>
<where>
<if test="machineId != null and machineId != ''"> and machine_id = #{machineId}</if>
<if test="carId != null and carId != ''"> and car_id = #{carId}</if>
<if test="carLicense != null and carLicense != ''"> and car_license = #{carLicense}</if>
<if test="emergencyAlarm != null "> and emergency_alarm = #{emergencyAlarm}</if>
<if test="speedAlarm != null "> and speed_alarm = #{speedAlarm}</if>
<if test="fatigueDrivingAlarm != null "> and fatigue_driving_alarm = #{fatigueDrivingAlarm}</if>
<if test="riskEarlyAlarm != null "> and risk_early_alarm = #{riskEarlyAlarm}</if>
<if test="gnssModule != null "> and gnss_module = #{gnssModule}</if>
<if test="gnssLossAntenna != null "> and gnss_loss_antenna = #{gnssLossAntenna}</if>
<if test="gnssAntennaShortcircuit != null "> and gnss_antenna_shortcircuit = #{gnssAntennaShortcircuit}</if>
<if test="mainPowerLake != null "> and main_power_lake = #{mainPowerLake}</if>
<if test="mainpowerloss != null "> and mainpowerloss = #{mainpowerloss}</if>
<if test="accclose != null "> and accclose = #{accclose}</if>
<if test="unpositioned != null "> and unpositioned = #{unpositioned}</if>
<if test="dimensionalNOrS != null "> and dimensional_n_or_s = #{dimensionalNOrS}</if>
<if test="longitudinalEOrW != null "> and longitudinal_e_or_w = #{longitudinalEOrW}</if>
<if test="dLIsencryption != null "> and d_l_isencryption = #{dLIsencryption}</if>
<if test="latitude != null "> and latitude = #{latitude}</if>
<if test="longitude != null "> and longitude = #{longitude}</if>
<if test="altitude != null "> and altitude = #{altitude}</if>
<if test="speed != null "> and speed = #{speed}</if>
<if test="course != null "> and course = #{course}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="gpsIntensity != null "> and gps_intensity = #{gpsIntensity}</if>
<if test="gpsSatellites != null "> and gps_satellites = #{gpsSatellites}</if>
<if test="gpsMileage != null "> and gps_mileage = #{gpsMileage}</if>
<if test="isOutPower != null "> and is_out_power = #{isOutPower}</if>
<if test="carPower != null "> and car_power = #{carPower}</if>
<if test="isSensorRun != null "> and is_sensor_run = #{isSensorRun}</if>
</where>
</select>
<select id="selectCollectMachineGpsById" parameterType="String" resultMap="CollectMachineGpsResult">
<include refid="selectCollectMachineGpsVo"/>
where id = #{id}
</select>
<insert id="insertCollectMachineGps" parameterType="CollectMachineGps">
insert into collect_machine_gps
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="machineId != null">machine_id,</if>
<if test="carId != null">car_id,</if>
<if test="carLicense != null">car_license,</if>
<if test="emergencyAlarm != null">emergency_alarm,</if>
<if test="speedAlarm != null">speed_alarm,</if>
<if test="fatigueDrivingAlarm != null">fatigue_driving_alarm,</if>
<if test="riskEarlyAlarm != null">risk_early_alarm,</if>
<if test="gnssModule != null">gnss_module,</if>
<if test="gnssLossAntenna != null">gnss_loss_antenna,</if>
<if test="gnssAntennaShortcircuit != null">gnss_antenna_shortcircuit,</if>
<if test="mainPowerLake != null">main_power_lake,</if>
<if test="mainpowerloss != null">mainpowerloss,</if>
<if test="accclose != null">accclose,</if>
<if test="unpositioned != null">unpositioned,</if>
<if test="dimensionalNOrS != null">dimensional_n_or_s,</if>
<if test="longitudinalEOrW != null">longitudinal_e_or_w,</if>
<if test="dLIsencryption != null">d_l_isencryption,</if>
<if test="latitude != null">latitude,</if>
<if test="longitude != null">longitude,</if>
<if test="altitude != null">altitude,</if>
<if test="speed != null">speed,</if>
<if test="course != null">course,</if>
<if test="createTime != null">create_time,</if>
<if test="gpsIntensity != null">gps_intensity,</if>
<if test="gpsSatellites != null">gps_satellites,</if>
<if test="gpsMileage != null">gps_mileage,</if>
<if test="isOutPower != null">is_out_power,</if>
<if test="carPower != null">car_power,</if>
<if test="isSensorRun != null">is_sensor_run,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="machineId != null">#{machineId},</if>
<if test="carId != null">#{carId},</if>
<if test="carLicense != null">#{carLicense},</if>
<if test="emergencyAlarm != null">#{emergencyAlarm},</if>
<if test="speedAlarm != null">#{speedAlarm},</if>
<if test="fatigueDrivingAlarm != null">#{fatigueDrivingAlarm},</if>
<if test="riskEarlyAlarm != null">#{riskEarlyAlarm},</if>
<if test="gnssModule != null">#{gnssModule},</if>
<if test="gnssLossAntenna != null">#{gnssLossAntenna},</if>
<if test="gnssAntennaShortcircuit != null">#{gnssAntennaShortcircuit},</if>
<if test="mainPowerLake != null">#{mainPowerLake},</if>
<if test="mainpowerloss != null">#{mainpowerloss},</if>
<if test="accclose != null">#{accclose},</if>
<if test="unpositioned != null">#{unpositioned},</if>
<if test="dimensionalNOrS != null">#{dimensionalNOrS},</if>
<if test="longitudinalEOrW != null">#{longitudinalEOrW},</if>
<if test="dLIsencryption != null">#{dLIsencryption},</if>
<if test="latitude != null">#{latitude},</if>
<if test="longitude != null">#{longitude},</if>
<if test="altitude != null">#{altitude},</if>
<if test="speed != null">#{speed},</if>
<if test="course != null">#{course},</if>
<if test="createTime != null">#{createTime},</if>
<if test="gpsIntensity != null">#{gpsIntensity},</if>
<if test="gpsSatellites != null">#{gpsSatellites},</if>
<if test="gpsMileage != null">#{gpsMileage},</if>
<if test="isOutPower != null">#{isOutPower},</if>
<if test="carPower != null">#{carPower},</if>
<if test="isSensorRun != null">#{isSensorRun},</if>
</trim>
</insert>
<update id="updateCollectMachineGps" parameterType="CollectMachineGps">
update collect_machine_gps
<trim prefix="SET" suffixOverrides=",">
<if test="machineId != null">machine_id = #{machineId},</if>
<if test="carId != null">car_id = #{carId},</if>
<if test="carLicense != null">car_license = #{carLicense},</if>
<if test="emergencyAlarm != null">emergency_alarm = #{emergencyAlarm},</if>
<if test="speedAlarm != null">speed_alarm = #{speedAlarm},</if>
<if test="fatigueDrivingAlarm != null">fatigue_driving_alarm = #{fatigueDrivingAlarm},</if>
<if test="riskEarlyAlarm != null">risk_early_alarm = #{riskEarlyAlarm},</if>
<if test="gnssModule != null">gnss_module = #{gnssModule},</if>
<if test="gnssLossAntenna != null">gnss_loss_antenna = #{gnssLossAntenna},</if>
<if test="gnssAntennaShortcircuit != null">gnss_antenna_shortcircuit = #{gnssAntennaShortcircuit},</if>
<if test="mainPowerLake != null">main_power_lake = #{mainPowerLake},</if>
<if test="mainpowerloss != null">mainpowerloss = #{mainpowerloss},</if>
<if test="accclose != null">accclose = #{accclose},</if>
<if test="unpositioned != null">unpositioned = #{unpositioned},</if>
<if test="dimensionalNOrS != null">dimensional_n_or_s = #{dimensionalNOrS},</if>
<if test="longitudinalEOrW != null">longitudinal_e_or_w = #{longitudinalEOrW},</if>
<if test="dLIsencryption != null">d_l_isencryption = #{dLIsencryption},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="altitude != null">altitude = #{altitude},</if>
<if test="speed != null">speed = #{speed},</if>
<if test="course != null">course = #{course},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="gpsIntensity != null">gps_intensity = #{gpsIntensity},</if>
<if test="gpsSatellites != null">gps_satellites = #{gpsSatellites},</if>
<if test="gpsMileage != null">gps_mileage = #{gpsMileage},</if>
<if test="isOutPower != null">is_out_power = #{isOutPower},</if>
<if test="carPower != null">car_power = #{carPower},</if>
<if test="isSensorRun != null">is_sensor_run = #{isSensorRun},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCollectMachineGpsById" parameterType="String">
delete from collect_machine_gps where id = #{id}
</delete>
<delete id="deleteCollectMachineGpsByIds" parameterType="String">
delete from collect_machine_gps where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -132,6 +132,22 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.yezhihao</groupId>
<artifactId>protostar</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>io.github.yezhihao</groupId>
<artifactId>netmc</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,51 @@
package com.ruoyi.common.t808;
import com.ruoyi.common.t808.attribute.AlarmADAS;
import com.ruoyi.common.t808.attribute.AlarmBSD;
import com.ruoyi.common.t808.attribute.AlarmDSM;
import com.ruoyi.common.t808.attribute.AlarmTPMS;
import io.github.yezhihao.protostar.PrepareLoadStrategy;
import io.github.yezhihao.protostar.ProtostarUtil;
import io.github.yezhihao.protostar.schema.MapSchema;
import io.github.yezhihao.protostar.schema.NumberSchema;
/**
* ()
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public class AttributeConverter extends MapSchema<Number, Object> {
public AttributeConverter() {
super(NumberSchema.BYTE_INT, 1);
}
@Override
protected void addSchemas(PrepareLoadStrategy<Number> schemaRegistry) {
schemaRegistry
.addSchema(AttributeKey.Mileage, NumberSchema.DWORD_LONG)
.addSchema(AttributeKey.Fuel, NumberSchema.WORD_INT)
.addSchema(AttributeKey.Speed, NumberSchema.WORD_INT)
.addSchema(AttributeKey.AlarmEventId, NumberSchema.WORD_INT)
.addSchema(AttributeKey.TirePressure, TirePressure.SCHEMA)
.addSchema(AttributeKey.CarriageTemperature, NumberSchema.WORD_SHORT)
.addSchema(AttributeKey.OverSpeedAlarm, OverSpeedAlarm.SCHEMA)
.addSchema(AttributeKey.InOutAreaAlarm, InOutAreaAlarm.SCHEMA)
.addSchema(AttributeKey.RouteDriveTimeAlarm, RouteDriveTimeAlarm.SCHEMA)
.addSchema(AttributeKey.Signal, NumberSchema.DWORD_INT)
.addSchema(AttributeKey.IoState, NumberSchema.WORD_INT)
.addSchema(AttributeKey.AnalogQuantity, NumberSchema.DWORD_INT)
.addSchema(AttributeKey.SignalStrength, NumberSchema.BYTE_INT)
.addSchema(AttributeKey.GnssCount, NumberSchema.BYTE_INT)
.addSchema(AttributeKey.AlarmADAS, ProtostarUtil.getRuntimeSchema(AlarmADAS.class, 0))
.addSchema(AttributeKey.AlarmBSD, ProtostarUtil.getRuntimeSchema(AlarmBSD.class, 0))
.addSchema(AttributeKey.AlarmDSM, ProtostarUtil.getRuntimeSchema(AlarmDSM.class, 0))
.addSchema(AttributeKey.AlarmTPMS, ProtostarUtil.getRuntimeSchema(AlarmTPMS.class, 0))
;
}
}

@ -0,0 +1,51 @@
package com.ruoyi.common.t808;
import com.ruoyi.common.t808.attribute.AlarmADAS;
import com.ruoyi.common.t808.attribute.AlarmBSD;
import com.ruoyi.common.t808.attribute.AlarmDSM;
import com.ruoyi.common.t808.attribute.AlarmTPMS;
import io.github.yezhihao.protostar.PrepareLoadStrategy;
import io.github.yezhihao.protostar.ProtostarUtil;
import io.github.yezhihao.protostar.schema.MapSchema;
import io.github.yezhihao.protostar.schema.NumberSchema;
/**
* ()
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public class AttributeConverterYue extends MapSchema<Number, Object> {
public AttributeConverterYue() {
super(NumberSchema.BYTE_INT, 1);
}
@Override
protected void addSchemas(PrepareLoadStrategy<Number> schemaRegistry) {
schemaRegistry
.addSchema(AttributeKey.Mileage, NumberSchema.DWORD_LONG)
.addSchema(AttributeKey.Fuel, NumberSchema.WORD_INT)
.addSchema(AttributeKey.Speed, NumberSchema.WORD_INT)
.addSchema(AttributeKey.AlarmEventId, NumberSchema.WORD_INT)
.addSchema(AttributeKey.TirePressure, TirePressure.SCHEMA)
.addSchema(AttributeKey.CarriageTemperature, NumberSchema.WORD_SHORT)
.addSchema(AttributeKey.OverSpeedAlarm, OverSpeedAlarm.SCHEMA)
.addSchema(AttributeKey.InOutAreaAlarm, InOutAreaAlarm.SCHEMA)
.addSchema(AttributeKey.RouteDriveTimeAlarm, RouteDriveTimeAlarm.SCHEMA)
.addSchema(AttributeKey.Signal, NumberSchema.DWORD_INT)
.addSchema(AttributeKey.IoState, NumberSchema.WORD_INT)
.addSchema(AttributeKey.AnalogQuantity, NumberSchema.DWORD_INT)
.addSchema(AttributeKey.SignalStrength, NumberSchema.BYTE_INT)
.addSchema(AttributeKey.GnssCount, NumberSchema.BYTE_INT)
.addSchema(AttributeKey.AlarmADAS, ProtostarUtil.getRuntimeSchema(AlarmADAS.class, 1))
.addSchema(AttributeKey.AlarmBSD, ProtostarUtil.getRuntimeSchema(AlarmBSD.class, 1))
.addSchema(AttributeKey.AlarmDSM, ProtostarUtil.getRuntimeSchema(AlarmDSM.class, 1))
.addSchema(AttributeKey.AlarmTPMS, ProtostarUtil.getRuntimeSchema(AlarmTPMS.class, 1))
;
}
}

@ -0,0 +1,29 @@
package com.ruoyi.common.t808;
/**
*
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public interface AttributeKey {
int Mileage = 1; // 0x01 里程,数据类型为DWORD,单位为1/10km,对应车上里程表读数
int Fuel = 2; // 0x02 油量,数据类型为WORD,单位为1/10L,对应车上油量表读数
int Speed = 3; // 0x03 行驶记录功能获取的速度,数据类型为WORD,单位为1/10km/h
int AlarmEventId = 4; // 0x04 需要人工确认报警事件的ID,数据类型为WORD,从1开始计数
int TirePressure = 5; // 0x05 胎压,单位为Pa,标定轮子的顺序为从车头开始从左到右顺序排列,多余的字节为0xFF,表示无效数据
int CarriageTemperature = 6; // 0x06 车厢温度,单位为摄氏度,取值范围为-32767~+32767,最高位为1表示负数
int OverSpeedAlarm = 17; // 0x11 超速报警附加信息见表28
int InOutAreaAlarm = 18; // 0x12 进出区域/路线报警附加信息见表29
int RouteDriveTimeAlarm = 19; // 0x13 路段行驶时间不足/过长报警附加信息见表30
int Signal = 37; // 0x25 扩展车辆信号状态位,参数项格式和定义见表31
int IoState = 42; // 0x2a I0状态位,参数项格式和定义见表32
int AnalogQuantity = 43; // 0x2b 模拟量,bit[0~15],AD0;bit[l6~31],ADl
int SignalStrength = 48; // 0x30 数据类型为BYTE,无线通信网络信号强度
int GnssCount = 49; // 0x31 数据类型为BYTE,GNSS定位卫星数
int AlarmADAS = 100; // 0x64 高级驾驶辅助系统报警
int AlarmDSM = 101; // 0x65 驾驶员状态监测
int AlarmTPMS = 102; // 0x66 轮胎气压监测系统
int AlarmBSD = 103; // 0x67 盲点监测
int InstallErrorMsg = 241; // 0xF1 安装异常信息,由厂家自定义(粤标)
int AlgorithmErrorMsg = 242; // 0xF2 算法异常信息,由厂家自定义(粤标)
}

@ -0,0 +1,93 @@
package com.ruoyi.common.t808;
import com.ruoyi.common.t808.attribute.Alarm;
import io.github.yezhihao.protostar.Schema;
import io.netty.buffer.ByteBuf;
/**
* /线 0x12
* length 6
*/
public class InOutAreaAlarm extends Alarm {
public static final int key = 18;
public static final Schema<InOutAreaAlarm> SCHEMA = new InOutAreaAlarmSchema();
/** 位置类型1.圆形区域 2.矩形区域 3.多边形区域 4.路线 */
private byte areaType;
/** 区域或路段ID */
private int areaId;
/** 方向0.进 1.出 */
private byte direction;
public InOutAreaAlarm() {
}
public InOutAreaAlarm(byte areaType, int areaId, byte direction) {
this.areaType = areaType;
this.areaId = areaId;
this.direction = direction;
}
public byte getAreaType() {
return areaType;
}
public void setAreaType(byte areaType) {
this.areaType = areaType;
}
public int getAreaId() {
return areaId;
}
public void setAreaId(int areaId) {
this.areaId = areaId;
}
public byte getDirection() {
return direction;
}
public void setDirection(byte direction) {
this.direction = direction;
}
@Override
public int getAlarmType() {
return key;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(80);
sb.append("InOutAreaAlarm{areaType=").append(areaType);
sb.append(",areaId=").append(areaId);
sb.append(",direction=").append(direction);
sb.append('}');
return sb.toString();
}
private static class InOutAreaAlarmSchema implements Schema<InOutAreaAlarm> {
private InOutAreaAlarmSchema() {
}
@Override
public InOutAreaAlarm readFrom(ByteBuf input) {
InOutAreaAlarm message = new InOutAreaAlarm();
message.areaType = input.readByte();
message.areaId = input.readInt();
message.direction = input.readByte();
return message;
}
@Override
public void writeTo(ByteBuf output, InOutAreaAlarm message) {
output.writeByte(message.areaType);
output.writeInt(message.areaId);
output.writeByte(message.direction);
}
}
}

@ -0,0 +1,18 @@
package com.ruoyi.common.t808;
/**
*
* ()
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public interface JSATL12 {
int = 0x9208;
int = 0x9212;
int = 0x1210;
int = 0x1211;
int = 0x1212;
int = 0x30316364;
}

@ -0,0 +1,32 @@
package com.ruoyi.common.t808;
/**
*
*
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public interface JT1078 {
int = 0x1003;
int = 0x1005;
int = 0x1205;
int = 0x1206;
int = 0x9003;
int = 0x9101;
int = 0x9102;
int = 0x9105;
int = 0x9201;
int = 0x9202;
int = 0x9205;
int = 0x9206;
int = 0x9207;
int = 0x9301;
int = 0x9302;
int = 0x9303;
int = 0x9304;
int = 0x9305;
int = 0x9306;
int = 0x30316364;
String _ = "WAKEUP";
}

@ -0,0 +1,92 @@
package com.ruoyi.common.t808;
/**
*
*
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public interface JT808 {
int = 0x0001;
int = 0x0002;
int = 0x0003;
int = 0x0004;//2019 new
int = 0x0005;//2019 new
int = 0x0100;
int = 0x0102;//2019 modify
int = 0x0104;
int = 0x0107;
int = 0x0108;
int = 0x0200;
int = 0x0201;
int = 0x0301;//2019 del
int = 0x0302;//2019 del
int _ = 0x0303;//2019 del
int = 0x0500;
int 线 = 0x0608;//2019 new
int = 0x0700;
int = 0x0701;
int = 0x0702;//2019 modify
int = 0x0704;
int CAN线 = 0x0705;
int = 0x0800;
int = 0x0801;
int = 0x0802;
int = 0x0805;
int = 0x0900;
int = 0x0901;
int RSA = 0x0A00;
int = 0x0F00 - 0x0FFF;
int = 0x8001;
int = 0x8003;
int = 0x8004;//2019 new
int = 0x8100;
int = 0x8103;
int = 0x8104;
int = 0x8105;
int = 0x8106;
int = 0x8107;
int = 0x8108;
int = 0x8201;
int = 0x8202;
int = 0x8203;
int = 0x8204;//2019 new
int = 0x8300;//2019 modify
int = 0x8301;//2019 del
int = 0x8302;//2019 del
int = 0x8303;//2019 del
int = 0x8304;//2019 del
int = 0x8400;
int = 0x8401;
int = 0x8500;//2019 modify
int = 0x8600;//2019 modify
int = 0x8601;
int = 0x8602;//2019 modify
int = 0x8603;
int = 0x8604;//2019 modify
int = 0x8605;
int 线 = 0x8606;
int 线 = 0x8607;
int 线 = 0x8608;//2019 new
int = 0x8700;
int = 0x8701;
int = 0x8702;
int = 0x8800;
int = 0x8801;
int = 0x8802;
int = 0x8803;
int = 0x8804;
int = 0x8805;
int = 0x8900;
int RSA = 0x8A00;
int = 0x8F00 - 0x8FFF;
int = 0xE000 - 0xEFFF;//2019 new
int = 0xF000 - 0xFFFF;//2019 new
}

@ -0,0 +1,247 @@
package com.ruoyi.common.t808;
import io.github.yezhihao.netmc.core.model.Message;
import io.github.yezhihao.netmc.session.Session;
import io.github.yezhihao.protostar.annotation.Field;
import io.github.yezhihao.protostar.util.ToStringBuilder;
import io.netty.buffer.ByteBuf;
import java.beans.Transient;
/**
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public class JTMessage implements Message {
@Field(length = 2, desc = "消息ID")
protected int messageId;
@Field(length = 2, desc = "消息体属性")
protected int properties;
@Field(length = 1, desc = "协议版本号", version = 1)
protected int protocolVersion;
@Field(length = 6, charset = "BCD", desc = "终端手机号", version = {-1, 0})
@Field(length = 10, charset = "BCD", desc = "终端手机号", version = 1)
protected String clientId;
@Field(length = 2, desc = "流水号")
protected int serialNo;
@Field(length = 2, desc = "消息包总数")
protected Integer packageTotal;
@Field(length = 2, desc = "包序号")
protected Integer packageNo;
/** bcc校验 */
protected boolean verified = true;
protected transient Session session;
protected transient ByteBuf payload;
public JTMessage() {
}
public JTMessage(int messageId) {
this.messageId = messageId;
}
public JTMessage copyBy(JTMessage that) {
this.setClientId(that.getClientId());
this.setProtocolVersion(that.getProtocolVersion());
this.setVersion(that.isVersion());
return this;
}
public int getMessageId() {
return messageId;
}
public void setMessageId(int messageId) {
this.messageId = messageId;
}
public int getProperties() {
return properties;
}
public void setProperties(int properties) {
this.properties = properties;
}
public int getProtocolVersion() {
return protocolVersion;
}
public void setProtocolVersion(int protocolVersion) {
this.protocolVersion = protocolVersion;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public int getSerialNo() {
return serialNo;
}
public void setSerialNo(int serialNo) {
this.serialNo = serialNo;
}
public Integer getPackageTotal() {
if (isSubpackage())
return packageTotal;
return null;
}
public void setPackageTotal(Integer packageTotal) {
this.packageTotal = packageTotal;
}
public Integer getPackageNo() {
if (isSubpackage())
return packageNo;
return null;
}
public void setPackageNo(Integer packageNo) {
this.packageNo = packageNo;
}
public boolean isVerified() {
return verified;
}
public void setVerified(boolean verified) {
this.verified = verified;
}
@Transient
public Session getSession() {
return session;
}
public void setSession(Session session) {
this.session = session;
}
@Transient
public ByteBuf getPayload() {
return payload;
}
public void setPayload(ByteBuf payload) {
this.payload = payload;
}
public int reflectMessageId() {
if (messageId != 0)
return messageId;
return reflectMessageId(this.getClass());
}
public static int reflectMessageId(Class<?> clazz) {
io.github.yezhihao.protostar.annotation.Message messageType = clazz.getAnnotation(io.github.yezhihao.protostar.annotation.Message.class);
if (messageType != null && messageType.value().length > 0)
return messageType.value()[0];
return 0;
}
public boolean transform() {
return true;
}
public boolean noBuffer() {
return true;
}
private static final int BODY_LENGTH = 0b0000_0011_1111_1111;
private static final int ENCRYPTION = 0b00011_100_0000_0000;
private static final int SUBPACKAGE = 0b0010_0000_0000_0000;
private static final int VERSION = 0b0100_0000_0000_0000;
private static final int RESERVED = 0b1000_0000_0000_0000;
/** 消息体长度 */
public int getBodyLength() {
return this.properties & BODY_LENGTH;
}
public void setBodyLength(int bodyLength) {
this.properties ^= (properties & BODY_LENGTH);
this.properties |= bodyLength;
}
/** 加密方式 */
public int getEncryption() {
return (properties & ENCRYPTION) >> 10;
}
public void setEncryption(int encryption) {
this.properties ^= (properties & ENCRYPTION);
this.properties |= (encryption << 10);
}
/** 是否分包 */
public boolean isSubpackage() {
return (properties & SUBPACKAGE) == SUBPACKAGE;
}
public void setSubpackage(boolean subpackage) {
if (subpackage)
this.properties |= SUBPACKAGE;
else
this.properties ^= (properties & SUBPACKAGE);
}
/** 是否有版本 */
public boolean isVersion() {
return (properties & VERSION) == VERSION;
}
public void setVersion(boolean version) {
if (version)
this.properties |= VERSION;
else
this.properties ^= (properties & VERSION);
}
/** 保留位 */
public boolean isReserved() {
return (properties & RESERVED) == RESERVED;
}
public void setReserved(boolean reserved) {
if (reserved)
this.properties |= RESERVED;
else
this.properties ^= (properties & RESERVED);
}
protected StringBuilder toStringHead() {
final StringBuilder sb = new StringBuilder(768);
sb.append(MessageId.getName(messageId));
sb.append('[');
sb.append("cid=").append(clientId);
sb.append(",msgId=").append(messageId);
sb.append(",version=").append(protocolVersion);
sb.append(",serialNo=").append(serialNo);
sb.append(",props=").append(properties);
sb.append(",verified=").append(verified);
if (isSubpackage()) {
sb.append(",pt=").append(packageTotal);
sb.append(",pn=").append(packageNo);
}
sb.append(']');
sb.append(',');
return sb;
}
@Override
public String toString() {
String result = ToStringBuilder.toString(toStringHead(), this, false, "messageId", "clientId", "protocolVersion", "serialNo", "properties", "packageTotal", "packageNo");
return result;
}
}

@ -0,0 +1,73 @@
package com.ruoyi.common.t808;
import io.github.yezhihao.protostar.annotation.Message;
import io.github.yezhihao.protostar.util.ClassUtils;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public class MessageId {
private static final Map<Integer, String> messageId = new HashMap<>(256);
private static final Map<Integer, Class> messageClass = new HashMap<>(256);
static {
for (Class clazz : new Class[]{JT808.class, JT1078.class, JSATL12.class}) {
Field[] fields = clazz.getFields();
for (Field field : fields) {
try {
if (!Integer.TYPE.isAssignableFrom(field.getType()))
continue;
int id = field.getInt(null);
String hexId = leftPad(Integer.toHexString(id), 4, '0');
String name = field.getName();
messageId.put(id, "[" + hexId + "]" + name);
} catch (Exception e) {
e.printStackTrace();
}
}
}
List<Class> classList = ClassUtils.getClassList("org.yzh.protocol");
for (Class<?> clazz : classList) {
Message annotation = clazz.getAnnotation(Message.class);
if (annotation != null) {
int[] value = annotation.value();
for (int i : value) {
messageClass.put(i, clazz);
}
}
}
}
public static Class<JTMessage> getClass(Integer id) {
return messageClass.get(id);
}
public static String getName(int id) {
String name = messageId.get(id);
if (name != null) {
return name;
}
return leftPad(Integer.toHexString(id), 4, '0');
}
public static String leftPad(String str, int size, char ch) {
int length = str.length();
int pads = size - length;
if (pads > 0) {
char[] result = new char[size];
str.getChars(0, length, result, pads);
while (pads > 0)
result[--pads] = ch;
return new String(result);
}
return str;
}
}

@ -0,0 +1,81 @@
package com.ruoyi.common.t808;
import com.ruoyi.common.t808.attribute.Alarm;
import io.github.yezhihao.protostar.Schema;
import io.netty.buffer.ByteBuf;
/**
* 0x11
* length 1 5
*/
public class OverSpeedAlarm extends Alarm {
public static final int key = 17;
public static final Schema<OverSpeedAlarm> SCHEMA = new OverSpeedAlarmSchema();
/** 位置类型0.无特定位置 1.圆形区域 2.矩形区域 3.多边形区域 4.路段 */
private byte areaType;
/** 区域或路段ID */
private int areaId;
public OverSpeedAlarm() {
}
public OverSpeedAlarm(byte areaType, int areaId) {
this.areaType = areaType;
this.areaId = areaId;
}
public byte getAreaType() {
return areaType;
}
public void setAreaType(byte areaType) {
this.areaType = areaType;
}
public int getAreaId() {
return areaId;
}
public void setAreaId(int areaId) {
this.areaId = areaId;
}
@Override
public int getAlarmType() {
return key;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(80);
sb.append("OverSpeedAlarm{areaType=").append(areaType);
sb.append(",areaId=").append(areaId);
sb.append('}');
return sb.toString();
}
private static class OverSpeedAlarmSchema implements Schema<OverSpeedAlarm> {
private OverSpeedAlarmSchema() {
}
@Override
public OverSpeedAlarm readFrom(ByteBuf input) {
OverSpeedAlarm message = new OverSpeedAlarm();
message.areaType = input.readByte();
if (message.areaType > 0)
message.areaId = input.readInt();
return message;
}
@Override
public void writeTo(ByteBuf output, OverSpeedAlarm message) {
output.writeByte(message.areaType);
if (message.areaType > 0)
output.writeInt(message.areaId);
}
}
}

@ -0,0 +1,93 @@
package com.ruoyi.common.t808;
import com.ruoyi.common.t808.attribute.Alarm;
import io.github.yezhihao.protostar.Schema;
import io.netty.buffer.ByteBuf;
/**
* / 0x13
* length 7
*/
public class RouteDriveTimeAlarm extends Alarm {
public static final int key = 19;
public static final Schema<RouteDriveTimeAlarm> SCHEMA = new RouteDriveTimeAlarmSchema();
/** 路段ID */
private int areaId;
/** 路段行驶时间(秒) */
private int driveTime;
/** 结果0.不足 1.过长 */
private byte result;
public RouteDriveTimeAlarm() {
}
public RouteDriveTimeAlarm(int areaId, int driveTime, byte result) {
this.areaId = areaId;
this.driveTime = driveTime;
this.result = result;
}
public int getAreaId() {
return areaId;
}
public void setAreaId(int areaId) {
this.areaId = areaId;
}
public int getDriveTime() {
return driveTime;
}
public void setDriveTime(int driveTime) {
this.driveTime = driveTime;
}
public byte getResult() {
return result;
}
public void setResult(byte result) {
this.result = result;
}
@Override
public int getAlarmType() {
return key;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(80);
sb.append("RouteDriveTimeAlarm{areaId=").append(areaId);
sb.append(",driveTime=").append(driveTime);
sb.append(",result=").append(result);
sb.append('}');
return sb.toString();
}
private static class RouteDriveTimeAlarmSchema implements Schema<RouteDriveTimeAlarm> {
private RouteDriveTimeAlarmSchema() {
}
@Override
public RouteDriveTimeAlarm readFrom(ByteBuf input) {
RouteDriveTimeAlarm message = new RouteDriveTimeAlarm();
message.areaId = input.readInt();
message.driveTime = input.readUnsignedShort();
message.result = input.readByte();
return message;
}
@Override
public void writeTo(ByteBuf output, RouteDriveTimeAlarm message) {
output.writeInt(message.areaId);
output.writeShort(message.driveTime);
output.writeByte(message.result);
}
}
}

@ -0,0 +1,64 @@
package com.ruoyi.common.t808;
import io.github.yezhihao.protostar.Schema;
import io.github.yezhihao.protostar.util.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import java.util.Arrays;
/**
* 0x05
* length 30
*/
public class TirePressure {
public static final int key = 5;
public static final Schema<TirePressure> SCHEMA = new TirePressureSchema();
private byte[] value;
public TirePressure() {
}
public TirePressure(byte[] value) {
this.value = value;
}
public byte[] getValue() {
return value;
}
public void setValue(byte[] value) {
this.value = value;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(32);
sb.append("TirePressure{value=").append(Arrays.toString(value));
sb.append('}');
return sb.toString();
}
private static class TirePressureSchema implements Schema<TirePressure> {
private TirePressureSchema() {
}
@Override
public TirePressure readFrom(ByteBuf input) {
int len = input.readableBytes();
if (len > 30)
len = 30;
byte[] value = new byte[len];
input.readBytes(value);
return new TirePressure(value);
}
@Override
public void writeTo(ByteBuf output, TirePressure message) {
ByteBufUtils.writeFixedLength(output, 30, message.value);
}
}
}

@ -0,0 +1,115 @@
package com.ruoyi.common.t808.attribute;
import com.ruoyi.common.t808.model.T0200;
import java.time.LocalDateTime;
public abstract class Alarm {
private T0200 location;
private String platformAlarmId;
public T0200 getLocation() {
return location;
}
public void setLocation(T0200 location) {
this.location = location;
}
public String getPlatformAlarmId() {
return platformAlarmId;
}
public void setPlatformAlarmId(String platformAlarmId) {
this.platformAlarmId = platformAlarmId;
}
static int buildType(int key, int type) {
return (key * 100) + type;
}
//报警来源0.设备报警 1.苏标报警 127.平台报警
public int getSource() {
return 0;
}
public int getAreaId() {
return 0;
}
public int getState() {
return 1;
}
//报警时间
public LocalDateTime getAlarmTime() {
if (location == null)
return null;
return location.getDeviceTime();
}
//报警类别<=255
public int getCategory() {
return 0;
}
//报警类型
public abstract int getAlarmType();
//报警级别
public int getLevel() {
return 0;
}
//gps经度
public int getLongitude() {
if (location == null)
return 0;
return location.getLongitude();
}
//gps纬度
public int getLatitude() {
if (location == null)
return 0;
return location.getLatitude();
}
//海拔(米)
public int getAltitude() {
if (location == null)
return 0;
return location.getAltitude();
}
//速度(公里每小时)
public int getSpeed() {
if (location == null)
return 0;
return location.getSpeed() / 10;
}
//车辆状态
public int getStatusBit() {
if (location == null)
return 0;
return location.getStatusBit();
}
//序号(同一时间点报警的序号从0循环累加)
public int getSequenceNo() {
return 0;
}
//附件总数
public int getFileTotal() {
return 0;
}
//扩展信息
public String getExtra() {
return null;
}
}

@ -0,0 +1,294 @@
package com.ruoyi.common.t808.attribute;
import io.github.yezhihao.protostar.annotation.Field;
import java.time.LocalDateTime;
/**
* 0x64
*/
public class AlarmADAS extends Alarm {
public static final int key = 100;
@Field(length = 4, desc = "报警ID")
private long id;
@Field(length = 1, desc = "标志状态0.不可用 1.开始标志 2.结束标志")
private int state;
@Field(length = 1, desc = "报警/事件类型:" +
" 1.前向碰撞报警" +
" 2.车道偏离报警" +
" 3.车距过近报警" +
" 4.行人碰撞报警" +
" 5.频繁变道报警" +
" 6.道路标识超限报警" +
" 7.障碍物报警" +
" 8~15.用户自定义" +
" 16.道路标志识别事件" +
" 17.主动抓拍事件" +
" 18.实线变道报警(粤标)" +
" 19.车厢过道行人检测报警(粤标)" +
" 18~31.用户自定义")
private int type;
@Field(length = 1, desc = "报警级别")
private int level;
@Field(length = 1, desc = "前车车速(Km/h)范围0~250,仅报警类型为1和2时有效")
private int frontSpeed;
@Field(length = 1, desc = "前车/行人距离(100ms),范围0~100,仅报警类型为1、2和4时有效")
private int frontDistance;
@Field(length = 1, desc = "偏离类型1.左侧偏离 2.右侧偏离(报警类型为2时有效)")
private int deviateType;
@Field(length = 1, desc = "道路标志识别类型1.限速标志 2.限高标志 3.限重标志 4.禁行标志(粤标) 5.禁停标志(粤标)(报警类型为6和10时有效)")
private int roadSign;
@Field(length = 1, desc = "道路标志识别数据")
private int roadSignValue;
@Field(length = 1, desc = "车速")
private int speed;
@Field(length = 2, desc = "高程")
private int altitude;
@Field(length = 4, desc = "纬度")
private int latitude;
@Field(length = 4, desc = "经度")
private int longitude;
@Field(length = 6, charset = "BCD", desc = "日期时间")
private LocalDateTime alarmTime;
@Field(length = 2, desc = "车辆状态")
private int statusBit;
@Field(length = 7, desc = "终端ID", version = {-1, 0})
@Field(length = 30, desc = "终端ID(粤标)", version = 1)
private String deviceId;
@Field(length = 6, charset = "BCD", desc = "时间(YYMMDDHHMMSS)")
private LocalDateTime dateTime;
@Field(length = 1, desc = "序号(同一时间点报警的序号从0循环累加)")
private int sequenceNo;
@Field(length = 1, desc = "附件数量")
private int fileTotal;
@Field(length = 1, desc = "预留", version = {-1, 0})
@Field(length = 2, desc = "预留(粤标)", version = 1)
private int reserved;
@Override
public int getSource() {
return 1;
}
@Override
public int getCategory() {
return key;
}
@Override
public int getAlarmType() {
return Alarm.buildType(key, type);
}
@Override
public String getExtra() {
final StringBuilder sb = new StringBuilder(64);
if (type == 1 || type == 2) {
sb.append("frontSpeed:").append(frontSpeed).append(',');
}
if (type == 1 || type == 2 || type == 4) {
sb.append("frontDistance:").append(frontDistance).append(',');
}
if (type == 2) {
sb.append("deviateType:").append(deviateType).append(',');
}
if (type == 6 || type == 10) {
sb.append("roadSign:").append(roadSign).append(',');
sb.append("roadSignValue:").append(roadSignValue).append(',');
}
int length = sb.length();
if (length > 0)
return sb.substring(0, length - 1);
return null;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getFrontSpeed() {
return frontSpeed;
}
public void setFrontSpeed(int frontSpeed) {
this.frontSpeed = frontSpeed;
}
public int getFrontDistance() {
return frontDistance;
}
public void setFrontDistance(int frontDistance) {
this.frontDistance = frontDistance;
}
public int getDeviateType() {
return deviateType;
}
public void setDeviateType(int deviateType) {
this.deviateType = deviateType;
}
public int getRoadSign() {
return roadSign;
}
public void setRoadSign(int roadSign) {
this.roadSign = roadSign;
}
public int getRoadSignValue() {
return roadSignValue;
}
public void setRoadSignValue(int roadSignValue) {
this.roadSignValue = roadSignValue;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public LocalDateTime getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(LocalDateTime alarmTime) {
this.alarmTime = alarmTime;
}
public int getStatusBit() {
return statusBit;
}
public void setStatusBit(int statusBit) {
this.statusBit = statusBit;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public int getSequenceNo() {
return sequenceNo;
}
public void setSequenceNo(int sequenceNo) {
this.sequenceNo = sequenceNo;
}
public int getFileTotal() {
return fileTotal;
}
public void setFileTotal(int fileTotal) {
this.fileTotal = fileTotal;
}
public int getReserved() {
return reserved;
}
public void setReserved(int reserved) {
this.reserved = reserved;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(512);
sb.append("AlarmADAS{id=").append(id);
sb.append(", state=").append(state);
sb.append(", type=").append(type);
sb.append(", level=").append(level);
sb.append(", frontSpeed=").append(frontSpeed);
sb.append(", frontDistance=").append(frontDistance);
sb.append(", deviateType=").append(deviateType);
sb.append(", roadSign=").append(roadSign);
sb.append(", roadSignValue=").append(roadSignValue);
sb.append(", speed=").append(speed);
sb.append(", altitude=").append(altitude);
sb.append(", longitude=").append(longitude);
sb.append(", latitude=").append(latitude);
sb.append(", alarmTime=").append(alarmTime);
sb.append(", statusBit=").append(statusBit);
sb.append(", deviceId=").append(deviceId);
sb.append(", dateTime=").append(dateTime);
sb.append(", sequenceNo=").append(sequenceNo);
sb.append(", fileTotal=").append(fileTotal);
sb.append(", reserved=").append(reserved);
sb.append('}');
return sb.toString();
}
}

@ -0,0 +1,204 @@
package com.ruoyi.common.t808.attribute;
import io.github.yezhihao.protostar.annotation.Field;
import java.time.LocalDateTime;
/**
* 0x67
*/
public class AlarmBSD extends Alarm {
public static final int key = 103;
@Field(length = 4, desc = "报警ID")
private long id;
@Field(length = 1, desc = "标志状态0.不可用 1.开始标志 2.结束标志")
private int state;
@Field(length = 1, desc = "报警/事件类型1.后方接近报警 2.左侧后方接近报警 3.右侧后方接近报警")
private int type;
@Field(length = 1, desc = "车速")
private int speed;
@Field(length = 2, desc = "高程")
private int altitude;
@Field(length = 4, desc = "纬度")
private int latitude;
@Field(length = 4, desc = "经度")
private int longitude;
@Field(length = 6, charset = "BCD", desc = "日期时间")
private LocalDateTime alarmTime;
@Field(length = 2, desc = "车辆状态")
private int statusBit;
@Field(length = 7, desc = "终端ID", version = {-1, 0})
@Field(length = 30, desc = "终端ID(粤标)", version = 1)
private String deviceId;
@Field(length = 6, charset = "BCD", desc = "时间(YYMMDDHHMMSS)")
private LocalDateTime dateTime;
@Field(length = 1, desc = "序号(同一时间点报警的序号从0循环累加)")
private int sequenceNo;
@Field(length = 1, desc = "附件数量")
private int fileTotal;
@Field(length = 1, desc = "预留", version = {-1, 0})
@Field(length = 2, desc = "预留(粤标)", version = 1)
private int reserved;
@Override
public int getSource() {
return 1;
}
@Override
public int getCategory() {
return key;
}
@Override
public int getAlarmType() {
return Alarm.buildType(key, type);
}
@Override
public int getLevel() {
return 0;
}
@Override
public String getExtra() {
return null;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public LocalDateTime getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(LocalDateTime alarmTime) {
this.alarmTime = alarmTime;
}
public int getStatusBit() {
return statusBit;
}
public void setStatusBit(int statusBit) {
this.statusBit = statusBit;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public int getSequenceNo() {
return sequenceNo;
}
public void setSequenceNo(int sequenceNo) {
this.sequenceNo = sequenceNo;
}
public int getFileTotal() {
return fileTotal;
}
public void setFileTotal(int fileTotal) {
this.fileTotal = fileTotal;
}
public int getReserved() {
return reserved;
}
public void setReserved(int reserved) {
this.reserved = reserved;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(300);
sb.append("AlarmBSD{id=").append(id);
sb.append(", state=").append(state);
sb.append(", type=").append(type);
sb.append(", speed=").append(speed);
sb.append(", altitude=").append(altitude);
sb.append(", longitude=").append(longitude);
sb.append(", latitude=").append(latitude);
sb.append(", alarmTime=").append(alarmTime);
sb.append(", statusBit=").append(statusBit);
sb.append(", deviceId=").append(deviceId);
sb.append(", dateTime=").append(dateTime);
sb.append(", sequenceNo=").append(sequenceNo);
sb.append(", fileTotal=").append(fileTotal);
sb.append(", reserved=").append(reserved);
sb.append('}');
return sb.toString();
}
}

@ -0,0 +1,249 @@
package com.ruoyi.common.t808.attribute;
import io.github.yezhihao.protostar.annotation.Field;
import java.time.LocalDateTime;
/**
* 0x65
*/
public class AlarmDSM extends Alarm {
public static final int key = 101;
@Field(length = 4, desc = "报警ID")
private long id;
@Field(length = 1, desc = "标志状态0.不可用 1.开始标志 2.结束标志")
private int state;
@Field(length = 1, desc = "报警/事件类型:" +
" 1.疲劳驾驶报警" +
" 2.接打电话报警" +
" 3.抽烟报警" +
" 4.分神驾驶报警|不目视前方报警(粤标)" +
" 5.驾驶员异常报警" +
" 6.探头遮挡报警(粤标)" +
" 7.用户自定义" +
" 8.超时驾驶报警(粤标)" +
" 9.用户自定义" +
" 10.未系安全带报警(粤标)" +
" 11.红外阻断型墨镜失效报警(粤标)" +
" 12.双脱把报警(双手同时脱离方向盘)(粤标)" +
" 13.玩手机报警(粤标)" +
" 14.用户自定义" +
" 15.用户自定义" +
" 16.自动抓拍事件" +
" 17.驾驶员变更事件" +
" 18~31.用户自定义")
private int type;
@Field(length = 1, desc = "报警级别")
private int level;
@Field(length = 1, desc = "疲劳程度")
private int fatigueDegree;
@Field(length = 4, desc = "预留")
private int reserves;
@Field(length = 1, desc = "车速")
private int speed;
@Field(length = 2, desc = "高程")
private int altitude;
@Field(length = 4, desc = "纬度")
private int latitude;
@Field(length = 4, desc = "经度")
private int longitude;
@Field(length = 6, charset = "BCD", desc = "日期时间")
private LocalDateTime alarmTime;
@Field(length = 2, desc = "车辆状态")
private int statusBit;
@Field(length = 7, desc = "终端ID", version = {-1, 0})
@Field(length = 30, desc = "终端ID(粤标)", version = 1)
private String deviceId;
@Field(length = 6, charset = "BCD", desc = "时间(YYMMDDHHMMSS)")
private LocalDateTime dateTime;
@Field(length = 1, desc = "序号(同一时间点报警的序号从0循环累加)")
private int sequenceNo;
@Field(length = 1, desc = "附件数量")
private int fileTotal;
@Field(length = 1, desc = "预留", version = {-1, 0})
@Field(length = 2, desc = "预留(粤标)", version = 1)
private int reserved;
@Override
public int getSource() {
return 1;
}
@Override
public int getCategory() {
return key;
}
@Override
public int getAlarmType() {
return Alarm.buildType(key, type);
}
@Override
public String getExtra() {
return "fatigueDegree:" + fatigueDegree;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getFatigueDegree() {
return fatigueDegree;
}
public void setFatigueDegree(int fatigueDegree) {
this.fatigueDegree = fatigueDegree;
}
public int getReserves() {
return reserves;
}
public void setReserves(int reserves) {
this.reserves = reserves;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public LocalDateTime getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(LocalDateTime alarmTime) {
this.alarmTime = alarmTime;
}
public int getStatusBit() {
return statusBit;
}
public void setStatusBit(int statusBit) {
this.statusBit = statusBit;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public int getSequenceNo() {
return sequenceNo;
}
public void setSequenceNo(int sequenceNo) {
this.sequenceNo = sequenceNo;
}
public int getFileTotal() {
return fileTotal;
}
public void setFileTotal(int fileTotal) {
this.fileTotal = fileTotal;
}
public int getReserved() {
return reserved;
}
public void setReserved(int reserved) {
this.reserved = reserved;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(400);
sb.append("AlarmDSM{id=").append(id);
sb.append(", state=").append(state);
sb.append(", type=").append(type);
sb.append(", level=").append(level);
sb.append(", fatigueDegree=").append(fatigueDegree);
sb.append(", reserves=").append(reserves);
sb.append(", speed=").append(speed);
sb.append(", altitude=").append(altitude);
sb.append(", longitude=").append(longitude);
sb.append(", latitude=").append(latitude);
sb.append(", alarmTime=").append(alarmTime);
sb.append(", statusBit=").append(statusBit);
sb.append(", deviceId=").append(deviceId);
sb.append(", dateTime=").append(dateTime);
sb.append(", sequenceNo=").append(sequenceNo);
sb.append(", fileTotal=").append(fileTotal);
sb.append(", reserved=").append(reserved);
sb.append('}');
return sb.toString();
}
}

@ -0,0 +1,290 @@
package com.ruoyi.common.t808.attribute;
import io.github.yezhihao.protostar.annotation.Field;
import java.time.LocalDateTime;
import java.util.List;
/**
* 0x66
*/
public class AlarmTPMS extends Alarm {
public static final int key = 102;
@Field(length = 4, desc = "报警ID")
private long id;
@Field(length = 1, desc = "标志状态")
private int state;
@Field(length = 1, desc = "车速")
private int speed;
@Field(length = 2, desc = "高程")
private int altitude;
@Field(length = 4, desc = "纬度")
private int latitude;
@Field(length = 4, desc = "经度")
private int longitude;
@Field(length = 6, charset = "BCD", desc = "日期时间")
private LocalDateTime alarmTime;
@Field(length = 2, desc = "车辆状态")
private int statusBit;
@Field(length = 7, desc = "终端ID", version = {-1, 0})
@Field(length = 30, desc = "终端ID(粤标)", version = 1)
private String deviceId;
@Field(length = 6, charset = "BCD", desc = "时间(YYMMDDHHMMSS)")
private LocalDateTime dateTime;
@Field(length = 1, desc = "序号(同一时间点报警的序号从0循环累加)")
private int sequenceNo;
@Field(length = 1, desc = "附件数量")
private int fileTotal;
@Field(length = 1, desc = "预留", version = {-1, 0})
@Field(length = 2, desc = "预留(粤标)", version = 1)
private int reserved;
@Field(totalUnit = 1, desc = "事件信息列表")
private List<Item> items;
@Override
public int getSource() {
return 1;
}
@Override
public int getCategory() {
return key;
}
@Override
public int getAlarmType() {
return Alarm.buildType(key, 0);
}
@Override
public int getLevel() {
return 0;
}
@Override
public String getExtra() {
return null;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public LocalDateTime getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(LocalDateTime alarmTime) {
this.alarmTime = alarmTime;
}
public int getStatusBit() {
return statusBit;
}
public void setStatusBit(int statusBit) {
this.statusBit = statusBit;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
public int getSequenceNo() {
return sequenceNo;
}
public void setSequenceNo(int sequenceNo) {
this.sequenceNo = sequenceNo;
}
public int getFileTotal() {
return fileTotal;
}
public void setFileTotal(int fileTotal) {
this.fileTotal = fileTotal;
}
public int getReserved() {
return reserved;
}
public void setReserved(int reserved) {
this.reserved = reserved;
}
public List<Item> getItems() {
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
public static class Item {
@Field(length = 1, desc = "胎压报警位置(从左前轮开始以Z字形从00依次编号,编号与是否安装TPMS无关)")
private int position;
@Field(length = 2, desc = "报警类型:" +
" 0.胎压(定时上报)" +
" 1.胎压过高报警" +
" 2.胎压过低报警" +
" 3.胎温过高报警" +
" 4.传感器异常报警" +
" 5.胎压不平衡报警" +
" 6.慢漏气报警" +
" 7.电池电量低报警" +
" 8~31.预留")
private int type;
@Field(length = 2, desc = "胎压(Kpa)")
private int pressure;
@Field(length = 2, desc = "温度(℃)")
private int temperature;
@Field(length = 2, desc = "电池电量(%)")
private int batteryLevel;
public Item() {
}
public Item(int position, int type, int pressure, int temperature, int batteryLevel) {
this.position = position;
this.type = type;
this.pressure = pressure;
this.temperature = temperature;
this.batteryLevel = batteryLevel;
}
public int getPosition() {
return position;
}
public void setPosition(int position) {
this.position = position;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getPressure() {
return pressure;
}
public void setPressure(int pressure) {
this.pressure = pressure;
}
public int getTemperature() {
return temperature;
}
public void setTemperature(int temperature) {
this.temperature = temperature;
}
public int getBatteryLevel() {
return batteryLevel;
}
public void setBatteryLevel(int batteryLevel) {
this.batteryLevel = batteryLevel;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Item{");
sb.append("position=").append(position);
sb.append(", type=").append(type);
sb.append(", pressure=").append(pressure);
sb.append(", temperature=").append(temperature);
sb.append(", batteryLevel=").append(batteryLevel);
sb.append('}');
return sb.toString();
}
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(400);
sb.append("AlarmTPMS{id=").append(id);
sb.append(", state=").append(state);
sb.append(", speed=").append(speed);
sb.append(", altitude=").append(altitude);
sb.append(", longitude=").append(longitude);
sb.append(", latitude=").append(latitude);
sb.append(", alarmTime=").append(alarmTime);
sb.append(", statusBit=").append(statusBit);
sb.append(", deviceId=").append(deviceId);
sb.append(", dateTime=").append(dateTime);
sb.append(", sequenceNo=").append(sequenceNo);
sb.append(", fileTotal=").append(fileTotal);
sb.append(", reserved=").append(reserved);
sb.append(", items=").append(items);
sb.append('}');
return sb.toString();
}
}

@ -0,0 +1,130 @@
package com.ruoyi.common.t808.model;
import com.ruoyi.common.t808.AttributeConverter;
import com.ruoyi.common.t808.AttributeConverterYue;
import com.ruoyi.common.t808.JT808;
import com.ruoyi.common.t808.JTMessage;
import io.github.yezhihao.protostar.annotation.Field;
import io.github.yezhihao.protostar.annotation.Message;
import java.time.LocalDateTime;
import java.util.Map;
/**
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
@Message(JT808.)
public class T0200 extends JTMessage {
/**
* 使 Bit.isTrue
* @see
*/
@Field(length = 4, desc = "报警标志")
private int warnBit;
@Field(length = 4, desc = "状态")
private int statusBit;
@Field(length = 4, desc = "纬度")
private int latitude;
@Field(length = 4, desc = "经度")
private int longitude;
@Field(length = 2, desc = "高程(米)")
private int altitude;
@Field(length = 2, desc = "速度(1/10公里每小时)")
private int speed;
@Field(length = 2, desc = "方向")
private int direction;
@Field(length = 6, charset = "BCD", desc = "时间(YYMMDDHHMMSS)")
private LocalDateTime deviceTime;
@Field(converter = AttributeConverter.class, desc = "位置附加信息", version = {-1, 0})
@Field(converter = AttributeConverterYue.class, desc = "位置附加信息(粤标)", version = 1)
private Map<Integer, Object> attributes;
public int getWarnBit() {
return warnBit;
}
public void setWarnBit(int warnBit) {
this.warnBit = warnBit;
}
public int getStatusBit() {
return statusBit;
}
public void setStatusBit(int statusBit) {
this.statusBit = statusBit;
}
public int getLatitude() {
return latitude;
}
public void setLatitude(int latitude) {
this.latitude = latitude;
}
public int getLongitude() {
return longitude;
}
public void setLongitude(int longitude) {
this.longitude = longitude;
}
public int getAltitude() {
return altitude;
}
public void setAltitude(int altitude) {
this.altitude = altitude;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public LocalDateTime getDeviceTime() {
return deviceTime;
}
public void setDeviceTime(LocalDateTime deviceTime) {
this.deviceTime = deviceTime;
}
public Map<Integer, Object> getAttributes() {
return attributes;
}
public void setAttributes(Map<Integer, Object> attributes) {
this.attributes = attributes;
}
@Override
public String toString() {
StringBuilder sb = toStringHead();
sb.append("T0200{deviceTime=").append(deviceTime);
sb.append(",longitude=").append(longitude);
sb.append(",latitude=").append(latitude);
sb.append(",altitude=").append(altitude);
sb.append(",speed=").append(speed);
sb.append(",direction=").append(direction);
sb.append(",warnBit=").append(Integer.toBinaryString(warnBit));
sb.append(",statusBit=").append(Integer.toBinaryString(statusBit));
sb.append(",attributes=").append(attributes);
sb.append('}');
return sb.toString();
}
}

@ -0,0 +1,46 @@
package com.ruoyi.common.t808.model;
import com.ruoyi.common.t808.JTMessage;
import io.github.yezhihao.protostar.annotation.Field;
import java.util.List;
/**
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
public class T0704 extends JTMessage {
@Field(length = 2, desc = "数据项个数")
private int total;
@Field(length = 1, desc = "位置数据类型0.正常位置批量汇报 1.盲区补报")
private int type;
@Field(lengthUnit = 2, desc = "位置汇报数据项")
private List<T0200> items;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public List<T0200> getItems() {
return items;
}
public void setItems(List<T0200> items) {
this.items = items;
this.total = items.size();
}
}

@ -35,6 +35,7 @@
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!-- 验证码 -->
<dependency>
<groupId>pro.fessional</groupId>
@ -59,6 +60,16 @@
<artifactId>ruoyi-system</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-basetyre</artifactId>
</dependency>
</dependencies>
</project>

@ -1,5 +1,6 @@
package com.ruoyi.framework.config;
import com.ruoyi.basetyre.redislistener.RedisMessageListener;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
@ -7,6 +8,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
@ -47,7 +50,15 @@ public class RedisConfig extends CachingConfigurerSupport
redisScript.setResultType(Long.class);
return redisScript;
}
@Bean
public RedisMessageListenerContainer container(RedisConnectionFactory factory, RedisMessageListener listener) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(factory);
//订阅频道redis.news 和 redis.life 这个container 可以添加多个 messageListener
container.addMessageListener(listener, new ChannelTopic("0200"));
container.addMessageListener(listener, new ChannelTopic("0704"));
return container;
}
/**
*
*/

@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求
.authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage","/system/language/change").permitAll()
.antMatchers("/login", "/register", "/captchaImage","/system/language/change","/websocket/**").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

@ -0,0 +1,225 @@
package com.ruoyi.framework.websocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class EchoSocketServer {
private static final Logger log = LoggerFactory.getLogger(EchoSocketServer.class);
private static final String START_CODE = "7E",COMMN_CODE="8100",
END_CODE = "7E",MESSAGE_ARRRIBUTE = "000C",Serial_Number = "003B",Suce_STATUS = "00",
Auth_Size="0005",Auth_MessageID="0102",Auth_COMMN_CODE="8001",
JUMP_ARRRIBUTE="0002",JUMP_MessageID="0249";
/**
* 线
*/
private ExecutorService executorService = null;
/**
*
*/
private ServerSocket serverSocket = null;
/**
*
*/
private List<Socket> socketList = new ArrayList<>();
EchoSocketServer(int port) {
try {
// 创建服务器 socket
serverSocket = new ServerSocket(port);
// 初始化线程池
executorService = Executors.newCachedThreadPool();
log.info("服务启动完成,等待客户端连接...");
System.out.println("服务启动完成,等待客户端连接...");
Socket client = null;
while (true) {
client = serverSocket.accept();
socketList.add(client);
executorService.execute(new Service(client));
}
} catch (IOException e) {
e.printStackTrace();
}
// TODO
// socketList 管理
}
private static class Service implements Runnable {
/**
* 20
*/
private static final long TIMEOUT_MILLISECOND = 20000;
private Socket socket;
private boolean isConnect;
private long lastReceiveTime = System.currentTimeMillis();
public Service(Socket socket) {
this.socket = socket;
this.isConnect = true;
System.out.println(socket.getInetAddress() + ":" + socket.getPort() + " <连接>");
}
@Override
public void run() {
while (isConnect) {
// 超时
if (System.currentTimeMillis() - lastReceiveTime > TIMEOUT_MILLISECOND) {
stopService();
} else {
try {
// 默认接收 1024字节
InputStream in = socket.getInputStream();
if (in.available() > 0) {
lastReceiveTime = System.currentTimeMillis();
byte[] bytes = new byte[in.available()];
int len = in.read(bytes);
// String content = new String(bytes);
StringBuilder sb = new StringBuilder();
String tmp = null;
for (byte b : bytes)
{
// 将每个字节与0xFF进行与运算然后转化为10进制然后借助于Integer再转化为16进制
tmp = Integer.toHexString(0xFF & b);
if (tmp.length() == 1)// 每个字节8为转为16进制标志2个16进制位
{
tmp = "0" + tmp;
}
sb.append(tmp);
}
String msg = sb.toString().toUpperCase();
log.info("收-----------"+msg);
System.out.println(msg);
OutputStream os = socket.getOutputStream();
// 回响
String sendMessage = null;
if (msg.substring(2,6).equals("0100")){
// log.info("注册收-----------"+msg);
//设备号
sendMessage=START_CODE+COMMN_CODE+MESSAGE_ARRRIBUTE+
msg.substring(10,22)+Serial_Number+msg.substring(22,26)+
Suce_STATUS+"4A5400000000000000"+BccCheckCode(COMMN_CODE+MESSAGE_ARRRIBUTE+
msg.substring(10,22)+Serial_Number+msg.substring(22,26)+
Suce_STATUS+"4A5400000000000000")+END_CODE;
byte[] sendbytes_zhuce = hexStringToByteArray(sendMessage);
os.write(sendbytes_zhuce);
log.info("注册发-----------"+sendMessage);
}
if (msg.substring(2,6).equals("0102")){
// log.info("鉴权收-----------"+msg);
sendMessage=START_CODE+Auth_COMMN_CODE+Auth_Size+
msg.substring(10,22)+Serial_Number+msg.substring(22,26)+Auth_MessageID+
Suce_STATUS+BccCheckCode(COMMN_CODE+Auth_Size+
msg.substring(10,22)+Serial_Number+msg.substring(22,26)+Auth_MessageID+
Suce_STATUS)+END_CODE;
byte[] sendbytes_anth = hexStringToByteArray(sendMessage);
os.write(sendbytes_anth);
log.info("鉴权发-----------"+sendMessage);
}
if (msg.substring(2,6).equals("0002")){
// log.info("心跳收-----------"+msg);
sendMessage=START_CODE+Auth_COMMN_CODE+Auth_Size+
msg.substring(10,22)+JUMP_MessageID+msg.substring(22,26)+JUMP_ARRRIBUTE+
Suce_STATUS+BccCheckCode(Auth_COMMN_CODE+Auth_Size+
msg.substring(10,22)+JUMP_MessageID+msg.substring(22,26)+JUMP_ARRRIBUTE+
Suce_STATUS)+END_CODE;
byte[] sendbytes_jump = hexStringToByteArray(sendMessage);
os.write(sendbytes_jump);
log.info("心跳发-----------"+sendMessage);
}
os.flush();
} else {
Thread.sleep(10);
}
} catch (Exception e) {
e.printStackTrace();
stopService();
}
}
}
}
/**
*
*/
private void stopService() {
isConnect = false;
System.out.println(socket.getInetAddress() + ":" + socket.getPort() + " <断开>");
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static byte[] hexStringToByteArray(String hexString){
hexString = hexString.replaceAll(" ", "");
int len = hexString.length();
byte[] bytes = new byte[len / 2];
for (int i = 0; i < len; i += 2){
// 两位一组,表示一个字节,把这样表示的16进制字符串还原成一个字节
bytes[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) + Character
.digit(hexString.charAt(i + 1), 16));
}
return bytes;
}
public static String BccCheckCode(String code){
int a = 0;
for (int i = 0; i < code.length()/2; i++) {
a = a ^ Integer.parseInt(code.substring(i*2,(i*2)+2), 16);
}
String result = Integer.toHexString(a);
if (result.length()==1) {
return "0"+result.toUpperCase();
}else{
return result.toUpperCase();
}
}
public static void main(String[] args) {
String msg="7E0102000978408686549800014A5400000000000000E17E";
String sendMessage=START_CODE+COMMN_CODE+Auth_Size+
msg.substring(10,22)+Serial_Number+msg.substring(22,26)+Auth_MessageID+
Suce_STATUS+BccCheckCode(COMMN_CODE+Auth_Size+
msg.substring(10,22)+Serial_Number+msg.substring(22,26)+Auth_MessageID+
Suce_STATUS)+"7E";
System.out.println(sendMessage);
}
}

@ -0,0 +1,58 @@
package com.ruoyi.framework.websocket;
import java.util.concurrent.Semaphore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*
* @author ruoyi
*/
public class SemaphoreUtils
{
/**
* SemaphoreUtils
*/
private static final Logger LOGGER = LoggerFactory.getLogger(SemaphoreUtils.class);
/**
*
*
* @param semaphore
* @return
*/
public static boolean tryAcquire(Semaphore semaphore)
{
boolean flag = false;
try
{
flag = semaphore.tryAcquire();
}
catch (Exception e)
{
LOGGER.error("获取信号量异常", e);
}
return flag;
}
/**
*
*
* @param semaphore
*/
public static void release(Semaphore semaphore)
{
try
{
semaphore.release();
}
catch (Exception e)
{
LOGGER.error("释放信号量异常", e);
}
}
}

@ -0,0 +1,39 @@
package com.ruoyi.framework.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* websocket
*
* @author ruoyi
*/
@Configuration
public class WebSocketConfig
{
@Bean
public ServerEndpointExporter serverEndpointExporter()
{
return new ServerEndpointExporter();
}
// @Bean
// public EchoSocketServer echoSocketServer(){
// return new EchoSocketServer(8691);
// }
}

@ -0,0 +1,108 @@
package com.ruoyi.framework.websocket;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Semaphore;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import io.netty.buffer.ByteBuf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* websocket
*
* @author ruoyi
*/
@Component
@ServerEndpoint("/websocket/message")
public class WebSocketServer
{
/**
* WebSocketServer
*/
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketServer.class);
/**
* 线100
*/
public static int socketMaxOnlineCount = 100;
private static Semaphore socketSemaphore = new Semaphore(socketMaxOnlineCount);
/**
*
*/
@OnOpen
public void onOpen(Session session) throws Exception
{
boolean semaphoreFlag = false;
// 尝试获取信号量
semaphoreFlag = SemaphoreUtils.tryAcquire(socketSemaphore);
if (!semaphoreFlag)
{
// 未获取到信号量
LOGGER.error("\n 当前在线人数超过限制数- {}", socketMaxOnlineCount);
WebSocketUsers.sendMessageToUserByText(session, "当前在线人数超过限制数:" + socketMaxOnlineCount);
session.close();
}
else
{
// 添加用户
WebSocketUsers.put(session.getId(), session);
LOGGER.info("\n 建立连接 - {}", session);
LOGGER.info("\n 当前人数 - {}", WebSocketUsers.getUsers().size());
WebSocketUsers.sendMessageToUserByText(session, "连接成功");
}
}
/**
*
*/
@OnClose
public void onClose(Session session)
{
LOGGER.info("\n 关闭连接 - {}", session);
// 移除用户
WebSocketUsers.remove(session.getId());
// 获取到信号量则需释放
SemaphoreUtils.release(socketSemaphore);
}
/**
*
*/
@OnError
public void onError(Session session, Throwable exception) throws Exception
{
if (session.isOpen())
{
// 关闭连接
session.close();
}
String sessionId = session.getId();
LOGGER.info("\n 连接异常 - {}", sessionId);
LOGGER.info("\n 异常信息 - {}", exception);
// 移出用户
WebSocketUsers.remove(sessionId);
// 获取到信号量则需释放
SemaphoreUtils.release(socketSemaphore);
}
/**
*
*/
@OnMessage
public void onMessage(String message, Session session)
{
String msg = message.replace("你", "我").replace("吗", "");
WebSocketUsers.sendMessageToUserByText(session, msg);
}
}

@ -0,0 +1,140 @@
package com.ruoyi.framework.websocket;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* websocket
*
* @author ruoyi
*/
public class WebSocketUsers
{
/**
* WebSocketUsers
*/
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketUsers.class);
/**
*
*/
private static Map<String, Session> USERS = new ConcurrentHashMap<String, Session>();
/**
*
*
* @param key
* @param session
*/
public static void put(String key, Session session)
{
USERS.put(key, session);
}
/**
*
*
* @param session
*
* @return
*/
public static boolean remove(Session session)
{
String key = null;
boolean flag = USERS.containsValue(session);
if (flag)
{
Set<Map.Entry<String, Session>> entries = USERS.entrySet();
for (Map.Entry<String, Session> entry : entries)
{
Session value = entry.getValue();
if (value.equals(session))
{
key = entry.getKey();
break;
}
}
}
else
{
return true;
}
return remove(key);
}
/**
*
*
* @param key
*/
public static boolean remove(String key)
{
LOGGER.info("\n 正在移出用户 - {}", key);
Session remove = USERS.remove(key);
if (remove != null)
{
boolean containsValue = USERS.containsValue(remove);
LOGGER.info("\n 移出结果 - {}", containsValue ? "失败" : "成功");
return containsValue;
}
else
{
return true;
}
}
/**
* 线
*
* @return
*/
public static Map<String, Session> getUsers()
{
return USERS;
}
/**
*
*
* @param message
*/
public static void sendMessageToUsersByText(String message)
{
Collection<Session> values = USERS.values();
for (Session value : values)
{
sendMessageToUserByText(value, message);
}
}
/**
*
*
* @param userName
* @param message
*/
public static void sendMessageToUserByText(Session session, String message)
{
if (session != null)
{
try
{
session.getBasicRemote().sendText(message);
}
catch (IOException e)
{
LOGGER.error("\n[发送消息异常]", e);
}
}
else
{
LOGGER.info("\n[你已离线]");
}
}
}
Loading…
Cancel
Save