换电工单
This commit is contained in:
parent
1c61276a0b
commit
a6cfb9e4c9
@ -0,0 +1,33 @@
|
||||
package com.cdzy.ebikemaintenance.controller;
|
||||
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 工单控制层
|
||||
* @author attiya
|
||||
* @since 2025-04-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ebikeOrder")
|
||||
public class EbikeOrderController {
|
||||
|
||||
@Resource
|
||||
EbikeBikeOrderService ebikeBikeOrderService;
|
||||
|
||||
/**
|
||||
* 生成换电工单
|
||||
* @return 运营车辆列表
|
||||
*/
|
||||
@GetMapping("changeBattery")
|
||||
public JsonResult<?> changeBattery(@RequestParam("ecuSn") String ecuSn) {
|
||||
ebikeBikeOrderService.changeBattery(ecuSn);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,4 +11,16 @@ import com.mybatisflex.core.service.IService;
|
||||
*/
|
||||
public interface EbikeBikeOrderService extends IService<EbikeBikeOrder> {
|
||||
|
||||
/**
|
||||
* 根据ecu生成换电工单
|
||||
* @param ecuSn 中控编号
|
||||
*/
|
||||
void changeBattery(String ecuSn);
|
||||
|
||||
/**
|
||||
* 完成换电工
|
||||
* @param bikeId 车辆ID
|
||||
* @param receiverId 处理人ID
|
||||
*/
|
||||
void doneChangeBattery(String bikeId,String receiverId);
|
||||
}
|
||||
|
||||
@ -2,11 +2,10 @@ package com.cdzy.ebikemaintenance.service;
|
||||
|
||||
import com.cdzy.common.model.EbikeUserFaultreportDto;
|
||||
import com.cdzy.common.model.EbikeUserFaultreportQueryDto;
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.EbikeFaultreportReviewDto;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.ResEbikeUserFaultreportDto;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.ebikemaintenance.model.pojo.EbikeFaultreportReview;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import com.cdzy.ebikemaintenance.model.dto.request.*;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.*;
|
||||
import com.cdzy.ebikemaintenance.model.pojo.*;
|
||||
import com.cdzy.ebikemaintenance.service.EbikeBikeInfoService;
|
||||
import com.cdzy.ebikemaintenance.service.EbikeBikeOrderService;
|
||||
import com.cdzy.ebikemaintenance.utils.GeoCodingUtil;
|
||||
import com.cdzy.ebikemaintenance.utils.MinioUtil;
|
||||
import com.cdzy.ebikemaintenance.utils.RedisUtil;
|
||||
@ -31,7 +32,6 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -71,6 +71,8 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
@Resource
|
||||
private EbikeBikeInfoMapper ebikeBikeInfoMapper;
|
||||
@Resource
|
||||
private EbikeBikeOrderService orderService;
|
||||
@Resource
|
||||
private EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
||||
@Resource
|
||||
private EbikeHelmetInfoMapper ebikeHelmetInfoMapper;
|
||||
@ -90,26 +92,26 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
private EbikeBikeFaultReportFileMapper ebikeBikeFaultReportFileMapper;
|
||||
@Resource
|
||||
private EbikeBikeOrderMapper ebikeBikeOrderMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
private EbikeBikeFaultRepairRecordMapper ebikeBikeFaultRepairRecordMapper;
|
||||
@Resource
|
||||
private EbikeBatteryInfoServiceImpl ebikeBatteryInfoServiceImpl;
|
||||
@Resource
|
||||
private StaffFeignClient staffFeignClient;
|
||||
@Autowired
|
||||
@Resource
|
||||
private EbikeBikeComMapper ebikeBikeComMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
private EbikeBikeFaultHandleFileMapper ebikeBikeFaultHandleFileMapper;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private EbikeCoreController ebikeCoreController;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Autowired
|
||||
@Resource
|
||||
private GeoCodingUtil geoCodingUtil;
|
||||
|
||||
@Override
|
||||
@ -244,7 +246,6 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
resEbikeBikeAndEcuCodeDto.setResGPSDto(resGPSDto);
|
||||
return resEbikeBikeAndEcuCodeDto;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("getBikeINfoData===>{}", e.getMessage() + Arrays.toString(e.getStackTrace()));
|
||||
return null;
|
||||
}
|
||||
@ -262,7 +263,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
try {
|
||||
return ebikeBikeInfoMapper.untieEcu(bikeId) >= 1;
|
||||
} catch (Exception e) {
|
||||
log.error("untieEcu===>" + e.getMessage() + Arrays.toString(e.getStackTrace()));
|
||||
log.error("untieEcu===>{}{}", e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -341,7 +342,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
if (stateList.length == 1) {
|
||||
query.eq(EBIKE_BIKE_INFO.STATE.getName(), queryParam.getState());
|
||||
} else {
|
||||
query.in(EBIKE_BIKE_INFO.STATE.getName(), stateList);
|
||||
query.in(EBIKE_BIKE_INFO.STATE.getName(), Arrays.stream(stateList).toList());
|
||||
}
|
||||
}
|
||||
if (queryParam.getEnterTime() != null && !queryParam.getEnterTime().toString().isEmpty()) {
|
||||
@ -619,7 +620,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
ebikeBikeOrder.setReceiverId(reqEbikeBikeOrderDto.getReceiverId());
|
||||
ebikeBikeOrderMapper.insert(ebikeBikeOrder);
|
||||
query.clear();
|
||||
query.in(EBIKE_BIKE_FAULT_REPORT.FAULT_REPORT_ID.getName(), faultIds);
|
||||
query.in(EBIKE_BIKE_FAULT_REPORT.FAULT_REPORT_ID.getName(), Arrays.stream(faultIds).toList());
|
||||
List<EbikeBikeFaultRepairRecord> ebikeBikeFaultRepairRecords = new ArrayList<>();
|
||||
List<EbikeBikeFaultReport> ebikeBikeFaultReports = ebikeBikeFaultReportMapper.selectListByQuery(query);
|
||||
for (EbikeBikeFaultReport ebikeBikeFaultReport : ebikeBikeFaultReports) {
|
||||
@ -730,13 +731,15 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
||||
ebikeBikeInfo.setBatteryId(newBattery.getBatteryId());
|
||||
ebikeBikeInfoMapper.update(ebikeBikeInfo);
|
||||
|
||||
//TODO:匹配工单ID、将其完成
|
||||
String tokenValue = StpUtil.getTokenValue();
|
||||
JsonResult<StaffFeign> result = staffFeignClient.getInfoByToken(tokenValue);
|
||||
if (result.getCode() != Code.SUCCESS) {
|
||||
throw new RuntimeException("获取用户信息失败");
|
||||
}
|
||||
StaffFeign staffFeign = result.getData();
|
||||
//匹配工单ID、将其完成
|
||||
orderService.doneChangeBattery(ebikeBikeInfo.getBikeId(),String.valueOf(staffFeign.getStaffId()));
|
||||
//生成换电记录
|
||||
EbikeBikeBatterychange batteryChange = new EbikeBikeBatterychange();
|
||||
batteryChange.setBikeId(ebikeBikeInfo.getBikeId());
|
||||
batteryChange.setNbatteryId(newBattery.getBatteryId());
|
||||
|
||||
@ -1,11 +1,22 @@
|
||||
package com.cdzy.ebikemaintenance.service.impl;
|
||||
|
||||
import com.cdzy.ebikemaintenance.mapper.EbikeBikeInfoMapper;
|
||||
import com.cdzy.ebikemaintenance.mapper.EbikeBikeOrderMapper;
|
||||
import com.cdzy.ebikemaintenance.model.pojo.EbikeBikeInfo;
|
||||
import com.cdzy.ebikemaintenance.model.pojo.EbikeBikeOrder;
|
||||
import com.cdzy.ebikemaintenance.service.EbikeBikeOrderService;
|
||||
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeOrderTableDef.EBIKE_BIKE_ORDER;
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
||||
|
||||
/**
|
||||
* 工单信息 服务层实现。
|
||||
*
|
||||
@ -15,4 +26,45 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper, EbikeBikeOrder> implements EbikeBikeOrderService {
|
||||
|
||||
private static final SnowFlakeIDKeyGenerator snowFlakeIDKeyGenerator = new SnowFlakeIDKeyGenerator();
|
||||
|
||||
@Resource
|
||||
EbikeBikeInfoMapper infoMapper;
|
||||
|
||||
@Override
|
||||
public void changeBattery(String ecuSn) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID))
|
||||
.where(EBIKE_ECU_INFO.ECU_SN.eq(ecuSn));
|
||||
EbikeBikeInfo ebikeBikeInfo = infoMapper.selectOneByQuery(queryWrapper);
|
||||
queryWrapper.clear();
|
||||
queryWrapper.where(EBIKE_BIKE_ORDER.BIKE_ID.eq(ebikeBikeInfo.getBikeId()))
|
||||
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq("0"));
|
||||
EbikeBikeOrder order = this.mapper.selectOneByQuery(queryWrapper);
|
||||
if (order != null) {
|
||||
throw new RuntimeException("该车辆已存在换电工单,无需重复生成");
|
||||
}
|
||||
//生成工单
|
||||
EbikeBikeOrder bikeOrder = new EbikeBikeOrder();
|
||||
bikeOrder.setBikeId(ebikeBikeInfo.getBikeId());
|
||||
long orderCode = snowFlakeIDKeyGenerator.nextId();
|
||||
bikeOrder.setOrderCode(orderCode);
|
||||
bikeOrder.setOrderType("2");
|
||||
this.mapper.insert(bikeOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneChangeBattery(String bikeId, String receiverId) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_BIKE_ORDER.BIKE_ID.eq(bikeId))
|
||||
.where(EBIKE_BIKE_ORDER.HANDLE_STATE.eq("0"));
|
||||
EbikeBikeOrder bikeOrder = this.mapper.selectOneByQuery(queryWrapper);
|
||||
if (bikeOrder == null){
|
||||
throw new RuntimeException("该车辆不存在未完成的换电工单");
|
||||
}
|
||||
bikeOrder.setHandleState("1");
|
||||
bikeOrder.setHandleAt(LocalDateTime.now());
|
||||
bikeOrder.setReceiverId(receiverId);
|
||||
this.mapper.update(bikeOrder);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user