入库单下推无合同付款申请单botp插件
This commit is contained in:
		
							parent
							
								
									db0509d311
								
							
						
					
					
						commit
						4f2bba4991
					
				| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
package zcgj.zcdev.zcdev.fs.plugin.other;
 | 
			
		||||
 | 
			
		||||
import kd.bos.coderule.api.CodeRuleInfo;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
			
		||||
import kd.bos.entity.ExtendedDataEntity;
 | 
			
		||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
 | 
			
		||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
 | 
			
		||||
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
 | 
			
		||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单下推无合同付款申请单botp插件
 | 
			
		||||
 */
 | 
			
		||||
public class MaterialinbillToNoContractBotpPlugin extends AbstractConvertPlugIn {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void afterConvert(AfterConvertEventArgs e) {
 | 
			
		||||
        super.afterConvert(e);
 | 
			
		||||
        // 获取已生成的资产卡片
 | 
			
		||||
        ExtendedDataEntity[] billDataEntitys = e.getTargetExtDataEntitySet().FindByEntityKey("er_publicreimbursebill");
 | 
			
		||||
 | 
			
		||||
        // 构造 ExtendedDataEntity 时需要的索引值
 | 
			
		||||
        int dataIndex = billDataEntitys.length;
 | 
			
		||||
        List<ExtendedDataEntity> copyDataEntitys = new ArrayList<>();
 | 
			
		||||
        for(ExtendedDataEntity billDataEntity : billDataEntitys){
 | 
			
		||||
            System.out.println();
 | 
			
		||||
            DynamicObject dataEntity = billDataEntity.getDataEntity();
 | 
			
		||||
 | 
			
		||||
            CodeRuleInfo codeRule = CodeRuleServiceHelper.getCodeRule(dataEntity.getDataEntityType().getName(), dataEntity, null);
 | 
			
		||||
            String billno = CodeRuleServiceHelper.getNumber(codeRule, dataEntity);
 | 
			
		||||
            dataEntity.set("billno", billno);
 | 
			
		||||
            SaveServiceHelper.save(new DynamicObject[]{dataEntity});
 | 
			
		||||
            Map<String,Long> invoiceEntryMap = new HashMap<String, Long>();//发票信息分录
 | 
			
		||||
            Map<String,Long> expensEntryMap = new HashMap<String, Long>();//费用明细分录
 | 
			
		||||
            DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
 | 
			
		||||
            for (DynamicObject invoice : invoiceentry) {
 | 
			
		||||
                String invoiceno = invoice.getString("invoiceno");
 | 
			
		||||
                long aLong = invoice.getLong("id");
 | 
			
		||||
                invoiceEntryMap.put(invoiceno, aLong);
 | 
			
		||||
            }
 | 
			
		||||
            DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");
 | 
			
		||||
            for (DynamicObject expenseentry : expenseentryentity) {
 | 
			
		||||
                String invoiceno = expenseentry.getString("invoiceno_entry");
 | 
			
		||||
                long aLong = expenseentry.getLong("id");
 | 
			
		||||
                expensEntryMap.put(invoiceno, aLong);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //发票明细分录
 | 
			
		||||
            DynamicObjectCollection invoiceitementry = dataEntity.getDynamicObjectCollection("invoiceitementry");
 | 
			
		||||
            for (String invoiceno : expensEntryMap.keySet()) {
 | 
			
		||||
                Long itemid = expensEntryMap.get(invoiceno);//费用明细分录id
 | 
			
		||||
                Long invoiceId = invoiceEntryMap.get(invoiceno);//发票信息分录id
 | 
			
		||||
                DynamicObject dynamicObject = invoiceitementry.addNew();//发票明细,费用明细和发票信息关联关系
 | 
			
		||||
                dynamicObject.set("itementryid", itemid);
 | 
			
		||||
                dynamicObject.set("invoiceheadentryid", invoiceId);
 | 
			
		||||
            }
 | 
			
		||||
            SaveServiceHelper.save(new DynamicObject[]{dataEntity});
 | 
			
		||||
 | 
			
		||||
            //dataEntity.getDynamicObjectCollection("invoiceentry").get(0).getLong("id");
 | 
			
		||||
            //dataEntity.getDynamicObjectCollection("expenseentryentity").get(0).getLong("id"); //invoiceno_entry
 | 
			
		||||
            System.out.println();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue