| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.equipage.entity.Car; |
| | | import org.springblade.modules.equipage.excel.CarExcel; |
| | | import org.springblade.modules.equipage.mapper.CarMapper; |
| | | import org.springblade.modules.equipage.service.CarService; |
| | | import org.springblade.modules.equipage.vo.CarVo; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IUserDeptService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 车辆服务实现类 |
| | |
| | | */ |
| | | @Service |
| | | public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarService { |
| | | |
| | | @Autowired |
| | | private IUserDeptService userDeptService; |
| | | @Autowired |
| | | private MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 车辆分页信息 |
| | |
| | | public CarVo selectCarInfo(Car car) { |
| | | return baseMapper.selectCarInfo(car); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 车辆批量导入 |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importCar(List<CarExcel> data, Boolean isCovered,String deptId) { |
| | | if (data.size()>0){ |
| | | //遍历 |
| | | data.forEach(carExcel -> { |
| | | Car car = Objects.requireNonNull(BeanUtil.copy(carExcel, Car.class)); |
| | | //设置部门id |
| | | String deptIds = userDeptService.selectIn(carExcel.getDeptId()); |
| | | if (null!=deptIds && !deptIds.equals("")) { |
| | | if (null != deptId && !deptId.equals("")) { |
| | | if (!deptId.equals(deptIds)) { |
| | | throw new ServiceException("导入失败!不能导入不是本公司的车辆信息数据!"); |
| | | } |
| | | } |
| | | car.setDeptId(Long.parseLong(deptIds)); |
| | | }else { |
| | | //如果deptIds 为空,则说明还没有改公司 |
| | | throw new ServiceException("导入失败!公司名:["+carExcel.getDeptId()+"]不存在!"); |
| | | } |
| | | |
| | | //新增车辆数据 |
| | | this.save(car); |
| | | |
| | | //数据同步 |
| | | String s = "insert into blade_user(" + |
| | | "id,dept_id,car_number,person_in_charge,brand,umweltsatz,mode) " + |
| | | "values(" + "'" + car.getId() + "'" + |
| | | "," + "'" + car.getDeptId() + "'" + |
| | | "," + "'" + car.getCarNumber() + "'" + |
| | | "," + "'" + car.getPersonInCharge() + "'" + |
| | | "," + "'" + car.getBrand() + "'" + |
| | | "," + "'" + car.getUmweltsatz() + "'" + |
| | | "," + "'" + car.getMode() + "'" + ")"; |
| | | //FtpUtil.sqlFileUpload(s); |
| | | myAsyncService.dataSync(s); |
| | | |
| | | }); |
| | | }else { |
| | | throw new ServiceException("没有数据"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<Object,Object>> selectCar() { |
| | | return baseMapper.selectCar(); |
| | | } |
| | | } |