修改ecuId取值错误问题

This commit is contained in:
小朱 2025-04-24 17:55:27 +08:00
parent 312e7e178d
commit 1861389672
5 changed files with 81 additions and 2 deletions

View File

@ -768,6 +768,33 @@ public class EbikeBikeInfoController {
return JsonResult.success("", resDispatchVehicleDto);
}
return JsonResult.failed("获取调度车辆数据失败!");
}
/**
* 有工单-根据工单ID 车辆编号 新增调度车车辆
* @param ebikeDispatchRecordDto
*/
@PostMapping("createDispatchRecord")
public JsonResult<?> createDispatchRecord(@RequestBody ReqEbikeDispatchRecordDto ebikeDispatchRecordDto) {
EbikeDispatchRecords dispatchRecord = ebikeBikeInfoService.createDispatchRecord(ebikeDispatchRecordDto);
if (!StringUtils.isEmpty(dispatchRecord)) {
return JsonResult.success("", dispatchRecord);
}else{
return JsonResult.failed("车辆已经在调度列表中!");
}
}
/**
* 删除调度记录接口
* @param recordId
* @return
*/
@GetMapping("deleteDispatchRecord")
public JsonResult<?> deleteDispatchRecord(@RequestParam(name = "recordId") String recordId) {
Boolean aBoolean = ebikeBikeInfoService.deleteDispatchRecord(recordId);
if (aBoolean) {
return JsonResult.success("删除成功", aBoolean);
}
return JsonResult.failed("删除失败!");
}
}

View File

@ -59,4 +59,8 @@ public class ResInventoryBikeListDto {
* IMEI
*/
private String imei;
/**
* ecuId
*/
private String ecuId;
}

View File

@ -35,7 +35,7 @@ public class EbikeDispatchRecords implements Serializable {
* 自增主键唯一标识一条记录
*/
@Id
private Long id;
private String id;
/**
* 工单ID表示对应的工单

View File

@ -249,4 +249,16 @@ public interface EbikeBikeInfoService extends IService<EbikeBikeInfo> {
* @return
*/
ResDispatchVehicleDto getDispatchVehicleByOrderId(String orderId);
/**
* 有工单-根据工单ID 车辆编号 新增调度车车辆
* @param ebikeDispatchRecordDto
*/
EbikeDispatchRecords createDispatchRecord(ReqEbikeDispatchRecordDto ebikeDispatchRecordDto);
/**
* 删除调度记录接口
* @param recordId
* @return
*/
Boolean deleteDispatchRecord(String recordId);
}

View File

@ -32,6 +32,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.common.errors.ResourceNotFoundException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -234,7 +235,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
ResInventoryBikeListDto resInventoryBikeListDto = ebikeBikeInfoMapper
.selectOneByQueryAs(queryWrapper, ResInventoryBikeListDto.class);
queryWrapper.clear();
queryWrapper.eq("ecu_id", resEbikeBikeAndEcuCodeDto.getEcuId());
queryWrapper.eq("ecu_id", resInventoryBikeListDto.getEcuId());
EbikeEcuInfo ebikeEcuInfo = ebikeEcuInfoMapper.selectOneByQuery(queryWrapper);
BeanUtils.copyProperties(resInventoryBikeListDto, resEbikeBikeAndEcuCodeDto);
BeanUtils.copyProperties(ebikeEcuInfo, resEbikeBikeAndEcuCodeDto);
@ -1215,4 +1216,39 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
return resDispatchVehicleDto;
}
/**
* 有工单-根据工单ID 车辆编号 新增调度车车辆
* @param ebikeDispatchRecordDto
*/
public EbikeDispatchRecords createDispatchRecord(ReqEbikeDispatchRecordDto ebikeDispatchRecordDto){
// 检查是否已存在相同的 OrderId BikeCode
QueryWrapper query = QueryWrapper.create();
query.eq("dispatch_state", 0);
query.eq("bike_code", ebikeDispatchRecordDto.getBikeCode());
// 执行查询操作
EbikeDispatchRecords existingRecord = ebikeDispatchRecordsMapper.selectOneByQuery(query);
if (existingRecord != null) {
// 如果存在直接返回现有记录
return null;
}
EbikeDispatchRecords ebikeDispatchRecords = new EbikeDispatchRecords();
ebikeDispatchRecords.setOrderId(ebikeDispatchRecordDto.getOrderId());
ebikeDispatchRecords.setBikeCode(ebikeDispatchRecordDto.getBikeCode());
ebikeDispatchRecords.setDispatchState(ebikeDispatchRecordDto.getDispatchState());
ebikeDispatchRecordsMapper.insert(ebikeDispatchRecords);
return ebikeDispatchRecords;
}
/**
* 删除调度记录接口
* @param recordId
* @return
*/
public Boolean deleteDispatchRecord(String recordId) {
if (ebikeDispatchRecordsMapper.selectOneById(recordId) == null) {
throw new ResourceNotFoundException("调度记录不存在");
}
return ebikeDispatchRecordsMapper.deleteById(recordId) > 0;
}
}