批量生成调度工单
This commit is contained in:
parent
1275b92ad1
commit
21b0f5d0b9
@ -137,6 +137,30 @@ public class EbikeBikeOrderController {
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验车辆是否可以生成调度工单。
|
||||
*
|
||||
* @param bikeCode 车辆编号
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("checkDispatchSwapOrder")
|
||||
public JsonResult<Boolean> checkDispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode) {
|
||||
Boolean checked = ebikeBikeOrderService.checkDispatchSwapOrder(bikeCode);
|
||||
return JsonResult.success(checked);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量生成调度工单。
|
||||
*
|
||||
* @param dispatchSwapVo 车辆编号
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("dispatchSwapOrders")
|
||||
public JsonResult<?> dispatchSwapOrders(@RequestBody @Validated DispatchSwapVo dispatchSwapVo) {
|
||||
ebikeBikeOrderService.createDispatchSwapOrders(dispatchSwapVo);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成维修工单。
|
||||
*
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.cdzy.operations.model.vo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DispatchSwapVo {
|
||||
@NotNull(message = "车辆编号不能为空")
|
||||
private List<String> bikeCodes;
|
||||
|
||||
@NotNull(message = "是否接单不能为空")
|
||||
private Boolean acceptOrders;
|
||||
}
|
||||
@ -5,6 +5,7 @@ import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||
import com.cdzy.operations.model.vo.*;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -143,4 +144,17 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||
* @return 结果
|
||||
*/
|
||||
EbikeOrderUnfinishedInfo unfinishedOrders();
|
||||
|
||||
/**
|
||||
* 批量生成工单信息
|
||||
* @param dispatchSwapVo 车辆编号
|
||||
*/
|
||||
void createDispatchSwapOrders(DispatchSwapVo dispatchSwapVo);
|
||||
|
||||
/**
|
||||
* 校验车辆是否已存在调度工单。
|
||||
*
|
||||
* @param bikeCode 车辆编号
|
||||
*/
|
||||
Boolean checkDispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode);
|
||||
}
|
||||
|
||||
@ -811,6 +811,52 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDispatchSwapOrders(DispatchSwapVo dispatchSwapVo) {
|
||||
List<String> bikeCodes = dispatchSwapVo.getBikeCodes();
|
||||
QueryWrapper queryWrapper = new QueryWrapper()
|
||||
.select(EBIKE_BIKE_INFO.OPERATOR_ID)
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.in(bikeCodes))
|
||||
.groupBy(EBIKE_BIKE_INFO.OPERATOR_ID);
|
||||
long count = bikeInfoMapper.selectCountByQuery(queryWrapper);
|
||||
if (count > 1) {
|
||||
throw new EbikeException("该列表中同时存在不同运营商的车辆");
|
||||
}
|
||||
queryWrapper.clear();
|
||||
queryWrapper.select(EBIKE_BIKE_INFO.OPERATOR_ID)
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCodes.get(0)))
|
||||
.groupBy(EBIKE_BIKE_INFO.OPERATOR_ID);
|
||||
Long operatorId = bikeInfoMapper.selectOneByQueryAs(queryWrapper, Long.class);
|
||||
List<EbikeBikeOrder> list = new ArrayList<>();
|
||||
long staffId = StpUtil.getLoginIdAsLong();
|
||||
for (String bikeCode : bikeCodes) {
|
||||
EbikeBikeOrder ebikeBikeOrder = EbikeBikeOrder.builder()
|
||||
.bikeCode(bikeCode)
|
||||
.orderCode(snowFlakeIDKeyGenerator.nextId())
|
||||
.orderType(BikeOrderType.DISPATCH)
|
||||
.operatorId(operatorId)
|
||||
.dispatchState(OrderDispatchState.PROCESSED)
|
||||
.build();
|
||||
if (dispatchSwapVo.getAcceptOrders()) {
|
||||
ebikeBikeOrder.setReceiverId(staffId);
|
||||
}
|
||||
list.add(ebikeBikeOrder);
|
||||
}
|
||||
this.mapper.insertBatch(list);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkDispatchSwapOrder(String bikeCode) {
|
||||
checkBikeCode(bikeCode);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(bikeCode))
|
||||
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.ne(OrderHandleState.PROCESSED))
|
||||
.and(EBIKE_BIKE_ORDER.HANDLE_STATE.ne(OrderHandleState.VOIDED));
|
||||
EbikeBikeInfo ebikeBikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
|
||||
return ebikeBikeInfo == null;
|
||||
}
|
||||
|
||||
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user