|
|
@ -7,10 +7,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.hnac.hzims.safeproduct.dto.CarMilesYearDTO; |
|
|
|
import com.hnac.hzims.safeproduct.dto.CarMilesYearDTO; |
|
|
|
import com.hnac.hzims.safeproduct.entity.CarEntity; |
|
|
|
import com.hnac.hzims.safeproduct.entity.CarEntity; |
|
|
|
import com.hnac.hzims.safeproduct.mapper.CarMapper; |
|
|
|
import com.hnac.hzims.safeproduct.mapper.CarMapper; |
|
|
|
|
|
|
|
import com.hnac.hzims.safeproduct.service.ICarCheckRecordService; |
|
|
|
|
|
|
|
import com.hnac.hzims.safeproduct.service.ICarMaintenanceService; |
|
|
|
import com.hnac.hzims.safeproduct.service.ICarService; |
|
|
|
import com.hnac.hzims.safeproduct.service.ICarService; |
|
|
|
|
|
|
|
import com.hnac.hzims.safeproduct.service.ICarUsedRecordService; |
|
|
|
import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; |
|
|
|
import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -27,6 +33,15 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements ICarService { |
|
|
|
public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements ICarService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
ICarMaintenanceService carMaintenanceService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
ICarUsedRecordService carUsedRecordService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
ICarCheckRecordService carCheckRecordService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 年度里程数页面 |
|
|
|
* 年度里程数页面 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -100,8 +115,9 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements |
|
|
|
res.add(carMilesYearVO); |
|
|
|
res.add(carMilesYearVO); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
carPage.setRecords(res); |
|
|
|
page.setRecords(res); |
|
|
|
return carPage; |
|
|
|
page.setTotal(res.size()); |
|
|
|
|
|
|
|
return page; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -125,4 +141,57 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, CarEntity> implements |
|
|
|
.ge(CarEntity::getMaintenanceNextTime, yesterday); |
|
|
|
.ge(CarEntity::getMaintenanceNextTime, yesterday); |
|
|
|
return this.list(queryWrapper); |
|
|
|
return this.list(queryWrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 新增车辆 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R saveCar(CarEntity carEntity) { |
|
|
|
|
|
|
|
QueryWrapper<CarEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.lambda().eq(CarEntity::getPlateNumber, carEntity.getPlateNumber()); |
|
|
|
|
|
|
|
CarEntity car = this.getOne(queryWrapper); |
|
|
|
|
|
|
|
if (car == null) { |
|
|
|
|
|
|
|
return R.status(this.save(carEntity)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.fail("车牌号已存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 更新车辆 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R updateCar(CarEntity carEntity) { |
|
|
|
|
|
|
|
QueryWrapper<CarEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.lambda().eq(CarEntity::getPlateNumber, carEntity.getPlateNumber()) |
|
|
|
|
|
|
|
.ne(CarEntity::getId, carEntity.getId()); |
|
|
|
|
|
|
|
CarEntity car = this.getOne(queryWrapper); |
|
|
|
|
|
|
|
if (car == null) { |
|
|
|
|
|
|
|
return R.status(this.updateById(carEntity)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.fail("车牌号已存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 删除车辆 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean removeCar(Long id) { |
|
|
|
|
|
|
|
boolean remove = this.removeById(id); |
|
|
|
|
|
|
|
if (remove) { |
|
|
|
|
|
|
|
// 删除关联维保记录
|
|
|
|
|
|
|
|
boolean removeCarMaintenance = carMaintenanceService.removeRelativeCarMaintenance(id); |
|
|
|
|
|
|
|
if (!removeCarMaintenance) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 删除关联用车记录
|
|
|
|
|
|
|
|
boolean removeCarUsedRecord = carUsedRecordService.removeRelativeCarUsedRecord(id); |
|
|
|
|
|
|
|
if (!removeCarUsedRecord) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 删除关联车检记录
|
|
|
|
|
|
|
|
return carCheckRecordService.removeRelativeCarCheckRecord(id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|