68 lines
2.4 KiB
Java
Raw Normal View History

2025-04-14 09:35:36 +08:00
package com.cdzy.ebikemaintenance.controller;
import com.cdzy.common.model.JsonResult;
import com.cdzy.common.model.PageParam;
2025-06-04 15:38:53 +08:00
import com.cdzy.ebikemaintenance.model.dto.response.ResEbikeInfoRegionDto;
2025-04-14 09:35:36 +08:00
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;
2025-06-04 15:38:53 +08:00
import org.springframework.web.bind.annotation.RequestParam;
2025-04-14 09:35:36 +08:00
import org.springframework.web.bind.annotation.RestController;
2025-06-04 15:38:53 +08:00
import java.util.List;
2025-04-14 09:35:36 +08:00
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);
}
2025-06-04 15:38:53 +08:00
/**
* 根据运营区id获取运营车辆状态及其位置信息列表
* @return 运营车辆列表
*/
@GetMapping("list")
public JsonResult<?> list(@RequestParam("operationRegionId")Long operationRegionId) {
List<ResEbikeInfoRegionDto> list = bikeInfoService.getOperationalBikeListWithGpsByRegionId(operationRegionId);
return JsonResult.success(list);
}
2025-04-14 09:35:36 +08:00
}