停车场-远程抬杠模块

This commit is contained in:
XinWei 2024-08-20 10:01:25 +08:00
parent 986a6be07d
commit f1d9bd23bc
10 changed files with 436 additions and 0 deletions

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.parking.controller.admin.liftingrod;
import cn.iocoder.yudao.module.parking.util.BlueCardResult;
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.*;
import cn.iocoder.yudao.module.parking.controller.admin.liftingrod.vo.*;
import cn.iocoder.yudao.module.parking.dal.dataobject.liftingrod.LiftingRodDO;
import cn.iocoder.yudao.module.parking.service.liftingrod.LiftingRodService;
@Tag(name = "管理后台 - 远程抬杠日志")
@RestController
@RequestMapping("/parking/lifting-rod")
@Validated
public class LiftingRodController {
@Resource
private LiftingRodService liftingRodService;
@PostMapping("/actionLiftingRod")
@Operation(summary = "下发远程抬杠指令")
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:create')")
public BlueCardResult actionLiftingRod(@RequestBody LiftingRodVo liftingRodVo){
return liftingRodService.doLiftingRod(liftingRodVo);
}
@PostMapping("/create")
@Operation(summary = "创建远程抬杠日志")
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:create')")
public CommonResult<Long> createLiftingRod(@Valid @RequestBody LiftingRodSaveReqVO createReqVO) {
return success(liftingRodService.createLiftingRod(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新远程抬杠日志")
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:update')")
public CommonResult<Boolean> updateLiftingRod(@Valid @RequestBody LiftingRodSaveReqVO updateReqVO) {
liftingRodService.updateLiftingRod(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除远程抬杠日志")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:delete')")
public CommonResult<Boolean> deleteLiftingRod(@RequestParam("id") Long id) {
liftingRodService.deleteLiftingRod(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得远程抬杠日志")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:query')")
public CommonResult<LiftingRodRespVO> getLiftingRod(@RequestParam("id") Long id) {
LiftingRodDO liftingRod = liftingRodService.getLiftingRod(id);
return success(BeanUtils.toBean(liftingRod, LiftingRodRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得远程抬杠日志分页")
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:query')")
public CommonResult<PageResult<LiftingRodRespVO>> getLiftingRodPage(@Valid LiftingRodPageReqVO pageReqVO) {
PageResult<LiftingRodDO> pageResult = liftingRodService.getLiftingRodPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, LiftingRodRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出远程抬杠日志 Excel")
@PreAuthorize("@ss.hasPermission('parking:lifting-rod:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportLiftingRodExcel(@Valid LiftingRodPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<LiftingRodDO> list = liftingRodService.getLiftingRodPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "远程抬杠日志.xls", "数据", LiftingRodRespVO.class,
BeanUtils.toBean(list, LiftingRodRespVO.class));
}
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.parking.controller.admin.liftingrod.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 LiftingRodPageReqVO extends PageParam {
@Schema(description = "停车场编号")
private String parkNumber;
@Schema(description = "通道Id", example = "10415")
private String passagewayId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "状态", example = "1")
private Integer status;
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.parking.controller.admin.liftingrod.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.*;
@Schema(description = "管理后台 - 远程抬杠日志 Response VO")
@Data
@ExcelIgnoreUnannotated
public class LiftingRodRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19179")
@ExcelProperty("id")
private Long id;
@Schema(description = "停车场编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("停车场编号")
private String parkNumber;
@Schema(description = "通道Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10415")
@ExcelProperty("通道Id")
private String passagewayId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "状态", example = "2")
@ExcelProperty("状态")
private Integer status;
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.parking.controller.admin.liftingrod.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 远程抬杠日志新增/修改 Request VO")
@Data
public class LiftingRodSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19179")
private Long id;
@Schema(description = "停车场编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "停车场编号不能为空")
private String parkNumber;
@Schema(description = "通道Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10415")
@NotEmpty(message = "通道Id不能为空")
private String passagewayId;
@Schema(description = "状态", example = "2")
private Integer status;
}

View File

@ -0,0 +1,9 @@
package cn.iocoder.yudao.module.parking.controller.admin.liftingrod.vo;
import lombok.Data;
@Data
public class LiftingRodVo {
private String parkNumber;
private String passagewayId;
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.parking.dal.dataobject.liftingrod;
import lombok.*;
import java.util.*;
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("lifting_rod")
@KeySequence("lifting_rod_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LiftingRodDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 停车场编号
*/
private String parkNumber;
/**
* 通道Id
*/
private String passagewayId;
/**
* 状态
*/
private Integer status;
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.parking.dal.mysql.liftingrod;
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.parking.dal.dataobject.liftingrod.LiftingRodDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.parking.controller.admin.liftingrod.vo.*;
/**
* 远程抬杠日志 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface LiftingRodMapper extends BaseMapperX<LiftingRodDO> {
default PageResult<LiftingRodDO> selectPage(LiftingRodPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<LiftingRodDO>()
.eqIfPresent(LiftingRodDO::getParkNumber, reqVO.getParkNumber())
.eqIfPresent(LiftingRodDO::getPassagewayId, reqVO.getPassagewayId())
.betweenIfPresent(LiftingRodDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(LiftingRodDO::getStatus, reqVO.getStatus())
.orderByDesc(LiftingRodDO::getId));
}
}

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.parking.service.liftingrod;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.parking.controller.admin.liftingrod.vo.*;
import cn.iocoder.yudao.module.parking.dal.dataobject.liftingrod.LiftingRodDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.parking.util.BlueCardResult;
/**
* 远程抬杠日志 Service 接口
*
* @author 芋道源码
*/
public interface LiftingRodService {
/**
* 创建远程抬杠日志
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createLiftingRod(@Valid LiftingRodSaveReqVO createReqVO);
/**
* 更新远程抬杠日志
*
* @param updateReqVO 更新信息
*/
void updateLiftingRod(@Valid LiftingRodSaveReqVO updateReqVO);
/**
* 删除远程抬杠日志
*
* @param id 编号
*/
void deleteLiftingRod(Long id);
/**
* 获得远程抬杠日志
*
* @param id 编号
* @return 远程抬杠日志
*/
LiftingRodDO getLiftingRod(Long id);
/**
* 获得远程抬杠日志分页
*
* @param pageReqVO 分页查询
* @return 远程抬杠日志分页
*/
PageResult<LiftingRodDO> getLiftingRodPage(LiftingRodPageReqVO pageReqVO);
/**
* 下发远程抬杠指令
* @param liftingRodVo
* @return cn.iocoder.yudao.module.parking.util.BlueCardResult
*/
BlueCardResult doLiftingRod(LiftingRodVo liftingRodVo);
}

View File

@ -0,0 +1,90 @@
package cn.iocoder.yudao.module.parking.service.liftingrod;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.parking.util.BlueCarRequestUtil;
import cn.iocoder.yudao.module.parking.util.BlueCardResult;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.module.parking.controller.admin.liftingrod.vo.*;
import cn.iocoder.yudao.module.parking.dal.dataobject.liftingrod.LiftingRodDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.parking.dal.mysql.liftingrod.LiftingRodMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.parking.enums.ErrorCodeConstants.*;
/**
* 远程抬杠日志 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class LiftingRodServiceImpl implements LiftingRodService {
@Resource
private LiftingRodMapper liftingRodMapper;
@Resource
private BlueCarRequestUtil blueCarRequestUtil;
@Override
public Long createLiftingRod(LiftingRodSaveReqVO createReqVO) {
// 插入
LiftingRodDO liftingRod = BeanUtils.toBean(createReqVO, LiftingRodDO.class);
liftingRodMapper.insert(liftingRod);
// 返回
return liftingRod.getId();
}
@Override
public void updateLiftingRod(LiftingRodSaveReqVO updateReqVO) {
// 校验存在
validateLiftingRodExists(updateReqVO.getId());
// 更新
LiftingRodDO updateObj = BeanUtils.toBean(updateReqVO, LiftingRodDO.class);
liftingRodMapper.updateById(updateObj);
}
@Override
public void deleteLiftingRod(Long id) {
// 校验存在
validateLiftingRodExists(id);
// 删除
liftingRodMapper.deleteById(id);
}
private void validateLiftingRodExists(Long id) {
if (liftingRodMapper.selectById(id) == null) {
throw exception(LIFTING_ROD_NOT_EXISTS);
}
}
@Override
public LiftingRodDO getLiftingRod(Long id) {
return liftingRodMapper.selectById(id);
}
@Override
public PageResult<LiftingRodDO> getLiftingRodPage(LiftingRodPageReqVO pageReqVO) {
return liftingRodMapper.selectPage(pageReqVO);
}
@Override
public BlueCardResult doLiftingRod(LiftingRodVo liftingRodVo) {
// 下发抬杠指令
CommonResult<String> stringCommonResult = blueCarRequestUtil.doBlueCarPost(liftingRodVo, "bcopenapi/out/RemoteLiftRod");
LiftingRodDO liftingRod = new LiftingRodDO();
liftingRod.setParkNumber(liftingRodVo.getParkNumber());
liftingRod.setPassagewayId(liftingRodVo.getPassagewayId());
//具体逻辑到联调时实现
// liftingRod.setStatus();
// 记录抬杠记录
liftingRodMapper.insert(liftingRod);
return null;
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.parking.dal.mysql.liftingrod.LiftingRodMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>