批量换电

This commit is contained in:
attiya 2025-08-05 14:09:38 +08:00
parent cc8792c6fb
commit 5690462966
4 changed files with 62 additions and 4 deletions

View File

@ -1,12 +1,10 @@
package com.cdzy.ebikemaintenance.controller;
import com.cdzy.common.model.JsonResult;
import com.cdzy.ebikemaintenance.model.dto.request.BatchBatteryOrderVo;
import com.cdzy.ebikemaintenance.service.EbikeBikeOrderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 工单控制层
@ -39,4 +37,14 @@ public class EbikeOrderController {
ebikeBikeOrderService.receiveBatteryOrder(bikeId);
return JsonResult.success();
}
/**
* 批量领取换电工单
* @return 结果
*/
@GetMapping("receiveBatchBatteryOrder")
public JsonResult<?> receiveBatchBatteryOrder(@RequestBody BatchBatteryOrderVo batteryOrderVo) {
ebikeBikeOrderService.receiveBatchBatteryOrder(batteryOrderVo.getBikeIds());
return JsonResult.success();
}
}

View File

@ -0,0 +1,14 @@
package com.cdzy.ebikemaintenance.model.dto.request;
import lombok.Data;
import java.util.List;
/**
* @author attiya
* @since 2025-08-05
*/
@Data
public class BatchBatteryOrderVo {
private List<String> bikeIds;
}

View File

@ -3,6 +3,8 @@ package com.cdzy.ebikemaintenance.service;
import com.cdzy.ebikemaintenance.model.pojo.EbikeBikeOrder;
import com.mybatisflex.core.service.IService;
import java.util.List;
/**
* 工单信息 服务层
*
@ -29,4 +31,10 @@ public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
* @param bikeId 车辆ID
*/
void receiveBatteryOrder(Long bikeId);
/**
* 批量领取换电工单
* @param bikeIds 车辆ID列表
*/
void receiveBatchBatteryOrder(List<String> bikeIds);
}

View File

@ -12,11 +12,13 @@ import com.ebike.feign.clients.StaffFeignClient;
import com.ebike.feign.model.rsp.StaffFeign;
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 org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
@ -96,7 +98,33 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq("2"))
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq("0"));
EbikeBikeOrder bikeOrder = this.mapper.selectOneByQuery(queryWrapper);
if (bikeOrder == null){
throw new RuntimeException("该车辆当前无可接取换电工单");
}
bikeOrder.setReceiverId(String.valueOf(staffId));
this.mapper.update(bikeOrder);
}
@Override
public void receiveBatchBatteryOrder(List<String> bikeIds) {
String tokenValue = StpUtil.getTokenValue();
JsonResult<StaffFeign> jsonResult = staffFeignClient.getInfoByToken(tokenValue);
if (jsonResult.getCode() == Code.SUCCESS){
throw new RuntimeException("获取用户信息失败");
}
Long staffId = jsonResult.getData().getStaffId();
QueryWrapper queryWrapper = QueryWrapper.create()
.where(EBIKE_BIKE_ORDER.BIKE_ID.in(bikeIds))
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.isNull())
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq("2"))
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq("0"));
List<EbikeBikeOrder> list = this.mapper.selectListByQuery(queryWrapper);
List<String> strings = list.stream().map(EbikeBikeOrder::getOrderId).toList();
UpdateChain.of(EBIKE_BIKE_ORDER)
.set(EBIKE_BIKE_ORDER.RECEIVER_ID,staffId)
.where(EBIKE_BIKE_ORDER.ORDER_ID.in(strings))
.where(EBIKE_BIKE_ORDER.RECEIVER_ID.isNull())
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq("2"))
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq("0"));
}
}