/**
 * 根据气体信息生成打印模版
 * 
 * @param depotData
 *            仓库基本信息
 * @param grainData
 *            粮情数据信息
 */
builderModel = function(curData,dept) {
	var depotData = curData.depotData;
	var listPoint = curData.listPoint;
	var model = "\n"
			+ "
气体报表模版"
			+ "    \n"
			+ "";
	model += "\n"
			+ "
\n";
	if(dept){
		model += dept.name;
	}else{
		model += "--XXX--粮库"
	}
	model += "\n";
	model += "
";
	model += depotData.name;
	model += "    虫害报表\n";
	model += "
";
	model += "  方向:东检测时间:";
	model += curData.receiveDate;
	model += "
";
	// 动态配置
	model += "";
	model += "| 采集位 | 虫害头数 | 虫害类型 | 采集位 | 虫害头数 | 虫害类型 | 
";
	var num = Math.ceil(listPoint.length / 2);
	var index = 1;
	var point;
	for (var i = 0; i < num; i++) {
		point = listPoint[index - 1];
		model += "";
		model += "| 采集位 " + point.passCode + "";
		model += " | " + attrPoint(point, curData)
				+ "";
		model += " | " + point.pestType + "";
		index++;
		if (index > listPoint.length) {
			model += " | ";
			model += " | ";
			model += " | ";
		} else {
			point = listPoint[index - 1];
			model += " | 采集位 " + point.passCode + "";
			model += " | " + attrPoint(point, curData)
					+ "";
			model += " | " + point.pestType + "";
			index++;
		}
		model += " | 
";
	}
	model += "
";
	// 
	model += "";
	model += "| 检测分析:";
	model += " | " + curData.remark + " | 
";
	model += "|  | 总检测位数 | 检测最多头数 | 备注 | 
";
	// 气体整体信息
	model += " | 整仓 | " + curData.checkNum + "";
	model += " | " + curData.pestMax + "";
	model += " |  | 
";
	
	// 仓库信息
	model += "| 仓房类型 | " + depotData.depotTypeName + "";
	model += " | 入仓日期 | " + depotData.storeDate + " | 
";
	model += "| 粮食品种 | " + depotData.foodVarietyName + "";
	model += " | 实际储量(吨) | " + depotData.storageReal
			+ " | 
";
	model += "| 入仓水分(%) | " + depotData.perWet + "";
	model += " | 当前水分(%) | " + depotData.perWet + " | 
";
	model += "| 发芽率(%) | ";
	model += " | 粮食产地 | " + depotData.foodLocation
			+ " | 
";
	model += "| 容重(kg/m3) | " + depotData.bulkWeight + "";
	model += " | 面筋持水率(%) |  | 
";
	model += "| 杂质(%) | " + depotData.perImpurity + "";
	model += " | 不完善粒(%) | " + depotData.broken + " | 
";
	model += "| 检测人 | " + curData.checkUser + "";
	model += " | 保管员 | " + depotData.storeKeeperName
			+ " | 
";
	model += "
";
	// 添加尾部信息
	model += "";
	model += "注:#表示最低  *表示最高";
	model += "制表时间:" + curData.sysDate
			+ "
";
	model += "";
	return model;
};
// 根据采集点赋值,注意数据库生成的坐标是从0开始的
attrPoint = function(point, curData) {
	if (-100.0 == point.pestNum) {
		return "备用";
	}
	if (curData.pestMax == point.pestNum) {
		return point.pestNum + "*";
	}
	return point.pestNum;
};
/**
 * 根据HTML模版打印为A4
 * 
 * @param strHtml
 */
previewA4 = function(strHtml) {
	var LODOP = getLodop();
	LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
	LODOP.PRINT_INIT("虫害报表");
	LODOP.ADD_PRINT_HTM(30, 40, "180mm", "100%", strHtml);
	LODOP.PREVIEW();
};