| | |
| | | import com.fgkj.db.CallBack; |
| | | import com.fgkj.pojo.Dev_Vol; |
| | | import com.fgkj.service.Dev_VolService; |
| | | import com.sun.org.apache.bcel.internal.generic.DCMPG; |
| | | |
| | | public class Dev_VolImpl implements BaseDAO,CallBack{ |
| | | |
| | |
| | | // TODO Auto-generated method stub |
| | | return false; |
| | | } |
| | | //读取全图 |
| | | @Override |
| | | public List searchAll() { |
| | | String filePath=getfilePath(1); |
| | | List list=new ArrayList(); |
| | | try { |
| | | |
| | | File csv=new File(filePath); |
| | | csv.setReadable(true);//设置可读 |
| | | csv.setWritable(true);//设置可写 |
| | | LineNumberReader br = new LineNumberReader(new FileReader(csv)); |
| | | String line = ""; |
| | | String everyLine = ""; |
| | | try { |
| | | while ((line = br.readLine()) != null) // 读取到的内容给line变量 |
| | | { if(br.getLineNumber() >= 1500&&br.getLineNumber() <= 101500) { |
| | | everyLine = line; |
| | | list.add(changeStrToDev_Vol(everyLine,1)); |
| | | } |
| | | } |
| | | System.out.println("csv表格中所有行数:" + list.size()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | } |
| | | return list; |
| | | return null; |
| | | } |
| | | //读取全图 |
| | | @Override |
| | | public List serchByCondition(Object obj) { |
| | | Dev_Vol dv=(com.fgkj.pojo.Dev_Vol) obj; |
| | | String filePath=getfilePath(1); |
| | | Dev_Vol dv=(Dev_Vol) obj; |
| | | String filePath=getfilePath(dv.getFileName()); |
| | | List list=new ArrayList(); |
| | | try { |
| | | |
| | |
| | | list.add(changeStrToDev_Vol(everyLine,1)); |
| | | } |
| | | } |
| | | System.out.println("csv表格中所有行数:" + list.size()); |
| | | //System.out.println("csv表格中所有行数:" + list.size()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return null; |
| | | } |
| | | //读取缩略图 |
| | | public List searchAbbreviation(){ |
| | | String filePath=getfilePath(0); |
| | | public List searchAbbreviation(Object obj){ |
| | | Dev_Vol dc=(Dev_Vol) obj; |
| | | String filePath=getfilePath(dc.getFileName()); |
| | | List list=new ArrayList(); |
| | | try { |
| | | /* |
| | |
| | | everyLine = line; |
| | | list.add(changeStrToDev_Vol(everyLine,0)); |
| | | } |
| | | System.out.println("csv表格中所有行数:" + list.size()); |
| | | //System.out.println("csv表格中所有行数:" + list.size()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return dv; |
| | | } |
| | | //读取文件路径 |
| | | public static String getfilePath(int flag) { |
| | | public static String getfilePath(String fileName) { |
| | | //String path=this.getClass().getResource("/").getPath(); |
| | | String loadpath =ActionUtil.getSession().getServletContext().getRealPath("/"); |
| | | //String filePath = "D:/apache-tomcat-7.0.105/webapps/Dev_FastAcquisition/WEB-INF/电压2020_03_04_10_00_dgls.csv"; |
| | |
| | | String str=loadpath.substring(0, loadpath.lastIndexOf("Dev_FastAcquisition")); |
| | | //System.out.println(str); |
| | | String filePath=null; |
| | | if(flag==0) { |
| | | filePath=str+File.separator+"csv"+File.separator+"电压2020_03_04_10_00_dgls.csv"; |
| | | }else { |
| | | filePath=str+File.separator+"csv"+File.separator+"电压2020_03_04_10_00.csv"; |
| | | } |
| | | // if(flag==0) { |
| | | // filePath=str+File.separator+"csv"+File.separator+"电压2020_03_04_10_00_dgls.csv"; |
| | | // }else { |
| | | // filePath=str+File.separator+"csv"+File.separator+"电压2020_03_04_10_00.csv"; |
| | | // } |
| | | filePath=str+File.separator+"csv"+File.separator+fileName; |
| | | return filePath; |
| | | } |
| | | } |