获取成本中心的方法

 //成本中心
        String costCenter = jo.getString("orgUnit");
        verifyFieldNotNull("costCenter", costCenter);
          CostCenterOrgUnitInfo costCenterInfo = null;
          FullOrgUnitInfo tempInfo = (FullOrgUnitInfo)
            BillProertiesConvertor.getValueObject(costCenter, FullOrgUnitInfo.class, null, ctx);
          verifyFieldNotNull("costCenter", tempInfo);
          while ((tempInfo != null) && (!tempInfo.isIsCostOrgUnit()) && (tempInfo.getParent() != null)) {
            tempInfo = tempInfo.getParent();
            tempInfo = FullOrgUnitFactory.getLocalInstance(ctx).getFullOrgUnitInfo(new ObjectUuidPK(tempInfo.getId()));
          }
          verifyFieldNotNull("costCenter", tempInfo);
          costCenterInfo = CostCenterOrgUnitFactory.getLocalInstance(ctx).getCostCenterOrgUnitInfo(new ObjectUuidPK(tempInfo.getId()));
          if (!tempInfo.isIsCostOrgUnit())
            throw new EASBizException(new NumericExceptionSubItem("", "当前成本中心匹配不到,请检查"));
         //判断是成本中心虚体
          if (!costCenterInfo.isIsBizUnit()) {
			String sql = "/*dialect*/select FID from t_org_baseunit where FParentID = '"+tempInfo.getId()+"' and FNUMBER LIKE '%-B%' ";  
			IRowSet rows = DbUtil.executeQuery(ctx, sql);
			String  fid = null;
			if (rows != null && rows.size()>0 && rows.next()) {
				fid = rows.getString("FID");
		 }
			 FullOrgUnitInfo tempInfo2 = FullOrgUnitFactory.getLocalInstance(ctx).getFullOrgUnitInfo(new ObjectUuidPK(fid));
			 CostCenterOrgUnitInfo  costCenterInfo2 = CostCenterOrgUnitFactory.getLocalInstance(ctx).getCostCenterOrgUnitInfo(new ObjectUuidPK(fid));
			 costCenterInfo = new CostCenterOrgUnitInfo();
			 costCenterInfo.setId(tempInfo2.getId());
	         eInfo.setCostCenter(costCenterInfo2);
          }else {
        	  costCenterInfo = new CostCenterOrgUnitInfo();
              costCenterInfo.setId(tempInfo.getId());
              eInfo.setCostCenter(costCenterInfo);
          }       

 

你可能感兴趣的:(eas,bos)