whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
src/main/java/com/fgkj/services/Batt_rtstateService.java
@@ -1,25 +1,29 @@
package com.fgkj.services;
import com.fgkj.dto.*;
import com.fgkj.mapper.BattTestData;
import com.fgkj.mapper.impl.Batt_rtdataMapper;
import com.fgkj.mapper.impl.Batt_rtstateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
@Service
public class Batt_rtstateService {
   private ServiceModel model;
   @Autowired
   @Resource
   private Batt_rtstateMapper mapper;
   
   @Autowired
   @Resource
   private Batt_rtdataMapper rtDataMapper;
   
   public ServiceModel serchByCondition(Object obj){
   public ServiceModel serchByCondition(Batt_rtstate obj){
      ServiceModel model = new ServiceModel();
      List list=mapper.serchByCondition(obj);
      if(list!=null && list.size()>0){
         model.setCode(1);
@@ -30,9 +34,9 @@
   }
   
   //9.1根据查询电池组单体的实时数据(电池单体实时信息)
   public ServiceModel serchByMons(Object obj){
      List<Batt_State>  list=mapper.serchMons(obj);
   public ServiceModel serchByMons(BattInf obj){
      ServiceModel model = new ServiceModel();
      List<Batt_State>  list=mapper.serchMons(obj);
      if(list!=null&&list.size()>0){
         for(int i=0;i<list.size();i++){
            BattInf binf=list.get(i).getBinf();            
@@ -55,8 +59,9 @@
   }
   
   //根据电池组id查询该电池组/单体的实时情况(电池续航能力)
   public ServiceModel serchByInfo(Object obj){
      List  list=mapper.serchByInfo(obj);
   public ServiceModel serchByInfo(BattInf obj){
      ServiceModel model = new ServiceModel();
      List<Batt_State>  list=mapper.serchByInfo(obj);
      if(list!=null&&list.size()>0){
         model.setCode(1);
         model.setData(list);
@@ -85,11 +90,18 @@
   }*/
   
   //电池组实时情况+实时电池续航能力查询
   public ServiceModel serchBattLife(Object obj){
      List<Batt_State>  list=mapper.serchBattLife(obj);
   public ServiceModel serchBattLife(Batt_Maint_Dealarm bmd){
      ServiceModel model = new ServiceModel();
      //分页
      PageBean pageBean = bmd.getPageBean();
//      PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true);   //TODO RZG Duplicate column name 'BattGroupId'
      List<Batt_State>  list=mapper.serchBattLife(bmd);
      if(list!=null&&list.size()>0){
         list.get(list.size()-1).getBinf().setMonNum(pageBean.getPageAll());
         PageInfo<Batt_State> pageInfo = new PageInfo<>(list);
         model.setCode(1);
         model.setData(list);
         model.setData(pageInfo);
         model.setMsg("查询成功!");
      }else{
         model.setCode(0);
@@ -101,9 +113,51 @@
   
   //首页上饼状图电池状态比例
   public ServiceModel serchBattStateRate(Object obj){
      List list=mapper.serchBattStateRate(obj);
   public ServiceModel serchBattStateRate(User_inf obj){
      ServiceModel model = new ServiceModel();
      List<Batt_rtstate> list=mapper.serchBattStateRate(obj);
      int test_plan0=0;//状态为无
      int test_plan1=0;//状态为浮充
      int test_plan2=0;//状态为充电
      int test_plan3=0;//状态为放电
      int test_plan4=0;//状态为均充
      if(list!=null&&list.size()>0){
         for (Batt_rtstate batt_rtstate : list) {
            if(batt_rtstate.getBatt_state()==BattTestData.test_plan0){
               test_plan0+=batt_rtstate.getBatt_count();   // COUNT(tb_batt_rtstate.BattGroupId) batt_count
            }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan1){
               test_plan1+=batt_rtstate.getBatt_count();
            }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan2){
               test_plan2+=batt_rtstate.getBatt_count();
            }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan3){
               test_plan3+=batt_rtstate.getBatt_count();
            }else if(batt_rtstate.getBatt_state()==BattTestData.test_plan4){
               test_plan4+=batt_rtstate.getBatt_count();
            }
         }
         list= new ArrayList<>();
         {
            Batt_rtstate bstate = new Batt_rtstate();
            bstate.setBatt_state(BattTestData.test_plan0);
            bstate.setNum(test_plan0);
            list.add(bstate);
            Batt_rtstate bstate1 = new Batt_rtstate();
            bstate1.setBatt_state(BattTestData.test_plan1);
            bstate1.setNum(test_plan1);
            list.add(bstate1);
            Batt_rtstate bstate2 = new Batt_rtstate();
            bstate2.setBatt_state(BattTestData.test_plan2);
            bstate2.setNum(test_plan2);
            list.add(bstate2);
            Batt_rtstate bstate3 = new Batt_rtstate();
            bstate3.setBatt_state(BattTestData.test_plan3);
            bstate3.setNum(test_plan3);
            list.add(bstate3);
            Batt_rtstate bstate4 = new Batt_rtstate();
            bstate4.setBatt_state(BattTestData.test_plan4);
            bstate4.setNum(test_plan4);
            list.add(bstate4);
         }
         model.setCode(1);
         model.setData(list);
         model.setMsg("查询成功!");
@@ -116,8 +170,20 @@
   }
   //测试数据——实时查询中左下角的充放电统计(旧)
   public ServiceModel serchDisOrChargr(){
      List list=mapper.serchDisOrChargr();
      ServiceModel model = new ServiceModel();
      List<Batt_rtstate> list=mapper.serchDisOrChargr();
      if(list!=null&&list.size()>0){
         int charge=0;
         int dischar=0;
         for (Batt_rtstate brt: list) {
            if(brt.getBatt_test_type()==3){
               dischar++;
            }else if(brt.getBatt_test_type()==2){
               charge++;
            }
         }
         list.get(list.size()-1).setNum(charge);
         list.get(list.size()-1).setBatt_count(dischar);
         model.setCode(1);
         model.setData(list);
         model.setMsg("查询成功!");
@@ -132,9 +198,21 @@
   
   //测试数据——实时查询中左下角的充放电统计(用户管理的机房)
   public ServiceModel serchDisOrChargrNew(Object obj){
      List list=mapper.serchDisOrChargrNew(obj);
   public ServiceModel serchDisOrChargrNew(User_inf obj){
      ServiceModel model = new ServiceModel();
      List<Batt_rtstate> list=mapper.serchDisOrChargrNew(obj);
      if(list!=null&&list.size()>0){
         int charge=0;
         int dischar=0;
         for (Batt_rtstate brt: list) {
            if(brt.getBatt_test_type()==3){
               dischar++;
            }else if(brt.getBatt_test_type()==2){
               charge++;
            }
         }
         list.get(list.size()-1).setNum(charge);
         list.get(list.size()-1).setBatt_count(dischar);
         model.setCode(1);
         model.setData(list);
         model.setMsg("查询成功!");
@@ -147,7 +225,8 @@
      return model;
   }
   //实时监测中的查询实时组端信息<-------跨域----------->
   public ServiceModel serchByCondition_ky(Object obj){
   public ServiceModel serchByCondition_ky(Batt_rtstate obj){
      ServiceModel model = new ServiceModel();
      List list=mapper.serchByCondition_ky(obj);
      if(list!=null && list.size()>0){
         model.setCode(1);
@@ -166,15 +245,15 @@
      binf.setStationName1("内蒙古");
      binf.setNum(100);
      
      PageInfo pageInfo = new PageInfo();
      pageInfo.setPageCurr(1);
      pageInfo.setPageSize(10);
      PageBean pageBean = new PageBean();
      pageBean.setPageCurr(1);
      pageBean.setPageSize(10);
      
      User_inf uinf=new User_inf();
      uinf.setUId(1002);
      uinf.setuId(1002);
      
      bmd.setBinf(binf);
      bmd.setPageInfo(pageInfo);
      bmd.setPageBean(pageBean);
      bmd.setUinf(uinf);
      Batt_rtstateService bs=new Batt_rtstateService();
      bs.serchBattLife(bmd);