批量完成调度工单
This commit is contained in:
parent
e7870785bd
commit
6a13689090
@ -4,7 +4,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
|||||||
import com.cdzy.common.enums.Message;
|
import com.cdzy.common.enums.Message;
|
||||||
import com.cdzy.common.model.request.PageParam;
|
import com.cdzy.common.model.request.PageParam;
|
||||||
import com.cdzy.common.model.response.JsonResult;
|
import com.cdzy.common.model.response.JsonResult;
|
||||||
import com.cdzy.operations.enums.BikeOrderHandleState;
|
import com.cdzy.operations.enums.OrderHandleState;
|
||||||
import com.cdzy.operations.model.dto.*;
|
import com.cdzy.operations.model.dto.*;
|
||||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||||
import com.cdzy.operations.model.vo.*;
|
import com.cdzy.operations.model.vo.*;
|
||||||
@ -50,7 +50,7 @@ public class EbikeBikeOrderController {
|
|||||||
public JsonResult<?> page(PageParam page, Integer orderType, String bikeCode) {
|
public JsonResult<?> page(PageParam page, Integer orderType, String bikeCode) {
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
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.HANDLE_STATE.eq(OrderHandleState.UNPROCESSED))
|
||||||
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(orderType, Objects.nonNull(orderType)))
|
.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.BIKE_CODE.like(bikeCode, StringUtil.hasText(bikeCode)))
|
||||||
.leftJoin(EBIKE_BIKE_INFO).on(EBIKE_BIKE_INFO.BIKE_CODE.eq(EBIKE_BIKE_ORDER.BIKE_CODE));
|
.leftJoin(EBIKE_BIKE_INFO).on(EBIKE_BIKE_INFO.BIKE_CODE.eq(EBIKE_BIKE_ORDER.BIKE_CODE));
|
||||||
@ -68,7 +68,8 @@ public class EbikeBikeOrderController {
|
|||||||
public JsonResult<?> pageByStaff(PageParam page, Integer orderType, String bikeCode) {
|
public JsonResult<?> pageByStaff(PageParam page, Integer orderType, String bikeCode) {
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
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.RECEIVED))
|
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(OrderHandleState.ACCEPTED))
|
||||||
|
.or(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(OrderHandleState.ACCEPTED))
|
||||||
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(orderType, Objects.nonNull(orderType)))
|
.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.BIKE_CODE.like(bikeCode, StringUtil.hasText(bikeCode)))
|
||||||
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.eq(StpUtil.getLoginIdAsLong()))
|
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.eq(StpUtil.getLoginIdAsLong()))
|
||||||
@ -333,4 +334,26 @@ public class EbikeBikeOrderController {
|
|||||||
EbikeOrderUnfinishedInfo info = ebikeBikeOrderService.unfinishedOrders();
|
EbikeOrderUnfinishedInfo info = ebikeBikeOrderService.unfinishedOrders();
|
||||||
return JsonResult.success(info);
|
return JsonResult.success(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看未完成调度工单的车辆编号列表
|
||||||
|
*
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@GetMapping("unfinishedDispatchBikeCodes")
|
||||||
|
public JsonResult<List<String>> unfinishedDispatchBikeCodes() {
|
||||||
|
List<String> list = ebikeBikeOrderService.unfinishedDispatchBikeCodes();
|
||||||
|
return JsonResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量完成调度工单
|
||||||
|
*
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@GetMapping("batchFinishDispatch")
|
||||||
|
public JsonResult<?> batchFinishDispatch(@RequestBody @Validated EbikeBatchDispatchVo dispatchVo) {
|
||||||
|
ebikeBikeOrderService.batchFinishDispatch(dispatchVo);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
package com.cdzy.operations.enums;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author attiya
|
|
||||||
* @since 2025-11-25
|
|
||||||
*/
|
|
||||||
public interface BikeOrderHandleState {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 未处理
|
|
||||||
*/
|
|
||||||
int UNPROCESSED = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已接单
|
|
||||||
*/
|
|
||||||
int RECEIVED = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已处理
|
|
||||||
*/
|
|
||||||
int PROCESSED = 2;
|
|
||||||
}
|
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
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.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author attiya
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EbikeBatchDispatchVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆编号列表
|
||||||
|
*/
|
||||||
|
@NotNull(message = "车辆编号列表不能为空")
|
||||||
|
private List<String> bikeCodes;
|
||||||
|
|
||||||
|
@NotNull(message = "站点不能为空")
|
||||||
|
private Long siteId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private List<String> fileUrls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remarks;
|
||||||
|
}
|
||||||
@ -11,7 +11,6 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实体类。
|
|
||||||
*
|
*
|
||||||
* @author attiya
|
* @author attiya
|
||||||
* @since 2025-10-21
|
* @since 2025-10-21
|
||||||
|
|||||||
@ -157,4 +157,17 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
|||||||
* @param bikeCode 车辆编号
|
* @param bikeCode 车辆编号
|
||||||
*/
|
*/
|
||||||
Boolean checkDispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode);
|
Boolean checkDispatchSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看未完成调度工单的车辆编号列表
|
||||||
|
*
|
||||||
|
* @return 车辆编号
|
||||||
|
*/
|
||||||
|
List<String> unfinishedDispatchBikeCodes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量完成调度
|
||||||
|
* @param dispatchVo 调度信息
|
||||||
|
*/
|
||||||
|
void batchFinishDispatch(EbikeBatchDispatchVo dispatchVo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -375,7 +375,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
|
|
||||||
this.mapper.update(info);
|
this.mapper.update(info);
|
||||||
|
|
||||||
//若存在已处理但暂未生效的调度工单:清空redis中的为消耗调度工单,已处理的工单调度状态修改为生效
|
//若存在已处理但暂未生效的调度工单:清空redis中的未消耗调度工单,已处理的工单调度状态修改为生效
|
||||||
query.clear();
|
query.clear();
|
||||||
query.where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(info.getBikeCode()))
|
query.where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(info.getBikeCode()))
|
||||||
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.DISPATCH))
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.DISPATCH))
|
||||||
|
|||||||
@ -886,7 +886,7 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
if (dispatchSwapVo.getAcceptOrders()) {
|
if (dispatchSwapVo.getAcceptOrders()) {
|
||||||
ebikeBikeOrder.setReceiverId(staffId);
|
ebikeBikeOrder.setReceiverId(staffId);
|
||||||
ebikeBikeOrder.setHandleState(OrderHandleState.ACCEPTED);
|
ebikeBikeOrder.setHandleState(OrderHandleState.ACCEPTED);
|
||||||
}else {
|
} else {
|
||||||
ebikeBikeOrder.setHandleState(OrderHandleState.UNPROCESSED);
|
ebikeBikeOrder.setHandleState(OrderHandleState.UNPROCESSED);
|
||||||
}
|
}
|
||||||
list.add(ebikeBikeOrder);
|
list.add(ebikeBikeOrder);
|
||||||
@ -907,6 +907,56 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
return bikeOrder == null;
|
return bikeOrder == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> unfinishedDispatchBikeCodes() {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.select(EBIKE_BIKE_ORDER.BIKE_CODE)
|
||||||
|
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(OrderHandleState.ACCEPTED))
|
||||||
|
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.eq(StpUtil.getLoginIdAsLong()))
|
||||||
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.DISPATCH));
|
||||||
|
return this.mapper.selectListByQueryAs(queryWrapper, String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void batchFinishDispatch(EbikeBatchDispatchVo dispatchVo) {
|
||||||
|
List<String> bikeCodes = dispatchVo.getBikeCodes();
|
||||||
|
List<String> fileUrls = dispatchVo.getFileUrls();
|
||||||
|
List<EbikeOrderFile> files = new ArrayList<>();
|
||||||
|
Long receiverId = StpUtil.getLoginIdAsLong();
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.eq(receiverId))
|
||||||
|
.where(EBIKE_BIKE_ORDER.BIKE_CODE.in(bikeCodes))
|
||||||
|
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(OrderHandleState.ACCEPTED).or(EBIKE_BIKE_ORDER.HANDLE_STATE.eq(OrderHandleState.UNPROCESSED)))
|
||||||
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.DISPATCH));
|
||||||
|
List<EbikeBikeOrder> list = list(queryWrapper);
|
||||||
|
if (list == null) {
|
||||||
|
throw new EbikeException("列表中车辆工单均不存在或已作废");
|
||||||
|
}
|
||||||
|
EbikeDispatchConfiguration dispatchConfiguration = ebikeDispatchConfigurationMapper.selectOneByQuery(queryWrapper);
|
||||||
|
for (EbikeBikeOrder bikeOrder : list) {
|
||||||
|
bikeOrder.setSiteId(dispatchVo.getSiteId());
|
||||||
|
bikeOrder.setHandleState(OrderHandleState.PROCESSED);
|
||||||
|
bikeOrder.setRemarks(dispatchVo.getRemarks());
|
||||||
|
bikeOrder.setHandleAt(LocalDateTime.now());
|
||||||
|
redisUtil.saveDispatchOrder(bikeOrder.getOrderId(), bikeOrder, dispatchConfiguration != null ? dispatchConfiguration.getDispatchDuration() : 24L, TimeUnit.HOURS);
|
||||||
|
if (fileUrls != null && !fileUrls.isEmpty()) {
|
||||||
|
for (String fileUrl : fileUrls) {
|
||||||
|
EbikeOrderFile ebikeOrderFile = EbikeOrderFile.builder()
|
||||||
|
.orderId(bikeOrder.getOrderId())
|
||||||
|
.fileUrl(fileUrl)
|
||||||
|
.build();
|
||||||
|
files.add(ebikeOrderFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!files.isEmpty()) {
|
||||||
|
ebikeOrderFileMapper.insertBatch(files);
|
||||||
|
}
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
updateBatch(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
EbikeBikeInfo checkBikeCode(String bikeCode) {
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user