1078-设置矩形区域+删除矩形区域
This commit is contained in:
@@ -0,0 +1,163 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
@Schema(description = "矩形区域")
|
||||||
|
public class JTRectangleArea {
|
||||||
|
|
||||||
|
@Schema(description = "区域 ID")
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
@Schema(description = "")
|
||||||
|
private JTAreaAttribute attribute;
|
||||||
|
|
||||||
|
@Schema(description = "左上点纬度")
|
||||||
|
private Double latitudeForUpperLeft;
|
||||||
|
|
||||||
|
@Schema(description = "左上点经度")
|
||||||
|
private Double longitudeForUpperLeft;
|
||||||
|
|
||||||
|
@Schema(description = "右下点纬度")
|
||||||
|
private Double latitudeForLowerRight;
|
||||||
|
|
||||||
|
@Schema(description = "右下点经度")
|
||||||
|
private Double longitudeForLowerRight;
|
||||||
|
|
||||||
|
@Schema(description = "起始时间, yyyy-MM-dd HH:mm:ss")
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
@Schema(description = "结束时间, yyyy-MM-dd HH:mm:ss")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
@Schema(description = "最高速度, 单位为千米每小时(km/h)")
|
||||||
|
private int maxSpeed;
|
||||||
|
|
||||||
|
@Schema(description = "超速持续时间, 单位为秒(s)")
|
||||||
|
private int overSpeedDuration;
|
||||||
|
|
||||||
|
@Schema(description = "夜间最高速度, 单位为千米每小时(km/h)")
|
||||||
|
private int nighttimeMaxSpeed;
|
||||||
|
|
||||||
|
@Schema(description = "区域的名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public ByteBuf encode(){
|
||||||
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
|
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||||
|
byteBuf.writeBytes(attribute.encode());
|
||||||
|
byteBuf.writeInt((int) (Math.round((latitudeForUpperLeft * 1000000)) & 0xffffffffL));
|
||||||
|
byteBuf.writeInt((int) (Math.round((longitudeForLowerRight * 1000000)) & 0xffffffffL));
|
||||||
|
byteBuf.writeInt((int) (Math.round((latitudeForLowerRight * 1000000)) & 0xffffffffL));
|
||||||
|
byteBuf.writeInt((int) (Math.round((longitudeForLowerRight * 1000000)) & 0xffffffffL));
|
||||||
|
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)(nighttimeMaxSpeed & 0xffff));
|
||||||
|
byteBuf.writeShort((short)(name.getBytes(Charset.forName("GBK")).length & 0xffff));
|
||||||
|
byteBuf.writeCharSequence(name, Charset.forName("GBK"));
|
||||||
|
return byteBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JTAreaAttribute getAttribute() {
|
||||||
|
return attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttribute(JTAreaAttribute attribute) {
|
||||||
|
this.attribute = attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getLatitudeForUpperLeft() {
|
||||||
|
return latitudeForUpperLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitudeForUpperLeft(Double latitudeForUpperLeft) {
|
||||||
|
this.latitudeForUpperLeft = latitudeForUpperLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getLongitudeForUpperLeft() {
|
||||||
|
return longitudeForUpperLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitudeForUpperLeft(Double longitudeForUpperLeft) {
|
||||||
|
this.longitudeForUpperLeft = longitudeForUpperLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getLatitudeForLowerRight() {
|
||||||
|
return latitudeForLowerRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitudeForLowerRight(Double latitudeForLowerRight) {
|
||||||
|
this.latitudeForLowerRight = latitudeForLowerRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getLongitudeForLowerRight() {
|
||||||
|
return longitudeForLowerRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitudeForLowerRight(Double longitudeForLowerRight) {
|
||||||
|
this.longitudeForLowerRight = longitudeForLowerRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(String startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(String endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxSpeed() {
|
||||||
|
return maxSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxSpeed(int maxSpeed) {
|
||||||
|
this.maxSpeed = maxSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOverSpeedDuration() {
|
||||||
|
return overSpeedDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverSpeedDuration(int overSpeedDuration) {
|
||||||
|
this.overSpeedDuration = overSpeedDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNighttimeMaxSpeed() {
|
||||||
|
return nighttimeMaxSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNighttimeMaxSpeed(int nighttimeMaxSpeed) {
|
||||||
|
this.nighttimeMaxSpeed = nighttimeMaxSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,8 @@ public class JT1078Template {
|
|||||||
private static final String H8500 = "8500";
|
private static final String H8500 = "8500";
|
||||||
private static final String H8600 = "8600";
|
private static final String H8600 = "8600";
|
||||||
private static final String H8601 = "8601";
|
private static final String H8601 = "8601";
|
||||||
|
private static final String H8602 = "8602";
|
||||||
|
private static final String H8603 = "8603";
|
||||||
private static final String H9101 = "9101";
|
private static final String H9101 = "9101";
|
||||||
private static final String H9102 = "9102";
|
private static final String H9102 = "9102";
|
||||||
private static final String H9201 = "9201";
|
private static final String H9201 = "9201";
|
||||||
@@ -469,4 +471,26 @@ public class JT1078Template {
|
|||||||
.build();
|
.build();
|
||||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object setAreaForRectangle(String devId, J8602 j8602, int timeOut) {
|
||||||
|
Cmd cmd = new Cmd.Builder()
|
||||||
|
.setDevId(devId)
|
||||||
|
.setPackageNo(randomInt())
|
||||||
|
.setMsgId(H8602)
|
||||||
|
.setRespId(H0001)
|
||||||
|
.setRs(j8602)
|
||||||
|
.build();
|
||||||
|
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object deleteAreaForRectangle(String devId, J8603 j8603, int timeOut) {
|
||||||
|
Cmd cmd = new Cmd.Builder()
|
||||||
|
.setDevId(devId)
|
||||||
|
.setPackageNo(randomInt())
|
||||||
|
.setMsgId(H8603)
|
||||||
|
.setRespId(H0001)
|
||||||
|
.setRs(j8603)
|
||||||
|
.build();
|
||||||
|
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,5 +546,71 @@ public class JT1078Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "1078-更新矩形区域", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
|
@Parameter(name = "areaParam", description = "设置区域参数", required = true)
|
||||||
|
@PostMapping("/area/rectangle/update")
|
||||||
|
public WVPResult<Integer> updateAreaForRectangle(@RequestBody SetAreaParam areaParam){
|
||||||
|
|
||||||
|
logger.info("[1078-更新矩形区域] areaParam: {},", areaParam);
|
||||||
|
int result = service.setAreaForRectangle(0, areaParam.getDeviceId(), areaParam.getRectangleAreas());
|
||||||
|
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/rectangle/add")
|
||||||
|
public WVPResult<Integer> addAreaForRectangle(@RequestBody SetAreaParam areaParam){
|
||||||
|
|
||||||
|
logger.info("[1078-追加矩形区域] areaParam: {},", areaParam);
|
||||||
|
int result = service.setAreaForRectangle(1, areaParam.getDeviceId(), areaParam.getRectangleAreas());
|
||||||
|
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/rectangle/edit")
|
||||||
|
public WVPResult<Integer> editAreaForRectangle(@RequestBody SetAreaParam areaParam){
|
||||||
|
|
||||||
|
logger.info("[1078-修改矩形区域] areaParam: {},", areaParam);
|
||||||
|
int result = service.setAreaForRectangle(2, areaParam.getDeviceId(), areaParam.getRectangleAreas());
|
||||||
|
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 = "deviceId", description = "设备编号", required = true)
|
||||||
|
@Parameter(name = "ids", description = "待删除圆形区域的id,例如1,2,3", required = true)
|
||||||
|
@GetMapping("/area/rectangle/delete")
|
||||||
|
public WVPResult<Integer> deleteAreaForRectangle(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
|
||||||
|
|
||||||
|
logger.info("[1078-删除矩形区域] deviceId: {}, ids:{}", deviceId, ids);
|
||||||
|
int result = service.deleteAreaForRectangle(deviceId, ids);
|
||||||
|
if (result == 0) {
|
||||||
|
return WVPResult.success(result);
|
||||||
|
}else {
|
||||||
|
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
|
||||||
|
fail.setData(result);
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.jt1078.controller.bean;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.JTCircleArea;
|
import com.genersoft.iot.vmp.jt1078.bean.JTCircleArea;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.JTPhoneBookContact;
|
import com.genersoft.iot.vmp.jt1078.bean.JTPhoneBookContact;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.bean.JTRectangleArea;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,6 +16,9 @@ public class SetAreaParam {
|
|||||||
@Schema(description = "圆形区域项")
|
@Schema(description = "圆形区域项")
|
||||||
private List<JTCircleArea> circleAreaList;
|
private List<JTCircleArea> circleAreaList;
|
||||||
|
|
||||||
|
@Schema(description = "矩形区域项")
|
||||||
|
private List<JTRectangleArea> rectangleAreas;
|
||||||
|
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
@@ -32,11 +36,20 @@ public class SetAreaParam {
|
|||||||
this.circleAreaList = circleAreaList;
|
this.circleAreaList = circleAreaList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<JTRectangleArea> getRectangleAreas() {
|
||||||
|
return rectangleAreas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRectangleAreas(List<JTRectangleArea> rectangleAreas) {
|
||||||
|
this.rectangleAreas = rectangleAreas;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SetAreaParam{" +
|
return "SetAreaParam{" +
|
||||||
"deviceId='" + deviceId + '\'' +
|
"deviceId='" + deviceId + '\'' +
|
||||||
", circleAreaList=" + circleAreaList +
|
", circleAreaList=" + circleAreaList +
|
||||||
|
", rectangleAreas=" + rectangleAreas +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
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.JTRectangleArea;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置矩形区域
|
||||||
|
*/
|
||||||
|
@MsgId(id = "8602")
|
||||||
|
public class J8602 extends Rs {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置属性, 0:更新区域; 1:追加区域; 2:修改区域
|
||||||
|
*/
|
||||||
|
private int attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域项
|
||||||
|
*/
|
||||||
|
private List<JTRectangleArea> rectangleAreas;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ByteBuf encode() {
|
||||||
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
|
buffer.writeByte(attribute);
|
||||||
|
buffer.writeByte(rectangleAreas.size());
|
||||||
|
if (rectangleAreas.isEmpty()) {
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
for (JTRectangleArea area : rectangleAreas) {
|
||||||
|
buffer.writeBytes(area.encode());
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttribute() {
|
||||||
|
return attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttribute(int attribute) {
|
||||||
|
this.attribute = attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JTRectangleArea> getRectangleAreas() {
|
||||||
|
return rectangleAreas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRectangleAreas(List<JTRectangleArea> rectangleAreas) {
|
||||||
|
this.rectangleAreas = rectangleAreas;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除矩形区域
|
||||||
|
*/
|
||||||
|
@MsgId(id = "8603")
|
||||||
|
public class J8603 extends Rs {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待删除的区域ID
|
||||||
|
*/
|
||||||
|
private List<Long> idList;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ByteBuf encode() {
|
||||||
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
|
if (idList == null || idList.isEmpty()) {
|
||||||
|
buffer.writeByte(0);
|
||||||
|
return buffer;
|
||||||
|
}else {
|
||||||
|
buffer.writeByte(idList.size());
|
||||||
|
}
|
||||||
|
for (Long id : idList) {
|
||||||
|
buffer.writeInt((int) (id & 0xffffffffL));
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Long> getIdList() {
|
||||||
|
return idList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdList(List<Long> idList) {
|
||||||
|
this.idList = idList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,4 +73,8 @@ public interface Ijt1078Service {
|
|||||||
int setAreaForCircle(int attribute, String deviceId, List<JTCircleArea> circleAreaList);
|
int setAreaForCircle(int attribute, String deviceId, List<JTCircleArea> circleAreaList);
|
||||||
|
|
||||||
int deleteAreaForCircle(String deviceId, List<Long> ids);
|
int deleteAreaForCircle(String deviceId, List<Long> ids);
|
||||||
|
|
||||||
|
int setAreaForRectangle(int i, String deviceId, List<JTRectangleArea> rectangleAreas);
|
||||||
|
|
||||||
|
int deleteAreaForRectangle(String deviceId, List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -624,4 +624,19 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
j8601.setIdList(ids);
|
j8601.setIdList(ids);
|
||||||
return (int)jt1078Template.deleteAreaForCircle(deviceId, j8601, 20);
|
return (int)jt1078Template.deleteAreaForCircle(deviceId, j8601, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int setAreaForRectangle(int attribute, String deviceId, List<JTRectangleArea> rectangleAreas) {
|
||||||
|
J8602 j8602 = new J8602();
|
||||||
|
j8602.setAttribute(attribute);
|
||||||
|
j8602.setRectangleAreas(rectangleAreas);
|
||||||
|
return (int)jt1078Template.setAreaForRectangle(deviceId, j8602, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteAreaForRectangle(String deviceId, List<Long> ids) {
|
||||||
|
J8603 j8603 = new J8603();
|
||||||
|
j8603.setIdList(ids);
|
||||||
|
return (int)jt1078Template.deleteAreaForRectangle(deviceId, j8603, 20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user