工单详情

This commit is contained in:
attiya 2025-11-27 09:20:51 +08:00
parent 1707795a58
commit 67f68b03a7
4 changed files with 42 additions and 30 deletions

View File

@ -42,9 +42,9 @@ public class EbikeBikeOrderController {
* @return 分页对象
*/
@GetMapping("page")
public JsonResult<?> page(PageParam page, Integer orderType,String bikeCode) {
public JsonResult<?> page(PageParam page, Integer orderType, String bikeCode) {
QueryWrapper queryWrapper = QueryWrapper.create()
.select(EBIKE_BIKE_INFO.LOCATION,EBIKE_BIKE_ORDER.ALL_COLUMNS)
.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)))
@ -60,7 +60,7 @@ public class EbikeBikeOrderController {
* @return 分页对象
*/
@GetMapping("getInfo")
public JsonResult<?> getInfo(Long orderId) {
public JsonResult<?> getInfo(@NotNull(message = "工单ID不能为空") Long orderId) {
EbikeBikeOrderInfoDto infoDto = ebikeBikeOrderService.getInfo(orderId);
return JsonResult.success(infoDto);
}
@ -93,12 +93,23 @@ public class EbikeBikeOrderController {
* 生成调度工单
*
* @param bikeCode 车辆编号
* @param siteId 站点ID目的地站点
* @return 结果
*/
@GetMapping("dispatchSwapOrder")
public JsonResult<?> dispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode,@NotNull(message = "站点ID不能为空")Long siteId) {
ebikeBikeOrderService.createDispatchSwapOrder(bikeCode,siteId);
public JsonResult<?> dispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode) {
ebikeBikeOrderService.createDispatchSwapOrder(bikeCode);
return JsonResult.success();
}
/**
* 接取工单
*
* @param orderId 工单ID
* @return 分页对象
*/
@GetMapping("acceptOrder")
public JsonResult<?> acceptOrder(@NotNull(message = "工单ID不能为空") Long orderId) {
ebikeBikeOrderService.acceptOrder(orderId);
return JsonResult.success();
}
}

View File

@ -29,9 +29,8 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
/**
* 根据车辆编号bikeCode生成车辆调度工单
* @param bikeCode 车辆编号
* @param siteId 站点ID目的地站点
*/
void createDispatchSwapOrder(String bikeCode,Long siteId);
void createDispatchSwapOrder(String bikeCode);
/**
* 工单详情
@ -39,4 +38,10 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
* @return 详情
*/
EbikeBikeOrderInfoDto getInfo(Long orderId);
/**
* 接取工单
* @param orderId 工单ID
*/
void acceptOrder(Long orderId);
}

View File

@ -324,6 +324,8 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
info.setLatestCyclingTime(LocalDateTime.now());
this.mapper.update(info);
//TODO清空redis中的为消耗调度工单工单调度状态修改为生效
}
@Override

View File

@ -1,19 +1,23 @@
package com.cdzy.operations.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.cdzy.common.ex.EbikeException;
import com.cdzy.common.model.dto.ResGPSDto;
import com.cdzy.operations.enums.BikeOrderType;
import com.cdzy.operations.enums.BikeStatus;
import com.cdzy.operations.enums.BikeUsageStatus;
import com.cdzy.operations.enums.RegionStatus;
import com.cdzy.operations.mapper.*;
import com.cdzy.operations.model.dto.EbikeBikeOrderInfoDto;
import com.cdzy.operations.model.entity.*;
import com.cdzy.operations.model.entity.EbikeBikeInfo;
import com.cdzy.operations.model.entity.EbikeBikeOrder;
import com.cdzy.operations.model.entity.EbikeOrderFile;
import com.cdzy.operations.model.entity.EbikeOrderPart;
import com.cdzy.operations.model.vo.InspectionSwapOrderVo;
import com.cdzy.operations.service.EbikeBikeOrderService;
import com.cdzy.operations.utils.RedisUtil;
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@ -45,12 +49,6 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
@Resource
EbikeBikeInfoMapper bikeInfoMapper;
@Resource
EbikeSiteMapper siteMapper;
@Resource
EbikeRegionMapper regionMapper;
@Resource
EbikeOrderPartMapper orderPartMapper;
@ -123,7 +121,7 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
@Transactional
@Override
public void createDispatchSwapOrder(String bikeCode,Long siteId) {
public void createDispatchSwapOrder(String bikeCode) {
EbikeBikeInfo bikeInfo = checkBikeCode(bikeCode);
QueryWrapper queryWrapper = QueryWrapper.create().where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(bikeInfo.getBikeCode()))
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.DISPATCH));
@ -133,24 +131,11 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
throw new EbikeException("车辆已存在调度工单");
}
EbikeSite ebikeSite = siteMapper.selectOneById(siteId);
if (ebikeSite == null) {
log.error("创建工单失败,站点不存在,siteId={} ", siteId);
throw new EbikeException("创建工单失败站点ID错误");
}
EbikeRegion region = regionMapper.selectOneById(ebikeSite.getRegionId());
if ( region.getStatus() == RegionStatus.OPERATION){
log.error("站点所属运营区不在运营中,regionId={} ", region.getRegionId());
throw new EbikeException("站点所属运营区不在运营中");
}
EbikeBikeOrder ebikeBikeOrder = EbikeBikeOrder.builder()
.bikeCode(bikeInfo.getBikeCode())
.orderCode(snowFlakeIDKeyGenerator.nextId())
.orderType(BikeOrderType.DISPATCH)
.operatorId(bikeInfo.getOperatorId())
.siteId(siteId)
.build();
this.mapper.insert(ebikeBikeOrder);
bikeInfo.setUsageStatus(BikeUsageStatus.DEPLOYED);
@ -172,6 +157,15 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
return infoDto;
}
@Override
public void acceptOrder(Long orderId) {
UpdateChain.of(EbikeBikeOrder.class)
.where(EBIKE_BIKE_ORDER.ORDER_ID.eq(orderId))
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.isNull())
.set(EBIKE_BIKE_ORDER.RECEIVER_ID, StpUtil.getLoginIdAsLong())
.update();
}
EbikeBikeInfo checkBikeCode(String bikeCode) {
QueryWrapper queryWrapper = QueryWrapper.create()
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))