调度工单
This commit is contained in:
parent
7ef5dd4baf
commit
9ab1fab011
@ -45,7 +45,7 @@ public class EbikeBikeOrderController {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.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.eq(bikeCode, StringUtil.hasText(bikeCode)));
|
||||
.where(EBIKE_BIKE_ORDER.BIKE_CODE.like(bikeCode, StringUtil.hasText(bikeCode)));
|
||||
Page<EbikeBikeOrder> orderPage = ebikeBikeOrderService.page(page.getPage(), queryWrapper);
|
||||
return JsonResult.success(orderPage);
|
||||
}
|
||||
@ -73,4 +73,17 @@ public class EbikeBikeOrderController {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,19 +26,8 @@ public interface BikeUsageStatus {
|
||||
*/
|
||||
int REPAIR = 3;
|
||||
|
||||
/**
|
||||
* 调度中
|
||||
*/
|
||||
int DISPATCH = 4;
|
||||
|
||||
|
||||
/**
|
||||
* 维修中
|
||||
*/
|
||||
int UNDER_REPAIR = 5;
|
||||
|
||||
/**
|
||||
* 待调度
|
||||
*/
|
||||
int DEPLOYED = 6;
|
||||
int DEPLOYED = 4;
|
||||
}
|
||||
|
||||
@ -107,4 +107,9 @@ public class EbikeBikeOrder implements Serializable {
|
||||
*/
|
||||
private Long createdBy;
|
||||
|
||||
/**
|
||||
* 站点ID
|
||||
*/
|
||||
private Long siteId;
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||
/**
|
||||
* 根据车辆编号(bikeCode)生成车辆调度工单
|
||||
* @param bikeCode 车辆编号
|
||||
* @param siteId 站点ID(目的地站点)
|
||||
*/
|
||||
void createDispatchSwapOrder(String bikeCode);
|
||||
void createDispatchSwapOrder(String bikeCode,Long siteId);
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
throw new EbikeException("车辆已被占用");
|
||||
}
|
||||
|
||||
if (info.getUsageStatus() == BikeUsageStatus.REPAIR || info.getUsageStatus() == BikeUsageStatus.UNDER_REPAIR) {
|
||||
if (info.getUsageStatus() == BikeUsageStatus.REPAIR) {
|
||||
throw new EbikeException("车辆故障");
|
||||
}
|
||||
query.clear();
|
||||
|
||||
@ -3,11 +3,13 @@ package com.cdzy.operations.service.impl;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.enums.BikeOrderType;
|
||||
import com.cdzy.operations.enums.BikeStatus;
|
||||
import com.cdzy.operations.mapper.EbikeBikeInfoMapper;
|
||||
import com.cdzy.operations.mapper.EbikeBikeOrderMapper;
|
||||
import com.cdzy.operations.mapper.EbikeEcuInfoMapper;
|
||||
import com.cdzy.operations.enums.BikeUsageStatus;
|
||||
import com.cdzy.operations.enums.RegionStatus;
|
||||
import com.cdzy.operations.mapper.*;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||
import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||
import com.cdzy.operations.model.entity.EbikeSite;
|
||||
import com.cdzy.operations.service.EbikeBikeOrderService;
|
||||
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@ -15,6 +17,7 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
import static com.cdzy.operations.model.entity.table.EbikeBikeOrderTableDef.EBIKE_BIKE_ORDER;
|
||||
@ -38,6 +41,12 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
@Resource
|
||||
EbikeBikeInfoMapper bikeInfoMapper;
|
||||
|
||||
@Resource
|
||||
EbikeSiteMapper siteMapper;
|
||||
|
||||
@Resource
|
||||
EbikeRegionMapper regionMapper;
|
||||
|
||||
@Override
|
||||
public void createBatterySwapOrder(String ecuSn) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
@ -86,8 +95,9 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
this.mapper.insert(ebikeBikeOrder);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void createDispatchSwapOrder(String bikeCode) {
|
||||
public void createDispatchSwapOrder(String bikeCode,Long siteId) {
|
||||
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));
|
||||
@ -96,13 +106,29 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
log.error("车辆已存在调度工单,bikeCode={} ", bikeInfo.getBikeCode());
|
||||
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);
|
||||
bikeInfoMapper.update(bikeInfo);
|
||||
}
|
||||
|
||||
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user