| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.BattInfAndEnduranceDTO; |
| | | import com.whyc.dto.BatteryRTState; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattInfMapper; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.PowerInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.MathUtil; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public Response<Map> getDevCountMap(int userId) { |
| | | public Response getDevCountMap(int userId) { |
| | | try { |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | int battGroupCount = battInfMapper.getBattGroupNum(userId); |
| | | int devCount = battInfMapper.getDevNum(userId); |
| | |
| | | map.put("battGroupCount",battGroupCount); |
| | | map.put("devCount",devCount); |
| | | map.put("powerNum",powerNum); |
| | | return new Response<Map>().set(1,map); |
| | | return new Response().setII(1,true, map,null); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | public List<Battinf> getBattGroupList(int userId) { |
| | | return battInfMapper.getBattGroupList(userId); |
| | | } |
| | | /** |
| | | * 获取电池组的实际容量 |
| | | */ |
| | | public List<BatteryRTState> getBatteryCap(int userId){ |
| | | return battInfMapper.getBatteryCap(userId); |
| | | } |
| | | |
| | | public int getCapAlarmNum(int userId){ |
| | | int capAlarmNum=0; |
| | | List<BatteryRTState> stateList = getBatteryCap(userId); |
| | | //查询容量告警阈值,暂定为70% TODO 后续从数据库读取 |
| | | for (int i = 0; i < stateList.size(); i++) { |
| | | BatteryRTState state = stateList.get(i); |
| | | Float batteryRealCap = state.getBatteryRealCap(); |
| | | Float capStd = state.getMonCapStd(); |
| | | Float realCapDivide = (Float) MathUtil.divide(batteryRealCap, capStd, MathUtil.TYPE_FLOAT); |
| | | if(realCapDivide<=0.7){ |
| | | capAlarmNum++; |
| | | } |
| | | } |
| | | return capAlarmNum; |
| | | } |
| | | } |