lxw
2023-08-15 160e150009b51a39fa95d9462c3798ba28d51a09
src/main/java/com/whyc/service/BattMapInformationService.java
@@ -1,14 +1,12 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whyc.dto.Response;
import com.whyc.mapper.BadbattMonMapper;
import com.whyc.mapper.BattMapInformationMapper;
import com.whyc.mapper.BattdischargePlanMapper;
import com.whyc.pojo.BattMapInformation;
import com.whyc.pojo.BattalarmData;
import com.whyc.pojo.Battinf;
import com.whyc.pojo.UserInf;
import com.whyc.mapper.StationInfMapper;
import com.whyc.pojo.*;
import com.whyc.util.ActionUtil;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.stereotype.Service;
@@ -31,14 +29,41 @@
    @Resource
    private BattalarmDataService battalarmDataService;
    public Response add(BattMapInformation entity){
    @Resource
    private StationInfMapper stationInfMapper;
    public Response add(BattMapInformation entity) {
        mapper.insert(entity);
        return new Response().set(1,true,"添加成功");
        //查看在电池组机房是否存在stationId
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("stationId", entity.getStationId());
        wrapper.last("limit 1");
        StationInf sinf = stationInfMapper.selectOne(wrapper);
        if (sinf != null) {
            UpdateWrapper sinfWrapper = new UpdateWrapper();
            sinfWrapper.set("stationLongitude", entity.getLongitude());
            sinfWrapper.set("stationLatitude", entity.getLatitude());
            sinfWrapper.eq("stationId", entity.getStationId());
            stationInfMapper.update(null, sinfWrapper);
        }
        return new Response().set(1, true, "添加成功");
    }
    public Response update(BattMapInformation entity){
    public Response update(BattMapInformation entity) {
        mapper.updateById(entity);
        return new Response().set(1,true,"更新成功");
        //查看在电池组机房是否存在stationId
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("stationId", entity.getStationId());
        wrapper.last("limit 1");
        StationInf sinf = stationInfMapper.selectOne(wrapper);
        if (sinf != null) {
            UpdateWrapper sinfWrapper = new UpdateWrapper();
            sinfWrapper.set("stationLongitude", entity.getLongitude());
            sinfWrapper.set("stationLatitude", entity.getLatitude());
            sinfWrapper.eq("stationId", entity.getStationId());
            stationInfMapper.update(null, sinfWrapper);
        }
        return new Response().set(1, true, "更新成功");
    }
@@ -59,13 +84,13 @@
        QueryWrapper<BattMapInformation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("stationId",stationId);
        List<BattMapInformation> list = mapper.selectList(queryWrapper);
        for (BattMapInformation battMapInformation:list) {
        /*for (BattMapInformation battMapInformation:list) {
            String address = battMapInformation.getAddress();
            String[] split = address.split("-");
            battMapInformation.setStationName1(split[0]);
            battMapInformation.setStationName2(split[1]);
            battMapInformation.setStationName5(split[2]);
        }
        }*/
        return new Response().set(1,list,"查询成功");
    }
@@ -88,7 +113,8 @@
        int numPlan=0;//延迟总数
        state="item-normal";
        numBadBatt=badBattMonService.getBadCountByStationId(stationId);      //落后总数
        //太供局暂不显示落后单体数量
        //numBadBatt=badBattMonService.getBadCountByStationId(stationId);      //落后总数
        //numAlarm=(new Battalarm_dataDAOImpl()).serchByStationId(binformation);   //告警总数
        List<BattalarmData> alarmDataList = battalarmDataService.getCountByStationId(stationId);   //告警确认和未确认总数
        int battAlarmConfirmed = 0;
@@ -116,8 +142,8 @@
        }
        Map<String,Object> map = new HashedMap();
        map.put("battAlarmStr",battAlarmStr);
        map.put("numBadBatt",numBadBatt);
        map.put("numPlan",numAlarm);
        map.put("numBadBatt",0);
        map.put("numPlan",numPlan);
        return new Response().set(1,map,"查询成功");
    }
@@ -143,20 +169,20 @@
        }
        //用户管理内的异常机房id集合
        ArrayList<String> abnormalList = new ArrayList<>();
        for (BattMapInformation information:level1Behind){
            String stationId = information.getStationId();
            //用户管理内的站点进行操作
            if(stationList.contains(stationId)){
                //从结果机房list定位到对应的元素
                int index = stationList.indexOf(stationId);
                information.setNum(1);
                list.set(index,information);
                abnormalList.add(stationId);
            }
        }
        //太供调整地图显示暂去除异常为1的标识
//        for (BattMapInformation information:level1Behind){
//            String stationId = information.getStationId();
//            //用户管理内的站点进行操作
//            if(stationList.contains(stationId)){
//                //从结果机房list定位到对应的元素
//                int index = stationList.indexOf(stationId);
//
//                information.setNum(1);
//
//                list.set(index,information);
//                abnormalList.add(stationId);
//            }
//        }
        for (BattMapInformation information:level2Alarm){
            String stationId = information.getStationId();
            //用户管理内的站点进行操作