| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattRtdataMapper; |
| | | import com.whyc.pojo.BattRtdata; |
| | | import com.whyc.pojo.BattRtstate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @Transactional |
| | | public class BattRtdataService { |
| | | |
| | | @Resource |
| | | private BattRtdataMapper mapper; |
| | | |
| | | //根据电池组id查询该电池组中所有电池信息(图表数据) |
| | | @Transactional |
| | | public Response serchByCondition(int battGroupId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("BattGroupId",battGroupId); |
| | |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0?true:false,pageInfo,""); |
| | | } |
| | | |
| | | public List<List<BattRtdata>> getByDevId(int devId) { |
| | | List<List<BattRtdata>> list = new LinkedList<>(); |
| | | List<BattRtdata> dataList = mapper.getByDevId(devId); |
| | | if(dataList!=null && dataList.size()>0) { |
| | | Map<Long, List<BattRtdata>> map = dataList.stream().collect(Collectors.groupingBy(BattRtdata::getNum)); |
| | | Set<Long> keySet = map.keySet(); |
| | | //keySet = keySet.stream().sorted(Comparator.comparingLong(Long::intValue)).collect(Collectors.toCollection(LinkedHashSet::new)); |
| | | Iterator<Long> iterator = keySet.iterator(); |
| | | while (iterator.hasNext()){ |
| | | Long next = iterator.next(); |
| | | List<BattRtdata> battRtdataList = map.get(next); |
| | | list.add(next.intValue(),battRtdataList); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public void insertMonRecord(int battGroupId, List<Integer> monNumList) { |
| | | mapper.insertMonRecord(battGroupId,monNumList); |
| | | } |
| | | |
| | | public void deleteWhenMonNumBeyond(int battGroupId, int mon_cnt) { |
| | | mapper.deleteWhenMonNumBeyond(battGroupId,mon_cnt); |
| | | } |
| | | |
| | | public int seachBattMaxMonNum(int battGroupId) { |
| | | QueryWrapper<BattRtdata> query = Wrappers.query(); |
| | | query.select("mon_num").eq("BattGroupId", battGroupId).orderByDesc("mon_num").last("limit 1"); |
| | | BattRtdata battRtdata = mapper.selectOne(query); |
| | | if (battRtdata == null) { |
| | | return 0; |
| | | } |
| | | return battRtdata.getMonNum(); |
| | | } |
| | | |
| | | //并联电源多组单体数据 |
| | | public Response serch9141ByCondition(int devId) { |
| | | List<BattRtdata> list = mapper.serch9141ByCondition(devId); |
| | | return new Response().setII(1, list.size() > 0 ? true : false, list, "9141数据"); |
| | | } |
| | | } |