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("添加成功!");
@@ -105,7 +122,7 @@
   }
   
   //首页上查询用户管理的已经设置过位置的机房信息
   public List searchUserManageStation(Object obj){
   public List searchUserManageStation(User_inf obj){
      List<BattMap_information> list = mapper.serchInBattMapByUid(obj);
      List listAll=new ArrayList();//存放最后的结果
      String state="";
@@ -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);
@@ -209,7 +247,8 @@
   }
   
   //9.1电池寿命管理
    public ServiceModel serchByStationid(Object obj){
    public ServiceModel serchByStationid(BattMap_information obj){
      ServiceModel model= new ServiceModel();
       List<BattInf> list=battInfMapper.serchByStationid(obj);
      List listAll=new ArrayList();//存放指定机房的信息
      if(list!=null && list.size()>0){  
@@ -220,16 +259,18 @@
            binf.setNum(dayM);
         }
         model.setCode(1);
         model.setMsg("查询成功!");
         model.setData(list);
      }else{
         model.setCode(0);
         model.setMsg("删除失败!");
         model.setMsg("查询失败!");
      }
      return model;
    } 
    
   //9.1查询未添加物理信息的机房
   public ServiceModel serchNotInBattMap(){
      ServiceModel model= new ServiceModel();
      List list=mapper.serchNotInBattMap();
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -243,7 +284,8 @@
      return model;
   }
   //9.1查询未添加物理信息的机房(用户管理的)
   public ServiceModel serchNotInBattMapByUid(Object obj) {
   public ServiceModel serchNotInBattMapByUid(User_inf obj) {
      ServiceModel model= new ServiceModel();
      List list=mapper.serchNotInBattMapByUid(obj);
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -258,7 +300,8 @@
   }
   //9.1查询已经添加物理信息的机房(用户管理的)
   public ServiceModel serchInBattMapByUid(Object obj) {
   public ServiceModel serchInBattMapByUid(User_inf obj) {
      ServiceModel model= new ServiceModel();
      List list=mapper.serchInBattMapByUid(obj);
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -274,6 +317,7 @@
   
   //9.1查询机房所在的所有省份
   public ServiceModel serchStationName1(){
      ServiceModel model= new ServiceModel();
      List list=mapper.serchStationName1();
      //System.out.println(list.size());
      if(list!=null&&list.size()>0){
@@ -287,7 +331,8 @@
      return model;
   }
   //9.1根据省份查询机房所在的所有城市
   public ServiceModel serchStationName2(Object obj){
   public ServiceModel serchStationName2(BattMap_information obj){
      ServiceModel model= new ServiceModel();
      List list=mapper.serchStationName2(obj);
      //System.out.println(list.size());
      if(list!=null&&list.size()>0){
@@ -301,7 +346,8 @@
      return model;
   }
   //根据省/市/区县查询所有的站点
   public ServiceModel serchStationName3(Object obj){
   public ServiceModel serchStationName3(BattInf obj){
      ServiceModel model= new ServiceModel();
      List list=mapper.serchStationName3(obj);
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -314,7 +360,8 @@
      return model;
   }
   //9.1根据省份和城市查询机房所在的所有机房
   public ServiceModel serchStationName(Object obj){
   public ServiceModel serchStationName(BattMap_information obj){
      ServiceModel model= new ServiceModel();
      List list=mapper.serchStationName(obj);
      //System.out.println(list.size());
      if(list!=null&&list.size()>0){
@@ -342,7 +389,8 @@
      return model;
   }
   //查询站点的经纬度
   public ServiceModel serchAddressByStationName3(Object obj) {
   public ServiceModel serchAddressByStationName3(BattMap_information obj) {
      ServiceModel model = new ServiceModel();
      List list=mapper.serchAddressByStationName3(obj);
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -360,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);
   }
}