运营区删除检测车辆绑定情况、JsonResult类扩充
This commit is contained in:
parent
efdad0defb
commit
66e1298d2a
@ -71,4 +71,12 @@ public class JsonResult<E> implements Serializable {
|
||||
public static JsonResult<Object> failed(String msg, Object data) {
|
||||
return new JsonResult<>(Code.FAILED, msg, data);
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return this.code == Code.SUCCESS;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return this.code != Code.SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.ebike.feign.clients;
|
||||
|
||||
import com.cdzy.common.model.EcuSnDto;
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.common.model.ReqBatchRegionDto;
|
||||
import com.ebike.feign.component.FeignTokenInterceptor;
|
||||
import com.ebike.feign.config.ExampleFeignConfiguration;
|
||||
import com.ebike.feign.model.res.ReqEcuSnDto;
|
||||
@ -152,4 +153,12 @@ public interface MaintenanceFeignClient {
|
||||
*/
|
||||
@GetMapping("ebikeBikeInfo/used")
|
||||
JsonResult<?> used(@RequestParam(name = "bikeId") String bikeId);
|
||||
|
||||
/**
|
||||
* 查看运营区下是否有车辆(返回有车辆的运营区id
|
||||
* @param dto 运营区id
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("ebikeBikeInfo/getRegionIdsByBikes")
|
||||
JsonResult<List<Long>> getRegionIdsByBikes(@RequestBody ReqBatchRegionDto dto);
|
||||
}
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
package com.cdzy.ebikemaintenance.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cdzy.common.model.EcuSnDto;
|
||||
import com.cdzy.common.model.JsonResult;
|
||||
import com.cdzy.common.model.PageParam;
|
||||
import com.cdzy.common.model.ResGPSDto;
|
||||
import com.cdzy.common.model.*;
|
||||
import com.cdzy.common.utils.ConvertUtil;
|
||||
import com.cdzy.ebikemaintenance.model.dto.request.*;
|
||||
import com.cdzy.ebikemaintenance.model.dto.response.*;
|
||||
@ -33,6 +30,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeHelmetInfoTableDef.EBIKE_HELMET_INFO;
|
||||
|
||||
/**
|
||||
@ -396,7 +394,7 @@ public class EbikeBikeInfoController {
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
String contentType = multipartFile.getContentType();
|
||||
String fileUniqueKey = UUID.randomUUID() + fileName.substring(fileName.lastIndexOf("."));
|
||||
minioUtil.uploadFile(inputStream, MinioUtil.BUCKET_FAULT, fileUniqueKey,contentType);
|
||||
minioUtil.uploadFile(inputStream, MinioUtil.BUCKET_FAULT, fileUniqueKey, contentType);
|
||||
String fileUrl = minioUtil.getFileUrl(MinioUtil.BUCKET_FAULT, fileUniqueKey);
|
||||
ResEbikeFaultReportFileDto resEbikeFaultReportFileDto = new ResEbikeFaultReportFileDto();
|
||||
resEbikeFaultReportFileDto.setUrl(fileUrl);
|
||||
@ -920,7 +918,6 @@ public class EbikeBikeInfoController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据车辆id将车辆设置为待使用状态
|
||||
*
|
||||
@ -945,7 +942,24 @@ public class EbikeBikeInfoController {
|
||||
*/
|
||||
@GetMapping("getRideRecord")
|
||||
JsonResult<?> getRideRecord(@RequestParam("bikeId") String bikeId, PageParam pageParam) {
|
||||
JsonResult<Page<FeignRideRecord>> rideRecord = ordersFeignClient.getRideRecord(bikeId,pageParam.getPageNum(),pageParam.getPageSize());
|
||||
JsonResult<Page<FeignRideRecord>> rideRecord = ordersFeignClient.getRideRecord(bikeId, pageParam.getPageNum(), pageParam.getPageSize());
|
||||
return JsonResult.success(rideRecord.getData());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除运营区域前检查是否有绑定车辆
|
||||
*
|
||||
* @param dto 车辆id
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("getRegionIdsByBikes")
|
||||
JsonResult<?> getRegionIdsByBikes(@RequestBody ReqBatchRegionDto dto) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(EBIKE_BIKE_INFO.REGIN_ID)
|
||||
.where(EBIKE_BIKE_INFO.REGIN_ID.in(dto.getIds()))
|
||||
.groupBy(EBIKE_BIKE_INFO.REGIN_ID);
|
||||
List<Long> list = ebikeBikeInfoService.listAs(queryWrapper, Long.class);
|
||||
return JsonResult.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,17 +135,27 @@ public class EbikeOperationRegionServiceImpl extends ServiceImpl<EbikeOperationR
|
||||
|
||||
@Override
|
||||
public void delOperation(ReqBatchRegionDto delRegionDto) {
|
||||
List<EbikeOperationRegion> ebikeOperationRegions = this.mapper.selectListByIds(delRegionDto.getIds());
|
||||
JsonResult<List<Long>> result = maintenanceFeignClient.getRegionIdsByBikes(delRegionDto);
|
||||
if (result.isFailed()){
|
||||
throw new RuntimeException("检查车辆信息失败");
|
||||
}
|
||||
List<Long> list = result.getData();
|
||||
List<Long> ids = delRegionDto.getIds();
|
||||
ids.removeAll(list);
|
||||
if (ids.isEmpty()) {
|
||||
throw new RuntimeException("当前区域均有车辆绑定,不可删除");
|
||||
}
|
||||
List<EbikeOperationRegion> ebikeOperationRegions = this.mapper.selectListByIds(ids);
|
||||
//做不同运营商考虑,通过循环进行删除
|
||||
ebikeOperationRegions.forEach(region ->
|
||||
delPoints(region.getOrgId(), region.getOperationRegionId())
|
||||
);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.where(EBIKE_SITE_REGION.OPERATION_REGION_ID.in(delRegionDto.getIds()));
|
||||
.where(EBIKE_STAFF_REGION.REGION_ID.in(ids));
|
||||
staffRegionMapper.deleteByQuery(queryWrapper);
|
||||
//站点与运营商解耦仅与运营区有关,做批量删除
|
||||
redisUtil.deleteStieByOperationIds(delRegionDto.getIds());
|
||||
this.mapper.deleteBatchByIds(delRegionDto.getIds());
|
||||
redisUtil.deleteStieByOperationIds(ids);
|
||||
this.mapper.deleteBatchByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user