* 利用金浩那边操纵html的代码的接口HTMLTableManipulator,将值插入到报表模板的code中,并返回前台
* 注意:HTMLTableManipulator接口行列号是从0开始的,插入的时候,前台传值时也应该一致
* */
try
{
HTMLTableManipulator htmlTable = new HTMLTableManipulator(template.getCode());
Set<Cell> cells = template.getCells();
Iterator<Cell> iter = cells.iterator();
while(iter.hasNext())
{
Cell cell = iter.next();
CellId cellID = cell.getId();
String queryType = cell.getQueryType();
int sheetNum = cellID.getSheetNum().intValue();
int rowNum = cellID.getRowNum().intValue();
int colNum = cellID.getColNum().intValue();
if(queryType.equalsIgnoreCase("single")||queryType.equalsIgnoreCase("serial"))//商用库查询
{
String measureID = cell.getMeasureId();
String timeVar = cell.getTimeVar();
String target = cell.getQueryTarget();
LazyDynaBean bean = QueryTimeUtility.getHisQueryDate(timeVar, time);
if(bean==null)
{
htmlTable.setCellValue(sheetNum, rowNum,colNum,"");//将单元格值设为空,原来是*/#
continue;
}
Date startTime = (Date)bean.get("startTime");
// Date endTime = (Date)bean.get("endTime");
// int interval = (Integer)bean.get("interval");
if(queryType.equalsIgnoreCase("single"))//单点
{
Double value = getSigleValueFromWinCC(measureID, startTime);
if(value!=null)
{
htmlTable.setCellValue(sheetNum, rowNum,colNum,String.valueOf(value));
}
else
{
htmlTable.setCellValue(sheetNum, rowNum,colNum,"");//将单元格查询标记清除
}
}
// else//序列,暂时不支持序列查询
// {
// String direction = cell.getDirection();//序列方向,水平/垂直
// Long spacing = cell.getSpacing();//序列之间的间隔数
// if(direction==null)direction = "vertical";
// if(spacing==null)spacing = new Long(0);
// List<Double> values = getSerialValueFromHis(measureID, startTime, endTime, interval);
// if(values!=null&&values.size()>0)
// {
// int length = (int) (rowNum+values.size()*(1+spacing));//序列总长度
// if(direction.equalsIgnoreCase("vertical"))//垂直方向,则修改行
// {
// if(htmlTable.getNumberOfRows(sheetNum)<rowNum+length)
// {
// //表格模板不够长,插入count行,index是插入点
// int index = htmlTable.getNumberOfRows(sheetNum);//在最后一行插
// int count = rowNum + length- index;//计算插入的个数
// htmlTable.addRows(sheetNum, index, count);
// }
// for(Double value:values)
// {
// htmlTable.setCellValue(sheetNum, rowNum, colNum, String.valueOf(value));
// rowNum += 1+spacing;//默认序列是往下发展
// }
// }
// else//序列为水平方向
// {
// if(htmlTable.getNumberOfColumns(sheetNum)<colNum+length)
// {
// //表格模板不够长,插入count行,index是插入点
// int index = htmlTable.getNumberOfColumns(sheetNum);//最后一列插
// int count = colNum + length - index;//计算插入的个数
// htmlTable.addColumns(sheetNum, index, count);
// }
// for(Double value:values)
// {
// htmlTable.setCellValue(sheetNum, rowNum, colNum, String.valueOf(value));
// colNum += 1+spacing;//向右发展
// }
// }
// }
// else
// {
// htmlTable.setCellValue(sheetNum, rowNum, colNum, "");
// }
// }
}
else if(queryType.equalsIgnoreCase("time"))//单元格设定为时间变量
{
String timeVar = cell.getTimeVar();
String timeValue = QueryTimeUtility.getTimeQueryDate(timeVar, time);
if(timeValue==null)
{
timeValue = "";
}
htmlTable.setCellValue(sheetNum, rowNum,colNum,timeValue);
}
else if(queryType.equalsIgnoreCase("manual"))//人工设定的值,人工设定的值是存储在olapQuery中的
{
String manualContent = getCellManualValue(cell.getMeasureId(),template.getReportType(),time);
if(manualContent==null)
{
manualContent = "";
}
htmlTable.setCellValue(sheetNum, rowNum,colNum,manualContent);
}
}
result = htmlTable.getResult();
}
catch(Exception e)
{
e.printStackTrace();
}