1078-设置圆形区域

This commit is contained in:
648540858
2024-05-04 00:09:12 +08:00
parent 5dd49b3d44
commit faa0a01b9f
6 changed files with 83 additions and 6 deletions

View File

@@ -48,22 +48,17 @@ 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)(nighttimeMaxSpeed & 0xffff));
byteBuf.writeShort((short)(name.getBytes(Charset.forName("GBK")).length & 0xffff));
byteBuf.writeCharSequence(name, Charset.forName("GBK"));
System.out.println(byteBuf.readableBytes());
return byteBuf;
}

View File

@@ -31,6 +31,7 @@ public class JT1078Template {
private static final String H8401 = "8401";
private static final String H8500 = "8500";
private static final String H8600 = "8600";
private static final String H8601 = "8601";
private static final String H9101 = "9101";
private static final String H9102 = "9102";
private static final String H9201 = "9201";
@@ -457,4 +458,15 @@ public class JT1078Template {
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
public Object deleteAreaForCircle(String devId, J8601 j8601, int timeOut) {
Cmd cmd = new Cmd.Builder()
.setDevId(devId)
.setPackageNo(randomInt())
.setMsgId(H8601)
.setRespId(H0001)
.setRs(j8601)
.build();
return SessionManager.INSTANCE.request(cmd, timeOut);
}
}

View File

@@ -529,5 +529,22 @@ public class JT1078Controller {
}
}
@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/circle/delete")
public WVPResult<Integer> deleteAreaForCircle(String deviceId, @RequestParam(value = "ids", required = false) List<Long> ids){
logger.info("[1078-删除圆形区域] deviceId: {}, ids:{}", deviceId, ids);
int result = service.deleteAreaForCircle(deviceId, ids);
if (result == 0) {
return WVPResult.success(result);
}else {
WVPResult<Integer> fail = WVPResult.fail(ErrorCode.ERROR100);
fail.setData(result);
return fail;
}
}
}

View File

@@ -0,0 +1,45 @@
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 io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.List;
/**
* 删除圆形区域
*/
@MsgId(id = "8601")
public class J8601 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;
}
}

View File

@@ -72,4 +72,5 @@ public interface Ijt1078Service {
int setAreaForCircle(int attribute, String deviceId, List<JTCircleArea> circleAreaList);
int deleteAreaForCircle(String deviceId, List<Long> ids);
}

View File

@@ -617,4 +617,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
j8600.setCircleAreaList(circleAreaList);
return (int)jt1078Template.setAreaForCircle(deviceId, j8600, 20);
}
@Override
public int deleteAreaForCircle(String deviceId, List<Long> ids) {
J8601 j8601 = new J8601();
j8601.setIdList(ids);
return (int)jt1078Template.deleteAreaForCircle(deviceId, j8601, 20);
}
}