| 
					
				 | 
			
			
				@@ -0,0 +1,75 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package net.chenlin.dp.modules.api.controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.taobao.api.ApiException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import net.chenlin.dp.common.openapi4j.exception.OpenAPIException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import net.chenlin.dp.modules.api.service.PurchaseOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import net.chenlin.dp.modules.api.vo.SaleOrderRest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import net.chenlin.dp.modules.api.vo.YonyouPurchaseOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import net.chenlin.dp.modules.api.vo.YonyouSaleOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class PurchaseOrderController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PurchaseOrderService purchaseOrderService=new PurchaseOrderService(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private  DingdingOpenInterface dingdingOpenInterface=new DingdingOpenInterface(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 获取U8采购订单创建钉钉采购订单审批实列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws OpenAPIException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws ApiException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void dingPurchaseOrder() throws OpenAPIException, ApiException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,String> map=new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        purchaseOrderService.getToaccount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<YonyouPurchaseOrder> list = purchaseOrderService.yonyouQueryPurchaseOrder(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (list!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (YonyouPurchaseOrder purchaseOrders:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                YonyouPurchaseOrder purchaseOrder = purchaseOrderService.yonyouGetPurchaseOrder(purchaseOrders.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (purchaseOrder!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    purchaseOrderService.createPurchaseOrder("PROC-971173C9-46DF-4FA8-BEBB-94D3477ADB97",1306561711L,"manager5914",-1L,purchaseOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 钉钉采购订单审批后返回u8 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws OpenAPIException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void purchaseOrderShenhe() throws OpenAPIException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DingdingOpenInterface.getToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> orderIdList = dingdingOpenInterface.getOrderIdList("PROC-971173C9-46DF-4FA8-BEBB-94D3477ADB97"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (orderIdList!=null&&!orderIdList.equals("")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (String id:orderIdList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                SaleOrderRest saleOrderRest=new SaleOrderRest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String, Object> orderDetails = dingdingOpenInterface.getOrderDetails(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String, Object> map = DingdingOpenInterface.tableToMap(orderDetails); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                saleOrderRest.setUser_id(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Object code = map.get("单据编号"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                saleOrderRest.setVoucher_code(code.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Object result = orderDetails.get("result"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (!result.equals("")&&result!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (result.equals("agree")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        saleOrderRest.setAgree("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }if (result.equals("refuse")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        saleOrderRest.setAgree("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    purchaseOrderService.yonyouShenhePurchaseOrder(saleOrderRest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                System.out.println(code+"-"+result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static void main(String[] args) throws OpenAPIException, ApiException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        PurchaseOrderController purchaseOrderController =new PurchaseOrderController(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        purchaseOrderController.dingPurchaseOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |