[1078] 临时提交
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.genersoft.iot.vmp.jt1078.bean;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* JT 设备
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "jt808设备")
|
||||
public class JTDevice {
|
||||
|
||||
@@ -102,160 +104,16 @@ public class JTDevice {
|
||||
@Schema(description = "状态")
|
||||
private boolean status;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getProvinceId() {
|
||||
return provinceId;
|
||||
}
|
||||
|
||||
public void setProvinceId(String provinceId) {
|
||||
this.provinceId = provinceId;
|
||||
}
|
||||
|
||||
public String getProvinceText() {
|
||||
return provinceText;
|
||||
}
|
||||
|
||||
public void setProvinceText(String provinceText) {
|
||||
this.provinceText = provinceText;
|
||||
}
|
||||
|
||||
public String getCityId() {
|
||||
return cityId;
|
||||
}
|
||||
|
||||
public void setCityId(String cityId) {
|
||||
this.cityId = cityId;
|
||||
}
|
||||
|
||||
public String getCityText() {
|
||||
return cityText;
|
||||
}
|
||||
|
||||
public void setCityText(String cityText) {
|
||||
this.cityText = cityText;
|
||||
}
|
||||
|
||||
public String getMakerId() {
|
||||
return makerId;
|
||||
}
|
||||
|
||||
public void setMakerId(String makerId) {
|
||||
this.makerId = makerId;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getTerminalId() {
|
||||
return terminalId;
|
||||
}
|
||||
|
||||
public void setTerminalId(String deviceId) {
|
||||
this.terminalId = deviceId;
|
||||
}
|
||||
|
||||
public int getPlateColor() {
|
||||
return plateColor;
|
||||
}
|
||||
|
||||
public void setPlateColor(int plateColor) {
|
||||
this.plateColor = plateColor;
|
||||
}
|
||||
|
||||
public String getPlateNo() {
|
||||
return plateNo;
|
||||
}
|
||||
|
||||
public void setPlateNo(String plateNo) {
|
||||
this.plateNo = plateNo;
|
||||
}
|
||||
|
||||
public String getAuthenticationCode() {
|
||||
return authenticationCode;
|
||||
}
|
||||
|
||||
public void setAuthenticationCode(String authenticationCode) {
|
||||
this.authenticationCode = authenticationCode;
|
||||
}
|
||||
|
||||
public Double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(Double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public Double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(Double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(String updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRegisterTime() {
|
||||
return registerTime;
|
||||
}
|
||||
|
||||
public void setRegisterTime(String registerTime) {
|
||||
this.registerTime = registerTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTDevice{" +
|
||||
" 终端手机号='" + phoneNumber + '\'' +
|
||||
", 省域ID='" + provinceId + '\'' +
|
||||
", 省域文字描述='" + provinceText + '\'' +
|
||||
", 市县域ID='" + cityId + '\'' +
|
||||
", 市县域文字描述='" + cityText + '\'' +
|
||||
", 制造商ID='" + makerId + '\'' +
|
||||
", 终端型号='" + model + '\'' +
|
||||
", 终端手机号='" + phoneNumber + '\'' +
|
||||
", 设备ID='" + terminalId + '\'' +
|
||||
", 车牌颜色=" + plateColor +
|
||||
", 车牌='" + plateNo + '\'' +
|
||||
|
||||
@@ -4,9 +4,13 @@ import com.genersoft.iot.vmp.jt1078.util.BCDUtil;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Schema(description = "驾驶员身份信息")
|
||||
public class JTDriverInformation {
|
||||
|
||||
@@ -39,12 +43,18 @@ public class JTDriverInformation {
|
||||
@Schema(description = "驾驶员身份证号")
|
||||
private String driverIdNumber;
|
||||
|
||||
public static JTDriverInformation decode(ByteBuf buf) {
|
||||
public static JTDriverInformation decode(ByteBuf buf, boolean is2019) {
|
||||
JTDriverInformation jtDriverInformation = new JTDriverInformation();
|
||||
jtDriverInformation.setStatus(buf.readUnsignedByte());
|
||||
byte[] bytes = new byte[6];
|
||||
buf.readBytes(bytes);
|
||||
jtDriverInformation.setTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(bytes)));
|
||||
String timeStr = BCDUtil.transform(bytes);
|
||||
try {
|
||||
jtDriverInformation.setTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(timeStr));
|
||||
}catch (Exception e) {
|
||||
log.error("[JT-驾驶员身份信息] 解码时无法格式化时间: {}", timeStr);
|
||||
}
|
||||
|
||||
if (jtDriverInformation.getStatus() == 1) {
|
||||
jtDriverInformation.setResult((int)buf.readUnsignedByte());
|
||||
int nameLength = buf.readUnsignedByte();
|
||||
@@ -55,76 +65,19 @@ public class JTDriverInformation {
|
||||
certificateIssuanceMechanismNameLength, Charset.forName("GBK")).toString().trim());
|
||||
byte[] bytesForExpire = new byte[4];
|
||||
buf.readBytes(bytesForExpire);
|
||||
jtDriverInformation.setExpire(DateUtil.jt1078dateToyyyy_MM_dd(BCDUtil.transform(bytesForExpire)));
|
||||
jtDriverInformation.setDriverIdNumber(buf.readCharSequence(20, Charset.forName("GBK")).toString().trim());
|
||||
String bytesForExpireStr = BCDUtil.transform(bytesForExpire);
|
||||
try {
|
||||
jtDriverInformation.setExpire(DateUtil.jt1078dateToyyyy_MM_dd(bytesForExpireStr));
|
||||
}catch (Exception e) {
|
||||
log.error("[JT-驾驶员身份信息] 解码时无法格式化时间: {}", bytesForExpireStr);
|
||||
}
|
||||
if (is2019) {
|
||||
jtDriverInformation.setDriverIdNumber(buf.readCharSequence(20, Charset.forName("GBK")).toString().trim());
|
||||
}
|
||||
}
|
||||
return jtDriverInformation;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public Integer getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Integer result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCertificateCode() {
|
||||
return certificateCode;
|
||||
}
|
||||
|
||||
public void setCertificateCode(String certificateCode) {
|
||||
this.certificateCode = certificateCode;
|
||||
}
|
||||
|
||||
public String getCertificateIssuanceMechanismName() {
|
||||
return certificateIssuanceMechanismName;
|
||||
}
|
||||
|
||||
public void setCertificateIssuanceMechanismName(String certificateIssuanceMechanismName) {
|
||||
this.certificateIssuanceMechanismName = certificateIssuanceMechanismName;
|
||||
}
|
||||
|
||||
public String getExpire() {
|
||||
return expire;
|
||||
}
|
||||
|
||||
public void setExpire(String expire) {
|
||||
this.expire = expire;
|
||||
}
|
||||
|
||||
public String getDriverIdNumber() {
|
||||
return driverIdNumber;
|
||||
}
|
||||
|
||||
public void setDriverIdNumber(String driverIdNumber) {
|
||||
this.driverIdNumber = driverIdNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTDriverInformation{" +
|
||||
|
||||
@@ -152,6 +152,18 @@ public class JTPositionBaseInfo {
|
||||
this.videoAlarm = videoAlarm;
|
||||
}
|
||||
|
||||
|
||||
public String toSimpleString() {
|
||||
return "简略位置汇报信息: " +
|
||||
" \n 经度:" + longitude +
|
||||
" \n 纬度:" + latitude +
|
||||
" \n 高程: " + altitude +
|
||||
" \n 速度: " + speed +
|
||||
" \n 方向: " + direction +
|
||||
" \n 时间: " + time +
|
||||
" \n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "位置汇报信息: " +
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.genersoft.iot.vmp.jt1078.bean;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "拍摄命令参数")
|
||||
public class JTShootingCommand {
|
||||
|
||||
@@ -62,86 +64,6 @@ public class JTShootingCommand {
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public int getChanelId() {
|
||||
return chanelId;
|
||||
}
|
||||
|
||||
public void setChanelId(int chanelId) {
|
||||
this.chanelId = chanelId;
|
||||
}
|
||||
|
||||
public int getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(int command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public int getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(int save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public int getResolvingPower() {
|
||||
return resolvingPower;
|
||||
}
|
||||
|
||||
public void setResolvingPower(int resolvingPower) {
|
||||
this.resolvingPower = resolvingPower;
|
||||
}
|
||||
|
||||
public int getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
public void setQuality(int quality) {
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
public int getBrightness() {
|
||||
return brightness;
|
||||
}
|
||||
|
||||
public void setBrightness(int brightness) {
|
||||
this.brightness = brightness;
|
||||
}
|
||||
|
||||
public int getContrastRatio() {
|
||||
return contrastRatio;
|
||||
}
|
||||
|
||||
public void setContrastRatio(int contrastRatio) {
|
||||
this.contrastRatio = contrastRatio;
|
||||
}
|
||||
|
||||
public int getSaturation() {
|
||||
return saturation;
|
||||
}
|
||||
|
||||
public void setSaturation(int saturation) {
|
||||
this.saturation = saturation;
|
||||
}
|
||||
|
||||
public int getChroma() {
|
||||
return chroma;
|
||||
}
|
||||
|
||||
public void setChroma(int chroma) {
|
||||
this.chroma = chroma;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTShootingCommand{" +
|
||||
|
||||
@@ -19,7 +19,10 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author QingtaiJiang
|
||||
@@ -37,6 +40,7 @@ public class Jt808Decoder extends ByteToMessageDecoder {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
Map<String, List<String>> dumpMap = new ConcurrentHashMap<>();
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
Session session = ctx.channel().attr(Session.KEY).get();
|
||||
@@ -51,11 +55,9 @@ public class Jt808Decoder extends ByteToMessageDecoder {
|
||||
// 从消息属性中读取是否存在分包
|
||||
boolean isSubpackage = (header.getMsgPro() >>> 13 & 1) == 1;
|
||||
if (header.is2019Version()) {
|
||||
|
||||
header.setVersion(buf.readUnsignedByte());
|
||||
String devId = ByteBufUtil.hexDump(buf.readSlice(10));
|
||||
header.setPhoneNumber(devId.replaceFirst("^0*", ""));
|
||||
|
||||
} else {
|
||||
header.setPhoneNumber(ByteBufUtil.hexDump(buf.readSlice(6)).replaceFirst("^0*", ""));
|
||||
}
|
||||
@@ -63,14 +65,28 @@ public class Jt808Decoder extends ByteToMessageDecoder {
|
||||
if (isSubpackage) {
|
||||
int packageCount = buf.readUnsignedShort();
|
||||
int packageNumber = buf.readUnsignedShort();
|
||||
// List<String> strings = dumpMap.get(header.getPhoneNumber());
|
||||
// if (strings == null) {
|
||||
// strings = new ArrayList<>();
|
||||
// }
|
||||
// strings.add(dump);
|
||||
// if (strings.size() == packageCount) {
|
||||
// for (int i = 0; i < strings.size(); i++) {
|
||||
// if (i == strings.size() - 1) {
|
||||
// System.out.println(strings.get(i));
|
||||
// }else {
|
||||
// System.out.print(strings.get(i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
MultiPacket multiPacket = MultiPacket.getInstance(header, packageNumber, packageCount, buf);
|
||||
ByteBuf intactBuf = MultiPacketManager.INSTANCE.add(multiPacket);
|
||||
if (intactBuf != null) {
|
||||
buf = intactBuf;
|
||||
}else {
|
||||
in.skipBytes(in.readableBytes());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
Re handler = CodecFactory.getHandler(header.getMsgId());
|
||||
if (handler == null) {
|
||||
@@ -88,8 +104,6 @@ public class Jt808Decoder extends ByteToMessageDecoder {
|
||||
} finally {
|
||||
in.skipBytes(in.readableBytes());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ public enum MultiPacketManager {
|
||||
multiPackets.add(packet);
|
||||
packetTimeMap.put(key, System.currentTimeMillis());
|
||||
if (packet.getCount() == multiPackets.size()) {
|
||||
logger.info("分包接受完毕: \n{}", packet.getHeader());
|
||||
// 所有分包接收完毕,排序后返回
|
||||
multiPackets.sort(Comparator.comparing(MultiPacket::getNumber));
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
System.out.println(byteBuf.maxFastWritableBytes());
|
||||
for (MultiPacket multiPacket : multiPackets) {
|
||||
byteBuf.writeBytes(multiPacket.getByteBuf());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class J0200 extends Re {
|
||||
// JTPositionAdditionalInfo positionAdditionalInfo = new JTPositionAdditionalInfo();
|
||||
// Map<Integer, byte[]> additionalMsg = new HashMap<>();
|
||||
// getAdditionalMsg(buf, positionAdditionalInfo);
|
||||
log.debug("[JT-位置汇报]: {}", positionInfo.toString());
|
||||
// log.info("[JT-位置汇报]: phoneNumber={} {}", header.getPhoneNumber(), positionInfo.toSimpleString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class J0702 extends Re {
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
driverInformation = JTDriverInformation.decode(buf);
|
||||
driverInformation = JTDriverInformation.decode(buf, header.is2019Version());
|
||||
log.info("[JT-驾驶员身份信息采集上报]: {}", driverInformation.toString());
|
||||
SessionManager.INSTANCE.response(header.getPhoneNumber(), "0702", null, driverInformation);
|
||||
return null;
|
||||
|
||||
@@ -14,6 +14,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -31,14 +33,60 @@ public class J0801 extends Re {
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
JTMediaEventInfo mediaEventInfo = JTMediaEventInfo.decode(buf);
|
||||
log.info("[JT-多媒体数据上传]: {}", mediaEventInfo);
|
||||
File file = new File("/home/lin/" + header.getSn() + ".jpg");
|
||||
|
||||
|
||||
try {
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
BufferedImage image1 = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
File file1 = new File("/home/lin/1.jpg");
|
||||
ImageIO.write(image1, "jpg", file1);
|
||||
|
||||
|
||||
BufferedImage image2 = new BufferedImage(width, height, 2);
|
||||
File file2 = new File("/home/lin/2.jpg");
|
||||
ImageIO.write(image2, "jpg", file2);
|
||||
|
||||
|
||||
BufferedImage image3 = new BufferedImage(width, height, 3);
|
||||
File file3 = new File("/home/lin/3.jpg");
|
||||
ImageIO.write(image3, "jpg", file3);
|
||||
|
||||
|
||||
BufferedImage image4 = new BufferedImage(width, height, 4);
|
||||
File file4 = new File("/home/lin/4.jpg");
|
||||
ImageIO.write(image4, "jpg", file4);
|
||||
|
||||
|
||||
BufferedImage image5 = new BufferedImage(width, height, 5);
|
||||
File file5 = new File("/home/lin/5.jpg");
|
||||
ImageIO.write(image5, "jpg", file5);
|
||||
|
||||
|
||||
BufferedImage image6 = new BufferedImage(width, height, 6);
|
||||
File file6 = new File("/home/lin/6.jpg");
|
||||
ImageIO.write(image6, "jpg", file6);
|
||||
|
||||
|
||||
BufferedImage image7 = new BufferedImage(width, height, 7);
|
||||
File file7 = new File("/home/lin/7.jpg");
|
||||
ImageIO.write(image7, "jpg", file7);
|
||||
|
||||
|
||||
BufferedImage image8 = new BufferedImage(width, height, 8);
|
||||
File file8 = new File("/home/lin/8.jpg");
|
||||
ImageIO.write(image8, "jpg", file8);
|
||||
|
||||
File file = new File("/home/lin/source.jpg");
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
// fileOutputStream.write(0xFF);
|
||||
// fileOutputStream.write(0xD8);
|
||||
// fileOutputStream.write(0xFF);
|
||||
fileOutputStream.write(mediaEventInfo.getMediaData());
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
}catch (Exception e) {
|
||||
|
||||
log.error("[JT-多媒体数据上传] 写入文件异常", e);
|
||||
}
|
||||
|
||||
SessionManager.INSTANCE.response(header.getPhoneNumber(), "0801", null, mediaEventInfo);
|
||||
|
||||
@@ -734,11 +734,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
|
||||
JTShootingCommand shootingCommand = new JTShootingCommand();
|
||||
shootingCommand.setChanelId(channelId);
|
||||
shootingCommand.setCommand(1);
|
||||
shootingCommand.setCommand(3);
|
||||
shootingCommand.setTime(0);
|
||||
shootingCommand.setSave(0);
|
||||
shootingCommand.setResolvingPower(0x03);
|
||||
shootingCommand.setQuality(5);
|
||||
shootingCommand.setResolvingPower(0x01);
|
||||
shootingCommand.setQuality(1);
|
||||
shootingCommand.setBrightness(125);
|
||||
shootingCommand.setContrastRatio(60);
|
||||
shootingCommand.setSaturation(60);
|
||||
@@ -749,6 +749,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> ids = (List<Long>) jt1078Template.shooting(phoneNumber, j8801, 300);
|
||||
log.info("[JT-抓图] 抓图编号: {}, 设备编号: {}, 通道编号: {}", ids.get(0), phoneNumber, channelId);
|
||||
|
||||
log.info("[JT-抓图] 请求上传图片,抓图编号: {}, 设备编号: {}, 通道编号: {}", ids.get(0), phoneNumber, channelId);
|
||||
J8805 j8805 = new J8805();
|
||||
j8805.setMediaId(ids.get(0));
|
||||
|
||||
Reference in New Issue
Block a user