167 lines
4.6 KiB
Java
167 lines
4.6 KiB
Java
package com.cdzy.operations.controller;
|
|
|
|
import com.cdzy.common.model.request.PageParam;
|
|
import com.cdzy.common.model.response.JsonResult;
|
|
import com.cdzy.operations.model.dto.EbikeEcuInOverview;
|
|
import com.cdzy.operations.model.entity.EbikeEcuInfo;
|
|
import com.cdzy.operations.model.vo.EbikeEcuInfoBatchVo;
|
|
import com.cdzy.operations.model.vo.EbikeEcuInfoVo;
|
|
import com.cdzy.operations.service.EbikeEcuInfoService;
|
|
import com.mybatisflex.core.paginate.Page;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.validation.constraints.NotNull;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 中控基本信息 控制层。
|
|
*
|
|
* @author attiya
|
|
* @since 2025-09-15
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/ebikeEcuInfo")
|
|
@Validated
|
|
public class EbikeEcuInfoController {
|
|
|
|
@Resource
|
|
private EbikeEcuInfoService ebikeEcuInfoService;
|
|
|
|
/**
|
|
* 中控入库。
|
|
*
|
|
* @param ebikeEcuInfo 中控基本信息
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
*/
|
|
@PostMapping("save")
|
|
public JsonResult<?> saveEcu(@Validated @RequestBody EbikeEcuInfoVo ebikeEcuInfo) {
|
|
ebikeEcuInfoService.saveEcu(ebikeEcuInfo);
|
|
return JsonResult.success();
|
|
}
|
|
|
|
/**
|
|
* 批量入库。
|
|
*
|
|
* @param batchVo 中控信息
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
*/
|
|
@PostMapping("batchSave")
|
|
public JsonResult<?> batchSave(@Validated @RequestBody EbikeEcuInfoBatchVo batchVo) {
|
|
ebikeEcuInfoService.batchSave(batchVo);
|
|
return JsonResult.success();
|
|
}
|
|
|
|
/**
|
|
* 根据主键删除中控基本信息。
|
|
*
|
|
* @param ecuId 主键
|
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
*/
|
|
@GetMapping("remove")
|
|
public JsonResult<?> remove(@RequestParam("ecuId") Long ecuId) {
|
|
ebikeEcuInfoService.removeById(ecuId);
|
|
return JsonResult.success();
|
|
}
|
|
|
|
/**
|
|
* 根据主键更新中控基本信息。
|
|
*
|
|
* @param ebikeEcuInfo 中控基本信息
|
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
*/
|
|
@PostMapping("update")
|
|
public JsonResult<?> update(@RequestBody EbikeEcuInfo ebikeEcuInfo) {
|
|
ebikeEcuInfoService.updateById(ebikeEcuInfo);
|
|
return JsonResult.success();
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询所有中控基本信息。
|
|
*
|
|
* @return 所有数据
|
|
*/
|
|
@GetMapping("list")
|
|
public JsonResult<?> list() {
|
|
List<EbikeEcuInfo> list = ebikeEcuInfoService.list();
|
|
return JsonResult.success(list);
|
|
}
|
|
|
|
|
|
/**
|
|
* 中控总览。
|
|
*
|
|
* @return 所有数据
|
|
*/
|
|
@GetMapping("overview")
|
|
public JsonResult<?> overview() {
|
|
List<EbikeEcuInOverview> list = ebikeEcuInfoService.overview();
|
|
return JsonResult.success(list);
|
|
}
|
|
|
|
/**
|
|
* 根据中控基本信息主键获取详细信息。
|
|
*
|
|
* @param ecuId 中控基本信息主键
|
|
* @return 中控基本信息详情
|
|
*/
|
|
@GetMapping("getInfo")
|
|
public JsonResult<?> getInfo(@RequestParam("ecuId") Long ecuId) {
|
|
EbikeEcuInfo info = ebikeEcuInfoService.getById(ecuId);
|
|
return JsonResult.success(info);
|
|
}
|
|
|
|
/**
|
|
* 分页查询中控基本信息。
|
|
*
|
|
* @param pageParam 分页对象
|
|
* @return 分页对象
|
|
*/
|
|
@GetMapping("page")
|
|
public JsonResult<?> page(PageParam pageParam) {
|
|
Page<EbikeEcuInfo> paged = ebikeEcuInfoService.page(pageParam.getPage());
|
|
return JsonResult.success(paged);
|
|
}
|
|
|
|
|
|
/**
|
|
* 校验SN或BikeCode
|
|
*
|
|
* @return 执行结构
|
|
*/
|
|
@GetMapping("checkSnOrBikeCode")
|
|
public JsonResult<?> checkSnOrBikeCode(String ecuSn,String bikeCode) {
|
|
boolean result = ebikeEcuInfoService.checkSnOrBikeCode(ecuSn,bikeCode);
|
|
return JsonResult.success(result);
|
|
}
|
|
|
|
|
|
/**
|
|
* 设备是否在线
|
|
*
|
|
* @return 执行结构
|
|
*/
|
|
@GetMapping("online")
|
|
public JsonResult<?> online(String ecuSn,String bikeCode) throws IOException {
|
|
boolean online = ebikeEcuInfoService.online(ecuSn,bikeCode);
|
|
return JsonResult.success(online);
|
|
}
|
|
|
|
|
|
/**
|
|
* 执行命令
|
|
*
|
|
* @return 执行结构
|
|
*/
|
|
@GetMapping("executeCommand")
|
|
public JsonResult<?> executeCommand(String ecuSn,String bikeCode,@NotNull(message = "命令编码不能为空") String commandCode) {
|
|
boolean findBike = ebikeEcuInfoService.executeCommand(ecuSn,bikeCode,commandCode);
|
|
return JsonResult.success(findBike);
|
|
}
|
|
|
|
|
|
}
|