/** * 查询机构下的所有子机构,参数orgid为空时返回顶级机构 * * @param orgid * @return */ public OrgOrganization[] querySubOrgs(String orgid) { // 设置查询条件 IDASCriteria dasCriteria = getDASTemplate().createCriteria(OrgOrganization.QNAME); if (StringUtils.isBlank(orgid)) { // orgid为空则查询顶级机构 dasCriteria.add(ExpressionHelper.isNull("orgOrganization")); } else { dasCriteria.add(ExpressionHelper.eq("orgOrganization.orgid", orgid)); } OrgOrganization[] orgs = getDASTemplate().queryEntitiesByCriteriaEntity(OrgOrganization.class, dasCriteria); return orgs; }
/** * 查询机构下的所有岗位 * * @param orgid * @return */ public OrgPosition[] queryPositionsOfOrg(String orgid) { if (StringUtils.isBlank(orgid)) { return new OrgPosition[0]; } // 设置查询条件 IDASCriteria dasCriteria = getDASTemplate().createCriteria(OrgPosition.QNAME); dasCriteria.add(ExpressionHelper.eq("orgOrganization.orgid", orgid)); dasCriteria.add(ExpressionHelper.isNull("orgPosition.positionid")); OrgPosition[] positions = getDASTemplate().queryEntitiesByCriteriaEntity(OrgPosition.class, dasCriteria); return positions; }
/** * 获取子机构同时获取父机构信息 * * @param child */ public OrgOrganization getOrgOrganizationWithParent(OrgOrganization child) { IDASCriteria dasCriteria = getDASTemplate().createCriteria(OrgOrganization.QNAME); dasCriteria.add(ExpressionHelper.eq("orgid", child.getOrgid())); dasCriteria.addAssociation("orgOrganization"); OrgOrganization[] orgs = getDASTemplate().queryEntitiesByCriteriaEntity(OrgOrganization.class, dasCriteria); if (orgs != null && orgs.length == 1) { return orgs[0]; } return OrgOrganization.FACTORY.create(); }
/** * 检验机构code是否合格 * * @param orgcode * @return true合格,false不合格 */ public boolean validateOrgcode(OrgOrganization org) { IDASCriteria dasCriteria = getDASTemplate().createCriteria(OrgOrganization.QNAME); dasCriteria.add(ExpressionHelper.eq("orgcode", org.getOrgcode())); OrgOrganization[] orgs = getDASTemplate().queryEntitiesByCriteriaEntity(OrgOrganization.class, dasCriteria); if (orgs == null || orgs.length == 0) { return true; } if (org.getOrgid() != null && orgs[0].getOrgid().equals(org.getOrgid())) { // 修改的情况,只能为1个 return orgs.length == 1; } else { // 新增,必定没有 return orgs.length == 0; } }
/** * 查询机构下的所有员工 * * @param orgid * @return */ public OrgEmployee[] queryEmployeesOfOrg(String orgid) { if (StringUtils.isBlank(orgid)) { return new OrgEmployee[0]; } // 设置查询条件 IDASCriteria dasCriteria = getDASTemplate().createCriteria(OrgEmployee.QNAME); dasCriteria.add(ExpressionHelper.eq("orgid", orgid)); OrgEmployee[] emps = getDASTemplate().queryEntitiesByCriteriaEntity(OrgEmployee.class, dasCriteria); return emps; }