1078-设置圆形区域...
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
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.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
|
||||
@Schema(description = "圆形区域")
|
||||
public class JTCircleArea {
|
||||
|
||||
@@ -22,10 +27,10 @@ public class JTCircleArea {
|
||||
@Schema(description = "半径,单位为米(m)")
|
||||
private long radius;
|
||||
|
||||
@Schema(description = "起始时间, YY-MM-DD hh-mm-ss")
|
||||
@Schema(description = "起始时间, yyyy-MM-dd HH:mm:ss")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间, YY-MM-DD hh-mm-ss")
|
||||
@Schema(description = "结束时间, yyyy-MM-dd HH:mm:ss")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "最高速度, 单位为千米每小时(km/h)")
|
||||
@@ -43,10 +48,23 @@ public class JTCircleArea {
|
||||
public ByteBuf encode(){
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||
System.out.println("attribute: " + attribute.encode().readableBytes());
|
||||
byteBuf.writeBytes(attribute.encode());
|
||||
byteBuf.writeInt((int) (Math.round((latitude * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (Math.round((longitude * 1000000)) & 0xffffffffL));
|
||||
byteBuf.writeInt((int) (radius & 0xffffffffL));
|
||||
ByteBuf transform = BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime));
|
||||
ByteBuf transform1 = BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime));
|
||||
System.out.println("startTime: " + transform.readableBytes());
|
||||
System.out.println("endTime: " + transform1.readableBytes());
|
||||
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)));
|
||||
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)));
|
||||
byteBuf.writeShort((short)(maxSpeed & 0xffff));
|
||||
byteBuf.writeByte(overSpeedDuration);
|
||||
byteBuf.writeShort((short)(name.getBytes(Charset.forName("GBK")).length & 0xffff));
|
||||
byteBuf.writeCharSequence(name, Charset.forName("GBK"));
|
||||
System.out.println(byteBuf.readableBytes());
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
|
||||
@@ -30,6 +30,7 @@ public class JT1078Template {
|
||||
private static final String H8400 = "8400";
|
||||
private static final String H8401 = "8401";
|
||||
private static final String H8500 = "8500";
|
||||
private static final String H8600 = "8600";
|
||||
private static final String H9101 = "9101";
|
||||
private static final String H9102 = "9102";
|
||||
private static final String H9201 = "9201";
|
||||
@@ -445,4 +446,15 @@ public class JT1078Template {
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
|
||||
public Object setAreaForCircle(String devId, J8600 j8600, int timeOut) {
|
||||
Cmd cmd = new Cmd.Builder()
|
||||
.setDevId(devId)
|
||||
.setPackageNo(randomInt())
|
||||
.setMsgId(H8600)
|
||||
.setRespId(H0001)
|
||||
.setRs(j8600)
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.genersoft.iot.vmp.jt1078.controller;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||
import com.genersoft.iot.vmp.jt1078.controller.bean.ConfirmationAlarmMessageParam;
|
||||
import com.genersoft.iot.vmp.jt1078.controller.bean.ConnectionControlParam;
|
||||
import com.genersoft.iot.vmp.jt1078.controller.bean.SetPhoneBookParam;
|
||||
import com.genersoft.iot.vmp.jt1078.controller.bean.TextMessageParam;
|
||||
import com.genersoft.iot.vmp.jt1078.controller.bean.*;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
@@ -484,5 +481,53 @@ public class JT1078Controller {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-更新圆形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||
@PostMapping("/area/circle/update")
|
||||
public WVPResult<Integer> updateAreaForCircle(@RequestBody SetAreaParam areaParam){
|
||||
|
||||
logger.info("[1078-更新圆形区域] areaParam: {},", areaParam);
|
||||
int result = service.setAreaForCircle(0, areaParam.getDeviceId(), areaParam.getCircleAreaList());
|
||||
if (result == 0) {
|
||||
return WVPResult.success(result);
|
||||
}else {
|
||||
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
|
||||
fail.setData(result);
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-追加圆形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||
@PostMapping("/area/circle/add")
|
||||
public WVPResult<Integer> addAreaForCircle(@RequestBody SetAreaParam areaParam){
|
||||
|
||||
logger.info("[1078-追加圆形区域] areaParam: {},", areaParam);
|
||||
int result = service.setAreaForCircle(1, areaParam.getDeviceId(), areaParam.getCircleAreaList());
|
||||
if (result == 0) {
|
||||
return WVPResult.success(result);
|
||||
}else {
|
||||
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
|
||||
fail.setData(result);
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-修改圆形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||
@PostMapping("/area/circle/edit")
|
||||
public WVPResult<Integer> editAreaForCircle(@RequestBody SetAreaParam areaParam){
|
||||
|
||||
logger.info("[1078-修改圆形区域] areaParam: {},", areaParam);
|
||||
int result = service.setAreaForCircle(2, areaParam.getDeviceId(), areaParam.getCircleAreaList());
|
||||
if (result == 0) {
|
||||
return WVPResult.success(result);
|
||||
}else {
|
||||
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
|
||||
fail.setData(result);
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.genersoft.iot.vmp.jt1078.controller.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTCircleArea;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTPhoneBookContact;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "设置区域")
|
||||
public class SetAreaParam {
|
||||
|
||||
@Schema(description = "设备")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "圆形区域项")
|
||||
private List<JTCircleArea> circleAreaList;
|
||||
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public List<JTCircleArea> getCircleAreaList() {
|
||||
return circleAreaList;
|
||||
}
|
||||
|
||||
public void setCircleAreaList(List<JTCircleArea> circleAreaList) {
|
||||
this.circleAreaList = circleAreaList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SetAreaParam{" +
|
||||
"deviceId='" + deviceId + '\'' +
|
||||
", circleAreaList=" + circleAreaList +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.response;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTCircleArea;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTVehicleControl;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设置圆形区域
|
||||
*/
|
||||
@MsgId(id = "8600")
|
||||
public class J8600 extends Rs {
|
||||
|
||||
/**
|
||||
* 设置属性, 0:更新区域; 1:追加区域; 2:修改区域
|
||||
*/
|
||||
private int attribute;
|
||||
|
||||
/**
|
||||
* 区域项
|
||||
*/
|
||||
private List<JTCircleArea> circleAreaList;
|
||||
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
buffer.writeByte(attribute);
|
||||
buffer.writeByte(circleAreaList.size());
|
||||
if (circleAreaList.isEmpty()) {
|
||||
return buffer;
|
||||
}
|
||||
for (JTCircleArea circleArea : circleAreaList) {
|
||||
buffer.writeBytes(circleArea.encode());
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public int getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(int attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public List<JTCircleArea> getCircleAreaList() {
|
||||
return circleAreaList;
|
||||
}
|
||||
|
||||
public void setCircleAreaList(List<JTCircleArea> circleAreaList) {
|
||||
this.circleAreaList = circleAreaList;
|
||||
}
|
||||
}
|
||||
@@ -69,4 +69,7 @@ public interface Ijt1078Service {
|
||||
int setPhoneBook(String deviceId, int type, List<JTPhoneBookContact> phoneBookContactList);
|
||||
|
||||
JTPositionBaseInfo controlDoor(String deviceId, Boolean open);
|
||||
|
||||
int setAreaForCircle(int attribute, String deviceId, List<JTCircleArea> circleAreaList);
|
||||
|
||||
}
|
||||
|
||||
@@ -609,4 +609,12 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
j8500.setVehicleControl(jtVehicleControl);
|
||||
return (JTPositionBaseInfo)jt1078Template.vehicleControl(deviceId, j8500, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setAreaForCircle(int attribute, String deviceId, List<JTCircleArea> circleAreaList) {
|
||||
J8600 j8600 = new J8600();
|
||||
j8600.setAttribute(attribute);
|
||||
j8600.setCircleAreaList(circleAreaList);
|
||||
return (int)jt1078Template.setAreaForCircle(deviceId, j8600, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package com.genersoft.iot.vmp.jt1078.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* BCD码转换
|
||||
*/
|
||||
@@ -19,4 +26,26 @@ public class BCDUtil {
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间使用按照YY-MM-DD-hh-mm-ss,转换为byte数据
|
||||
*/
|
||||
public static ByteBuf transform(long time) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
int month = calendar.get(Calendar.MONTH) + 1 ;
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int second = calendar.get(Calendar.SECOND);
|
||||
byteBuf.writeByte(year);
|
||||
byteBuf.writeByte(month);
|
||||
byteBuf.writeByte(day);
|
||||
byteBuf.writeByte(hour);
|
||||
byteBuf.writeByte(minute);
|
||||
byteBuf.writeByte(second);
|
||||
return byteBuf;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user