| | |
| | | if(powerInf.getChannelCount() == null){ |
| | | powerInf.setChannelCount(1); |
| | | } |
| | | //电源id查询最大值 |
| | | int powerId = mapper.getMaxPowerId(); |
| | | powerInf.setPowerId(powerId); |
| | | mapper.insert(powerInf); |
| | | |
| | | //电源id获取 |
| | | int powerId = powerInf.getPowerId(); |
| | | //对站点名称进行查询,如果存在则直接绑定关系 |
| | | //如果不存在,则新增后,再绑定关系 |
| | | StationInf stationInf = stationInfService.getByStationName(powerInf.getStationName()); |
| | | if(stationInf == null){ |
| | | Integer stationId = stationInf.getSinfId(); |
| | | if(stationInf == null) { |
| | | StationInf stationNew = new StationInf(); |
| | | stationNew.setSinfName(powerInf.getStationName()); |
| | | int stationId = stationInfService.getMaxStationId(); |
| | | stationNew.setSinfId(stationId+1); |
| | | int stationIdInDB = stationInfService.getMaxStationId(); |
| | | stationId = stationIdInDB + 1; |
| | | stationNew.setSinfId(stationId); |
| | | stationInfService.add(stationNew); |
| | | //站点和电源id关联 |
| | | stationPowerRelationService.add(stationId,powerId); |
| | | } |
| | | mapper.insert(powerInf); |
| | | //站点和电源id关联 |
| | | stationPowerRelationService.add(stationId,powerId); |
| | | return new Response().setII(1,"新增完成"); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response delete(int powerId) { |
| | | mapper.deleteById(powerId); |
| | | //删除跟电源相关的所有关联 |
| | | stationPowerRelationService.deleteByPowerId(powerId); |
| | | return new Response().setII(1,"删除完成"); |
| | | } |
| | | |
| | |
| | | public Response getPage(int pageNum, int pageSize) { |
| | | PageHelper helper = new PageHelper(); |
| | | helper.startPage(pageNum,pageSize); |
| | | QueryWrapper<PowerInf> queryWrapper = Wrappers.query(); |
| | | /*QueryWrapper<PowerInf> queryWrapper = Wrappers.query(); |
| | | queryWrapper.orderByAsc("power_id"); |
| | | List<PowerInf> powerInfs = mapper.selectList(queryWrapper); |
| | | |
| | | List<PowerInf> powerInfs = mapper.selectList(queryWrapper);*/ |
| | | List<PowerInf> powerInfs = mapper.getList(); |
| | | PageInfo<PowerInf> pageInfo = new PageInfo<>(powerInfs); |
| | | return new Response().set(1,pageInfo); |
| | | |
| | | } |
| | | |
| | | public Response getById(int powerId) { |
| | | PowerInf powerInf = mapper.selectById(powerId); |
| | | //PowerInf powerInf = mapper.selectById(powerId); |
| | | PowerInf powerInf = mapper.getById(powerId); |
| | | return new Response().set(1,powerInf); |
| | | } |
| | | |
| | | public Response getProducerList() { |
| | | List<String> producerList = mapper.getProducerList(); |
| | | return new Response().set(1,producerList); |
| | | } |
| | | |
| | | public PowerInf getByBattGroupId(Integer battGroupId) { |
| | | QueryWrapper<PowerInf> query = Wrappers.query(); |
| | | query.eq("binf_id",battGroupId); |
| | | query.last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | } |