2025-11-24 16:02:55 +08:00
|
|
|
|
package com.cdzy.operations.controller;
|
|
|
|
|
|
|
2025-11-27 15:22:19 +08:00
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
2025-11-27 10:25:20 +08:00
|
|
|
|
import com.cdzy.common.enums.Message;
|
2025-11-25 10:37:06 +08:00
|
|
|
|
import com.cdzy.common.model.request.PageParam;
|
|
|
|
|
|
import com.cdzy.common.model.response.JsonResult;
|
|
|
|
|
|
import com.cdzy.operations.enums.BikeOrderHandleState;
|
2025-11-26 14:42:54 +08:00
|
|
|
|
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
|
2025-12-04 16:20:44 +08:00
|
|
|
|
import com.cdzy.operations.model.dto.EbikeOrderBikeListDto;
|
2025-11-25 17:39:59 +08:00
|
|
|
|
import com.cdzy.operations.model.dto.EbikeBikeOrderPageDto;
|
2025-12-03 16:45:32 +08:00
|
|
|
|
import com.cdzy.operations.model.dto.EbikeOrderBikeInfoDto;
|
2025-12-05 17:35:30 +08:00
|
|
|
|
import com.cdzy.operations.model.vo.*;
|
2025-11-24 16:02:55 +08:00
|
|
|
|
import com.cdzy.operations.service.EbikeBikeOrderService;
|
|
|
|
|
|
import com.mybatisflex.core.paginate.Page;
|
2025-11-25 10:37:06 +08:00
|
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
|
|
|
import com.mybatisflex.core.util.StringUtil;
|
2025-11-24 16:02:55 +08:00
|
|
|
|
import jakarta.annotation.Resource;
|
2025-11-25 10:46:54 +08:00
|
|
|
|
import jakarta.validation.constraints.NotNull;
|
2025-11-25 10:37:06 +08:00
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2025-11-26 10:42:39 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2025-11-27 10:25:20 +08:00
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
2025-11-24 16:02:55 +08:00
|
|
|
|
|
2025-12-05 10:45:04 +08:00
|
|
|
|
import java.io.IOException;
|
2025-12-04 16:20:44 +08:00
|
|
|
|
import java.util.List;
|
2025-11-25 10:37:06 +08:00
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
2025-11-25 17:39:59 +08:00
|
|
|
|
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
2025-11-25 10:37:06 +08:00
|
|
|
|
import static com.cdzy.operations.model.entity.table.EbikeBikeOrderTableDef.EBIKE_BIKE_ORDER;
|
2025-11-24 16:02:55 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 工单信息 控制层。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author attiya
|
|
|
|
|
|
* @since 2025-11-24
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/ebikeBikeOrder")
|
2025-11-25 10:37:06 +08:00
|
|
|
|
@Validated
|
2025-11-24 16:02:55 +08:00
|
|
|
|
public class EbikeBikeOrderController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
private EbikeBikeOrderService ebikeBikeOrderService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-25 10:37:06 +08:00
|
|
|
|
* 分页查询工单信息。
|
2025-11-24 16:02:55 +08:00
|
|
|
|
*
|
2025-11-25 10:37:06 +08:00
|
|
|
|
* @param page 分页对象
|
|
|
|
|
|
* @return 分页对象
|
2025-11-24 16:02:55 +08:00
|
|
|
|
*/
|
2025-11-25 10:37:06 +08:00
|
|
|
|
@GetMapping("page")
|
2025-11-27 09:20:51 +08:00
|
|
|
|
public JsonResult<?> page(PageParam page, Integer orderType, String bikeCode) {
|
2025-11-25 10:37:06 +08:00
|
|
|
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
2025-11-27 09:20:51 +08:00
|
|
|
|
.select(EBIKE_BIKE_INFO.LOCATION, EBIKE_BIKE_ORDER.ALL_COLUMNS)
|
2025-11-25 10:37:06 +08:00
|
|
|
|
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(BikeOrderHandleState.UNPROCESSED))
|
|
|
|
|
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(orderType, Objects.nonNull(orderType)))
|
2025-11-26 09:31:56 +08:00
|
|
|
|
.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));
|
2025-11-25 17:39:59 +08:00
|
|
|
|
Page<EbikeBikeOrderPageDto> orderPage = ebikeBikeOrderService.pageAs(page.getPage(), queryWrapper, EbikeBikeOrderPageDto.class);
|
2025-11-25 10:37:06 +08:00
|
|
|
|
return JsonResult.success(orderPage);
|
2025-11-24 16:02:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-27 15:22:19 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 分页查询当前员工接取的工单信息。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param page 分页对象
|
|
|
|
|
|
* @return 分页对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("pageByStaff")
|
|
|
|
|
|
public JsonResult<?> pageByStaff(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.RECEIVED))
|
|
|
|
|
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(orderType, Objects.nonNull(orderType)))
|
|
|
|
|
|
.where(EBIKE_BIKE_ORDER.BIKE_CODE.like(bikeCode, StringUtil.hasText(bikeCode)))
|
|
|
|
|
|
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.eq(StpUtil.getLoginIdAsLong()))
|
|
|
|
|
|
.leftJoin(EBIKE_BIKE_INFO).on(EBIKE_BIKE_INFO.BIKE_CODE.eq(EBIKE_BIKE_ORDER.BIKE_CODE))
|
|
|
|
|
|
.orderBy(EBIKE_BIKE_ORDER.CREATED_AT.desc());
|
|
|
|
|
|
Page<EbikeBikeOrderPageDto> orderPage = ebikeBikeOrderService.pageAs(page.getPage(), queryWrapper, EbikeBikeOrderPageDto.class);
|
|
|
|
|
|
return JsonResult.success(orderPage);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-26 11:11:05 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 工单详情。
|
|
|
|
|
|
*
|
2025-11-26 14:42:54 +08:00
|
|
|
|
* @param orderId 工单ID
|
2025-11-26 11:11:05 +08:00
|
|
|
|
* @return 分页对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("getInfo")
|
2025-11-27 09:20:51 +08:00
|
|
|
|
public JsonResult<?> getInfo(@NotNull(message = "工单ID不能为空") Long orderId) {
|
2025-11-26 14:42:54 +08:00
|
|
|
|
EbikeBikeOrderInfoDto infoDto = ebikeBikeOrderService.getInfo(orderId);
|
|
|
|
|
|
return JsonResult.success(infoDto);
|
2025-11-26 11:11:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-24 16:02:55 +08:00
|
|
|
|
/**
|
2025-11-25 10:37:06 +08:00
|
|
|
|
* 生成换电工单。
|
2025-11-24 16:02:55 +08:00
|
|
|
|
*
|
2025-11-25 10:37:06 +08:00
|
|
|
|
* @param ecuSn 中控编码
|
|
|
|
|
|
* @return 结果
|
2025-11-24 16:02:55 +08:00
|
|
|
|
*/
|
2025-11-25 10:37:06 +08:00
|
|
|
|
@GetMapping("batterySwapOrder")
|
2025-11-25 10:46:54 +08:00
|
|
|
|
public JsonResult<?> batterySwapOrder(@NotNull(message = "中控编号不能为空") String ecuSn) {
|
2025-11-25 10:37:06 +08:00
|
|
|
|
ebikeBikeOrderService.createBatterySwapOrder(ecuSn);
|
|
|
|
|
|
return JsonResult.success();
|
2025-11-24 16:02:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 10:46:54 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 生成巡检工单。
|
|
|
|
|
|
*
|
2025-11-26 10:42:39 +08:00
|
|
|
|
* @param inspectionSwapOrderVo 巡检信息
|
2025-11-25 10:46:54 +08:00
|
|
|
|
* @return 结果
|
|
|
|
|
|
*/
|
2025-11-26 10:42:39 +08:00
|
|
|
|
@PostMapping("inspectionSwapOrder")
|
|
|
|
|
|
public JsonResult<?> inspectionSwapOrder(@Validated @RequestBody InspectionSwapOrderVo inspectionSwapOrderVo) {
|
|
|
|
|
|
ebikeBikeOrderService.createInspectionSwapOrder(inspectionSwapOrderVo);
|
2025-11-25 10:46:54 +08:00
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
2025-11-25 17:35:21 +08:00
|
|
|
|
|
2025-12-05 17:35:30 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 完成巡检工单。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("doInspection")
|
|
|
|
|
|
public JsonResult<?> doInspection(@RequestBody @Validated DoneInspectionVo inspectionVo) {
|
|
|
|
|
|
ebikeBikeOrderService.doInspection(inspectionVo);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
2025-12-05 10:45:04 +08:00
|
|
|
|
|
2025-11-25 17:35:21 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 生成调度工单。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param bikeCode 车辆编号
|
|
|
|
|
|
* @return 结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("dispatchSwapOrder")
|
2025-11-27 09:20:51 +08:00
|
|
|
|
public JsonResult<?> dispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode) {
|
|
|
|
|
|
ebikeBikeOrderService.createDispatchSwapOrder(bikeCode);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-27 10:25:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 生成维修工单。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param faultOrderVo 故障信息
|
|
|
|
|
|
* @return 结果
|
|
|
|
|
|
*/
|
2025-11-27 16:41:28 +08:00
|
|
|
|
@PostMapping("faultOrder")
|
2025-11-27 10:25:20 +08:00
|
|
|
|
public JsonResult<?> faultOrder(@Validated @RequestBody FaultOrderVo faultOrderVo) {
|
|
|
|
|
|
ebikeBikeOrderService.faultOrder(faultOrderVo);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-27 09:20:51 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 接取工单。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param orderId 工单ID
|
|
|
|
|
|
* @return 分页对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("acceptOrder")
|
|
|
|
|
|
public JsonResult<?> acceptOrder(@NotNull(message = "工单ID不能为空") Long orderId) {
|
|
|
|
|
|
ebikeBikeOrderService.acceptOrder(orderId);
|
2025-11-25 17:35:21 +08:00
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
2025-11-27 10:25:20 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 上传远程故障图片
|
2025-12-01 21:48:21 +08:00
|
|
|
|
*
|
2025-11-27 10:25:20 +08:00
|
|
|
|
* @param file 文件
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("upload")
|
|
|
|
|
|
public JsonResult<?> upload(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
|
|
|
String result = ebikeBikeOrderService.upload(file);
|
2025-12-01 21:48:21 +08:00
|
|
|
|
return JsonResult.success(Message.SUCCESS, result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 电池二维码检查(换电工单用,包含带电池中控二维码)
|
|
|
|
|
|
* @param code 电池二维码
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("checkCode")
|
|
|
|
|
|
public JsonResult<?> checkCode(@NotNull(message = "二维码不能为空")String code) {
|
|
|
|
|
|
ebikeBikeOrderService.checkCode(code);
|
|
|
|
|
|
return JsonResult.success(Message.SUCCESS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 领取电池(换电工单用)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("batteryClaim")
|
|
|
|
|
|
public JsonResult<?> batteryClaim(@Validated @RequestBody EbikeBatteryClaimReturnVo batteryClaimVo) {
|
|
|
|
|
|
ebikeBikeOrderService.batteryClaim(batteryClaimVo);
|
|
|
|
|
|
return JsonResult.success(Message.SUCCESS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 归还电池(换电工单用)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("batteryReturn")
|
|
|
|
|
|
public JsonResult<?> batteryReturn(@Validated @RequestBody EbikeBatteryClaimReturnVo batteryClaimVo) {
|
|
|
|
|
|
ebikeBikeOrderService.batteryReturn(batteryClaimVo);
|
|
|
|
|
|
return JsonResult.success(Message.SUCCESS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-12-05 10:45:04 +08:00
|
|
|
|
* 更换电池(换电工单用,完成换电工单)
|
2025-12-01 21:48:21 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("batteryChange")
|
|
|
|
|
|
public JsonResult<?> batteryChange(@Validated @RequestBody EbikeBatteryChangeVo changeVo) {
|
|
|
|
|
|
ebikeBikeOrderService.batteryChange(changeVo);
|
2025-12-04 14:19:22 +08:00
|
|
|
|
return JsonResult.success();
|
2025-11-27 10:25:20 +08:00
|
|
|
|
}
|
2025-12-03 16:45:32 +08:00
|
|
|
|
|
2025-12-05 10:45:04 +08:00
|
|
|
|
// /**
|
|
|
|
|
|
// * 完成调度工单。
|
|
|
|
|
|
// *
|
|
|
|
|
|
// * @param bikeCode 车辆编号
|
|
|
|
|
|
// * @return 结果
|
|
|
|
|
|
// */
|
|
|
|
|
|
// @GetMapping("bikeDispatch")
|
|
|
|
|
|
// public JsonResult<?> bikeDispatch(@NotNull(message = "车辆编号不能为空") String bikeCode,@NotNull(message = "站点ID不能为空")Long siteId) {
|
|
|
|
|
|
// ebikeBikeOrderService.bikeDispatch(bikeCode,siteId);
|
|
|
|
|
|
// return JsonResult.success();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
2025-12-04 16:20:44 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 车辆列表(工单用)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("bikeList")
|
2025-12-05 10:45:04 +08:00
|
|
|
|
public JsonResult<List<EbikeOrderBikeListDto>> bikeList(@RequestParam("regionId") Long regionId) throws IOException {
|
2025-12-04 16:20:44 +08:00
|
|
|
|
List<EbikeOrderBikeListDto> list = ebikeBikeOrderService.bikeList(regionId);
|
|
|
|
|
|
return JsonResult.success(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-03 16:45:32 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 车辆详情(工单用)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("bikeInfo")
|
2025-12-05 17:35:30 +08:00
|
|
|
|
public JsonResult<EbikeOrderBikeInfoDto> bikeInfo(@RequestParam("bikeCode") String bikeCode) throws IOException {
|
2025-12-03 16:45:32 +08:00
|
|
|
|
EbikeOrderBikeInfoDto info = ebikeBikeOrderService.bikeInfo(bikeCode);
|
|
|
|
|
|
return JsonResult.success(info);
|
|
|
|
|
|
}
|
2025-11-24 16:02:55 +08:00
|
|
|
|
}
|