lxw
2023-03-07 c491231aa592006889873485e2e1a870bf5e1282
src/main/java/com/whyc/service/StationInfService.java
@@ -8,6 +8,7 @@
import com.whyc.dto.Response;
import com.whyc.mapper.*;
import com.whyc.pojo.BattRtdata;
import com.whyc.pojo.BattRtstate;
import com.whyc.pojo.StationInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -15,6 +16,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class StationInfService {
@@ -23,6 +25,9 @@
    @Autowired(required = false)
    private BattRtdataMapper rtdataMapper;
    @Autowired(required = false)
    private BattRtstateMapper rtstateMapper;
    @Autowired(required = false)
    private BattalarmDataMapper battAlmMapper;
@@ -94,20 +99,33 @@
    //运维层首页:站点实时数据推送
    public Object getDevOpAll(int userId) {
        Map<String, Object> map = null;
        try {
            map = new HashMap();
            Map<String, Object> map = new HashMap();
            //头部统计数据
            int stationNum = mapper.getStation(userId);
            map.put("stationNum", stationNum);
            //浮充/充电
            List<BattRtstate> stateList = rtstateMapper.getBattStateStatic(userId);
            Map<Integer, Integer> statemap = new HashMap();
            Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
            for (Integer state : battstateMap.keySet()) {
                statemap.put(state, battstateMap.get(state).size());
            }
            map.put("battState", statemap);
            //整流器故障/负载熔断
            //下面各个站点数据
            List<StationInf> list = mapper.getSystemAll(userId);
            map.put("data", list);
            return new Response().setII(1, true, map, "站点实时数据推送");
        } catch (Exception e) {
            return new Response().set(1, false, "发生异常:" + e.getCause());
        }
        return new Response().setII(1, true, map, "站点实时数据推送");
    }
    //总机房
    public int geStation(int userId) {
        return mapper.geStation(userId);
    public int getStation(int userId) {
        return mapper.getStation(userId);
    }
}