NC6 人员信息查询、维护列表表头和表体子集数据查询或加载方法

表头数据查询:
类 nc.impl.hi.psndoc.PsndocDAO 中 queryPsndocVOByPks()方法

public PsndocAggVO[] queryPsndocVOByPks(boolean blLazyLoad, String... strPks) throws BusinessException {

		if (strPks == null || strPks.length == 0) {
			return null;
		}

		ArrayList<String> fields = getDefaultQueryFields();
		String fieldSql = "";
		for (String fld : fields) {
			fieldSql += "," + fld;
		}
		fieldSql = fieldSql.substring(1);

		ArrayList<PsndocVO> psns = null;
		InSQLCreator ttu = null;
		try {
			ttu = new InSQLCreator();
			String selectSql = " select " + fieldSql + " from bd_psndoc inner join hi_psnorg on bd_psndoc.pk_psndoc = hi_psnorg.pk_psndoc "
					+ " inner join hi_psnjob on hi_psnorg.pk_psnorg = hi_psnjob.pk_psnorg where hi_psnjob.pk_psnjob in ( " + ttu.getInSQL(strPks) + " ) order by hi_psnjob.showorder";
			psns = (ArrayList<PsndocVO>) baseDAOManager.executeQuery(selectSql, new BeanListProcessor(PsndocVO.class));

		}
		// 不把异常吃掉,否则查询死循环
		// catch (Exception e)
		// {
		// Logger.error(e.getMessage(), e);
		// }
		finally {
			if (ttu != null) {

				ttu.clear();

			}
		}

		if (psns == null || psns.size() == 0) {
			return null;
		}

		HashMap<String, PsndocVO> hm = new HashMap<String, PsndocVO>();
		for (PsndocVO psn : psns) {
			hm.put(psn.getPsnJobVO().getPk_psnjob(), psn);
		}

		ArrayList<PsndocAggVO> al = new ArrayList<PsndocAggVO>();
		for (String pk : strPks) {
			if (hm.get(pk) == null) {
				continue;
			}
			PsndocAggVO agg = new PsndocAggVO();
			agg.setParentVO(hm.get(pk));
			al.add(agg);
		}

		return al.size() > 0 ? al.toArray(new PsndocAggVO[0]) : null;

	}

	public Object[] queryPsndocVOByPks(boolean b, String[] strPks, Object treeObj) throws BusinessException {
		if (strPks == null || strPks.length == 0) {
			return null;
		}

		ArrayList<String> fields = getDefaultQueryFields();
		String fieldSql = "";
		for (String fld : fields) {
			fieldSql += "," + fld;
		}
		fieldSql = fieldSql.substring(1);

		ArrayList<PsndocVO> psns = null;
		InSQLCreator ttu = null;
		try {
			ttu = new InSQLCreator();
			String inSql = ttu.getInSQL(strPks);
			String selectSql = " select " + fieldSql + " from bd_psndoc inner join hi_psnorg on bd_psndoc.pk_psndoc = hi_psnorg.pk_psndoc "
					+ " inner join hi_psnjob on hi_psnorg.pk_psnorg = hi_psnjob.pk_psnorg where hi_psnjob.pk_psnjob in ( " + inSql + " )";
			psns = (ArrayList<PsndocVO>) baseDAOManager.executeQuery(selectSql, new BeanListProcessor(PsndocVO.class));

			if (psns == null || psns.size() == 0) {
				return null;
			}

			String sql = " select pk_psnorg , sum(case when endflag ='Y' then 0 else 1 end) as count from hi_psndoc_keypsn where pk_psnorg in ( select pk_psnorg from hi_psnjob where pk_psnjob in ( " + inSql + " )) ";
			if (treeObj instanceof KeyPsnGrpVO) {
				sql += " and pk_keypsn_grp ='" + ((KeyPsnGrpVO) treeObj).getPk_keypsn_group() + "' ";
			}

			sql += " group by pk_psnorg ";

			GeneralVO[] vos = (GeneralVO[]) new BaseDAO().executeQuery(sql, new GeneralVOProcessor<GeneralVO>(GeneralVO.class));
			HashMap<String, UFBoolean> map = new HashMap<String, UFBoolean>();
			for (int i = 0; vos != null && i < vos.length; i++) {
				map.put((String) vos[i].getAttributeValue("pk_psnorg"),
						(vos[i].getAttributeValue("pk_psnorg") == null || new Integer(vos[i].getAttributeValue("count").toString()) <= 0) ? UFBoolean.TRUE : UFBoolean.FALSE);
			}

			HashMap<String, PsndocVO> hm = new HashMap<String, PsndocVO>();
			for (PsndocVO psn : psns) {
				psn.setIshiskeypsn(map.get(psn.getPsnOrgVO().getPk_psnorg()) == null ? UFBoolean.TRUE : map.get(psn.getPsnOrgVO().getPk_psnorg()));
				hm.put(psn.getPsnJobVO().getPk_psnjob(), psn);
			}

			ArrayList<PsndocAggVO> al = new ArrayList<PsndocAggVO>();
			for (String pk : strPks) {
				if (hm.get(pk) == null) {
					continue;
				}
				PsndocAggVO agg = new PsndocAggVO();
				agg.setParentVO(hm.get(pk));
				al.add(agg);
			}

			return al.size() > 0 ? al.toArray(new PsndocAggVO[0]) : null;
		} catch (Exception e) {
			Logger.error(e.getMessage(), e);
			return null;
		} finally {
			if (ttu != null) {

				ttu.clear();

			}
		}
	}

表体子集数据加载:
列表类:nc.ui.hi.psndoc.view.PsndocListView 中 loadCurrentRowSubData()方法

/***************************************************************************
     * 处理子集加载数据<br>
     * Created on 2010-5-8 17:30:13<br>
     * @author Rocex Wang
     ***************************************************************************/
    public void loadCurrentRowSubData()
    {
        int tabIndex = getBillListPanel().getBodyTabbedPane().getSelectedIndex();
        if (tabIndex < 0)
        {
            // 如果当前选择的页签为-1 返回
            return;
        }
        BillModel billModel = getBillListPanel().getBodyBillModel();
        if (billModel.getTabvo() == null)
        {
            return;
        }
        String strTabCode = billModel.getTabvo().getTabcode();
        SuperVO subVOs[] = null;
        try
        {
            subVOs = getDataManger().querySubVO(strTabCode, null);
        }
        catch (BusinessException ex)
        {
            throw new BusinessRuntimeException(ex.getMessage(), ex);
        }
        if (subVOs != null && subVOs.length > 0)
        {
            billModel.clearBodyData();
            billModel.addLine(subVOs.length);
            // for (int i = 0; i < subVOs.length; i++)
            // {
            // billModel.setBodyRowObjectByMetaData(subVOs[i], i);
            // billModel.setRowState(i, BillModel.NORMAL);
            
            // }
            billModel.setBodyRowObjectByMetaData(subVOs, 0);
            billModel.execLoadFormula();
        }
    }

调用类 nc.ui.hi.psndoc.model.PsndocDataManager 中 querySubVO(String strTabCode, String strAddtionalWhere) 方法

/***************************************************************************
     * <br>
     * Created on 2010-2-23 9:32:55<br>
     * @param strTabCode
     * @param strAddtionalWhere
     * @return SuperVO[]
     * @throws BusinessException
     * @author Rocex Wang
     ***************************************************************************/
    public SuperVO[] querySubVO(String strTabCode, String strAddtionalWhere) throws BusinessException
    {
        if (getModel().getCurrentPkPsndoc() == null || getModel().getCurrentPkPsndoc().trim().length() == 0)
        {
            return null;
        }
        if (strAddtionalWhere == null)
        {
            strAddtionalWhere = "";
        }
        if (PsnJobVO.getDefaultTableName().equals(strTabCode))
        {
            strAddtionalWhere += " hi_psnjob.ismainjob='Y'";
        }
        else if (PartTimeVO.getDefaultTableName().equals(strTabCode))
        {
            strAddtionalWhere += " hi_psnjob.ismainjob='N'";
        }
        else if (CtrtVO.getDefaultTableName().equals(strTabCode))
        {
            // 在维护和信息节点合同只能看到生效的记录
            strAddtionalWhere += " hi_psndoc_ctrt.isrefer = 'Y' ";
        }
        else if (KeyPsnVO.getDefaultTableName().equals(strTabCode))
        {
            // 关键人员选择根节点显示全部,否则只显示所选组的信息
            if (getModel().getCurrTypeOrgVO() != null && getModel().getCurrTypeOrgVO() instanceof KeyPsnGrpVO)
            {
                strAddtionalWhere +=
                    " hi_psndoc_keypsn.pk_keypsn_grp = '" + ((KeyPsnGrpVO) getModel().getCurrTypeOrgVO()).getPk_keypsn_group() + "' ";
            }
            else
            {
                strAddtionalWhere +=
                    " hi_psndoc_keypsn.pk_keypsn_grp in ( select pk_keypsn_group from hi_keypsn_group where "
                        + KeyPsnGroupSqlUtils.getKeyPsnGroupPowerSql(KeyPsnGrpVO.getDefaultTableName()) + " ) ";
            }
        }
        else if (CapaVO.getDefaultTableName().equals(strTabCode))
        {
            strAddtionalWhere += " hi_psndoc_capa.lastflag = 'Y' ";
        }
        else if (TrainVO.getDefaultTableName().equals(strTabCode))
        {
            PsndocAggVO psndocAggVO = (PsndocAggVO) getModel().getSelectedData();
            if (psndocAggVO != null && psndocAggVO.getParentVO().getPsnJobVO() != null)
            {
                String pk_psnjob = psndocAggVO.getParentVO().getPsnJobVO().getPk_psnjob();
                strAddtionalWhere += " hi_psndoc_train.pk_psnjob = '" + pk_psnjob + "' ";
            }
        }
        
        String strWhere = " pk_psndoc='" + getModel().getCurrentPkPsndoc() + "'";
        PsndocAggVO psndocAggVO = (PsndocAggVO) getModel().getSelectedData();
        
        // 业务子集还要按照组织关系主键过滤
        if ((getModel().getBusinessInfoSet().contains(strTabCode) || WainfoVO.getDefaultTableName().equals(strTabCode))
            && psndocAggVO != null)
        {
            if (HICommonValue.FUNC_CODE_PSN_INFO.equals(getContext().getNodeCode()))
            {
                //
                String pk_org = psndocAggVO.getParentVO().getPsnJobVO().getPk_org();
                if (PsnJobVO.getDefaultTableName().equals(strTabCode))
                {
                    
                    strWhere +=
                        " and pk_org = '" + pk_org + "' and pk_psnorg = '" + psndocAggVO.getParentVO().getPsnOrgVO().getPrimaryKey() + "'";
                }
                else if (PsndocAggVO.hashPsnJobInfoSet.contains(strTabCode))
                {
                    
                    strWhere +=
                        " and pk_psnjob in (select pk_psnjob from hi_psnjob where pk_org = '" + pk_org + "' and pk_psnorg = '"
                            + psndocAggVO.getParentVO().getPsnOrgVO().getPrimaryKey() + "') ";
                }
                else
                {
                    
                    // 只显示当前组织关系的数据
                    strWhere += " and pk_psnorg = '" + psndocAggVO.getParentVO().getPsnOrgVO().getPrimaryKey() + "'";
                }
                
                // 信息查询节点 单独处理主职/兼职记录
                UFBoolean ismainjob = psndocAggVO.getParentVO().getPsnJobVO().getIsmainjob();
                if (ismainjob == null || !ismainjob.booleanValue())
                {
                    // 兼职,除兼职外的业务子集不显示
                    if (WainfoVO.getDefaultTableName().equals(strTabCode))
                    {
                        strWhere +=
                            " and pk_psnjob in (select pk_psnjob from hi_psnjob where pk_org = '" + pk_org + "' and pk_psnorg = '"
                                + psndocAggVO.getParentVO().getPsnOrgVO().getPrimaryKey() + "' and ismainjob = 'N') ";
                    }
                    else if (PartTimeVO.getDefaultTableName().equals(strTabCode))
                    {
                        // 兼职页签显示任职组织下的兼职
                        strWhere += " and pk_org = '" + pk_org + "' ";
                    }
                    else if (TrainVO.getDefaultTableName().equals(strTabCode))
                    {
                        strWhere += " and 1 = 1 ";
                    }
                    else
                    {
                        strWhere += " and 1 = 2 ";
                    }
                }
            }
            else
            {
                if (UIState.ADD == getModel().getUiState() || UIState.EDIT == getModel().getUiState())
                {
                    // 编辑态还是只显示当前组织关系的数据
                    strWhere += " and pk_psnorg = '" + psndocAggVO.getParentVO().getPsnOrgVO().getPrimaryKey() + "'";
                }
                else
                {
                    // 编辑态还是只显示当前组织关系的数据
                    strWhere += " and pk_psnorg = '" + psndocAggVO.getParentVO().getPsnOrgVO().getPrimaryKey() + "'";
                    // 显示所有信息时只显示转档的数据
                    // strWhere +=
                    // " and pk_psnorg in ( select pk_psnorg from hi_psnorg where pk_psndoc='"
                    // + getModel().getCurrentPkPsndoc()
                    // + "' and indocflag = 'Y' and orgrelaid <= " +
                    // psndocAggVO.getParentVO().getPsnOrgVO().getOrgrelaid() +
                    // " ) ";
                }
            }
            
        }
        
        if (strAddtionalWhere.length() > 0)
        {
            strWhere = strWhere + " and " + strAddtionalWhere;
        }
        
        IBean bean = MDBaseQueryFacade.getInstance().getBeanByFullName("hrhi." + strTabCode);
        IAttribute attribute = MDBaseQueryFacade.getInstance().getAttributeByFullName("hrhi." + strTabCode + ".recordnum");
        String strOrder = attribute != null ? " recordnum desc" : null;// 此处根据不同情况构建order
        
        // 业务子集在非编辑态并且显示所有信息时,按照开始时间排序
        if (getModel().getBusinessInfoSet().contains(strTabCode) && HICommonValue.FUNC_CODE_PSN_INFO.equals(getContext().getNodeCode()))
        {
            if (QulifyVO.getDefaultTableName().equals(strTabCode))
            {
                strOrder = " authendate ";
            }
            else
            {
                strOrder = " begindate ";
            }
        }
        
        Class clazzVO = null;
        try
        {
            clazzVO = Class.forName(bean.getFullClassName());
        }
        catch (ClassNotFoundException ex)
        {
            Logger.error(ex);
        }
        SuperVO subVOs[] = getQueryService().querySubVO(clazzVO, strWhere, strOrder);
        return subVOs;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值