|
|
@@ -45,6 +45,10 @@ import org.springblade.community.tdcarrecord.wrapper.TdCarRecordWrapper;
|
|
|
import org.springblade.community.tdcarrecord.service.ITdCarRecordService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 控制器
|
|
|
*
|
|
|
@@ -80,24 +84,27 @@ public class TdCarRecordController extends BladeController {
|
|
|
public R<IPage<TdCarRecordVO>> list(TdTdCarRecordDTO tdCarRecord, Query query, BladeUser bladeUser) {
|
|
|
String tenantId = bladeUser.getTenantId();
|
|
|
LambdaQueryWrapper<TdCarRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- ParkingLot parkingLot = null;
|
|
|
+ List<String> parkingLotKey = null;
|
|
|
if(tenantId.equals("000000")){
|
|
|
if(tdCarRecord.getResidentialId() == null){
|
|
|
return R.data(null);
|
|
|
}
|
|
|
- parkingLot = parkingLotService.getByResidentialId(tdCarRecord.getResidentialId());
|
|
|
- Assert.notNull(parkingLot, "该小区下没有创建车场");
|
|
|
+ List<ParkingLot> lotList = parkingLotService.getByResidentialId(tdCarRecord.getResidentialId());
|
|
|
+ Assert.isTrue(lotList.size() > 0, "该小区下没有创建车场");
|
|
|
+ parkingLotKey = lotList.stream().map(lot -> lot.getParkKey()).collect(Collectors.toList());
|
|
|
}else{
|
|
|
if(tdCarRecord.getAgencyId() == null){
|
|
|
return R.data(null);
|
|
|
}
|
|
|
- parkingLot = parkingLotService.getByAgencyId(tdCarRecord.getAgencyId());
|
|
|
- Assert.notNull(parkingLot, "该园区下没有创建车场");
|
|
|
+ List<ParkingLot> lotList = parkingLotService.getByAgencyId(tdCarRecord.getAgencyId());
|
|
|
+ Assert.isTrue(lotList.size() > 0, "该园区下没有创建车场");
|
|
|
+ parkingLotKey = lotList.stream().map(lot -> lot.getParkKey()).collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
if(tdCarRecord.getInOrOut() == 1){
|
|
|
- lambdaQueryWrapper.eq(TdCarRecord::getInMac, parkingLot.getParkKey());
|
|
|
+ lambdaQueryWrapper.in(TdCarRecord::getInMac, parkingLotKey);
|
|
|
}else{
|
|
|
- lambdaQueryWrapper.eq(TdCarRecord::getOutMac, parkingLot.getParkKey());
|
|
|
+ lambdaQueryWrapper.in(TdCarRecord::getOutMac, parkingLotKey);
|
|
|
}
|
|
|
lambdaQueryWrapper.orderByDesc(TdCarRecord::getCreateTime);
|
|
|
IPage<TdCarRecord> pages = carRecordService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
@@ -113,28 +120,30 @@ public class TdCarRecordController extends BladeController {
|
|
|
public R<IPage<TdCarRecordVO>> getRecord(TdTdCarRecordDTO tdCarRecord, Query query, BladeUser bladeUser) {
|
|
|
String tenantId = bladeUser.getTenantId();
|
|
|
LambdaQueryWrapper<TdCarRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- ParkingLot parkingLot = null;
|
|
|
+ List<String> parkingLotKey = new ArrayList<>();
|
|
|
if(tenantId.equals("000000")){
|
|
|
if(tdCarRecord.getResidentialId() == null){
|
|
|
return R.data(null);
|
|
|
}
|
|
|
- parkingLot = parkingLotService.getByResidentialId(tdCarRecord.getResidentialId());
|
|
|
- if(parkingLot == null){
|
|
|
+ List<ParkingLot> lotList = parkingLotService.getByResidentialId(tdCarRecord.getResidentialId());
|
|
|
+ if(lotList == null || lotList.size() == 0){
|
|
|
return R.data(new Page<TdCarRecordVO>());
|
|
|
}
|
|
|
+ parkingLotKey = lotList.stream().map(lot -> lot.getParkKey()).collect(Collectors.toList());
|
|
|
}else{
|
|
|
LambdaQueryWrapper<ParkingLot> parkLogWrapper = new LambdaQueryWrapper<>();
|
|
|
parkLogWrapper.eq(ParkingLot::getTenantId, bladeUser.getTenantId());
|
|
|
- parkingLot = parkingLotService.getOne(parkLogWrapper);
|
|
|
+ ParkingLot parkingLot = parkingLotService.getOne(parkLogWrapper);
|
|
|
if(parkingLot == null){
|
|
|
return R.data(new Page<TdCarRecordVO>());
|
|
|
}
|
|
|
+ parkingLotKey.add(parkingLot.getParkKey());
|
|
|
}
|
|
|
if(tdCarRecord.getInOrOut() != null){
|
|
|
if(tdCarRecord.getInOrOut() == 1){
|
|
|
- lambdaQueryWrapper.eq(TdCarRecord::getInMac, parkingLot.getParkKey());
|
|
|
+ lambdaQueryWrapper.in(TdCarRecord::getInMac, parkingLotKey);
|
|
|
}else{
|
|
|
- lambdaQueryWrapper.eq(TdCarRecord::getOutMac, parkingLot.getParkKey());
|
|
|
+ lambdaQueryWrapper.in(TdCarRecord::getOutMac, parkingLotKey);
|
|
|
}
|
|
|
}
|
|
|
lambdaQueryWrapper.orderByDesc(TdCarRecord::getCreateTime);
|