EAS Botp下推(不展示选择界面)

 


    /**
     * 下推按钮
     */

public void actionUpTrace_actionPerformed(ActionEvent e) throws Exception {
        ArrayList idList = new ArrayList();
        List entriesKey = new ArrayList();


        ArrayList blocks = this.tblMain.getSelectManager().getBlocks();
        Iterator iter = blocks.iterator();
        while(iter.hasNext()){
            KDTSelectBlock block = (KDTSelectBlock)iter.next();
            int top = block.getTop();
            int bottom = block.getBottom();
            for (int rowIndex = top; rowIndex <= bottom; ++rowIndex){
                ICell cell = this.tblMain.getRow(rowIndex).getCell(getKeyFieldName());
                if ((this.tblMain.getRow(rowIndex).getCell(getEntriesPKName()) != null) && (this.tblMain.getRow(rowIndex).getCell(getEntriesPKName()).getValue() != null)){
                    //获取分录id
                    entriesKey.add(this.tblMain.getRow(rowIndex).getCell(getEntriesPKName()).getValue().toString());
                }
                
                if (!(idList.contains(cell.getValue())))
                    idList.add(cell.getValue());//获取单据id
                String[] idArray = new String[idList.size()];
                idList.toArray(idArray);
                PurOrderFactory.getRemoteInstance().createToSale(idList.get(0).toString(), entriesKey.get(0).toString());
            }
        }
        super.actionUpTrace_actionPerformed(e);
    }   


@Override
    public void _createToSale(Context ctx, String idList, String entries) throws BOSException, EASBizException {
    	//查询出来源表的值
    	PurOrderCollection purOrderCollection = PurOrderFactory.getLocalInstance(ctx).getPurOrderCollection(BaseUtil.OqlToAll(idList));
    	PurOrderInfo purOrderInfo = purOrderCollection.get(0);
    	PurOrderEntryCollection purOrderEntryColl = purOrderInfo.getEntrys();
    	PurOrderEntryInfo purOrderEntryInfo = purOrderEntryColl.get(0);
    	CoreBillBaseInfo infos = purOrderCollection.get(0);
    	infos.getNumber();//是否拿到数据
    	try {
			BOTPUtil.createToSubmitBill(ctx, infos, "CG00002");//拿到数据后根据编号为CG00002BOTP的编码规则下推
		} catch (Exception e) {
			e.printStackTrace();
		}
 
    }
/**
	 * 生成下游单据
	 * @param ctx
	 * @param srcbillInfo
	 * @param tarbillBase
	 * @param botpNumber
	 * @return
	 * @throws EASBizException
	 * @throws BOSException
	 * @throws Exception
	 */
	public static void createToSubmitBill(Context ctx, CoreBillBaseInfo srcbillInfo, String botpNumber) throws EASBizException, BOSException, Exception{
		BTPTransformResult res = getBotpBills(ctx, srcbillInfo, botpNumber);
		BOTRelationCollection relations = res.getBOTRelationCollection();
 		IObjectCollection bills = res.getBills();
 		for (int i = 0; i < bills.size(); i++) {
 			CoreBillBaseInfo corebaseInfo =  (CoreBillBaseInfo) bills.getObject(i);
 			IObjectPK pk = BTPManagerFactory.getLocalInstance(ctx).submitRelations(corebaseInfo, relations);
 			//可能会存在提交即审核 需要判断
// 			if(!checkBillIsAudit(corebaseInfo)){
// 				tarbillBase.getClass().getMethod("audit", IObjectPK.class).invoke(tarbillBase, pk);
// 			}
 		}
	}

public static BTPTransformResult getBotpBills(Context ctx, CoreBillBaseInfo srcbillInfo, String botpNumber) throws Exception{
         BOTMappingCollection bmc = BOTMappingFactory.getLocalInstance(ctx).getBOTMappingCollection("select *, extRule.* where name='"+ botpNumber +"' ");
CoreBillBaseCollection coreBillColl = new CoreBillBaseCollection();
         coreBillColl.add(srcbillInfo);
         BOTAppTools.execDataFilterMultiEntry(ctx, coreBillColl, botMappingInfo);
         return BTPManagerFactory.getLocalInstance(ctx).transform(coreBillColl, botMappingInfo);

}




你可能感兴趣的:(金蝶EAS)