| | |
| | | package com.ruoyi.sy.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.sy.domain.ArdSyCar; |
| | |
| | | import com.ruoyi.sy.mapper.ArdSyCarLockMapper; |
| | | import com.ruoyi.sy.mapper.ArdSyCarMapper; |
| | | import com.ruoyi.sy.mapper.ArdSyCarRtuMapper; |
| | | import com.ruoyi.sy.param.AddRtuParam; |
| | | import com.ruoyi.sy.service.ArdSyCarLockService; |
| | | import com.ruoyi.sy.vo.CarLockVo; |
| | | import com.ruoyi.sy.vo.CarVo; |
| | | import com.ruoyi.sy.vo.RtuVo; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | |
| | | @Autowired |
| | | private ArdSyCarLockMapper lockMapper; |
| | | |
| | | |
| | | @Override |
| | | public List<CarVo> car() { |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int addRtu(String carId) { |
| | | public int addRtu(AddRtuParam addRtuParam) { |
| | | ArdSyCarRtu ardSyCarRtu = new ArdSyCarRtu(); |
| | | ardSyCarRtu.setId(String.valueOf(UUID.randomUUID())); |
| | | ardSyCarRtu.setCarId(carId); |
| | | ardSyCarRtu.setTopicPublish("/p"+carId+"/"); |
| | | ardSyCarRtu.setTopicSubscribe("/p"+carId+"/set/"); |
| | | ardSyCarRtu.setCarId(addRtuParam.getCarId()); |
| | | ardSyCarRtu.setTopicPublish("/p"+addRtuParam.getCarId()+"/"); |
| | | ardSyCarRtu.setTopicSubscribe("/p"+addRtuParam.getCarId()+"/set/"); |
| | | ardSyCarRtu.setInstallType(addRtuParam.getInstallType()); |
| | | ardSyCarRtu.setUnloadType(addRtuParam.getUnloadType()); |
| | | rtuMapper.insert(ardSyCarRtu); |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("car_id",carId); |
| | | queryWrapper.eq("car_id",addRtuParam.getCarId()); |
| | | ArdSyCar ardSyCar = ardSyCarMapper.selectOne(queryWrapper); |
| | | ardSyCar.setReserved1(ardSyCarRtu.getId()); |
| | | return ardSyCarMapper.updateById(ardSyCar); |
| | |
| | | |
| | | @Override |
| | | public List<ArdSyCarLock> carLock(String rtu) { |
| | | QueryWrapper<ArdSyCarLock> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("rtu_id",rtu); |
| | | return lockMapper.selectList(queryWrapper); |
| | | List<ArdSyCarLock> locks = new ArrayList<>(); |
| | | try { |
| | | QueryWrapper<ArdSyCarLock> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("rtu_id",rtu); |
| | | locks = lockMapper.selectList(queryWrapper); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | return locks; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return ardSyCarMapper.updateById(ardSyCar); |
| | | } |
| | | |
| | | @Override |
| | | public List<CarVo> queryCar(List<String> list) { |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne("reserved_1","").notIn("car_id",list); |
| | | List<ArdSyCar> ardSyCars = ardSyCarMapper.selectList(queryWrapper); |
| | | return carAnalysis(ardSyCars); |
| | | } |
| | | |
| | | @Override |
| | | public List<CarVo> addCarBefore(String id) { |
| | | QueryWrapper<ArdSyCar> ardSyCarQueryWrapper = new QueryWrapper<>(); |
| | | ardSyCarQueryWrapper.eq("car_id",id); |
| | | List<ArdSyCar> carList = ardSyCarMapper.selectList(ardSyCarQueryWrapper); |
| | | return carAnalysis(carList); |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdSyCarLock> data(String msg) { |
| | | JSONObject jsonObject = JSONObject.parseObject(msg); |
| | | List<ArdSyCarLock> lockList = new ArrayList<>(); |
| | | ArdSyCarLock ardSyCarLock1 = new ArdSyCarLock(); |
| | | ardSyCarLock1.setRelay("A01"); |
| | | ardSyCarLock1.setRelayInfo(String.valueOf(jsonObject.getInteger("A01"))); |
| | | ardSyCarLock1.setCurrent("C01"); |
| | | ardSyCarLock1.setCurrentInfo(String.valueOf(jsonObject.getFloat("C01"))); |
| | | lockList.add(ardSyCarLock1); |
| | | ArdSyCarLock ardSyCarLock2 = new ArdSyCarLock(); |
| | | ardSyCarLock2.setRelay("A02"); |
| | | ardSyCarLock2.setRelayInfo(String.valueOf(jsonObject.getInteger("A02"))); |
| | | ardSyCarLock2.setCurrent("C02"); |
| | | ardSyCarLock2.setCurrentInfo(String.valueOf(jsonObject.getFloat("C02"))); |
| | | lockList.add(ardSyCarLock2); |
| | | return lockList; |
| | | } |
| | | |
| | | @Override |
| | | public int updLock(ArdSyCarLock ardSyCarLock) { |
| | | return lockMapper.updateById(ardSyCarLock); |
| | | } |
| | | |
| | | |
| | | //车辆列表封装 |
| | | public List<CarVo> carAnalysis(List<ArdSyCar> ardSyCars){ |
| | | List<CarVo> list = new ArrayList<>(); |
| | | for (int i = 0; i < ardSyCars.size(); i++) { |
| | |
| | | SysDept sysDept = sysDeptMapper.selectById(ardSyCar.getDeptId()); |
| | | carVo.setDeptName(sysDept.getDeptName()); |
| | | carVo.setRtu(ardSyCar.getReserved1()); |
| | | carVo.setCarModel(ardSyCar.getCarModel()); |
| | | list.add(carVo); |
| | | } |
| | | return list; |