66 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Java
		
	
	
	
| package tqq9.lc123.cloud.app.plugin.operate.sys;
 | |
| 
 | |
| import com.alibaba.fastjson.JSONObject;
 | |
| import kd.bos.dataentity.entity.DynamicObject;
 | |
| import kd.bos.dataentity.entity.DynamicObjectCollection;
 | |
| import kd.bos.entity.operate.result.OperationResult;
 | |
| import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 | |
| import kd.bos.entity.plugin.args.AfterOperationArgs;
 | |
| import kd.bos.servicehelper.BusinessDataServiceHelper;
 | |
| import kd.bos.servicehelper.operation.SaveServiceHelper;
 | |
| import org.apache.commons.lang3.StringUtils;
 | |
| import tqq9.lc123.cloud.app.plugin.trd.FWImpl;
 | |
| 
 | |
| import java.util.List;
 | |
| 
 | |
| /**
 | |
|  * 供应商提交到泛微
 | |
|  */
 | |
| public class SupplierSubmitToFwOp extends AbstractOperationServicePlugIn {
 | |
| 
 | |
| 
 | |
|     @Override
 | |
|     public void afterExecuteOperationTransaction(AfterOperationArgs e) {
 | |
|         super.afterExecuteOperationTransaction(e);
 | |
|         OperationResult operationResult = this.getOperationResult();
 | |
|         List<Object> successPkIds = operationResult.getSuccessPkIds();
 | |
|         for (Object successPkId : successPkIds) {
 | |
|             DynamicObject bill = BusinessDataServiceHelper.loadSingle(successPkId, "bd_supplier");
 | |
|             DynamicObjectCollection groupstandardColl = bill.getDynamicObjectCollection("entry_groupstandard");
 | |
|             boolean isPurSupplier = false;//是否是采购供应商
 | |
|             for (DynamicObject groupstandard : groupstandardColl) {
 | |
|                 DynamicObject groupid = groupstandard.getDynamicObject("groupid");
 | |
|                 if(groupid != null){
 | |
|                     String groupNumber = groupid.getString("number");
 | |
|                     if("002".equals(groupNumber)){//002-采购供应商
 | |
|                         isPurSupplier = true;
 | |
|                         break;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             if(isPurSupplier){
 | |
|                 //是采购供应商 才需要推送泛微
 | |
|                 boolean tqq9_issuccess = bill.getBoolean("tqq9_issuccess");
 | |
|                 String resultStr = FWImpl.pushFwSupplier(bill);
 | |
|                 if(StringUtils.isNotBlank(resultStr)){
 | |
|                     JSONObject resultObj = JSONObject.parseObject(resultStr);
 | |
|                     String code = resultObj.getString("code");
 | |
|                     if("SUCCESS".equals(code)){
 | |
|                         JSONObject data = resultObj.getJSONObject("data");
 | |
|                         if(data != null){
 | |
|                             String requestid = data.getString("requestid");
 | |
|                             if(tqq9_issuccess){
 | |
|                                 bill.set("tqq9_fwupdid", requestid);
 | |
|                             }else{
 | |
|                                 bill.set("tqq9_fwrequestid", requestid);
 | |
|                             }
 | |
|                             bill.set("tqq9_fwstate", "B");
 | |
|                             SaveServiceHelper.save(new DynamicObject[]{bill});
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |