This commit is contained in:
tiger_zhou 2023-06-08 15:14:04 +08:00
commit 7735b3e63b
10 changed files with 148 additions and 58 deletions

View File

@ -42,44 +42,44 @@ public class TrainBlockInfoResponse extends MessageResponse {
/**
* 列车编组号(9)
*/
private String groupId;
private String groupId;
/**
* 表号(9)
*/
private String trainId;
private String trainId;
/**
* 方向(1)
* 0上行
* 1下行
* 2未知
*/
private DirectionEnum direction;
private DirectionEnum direction;
/**
* 列车所在区间左边车站的站号(2)
*/
private Short stationIdInUpSide;
private Short stationIdInUpSide;
/**
* 列车所在区间右边车站的站号(2)
*/
private Short stationIdInDownSide;
private Short stationIdInDownSide;
/**
* 集中站站号(2)
*/
private Short rtuId;
private Short rtuId;
/**
* 列车所在的设备的类型(2)
*/
private Short devType;
private DeviceTypeEnum devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
private String devName;
/**
* 列车阻塞标记(1)
* 1列车阻塞
* 0列车没有阻塞
*/
private Boolean blockFlag;
private Boolean blockFlag;
private TrainCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
@ -87,6 +87,7 @@ public class TrainBlockInfoResponse extends MessageResponse {
byte direction;
final byte[] devName = new byte[24];
byte blockFlag;
short devType;
//
buf.readBytes(groupId);
buf.readBytes(trainId);
@ -94,12 +95,13 @@ public class TrainBlockInfoResponse extends MessageResponse {
this.stationIdInUpSide = buf.readShort();
this.stationIdInDownSide = buf.readShort();
this.rtuId = buf.readShort();
this.devType = buf.readShort();
devType = buf.readShort();
buf.readBytes(devName);
blockFlag = buf.readByte();
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.devType = DeviceTypeEnum.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.direction = DirectionEnum.of(direction);
switch (blockFlag) {

View File

@ -2,13 +2,16 @@ package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 2.7.9列车信息全体消息
*/
@Getter
public class TrainIndicationInitResponse extends MessageResponse {
/**
@ -34,105 +37,127 @@ public class TrainIndicationInitResponse extends MessageResponse {
}
}
@Getter
public static class TrainCell {
/**
* 集中站站号(2)
*/
private Short rtuId;
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private Short devType;
private DeviceTypeEnum devType;
/**
* 列车所在的设备的名称(24)
*/
private byte[] devName = new byte[24];
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private byte[] trainIndex = new byte[10];
private String trainIndex;
/**
* 列车编组号(9)
*/
private byte[] groupId = new byte[9];
private String groupId;
/**
* 表号(9)
*/
private byte[] trainId = new byte[9];
private String trainId;
/**
* 车次号(12)
*/
private byte[] globalId = new byte[12];
private String globalId;
/**
* 目的地号(4)
*/
private byte[] destinationId = new byte[4];
private Integer destinationId;
/**
* 编组数量(1)
*/
private byte rollingStock;
private byte rollingStock;
/**
* 司机号(13)
*/
private byte[] driverId = new byte[13];
private String driverId;
/**
* 根据实际报点和计划的偏离时间单位-215- +215 正数表示列车晚点秒数负数表示列车早点秒数(4)
*/
private Integer otpTime;
private Integer otpTime;
/**
* 列车状态见附录6.3.14列车状态定义(4)
*/
private Integer mode;
private Integer mode;
/**
* 列车到点(7)
*/
private byte[] arriveTime = new byte[7];
private LocalDateTime arriveTime;
/**
* 列车发点(7)
*/
private byte[] departTime = new byte[7];
private LocalDateTime departTime;
/**
* 满载率百分比例如50表示满载率为50%(4)
*/
private Integer rate;
private Integer rate;
/**
* 速度KM/H(1)
*/
private byte speed;
private byte speed;
/**
* 预留(2)
*/
private byte[] reserve = new byte[2];
private byte[] reserve = new byte[2];
private TrainCell decode(final ByteBuf buf) {
short devType;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] driverId = new byte[13];
final byte[] arriveTime = new byte[7];
final byte[] departTime = new byte[7];
//
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
this.devType = buf.readShort();
buf.readBytes(this.devName);
buf.readBytes(this.trainIndex);
buf.readBytes(this.groupId);
buf.readBytes(this.trainId);
buf.readBytes(this.globalId);
buf.readBytes(this.destinationId);
this.rollingStock = buf.readByte();
buf.readBytes(this.driverId);
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
buf.readBytes(trainId);
buf.readBytes(globalId);
this.destinationId = buf.readInt();
this.rollingStock = buf.readByte();
buf.readBytes(driverId);
this.otpTime = buf.readInt();
this.mode = buf.readInt();
buf.readBytes(this.arriveTime);
buf.readBytes(this.departTime);
buf.readBytes(arriveTime);
buf.readBytes(departTime);
this.rate = buf.readInt();
this.speed = buf.readByte();
buf.readBytes(this.reserve);
//
this.devType = DeviceTypeEnum.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.globalId = new String(globalId, MessageCons.STRING_CHARSET);
this.driverId = new String(driverId, MessageCons.STRING_CHARSET);
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
//
return this;
}
}

View File

@ -2,54 +2,66 @@ package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
/**
* 2.7.11 列车信息删除消息
*/
@Getter
public class TrainIndicationRemoveResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
private Short lineId;
/**
* 集中站站号(2)
*/
private Short rtuId;
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private Short devType;
private DeviceTypeEnum devType;
/**
* 列车所在的设备的名称(24)
*/
private byte[] devName = new byte[24];
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private byte[] trainIndex = new byte[10];
private String trainIndex;
/**
* 列车编组号(9)
*/
private byte[] groupId = new byte[9];
private String groupId;
@Override
public void decode2(ByteBuf buf) throws Exception {
short devType;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
//
this.lineId = buf.readShort();
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
this.devType = buf.readShort();
buf.readBytes(this.devName);
buf.readBytes(this.trainIndex);
buf.readBytes(this.groupId);
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
//
this.devType = DeviceTypeEnum.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
}
}

View File

@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
@ -62,7 +63,8 @@ public class LineInfoController {
@SecurityRequirement(name = "jwt")
@Operation(summary = "创建线路")
@ApiResponse(description = "线路信息")
public LineInfo create(Principal user, @RequestBody LineInfo lineInfo) {
public LineInfo create(Principal user
, @RequestBody @Validated(LineInfo.Creation.class) LineInfo lineInfo) {
return lineInfoService.create(user, lineInfo);
}
@ -76,9 +78,10 @@ public class LineInfoController {
@PutMapping("/{id}")
@SecurityRequirement(name = "jwt")
@Operation(summary = "保存线路数据")
@ApiResponse(description = "保存成功失败标识")
public boolean updateData(@PathVariable Integer id, @RequestBody LineInfo lineInfo) {
@Operation(summary = "更新线路数据")
@ApiResponse(description = "更新成功失败标识")
public boolean updateData(@PathVariable Integer id
, @RequestBody @Validated(LineInfo.SaveData.class) LineInfo lineInfo) {
return lineInfoService.updateData(id, lineInfo);
}

View File

@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
@ -53,11 +54,31 @@ public class PublishedGiController {
return publishedGiRepository.list(query);
}
@GetMapping("/{id}")
@SecurityRequirement(name = "jwt")
@Operation(summary = "根据主键获取发布图形数据详情")
@ApiResponse(description = "根据主键获取发布图形数据详情")
public PublishedGi queryById(@PathVariable Integer id) {
return publishedGiRepository.getById(id);
}
@GetMapping("/{type}/{lineId}")
@SecurityRequirement(name = "jwt")
@Operation(summary = "根据线路号和类型获取发布图形数据详情")
@ApiResponse(description = "根据线路号和类型获取发布图形数据详情")
public PublishedGi queryByTypeAndLineId(@PathVariable String type, @PathVariable Integer lineId) {
PublishedGIQueryDto dto = new PublishedGIQueryDto();
dto.setType(type);
dto.setLineId(lineId);
return publishedGiRepository.queryByDto(dto);
}
@PostMapping("/publish")
@SecurityRequirement(name = "jwt")
@Operation(summary = "发布草稿图形数据")
@ApiResponse(description = "发布草稿图形数据")
public PublishedGi publish(Principal user, @RequestBody PublishedGIDto publishedDto) {
public PublishedGi publish(Principal user, @RequestBody @Validated(PublishedGIDto.Publish.class) PublishedGIDto publishedDto) {
return publishedGiService.publish(user, publishedDto);
}

View File

@ -1,6 +1,7 @@
package club.joylink.xiannccda.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
@ -14,9 +15,15 @@ public class PublishedGIDto {
@NotNull
@Schema(description = "关联的线路号")
@NotBlank(message = "关联线路不能为空", groups = { Publish.class })
private Integer lineId;
@NotNull
@Schema(description = "草稿数据主键")
@NotBlank(message = "请选择草稿数据", groups = { Publish.class })
private Integer draftingId;
public interface Publish {
}
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@ -30,9 +31,11 @@ public class LineInfo {
private Integer id;
@Schema(description = "线路名")
@NotBlank(message = "线路名不能为空", groups = {Creation.class, SaveData.class})
private String name;
@Schema(description = "线路号")
@NotBlank(message = "线路号不能为空", groups = {Creation.class, SaveData.class})
private Integer lineId;
@Schema(description = "线路配置")

View File

@ -20,4 +20,6 @@ public interface IPublishedGiRepository extends IService<PublishedGi> {
Page<PublishedGi> paging(PublishedGIQueryDto query);
List<PublishedGi> list(PublishedGIQueryDto query);
PublishedGi queryByDto(PublishedGIQueryDto query);
}

View File

@ -56,4 +56,19 @@ public class PublishedGiRepository extends ServiceImpl<PublishedGiMapper, Publis
wrapper.select(PublishedGi.class, publishedGi -> !publishedGi.getColumn().equals("proto"));
return list(wrapper);
}
@Override
public PublishedGi queryByDto(PublishedGIQueryDto query) {
LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery();
if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like(PublishedGi::getName, query.getName());
}
if (StringUtils.isNotEmpty(query.getType())) {
wrapper.eq(PublishedGi::getType, query.getType());
}
if (query.getLineId() != null) {
wrapper.eq(PublishedGi::getLineId, query.getLineId());
}
return getOne(wrapper);
}
}

View File

@ -44,7 +44,7 @@ public class PublishedGiService {
// 删除已发布的绘图数据
LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery();
String name = StringUtils.isNotEmpty(publishedDto.getName()) ? publishedDto.getName() : drafting.getName();
wrapper.eq(PublishedGi::getName, name).eq(PublishedGi::getType, drafting.getType()).eq(PublishedGi::getLineId, publishedDto.getLineId());
wrapper.eq(PublishedGi::getType, drafting.getType()).eq(PublishedGi::getLineId, publishedDto.getLineId());
publishedGiRepository.remove(wrapper); // 删除发布数据
// 保存发布信息
PublishedGi publishedGi = new PublishedGi();