package com.hnevc.CarPark.service.impl;
import com.hnevc.CarPark.entity.Car;
import com.hnevc.CarPark.entity.StallUsage;
import com.hnevc.CarPark.mapper.CarMapper;
import com.hnevc.CarPark.mapper.StallUsageMapper;
import com.hnevc.CarPark.service.CarService;
import com.hnevc.CarPark.service.ex.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class CarServiceImpl implements CarService {
@Autowired
private CarMapper carMapper;
@Autowired
private StallUsageMapper stallUsageMapper;
@Override
public void addnew(Car car, String username) {
// 调用私有方法findByLicenseNumber()查询车辆信息是否已存在
Car result = findByLicenseNumber(car.getLicenseNumber());
if (result != null) {
throw new CarDuplicateException("添加车辆信息失败(>﹏<) 车辆信息已存在");
}
// 补全数据 日志
car.setIsParking(1);
Date now = new Date();
car.setCreatedUser(username);
car.setCreatedTime(now);
car.setModifiedUser(username);
car.setModifiedTime(now);
// 调用私有方法insert()执行插入数据
insert(car);
Integer num;
StallUsage stallUsage = stallUsageMapper.findAll();
// 根据添加的车辆类型增加相应的车位占用
switch (car.getTypeId()) {
case 1:
num = stallUsage.getSmallCars() + 1;
stallUsageMapper.updateSmallCars(num);
break;
case 2:
num = stallUsage.getMiddleCars() + 1;
stallUsageMapper.updateMiddleCars(num);
break;
case 3:
num = stallUsage.getLargeCars() + 1;
stallUsageMapper.updateLargeCars(num);
break;
}
}
@Override
public void delete(Integer cid) {
// 调用私有方法findByCid()查询车辆数据是否存在
Car result = findByCid(cid);
if (result == null) {
throw new CarNotFoundException("删除车辆信息失败(>﹏<) 车辆信息不存在");
}
//调用私有方法deleteByCid()执行删除数据
deleteByCid(cid);
Integer num;
StallUsage stallUsage = stallUsageMapper.findAll();
// 根据删除的车辆类型减少相应的车位占用
switch (result.getTypeId()) {
case 1:
num = stallUsage.getSmallCars() - 1;
stallUsageMapper.updateSmallCars(num);
break;
case 2:
num = stallUsage.getMiddleCars() - 1;
stallUsageMapper.updateMiddleCars(num);
break;
case 3:
num = stallUsage.getLargeCars() - 1;
stallUsageMapper.updateLargeCars(num);
break;
}
}
@Override
public void changeByCid(String username, Car car) {
// 调用私有方法findByCid()查询车辆信息是否存在
Car result = findByCid(car.getCid());
if (result == null) {
throw new CarNotFoundException("修改车辆信息失败(>﹏<) 车辆信息不存在");
}
Date now = new Date();
Integer num;
// 判断当前状态是否在停
if (result.getIsParking() != car.getIsParking()) {
car.setOutTime(now);
StallUsage stallUsage = stallUsageMapper.findAll();
if (result.getIsParking() == 0 && car.getIsParking() == 1){
switch (car.getTypeId()) {
case 1:
num = stallUsage.getSmallCars() + 1;
stallUsageMapper.updateSmallCars(num);
break;
case 2:
num = stallUsage.getMiddleCars() + 1;
stallUsageMapper.updateMiddleCars(num);
break;
case 3:
num = stallUsage.getLargeCars() + 1;
stallUsageMapper.updateLargeCars(num);
break;
}
// 更新日志
car.setModifiedUser(username);
car.setModifiedTime(now);
// 调用私有方法updateByCid()执行修改操作
updateByCid(car);
return;
}
// 根据修改的出场车辆类型减少相应的车位占用
switch (result.getTypeId()) {
case 1:
num = stallUsage.getSmallCars() - 1;
stallUsageMapper.updateSmallCars(num);
break;
case 2:
num = stallUsage.getMiddleCars() - 1;
stallUsageMapper.updateMiddleCars(num);
break;
case 3:
num = stallUsage.getLargeCars() - 1;
stallUsageMapper.updateLargeCars(num);
break;
}
} else {
StallUsage stallUsage1 = stallUsageMapper.findAll();
// 根据修改的原车辆类型减少相应的车位占用
switch (result.getTypeId()) {
case 1:
num = stallUsage1.getSmallCars() - 1;
stallUsageMapper.updateSmallCars(num);
break;
case 2:
num = stallUsage1.getMiddleCars() - 1;
stallUsageMapper.updateMiddleCars(num);
break;
case 3:
num = stallUsage1.getLargeCars() - 1;
stallUsageMapper.updateLargeCars(num);
break;
}
StallUsage stallUsage2 = stallUsageMapper.findAll();
// 根据修改后的车辆类型增加相应的车位占用
switch (car.getTypeId()) {
case 1:
num = stallUsage2.getSmallCars() + 1;
stallUsageMapper.updateSmallCars(num);
break;
case 2:
num = stallUsage2.getMiddleCars() + 1;
stallUsageMapper.updateMiddleCars(num);
break;
case 3:
num = stallUsage2.getLargeCars() + 1;
stallUsageMapper.updateLargeCars(num);
break;
}
}
// 更新日志
car.setModifiedUser(username);
car.setModifiedTime(now);
// 调用私有方法updateByCid()执行修改操作
updateByCid(car);
}
@Override
public Car getByCid(Integer cid) {
Car result = findByCid(cid);
result.setCid(null);
result.setTypeId(null);
result.setMemberId(null);
result.setIsParking(null);
result.setOutTime(null);
result.setCreatedUser(null);
result.setCreatedTime(null);
result.setModifiedUser(null);
result.setModifiedTime(null);
return result;
}
@Override
public List<Car> findAll() {
return carMapper.findAll();
}
/**
* 插入车辆数据
*
* @param car 车辆数据
* @return 受影响的行数
*/
private void insert(Car car) {
Integer rows = carMapper.insert(car);
if (rows != 1) {
throw new InsertException("添加车辆信息失败(>﹏<) 添加车辆信息时出现未知错误,请联系系统管理员");
}
}
/**
* 根据cid删除车辆数据
*
* @param cid 车辆数据id
* @return 受影响的行数
*/
private void deleteByCid(Integer cid) {
Integer rows = carMapper.deleteByCid(cid);
if (rows != 1) {
throw new DeleteException("删除�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
根据系统需求分析涉及到的实体类表有,用户表,车辆信息表,车辆信息详情表、车位使用情况表及车辆收费标准表 实体类用户有姓名,密码,盐值,创建人,创建时间,最后修改人,最后修改时间 车辆信息主要有,车牌号,车辆类型id,会员类型id,是否在停,出场时间。车辆信息详情表主要有车辆类型id,会员类型id,车辆类型名称,会员类型名称 车位使用情况表主要有总车位,小型车车位使用情况,中型车车位使用情况,大型车车位使用情况 车辆收费标准表主要分为车辆类型,3-12小时收费标准,12-24小时收费标准,超出24小时收费标准,周卡会员收费标准,月卡会员收费标准,年卡会员收费标准。 参考链接: https://www.bilibili.com/video/BV1ok4y1b7mi/
资源推荐
资源详情
资源评论
收起资源包目录
基于Springboot的停车场管理系统
数据库:mysql
有数据库文件,拿来即用
可作为毕设参考
如遇到运行问题,可私信
(991个子文件)
UserServiceImpl.class 7KB
UserServiceImpl.class 7KB
CarServiceImpl.class 6KB
CarServiceImpl.class 6KB
UserController.class 4KB
UserController.class 4KB
Car.class 4KB
Car.class 4KB
UserServiceTests.class 3KB
CarChargeStandard.class 3KB
CarChargeStandard.class 3KB
CarController.class 3KB
CarController.class 3KB
UserMapperTests.class 3KB
User.class 3KB
User.class 3KB
CarMapperTests.class 3KB
CarServiceTests.class 3KB
StallUsage.class 2KB
StallUsage.class 2KB
StallUsageMapperTests.class 2KB
InterceptorConfigration.class 2KB
InterceptorConfigration.class 2KB
GlobalExceptionHandler.class 2KB
GlobalExceptionHandler.class 2KB
JsonResult.class 2KB
JsonResult.class 2KB
CarChargeStandardMapperTests.class 2KB
BaseEntity.class 2KB
BaseEntity.class 2KB
CarChargeStandardServiceTests.class 2KB
CarChargeStandardServiceImpl.class 2KB
CarChargeStandardServiceImpl.class 2KB
CarChargeStandardController.class 1KB
CarChargeStandardController.class 1KB
CarParkApplication.class 1KB
StallUsageController.class 1KB
StallUsageController.class 1KB
LoginInterceptor.class 1KB
LoginInterceptor.class 1KB
UsernameDuplicateException.class 1KB
UsernameDuplicateException.class 1KB
PasswordNotMatchException.class 1KB
PasswordNotMatchException.class 1KB
DeleteLoginUserException.class 1KB
DeleteLoginUserException.class 1KB
UserNotFoundException.class 1KB
CarDuplicateException.class 1KB
UserNotFoundException.class 1KB
CarDuplicateException.class 1KB
CarNotFoundException.class 1KB
CarNotFoundException.class 1KB
UpdateException.class 1KB
DeleteException.class 1KB
InsertException.class 1KB
UpdateException.class 1KB
DeleteException.class 1KB
InsertException.class 1KB
ServiceException.class 1KB
ServiceException.class 1KB
StallUsageServiceTests.class 1KB
BaseController.class 1KB
BaseController.class 1KB
StallUsageServiceImpl.class 1KB
StallUsageServiceImpl.class 1KB
UserMapper.class 942B
UserMapper.class 942B
ServletInitializer.class 921B
ServletInitializer.class 921B
CarParkApplication.class 836B
UserService.class 707B
UserService.class 707B
CarMapper.class 653B
CarMapper.class 653B
CarParkApplicationTests.class 633B
CarService.class 595B
CarService.class 595B
StallUsageMapper.class 416B
StallUsageMapper.class 416B
CarChargeStandardMapper.class 400B
CarChargeStandardMapper.class 400B
CarChargeStandardService.class 280B
CarChargeStandardService.class 280B
StallUsageService.class 200B
StallUsageService.class 200B
mvnw.cmd 6KB
bootstrap.min.css 106KB
bootstrap.min.css 106KB
bootstrap.min.css 106KB
style.min.css 105KB
style.min.css 105KB
style.min.css 105KB
materialdesignicons.min.css 85KB
materialdesignicons.min.css 85KB
materialdesignicons.min.css 85KB
animate.css 71KB
animate.css 71KB
animate.css 71KB
bootstrap-datepicker3.css 22KB
bootstrap-datepicker3.css 22KB
共 991 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
xiaozhima-dun
- 粉丝: 5627
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功