巡检工单生成(待用户端接入故障上报实现自动生成巡检工单)
This commit is contained in:
parent
753318acad
commit
d577d2db06
@ -63,4 +63,13 @@ public interface OperationsFeignClient {
|
|||||||
@GetMapping("/ebikeBikeOrder/batterySwapOrder")
|
@GetMapping("/ebikeBikeOrder/batterySwapOrder")
|
||||||
JsonResult<FeignEbikeUserBikeInfo> batterySwapOrder(@RequestParam("ecuSn")String ecuSn);
|
JsonResult<FeignEbikeUserBikeInfo> batterySwapOrder(@RequestParam("ecuSn")String ecuSn);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据bikeCode生成巡检工单
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/ebikeBikeOrder/inspectionSwapOrder")
|
||||||
|
JsonResult<FeignEbikeUserBikeInfo> inspectionSwapOrder(@RequestParam("bikeCode")String bikeCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import com.mybatisflex.core.paginate.Page;
|
|||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.core.util.StringUtil;
|
import com.mybatisflex.core.util.StringUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -56,9 +57,20 @@ public class EbikeBikeOrderController {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("batterySwapOrder")
|
@GetMapping("batterySwapOrder")
|
||||||
public JsonResult<?> batterySwapOrder(String ecuSn) {
|
public JsonResult<?> batterySwapOrder(@NotNull(message = "中控编号不能为空") String ecuSn) {
|
||||||
ebikeBikeOrderService.createBatterySwapOrder(ecuSn);
|
ebikeBikeOrderService.createBatterySwapOrder(ecuSn);
|
||||||
return JsonResult.success();
|
return JsonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成巡检工单。
|
||||||
|
*
|
||||||
|
* @param bikeCode 车辆编号
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("inspectionSwapOrder")
|
||||||
|
public JsonResult<?> inspectionSwapOrder(@NotNull(message = "车辆编号不能为空") String bikeCode) {
|
||||||
|
ebikeBikeOrderService.createInspectionSwapOrder(bikeCode);
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,8 +12,15 @@ import com.cdzy.operations.model.entity.EbikeBikeOrder;
|
|||||||
public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据EcuSn生成车辆换电工单
|
* 根据中控编码(EcuSn)生成车辆换电工单
|
||||||
* @param ecuSn 中控编码
|
* @param ecuSn 中控编码
|
||||||
*/
|
*/
|
||||||
void createBatterySwapOrder(String ecuSn);
|
void createBatterySwapOrder(String ecuSn);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据车辆编号(bikeCode)生成车辆巡检工单
|
||||||
|
* @param bikeCode 中控编码
|
||||||
|
*/
|
||||||
|
void createInspectionSwapOrder(String bikeCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.cdzy.operations.service.impl;
|
|||||||
import com.cdzy.common.ex.EbikeException;
|
import com.cdzy.common.ex.EbikeException;
|
||||||
import com.cdzy.operations.enums.BikeOrderType;
|
import com.cdzy.operations.enums.BikeOrderType;
|
||||||
import com.cdzy.operations.enums.BikeStatus;
|
import com.cdzy.operations.enums.BikeStatus;
|
||||||
|
import com.cdzy.operations.mapper.EbikeBikeInfoMapper;
|
||||||
import com.cdzy.operations.mapper.EbikeBikeOrderMapper;
|
import com.cdzy.operations.mapper.EbikeBikeOrderMapper;
|
||||||
import com.cdzy.operations.mapper.EbikeEcuInfoMapper;
|
import com.cdzy.operations.mapper.EbikeEcuInfoMapper;
|
||||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||||
@ -34,6 +35,9 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
@Resource
|
@Resource
|
||||||
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
EbikeBikeInfoMapper bikeInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createBatterySwapOrder(String ecuSn) {
|
public void createBatterySwapOrder(String ecuSn) {
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
@ -47,7 +51,8 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
throw new EbikeException("创建换电工单失败,中控编号错误");
|
throw new EbikeException("创建换电工单失败,中控编号错误");
|
||||||
}
|
}
|
||||||
queryWrapper.clear();
|
queryWrapper.clear();
|
||||||
queryWrapper.where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(bikeInfo.getBikeCode()));
|
queryWrapper.where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(bikeInfo.getBikeCode()))
|
||||||
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.BATTERY_SWAP));
|
||||||
EbikeBikeOrder bikeOrder = this.mapper.selectOneByQuery(queryWrapper);
|
EbikeBikeOrder bikeOrder = this.mapper.selectOneByQuery(queryWrapper);
|
||||||
if (bikeOrder != null) {
|
if (bikeOrder != null) {
|
||||||
log.error("车辆已存在换电工单,bikeCode={} ", bikeInfo.getBikeCode());
|
log.error("车辆已存在换电工单,bikeCode={} ", bikeInfo.getBikeCode());
|
||||||
@ -60,4 +65,30 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
.build();
|
.build();
|
||||||
this.mapper.insert(ebikeBikeOrder);
|
this.mapper.insert(ebikeBikeOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createInspectionSwapOrder(String bikeCode) {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode))
|
||||||
|
.where(EBIKE_BIKE_INFO.STATUS.eq(BikeStatus.LAUNCH));
|
||||||
|
EbikeBikeInfo bikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
|
||||||
|
if (bikeInfo == null) {
|
||||||
|
log.error("创建巡检工单失败,车辆不存在或未上架,bikeCode={} ", bikeCode);
|
||||||
|
throw new EbikeException("创建巡检工单失败,车辆编号错误");
|
||||||
|
}
|
||||||
|
queryWrapper.clear();
|
||||||
|
queryWrapper.where(EBIKE_BIKE_ORDER.BIKE_CODE.eq(bikeInfo.getBikeCode()))
|
||||||
|
.where(EBIKE_BIKE_ORDER.ORDER_TYPE.eq(BikeOrderType.INSPECTION));
|
||||||
|
EbikeBikeOrder bikeOrder = this.mapper.selectOneByQuery(queryWrapper);
|
||||||
|
if (bikeOrder != null) {
|
||||||
|
log.error("车辆已存在巡检工单,bikeCode={} ", bikeInfo.getBikeCode());
|
||||||
|
throw new EbikeException("车辆已存在巡检工单");
|
||||||
|
}
|
||||||
|
EbikeBikeOrder ebikeBikeOrder = EbikeBikeOrder.builder()
|
||||||
|
.bikeCode(bikeInfo.getBikeCode())
|
||||||
|
.orderCode(snowFlakeIDKeyGenerator.nextId())
|
||||||
|
.orderType(BikeOrderType.INSPECTION)
|
||||||
|
.build();
|
||||||
|
this.mapper.insert(ebikeBikeOrder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user