package com.fgkj.actions; import java.io.File; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import com.fgkj.dao.CsvUtil; import com.fgkj.dao.UinfDaoFactory; import com.fgkj.dao.impl.Batt_realdataImpl; import com.fgkj.dao.impl.BattcurrdataImpl; import com.fgkj.dao.impl.BatttestdataDAOImpl; import com.fgkj.dto.Batt_realdata; import com.fgkj.dto.Battcurrdata; import com.fgkj.dto.Batttestdata; import com.fgkj.dto.CsvFile; import com.fgkj.dto.MyFile; import com.fgkj.dto.User_log; import com.fgkj.dynamicload.dto.Dynamicload_realdata; import com.fgkj.dynamicload.impl.Dynamicload_realdataImpl; import com.fgkj.electric2mwsystem.Impl.Electric2mw_realdataImpl; import com.fgkj.electric2mwsystem.dto.Electric2mw_realdata; import com.fgkj.electricsystem.Impl.Electric_realhist_dataImpl; import com.fgkj.electricsystem.dto.Electric_realhist_data; import com.fgkj.elemachinery.dto.Motor_readdata; import com.fgkj.elemachinery.impl.Motor_readdataImpl; import com.fgkj.partinsystem.dto.Ac230v_ups; import com.fgkj.partinsystem.dto.AcDistribution; import com.fgkj.partinsystem.dto.Acinsulation; import com.fgkj.partinsystem.dto.Battery_monitor; import com.fgkj.partinsystem.dto.Cabin_board; import com.fgkj.partinsystem.dto.Dc230v_batt; import com.fgkj.partinsystem.dto.Dc25v_batt; import com.fgkj.partinsystem.dto.DcDistribution; import com.fgkj.partinsystem.dto.Dcinsulation; import com.fgkj.partinsystem.dto.Electrical_monitor_station; import com.fgkj.partinsystem.dto.Inverter_ele; import com.fgkj.partinsystem.dto.Propulsion_motor; import com.fgkj.partinsystem.dto.Reliable_board; import com.fgkj.partinsystem.dto.Switch_board; import com.fgkj.partinsystem.impl.Ac230v_upsImpl; import com.fgkj.partinsystem.impl.AcDistributionImpl; import com.fgkj.partinsystem.impl.AcinsulationImpl; import com.fgkj.partinsystem.impl.Battery_monitorImpl; import com.fgkj.partinsystem.impl.Cabin_boardImpl; import com.fgkj.partinsystem.impl.Dc230v_battImpl; import com.fgkj.partinsystem.impl.Dc25v_battImpl; import com.fgkj.partinsystem.impl.DcDistributionImpl; import com.fgkj.partinsystem.impl.DcinsulationImpl; import com.fgkj.partinsystem.impl.Electrical_monitor_stationImpl; import com.fgkj.partinsystem.impl.Inverter_eleImpl; import com.fgkj.partinsystem.impl.Propulsion_motorImpl; import com.fgkj.partinsystem.impl.Reliable_boardImpl; import com.fgkj.partinsystem.impl.Switch_boardImpl; import com.fgkj.services.ServiceModel; import com.fgkj.services.User_logService; import com.fgkj.watersystem.Impl.Water_realdataImpl; import com.fgkj.watersystem.dto.Water_realdata; import com.google.gson.reflect.TypeToken; import com.partinsystem.udpall.dto.Partin_elemonitor; import com.partinsystem.udpall.impl.Partin_elemonitorImpl; public class CsvFileDownloadAction extends ActionUtil{ private String json; private String result; //private static String path="d:/tomcat7_csv/"; //下载服务器CSV文件<陪试设备> public String searchDownloadFile(){ ActionUtil.getSession().setAttribute("percent",0);//导出文件先清空百分比 CsvFile cs=ActionUtil.getGson(ActionUtil.time_yyyyMMddHHmmss).fromJson(json, CsvFile.class); String loadpath = ActionUtil.getSession().getServletContext().getRealPath("/"); //String str = new File(loadpath).getParentFile().getAbsolutePath(); String str = new File(loadpath).getAbsolutePath(); String path=str+File.separator+"tomcat7_csv"+File.separator; ServiceModel model=new ServiceModel(); String msg=""; if(cs.getExport_num()==1){ String state="时间(HH:MM:SS),FZ按钮1,FZ按钮2,FZ按钮3,FZ按钮4,FZ按钮5,FZ按钮6,FZ按钮7,FZ按钮8,FZ按钮9,FZ按钮10,FZ按钮11" + ",启动自动加载,停止自动加载,突加突卸,全部分闸,实际设定功率,已输出功率,设定功率,间隔时间s,实际电流,实际电压,是否合闸" + ",FZ自动状态1,FZ自动状态2,FZ自动状态3,FZ自动状态4,FZ自动状态5,电抗超温,冷却水超温,冷却水液位低,冷却水压高,就地控制" + ",后台控制,中控控制,开关柜状态,中间量M200,风机按钮,风机输出,是否允许合闸"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==2){ String state="时间(HH:MM:SS),加载电机功率,加载电机转速,加载电机转矩,加载电机电流(A),加载电机电压(V),加载功率给定,加载转矩给定,加载电机转速限制,加载电机转矩限制,加载步长" + ",加载电机水冷进水风温,加载电机水冷出水风温,加载电机绕组温度1,加载电机绕组温度2,加载电机绕组温度3,加载电机轴承温度1,加载电机轴承温度2,加载电机出口温度,加载电机进口温度" + ",加载电机启动,加载电机停机,加载,减载,手动加载,加载电机紧停,加载电机风机状态,备用加载电机绕组温度1,备用加载电机绕组温度2,备用加载电机绕组温度3,传感器转矩,传感器功率,故障确认" + ",齿轮箱轴功率,推进轴功率,齿轮箱轴承温度1,齿轮箱轴承温度2,齿轮箱轴承温度3,齿轮箱轴承温度4,齿轮箱轴承温度5,齿轮箱轴承温度6,油站启动,油站停机,功率控制,转矩控制,变压器高温报警" + ",变压器高温故障,变压器缺相报警,润滑泵1运行,润滑泵2运行,润滑允许远程访问,遥控/就地,变频器就绪,变频器运行,变频器报警,变频器故障,润滑允许主机运行,主开关状态" + ",受试电机运行,受试电机报警,受试电机故障,受试电机紧停,润滑故障,润滑报警"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==3){ String state="时间(HH:MM:SS),单体编号,在线电压(V),组端电压(V),测试电流(A),单体电压(V),单体温度(℃)"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==4){ String state="时间(HH:MM:SS),直流电压(V),直流电流(A),控制角(°)"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==5){ String state="时间(HH:MM:SS),P01主泵运行,P11补水泵运行,P12试压泵运行,P13补气泵运行,H01电加热器运行,H02电加热器运行,电磁阀开限位,电磁阀关限位,阀打开,排气阀打开" + ",远程启动水冷系统,远程停止水冷系统,被冷却器件投运,水冷系统自动控制状态,水冷系统手动控制状态,水冷系统远程控制状态,水冷系统运行,冷却水流量,供水温度,供水压力" + ",回水温度,回水压力,冷却水电导率,缓冲罐液位,缓冲罐压力,阀厅湿度,阀厅温度,外水温度,外水压力" + ",1#支路流量,2#支路流量,3#支路流量,4#支路流量,5#支路流量,6#支路流量,7#支路流量,8#支路流量,9#支路流量" + ",1#支路温度,2#支路温度,3#支路温度,4#支路温度,5#支路温度,6#支路温度,7#支路温度,8#支路温度,9#支路温度" + ",1#支路压力,2#支路压力,3#支路压力,4#支路压力,5#支路压力,6#支路压力,7#支路压力,8#支路压力,9#支路压力"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==6){ String state="时间(HH:MM:SS),分直流电压(V),分直流电流(A),总直流电压(V),总直流电流(A),控制角(°)"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==7){ String state="时间(HH:MM:SS.sss),组端电流"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==8){ String state="时间(HH:MM:SS),组端电压(V),在线电压(V),组端电流(A)"; cs.setStates(state); createFileCsv(cs,path); model=searchStationSource(cs,path); }else{ model.setCode(0); model.setMsg("导出文件页面匹配不上"); } result=tojson(model); return SUCCESS; } //导出文件时服务器生成CSV public void createFileCsv(Object obj,String path){ CsvFile cs=(CsvFile) obj; //List exportData = new ArrayList(); //文件名=生产的文件名称+时间戳 String fileName = cs.getDev_name()+cs.getTable_name(); //列名 LinkedHashMap map = new LinkedHashMap(); String[] state=cs.getStates().split(","); /* List tabTh = new ArrayList(); for(int i=0;i(); row.put(1, ""); for(int i=0;i0){ List myfiles = new ArrayList(); for(int i=0;i 0){ model.setCode(1); model.setData(myfiles); model.setMsg("读取成功"); } }else{ model.setCode(0); model.setMsg("读取不成功"); } return model; } //参试设备历史数据下载 public String searchDownloadFile_partinsystem(){ ActionUtil.getSession().setAttribute("percent",0);//导出文件先清空百分比 CsvFile cs=ActionUtil.getGson(ActionUtil.time_yyyyMMddHHmmss).fromJson(json, CsvFile.class); String loadpath = ActionUtil.getSession().getServletContext().getRealPath("/"); //String str = new File(loadpath).getParentFile().getAbsolutePath(); String str = new File(loadpath).getAbsolutePath(); String path=str+File.separator+"tomcat7_csv"+File.separator; ServiceModel model=new ServiceModel(); String msg=""; if(cs.getExport_num()>=7){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); /*}else if(cs.getExport_num()==8){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==9){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==10){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==11){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==12){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==13){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==14){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==15){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==16){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==17){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path); }else if(cs.getExport_num()==18){ createFileCsv_partinsystem(cs,path); model=searchStationSource(cs,path);*/ }else{ model.setCode(0); model.setMsg("导出文件页面匹配不上"); } result=tojson(model); return SUCCESS; } //导出文件时服务器生成CSV<参试设备> public void createFileCsv_partinsystem(Object obj,String path){ CsvFile cs=(CsvFile) obj; //List exportData = new ArrayList(); //文件名=生产的文件名称+时间戳 String fileName = cs.getDev_name()+cs.getTable_name(); //列名 LinkedHashMap map = new LinkedHashMap(); String stateString=cs.getStates(); String switchString1="Q100,Q101,Q102,Q103,Q108,Q112,Q113,Q120" + ",Q122,Q200,Q202,Q204,Q208,Q211,Q212,Q213" + ",Q220,Q300,Q301,Q303,Q309,Q344,Q400,Q402" + ",Q403,Q404,Q409,Q433,Q11,Q12,Q15,Q17"; String switchString2="Q18,Q19,Q20,Q22,Q26,Q27,Q28,Q29" + ",Q30,Q33,Q35,Q37,Q38,Q43,Q44,Q46" + ",Q47,Q48,Q10,Q53,Q56,Q40,Q62,Q65"; String switchString3="1#可靠配电板Q51,AC20的Q10,AC51的Q2,AC51的Q4,AC52的Q1,AC52的Q6,AC53的Q3" + ",AC60的Q1,AR11的Q8,AR12的Q2,AR12的Q3,AR12的Q4,AR12的Q5,AR12的Q6,AR13的Q1,AR23的Q1" + ",AR23的Q2,AR23的Q3,AR23的Q4,AR23的Q6"; String switchString4="Q11,Q22,Q29,Q33,Q44,Q59,Q55,Q57,Q58,Q67,Q68,AR11的Q5,AR11的Q6,AR21的Q11,AR23的Q5"; if(stateString.contains("开关量1")) { stateString=stateString.replaceAll("开关量1", switchString1); } if(stateString.contains("开关量2")) { stateString=stateString.replaceAll("开关量2", switchString2); } if(stateString.contains("开关量3")) { stateString=stateString.replaceAll("开关量3", switchString3); } if(stateString.contains("开关量4")) { stateString=stateString.replaceAll("开关量4", switchString4); } //System.out.println(stateString); String[] state=stateString.split(","); map.put(1, "时间(HH:MM:SS)"); for(int i=0;i(); row.put(1, ""); for(int i=0;i