package nc.impl.fa.assetcombin;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import nc.bs.am.framework.action.IActionTemplate;
import nc.bs.am.framework.action.IRule;
import nc.bs.am.framework.action.approve.ApproveActionTemplate;
import nc.bs.am.framework.action.approve.UnApproveActionTemplate;
import nc.bs.am.framework.common.rule.ValidateServiceRule;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.uif2.validation.Validator;
import nc.impl.am.bill.BillBaseDAO;
import nc.impl.am.bill.rule.BillCodeDeleteRule;
import nc.impl.am.bill.rule.BillCodeInsertAfterRule;
import nc.impl.am.bill.rule.BillCodeInsertBeforeRule;
import nc.impl.am.bill.rule.BillCodeUpdateRule;
import nc.impl.am.bill.rule.VOSagasStatusCheckBeforeRule;
import nc.impl.am.common.InSqlManager;
import nc.impl.am.db.DBAccessUtil;
import nc.impl.am.db.QueryUtil;
import nc.impl.fa.asset.AssetServiceImpl;
import nc.impl.fa.assetcombin.rule.AddNewAssetRule;
import nc.impl.fa.assetcombin.rule.AfterAssetCombinedApprove;
import nc.impl.fa.assetcombin.rule.CancelAssetReduceRule;
import nc.impl.fa.assetcombin.rule.ClearHeadAssetCardInfoRule;
import nc.impl.fa.assetcombin.rule.CombineAssetInMultiAccbookRule;
import nc.impl.fa.assetcombin.rule.DeleteNewAssetRule;
import nc.impl.fa.assetcombin.rule.ReduceCombinedAssetRule;
import nc.impl.fa.assetcombin.rule.UpdateRelatedEquipInfoForApprovingRule;
import nc.impl.fa.assetcombin.rule.UpdateRelatedEquipsInfoForUnapproving;
import nc.impl.fa.assetcombin.validator.CheckCreatedCardMinUnClosedBookPeriodValidator;
import nc.impl.fa.assetcombin.validator.CheckHeadAssetCategoryLegalValidator;
import nc.impl.fa.assetcombin.validator.CheckHeadDepStartDateValidator;
import nc.impl.fa.assetcombin.validator.CheckInTheSameAccbookValidator;
import nc.impl.fa.assetcombin.validator.CheckWorkloanInfosValidator;
import nc.impl.fa.closebook.CloseBookImpl;
import nc.impl.fa.common.rule.CreateBillLogAfterRule;
import nc.impl.fa.common.rule.DeleteBillLogAfterRule;
import nc.impl.fa.common.rule.UpdateCardLogAfterRule;
import nc.impl.fa.common.validator.CheckCardLegalValidator;
import nc.impl.fa.common.validator.CheckHasFipMakeVoucherForAccbooks;
import nc.impl.fa.common.validator.CheckMinUnClosedBookPeriodValidator;
import nc.impl.fa.rule.PKAccbookBeforeRule;
import nc.impl.fa.rule.ReceiptScanBeforeRule;
import nc.itf.am.prv.IDataService;
import nc.itf.fa.prv.IAssetCombin;
import nc.itf.fa.service.IAccbookInfoService;
import nc.itf.fa.service.IAssetService;
import nc.itf.fa.service.ICloseBookService;
import nc.md.model.MetaDataException;
import nc.pub.fa.common.consts.LogTypeConst;
import nc.pub.fa.common.manager.DeptScaleManager;
import nc.pub.fa.common.manager.VOManager;
import nc.pub.fa.common.util.FAUseDeptKeyGenerator;
import nc.pub.fa.common.util.StringUtils;
import nc.pub.fa.common.util.UseDeptScaleUtils;
import nc.vo.am.common.BaseLockData;
import nc.vo.am.common.TransportBillVO;
import nc.vo.am.common.util.ArrayUtils;
import nc.vo.am.common.util.BillTransportTool;
import nc.vo.am.common.util.CollectionUtils;
import nc.vo.am.common.util.MapUtils;
import nc.vo.am.manager.AccperiodVO;
import nc.vo.am.manager.LockManager;
import nc.vo.am.proxy.AMProxy;
import nc.vo.fa.assetcombin.AssetCombinBodyVO;
import nc.vo.fa.assetcombin.AssetCombinHeadVO;
import nc.vo.fa.assetcombin.AssetCombinVO;
import nc.vo.fa.deptscale.DeptScaleVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.uif2.LoginContext;

public class AssetCombinImpl
  extends BillBaseDAO<AssetCombinVO>
  implements IAssetCombin
{
  public void delete(AssetCombinVO vo)
    throws BusinessException
  {
    vo = reQueryBillByPK(new String[] { vo.getParent().getPrimaryKey() });
    
    deleteBillVO(new AssetCombinVO[] { vo });
  }
  
  public TransportBillVO insert(LoginContext context, AssetCombinVO vo)
    throws BusinessException
  {
    String link_key = dealWithUseDept(vo);
    
    ((AssetCombinHeadVO)vo.getParent()).setUsedept(link_key);
    
    AssetCombinVO[] vos = (AssetCombinVO[])insertBillVO(new AssetCombinVO[] { vo });
    if ((vos == null) || (vos.length == 0)) {
      return null;
    }
    releasePKCardLock(vo, context);
    
    TransportBillVO pkBillVO = BillTransportTool.createTransportBill(vos[0], 1);
    
    return pkBillVO;
  }
  
  protected void initCommitActionRules(IActionTemplate<AssetCombinVO> template)
  {
    super.initCommitActionRules(template);
    
    template.addBeforeRule(new VOSagasStatusCheckBeforeRule());
    
    template.addBeforeRule(new ReceiptScanBeforeRule());
  }
  
  protected void releasePKCardLock(AssetCombinVO billVO, LoginContext context)
  {
    if (billVO == null) {
      return;
    }
    AssetCombinBodyVO[] bodyVOs = (AssetCombinBodyVO[])billVO.getChildrenVO();
    if ((null == bodyVOs) || (bodyVOs.length < 1)) {
      return;
    }
    List<String> list = new ArrayList();
    for (int i = 0; i < bodyVOs.length; i++) {
      if (StringUtils.isNotEmpty(bodyVOs[i].getPk_card())) {
        list.add(bodyVOs[i].getPk_card());
      }
    }
    String[] pk_cardsAry = (String[])CollectionUtils.convertToArray(list, new String[0]);
    if (ArrayUtils.isNotEmpty(pk_cardsAry)) {
      if (context != null) {
        LockManager.releasePKLocks(pk_cardsAry, context.getPk_loginUser());
      } else {
        LockManager.releasePKLocks(pk_cardsAry, InvocationInfoProxy.getInstance().getUserId());
      }
    }
  }
  
  private String dealWithUseDept(AssetCombinVO vo) throws BusinessException {
		AssetCombinBodyVO[] bodyVOs = (AssetCombinBodyVO[]) vo.getChildrenVO();
		if (ArrayUtils.isNotEmpty(bodyVOs)) {
			String[] pk_cards = new String[bodyVOs.length];
			// 遍历取得表体卡片
			for (int i = 0; i < bodyVOs.length; i++) {
				pk_cards[i] = bodyVOs[i].getPk_card();
			}
			// 批量去的多使用部门信息
			Map<String, List<DeptScaleVO>> card2Usedept = AMProxy.lookup(IAssetService.class).queryUseDeptBatch(pk_cards);
			// 遍历表体设置多使用部门link_key
			for (int i = 0; i < bodyVOs.length; i++) {
				String pk_card = bodyVOs[i].getPk_card();
				// 取得表体行对应的多使用部门信息
				List<DeptScaleVO> deptScaleVOs = card2Usedept.get(pk_card);
				if (deptScaleVOs != null && deptScaleVOs.size() > 0) {
					// 卡片的多个使用部门link_key 是一样的
					String link_key = deptScaleVOs.get(0).getLink_key();
					bodyVOs[i].setUsedept(link_key);
				}
			}
			// 调整效率问题注掉   V6.3  zhumyc
			/*  DeptScaleVO[] deptScaleVOs = AMProxy.lookup(IAssetService.class).queryUseDept(bodyVO.getPk_card());
              if (ArrayUtils.isNotEmpty(deptScaleVOs)) {
                  for (DeptScaleVO dept : deptScaleVOs) {
                      dept.setLink_key(null);
                      dept.setPk_deptscale(null);
                  }
                  bodyVO.setUsedept(null);
                  DeptScaleVO[] depts = UseDeptScaleUtils.insert(deptScaleVOs);
                  bodyVO.setUsedept(depts[0].getLink_key());
              }
          }*/
		}

		AssetCombinHeadVO headVO = (AssetCombinHeadVO) vo.getParentVO();
		Map<String, DeptScaleVO[]> useDeptMap = new HashMap<String, DeptScaleVO[]>();
		if (ArrayUtils.isNotEmpty(headVO.getDeptscaleVOs())) {
			for (DeptScaleVO dept : headVO.getDeptscaleVOs()) {
				dept.setLink_key(null);
				dept.setPk_deptscale(null);
			}
			// 取表头增减方式的主键作为多使用部门的link key
			useDeptMap.put(headVO.getPk_addreducestyle(), headVO.getDeptscaleVOs());
			Map<String, String> linkMap = UseDeptScaleUtils.insertBatch(useDeptMap);
			return linkMap.get(headVO.getPk_addreducestyle());
		}

		return null;
	}

  
  public TransportBillVO update(LoginContext context, AssetCombinVO vo)
    throws BusinessException
  {
    LockManager.lock(new BaseLockData(vo));
    SuperVO[] bodyVOs = vo.getChildrenVO();
    
    String link_key = dealWithUseDept(vo);
    
    ((AssetCombinHeadVO)vo.getParent()).setUsedept(link_key);
    
    ((AssetCombinHeadVO)vo.getParent()).setPk_accbook(null);
    
    AssetCombinVO result = ((AssetCombinVO[])updateBillVO(new AssetCombinVO[] { vo }, null))[0];
    if (result == null) {
      return null;
    }
    validateBill(result);
    
    releasePKCardLock(vo, context);
    if (ArrayUtils.isNotEmpty(bodyVOs)) {
      try
      {
        bodyVOs = setBodyMultiDeptscaleVOs(bodyVOs);
      }
      catch (BusinessException e)
      {
        throw new MetaDataException(e.getMessage());
      }
    }
    TransportBillVO pkBillVO = BillTransportTool.createTransportBill(result, new String[0], new String[] { "usedept" }, 2);
    
    return pkBillVO;
  }
  
  protected void validateBill(AssetCombinVO result)
    throws BusinessException
  {
    ((ICloseBookService)AMProxy.lookup(ICloseBookService.class)).checkMinUnCloseBookPeriod(result);
  }
  
  public AssetCombinVO commit(LoginContext context, AssetCombinVO[] billVOs)
    throws BusinessException
  {
    AssetCombinVO[] returnVOs = (AssetCombinVO[])commitBillVO(billVOs);
    AssetCombinVO billVO = ArrayUtils.isEmpty(returnVOs) == true ? null : returnVOs[0];
    
    return billVO;
  }
  
  public AssetCombinVO unSave(AssetCombinVO[] billVOs)
    throws BusinessException
  {
    AssetCombinVO[] returnVOs = (AssetCombinVO[])unSaveBillVOs(billVOs);
    AssetCombinVO billVO = ArrayUtils.isEmpty(returnVOs) == true ? null : returnVOs[0];
    
    return billVO;
  }
  
  protected void initApproveRule(ApproveActionTemplate<AssetCombinVO> template)
  {
    List<Validator> validators = new ArrayList();
    
    validators.add(new CheckHasFipMakeVoucherForAccbooks());

    template.addApprovedBeforeRule(new IRule[] { new VOSagasStatusCheckBeforeRule()});
    template.addApprovedBeforeRule(new IRule[] { new ValidateServiceRule(validators) });
    
    List<IRule<AssetCombinVO>> approvePassAfterRules = new ArrayList();
    
    approvePassAfterRules.add(new CreateBillLogAfterRule(LogTypeConst.combin.intValue()));
    
    approvePassAfterRules.add(new UpdateCardLogAfterRule(true));
    
    approvePassAfterRules.add(new CombineAssetInMultiAccbookRule());
    
    approvePassAfterRules.add(new ReduceCombinedAssetRule());
    
    approvePassAfterRules.add(new AddNewAssetRule());
    
    approvePassAfterRules.add(new UpdateRelatedEquipInfoForApprovingRule());
    
    approvePassAfterRules.add(new AfterAssetCombinedApprove());
    //资产合并单 ： 审批后同步--->碧优资  2021年12月27日  ccy
//    approvePassAfterRules.add(new AfterAssetCombinedApprove());
    template.addApprovePassAfterRule(approvePassAfterRules);
  }
  
  protected void initUnApproveRule(UnApproveActionTemplate<AssetCombinVO> template)
  {
    List<Validator> validators = new ArrayList();
    
    validators.add(new CheckCardLegalValidator(true, true));
    
    validators.add(new CheckMinUnClosedBookPeriodValidator());
    
    validators.add(new CheckHasFipMakeVoucherForAccbooks());
    
    List<IRule<AssetCombinVO>> unApprovBeforeRules = new ArrayList();
    
    unApprovBeforeRules.add(new VOSagasStatusCheckBeforeRule());
    
    unApprovBeforeRules.add(new ValidateServiceRule(validators));
    
    template.addUnApprovedBeforeRules(unApprovBeforeRules);
    
    List<IRule<AssetCombinVO>> lastUnApprovedAfterRules = new ArrayList();
    
    lastUnApprovedAfterRules.add(new DeleteBillLogAfterRule());
    
    lastUnApprovedAfterRules.add(new CancelAssetReduceRule());
    
    lastUnApprovedAfterRules.add(new DeleteNewAssetRule());
    
    lastUnApprovedAfterRules.add(new UpdateCardLogAfterRule(false));
    
    lastUnApprovedAfterRules.add(new UpdateRelatedEquipsInfoForUnapproving());
    
    lastUnApprovedAfterRules.add(new ClearHeadAssetCardInfoRule());
    
    template.addLastUnApprovedAfterRules(lastUnApprovedAfterRules);
  }
  
  protected void initUnSaveActionRules(IActionTemplate<AssetCombinVO> template)
  {
    super.initUnSaveActionRules(template);
    
    template.addBeforeRule(new VOSagasStatusCheckBeforeRule());
  }
  
  private AssetCombinVO reQueryBillByPK(String... pks)
  {
    AssetCombinVO[] aggVO = (AssetCombinVO[])QueryUtil.queryBillVOByPks(AssetCombinVO.class, pks, true);
    if ((aggVO != null) && (aggVO.length != 0)) {
      return aggVO[0];
    }
    return null;
  }
  
  protected void initInsertActionRules(IActionTemplate<AssetCombinVO> insertAction)
  {
    super.initInsertActionRules(insertAction);
    
    List<Validator> validators = new ArrayList();
    
    validators.add(new CheckCardLegalValidator(false, false));
    
    validators.add(new CheckMinUnClosedBookPeriodValidator());
    
    validators.add(new CheckHeadDepStartDateValidator());
    
    validators.add(new CheckInTheSameAccbookValidator());
    
    validators.add(new CheckCreatedCardMinUnClosedBookPeriodValidator());
    
    validators.add(new CheckHeadAssetCategoryLegalValidator());
    
    validators.add(new CheckWorkloanInfosValidator());
    
    validators.add(new CheckHasFipMakeVoucherForAccbooks());
    insertAction.addBeforeRule(new ValidateServiceRule(validators));
    
    insertAction.addBeforeRule(new PKAccbookBeforeRule());
    
    insertAction.addBeforeRule(new BillCodeInsertBeforeRule());
    
    insertAction.addAfterRule(new BillCodeInsertAfterRule());
    
    insertAction.addAfterRule(new UpdateCardLogAfterRule(false));
  }
  
  protected void initUpdateActionRules(IActionTemplate<AssetCombinVO> updateAction)
  {
    super.initUpdateActionRules(updateAction);
    
    List<Validator> validators = new ArrayList();
    
    validators.add(new CheckCardLegalValidator(false, false));
    
    validators.add(new CheckMinUnClosedBookPeriodValidator());
    
    validators.add(new CheckHeadDepStartDateValidator());
    
    validators.add(new CheckCreatedCardMinUnClosedBookPeriodValidator());
    
    validators.add(new CheckHeadAssetCategoryLegalValidator());
    
    validators.add(new CheckInTheSameAccbookValidator());
    
    validators.add(new CheckWorkloanInfosValidator());
    updateAction.addBeforeRule(new ValidateServiceRule(validators));
    
    updateAction.addBeforeRule(new BillCodeUpdateRule());
    
    updateAction.addAfterRule(new UpdateCardLogAfterRule(false, false, true));
  }
  
  protected void initDeleteActionRules(IActionTemplate<AssetCombinVO> deleteAction)
  {
    super.initDeleteActionRules(deleteAction);
    
    deleteAction.addBeforeRule(new VOSagasStatusCheckBeforeRule());
    
    deleteAction.addAfterRule(new BillCodeDeleteRule());
    
    deleteAction.addAfterRule(new UpdateCardLogAfterRule(false, true));
  }
  
  public List<AssetCombinHeadVO> setHeadMultiDeptscaleVO(List<AssetCombinHeadVO> headVOs)
    throws BusinessException
  {
    List<AssetCombinHeadVO> VOs = new ArrayList();
    Object[] usedeptPks = VOManager.getAttributeValueArray((CircularlyAccessibleValueObject[])headVOs.toArray(new AssetCombinHeadVO[0]), "usedept");
    
    Map<String, List<DeptScaleVO>> deptListMap = null;
    if (ArrayUtils.isNotEmpty(usedeptPks)) {
      deptListMap = UseDeptScaleUtils.queryDeptScaleBatch((String[])usedeptPks);
    }
    if (MapUtils.isNotEmpty(deptListMap)) {
      for (AssetCombinHeadVO headVO : headVOs)
      {
        DeptScaleVO[] deptVOs = (DeptScaleVO[])CollectionUtils.toArray((Collection)deptListMap.get(headVO.getUsedept()));
        
        String pk_dept_key = FAUseDeptKeyGenerator.generatorKeyForAssetSplit(deptVOs);
        
        headVO.setDeptscaleVOs(deptVOs);
        headVO.setAttributeValue("usedept", DeptScaleManager.getShowName(deptVOs));
        headVO.setAttributeValue("pk_dept_key", pk_dept_key);
        VOs.add(headVO);
      }
    }
    return VOs;
  }
  
  public SuperVO[] setBodyMultiDeptscaleVOs(SuperVO[] superVOs)
    throws BusinessException
  {
    AssetCombinBodyVO[] bodyVOs = (AssetCombinBodyVO[])superVOs;
    
    String[] usedeptPks = (String[])VOManager.getAttributeValueArray(bodyVOs, "usedept");
    
    Map<String, List<DeptScaleVO>> deptListMap = null;
    if (ArrayUtils.isNotEmpty(usedeptPks)) {
      deptListMap = UseDeptScaleUtils.queryDeptScaleBatch(usedeptPks);
    }
    if (MapUtils.isNotEmpty(deptListMap)) {
      for (AssetCombinBodyVO bodyVO : bodyVOs)
      {
        DeptScaleVO[] deptVOs = (DeptScaleVO[])CollectionUtils.toArray((Collection)deptListMap.get(bodyVO.getUsedept()));
        
        String bodyPk_dept_key = FAUseDeptKeyGenerator.generatorKeyForAssetSplit(deptVOs);
        
        bodyVO.setDeptscaleVOs(deptVOs);
        bodyVO.setAttributeValue("usedept", DeptScaleManager.getShowName(deptVOs));
        bodyVO.setAttributeValue("bodypk_dept_key", bodyPk_dept_key);
      }
    }
    return superVOs;
  }
  
  public List<String> queryCategoryInnercodeBySql(String sql, String pk_org, List<String> setOfBook)
    throws BusinessException
  {
    DBAccessUtil dbUtil = new DBAccessUtil();
    List<String> pk_categorys = dbUtil.querySingleColumn(sql.toString());
    Map<String, List<String>> cate2setOfBook;
    if (setOfBook.size() > 1)
    {
      cate2setOfBook = ((IAccbookInfoService)AMProxy.lookup(IAccbookInfoService.class)).querySetAccbookByCategorys(pk_org, pk_categorys);
      for (String pk_category : cate2setOfBook.keySet()) {
        if ((null != cate2setOfBook.get(pk_category)) && (!((List)cate2setOfBook.get(pk_category)).containsAll(setOfBook))) {
          pk_categorys.remove(pk_category);
        }
      }
    }
    String querySQL = "select innercode from fa_category where pk_category in " + InSqlManager.getInSQLValue(pk_categorys);
    Object innercodes = dbUtil.querySingleColumn(querySQL);
    return (List<String>)innercodes;
  }
  
  public UFDate isMinUnCloseMonth(String pk_org, String pk_card, UFDate busi_date)
    throws BusinessException
  {
    CloseBookImpl closebookService = new CloseBookImpl();
    
    Map<String, List<String>> pk_card2pk_accbook = new AssetServiceImpl().queryCardAssociateAccbooks(new String[] { pk_card });
    
    String[] pk_accbooks = (String[])((List)pk_card2pk_accbook.get(pk_card)).toArray(new String[0]);
    
    Map<String, UFBoolean> pk_accbook2isMinCloseMonth = closebookService.queryIsMinUnClosePeriod(pk_org, busi_date.toString(), pk_accbooks);
    if (pk_accbook2isMinCloseMonth.values().contains(UFBoolean.valueOf(false)))
    {
      AccperiodVO minUnCloseBookPeriod = closebookService.queryMinUnClosebookPeriod(pk_org, pk_accbooks[0]);
      
      UFDate endDate = minUnCloseBookPeriod.getEnddate();
      return endDate;
    }
    return busi_date;
  }
  
  public Object[] queryObjectByPks(String[] pks)
    throws BusinessException
  {
    Object[] billVOs = ((IDataService)AMProxy.lookup(IDataService.class)).queryObjectByPks(AssetCombinVO.class, pks, "bodyvos");
    
    AssetCombinVO[] assetCombinVOs = (AssetCombinVO[])billVOs;
    List<AssetCombinHeadVO> headVOS = new ArrayList();
    List<AssetCombinHeadVO> vos = new ArrayList();
    for (AssetCombinVO assetCombinVO : assetCombinVOs)
    {
      AssetCombinHeadVO headVO = (AssetCombinHeadVO)assetCombinVO.getParentVO();
      headVOS.add(headVO);
      
      SuperVO[] bodyVOs = assetCombinVO.getChildrenVO();
      if (ArrayUtils.isNotEmpty(bodyVOs)) {
        try
        {
          bodyVOs = setBodyMultiDeptscaleVOs(bodyVOs);
        }
        catch (BusinessException e)
        {
          throw new MetaDataException(e.getMessage());
        }
      }
      assetCombinVO.setChildren(AssetCombinBodyVO.class, bodyVOs);
    }
    try
    {
      vos = setHeadMultiDeptscaleVO(headVOS);
    }
    catch (BusinessException e)
    {
      throw new MetaDataException(e.getMessage());
    }
    for (int i = 0; i < assetCombinVOs.length; i++) {
      assetCombinVOs[i].setParentVO((CircularlyAccessibleValueObject)vos.get(i));
    }
    return billVOs;
  }
  
  public AssetCombinHeadVO setHeadMultiDeptscaleVOs(AssetCombinHeadVO headVO)
    throws BusinessException
  {
    String usedeptPk = headVO.getUsedept();
    
    Map<String, List<DeptScaleVO>> deptListMap = null;
    if (StringUtils.isNotEmpty(usedeptPk)) {
      deptListMap = UseDeptScaleUtils.queryDeptScaleBatch(new String[] { usedeptPk });
    }
    if (MapUtils.isNotEmpty(deptListMap))
    {
      DeptScaleVO[] deptVOs = (DeptScaleVO[])CollectionUtils.toArray((Collection)deptListMap.get(headVO.getUsedept()));
      
      String pk_dept_key = FAUseDeptKeyGenerator.generatorKeyForAssetSplit(deptVOs);
      
      headVO.setDeptscaleVOs(deptVOs);
      headVO.setAttributeValue("usedept", DeptScaleManager.getShowName(deptVOs));
      headVO.setAttributeValue("pk_dept_key", pk_dept_key);
    }
    return headVO;
  }
  
  public AssetCombinVO[] queryVOByPK(String... pk)
    throws BusinessException
  {
    AssetCombinVO[] aggVO = (AssetCombinVO[])QueryUtil.queryBillVOByPks(AssetCombinVO.class, pk, true);
    return aggVO;
  }
}
