1078-上报驾驶员身份信息请求+驾驶员身份信息采集上报

This commit is contained in:
648540858
2024-05-08 22:51:29 +08:00
parent ad67155d73
commit c6e3df685a
8 changed files with 250 additions and 0 deletions

View File

@@ -0,0 +1,141 @@
package com.genersoft.iot.vmp.jt1078.bean;
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 java.nio.charset.Charset;
@Schema(description = "驾驶员身份信息")
public class JTDriverInformation {
@Schema(description = "0x01:从业资格证 IC卡插入( 驾驶员上班)0x02:从 业资格证 IC卡拔出(驾驶员下班)")
private int status;
@Schema(description = "插卡/拔卡时间 ,以下字段在状 态为0x01 时才有效并做填充")
private String time;
@Schema(description = "IC卡读取结果:" +
"0x00:IC卡读卡成功" +
"0x01:读卡失败 ,原因为卡片密钥认证未通过; 0x02:读卡失败 ,原因为卡片已被锁定;" +
"0x03:读卡失败 ,原因为卡片被拔出;" +
"0x04:读卡失败 ,原因为数据校验错误。" +
"以下字段在 IC卡读取结果等于0x00 时才有效")
private Integer result;
@Schema(description = "驾驶员姓名")
private String name;
@Schema(description = "从业资格证编码")
private String certificateCode;
@Schema(description = "发证机构名称")
private String certificateIssuanceMechanismName;
@Schema(description = "证件有效期")
private String expire;
@Schema(description = "驾驶员身份证号")
private String driverIdNumber;
public static JTDriverInformation decode(ByteBuf buf) {
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)));
if (jtDriverInformation.getStatus() == 1) {
jtDriverInformation.setResult((int)buf.readUnsignedByte());
int nameLength = buf.readUnsignedByte();
jtDriverInformation.setName(buf.readCharSequence(nameLength, Charset.forName("GBK")).toString().trim());
jtDriverInformation.setCertificateCode(buf.readCharSequence(20, Charset.forName("GBK")).toString().trim());
int certificateIssuanceMechanismNameLength = buf.readUnsignedByte();
jtDriverInformation.setCertificateIssuanceMechanismName(buf.readCharSequence(
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());
}
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{" +
"status=" + status +
", time='" + time + '\'' +
", result=" + result +
", name='" + name + '\'' +
", certificateCode='" + certificateCode + '\'' +
", certificateIssuanceMechanismName='" + certificateIssuanceMechanismName + '\'' +
", expire='" + expire + '\'' +
", driverIdNumber='" + driverIdNumber + '\'' +
'}';
}
}

View File

@@ -39,6 +39,7 @@ public class JT1078Template {
private static final String H8606 = "8606";
private static final String H8607 = "8607";
private static final String H8608 = "8608";
private static final String H8702 = "8702";
private static final String H9101 = "9101";
private static final String H9102 = "9102";
private static final String H9201 = "9201";
@@ -59,6 +60,7 @@ public class JT1078Template {
private static final String H0201 = "0201";
private static final String H0500 = "0500";
private static final String H0608 = "0608";
private static final String H0702 = "0702";
private static final String H1205 = "1205";
/**
@@ -554,4 +556,15 @@ public class JT1078Template {
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
public Object queryDriverInformation(String devId, J8702 j8702, int timeOut) {
Cmd cmd = new Cmd.Builder()
.setDevId(devId)
.setPackageNo(randomInt())
.setMsgId(H8702)
.setRespId(H0702)
.setRs(j8702)
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
}

View File

@@ -733,5 +733,21 @@ public class JT1078Controller {
return WVPResult.fail(ErrorCode.ERROR100);
}
}
// TODO 待实现 行驶记录数据采集命令 行驶记录数据上传 行驶记录参数下传命令 电子运单上报
@Operation(summary = "1078-上报驾驶员身份信息请求", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备编号", required = true)
@GetMapping("/driver-information")
public WVPResult<JTDriverInformation> queryDriverInformation(String deviceId){
logger.info("[1078-上报驾驶员身份信息请求] deviceId: {}", deviceId);
JTDriverInformation jtDriverInformation = service.queryDriverInformation(deviceId);
if (jtDriverInformation != null) {
return WVPResult.success(jtDriverInformation);
}else {
return WVPResult.fail(ErrorCode.ERROR100);
}
}
}

View File

@@ -0,0 +1,48 @@
package com.genersoft.iot.vmp.jt1078.proc.request;
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
import com.genersoft.iot.vmp.jt1078.bean.JTDriverInformation;
import com.genersoft.iot.vmp.jt1078.bean.JTPositionBaseInfo;
import com.genersoft.iot.vmp.jt1078.proc.Header;
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
import com.genersoft.iot.vmp.jt1078.session.Session;
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
import io.netty.buffer.ByteBuf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEvent;
/**
* 驾驶员身份信息采集上报
*
*/
@MsgId(id = "0702")
public class J0702 extends Re {
private final static Logger log = LoggerFactory.getLogger(J0100.class);
private JTDriverInformation driverInformation;
@Override
protected Rs decode0(ByteBuf buf, Header header, Session session) {
driverInformation = JTDriverInformation.decode(buf);
log.info("[JT-驾驶员身份信息采集上报]: {}", driverInformation.toString());
SessionManager.INSTANCE.response(header.getTerminalId(), "0702", null, driverInformation);
return null;
}
@Override
protected Rs handler(Header header, Session session, Ijt1078Service service) {
J8001 j8001 = new J8001();
j8001.setRespNo(header.getSn());
j8001.setRespId(header.getMsgId());
return j8001;
}
@Override
public ApplicationEvent getEvent() {
return null;
}
}

View File

@@ -0,0 +1,19 @@
package com.genersoft.iot.vmp.jt1078.proc.response;
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* 上报驾驶员身份信息请求
*/
@MsgId(id = "8702")
public class J8702 extends Rs {
@Override
public ByteBuf encode() {
ByteBuf buffer = Unpooled.buffer();
return buffer;
}
}

View File

@@ -93,4 +93,6 @@ public interface Ijt1078Service {
int deleteRoute(String deviceId, List<Long> ids);
List<JTAreaOrRoute> queryRoute(String deviceId, List<Long> ids);
JTDriverInformation queryDriverInformation(String deviceId);
}

View File

@@ -699,4 +699,10 @@ public class jt1078ServiceImpl implements Ijt1078Service {
j8608.setIdList(ids);
return (List<JTAreaOrRoute>)jt1078Template.queryAreaOrRoute(deviceId, j8608, 20);
}
@Override
public JTDriverInformation queryDriverInformation(String deviceId) {
J8702 j8702 = new J8702();
return (JTDriverInformation)jt1078Template.queryDriverInformation(deviceId, j8702, 20);
}
}

View File

@@ -50,6 +50,7 @@ public class DateUtil {
*/
public static final String URL_PATTERN = "yyyyMMddHHmmss";
public static final String PATTERN1078 = "yyMMddHHmmss";
public static final String PATTERN1078Date = "yyyyMMdd";
/**
* 日期格式
@@ -67,6 +68,7 @@ public class DateUtil {
public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter formatter1078 = DateTimeFormatter.ofPattern(PATTERN1078, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static final DateTimeFormatter formatter1078date = DateTimeFormatter.ofPattern(PATTERN1078Date, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) {
@@ -94,6 +96,9 @@ public class DateUtil {
public static String jt1078Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
return formatter.format(formatter1078.parse(formatTime));
}
public static String jt1078dateToyyyy_MM_dd(String formatTime) {
return DateFormatter.format(formatter1078date.parse(formatTime));
}
/**
* yyyy_MM_dd_HH_mm_ss 转时间戳