| 
					
				 | 
			
			
				@@ -0,0 +1,474 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package nckd.jimin.jyyy.fi.plugin.form; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.kingdee.util.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.algo.DataSet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.bill.BillShowParameter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.bill.OperationStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.context.RequestContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.dataentity.OperateOption; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.dataentity.entity.DynamicObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.dataentity.entity.DynamicObjectCollection; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.dataentity.metadata.IDataEntityProperty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.dataentity.resource.ResManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.entity.datamodel.events.PropertyChangedArgs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.entity.operate.result.OperationResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.ext.fi.ai.DapBuildVoucherCommonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.CloseCallBack; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.FormShowParameter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.ShowType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.control.EntryGrid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.control.Toolbar; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.control.events.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.events.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.operate.FormOperate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.plugin.AbstractFormPlugin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.list.ListShowParameter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.orm.query.QCP; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.orm.query.QFilter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.servicehelper.BusinessDataServiceHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.servicehelper.QueryServiceHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.servicehelper.operation.OperationServiceHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.servicehelper.operation.SaveServiceHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.servicehelper.permission.PermissionServiceHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.constant.ErPrintUserConstant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.constant.ErReimBurseBillConstant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.constant.HandInReceiveTicketConstant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.entity.MergePrintEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.util.ErFindRelationBillUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import nckd.jimin.jyyy.fi.common.util.ReceiveTicketUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements RowClickEventListener { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final String CLOSECALLBACK_MAIL = "closecallback_mail"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void registerListener(EventObject e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.registerListener(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EntryGrid entryGrid = this.getControl(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        entryGrid.addRowClickListener(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Toolbar toolbar = this.getControl(HandInReceiveTicketConstant.METEDATAFLAG.NCKD_ENTRY_TOOLBARAP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        toolbar.addItemClickListener(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void beforeBindData(EventObject e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.beforeBindData(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 显示当前扫描点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObjectCollection scanTypeCol = getScanType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getModel().setValue(HandInReceiveTicketConstant.KEY_NCKD_SCANTYPE,scanTypeCol.get(0).getString(ErPrintUserConstant.KEY_NCKD_SCANTYPE)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void preOpenForm(PreOpenFormEventArgs e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.preOpenForm(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObjectCollection scanTypeCol = getScanType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(CollectionUtils.isEmpty(scanTypeCol)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.setCancelMessage(ResManager.loadKDString("请先配置用户登记后再操作。","","")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(scanTypeCol.size() > 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.setCancelMessage(ResManager.loadKDString("用户登记存在多条有效数据,请处理后再操作。","","")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void propertyChanged(PropertyChangedArgs e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.propertyChanged(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        IDataEntityProperty property = e.getProperty(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String name = property.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (name){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.KEY_NCKD_SCANNUMBER: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                propertyChangedScanNumber(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void propertyChangedScanNumber(PropertyChangedArgs e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询单据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String scanNumber = (String)this.getModel().getValue(HandInReceiveTicketConstant.KEY_NCKD_SCANNUMBER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(StringUtils.isEmpty(scanNumber)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 判断编码是否存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObjectCollection entryEntity = getModel().getEntryEntity(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Optional<DynamicObject> findNumberOp = entryEntity.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .filter(r -> scanNumber.equals(r.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_NUMBER))).findFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(findNumberOp.isPresent()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String selector = String.join(",",ErReimBurseBillConstant.ID,ErReimBurseBillConstant.KEY_BILLNO,ErReimBurseBillConstant.KEY_COSTCOMPANY, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ErReimBurseBillConstant.KEY_NCKD_HANDIN_PERSON,ErReimBurseBillConstant.KEY_NCKD_RECEIPT_PERSON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询费用报销单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject reimBurseBill = BusinessDataServiceHelper.loadSingle(ErReimBurseBillConstant.ENTITYID,selector, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new QFilter(ErReimBurseBillConstant.KEY_BILLNO, QCP.equals, scanNumber).toArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(reimBurseBill != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addScanBillEntry(reimBurseBill.getString(ErReimBurseBillConstant.KEY_BILLNO),getReceiptStatus(reimBurseBill), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    reimBurseBill.get(ErReimBurseBillConstant.ID), ErReimBurseBillConstant.ENTITYID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    reimBurseBill.getDynamicObject(ErReimBurseBillConstant.KEY_COSTCOMPANY).getPkValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected String getReceiptStatus(DynamicObject billInfo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 未交票 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(billInfo.getDynamicObject(ErReimBurseBillConstant.KEY_NCKD_HANDIN_PERSON) == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return "handin_incomplete"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //未收票 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(billInfo.getDynamicObject(ErReimBurseBillConstant.KEY_NCKD_HANDIN_PERSON) != null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                && billInfo.getDynamicObject(ErReimBurseBillConstant.KEY_NCKD_RECEIPT_PERSON) == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return "receipt_incomplete"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //已收票 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(billInfo.getDynamicObject(ErReimBurseBillConstant.KEY_NCKD_HANDIN_PERSON) != null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                && billInfo.getDynamicObject(ErReimBurseBillConstant.KEY_NCKD_RECEIPT_PERSON) != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return "receipt_complete"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void addScanBillEntry(String number, String status, Object billId, String formId, Object companyId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int newEntryRow = this.getModel().createNewEntryRow(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getModel().setValue(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_NUMBER,number,newEntryRow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getModel().setValue(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_STATUS,status,newEntryRow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getModel().setValue(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID,billId,newEntryRow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getModel().setValue(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID,formId,newEntryRow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getModel().setItemValueByID(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_COMPANY,companyId,newEntryRow); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getView().updateView(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected DynamicObjectCollection getScanType(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        long currUserId = RequestContext.get().getCurrUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询用户登记 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return QueryServiceHelper.query(ErPrintUserConstant.ENTITYID, ErPrintUserConstant.KEY_NCKD_SCANTYPE, new QFilter[]{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new QFilter(ErPrintUserConstant.KEY_NCKD_BOS_USER, QCP.equals, currUserId), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new QFilter(ErPrintUserConstant.KEY_STATUS, QCP.equals, "C"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new QFilter(ErPrintUserConstant.KEY_ENABLE, QCP.equals, Boolean.TRUE), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void beforeItemClick(BeforeItemClickEvent evt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.beforeItemClick(evt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String itemKey = evt.getItemKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (itemKey){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.NCKD_MAIL: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                beforeMail(evt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.NCKD_CANCELMAIN: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                beforeCancleMail(evt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void beforeMail(BeforeItemClickEvent evt){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String checkMsg = checkSelectSingle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!StringUtils.isEmpty(checkMsg)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showTipNotification(checkMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            evt.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject selectRow = getSelectRows().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 快递编号为空 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject billInfo = BusinessDataServiceHelper.loadSingle(selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID), ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!StringUtils.isEmpty(billInfo.getString(ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showTipNotification(ResManager.loadKDString("单据快递单号不为空,请先进行退邮操作。","","")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            evt.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void beforeCancleMail(BeforeItemClickEvent evt){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String checkMsg = checkSelectSingle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!StringUtils.isEmpty(checkMsg)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showTipNotification(checkMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            evt.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 快递编号为空 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject billInfo = getSelectBillInfo(ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(StringUtils.isEmpty(billInfo.getString(ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showTipNotification(ResManager.loadKDString("单据没有进行邮寄操作。","","")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            evt.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void itemClick(ItemClickEvent evt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.itemClick(evt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String itemKey = evt.getItemKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (itemKey){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.NCKD_MAIL: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doMail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.NCKD_CANCELMAIN: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doCancleMail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.NCKD_VIEW_VOUCHER: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doViewVouhcer(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.NCKD_VIEW_ELECRECEIPT: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doViewElecReceipt(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void doViewVouhcer(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject selectRow = getSelectRows().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, Set<Object>> relationBelowBillMap = ErFindRelationBillUtils.getRelationBelowBillMap(selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(relationBelowBillMap.containsKey(BillTypeConstants.GL_VOUCHER)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Set<Object> voucherIdSet = relationBelowBillMap.get(BillTypeConstants.GL_VOUCHER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(CollectionUtils.isNotEmpty(voucherIdSet)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(voucherIdSet.size() == 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Object voucherId = voucherIdSet.iterator().next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BillShowParameter showParameter = new BillShowParameter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.setPkId(voucherId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.setFormId(BillTypeConstants.GL_VOUCHER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    DataSet ds = QueryServiceHelper.queryDataSet("TraceVoucher_queryvoucher", BillTypeConstants.GL_VOUCHER, "org", new QFilter[]{new QFilter("id", "=", voucherId)}, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long orgId = ds.iterator().next().getLong("org"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long userId = Long.parseLong(RequestContext.get().getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    int checkPermission = PermissionServiceHelper.checkPermission(userId, "DIM_ORG", orgId, "83bfebc8000017ac", BillTypeConstants.GL_VOUCHER, "4715a0df000000ac"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Boolean isbizvoucher = DapBuildVoucherCommonUtil.getEnableBizVoucherSystemParam(orgId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (checkPermission != 1 || isbizvoucher) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        showParameter.setStatus(OperationStatus.VIEW); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        showParameter.setStatus(OperationStatus.EDIT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.setHasRight(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.getView().showForm(showParameter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ListShowParameter showParameter = new ListShowParameter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.setBillFormId(BillTypeConstants.GL_VOUCHER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.setShowFilter(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.setShowQuickFilter(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for(Object voucherId : voucherIdSet){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        showParameter.addLinkQueryPkId(voucherId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.getCustomParams().put("org", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    showParameter.getCustomParams().put("booktype", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.getView().showForm(showParameter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.getView().showTipNotification(ResManager.loadKDString("单据没有关联的凭证。", "TraceVoucher_2", "bos-ext-fi", new Object[0])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.getView().showTipNotification(ResManager.loadKDString("单据没有关联的凭证。", "TraceVoucher_2", "bos-ext-fi", new Object[0])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void doViewElecReceipt(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void doMail(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FormShowParameter parameter = new FormShowParameter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        parameter.setFormId(HandInReceiveTicketConstant.ENTITY_NCKD_TICKET_MAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CloseCallBack callBack = new CloseCallBack(this,CLOSECALLBACK_MAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        parameter.setCloseCallBack(callBack); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        parameter.getOpenStyle().setShowType(ShowType.Modal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getView().showForm(parameter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void doCancleMail(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject billInfo = getSelectBillInfo(String.join(",",ErReimBurseBillConstant.KEY_BILLNO,ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        billInfo.set(ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaveServiceHelper.save(new DynamicObject[]{ billInfo }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getView().showSuccessNotification(String.format(ResManager.loadKDString("单据%1$s退邮成功。","",""),billInfo.getString(ErReimBurseBillConstant.KEY_BILLNO))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected DynamicObject getSelectBillInfo(String selector){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject selectRow = getSelectRows().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 快递编号为空 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       return BusinessDataServiceHelper.loadSingle(selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID), selector); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void beforeDoOperation(BeforeDoOperationEventArgs args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.beforeDoOperation(args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FormOperate operate = (FormOperate)args.getSource(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String operateKey = operate.getOperateKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String checkMsg = checkSelectSingle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (operateKey){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.MERGEPRINT: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!StringUtils.isEmpty(checkMsg)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    getView().showTipNotification(checkMsg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    args.setCancel(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void afterDoOperation(AfterDoOperationEventArgs args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.afterDoOperation(args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String operateKey = args.getOperateKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OperationResult operationResult = args.getOperationResult(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if( operationResult != null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                && (!operationResult.isSuccess() || operationResult.getSuccessPkIds().size() == 0)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (operateKey) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.HANDIN_TICKET: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                executeOperateBill(operateKey, "交票"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.RECEIVE_TICKET: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                executeOperateBill(operateKey, "收票"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 打印 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case HandInReceiveTicketConstant.OPERATE.MERGEPRINT: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doMergetPrint(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void entryRowDoubleClick(RowClickEvent evt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RowClickEventListener.super.entryRowDoubleClick(evt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EntryGrid entryGrid = (EntryGrid)evt.getSource(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String entryKey = entryGrid.getEntryKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int row = evt.getRow(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(StringUtils.equals(entryKey,HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 获取单据信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DynamicObject billEntry = getModel().getEntryRowEntity(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID, row); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BillShowParameter parameter = new BillShowParameter(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            parameter.setFormId(billEntry.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            parameter.setStatus(OperationStatus.VIEW); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            parameter.getOpenStyle().setShowType(ShowType.InContainer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            parameter.getOpenStyle().setTargetKey(HandInReceiveTicketConstant.METEDATAFLAG.NCKD_FLEX_TARGETBILL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showForm(parameter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void entryRowClick(RowClickEvent evt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RowClickEventListener.super.entryRowClick(evt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected String checkSelectSingle(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<DynamicObject> selectRows = getSelectRows(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(selectRows.size() == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResManager.loadKDString("请选择要执行的数据。","",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(selectRows.size() > 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResManager.loadKDString("请选择一条数据进行操作。","",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void doMergetPrint() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DynamicObject selectRow = getSelectRows().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Object companyId = selectRow.getDynamicObject(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_COMPANY).getPkValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String formId = selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String billId = selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 通过打印配置获取单据打印信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<MergePrintEntity> printPdfConfig = ReceiveTicketUtils.getPrintPdfConfig(formId,billId,companyId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String downloadUrl = ReceiveTicketUtils.mergePrintPdf(getView(), printPdfConfig, "报销单附件打印.pdf"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getView().download(downloadUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void reloadEntryRow(int[] indexArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(int index : indexArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DynamicObject entryRowEntity = getModel().getEntryRowEntity(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID, index); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DynamicObject billInfo = BusinessDataServiceHelper.loadSingle(entryRowEntity.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    entryRowEntity.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String.join(",", ErReimBurseBillConstant.KEY_NCKD_HANDIN_PERSON, ErReimBurseBillConstant.KEY_NCKD_RECEIPT_PERSON)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            entryRowEntity.set(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_STATUS,getReceiptStatus(billInfo)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        getView().updateView(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void closedCallBack(ClosedCallBackEvent event) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.closedCallBack(event); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String actionId = event.getActionId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Object returnData = event.getReturnData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(CLOSECALLBACK_MAIL.equals(actionId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(returnData == null || StringUtils.isEmpty(returnData.toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DynamicObject billInfo = getSelectBillInfo(ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            billInfo.set(ErReimBurseBillConstant.KEY_NCKD_TRACKING_NUMBER,returnData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SaveServiceHelper.save(new DynamicObject[]{ billInfo }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void executeOperateBill(String operate, String operateName){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<DynamicObject> selectRowList = getSelectRows(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EntryGrid entryGrid = this.getControl(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(selectRowList.size() <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 按照单据类型分组来执行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String, List<DynamicObject>> formIdMap = selectRowList.stream().collect(Collectors.groupingBy(r -> r.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OperationResult opResult =new OperationResult(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(Map.Entry<String, List<DynamicObject>> row : formIdMap.entrySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String billFormId = row.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<DynamicObject> billList = row.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Object> selectRowIdList = billList.stream().map(r -> r.get(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID)).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 调用操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            OperationResult operationResult = OperationServiceHelper.executeOperate(operate, billFormId, selectRowIdList.toArray(), OperateOption.create()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            opResult.mergeOperateResult(operationResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 全部成功弹出消息提示,否则弹出操作提示框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(opResult.isSuccess()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showSuccessNotification(String.format(ResManager.loadKDString("执行【%1$s】操作成功!","",""),operateName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getView().showOperationResult(opResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //刷新分录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        reloadEntryRow(entryGrid.getSelectRows()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected List<DynamicObject> getSelectRows(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<DynamicObject> selectRowList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EntryGrid entryGrid = this.getControl(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int[] selectRows = entryGrid.getSelectRows(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(int rowIndex : selectRows){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            selectRowList.add(getModel().getEntryRowEntity(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID,rowIndex)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return selectRowList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |