|  | @@ -1,9 +1,13 @@
 | 
											
												
													
														|  |  package bamp.basedata.opplugin;
 |  |  package bamp.basedata.opplugin;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import com.grapecity.documents.excel.Q;
 | 
											
												
													
														|  |  import kd.bos.dataentity.entity.DynamicObject;
 |  |  import kd.bos.dataentity.entity.DynamicObject;
 | 
											
												
													
														|  |  import kd.bos.dataentity.entity.DynamicObjectCollection;
 |  |  import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
											
												
													
														|  |  import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 |  |  import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 | 
											
												
													
														|  |  import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
 |  |  import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.exception.KDBizException;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.orm.query.QCP;
 | 
											
												
													
														|  | 
 |  | +import kd.bos.orm.query.QFilter;
 | 
											
												
													
														|  |  import kd.bos.servicehelper.BusinessDataServiceHelper;
 |  |  import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
											
												
													
														|  |  import kd.bos.servicehelper.operation.SaveServiceHelper;
 |  |  import kd.bos.servicehelper.operation.SaveServiceHelper;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -16,31 +20,57 @@ public class SupplierBankChangeOpPlugin  extends AbstractOperationServicePlugIn
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public void endOperationTransaction(EndOperationTransactionArgs e) {
 |  |      public void endOperationTransaction(EndOperationTransactionArgs e) {
 | 
											
												
													
														|  |          super.endOperationTransaction(e);
 |  |          super.endOperationTransaction(e);
 | 
											
												
													
														|  | 
 |  | +        String operationKey = e.getOperationKey();
 | 
											
												
													
														|  | 
 |  | +        if("save".equals(operationKey) || "submit".equals(operationKey)){
 | 
											
												
													
														|  | 
 |  | +            checkData(e);
 | 
											
												
													
														|  | 
 |  | +        }else if("audit".equals(operationKey)) {
 | 
											
												
													
														|  | 
 |  | +            updateSupplierBankData(e);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private void checkData(EndOperationTransactionArgs e) {
 | 
											
												
													
														|  | 
 |  | +        DynamicObject[] dynamicObjects = e.getDataEntities();
 | 
											
												
													
														|  | 
 |  | +        for (int i = 0; i < dynamicObjects.length; i++) {
 | 
											
												
													
														|  | 
 |  | +            DynamicObject bill = dynamicObjects[i];
 | 
											
												
													
														|  | 
 |  | +            QFilter qFilter_id = new QFilter("id", QCP.not_equals,bill.getPkValue());
 | 
											
												
													
														|  | 
 |  | +            QFilter qFilter_status = new QFilter("status", QCP.not_equals,"C");
 | 
											
												
													
														|  | 
 |  | +            DynamicObject supplier = bill.getDynamicObject("nckd_supplierfield");
 | 
											
												
													
														|  | 
 |  | +            QFilter qFilter_supplier = new QFilter("nckd_supplierfield",QCP.not_equals,supplier.getPkValue());
 | 
											
												
													
														|  | 
 |  | +            DynamicObject[] oldBills = BusinessDataServiceHelper.load("nckd_supplierbankchange","id,billno",
 | 
											
												
													
														|  | 
 |  | +                    new QFilter[]{qFilter_id,qFilter_status,qFilter_supplier});
 | 
											
												
													
														|  | 
 |  | +            if(oldBills.length>0){
 | 
											
												
													
														|  | 
 |  | +                DynamicObject oldBill = oldBills[0];
 | 
											
												
													
														|  | 
 |  | +                throw new KDBizException("供应商银行信息已存在编码为["+oldBill.getString("billno")+"]的未审核变更记录");
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    private void updateSupplierBankData(EndOperationTransactionArgs e) {
 | 
											
												
													
														|  |          DynamicObject[] dynamicObjects = e.getDataEntities();
 |  |          DynamicObject[] dynamicObjects = e.getDataEntities();
 | 
											
												
													
														|  |          for (int i = 0; i < dynamicObjects.length; i++) {
 |  |          for (int i = 0; i < dynamicObjects.length; i++) {
 | 
											
												
													
														|  |              DynamicObject bill = dynamicObjects[i];
 |  |              DynamicObject bill = dynamicObjects[i];
 | 
											
												
													
														|  |              DynamicObject supplier = BusinessDataServiceHelper.loadSingle(
 |  |              DynamicObject supplier = BusinessDataServiceHelper.loadSingle(
 | 
											
												
													
														|  | -                    bill.getDynamicObject("nckd_supplierfield").getLong("id"),"bd_supplier");
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    bill.getDynamicObject("nckd_supplierfield").getLong("id"), "bd_supplier");
 | 
											
												
													
														|  |              DynamicObjectCollection supplierBankCol = supplier.getDynamicObjectCollection("entry_bank");
 |  |              DynamicObjectCollection supplierBankCol = supplier.getDynamicObjectCollection("entry_bank");
 | 
											
												
													
														|  |              supplierBankCol.clear();
 |  |              supplierBankCol.clear();
 | 
											
												
													
														|  |              DynamicObjectCollection entryCol = bill.getDynamicObjectCollection("nckd_entry_bank");
 |  |              DynamicObjectCollection entryCol = bill.getDynamicObjectCollection("nckd_entry_bank");
 | 
											
												
													
														|  | -            for(DynamicObject entry : entryCol){
 |  | 
 | 
											
												
													
														|  | 
 |  | +            for (DynamicObject entry : entryCol) {
 | 
											
												
													
														|  |                  DynamicObject supplierEntryInfo = supplierBankCol.addNew();
 |  |                  DynamicObject supplierEntryInfo = supplierBankCol.addNew();
 | 
											
												
													
														|  | -                supplierEntryInfo.set("bankaccount",entry.get("nckd_bankaccount"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("accountname",entry.get("nckd_accountname"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("iban",entry.get("nckd_iban"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("bank",entry.get("nckd_bank"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("currency",entry.get("nckd_currency"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("payeeadmindivision",entry.get("nckd_payeeadmindivision"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("payeeaddress",entry.get("nckd_payeeaddress"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("payeephone",entry.get("nckd_payeephone"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("isdefault_bank",entry.get("nckd_isdefault_bank"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("bankaccounttype",entry.get("nckd_bankaccounttype"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("settlment",entry.get("nckd_settlment"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("commissionbearer",entry.get("nckd_commissionbearer"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("liquidationparam",entry.get("nckd_liquidationparam"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("agentbankaccount",entry.get("nckd_agentbankaccount"));
 |  | 
 | 
											
												
													
														|  | -                supplierEntryInfo.set("agentbank",entry.get("nckd_agentbank"));
 |  | 
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("bankaccount", entry.get("nckd_bankaccount"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("accountname", entry.get("nckd_accountname"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("iban", entry.get("nckd_iban"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("bank", entry.get("nckd_bank"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("currency", entry.get("nckd_currency"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("payeeadmindivision", entry.get("nckd_payeeadmindivision"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("payeeaddress", entry.get("nckd_payeeaddress"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("payeephone", entry.get("nckd_payeephone"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("isdefault_bank", entry.get("nckd_isdefault_bank"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("bankaccounttype", entry.get("nckd_bankaccounttype"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("settlment", entry.get("nckd_settlment"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("commissionbearer", entry.get("nckd_commissionbearer"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("liquidationparam", entry.get("nckd_liquidationparam"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("agentbankaccount", entry.get("nckd_agentbankaccount"));
 | 
											
												
													
														|  | 
 |  | +                supplierEntryInfo.set("agentbank", entry.get("nckd_agentbank"));
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              SaveServiceHelper.save(new DynamicObject[]{supplier});
 |  |              SaveServiceHelper.save(new DynamicObject[]{supplier});
 | 
											
												
													
														|  |          }
 |  |          }
 |