93 lines
3.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.cdzy.operations.controller;
import com.cdzy.common.model.request.PageParam;
import com.cdzy.common.model.response.JsonResult;
import com.cdzy.operations.enums.BikeOrderHandleState;
import com.cdzy.operations.model.dto.EbikeBikeOrderPageDto;
import com.cdzy.operations.service.EbikeBikeOrderService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.util.StringUtil;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
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.RestController;
import java.util.Objects;
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
import static com.cdzy.operations.model.entity.table.EbikeBikeOrderTableDef.EBIKE_BIKE_ORDER;
/**
* 工单信息 控制层。
*
* @author attiya
* @since 2025-11-24
*/
@RestController
@RequestMapping("/ebikeBikeOrder")
@Validated
public class EbikeBikeOrderController {
@Resource
private EbikeBikeOrderService ebikeBikeOrderService;
/**
* 分页查询工单信息。
*
* @param page 分页对象
* @return 分页对象
*/
@GetMapping("page")
public JsonResult<?> page(PageParam page, Integer orderType,String bikeCode) {
QueryWrapper queryWrapper = QueryWrapper.create()
.select(EBIKE_BIKE_INFO.LOCATION,EBIKE_BIKE_ORDER.ALL_COLUMNS)
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(BikeOrderHandleState.UNPROCESSED))
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(orderType, Objects.nonNull(orderType)))
.where(EBIKE_BIKE_ORDER.BIKE_CODE.like(bikeCode, StringUtil.hasText(bikeCode)))
.leftJoin(EBIKE_BIKE_INFO).on(EBIKE_BIKE_INFO.BIKE_CODE.eq(EBIKE_BIKE_ORDER.BIKE_CODE));
Page<EbikeBikeOrderPageDto> orderPage = ebikeBikeOrderService.pageAs(page.getPage(), queryWrapper, EbikeBikeOrderPageDto.class);
return JsonResult.success(orderPage);
}
/**
* 生成换电工单。
*
* @param ecuSn 中控编码
* @return 结果
*/
@GetMapping("batterySwapOrder")
public JsonResult<?> batterySwapOrder(@NotNull(message = "中控编号不能为空") String ecuSn) {
ebikeBikeOrderService.createBatterySwapOrder(ecuSn);
return JsonResult.success();
}
/**
* 生成巡检工单。
*
* @param bikeCode 车辆编号
* @return 结果
*/
@GetMapping("inspectionSwapOrder")
public JsonResult<?> inspectionSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode) {
ebikeBikeOrderService.createInspectionSwapOrder(bikeCode);
return JsonResult.success();
}
/**
* 生成调度工单。
*
* @param bikeCode 车辆编号
* @param siteId 站点ID目的地站点
* @return 结果
*/
@GetMapping("dispatchSwapOrder")
public JsonResult<?> dispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode,@NotNull(message = "站点ID不能为空")Long siteId) {
ebikeBikeOrderService.createDispatchSwapOrder(bikeCode,siteId);
return JsonResult.success();
}
}