whycxzp
2021-02-05 8cf143a196e20ddd68cbf9855290f2d3a0b78da0
src/main/java/com/fgkj/services/Battresdata_infService.java
@@ -7,14 +7,13 @@
import com.fgkj.mapper.impl.BattInfMapper;
import com.fgkj.mapper.impl.BattresdataMapper;
import com.fgkj.mapper.impl.Battresdata_infMapper;
import com.fgkj.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.fgkj.util.ActionUtil;
import com.fgkj.util.DateUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;
import javax.annotation.Resource;
@Service
public class Battresdata_infService {
@@ -28,8 +27,8 @@
   private BattresdataMapper battResDataMapper;
   
   public ServiceModel add(Object obj) {
      Boolean bl = mapper.add(obj);
   public ServiceModel add(Battresdata_inf dataInf) {
      Boolean bl = mapper.add(dataInf);
      if (bl) {
         model.setCode(1);
         model.setMsg("添加成功!");
@@ -40,8 +39,8 @@
   }
   public ServiceModel update(Object obj) {
      Boolean bl = mapper.update(obj);
   public ServiceModel update(Battresdata_inf dataInf) {
      Boolean bl = mapper.update(dataInf);
      if (bl) {
         model.setCode(1);
         model.setMsg("修改成功!");
@@ -51,8 +50,8 @@
      return model;
   }
   public ServiceModel delete(Object obj) {
      Boolean bl = mapper.del(obj);
   public ServiceModel delete(int num) {
      Boolean bl = mapper.del(num);
      if (bl) {
         model.setCode(1);
         model.setMsg("删除成功!");
@@ -63,9 +62,9 @@
   }
   //筛选存在battresdata_inf表中的数据
   public ServiceModel serchByCondition(Object obj){
   public ServiceModel serchByCondition(Battresdata_inf dataInf){
         model=new ServiceModel();
         List list=mapper.serchByCondition(obj);
         List list=mapper.serchByCondition(dataInf);
         if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
@@ -77,9 +76,9 @@
         return model;
      }
   //测试battgroupid在battresdata_inf中是否存在
   public ServiceModel judge(Object obj){
   public ServiceModel judge(Battresdata_inf dataInf){
      model=new ServiceModel();
      List<String> list=mapper.judge(obj);
      List<String> list=mapper.judge(dataInf);
      if(list!=null && list.size()>0){
         model.setCode(1);
         model.setData(list);
@@ -92,10 +91,6 @@
   //查询所有
   public ServiceModel searchAll() {
      List<Battresdata_inf> list = mapper.searchAll();
//      for (Battresdata_inf u : list) {
//         System.out.println(u);
//      }
      // System.out.println(list);
      if (list != null && list.size() > 0) {
         model.setCode(1);
         model.setData(list);
@@ -109,71 +104,65 @@
       * test_record_count_ex中存放统计季度:一季度为1 以此类推
       * test_type 中存放年份
       * upload_usr_id 中存上传方式 100:全部  0:自动上传  用户ID对应手动上传*/
   public ServiceModel serchComplete(Object obj){
      Battresdata_inf rinf=(Battresdata_inf) obj;
      int level=rinf.getData_available();
      int year=rinf.getTest_type();//获取年份
   public ServiceModel serchComplete(Battresdata_inf dataInf){
      int level=dataInf.getData_available();
      int year=dataInf.getTest_type();//获取年份
      int firstMonth=0;//获取起始月份
      int lastMonth=0;//获取结束月份
      String dateFirst=""; //起始时间
      String dateLast="";  //结束时间
      //做时间判断
      if(rinf.getTest_record_count()==0){
      if(dataInf.getTest_record_count()==0){
          firstMonth=0;//获取起始月份
          lastMonth=11;//获取结束月份
      }else if(rinf.getTest_record_count()==1){
          if(rinf.getTest_record_count_ex()==1){
      }else if(dataInf.getTest_record_count()==1){
          if(dataInf.getTest_record_count_ex()==1){
             firstMonth=0;//获取起始月份
             lastMonth=2;//获取结束月份
          }else if(rinf.getTest_record_count_ex()==2){
          }else if(dataInf.getTest_record_count_ex()==2){
             firstMonth=3;//获取起始月份
             lastMonth=5;//获取结束月份
          }else if(rinf.getTest_record_count_ex()==3){
          }else if(dataInf.getTest_record_count_ex()==3){
             firstMonth=6;//获取起始月份
             lastMonth=8;//获取结束月份
          }else if(rinf.getTest_record_count_ex()==4){
          }else if(dataInf.getTest_record_count_ex()==4){
             firstMonth=9;//获取起始月份
             lastMonth=11;//获取结束月份
          }
      }
      dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
      try {
         rinf.setTest_starttime(DateUtil.sdf.parse(dateFirst));
         //System.out.println(dateFirst.substring(0,10));
         dataInf.setTest_starttime(DateUtil.sdf.parse(dateFirst));
         dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
         rinf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast));
         dataInf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast));
      } catch (ParseException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
      //System.out.println(dateLast.substring(0,10));
      //System.out.println(dateFirst.substring(0,11).concat(dateLast.substring(0,10)));
      List<BattInf> listB=battInfMapper.serchBylevel(level);
      if(listB!=null&&listB.size()>0){
        for(int i=0;i<listB.size();i++){
          if(level==1){
             rinf.setStationname1(listB.get(i).getStationName1());
             rinf.setStationname2("");
             rinf.setStationname3("");
             rinf.setStationname4("");
            dataInf.setStationname1(listB.get(i).getStationName1());
            dataInf.setStationname2("");
            dataInf.setStationname3("");
            dataInf.setStationname4("");
         }else if(level==2){
            rinf.setStationname1(listB.get(i).getStationName1());
             rinf.setStationname2(listB.get(i).getStationName2());
             rinf.setStationname3("");
             rinf.setStationname4("");
            dataInf.setStationname1(listB.get(i).getStationName1());
            dataInf.setStationname2(listB.get(i).getStationName2());
            dataInf.setStationname3("");
            dataInf.setStationname4("");
         }else if(level==3){
            rinf.setStationname1(listB.get(i).getStationName1());
             rinf.setStationname2(listB.get(i).getStationName2());
             rinf.setStationname3(listB.get(i).getStationName3());
             rinf.setStationname4("");
            dataInf.setStationname1(listB.get(i).getStationName1());
            dataInf.setStationname2(listB.get(i).getStationName2());
            dataInf.setStationname3(listB.get(i).getStationName3());
            dataInf.setStationname4("");
         }else if(level==4){
            rinf.setStationname1(listB.get(i).getStationName1());
             rinf.setStationname2(listB.get(i).getStationName2());
             rinf.setStationname3(listB.get(i).getStationName3());
             rinf.setStationname4(listB.get(i).getStationName4());
            dataInf.setStationname1(listB.get(i).getStationName1());
            dataInf.setStationname2(listB.get(i).getStationName2());
            dataInf.setStationname3(listB.get(i).getStationName3());
            dataInf.setStationname4(listB.get(i).getStationName4());
          }
         List<Battresdata_inf> list=mapper.serchComplete(rinf);
         List<Integer> list=mapper.serchComplete(dataInf);
          listB.get(i).setMonCount(list.size());//完成数
          listB.get(i).setStationName9(dateFirst.substring(0,11).concat(dateLast.substring(0,10)));
          if(listB.get(i).getMonNum()!=0){
@@ -202,39 +191,38 @@
       * test_record_count 中存放统计方式:年度统计为0 季度统计为1
       * test_record_count_ex中存放统计季度:一季度为1 以此类推
       * test_type 中存放年份*/
   public ServiceModel serchSer(Object obj) {
      Battresdata_inf rinf=(Battresdata_inf) obj;
      int level=rinf.getData_available();
      int year=rinf.getTest_type();//获取年份
   public ServiceModel serchSer(Battresdata_inf dataInf) {
      int level=dataInf.getData_available();
      int year=dataInf.getTest_type();//获取年份
      int firstMonth=0;//获取起始月份
      int lastMonth=0;//获取结束月份
      String dateFirst=""; //起始时间
      String dateLast="";  //结束时间
      //做时间判断
      if(rinf.getTest_record_count()==0){
      if(dataInf.getTest_record_count()==0){
          firstMonth=0;//获取起始月份
          lastMonth=11;//获取结束月份
      }else if(rinf.getTest_record_count()==1){
          if(rinf.getTest_record_count_ex()==1){
      }else if(dataInf.getTest_record_count()==1){
          if(dataInf.getTest_record_count_ex()==1){
             firstMonth=0;//获取起始月份
             lastMonth=2;//获取结束月份
          }else if(rinf.getTest_record_count_ex()==2){
          }else if(dataInf.getTest_record_count_ex()==2){
             firstMonth=3;//获取起始月份
             lastMonth=5;//获取结束月份
          }else if(rinf.getTest_record_count_ex()==3){
          }else if(dataInf.getTest_record_count_ex()==3){
             firstMonth=6;//获取起始月份
             lastMonth=8;//获取结束月份
          }else if(rinf.getTest_record_count_ex()==4){
          }else if(dataInf.getTest_record_count_ex()==4){
             firstMonth=9;//获取起始月份
             lastMonth=11;//获取结束月份
          }
      }
      dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
      try {
         rinf.setTest_starttime(DateUtil.sdf.parse(dateFirst));
         dataInf.setTest_starttime(DateUtil.sdf.parse(dateFirst));
         //System.out.println(dateFirst.substring(0,10));
         dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
         rinf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast));
         dataInf.setTest_starttime_ex(DateUtil.sdf.parse(dateLast));
      } catch (ParseException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
@@ -244,29 +232,29 @@
      if(listB!=null&&listB.size()>0){
         for(int i=0;i<listB.size();i++){
            if(level==1){
               rinf.setStationname1(listB.get(i).getStationName1());
               rinf.setStationname2("");
               rinf.setStationname3("");
               rinf.setStationname4("");
               dataInf.setStationname1(listB.get(i).getStationName1());
               dataInf.setStationname2("");
               dataInf.setStationname3("");
               dataInf.setStationname4("");
            }else if(level==2){
               rinf.setStationname1(listB.get(i).getStationName1());
                rinf.setStationname2(listB.get(i).getStationName2());
                rinf.setStationname3("");
                rinf.setStationname4("");
               dataInf.setStationname1(listB.get(i).getStationName1());
               dataInf.setStationname2(listB.get(i).getStationName2());
               dataInf.setStationname3("");
               dataInf.setStationname4("");
            }else if(level==3){
               rinf.setStationname1(listB.get(i).getStationName1());
                rinf.setStationname2(listB.get(i).getStationName2());
                rinf.setStationname3(listB.get(i).getStationName3());
                rinf.setStationname4("");
               dataInf.setStationname1(listB.get(i).getStationName1());
               dataInf.setStationname2(listB.get(i).getStationName2());
               dataInf.setStationname3(listB.get(i).getStationName3());
               dataInf.setStationname4("");
            }else if(level==4){
               rinf.setStationname1(listB.get(i).getStationName1());
                rinf.setStationname2(listB.get(i).getStationName2());
                rinf.setStationname3(listB.get(i).getStationName3());
                rinf.setStationname4(listB.get(i).getStationName4());
               dataInf.setStationname1(listB.get(i).getStationName1());
               dataInf.setStationname2(listB.get(i).getStationName2());
               dataInf.setStationname3(listB.get(i).getStationName3());
               dataInf.setStationname4(listB.get(i).getStationName4());
             }
             listB.get(i).setStationName9(dateFirst.substring(0,11).concat(dateLast.substring(0,10)));
             Float monSerStd=0f;//标存电导
            List<Battresdata_inf> list=mapper.serchSer(rinf);
            List<Battresdata_inf> list=mapper.serchSer(dataInf);
            int numC=0;//已完成个数总数
            int numQ=0;//80%合格个数总数
            if(list!=null&&list.size()>0){
@@ -308,15 +296,4 @@
      return model;
   }
   public static void main(String[] args) {
      Battresdata_infService brids = new Battresdata_infService();
      Battresdata_inf brid = new Battresdata_inf();
      brid.setTest_record_count(1);
      // brids.serchByCondition(brid);
      //brids.searchAll();
      Battresdata_inf brsdata=new Battresdata_inf();
      brsdata.setBattGroupId(1002561);
       brids.serchByCondition(brsdata);
   }
}