/** * 将采购计划插入采购需求的处理方法 * * @param key 采购计划的主表主键 * @param keyPlanItemList 要插入需求填报的子表数据 * @return 添加的采购需求的主表主键 * @throws BusinessException * @author liweiqiang 2009-11-16 */ public String savePlanInfo(String key, String[] keyPlanItemList) throws BusinessException { // 计划填报aggVO AggPlanVO aggPlanVO; // 计划填报主表VO PlanVO planVO; // 计划填报子表VO PlanItemProdVO planItemProdVO; // 计划填报子表VO数组 CircularlyAccessibleValueObject[] planApplyItemList = null; // 需求填报AggVO AggReqVO aggReqVO = new AggReqVO(); // 需求填报主表VO ReqMainVO reqMainVO; // 需求填报子表VO ReqItemProdVO reqItemProdVO; // 需求填报的NCObject NCObject objReq; // 返回新生成的需求填报的主表主键ID String result = null; // 存入选择的插入的计填报子表 ArrayList<PlanItemProdVO> planItemList = new ArrayList<PlanItemProdVO>(); // 查询key多对应的需求填报对应的NCObject NCObject objPlan = MDPersistenceService.lookupPersistenceQueryService() .queryBillOfNCObjectByPK(AggPlanVO.class, key); if (objPlan != null) { // 计划填报aggVO aggPlanVO = (AggPlanVO) objPlan.getContainmentObject(); if (aggPlanVO != null) { // 取得计划填报主表VO planVO = (PlanVO) aggPlanVO.getParentVO(); // 取得需求填报主表VO reqMainVO = setReqMainVO(planVO); // 将需求填报主表VO放入aggVO aggReqVO.setParentVO(reqMainVO); // 从addVO取出计划填报子表VO数组 planApplyItemList = aggPlanVO.getChildrenVO(); if (planApplyItemList != null) { ArrayList<ReqItemProdVO> reqItemList = new ArrayList<ReqItemProdVO>(); for (int i = 0; i < planApplyItemList.length; i++) { // 取得计划填报子表VO planItemProdVO = (PlanItemProdVO) planApplyItemList[i]; if (planItemProdVO != null) { // int dr = planItemProdVO.getDr(); // int refStatus = planItemProdVO.getRef_status(); if (planItemProdVO.getDr() == null || planItemProdVO.getDr() == 0) { if (planItemProdVO.getRef_status() == null || planItemProdVO.getRef_status() == 1) { // 需求填报子表VO if (keyPlanItemList != null && keyPlanItemList.length > 0) { if (isInsert(keyPlanItemList, planItemProdVO.getPk_jh_plan_item_prod())) { reqItemProdVO = setReqItemProdVO(planVO, planItemProdVO, keyPlanItemList); // 将选中的需求受理子表VO放入list reqItemList.add(reqItemProdVO); // 将选中的计划填报子表VO放入list planItemList.add(planItemProdVO); } } else { reqItemProdVO = setReqItemProdVO(planVO, planItemProdVO, keyPlanItemList); // 将选中的需求受理子表VO放入list reqItemList.add(reqItemProdVO); // 将选中的计划填报子表VO放入list planItemList.add(planItemProdVO); } } } } } // 存放需求填报的子表VO数组 CircularlyAccessibleValueObject[] reqApplyItemList = (CircularlyAccessibleValueObject[]) reqItemList.toArray(new ReqItemProdVO[0]); // 将需求填报的子表VO数组放入aggVO中 aggReqVO.setChildrenVO(reqApplyItemList); } // 生成需求填报的NCObject objReq = Ds2NCObjectUtil.wrapVOToNCObject(aggReqVO); // 调用write方法,取得返回的需求填报的NCObject objReq = super.write(objReq, null); // 取得返回的后需求填报的aggVO aggReqVO = (AggReqVO) objReq.getContainmentObject(); // 复制计划填报的附件到采购需求 setDaAtt(aggReqVO); // 复制计划填报的供应商到采购需求 setSupplier(aggReqVO); // 反写采购计划子表的引用状态 updatePlanItem(planItemList); // 反写采购计划主表表的引用状态 updatePlanVO(key); // 取得返回后的需求填报的主表 reqMainVO = (ReqMainVO) aggReqVO.getParentVO(); // 取得新生成需求填报的主表主键,返回 result = reqMainVO.getPk_xq_req_main(); } } return result; }
private IMDPersistenceQueryService getQueryService() { return MDPersistenceService.lookupPersistenceQueryService(); }