package com.fgkj.services; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.fgkj.actions.ActionUtil; import com.fgkj.dao.BaseDAO; import com.fgkj.dao.BaseDAOFactory; import com.fgkj.dao.impl.Batt_maint_infImpl; import com.fgkj.dao.impl.Batt_param_lowImpl; import com.fgkj.dao.impl.BattinfThirdImpl; import com.fgkj.dto.AllModel; import com.fgkj.dto.BattInf; import com.fgkj.dto.Batt_Maint_Dealarm; import com.fgkj.dto.Batt_maint_inf; import com.fgkj.dto.Batt_maintenance_inf; import com.fgkj.dto.Batt_param_low; import com.fgkj.dto.Battresdata; import com.fgkj.dto.Battresdata_inf; import com.fgkj.dto.Batttestdata_inf; import com.fgkj.dto.Batttestdatastop; import com.fgkj.dto.Page; import com.fgkj.dto.ServiceModel; public class Batt_MaintService { private BaseDAO dao; private BatttestdatastopService sservice; private Batttestdata_infService tservice; private Battresdata_infService eservice; private BattresdataService rservice; private ServiceModel model; public Batt_MaintService() { dao = BaseDAOFactory.getBaseDAO(BaseDAO.BATTINFTHIRD); sservice = new BatttestdatastopService(); tservice = new Batttestdata_infService(); eservice =new Battresdata_infService(); rservice = new BattresdataService(); model=new ServiceModel(); } // 1.3根据battgroupid和mon_num的值查出测试信息 // 或者根据battgroupid和mon_num得到内阻信息(旧) public List serchMon_num1(Object obj) { Batt_Maint_Dealarm bmd = (Batt_Maint_Dealarm) obj; BattInf binf = bmd.getBinf(); Batttestdata_inf tdata = bmd.getTdata(); Battresdata_inf rinf=new Battresdata_inf(); Batttestdatastop sdata = new Batttestdatastop(); Battresdata rdata = new Battresdata(); List list =dao.serchByCondition(bmd); //System.out.println(list.size()); Batt_param_low lowCA=new Batt_param_low(); lowCA.setLow_type(2); lowCA.setLow_nametype(2);//电容告警 Batt_param_low lowCH=new Batt_param_low(); lowCH.setLow_type(2); lowCH.setLow_nametype(3);//电容更换 List listCA = (new Batt_param_lowImpl()) .serchByLow(lowCA); List listCH = (new Batt_param_lowImpl()) .serchByLow(lowCH); Float percentCA = listCA.get(0).getLow_value(); Float percentCH = listCH.get(0).getLow_value(); //电导基准/维护建议/电导分析值 Batt_param_low lowRA=new Batt_param_low(); lowRA.setLow_type(3); lowRA.setLow_nametype(2);//电导告警 Batt_param_low lowRH=new Batt_param_low(); lowRH.setLow_type(3); lowRH.setLow_nametype(3);//电导更换 //电导 List listRA = (new Batt_param_lowImpl()) .serchByLow(lowRA); List listRH = (new Batt_param_lowImpl()) .serchByLow(lowRH); Float percentRA = listRA.get(0).getLow_value(); Float percentRH = listRH.get(0).getLow_value(); int methodRM=listRA.get(0).getLow_method(); //分析方式 List listAll = new ArrayList(); for (int i = 0; i < list.size(); i++) { //System.out.println(list.get(i).getBinf().getBattGroupId()); tdata.setBattGroupId(list.get(i).getBinf().getBattGroupId()); rinf.setBattGroupId(list.get(i).getBinf().getBattGroupId()); AllModel allmodel = new AllModel(); if (tservice.judge(tdata).getCode() == 1||eservice.judge(rinf).getCode() == 1) { if(tservice.serchByCondition(tdata).getCode() == 1){ if (tdata.getTest_type() == 3) { sdata.setBattGroupId(list.get(i).getBinf().getBattGroupId()); sdata.setMon_num(binf.getMonNum()); sdata.setTest_record_count(list.get(i).getTdata().getTest_record_count()); ServiceModel smodel = sservice.serchByMonNum(sdata); smodel.setLowCA(percentCA); smodel.setLowCH(percentCH); allmodel.setSmodel(smodel); } } if(eservice.serchByCondition(rinf).getCode()==1){ if(tdata.getTest_type() == 5){ rdata.setBattGroupId(list.get(i).getBinf().getBattGroupId()); rdata.setMon_num(binf.getMonNum()!=0?binf.getMonNum()*10+1:0); ServiceModel rmodel = rservice.serchByMonNum(rdata); rmodel.setLowCA(percentCA); rmodel.setLowCH(percentCH); rmodel.setLowRA(percentRA); rmodel.setLowRH(percentRH); rmodel.setNewsum(methodRM);//分析方式1:平均值;0:标称值 allmodel.setRmodel(rmodel); } } allmodel.setData(list.get(i)); //System.out.println(allmodel); listAll.add(allmodel); } } // for (AllModel a : listAll) { // System.out.println(a.getRmodel()); // } return listAll; } // 1.3根据battgroupid和mon_num的值查出测试信息 // 或者根据battgroupid和mon_num得到内阻信息(新) public ServiceModel serchMon_num(Object obj) { Batt_Maint_Dealarm bmd = (Batt_Maint_Dealarm) obj; BattInf binf = bmd.getBinf(); Batttestdata_inf tdata = bmd.getTdata(); Battresdata_inf rinf=new Battresdata_inf(); Batttestdatastop sdata = new Batttestdatastop(); Battresdata rdata = new Battresdata(); List list =dao.serchByCondition(bmd); Batt_param_low lowCA=new Batt_param_low(); lowCA.setLow_type(2); lowCA.setLow_nametype(2);//电容告警 Batt_param_low lowCH=new Batt_param_low(); lowCH.setLow_type(2); lowCH.setLow_nametype(3);//电容更换 List listCA = (new Batt_param_lowImpl()) .serchByLow(lowCA); List listCH = (new Batt_param_lowImpl()) .serchByLow(lowCH); Float percentCA = listCA.get(0).getLow_value(); Float percentCH = listCH.get(0).getLow_value(); //电导基准/维护建议/电导分析值 Batt_param_low lowRA=new Batt_param_low(); lowRA.setLow_type(3); lowRA.setLow_nametype(2);//电导告警 Batt_param_low lowRH=new Batt_param_low(); lowRH.setLow_type(3); lowRH.setLow_nametype(3);//电导更换 //电导 List listRA = (new Batt_param_lowImpl()) .serchByLow(lowRA); List listRH = (new Batt_param_lowImpl()) .serchByLow(lowRH); Float percentRA = listRA.get(0).getLow_value(); Float percentRH = listRH.get(0).getLow_value(); int methodRM=listRA.get(0).getLow_method(); //分析方式 if(list!=null&&list.size()>0){ model.setCode(1); model.setMsg("查询成功!"); model.setData(list); model.setLowCA(percentCA); model.setLowCH(percentCH); model.setLowRA(percentRA); model.setLowRH(percentRH); model.setNewsum(methodRM);//分析方式1:平均值;0:标称值 }else{ model.setMsg("查询失败!"); model.setCode(0); } return model; } public static void main(String[] args) { BattInf binf = new BattInf(); binf.setStationName(""); binf.setStationName1(""); binf.setBattGroupId(1000003); binf.setMonNum(0); Batttestdata_inf tdata=new Batttestdata_inf(); tdata.setTest_type(5); Batt_Maint_Dealarm bmd = new Batt_Maint_Dealarm(); bmd.setBinf(binf); bmd.setTdata(tdata); Page page=new Page(); page.setPageCurr(1); page.setPageSize(10); bmd.setPage(page); Batt_MaintService bs = new Batt_MaintService(); ServiceModel model = bs.serchMon_num(bmd); } }