68 lines
2.4 KiB
Java
68 lines
2.4 KiB
Java
package com.cdzy.ebikemaintenance.controller;
|
|
|
|
import com.cdzy.common.model.JsonResult;
|
|
import com.cdzy.common.model.PageParam;
|
|
import com.cdzy.ebikemaintenance.model.dto.response.ResEbikeInfoRegionDto;
|
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeBikeInfo;
|
|
import com.cdzy.ebikemaintenance.service.EbikeBikeInfoService;
|
|
import com.cdzy.ebikemaintenance.service.EbikeSystemInfoService;
|
|
import com.mybatisflex.core.paginate.Page;
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.List;
|
|
|
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
|
/**
|
|
* 运营车辆控制层
|
|
* @author attiya
|
|
* @since 2025-03-21
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/operation")
|
|
@Validated
|
|
public class EbikeOperationController {
|
|
|
|
@Resource
|
|
EbikeBikeInfoService bikeInfoService;
|
|
@Resource
|
|
private EbikeSystemInfoService ebikeSystemInfoService;
|
|
|
|
/**
|
|
* 运营车辆列表
|
|
* @return 运营车辆列表
|
|
*/
|
|
@GetMapping("page")
|
|
public JsonResult<?> page(PageParam pageParam) {
|
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
|
.where(EBIKE_BIKE_INFO.STATE.eq(1));
|
|
Page<EbikeBikeInfo> page = bikeInfoService.page(pageParam.getPage(), queryWrapper);
|
|
//汉化状态
|
|
page.getRecords().forEach(ebikeBikeInfo -> {
|
|
String bike_state = ebikeBikeInfo.getState();
|
|
if (bike_state == null || bike_state.isEmpty()) {
|
|
bike_state = "0";
|
|
}
|
|
bike_state = ebikeSystemInfoService.getEbikeCarStatusName(Integer.valueOf(bike_state));
|
|
ebikeBikeInfo.setState(bike_state);
|
|
});
|
|
return JsonResult.success(page);
|
|
}
|
|
|
|
/**
|
|
* 根据运营区id获取运营车辆状态及其位置信息列表
|
|
* @return 运营车辆列表
|
|
*/
|
|
@GetMapping("list")
|
|
public JsonResult<?> list(@RequestParam("operationRegionId")Long operationRegionId) {
|
|
List<ResEbikeInfoRegionDto> list = bikeInfoService.getOperationalBikeListWithGpsByRegionId(operationRegionId);
|
|
return JsonResult.success(list);
|
|
}
|
|
|
|
}
|