|
@@ -0,0 +1,58 @@
|
|
|
+package com.sagacloud.route.processors.supplier;
|
|
|
+/*
|
|
|
+ * Author: Jxing
|
|
|
+ * Create Time: 2018/11/12
|
|
|
+ */
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.sagacloud.utils.ExternalUrlUtil;
|
|
|
+import com.sagacloud.utils.HttpRequests;
|
|
|
+import com.sagacloud.utils.VendersUtil;
|
|
|
+import org.apache.camel.Exchange;
|
|
|
+import org.apache.camel.Processor;
|
|
|
+import org.apache.http.HttpRequest;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+public class SupplyContractProcessor implements Processor {
|
|
|
+ @Override
|
|
|
+ public void process(Exchange exchange) throws Exception {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void getContractList(Exchange exchange) throws Exception{
|
|
|
+ String jsonStr = exchange.getIn().getBody(String.class);
|
|
|
+ JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
+ String pjId = json.getString("projectId");
|
|
|
+ String venderId = json.getString("venderId");
|
|
|
+ if(pjId == null || !pjId.startsWith("Pj") || venderId == null || !venderId.startsWith("V"))
|
|
|
+ throw new Exception("输入参数不正确");
|
|
|
+ JSONObject body = new JSONObject();
|
|
|
+ JSONObject criteria = new JSONObject();
|
|
|
+ body.put("criteria", criteria);
|
|
|
+ JSONArray type = new JSONArray();
|
|
|
+ type.add("Pe");
|
|
|
+ JSONArray DPSupplierID = new JSONArray();
|
|
|
+ DPSupplierID.add(venderId);
|
|
|
+ criteria.put("type", type);
|
|
|
+ criteria.put("DPSupplierID", DPSupplierID);
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ result = HttpRequests.sendPost(ExternalUrlUtil.getInQueryUrl(pjId), body.toString());
|
|
|
+ }catch (Exception ex){
|
|
|
+ throw new Exception("数据平台请求失败");
|
|
|
+ }
|
|
|
+ if(result == null)
|
|
|
+ throw new Exception("数据平台请求失败");
|
|
|
+ JSONObject resultObject = JSONObject.parseObject(result);
|
|
|
+ if(resultObject == null || resultObject.getString("Result") == null || !resultObject.getString("Result").equals("success"))
|
|
|
+ throw new Exception("数据平台请求失败");
|
|
|
+ Set<Object> contractNoSet = VendersUtil.getInfoSet(resultObject.getJSONArray("Content"), "SupplierContractID");
|
|
|
+ JSONObject retObj = VendersUtil.successJsonMsg("");
|
|
|
+ JSONArray contractArr = new JSONArray(new ArrayList<>(contractNoSet));
|
|
|
+ retObj.put("contractId", contractArr);
|
|
|
+ exchange.getOut().setBody(retObj.toString());
|
|
|
+ }
|
|
|
+}
|