public Map<Integer, Integer> getListPageSizeMap(QueryStructVO voQryStruct) throws BusinessException { BaseDAO dao = new BaseDAO(); List<?> objPairs = (List<?>) dao.executeQuery( voQryStruct.getPaginationConfig().getPageSizeMapSQL(), new ArrayListProcessor()); Map<Integer, Integer> pageSizeMap = new LinkedHashMap<Integer, Integer>(); Map<Integer, Queue<RowInfo>> pageRowInfoMap = new LinkedHashMap<Integer, Queue<RowInfo>>(); if (objPairs != null && !objPairs.isEmpty()) { int i = 0; RowInfo lastRowInfo = null; Queue<RowInfo> rowQueue = new ArrayBlockingQueue<RowInfo>(10); for (Object rs : objPairs) { RowInfo rowInfo = RowInfoConverter.getInstance().convert(rs); if (lastRowInfo != null && !rowInfo.getObjValue(1).equals(lastRowInfo.getObjValue(1))) { pageRowInfoMap.put(++i, rowQueue); rowQueue = new ArrayBlockingQueue<RowInfo>(10); } rowQueue.add(rowInfo); lastRowInfo = rowInfo; } pageRowInfoMap.put(++i, rowQueue); for (Integer pageIndex : pageRowInfoMap.keySet()) { pageSizeMap.put( pageIndex, PageSizeCalculater.getInstance().calulate(pageRowInfoMap.get(pageIndex))); if (pageIndex == pageRowInfoMap.size()) { // 合计 pageSizeMap.put(pageIndex, pageSizeMap.get(pageIndex) + 1); } } } return pageSizeMap; }
/** * 功能:得到与某个clbh相关联的单据oid 作者:宋涛 创建时间:(2001-11-14 13:13:45) 参数:<|>o 返回值: 算法: 异常描述: * * @return java.lang.String[] * @param sClbh java.lang.String */ public String[] getOids(QueryStructVO voQryStruct, String sClbh) throws BusinessException { String[] sResults = new String[0]; try { ICreateSql createTools = getSqlCreater(); if (voQryStruct.isWanglaiDetail()) { createTools = new CreateSql_WL(); } createTools.initParam(voQryStruct); String strSQL = createTools.getOidSql(); NewListQueryDAO dmo = new NewListQueryDAO(); sResults = dmo.getVouchid(strSQL, sClbh); } catch (Exception e) { Log.getInstance(this.getClass()).error(e.getMessage()); throw new BusinessShowException( "NewListQueryBO::getOids(QueryStructVO voQryStruct, String sClbh) Exception!", e); } return sResults; }
/** * 查询期初暂估数据的冲回数据 * * @param voQryStruct * @return * @throws BusinessException */ private MemoryResultSet[] getInitTempEstimateOffsetData(QueryStructVO voQryStruct) throws BusinessException { MemoryResultSet[] mrsResults = null; StringBuffer strSql = new StringBuffer(); strSql.append("select "); if (voQryStruct.isQuerybyPeriod()) { strSql.append( nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() .getStrByID( "2006", "UPP2006-v55-000159") /*@res "'' ndqj,'' nd,'' rq,'期初'zy,'' clbh,"*/); } else { strSql.append( nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() .getStrByID("2006", "UPP2006-v55-000160") /*@res "'' rq,'期初'zy,'' clbh,"*/); } // 分组字段 StringBuffer grpSql = new StringBuffer(" "); String strFinalGroupSql = ""; // 查询对象 Vector v_qryObj = voQryStruct.getVetQryObj(); for (int i = 0; i < v_qryObj.size(); i++) { QryObjVO qryObj = (QryObjVO) v_qryObj.elementAt(i); // 当查询对象包含单位时,将zb替换为fb if (qryObj != null) { if ((qryObj.getFldorigin() + "." + qryObj.getQryfld()).equalsIgnoreCase("zb.dwbm")) { grpSql.append("fb.dwbm" + ","); } else { grpSql.append(qryObj.getFldorigin() + "." + qryObj.getQryfld() + ","); } } } strFinalGroupSql = strFinalGroupSql + grpSql.toString(); strSql.append(strFinalGroupSql); strSql.append( "'' ZB_DJBH,'' FB_FPH,'' ZB_YWBM,'' FB_BZBM,'' ZB_VOUCHID, 0.0 jfshlje,0.0 jfybje,0.0 jffbje,0.0 jfbbje, 0.0 jfybsj,0.0 jffbsj,0.0 jfbbsj, 0.0 jfybwsje,0.0 jffbwsje,0.0 jfbbwsje,0.0 dfshlje,0.0 dfybje,0.0 dffbje,0.0 dfbbje, 0.0 dfybsj,0.0 dffbsj,0.0 dfbbsj, 0.0 dfybwsje,0.0 dffbwsje,0.0 dfbbwsje,"); String strAmountCol = "sum(jfclshl2+dfclshl2),sum(jfclybje2+dfclybje2),sum(jfclfbje2+dfclfbje2),sum(jfclbbje2+dfclbbje2) "; strSql.append(strAmountCol); strSql.append(" from arap_djfb fb inner join arap_djclb clb on clb.fb_oid = fb.fb_oid "); // 如果查询条件中包含zb,则将zb拼入查询语句 String strQryObjCondition = EfficientPubMethod.getInstance() .getWhere(voQryStruct.getVoNormalCond(), voQryStruct.getVetCustomCond()); boolean flag = false; if (strQryObjCondition != null && strQryObjCondition.indexOf("zb.") > -1) { flag = true; } if (flag) { strSql.append(" INNER JOIN arap_djzb zb ON zb.vouchid = fb.vouchid "); } CreatJoinSQLTool sqlToll = new CreatJoinSQLTool(); Vector<String> vetTab = new Vector<String>(); vetTab = NewPubMethods.getInstance().getTabs(voQryStruct.getVoNormalCond(), vetTab); String[] strTabs = NewPubMethods.getInstance().getCustCondTabName(voQryStruct.getVetCustomCond(), vetTab); String joinSql = ""; try { joinSql = sqlToll.getJoinSQL(strTabs); } catch (Exception e1) { ExceptionHandler.getInstance(this.getClass().getName()).handle(e1); } if (!StringUtils.isEmpty(joinSql)) { strSql.append(joinSql); } strSql.append(" where "); // 设置查询条件 StringBuffer strWhere = new StringBuffer(); // 公司 String[] pk_corps = voQryStruct.getCorp(); if (pk_corps != null) { String strPKCorp = "("; for (int i = 0; i < pk_corps.length; i++) { strPKCorp = strPKCorp + "'"; strPKCorp = strPKCorp + pk_corps[i]; strPKCorp = strPKCorp + "',"; } strPKCorp = strPKCorp.substring(0, strPKCorp.length() - 1); strPKCorp = strPKCorp + ") "; strWhere.append(" and " + "clb.dwbm in "); strWhere.append(strPKCorp); } // 起止日期 String strBeginDate = voQryStruct.getDate()[0]; String strEndDate = voQryStruct.getDate()[1]; strWhere.append(" and clb.clrq >= "); strWhere.append(" '" + strBeginDate + "'"); strWhere.append(" and clb.clrq <= "); strWhere.append(" '" + strEndDate + "'"); // 限制期初 strWhere.append(" and fb.billdate < "); strWhere.append(" '" + strBeginDate + "'"); // 处理标志 strWhere.append(" and clbz = 10 "); // 删除标志 strWhere.append(" and clb.dr = 0 and fb.dr = 0 "); if (strQryObjCondition == null) { strQryObjCondition = ""; } if (strQryObjCondition.length() > 0) { strWhere.append(" and " + strQryObjCondition); } strSql.append(strWhere.substring(4)); strSql.append(" group by "); strSql.append(strFinalGroupSql.substring(0, strFinalGroupSql.length() - 1)); String[] strSqls = new String[] {strSql.toString()}; try { NewListQueryDAO dmo = new NewListQueryDAO(); mrsResults = dmo.getQueryResult(strSqls); } catch (Exception e) { ExceptionHandler.getInstance(this.getClass().getName()).handle(e); } return mrsResults; }
private RSTransferVO mergeTempEstimateData( QueryStructVO voQryStruct, RSTransferVO vo, MemoryResultSet[] initEstimateResults, MemoryResultSet[] estimateResults) throws java.lang.Exception { // 将期初冲回数据加到期初数据结果集中 MemoryResultSet initResultSet = vo.getResultset()[0]; ArrayList<ArrayList<Object>> initEstimateList = initEstimateResults[0].getResultArrayList(); ArrayList<ArrayList<Object>> oldInitList = initResultSet.getResultArrayList(); oldInitList.addAll(initEstimateList); // ---------进入发生数据处理--------- MemoryResultSet oldResultSet = vo.getResultset()[2]; String strQryObj = ""; String strPkCurrtype = ""; String strVoucherId = ""; String strQryField = ""; Vector<QryObjVO> v_qryObj = new Vector<QryObjVO>(); for (int i = 0; i < voQryStruct.getVetQryObj().size(); i++) { if (!(voQryStruct.getVetQryObj().elementAt(i).getFldorigin() + "." + voQryStruct.getVetQryObj().elementAt(i).getQryfld()) .equalsIgnoreCase("zb.dwbm")) { v_qryObj.addElement(voQryStruct.getVetQryObj().elementAt(i)); } } int qryObjCount = v_qryObj.size(); int[] qryObjIndex = new int[qryObjCount]; int pkCurrtypeIndex = -1; int voucherIdIndex = -1; int[] sumIndex = new int[8]; String[] sumKeys = new String[] { "JFSHLJE", "JFYBJE", "JFFBJE", "JFBBJE", "DFSHLJE", "DFYBJE", "DFFBJE", "DFBBJE", "WDJE" }; // wanglei 2014-01-14 for (int i = 0; i < qryObjCount; i++) { strQryField = v_qryObj.elementAt(i).getFldorigin() + "_" + v_qryObj.elementAt(i).getQryfld(); qryObjIndex[i] = getColIndex(strQryField, oldResultSet.getMetaData()); } pkCurrtypeIndex = getColIndex("FB_BZBM", oldResultSet.getMetaData()); voucherIdIndex = getColIndex("ZB_VOUCHID", oldResultSet.getMetaData()); for (int i = 0; i < 8; i++) { sumIndex[i] = getColIndex(sumKeys[i], oldResultSet.getMetaData()); } HashMap<String, ArrayList<Object>> map = new HashMap<String, ArrayList<Object>>(); // 旧的结果集 ArrayList<ArrayList<Object>> oldValueList = oldResultSet.getResultArrayList(); if (oldValueList != null && oldValueList.size() > 0) { for (int i = 0; i < oldValueList.size(); i++) { strQryObj = ""; ArrayList<Object> list = oldValueList.get(i); for (int j = 0; j < qryObjCount; j++) { strQryObj = strQryObj + (String) list.get(qryObjIndex[j]); } strPkCurrtype = (String) list.get(pkCurrtypeIndex); strVoucherId = (String) list.get(voucherIdIndex); String strKey = strQryObj + strPkCurrtype + strVoucherId; map.put(strKey, list); } } // 暂估及冲回数据 ArrayList<ArrayList<Object>> estimateList = estimateResults[0].getResultArrayList(); if (estimateList != null && estimateList.size() > 0) { for (int i = 0; i < estimateList.size(); i++) { strQryObj = ""; ArrayList<Object> eslist = estimateList.get(i); for (int j = 0; j < qryObjCount; j++) { strQryObj = strQryObj + (String) eslist.get(j); } strPkCurrtype = (String) eslist.get(qryObjCount); strVoucherId = (String) eslist.get(qryObjCount + 1); String strKey = strQryObj + strPkCurrtype + strVoucherId; if (map.get(strKey) != null) { ArrayList<Object> tempList = map.get(strKey); // 借方数量 tempList.set( sumIndex[0], ((BigDecimal) tempList.get(sumIndex[0])) .add((BigDecimal) eslist.get(qryObjCount + 2))); // 借方原币 tempList.set( sumIndex[1], ((BigDecimal) tempList.get(sumIndex[1])) .add((BigDecimal) eslist.get(qryObjCount + 3))); // 借方辅币 tempList.set( sumIndex[2], ((BigDecimal) tempList.get(sumIndex[2])) .add((BigDecimal) eslist.get(qryObjCount + 4))); // 借方本币 tempList.set( sumIndex[3], ((BigDecimal) tempList.get(sumIndex[3])) .add((BigDecimal) eslist.get(qryObjCount + 5))); // 贷方数量 tempList.set( sumIndex[4], ((BigDecimal) tempList.get(sumIndex[4])) .add((BigDecimal) eslist.get(qryObjCount + 6))); // 贷方原币 tempList.set( sumIndex[5], ((BigDecimal) tempList.get(sumIndex[5])) .add((BigDecimal) eslist.get(qryObjCount + 7))); // 贷方辅币 tempList.set( sumIndex[6], ((BigDecimal) tempList.get(sumIndex[6])) .add((BigDecimal) eslist.get(qryObjCount + 8))); // 贷方本币 tempList.set( sumIndex[7], ((BigDecimal) tempList.get(sumIndex[7])) .add((BigDecimal) eslist.get(qryObjCount + 9))); } } // 过滤掉金额为0的数据 int count = 0; while (count < oldValueList.size()) { for (int i = 0; i < oldValueList.size(); i++) { ArrayList<Object> list = oldValueList.get(i); if (new UFDouble(((BigDecimal) list.get(sumIndex[0])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[1])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[2])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[3])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[4])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[5])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[6])).abs()).compareTo(new UFDouble(0)) <= 0 && new UFDouble(((BigDecimal) list.get(sumIndex[7])).abs()).compareTo(new UFDouble(0)) <= 0) { oldValueList.remove(i); count = 0; break; } count++; } } } return vo; }
private MemoryResultSet[] getTempEstimateData(QueryStructVO voQryStruct) throws BusinessException { MemoryResultSet[] mrsResults = null; StringBuffer strSql = new StringBuffer(); strSql.append("select "); // 分组字段 StringBuffer grpSql = new StringBuffer(" "); String strFinalGroupSql = ""; // 查询对象 Vector v_qryObj = voQryStruct.getVetQryObj(); String[] sTargetTab = new String[v_qryObj.size()]; for (int i = 0; i < v_qryObj.size(); i++) { QryObjVO qryObj = (QryObjVO) v_qryObj.elementAt(i); // 不将公司主键作为分组条件 if (qryObj != null && !(qryObj.getFldorigin() + "." + qryObj.getQryfld()).equalsIgnoreCase("zb.dwbm")) { grpSql.append(qryObj.getFldorigin() + "." + qryObj.getQryfld() + ","); } sTargetTab[i] = qryObj.getFldorigin(); } strFinalGroupSql = strFinalGroupSql + grpSql.toString(); // 币种 strFinalGroupSql = strFinalGroupSql + "fb.bzbm,"; // 凭证id strFinalGroupSql = strFinalGroupSql + "clb.vouchid,"; strSql.append(strFinalGroupSql); String strAmountCol = "sum(jfclshl2),sum(jfclybje2),sum(jfclfbje2),sum(jfclbbje2),sum(dfclshl2),sum(dfclybje2),sum(dfclfbje2),sum(dfclbbje2) "; strSql.append(strAmountCol); strSql.append(" from arap_djfb fb inner join arap_djclb clb on clb.fb_oid = fb.fb_oid "); strSql.append(" INNER JOIN arap_djzb zb ON zb.vouchid = fb.vouchid "); AnalyseDirectory directory = new AnalyseDirectory(); String joinSql = ""; try { joinSql = directory.getJoinSQL(sTargetTab); } catch (Exception e1) { ExceptionHandler.getInstance(this.getClass().getName()).handle(e1); } if (!StringUtils.isEmpty(joinSql)) { strSql.append(joinSql); } strSql.append(" where "); // 设置查询条件 StringBuffer strWhere = new StringBuffer(); // 公司 String[] pk_corps = voQryStruct.getCorp(); if (pk_corps != null) { String strPKCorp = "("; for (int i = 0; i < pk_corps.length; i++) { strPKCorp = strPKCorp + "'"; strPKCorp = strPKCorp + pk_corps[i]; strPKCorp = strPKCorp + "',"; } strPKCorp = strPKCorp.substring(0, strPKCorp.length() - 1); strPKCorp = strPKCorp + ") "; strWhere.append(" and " + "clb.dwbm in "); strWhere.append(strPKCorp); } // 起止日期 String strBeginDate = voQryStruct.getDate()[0]; String strEndDate = voQryStruct.getDate()[1]; strWhere.append(" and clb.clrq >= "); strWhere.append(" '" + strBeginDate + "'"); strWhere.append(" and clb.clrq <= "); strWhere.append(" '" + strEndDate + "'"); // 处理标志 strWhere.append(" and clbz = 10 "); // 删除标志 strWhere.append(" and clb.dr = 0 and fb.dr = 0 "); strSql.append(strWhere.substring(4)); strSql.append(" group by "); strSql.append(strFinalGroupSql.substring(0, strFinalGroupSql.length() - 1)); String[] strSqls = new String[] {strSql.toString()}; try { NewListQueryDAO dmo = new NewListQueryDAO(); mrsResults = dmo.getQueryResult(strSqls); } catch (Exception e) { ExceptionHandler.getInstance(this.getClass().getName()).handle(e); } return mrsResults; }
/** * 功能:预处理数据 作者:宋涛 创建时间:(2001-10-25 16:00:59) 参数:<|> 返回值: 算法: * * @return nc.vo.pub.rs.MemoryResultSet[] */ private MemoryResultSet[] prepareData( MemoryResultSet[] mrs, QueryStructVO voQryStruct, boolean bHasSum, String[][] strObj, String[][] strDisplay) throws java.sql.SQLException { MemoryResultSet[] mrsResults = new MemoryResultSet[2]; /** 需要计算的数字字段 */ String[] sValueFlds = getJeFlds(voQryStruct.getIfx()); // String[] sObjFlds = strObj[1]; // if (!ArrayUtils.isEmpty(strObj[5])) { // for (String column : strObj[5]) { // sObjFlds = (String[]) ArrayUtils.add(sObjFlds, column); // } // } /** 查询对象字段 */ String sObjKey = EfficientPubMethod_NEW.array2string(strObj[1], IEfficientPubMethod.COMMA); String sDisplay = EfficientPubMethod_NEW.array2string(strDisplay[1], IEfficientPubMethod.COMMA); /** 期初 */ long qichu = System.currentTimeMillis(); mrsResults[0] = ComTool.sumResultSet(mrs[0], mrs[1], strObj[1], sValueFlds, JOIN_MODE); mrs[0] = null; mrs[1] = null; Log.getInstance(this.getClass()).debug("####预处理期初处理时间:" + (System.currentTimeMillis() - qichu)); long benqi = System.currentTimeMillis(); ResultSumTool sumTool = new ResultSumTool(); sumTool.setSourceResultSet(mrs[2]); mrs[2] = null; sumTool.setSumKey(PubMethodVO.getToken(sObjKey + ",zy,clbh," + sDisplay, ",")); sumTool.setSumValueKey(sValueFlds); sumTool.setJoinMode(JOIN_MODE); int LJ = 10; if (voQryStruct.isNew()) { LJ = 3; } for (int i = 3; i <= LJ; i++) { sumTool.addSumResultSet(mrs[i]); mrs[i] = null; } /** 本期 */ mrsResults[1] = sumTool.execute(); sumTool = null; Log.getInstance(this.getClass()).debug("####预处理本期处理时间:" + (System.currentTimeMillis() - benqi)); // ComTool.printResultSet(mrsResults[1]); long bennianleiji = System.currentTimeMillis(); if (bHasSum) { String[] arryLjValueFlds = getLjValueFlds(); sumTool = new ResultSumTool(); sumTool.setSourceResultSet(mrs[mrs.length - 1]); mrs[mrs.length - 1] = null; sumTool.setSumKey(strObj[1]); sumTool.setSumValueKey(arryLjValueFlds); sumTool.setJoinMode(JOIN_MODE); for (int i = LJ + 1; i < mrs.length - 1; i++) { sumTool.addSumResultSet(mrs[i]); mrs[i] = null; } MemoryResultSet mrsLj = sumTool.execute(); // ComTool.printResultSet(mrsLj); /** 连接本年累计和期初 */ ResultJoinTool rjt = new ResultJoinTool(); rjt.setSourceResultSet(mrsResults[0]); rjt.addJoinResultSet(mrsLj, strObj[1], arryLjValueFlds); mrsResults[0] = rjt.execute(); // ComTool.printResultSet(mrsResults[0]); /** 连接本年累计和本期 */ rjt = new ResultJoinTool(); rjt.setSourceResultSet(mrsResults[1]); rjt.addJoinResultSet(mrsLj, strObj[1], arryLjValueFlds); mrsResults[1] = rjt.execute(); // ComTool.printResultSet(mrsResults[1]); } sumTool = null; Log.getInstance(this.getClass()) .debug("####预处理本年累计处理时间:" + (System.currentTimeMillis() - bennianleiji)); return mrsResults; }
private boolean isLastPageIndex(QueryStructVO voQryStruct, RSTransferVO voResult) { return voQryStruct.getPaginationConfig() != null && voQryStruct.getPaginationConfig().getPageIndex() == voResult.getPageCount(); }
/** * 通过查询对象、条件和显示字段构造查询语句,返回符合条件的查询结果。 * * <p>创建日期:(2001-5-15) * * @return StatValueObject[] 查到的VO对象数组 * @param QueryStructVO voQryStruct 查询结构 * @exception BusinessException 异常说明。 */ public RSTransferVO getQueryResult(QueryStructVO voQryStruct) throws BusinessException { try { RSTransferVO voResult = new RSTransferVO(); MemoryResultSet[] mrsResults = null; // add by wdg(2007-10-18) // 期初暂估冲回数据 MemoryResultSet[] tempEstimateInitMrsResults = null; // 暂估发生数据 MemoryResultSet[] tempEstimateOccurMrsResults = null; for (int i = 0; i < voQryStruct.getVetQryObj().size(); i++) { if (nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() .getStrByID("2006", "UPTcommon-0100172") /*@res "客商"*/ .equals(voQryStruct.getVetQryObj().get(i).getM_strDisplayName())) { voQryStruct.getVetQryObj().get(i).setPk_bdinfo("00010000000000000073"); } } if (voQryStruct.getSecsrc() != null) { InvocationInfoProxy.getInstance().setUserDataSource(voQryStruct.getSecsrc()); } if (true) { ListQueryMetadata queryMetadata = new ListQueryMetadata(QueryMetadataUtil.convertQryStruct2Metadata(voQryStruct)); DateRange dateRange = new DateRange(); dateRange.setStartDate(voQryStruct.getSumDate()[0]); dateRange.setEndDate(voQryStruct.getSumDate()[1]); queryMetadata.getConfig().setSumDateRange(dateRange); queryMetadata.getConfig().setMonthQuery(voQryStruct.isQuerybyPeriod()); if (voQryStruct.getSecsrc() == null) { BalQryObjLogUtil.log( queryMetadata.getQueryObjects(), queryMetadata.getConfig().getSystem() == SysEnum.YS ? "20060504" : "20080504"); } voResult = new ListQueryBO().query(queryMetadata); mrsResults = voResult.getResultset(); } else { /** 插入单据信息,这是明细查询中的必查项目 */ Vector<QryObjVO> vetDisplay = voQryStruct.getVetDisplay(); vetDisplay = insertDjxx(vetDisplay); voQryStruct.setVetDisplay(vetDisplay); Vector vetObj = voQryStruct.getVetQryObj(); vetObj = PubMethodVO.mergeVector(vetObj, voQryStruct.getVetGroupBy()); voQryStruct.setVetQryObj(vetObj); voQryStruct.setVetGroupBy(new Vector()); ICreateSql createTools = getSqlCreater(); if (voQryStruct.isWanglaiDetail()) { createTools = new CreateSql_WL(); } /*设置需要的查询语句*/ int[] iPos; boolean[] bSum; if (!voQryStruct.isQuerybyPeriod()) { /*日期模式*/ iPos = new int[] { 0, 1, 2, 3, /*4, 5, 6, 7, 8, 9, 10*/ }; bSum = new boolean[] { false, false, false, false, /* false, false, false, false, false, false, false */ }; } else { /*期间模式*/ iPos = new int[] { 0, 1, 2, 3, /* 4, 5, 6, 7, 8, 9, 10, */ 2, 3, /*4, 5, 6, 7, 8, 9, 10*/ }; bSum = new boolean[] { false, false, false, false, /* false, false, false, false, false, false, false,*/ true, true, /*true, true, true, true, true, true, true */ }; } /*-----设置完毕----*/ NewListQueryDAO dmo = new NewListQueryDAO(); // Debug.println("调用dmo类,进行查询"); // zhongyue_begin for 多单位权限控制 begin nc.bs.arap.pub.CreatJoinSQLTool jointool = new nc.bs.arap.pub.CreatJoinSQLTool(); if (voQryStruct.getSecsrc() != null) { InvocationInfoProxy.getInstance().setUserDataSource(voQryStruct.getSecsrc()); } if (jointool.checkLegal(voQryStruct.getCorp())) { createTools.setQueryIdx(iPos, bSum); createTools.setDateType(voQryStruct); createTools.initParam(voQryStruct); String[] strSqls = createTools.getSQL(); mrsResults = dmo.getQueryResult(strSqls); } else { String[] sPk_corps = voQryStruct.getCorp(); if (sPk_corps != null) { for (int i = 0; i < sPk_corps.length; i++) { String[] tables = new PowerCtrlVO(sPk_corps[i]).getTables(); if (voQryStruct.getPowerCtrlVO() != null) { voQryStruct.getPowerCtrlVO().setTables(tables); } voQryStruct.setCorp(new String[] {sPk_corps[i]}); if (voQryStruct.getPowerCtrlVO() != null) { voQryStruct.getPowerCtrlVO().setPk_corp(new String[] {sPk_corps[i]}); } createTools = getSqlCreater(); if (voQryStruct.isWanglaiDetail()) { createTools = new CreateSql_WL(); } createTools.setQueryIdx(iPos, bSum); createTools.setDateType(voQryStruct); createTools.initParam(voQryStruct); String[] strSqls = createTools.getSQL(); mrsResults = mergeMultiCorps(mrsResults, dmo.getQueryResult(strSqls)); } } } } String[] sPk_corps = voQryStruct.getCorp(); if (sPk_corps != null) { for (int i = 0; i < sPk_corps.length; i++) { // 期初冲回数据要考虑数据权限,否则查出的无权限数据加入原期初结果集会造成数据增多 if (!voQryStruct.isBlnClearEstimateDataShow()) { tempEstimateInitMrsResults = mergeMultiCorps( tempEstimateInitMrsResults, getInitTempEstimateOffsetData(voQryStruct)); tempEstimateOccurMrsResults = mergeMultiCorps(tempEstimateOccurMrsResults, getTempEstimateData(voQryStruct)); } } } // end if (voQryStruct.isVouchshow()) { PubMethodVO.insertVouchidCol(mrsResults); } VOCompress.objectReference(mrsResults); voResult.setResultset(mrsResults); /*删除控制数据权限建立的临时表*/ // new PubDMO().onDropTemTab(createTools.getPowerHashtable()); // 如果查询条件为“已两清的暂估单据不显示”(add by wdg:2007-10-11) if (!voQryStruct.isBlnClearEstimateDataShow()) { mergeTempEstimateData( voQryStruct, voResult, tempEstimateInitMrsResults, tempEstimateOccurMrsResults); } if (!voQryStruct.isRecheck() && !(voQryStruct .getStrBillType() .equals( NCLangRes4VoTransl.getNCLangRes() .getStrByID("20060504", "UPP20060504-000228")) || voQryStruct .getStrBillType() .equals( NCLangRes4VoTransl.getNCLangRes() .getStrByID("20060504", "UPP20060504-000230")))) { Iterator<QryObjVO> iterator = voQryStruct.getVetQryObj().iterator(); while (iterator.hasNext()) { QryObjVO qryObjVO = iterator.next(); if ("bzbm".equals(qryObjVO.getQryfld())) { iterator.remove(); } } } voResult.setObjs(getJoinTools().getQryObjs(voQryStruct.getVetQryObj())); voResult.setDisplays(getJoinTools().getQryObjs(voQryStruct.getVetDisplay())); MemoryResultSet sumRs = null; MemoryResultSet[] mrs = voResult.getResultset(); if (isLastPageIndex(voQryStruct, voResult)) { sumRs = voResult.getResultset()[voResult.getResultset().length - 1]; mrs = (MemoryResultSet[]) ArrayUtils.subarray(voResult.getResultset(), 0, voResult.getResultset().length - 1); } MemoryResultSet[] mrsSource = prepareData( mrs, voQryStruct, voQryStruct.isQuerybyPeriod(), voResult.getObjs(), voResult.getDisplays()); if (mrsSource != null) { int total = 0; for (MemoryResultSet ms : mrsSource) { if (ms != null && ms.getResultArrayList() != null) total += ms.getResultArrayList().size(); } if (total > 20000) { throw new BusinessException("记录超过两万条,请分页查或缩小查询范围"); } } voResult.setResultset(mrsSource); if (sumRs != null) { voResult.setResultset((MemoryResultSet[]) ArrayUtils.add(mrsSource, sumRs)); } PubMethodVO.createCodeAndName(voResult.getObjs()); PubMethodVO.insertCodeAndNameColumns(voResult.getResultset(), voResult.getObjs()); return voResult; } catch (Exception e) { Log.getInstance(this.getClass()).error(e.getMessage()); throw new BusinessShowException(e.getMessage()); } }