whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
src/main/java/com/fgkj/services/BattMap_informationService.java
@@ -1,6 +1,7 @@
package com.fgkj.services;
import com.fgkj.dto.*;
import com.fgkj.dto.ram.Fbs9100_state;
import com.fgkj.mapper.impl.*;
import com.fgkj.mapper.impl.ram.Fbs9100_stateMapper;
import com.fgkj.util.ActionUtil;
@@ -29,13 +30,21 @@
   ServiceModel model = new ServiceModel();
   
   //9.1录入机房信息
   public ServiceModel add(BattMap_information obj){
   public ServiceModel add(BattMap_information obj) {
      ServiceModel model = new ServiceModel();
      Boolean bl=mapper.add(obj)>0;
      if(bl){
      Boolean bl = true;
      try {
         bl = mapper.add(obj) > 0;
      } catch (Exception e) {
         e.printStackTrace();
         model.setCode(0);
         model.setMsg("添加失败!");
         return model;
      }
      if (bl) {
         model.setCode(1);
         model.setMsg("添加成功!");
      }else{
      } else {
         model.setCode(0);
         model.setMsg("添加失败!");
      }
@@ -45,7 +54,15 @@
   //9.1录入机房信息
   public ServiceModel addDev(BattMap_information obj){
      ServiceModel model = new ServiceModel();
      Boolean bl=mapper.addDev(obj)>0;
      Boolean bl=true;
      try {
         bl=mapper.addDev(obj)>0;
      } catch (Exception e) {
         e.printStackTrace();
         model.setCode(0);
         model.setMsg("添加失败!");
         return model;
      }
      if(bl){
         model.setCode(1);
         model.setMsg("添加成功!");
@@ -115,12 +132,36 @@
      if(list!=null&&list.size()>0){
         for(int i=0;i<list.size();i++){
            state="item-normal";
            ServiceModel model=new ServiceModel();
            ServiceModelElectri model=new ServiceModelElectri();
            BattMap_information binformation = list.get(i);
            if(binformation.getFBSDeviceId()/100000==6185){
            if(binformation.getFbsDeviceId()/100000==6185){
               BattInf binf=new BattInf();
               binf.setFbsDeviceId(binformation.getFBSDeviceId());
               state=fbs9100StateMapper.seachDevNow(binf);
               binf.setFbsDeviceId(binformation.getFbsDeviceId());
               List<Fbs9100_state> fbslist =fbs9100StateMapper.seachDevNow(binf);
               if(fbslist!=null &&fbslist.size()>0){
                  Fbs9100_state fbs=fbslist.get(fbslist.size()-1);
                  if(fbs.getDev_61850alarms().contains("true")){
                     state="item-dev_alarm";
                  }else{
                     switch (fbs.getDev_workstate()) {
                        case 0:
                           state="item-online_charge";
                           break;
                        case 1:
                           state="item-pre_charge";
                           break;
                        case 2:
                           state="item-nuclear_cap";
                           break;
                        case 3:
                           state="item-nuclear_cap";
                           break;
                        default:
                           break;
                     }
                  }
               }
            }else{
               numBadBatt=badBattMonMapper.serchByStationId(binformation);            //落后总数
               numAlarm=battAlarmDataMapper.serchByStationId(binformation);      //告警总数
@@ -137,13 +178,12 @@
                  }
               }
            }
            //TODO perry
            // model.setData(list.get(i));
            // model.setCode(numAlarm);      //告警总数
            // model.setSum(numBadBatt);      //落后总数
            // model.setNewsum(numPlan);      //延时总数
            // model.setMsg(state);            //61850状态
            // model.setMsgN(binformation.getFBSDeviceId().toString());
             model.setData(list.get(i));
             model.setCode(numAlarm);      //告警总数
             model.setSum(numBadBatt);      //落后总数
             model.setNewsum(numPlan);      //延时总数
             model.setMsg(state);            //61850状态
             model.setMsgN(binformation.getFbsDeviceId().toString());
            //System.out.println(model);
            listAll.add(model);
         }
@@ -154,18 +194,17 @@
   //9.1百度地图定位根据省份查询所有该区域的机房
   public List serchByCondition(BattMap_information obj){
         List<BattMap_information> list =mapper.serchByCondition(obj);
      System.out.println("list = " + list);
//      System.out.println("list = " + list);
         List listAll=new ArrayList();//存放最后的结果
         if(list!=null&&list.size()>0){
            for(int i=0;i<list.size();i++){
               ServiceModelElectri model=new ServiceModelElectri();
               BattMap_information binformation=list.get(i);
               System.out.println("binformation = " + binformation);
//               System.out.println("binformation = " + binformation);
               int numAlarm=battAlarmDataMapper.serchByStationId(binformation);
               int numBadBatt=badBattMonMapper.serchByStationId(binformation);
               int numPlan=battDischargePlanMapper.serchByStationId(binformation);
               //TODO perry
                model.setData(list.get(i));
                model.setCode(numAlarm);      //告警总数
                model.setSum(numBadBatt);      //落后总数
@@ -185,7 +224,6 @@
            BattInf binf = list.get(i);
            ServiceModelElectri model = new ServiceModelElectri();
            model.setCode(binf.getMonCount());//电池组单体个数
            //TODO perry
            model.setNewsum(binf.getBattGroupId());
            model.setMsg(binf.getBattGroupName());//电池组名称
            List<BadBatt_mon> listb = badBattMonMapper.serchMonBad(binf);
@@ -370,7 +408,7 @@
   public static void main(String[] args) {
      BattMap_informationService service=new BattMap_informationService();
      User_inf uinf=new User_inf();
      uinf.setUId(1002);
      uinf.setuId(1002);
       service.searchUserManageStation(uinf);
   }
}