已阅读5页,还剩29页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
package nbpt.ts.report.test.helper;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.util.ArrayList;import java.util.List;import com.runqian.report4.model.ReportDefine;import com.runqian.report4.usermodel.DataSetConfig;import com.runqian.report4.usermodel.DataSetMetaData;import com.runqian.report4.usermodel.IByteMap;import com.runqian.report4.usermodel.IColCell;import com.runqian.report4.usermodel.INormalCell;import com.runqian.report4.usermodel.IReport;import com.runqian.report4.usermodel.IRowCell;import com.runqian.report4.usermodel.MacroMetaData;import com.runqian.report4.usermodel.Param;import com.runqian.report4.usermodel.ParamMetaData;import com.runqian.report4.usermodel.ProcDataSetConfig;import com.runqian.report4.usermodel.SQLDataSetConfig;import com.runqian.report4.usermodel.Types;import com.runqian.report4.util.ReportUtils;public class RunQianHelper private String raqFilesPath = WebContent/report/zh/;List reportRaqFileNames = new ArrayList();public RunQianHelper()/File dir = new File(raqFilesPath);/loadFiles(dir);public List loadFilesa(File dir)File files = dir.listFiles();for (int i = 0; i files.length; i+) if (filesi.isFile() if (filesi.getAbsolutePath().endsWith(.raq) reportRaqFileNames.add(filesi.getAbsolutePath(); else loadFiles(filesi);return reportRaqFileNames;/* * 统一把行高设置成8 */SuppressWarnings(unused)public void setRowHeight(List arrList)int flag=0;int index=0;for(String item : arrList)String fileName = item;if(!fileName.contains(error)continue;try ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);int colCount = rd.getColCount();int rowCount = rd.getRowCount();for(int i=1; i=3; i+)IRowCell iRowCell = rd.getRowCell(i);iRowCell.setRowHeight(8);for(int j=1; j=colCount; j+)INormalCell cell = rd.getCell(i, (short)j);cell.setFontSize(short)12);ReportUtils.write(fileName, rd); catch (Exception e) System.out.println(fileName + - + e.toString();System.out.println(fileName + - + 已经处理!);System.out.println(处理完成!);/* * 处理报表javascript链接在新窗口弹出 */SuppressWarnings(unused)public void adjustJavaScriptWindows(List arrList)int flag=0;int index=0;for(String item : arrList)String fileName = item;try ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);for(short i=1; i=rd.getColCount(); i+)IColCell colCell = rd.getColCell(short)i); INormalCell cell = rd.getCell(1, (short)i); if(cell.getValue() = null)continue;INormalCell cell2 = rd.getCell(2, (short)i);if(cell2 != null)IByteMap iByteMap = cell2.getExpMap();if(iByteMap != null & iByteMap.get(INormalCell.LINK) != null)cell2.setHyperlinkWindow(_blank);System.out.println(fileName + - + 已经处理!);ReportUtils.write(fileName, rd); catch (Exception e) System.out.println(fileName + - + e.toString();System.out.println(处理完成!);/* * 隔行换色的处理 */SuppressWarnings(unused)public void setRowColor(List arrList)int flag=0;int index=0;for(String item : arrList)String fileName = item;try ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);int colCount = rd.getColCount();int rowCount = rd.getRowCount();for(int i=1; i=rowCount; i+)IRowCell iRowCell = rd.getRowCell(i);if(IRowCell.TYPE_NORMAL = iRowCell.getRowType()for(int j=1; j=colCount; j+)INormalCell cell = rd.getCell(i, (short)j); IByteMap iByteMap = cell.getExpMap();iByteMap.put(INormalCell.BCOLOR, if(row()%2=0,-3342337,-1); cell.setExpMap(iByteMap);System.out.println(fileName + - + 已经处理!);ReportUtils.write(fileName, rd); catch (Exception e) System.out.println(fileName + - + e.toString();System.out.println(处理完成!);/* * 处理报表的javascript函数,改成超链接 */SuppressWarnings(unused)public void adjustJavaScriptColumn(List arrList)int flag=0;int index=0;for(String item : arrList)String fileName = item;try ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);for(short i=1; i=rd.getColCount(); i+)IColCell colCell = rd.getColCell(short)i); INormalCell cell = rd.getCell(1, (short)i); if(cell.getValue() = null)continue;INormalCell cell2 = rd.getCell(2, (short)i);if(cell2 != null)IByteMap iByteMap = cell2.getExpMap();if(iByteMap != null & iByteMap.get(INormalCell.LINK) != null)String url= iByteMap.get(INormalCell.LINK).toString();url = url.replace(;, );if(url.contains(javascript:)int pos1 = url.indexOf(javascript:);int pos2 = url.lastIndexOf();String value = url.substring(pos1+11, pos2+2);iByteMap.put(INormalCell.LINK, webpath+pages/report/excel/hyperlinkDisplay.jsp?fun=+value); cell2.setExpMap(iByteMap);System.out.println(fileName + - + 已经处理!);ReportUtils.write(fileName, rd); catch (Exception e) System.out.println(fileName + - + e.toString();System.out.println(处理完成!);/* * 特殊处理加拨报表,tasktype变成了数值型 */SuppressWarnings(unused)public void adjustAddTestColumn(List arrList)int index=0;for(String item : arrList)String fileName = item;try ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);for(short i=1; i=rd.getColCount(); i+)IColCell colCell = rd.getColCell(short)i);INormalCell cell = rd.getCell(1, (short)i);if(cell.getValue() = null)continue;if(cell.getValue().toString().contains(BSC名称)if(colCell.getColVisibleExp() != null)colCell.setColVisibleExp(if(str(ds1.tasktype)=16,true,false);/System.out.print(colCell.getColVisibleExp(); if(cell.getValue().toString().contains(加拨任务)if(colCell.getColVisibleExp() != null)colCell.setColVisibleExp(if(str(ds1.tasktype)=14|str(ds1.tasktype)=19|str(ds1.tasktype)=|ds1.tasktype=null,false, true);/System.out.println(-+colCell.getColVisibleExp(); ReportUtils.write(fileName, rd); catch (Exception e) System.out.println(fileName + - + e.toString();System.out.println(处理完成!);/* * 特殊处理错误类的报表 * param arrList */SuppressWarnings(unused)public void errorReport(List arrList)int index = 1;for(String item : arrList)String fileName = item; /E:/report/source/zh/078/078-00-1.raq;try String name = fileName.substring(fileName.lastIndexOf()+1, fileName.length();int pos1 = name.indexOf(-);int pos2 = name.lastIndexOf(-);String serviceCode = name.substring(pos1-3, pos1);String subServiceCode = name.substring(pos1+1, pos2);String procName = call p_testrecord+ serviceCode +subServiceCode+(?,?,?,?);String flag = ;if (fileName.indexOf(error)0)continue;ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);/获取参数元数据ParamMetaData pmd= rd.getParamMetaData(); if(pmd != null)pmd.clear();/添加需要的参数/1.webpathParam param = new Param(); /构造参数定义param.setParamName(webpath); /设置参数名param.setDataType(Types.DT_STRING); /设置参数数据类型param.setParamType(Param.PARAM_NORMAL); /设置参数类型(普通参数或动态参数)param.setValue(); /设参数缺省值pmd.addParam(param);/把参数定义添加到参数元数据中/2.flagparam = new Param(); param.setParamName(flag); param.setDataType(Types.DT_STRING); param.setParamType(Param.PARAM_NORMAL); param.setValue(9); pmd.addParam(param);/3.filedsparam = new Param(); param.setParamName(fileds); param.setDataType(Types.DT_STRING); param.setParamType(Param.PARAM_NORMAL); param.setValue(); pmd.addParam(param);/4.tasktypeparam = new Param(); param.setParamName(taskType); param.setDataType(Types.DT_STRING); param.setParamType(Param.PARAM_NORMAL); param.setValue(); pmd.addParam(param);/5.WHEREparam = new Param(); param.setParamName(WHERE); param.setDataType(Types.DT_STRING); param.setParamType(Param.PARAM_NORMAL); param.setValue(); pmd.addParam(param);/把参数元数据赋给ReportDefine rd.setParamMetaData(pmd); /获取宏元数据MacroMetaData macroMetaData= rd.getMacroMetaData(); if(macroMetaData!=null)macroMetaData.clear();/获取数据集元数据DataSetMetaData dataSetMetaData = rd.getDataSetMetaData();if(dataSetMetaData != null)dataSetMetaData.clear();ProcDataSetConfig procDataSetConfig = new ProcDataSetConfig();procDataSetConfig.setName(ds1); procDataSetConfig.setSQL(procName);/添加参数procDataSetConfig.addParam(); procDataSetConfig.addParam();procDataSetConfig.addParam();procDataSetConfig.addParam();/设置参数procDataSetConfig.setParamExp(0,flag); procDataSetConfig.setParamExp(1,fileds);procDataSetConfig.setParamExp(2,taskType);procDataSetConfig.setParamExp(3,WHERE);/把数据集定义添加到数据集元数据dataSetMetaData.addDataSetConfig(procDataSetConfig); SQLDataSetConfig sqlDataSetConfig = new SQLDataSetConfig();sqlDataSetConfig.setName(ds2);sqlDataSetConfig.setSQL(select * from resultcode);dataSetMetaData.addDataSetConfig(sqlDataSetConfig);/把数据集元数据赋给ReportDefinerd.setDataSetMetaData(dataSetMetaData); ReportUtils.write(fileName, rd);System.out.println(index+:+fileName+*已处理.); catch (Exception e) System.out.println(fileName + - + e.toString();/* * 特殊处理错误类的报表 * param arrList */SuppressWarnings(unused)public void tempCall(List arrList)int index = 1;for(String item : arrList)String fileName = item; try String name = fileName.substring(fileName.lastIndexOf()+1, fileName.length();int pos1 = name.indexOf(-);int pos2 = name.lastIndexOf(-);String serviceCode = name.substring(pos1-3, pos1);String subServiceCode = name.substring(pos1+1, pos2);String procName = call p_4000002Img(?,?,?);ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);/获取参数元数据ParamMetaData pmd= rd.getParamMetaData(); if(pmd != null)/pmd.clear();/添加需要的参数/1.YYYYMMSParam param = new Param(); /构造参数定义param.setParamName(YYYYMMS); /设置参数名param.setDataType(Types.DT_STRING); /设置参数数据类型param.setParamType(Param.PARAM_NORMAL); /设置参数类型(普通参数或动态参数)param.setValue(); /设参数缺省值pmd.addParam(param);/把参数定义添加到参数元数据中/2.WHEREparam = new Param(); param.setParamName(WHERE); param.setDataType(Types.DT_STRING); param.setParamType(Param.PARAM_NORMAL); param.setValue(); pmd.addParam(param);/把参数元数据赋给ReportDefine rd.setParamMetaData(pmd); /获取数据集元数据DataSetMetaData dataSetMetaData = rd.getDataSetMetaData();if(dataSetMetaData != null)dataSetMetaData.clear();ProcDataSetConfig procDataSetConfig = new ProcDataSetConfig();procDataSetConfig.setName(ds1); procDataSetConfig.setSQL(procName);/添加参数procDataSetConfig.addParam(); procDataSetConfig.addParam();procDataSetConfig.addParam();/设置参数procDataSetConfig.setParamExp(0,1); procDataSetConfig.setParamExp(1,YYYYMMS);procDataSetConfig.setParamExp(2,WHERE);/把数据集定义添加到数据集元数据dataSetMetaData.addDataSetConfig(procDataSetConfig); procDataSetConfig = new ProcDataSetConfig();procDataSetConfig.setName(ds2); procDataSetConfig.setSQL(procName);/添加参数procDataSetConfig.addParam(); procDataSetConfig.addParam();procDataSetConfig.addParam();/设置参数procDataSetConfig.setParamExp(0,2); procDataSetConfig.setParamExp(1,YYYYMMS);procDataSetConfig.setParamExp(2,WHERE);/把数据集定义添加到数据集元数据dataSetMetaData.addDataSetConfig(procDataSetConfig); /把数据集元数据赋给ReportDefinerd.setDataSetMetaData(dataSetMetaData); ReportUtils.write(fileName, rd);System.out.println(index+:+fileName+*已处理.); catch (Exception e) System.out.println(fileName + - + e.toString();/* * 调整列宽 */SuppressWarnings(unused)public void adjustSetDateColumnWidth(List arrList)int index=0;for(String item : arrList)String fileName = item;try ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);for(short i=1; i=rd.getColCount(); i+)IColCell colCell = rd.getColCell(short)i);INormalCell cell = rd.getCell(1, (short)i);if(cell.getValue() = null)continue;if(cell.getValue().toString().contains(时间)colCell.setColWidth(float)60);if(cell.getValue().toString().contains(终端)colCell.setColWidth(float)43);if(cell.getValue().toString().contains(编号)colCell.setColWidth(float)14);if(cell.getValue().toString().contains(业务类型)colCell.setColWidth(float)42);if(cell.getValue().toString().contains(传输方式)colCell.setColWidth(float)24);if(cell.getValue().toString().contains(测试结果)colCell.setColWidth(float)40);if(cell.getValue().toString().contains(监测结果)colCell.setColWidth(float)27);if(cell.getValue().toString().contains(访问链接)colCell.setColWidth(float)45);if(cell.getValue().toString().contains(重测次数)colCell.setColWidth(float)20);if(cell.getValue().toString().contains(主叫承载方式)colCell.setColWidth(float)20);if(cell.getValue().toString().contains(主叫运营商)colCell.setColWidth(float)27);if(cell.getValue().toString().contains(主叫号码)colCell.setColWidth(float)30);if(cell.getValue().toString().contains(主叫当前地)colCell.setColWidth(float)30);ReportUtils.write(fileName, rd);System.out.println(index+:+fileName+*已处理.); catch (Exception e) System.out.println(fileName + - + e.toString();/* * 修改报表数据集,支持存储过程 * param arrList */SuppressWarnings(unused)public void convert(List arrList)int index = 1;for(String item : arrList)String fileName = item; /E:/report/source/zh/078/078-00-1.raq;try String name = fileName.substring(fileName.lastIndexOf()+1, fileName.length();int pos1 = name.indexOf(-);int pos2 = name.lastIndexOf(-);String serviceCode = name.substring(pos1-3, pos1);String subServiceCode = name.substring(pos1+1, pos2);String procName = call p_testrecord+ serviceCode +subServiceCode+(?,?,?,?);String flag = ;if (-1.equals(fileName.substring(fileName.length()-6, fileName.length()-4)flag = 1;else if(fileName.contains(bycity) flag = 2;else if(fileName.contains(byctinfo)flag = 3;else if(fileName.contains(bytsinfo)flag = 4;else if(fileName.contains(bynet)flag = 5;else if(fileName.contains(byNumberModel)flag = 6;else if(fileName.contains(bybsc)flag = 7;else if(fileName.contains(byApn)flag = 8;else if(fileName.contains(error)flag = 9;System.out.println(index+:+fileName+*已处理.);continue;else if(-2.equals(fileName.substring(fileName.length()-6, fileName.length()-4)flag = 10;if(.equals(flag)System.out.println(index+:+ fileName + #未处理!); continue;ReportDefine rd = (ReportDefine)ReportUtils.read(fileName);/获取参数元数据ParamMetaData pmd= rd.getParamMetaData(); if(pmd != null)pmd.clear();/添加需要的参数/1.webpathParam param = new Param(); /构造参数定义param.setParamName(webpath); /设置参数名param.setDataType(Types.DT_STRING); /设置参数数据类型param.setParamType(Pa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年机场航站楼环境卫生服务标准
- 2026年性别平等主题儿童戏剧编排
- 2026年学校健康教育课程优化与素养提升
- 脊髓疾病患者的压力管理护理
- 热点三 张雪机车一战封神(解读)-高考语文高频热点命题练习卷
- 2026届高考作文话题预测及主题素:文明之光
- 畜牧养殖场动物疫病防控技术合同
- 糕点装饰师蛋糕裱花合作框架协议
- 2026年室内设计作品集制作从大一开始准备
- 舞台搭建与拆除合同范本
- 第十章 静电场中的能量 总结提升-2023学年高二物理(人教版)
- 2.1大气的组成和垂直分层(情境教学设计)地理人教版2019
- 《地下管线BIM模型技术规程》(征求意见稿)
- 水上乐园管理制度与安全操作规范
- 实施指南《G B-T17492-2019工业用金属丝编织网技术要求和检验》
- 关于精益管理办法
- 湖北省部分高中2025届高三下学期四月统考(二模)政治试卷(含解析)
- 白细胞减少症病例讨论
- 年产200吨高纯金属铯铷项目报告书
- 2025具身智能行业发展研究报告
- 智库能力测试题及答案
评论
0/150
提交评论