whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
src/main/java/com/fgkj/services/Batt_maint_infService.java
@@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@Service
@@ -38,42 +39,50 @@
   
   
   //2.1电池故障维护记录查询
   public ServiceModel serchMaint(Object obj){
      Batt_Maint_Dealarm bmd = (Batt_Maint_Dealarm) obj;
   public ServiceModel serchMaint(Batt_Maint_Dealarm bmd){
      ServiceModel model = new ServiceModel();
      User_inf uinf=new User_inf();
      Batt_maint_process pinf=new Batt_maint_process();
      List<Batt_Maint_Dealarm> list =mapper.serchByCondition(bmd);
      for(int i=0;i<list.size();i++){
         Batt_maint_inf mainf=list.get(i).getMainf();
         if(list.get(i).getMainf().getUsr_id()!=null){
            uinf.setuId(list.get(i).getMainf().getUsr_id());
            mainf.setUname(((List<User_inf>) uservice.serchuName(uinf).getData()).get(0).getuName());
         //   System.out.println(mainf.getuName());
            }
            if(list.get(i).getMainf().getCopy_uids()!=null&&list.get(i).getMainf().getCopy_uids().length()>0){
               //System.out.println(list.get(i).getMainf().getCopy_uids());
               String[] names=list.get(i).getMainf().getCopy_uids().split(",");
               String copyname=new String();
               for (String string : names) {
                  uinf.setuId(Integer.parseInt(string));
                  copyname+=((List<User_inf>) uservice.serchuName(uinf).getData()).get(0).getuName()+",";
      List<Batt_Maint_Dealarm> list = null;
      try {
         list = mapper.serchByCondition(bmd);
         for(int i=0;i<list.size();i++){
            Batt_maint_inf mainf=list.get(i).getMainf();
            if(list.get(i).getMainf().getUsr_id()!=null){
               uinf.setuId(list.get(i).getMainf().getUsr_id());
               mainf.setUname(((List<User_inf>) uservice.serchuName(uinf).getData()).get(0).getuName());
            //   System.out.println(mainf.getuName());
               }
               copyname=copyname.substring(0, copyname.length()-1);
               mainf.setCopy_name(copyname);
               //System.out.println(mainf.getCopy_name());
            }
            if(list.get(i).getMainf().getAppoint_uid()!=null){
            uinf.setuId(list.get(i).getMainf().getAppoint_uid());
            mainf.setAppoint_name(((List<User_inf>) uservice.serchuName(uinf).getData()).get(0).getuName());
         //   System.out.println(mainf.getAppoint_name());
            }
         list.get(i).setMainf(mainf);
         //System.out.println(list.size());
               if(list.get(i).getMainf().getCopy_uids()!=null&&list.get(i).getMainf().getCopy_uids().length()>0){
                  //System.out.println(list.get(i).getMainf().getCopy_uids());
                  String[] names=list.get(i).getMainf().getCopy_uids().split(",");
                  String copyname=new String();
                  for (String string : names) {
                     uinf.setuId(Integer.parseInt(string));
                     copyname+=((List<User_inf>) uservice.serchuName(uinf).getData()).get(0).getuName()+",";
                  }
                  copyname=copyname.substring(0, copyname.length()-1);
                  mainf.setCopy_name(copyname);
                  //System.out.println(mainf.getCopy_name());
               }
               if(list.get(i).getMainf().getAppoint_uid()!=null){
               uinf.setuId(list.get(i).getMainf().getAppoint_uid());
               mainf.setAppoint_name(((List<User_inf>) uservice.serchuName(uinf).getData()).get(0).getuName());
            //   System.out.println(mainf.getAppoint_name());
               }
            list.get(i).setMainf(mainf);
            //System.out.println(list.size());
         }
      } catch (NumberFormatException e) {
         e.printStackTrace();
         model.setCode(0);
         model.setMsg("查询失败!");
         return model;
      }
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -93,20 +102,44 @@
    * master_check存放包机人 
    * remark存放品牌
    */
   public List serchByCondition(Object obj) {
      //System.out.println(obj+"&&&&&&&&&&&&");
      Batt_User_Permit bup = (Batt_User_Permit) obj;
   public List serchByCondition(Batt_User_Permit bup) {
      ServiceModelElectri model = new ServiceModelElectri();
      BattInf binf=bup.getBinf();
      List<Batt_maint_inf> list = againMapper.serchByCondition(binf);
      List listb=battInfMapper.searchAll();
      List<Batt_maint_inf> list = againMapper.serchByCondition(binf);//TODO 无数据待测试
      List<Integer> listb=battInfMapper.searchAll();
      listb = listb.stream().distinct().collect(Collectors.toList());//去重 JDK8
      // 总电池数
      int allBatt=listb.size();
      // 超时次数
      List<ServiceModel> listmodel=new ArrayList<ServiceModel>();
      List<ServiceModelElectri> listmodel=new ArrayList<>();
      
      //System.out.println(list.get(1));
      if (list != null && list.size() > 0) {
         for (int i = 0; i < list.size(); i++) {
            // maint_result存放统计方式
            list.get(i).setMaint_result(binf.getDeviceName());
            // fault_caption存放维护区
            if (binf.getStationName1().equals("")) {
               list.get(i).setFault_caption("全部");
            } else {
               list.get(i).setFault_caption(binf.getStationName1());
            }
            // master_check存放包机人
            if (binf.getStationName().equals("")) {
               list.get(i).setMaster_check("全部");
            } else {
               list.get(i).setMaster_check(binf.getStationName());
            }
            // remark存放品牌
            if (binf.getBattProducer().equals("")) {
               list.get(i).setRemark("全部");
            } else {
               list.get(i).setRemark(binf.getBattProducer());
            }
            //------------------------------------------------------------------------------
            //System.out.println(list.size()+"lll");
            int overTime = 0;
            // 未完成次数
@@ -163,11 +196,10 @@
            if (list.get(i).getMaint_done() == 0) {
               lastNum++;
            }
            model = new ServiceModel();
            model.setCode(1);
            //TODO perry
            // model.setMsgN(perid_Time); // 时间段
            // model.setSum(list.size()); // 故障次数
             model.setMsgN(perid_Time); // 时间段
             model.setSum(list.size()); // 故障次数
            Float percentBatt=0f;
            if(allBatt!=0){
               percentBatt= (float) (list.size()/ allBatt);
@@ -176,31 +208,31 @@
            //System.out.println(allBatt);
            //System.out.println(percentBatt);
            //TODO perry
            /*model.setLowCH(percentBatt);//电池故障率
            model.setLowCH(percentBatt);//电池故障率
            model.setNewsum(lastNum); // 未完成次数
            Float percent = (float) (overTime / list.size());
            model.setLowCA(percent); // 超时率
            model.setMsg(list.get(i).getFault_caption());//维护区
            model.setMsgO(list.get(i).getMaster_check());    //责任人
            model.setMsgV(list.get(i).getRemark());//电池品牌*/
            model.setMsgV(list.get(i).getRemark());//电池品牌
            listmodel.add(model);
         }
      } else {   
         model.setCode(0);
         //TODO perry
         // model.setMsgN("0");
          model.setMsgN("0");
         listmodel.add(model);
      }
      ServiceModel lastModel=new ServiceModel();
      ServiceModelElectri lastModel=new ServiceModelElectri();
      //TODO perry
      /*lastModel.setMsgN("0");
      lastModel.setMsgN("0");
      lastModel.setCode(model.getCode());
      lastModel.setMsg(model.getMsg());
      lastModel.setLowCH(model.getLowCH());
      lastModel.setLowCA(model.getLowCA());
      lastModel.setMsgO(model.getMsgO());
      lastModel.setMsgV(model.getMsgV());*/
      lastModel.setMsgV(model.getMsgV());
      listmodel.add(lastModel);//补全最后一次时间改变
   //   System.out.println(listmodel.size());
      int num=0;//存放下发作业数
@@ -291,13 +323,13 @@
   }
   //2.1 电池维护记录查询(删除记录)
   public ServiceModel delete(Object obj) {
      Batt_maint_inf mainf=(Batt_maint_inf) obj;
   public ServiceModel delete(Batt_maint_inf mainf) {
      ServiceModel model=new ServiceModel();
      Batt_maint_process bprocess=new Batt_maint_process();
      bprocess.setBatt_maint_rec_id(mainf.getNum());            //通过Batt_maint_rec_id属性删除
      Boolean bl = mapper.del(mainf);
      Boolean bl = mapper.del(mainf)>0;
      if (bl) {
         Boolean blp=processMapper.del(bprocess);
         Boolean blp=processMapper.del(bprocess)>0;
         if(blp){
            model.setCode(1);
            model.setMsg("删除成功!");
@@ -334,7 +366,7 @@
   //0.3查询所有的维护记录(只传page对象)
   public ServiceModel search(){
      //Batt_Maint_Dealarm bmd=(Batt_Maint_Dealarm) obj;
      ServiceModel model = new ServiceModel();
      List<Batt_Maint_Dealarm> list=mapper.search();
      if(list!=null&&list.size()>0){
         model.setCode(1);
@@ -347,22 +379,23 @@
   }
   //0.4电池组故障率
   public ServiceModel searchAll() {
   public ServiceModelOnce searchAll() {
      List<Batt_maint_inf> list = mapper.searchAll();
      List listb=battInfMapper.searchAll();
      ServiceModelOnce model = new ServiceModelOnce();
      List<Integer> listb=battInfMapper.searchAll();
      listb = listb.stream().distinct().collect(Collectors.toList());//去重 JDK8
      if(list!=null && listb!=null){
         //TODO perry
         /*model.setCode(1);
         model.setNewsum(list.size());
         model.setSum(listb.size());*/
         model.setCode(1);
         model.setNewsum(list.size());   //所有故障的电池组
         model.setSum(listb.size());      //所有的电池组
      }
      //System.out.println(model);
      return model;
   }
   //0.4/0.8电池组故障率/维护率(最新)
   public ServiceModel searchByStationName(Object obj) {
      Batt_Maint_Dealarm bmd=(Batt_Maint_Dealarm) obj;
   public ServiceModelOnce searchByStationName(Batt_Maint_Dealarm bmd) {
      ServiceModelOnce model = new ServiceModelOnce();
      BattInf binf=bmd.getBinf();
      Batt_maint_inf mainf=bmd.getMainf();
      List<Batt_maint_inf> list = mapper.searchByStationName(bmd);      //故障数
@@ -370,15 +403,15 @@
      List<Batt_maint_inf> listD = mapper.searchByStationName(bmd);   //故障维护数
      
      List<BattInf> listB=battInfMapper.search(binf);//
      //TODO perry
      /*model.setCode(listD.size());     ////故障维护数
      listB = listB.stream().distinct().collect(Collectors.toList());//去重 JDK8
      model.setCode(listD.size());     ////故障维护数
      model.setNewsum(listB.size());    //电池组数
      model.setSum(list.size());*/        //故障数
      model.setSum(list.size());        //故障数
      return model;
   }
   
   //根据电池组id查询电池的故障记录
   public ServiceModel searchByBattgroupId(Object obj) {
   public ServiceModel searchByBattgroupId(Batt_maint_inf obj) {
      ServiceModel model=new ServiceModel();
      List<Batt_maint_inf> list = mapper.searchByBattgroupId(obj);
      User_inf uinf=new User_inf();