| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.dao.CarBrandMapper; |
| | | import com.stylefeng.guns.modular.system.dao.CarMapper; |
| | | import com.stylefeng.guns.modular.system.dao.CarModelMapper; |
| | |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil addCar(Integer modelId, String color, String licensePlate, Date time, String drivingLicensePhoto, |
| | | String carPhoto, String insurancePhoto, Integer uid,Integer id) throws Exception { |
| | | public ResultUtil addCar(Integer modelId, String color, String licensePlate, Date time, String drivingLicenseNumber, String drivingLicensePhoto, String drivingLicenseEndTime, |
| | | String carPhoto, String insurancePhoto, String commercialInsuranceTime, Integer uid,Integer id, String peopleAndCarsPhone, Integer language |
| | | ,String otherBrand,String otherModel) throws Exception { |
| | | |
| | | Car query = carMapper.query(licensePlate); |
| | | if(id==null){ |
| | | if(null != query){ |
| | | return ResultUtil.error("车牌号已经使用"); |
| | | return ResultUtil.error(language == 1 ? "车牌号已经使用" : language == 2 ? "Plate number is already in use" : "Le numéro de plaque est déjà utilisé"); |
| | | } |
| | | }else{ |
| | | if(null != query && !id.equals(query.getId())){ |
| | | return ResultUtil.error("车牌号已经使用"); |
| | | return ResultUtil.error(language == 1 ? "车牌号已经使用" : language == 2 ? "Plate number is already in use" : "Le numéro de plaque est déjà utilisé"); |
| | | } |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Car car = new Car(); |
| | | car.setDriverId(uid); |
| | | car = carMapper.selectOne(car); |
| | | if(car==null){ |
| | | car = new Car(); |
| | | car.setId(id); |
| | | car.setPeopleAndCarsPhone(peopleAndCarsPhone); |
| | | // |
| | | if (!StringUtils.isEmpty(otherBrand)){ |
| | | List<CarBrand> carBrandList = carBrandMapper.selectList(new EntityWrapper<CarBrand>().eq("name", otherBrand).eq("state",1)); |
| | | if (carBrandList.isEmpty()){ |
| | | CarBrand carBrand = new CarBrand(); |
| | | carBrand.setState(1); |
| | | carBrand.setInsertTime(new Date()); |
| | | carBrand.setName(otherBrand); |
| | | carBrand.setRemark("1"); |
| | | Integer insert = carBrandMapper.insert(carBrand); |
| | | car.setCarBrandId(carBrand.getId()); |
| | | }else { |
| | | // CarModel carModel = carModelMapper.selectById(modelId); |
| | | car.setCarBrandId(carBrandList.get(0).getId()); |
| | | } |
| | | }else { |
| | | CarModel carModel = carModelMapper.selectById(modelId); |
| | | car.setCarBrandId(carModel.getBrandId()); |
| | | } |
| | | car.setCarModelId(modelId); |
| | | CarModel carModel = carModelMapper.selectById(modelId); |
| | | car.setCarBrandId(carModel.getBrandId()); |
| | | // |
| | | if (!StringUtils.isEmpty(otherModel)){ |
| | | List<CarModel> carModels = carModelMapper.selectList(new EntityWrapper<CarModel>().eq("name", otherModel).eq("brandId", car.getCarBrandId()).eq("state",1)); |
| | | if (carModels.isEmpty()){ |
| | | CarModel carModel = new CarModel(); |
| | | carModel.setName(otherModel); |
| | | carModel.setState(1); |
| | | carModel.setInsertTime(new Date()); |
| | | carModel.setSeat(5); |
| | | carModel.setBrandId(car.getCarBrandId()); |
| | | carModel.setRemark("1"); |
| | | carModelMapper.insert(carModel); |
| | | car.setCarModelId(carModel.getId()); |
| | | |
| | | // carModel.setSeat(); |
| | | }else { |
| | | car.setCarModelId(carModels.get(0).getId()); |
| | | } |
| | | }else { |
| | | car.setCarModelId(modelId); |
| | | } |
| | | |
| | | // |
| | | car.setCarColor(color); |
| | | car.setCarLicensePlate(licensePlate); |
| | | car.setAnnualInspectionTime(time); |
| | | car.setDrivingLicenseNumber(drivingLicenseNumber); |
| | | car.setDrivingLicensePhoto(drivingLicensePhoto); |
| | | if(ToolUtil.isNotEmpty(drivingLicenseEndTime)){ |
| | | car.setDrivingLicenseEndTime(sdf.parse(drivingLicenseEndTime)); |
| | | } |
| | | car.setCarPhoto(carPhoto); |
| | | car.setInsurancePhoto(insurancePhoto); |
| | | |
| | | if(ToolUtil.isNotEmpty(commercialInsuranceTime)){ |
| | | car.setCommercialInsuranceTime(sdf.parse(commercialInsuranceTime)); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | car.setCompanyId(driver.getCompanyId()); |
| | | car.setFranchiseeId(driver.getFranchiseeId()); |