新增后台上行报文模块

This commit is contained in:
慕下 2024-08-22 16:17:47 +08:00
parent 66c7346bd8
commit 4713212bec
9 changed files with 447 additions and 0 deletions

View File

@ -11,5 +11,6 @@ public interface ErrorCodeConstants {
ErrorCode SALE_DATA_NOT_EXISTS = new ErrorCode(1_005_001_002, "售票不存在"); ErrorCode SALE_DATA_NOT_EXISTS = new ErrorCode(1_005_001_002, "售票不存在");
ErrorCode INFORMATION_NOT_EXISTS = new ErrorCode(1_005_002_001, "旅客信息不存在"); ErrorCode INFORMATION_NOT_EXISTS = new ErrorCode(1_005_002_001, "旅客信息不存在");
ErrorCode ALL_NOT_EXISTS = new ErrorCode(1_005_003_001, "设备登录日志不存在"); ErrorCode ALL_NOT_EXISTS = new ErrorCode(1_005_003_001, "设备登录日志不存在");
ErrorCode UM_NOT_EXISTS = new ErrorCode(1_005_004_001, "上行报文不存在");
} }

View File

@ -0,0 +1,97 @@
package cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessagePageReqVO;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessageRespVO;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessageSaveReqVO;
import cn.iocoder.yudao.module.ticket.dal.dataobject.uplinkMessage.UplinkMessageDO;
import cn.iocoder.yudao.module.ticket.service.uplinkMessage.UplinkMessageService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 上行报文")
@RestController
@RequestMapping("/ticket/uplinkMessage")
@Validated
public class UplinkMessageController {
@Resource
private UplinkMessageService Service;
@PostMapping("/create")
@Operation(summary = "创建上行报文")
@PreAuthorize("@ss.hasPermission('uplinkMessage::create')")
public CommonResult<Long> create(@Valid @RequestBody UplinkMessageSaveReqVO createReqVO) {
return success(Service.create(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新上行报文")
@PreAuthorize("@ss.hasPermission('uplinkMessage::update')")
public CommonResult<Boolean> update(@Valid @RequestBody UplinkMessageSaveReqVO updateReqVO) {
Service.update(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除上行报文")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('uplinkMessage::delete')")
public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
Service.delete(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得上行报文")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('uplinkMessage::query')")
public CommonResult<UplinkMessageRespVO> get(@RequestParam("id") Long id) {
UplinkMessageDO uplinkMessageDO = Service.get(id);
return success(BeanUtils.toBean(uplinkMessageDO, UplinkMessageRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得上行报文分页")
@PreAuthorize("@ss.hasPermission('uplinkMessage::query')")
public CommonResult<PageResult<UplinkMessageRespVO>> getPage(@Valid UplinkMessagePageReqVO pageReqVO) {
PageResult<UplinkMessageDO> pageResult = Service.getPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, UplinkMessageRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出上行报文 Excel")
@PreAuthorize("@ss.hasPermission('uplinkMessage::export')")
@ApiAccessLog(operateType = EXPORT)
public void exportExcel(@Valid UplinkMessagePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<UplinkMessageDO> list = Service.getPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "上行报文.xls", "数据", UplinkMessageRespVO.class,
BeanUtils.toBean(list, UplinkMessageRespVO.class));
}
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 上行报文分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class UplinkMessagePageReqVO extends PageParam {
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "上报时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] commitTime;
@Schema(description = "设备编号", example = "650")
private String deviceId;
@Schema(description = "设备名称", example = "芋艿")
private String deviceName;
@Schema(description = "状态", example = "1")
private Boolean status;
@Schema(description = "上行报文")
private String resBody;
@Schema(description = "备注", example = "你说的对")
private String remark;
}

View File

@ -0,0 +1,51 @@
package cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 上行报文 Response VO")
@Data
@ExcelIgnoreUnannotated
public class UplinkMessageRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4333")
@ExcelProperty("编号")
private Long id;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "上报时间")
@ExcelProperty("上报时间")
private LocalDateTime commitTime;
@Schema(description = "设备编号", example = "650")
@ExcelProperty("设备编号")
private String deviceId;
@Schema(description = "设备名称", example = "芋艿")
@ExcelProperty("设备名称")
private String deviceName;
@Schema(description = "状态", example = "1")
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat("uplink_message_status") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Boolean status;
@Schema(description = "上行报文", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("上行报文")
private String resBody;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty("备注")
private String remark;
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 上行报文新增/修改 Request VO")
@Data
public class UplinkMessageSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4333")
private Long id;
@Schema(description = "上报时间")
private LocalDateTime commitTime;
@Schema(description = "设备编号", example = "650")
private String deviceId;
@Schema(description = "设备名称", example = "芋艿")
private String deviceName;
@Schema(description = "状态", example = "1")
private Boolean status;
@Schema(description = "上行报文", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "上行报文不能为空")
private String resBody;
@Schema(description = "备注", example = "你说的对")
private String remark;
}

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.ticket.dal.dataobject.uplinkMessage;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 上行报文 DO
*
* @author 管理员
*/
@TableName("uplink_message")
@KeySequence("uplink_message_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UplinkMessageDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 上报时间
*/
private LocalDateTime commitTime;
/**
* 设备编号
*/
private String deviceId;
/**
* 设备名称
*/
private String deviceName;
/**
* 状态
*
* 枚举 {@link TODO uplink_message_status 对应的类}
*/
private Boolean status;
/**
* 上行报文
*/
private String resBody;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.ticket.dal.mysql.uplinkMessage;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessagePageReqVO;
import cn.iocoder.yudao.module.ticket.dal.dataobject.uplinkMessage.UplinkMessageDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 上行报文 Mapper
*
* @author 管理员
*/
@Mapper
public interface UplinkMessageMapper extends BaseMapperX<UplinkMessageDO> {
default PageResult<UplinkMessageDO> selectPage(UplinkMessagePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<UplinkMessageDO>()
.betweenIfPresent(UplinkMessageDO::getCreateTime, reqVO.getCreateTime())
.betweenIfPresent(UplinkMessageDO::getCommitTime, reqVO.getCommitTime())
.likeIfPresent(UplinkMessageDO::getDeviceId, reqVO.getDeviceId())
.likeIfPresent(UplinkMessageDO::getDeviceName, reqVO.getDeviceName())
.eqIfPresent(UplinkMessageDO::getStatus, reqVO.getStatus())
.likeIfPresent(UplinkMessageDO::getResBody, reqVO.getResBody())
.likeIfPresent(UplinkMessageDO::getRemark, reqVO.getRemark())
.orderByDesc(UplinkMessageDO::getId));
}
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.ticket.service.uplinkMessage;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessagePageReqVO;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessageSaveReqVO;
import cn.iocoder.yudao.module.ticket.dal.dataobject.uplinkMessage.UplinkMessageDO;
/**
* 上行报文 Service 接口
*
* @author 管理员
*/
public interface UplinkMessageService {
/**
* 创建上行报文
*
* @param createReqVO 创建信息
* @return 编号
*/
Long create(@Valid UplinkMessageSaveReqVO createReqVO);
/**
* 更新上行报文
*
* @param updateReqVO 更新信息
*/
void update(@Valid UplinkMessageSaveReqVO updateReqVO);
/**
* 删除上行报文
*
* @param id 编号
*/
void delete(Long id);
/**
* 获得上行报文
*
* @param id 编号
* @return 上行报文
*/
UplinkMessageDO get(Long id);
/**
* 获得上行报文分页
*
* @param pageReqVO 分页查询
* @return 上行报文分页
*/
PageResult<UplinkMessageDO> getPage(UplinkMessagePageReqVO pageReqVO);
}

View File

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.ticket.service.uplinkMessage;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessagePageReqVO;
import cn.iocoder.yudao.module.ticket.controller.admin.uplinkMessage.vo.UplinkMessageSaveReqVO;
import cn.iocoder.yudao.module.ticket.dal.dataobject.uplinkMessage.UplinkMessageDO;
import cn.iocoder.yudao.module.ticket.dal.mysql.uplinkMessage.UplinkMessageMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.ticket.enums.ErrorCodeConstants.UM_NOT_EXISTS;
/**
* 上行报文 Service 实现类
*
* @author 管理员
*/
@Service
@Validated
public class UplinkMessageServiceImpl implements UplinkMessageService {
@Resource
private UplinkMessageMapper Mapper;
@Override
public Long create(UplinkMessageSaveReqVO createReqVO) {
// 插入
UplinkMessageDO uplinkMessageDO = BeanUtils.toBean(createReqVO, UplinkMessageDO.class);
Mapper.insert(uplinkMessageDO);
// 返回
return uplinkMessageDO.getId();
}
@Override
public void update(UplinkMessageSaveReqVO updateReqVO) {
// 校验存在
validateExists(updateReqVO.getId());
// 更新
UplinkMessageDO updateObj = BeanUtils.toBean(updateReqVO, UplinkMessageDO.class);
Mapper.updateById(updateObj);
}
@Override
public void delete(Long id) {
// 校验存在
validateExists(id);
// 删除
Mapper.deleteById(id);
}
private void validateExists(Long id) {
if (Mapper.selectById(id) == null) {
throw exception(UM_NOT_EXISTS);
}
}
@Override
public UplinkMessageDO get(Long id) {
return Mapper.selectById(id);
}
@Override
public PageResult<UplinkMessageDO> getPage(UplinkMessagePageReqVO pageReqVO) {
return Mapper.selectPage(pageReqVO);
}
}