wanghongzhi преди 1 година
родител
ревизия
a80f832af3

+ 20 - 0
easydo-chengfa/pom.xml

@@ -54,6 +54,26 @@
             <artifactId>spring-kafka</artifactId>
             <version>2.2.0.RELEASE</version>
         </dependency>
+        <!-- <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-high-level-client</artifactId>
+            <version>6.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-client</artifactId>
+            <version>6.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch</groupId>
+            <artifactId>elasticsearch</artifactId>
+            <version>6.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-client</artifactId>
+            <version>5.3.0</version>
+        </dependency> -->
     </dependencies>
 
     <!-- 打包 -->

+ 34 - 0
easydo-chengfa/src/main/java/easydo/technology/controller/RocketMQConsumer.java

@@ -0,0 +1,34 @@
+// package easydo.technology.controller;
+
+// import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+// import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+// import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+// import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+// import org.apache.rocketmq.common.message.MessageExt;
+ 
+// import java.util.List;
+ 
+// public class RocketMQConsumer {
+ 
+//     public static void main(String[] args) throws Exception {
+//         // 创建消费者,并指定消费者组名
+//         DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("consumer_group");
+//         // 指定Namesrv地址
+//         consumer.setNamesrvAddr("172.16.1.150:9876");
+//         consumer.setMqClientApiTimeout(1000*10);
+//         // 订阅主题和标签
+//         consumer.subscribe("MyTopic1", "*");
+//         // 指定从哪个位置开始消费
+//         consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
+//         // 注册消息监听器
+//         consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {
+//             for (MessageExt msg : msgs) {
+//                 System.out.println("Received: " + new String(msg.getBody()));
+//             }
+//             return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+//         });
+//         // 启动消费者
+//         consumer.start();
+//         System.out.printf("Consumer Started.%n");
+//     }
+// }

+ 37 - 0
easydo-chengfa/src/main/java/easydo/technology/controller/RocketMQExample.java

@@ -0,0 +1,37 @@
+// package easydo.technology.controller;
+
+// import java.net.InetSocketAddress;
+// import java.net.Proxy;
+// import java.nio.charset.Charset;
+// import java.nio.charset.StandardCharsets;
+
+// import org.apache.rocketmq.client.producer.DefaultMQProducer;
+// import org.apache.rocketmq.client.producer.SendResult;
+// import org.apache.rocketmq.common.message.Message;
+
+// public class RocketMQExample {
+
+//     public static void main(String[] args) throws Exception {
+ 
+//         // 1.创建一个DefaultMQProducer实例,指定生产者组名
+//         DefaultMQProducer producer = new DefaultMQProducer("my-producer-group1");
+//         producer.setMqClientApiTimeout(1000*10);
+//         // 2.设置NameServer的地址
+//         producer.setNamesrvAddr("172.16.1.150:9876");
+//         // 3.启动生产者实例
+//         producer.start();
+//         // 4.使用for循环发送10条消息
+//         for (int i = 0; i < 10; i++) {
+//             // 创建一条消息,指定Topic为"MyTopic1",Tag标签为"TagA",消息体为"hello
+//             // rocketmq"加上循环变量的值,同时把字符串转换为字节数组
+//             Message message = new Message("MyTopic1", "TagA", ("hello rocketmq" + i).getBytes(Charset.forName("utf-8")));
+//             // 5.发送消息并接收发送结果
+//             SendResult sendResult = producer.send(message,1000*10);
+//             // 打印发送结果,包括消息ID、发送状态等信息
+//             System.out.println(sendResult);
+//         }
+//         // 6.发送完所有消息后,关闭生产者实例,释放资源
+//         producer.shutdown();
+//         producer.shutdown();
+//     }
+// }

+ 129 - 69
easydo-chengfa/src/main/java/easydo/technology/controller/TestController.java

@@ -4,8 +4,10 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.Authenticator;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
 import java.net.URL;
 import java.sql.Connection;
 import java.text.MessageFormat;
@@ -20,6 +22,20 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.sql.DataSource;
 
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -118,7 +134,7 @@ public class TestController {
     }
 
     @GetMapping(value = "/test")
-    public void test(HttpServletResponse response,HttpServletRequest request, @RequestParam String objectId,
+    public void test(HttpServletResponse response, HttpServletRequest request, @RequestParam String objectId,
             @RequestParam(required = false) String fileName) throws Exception {
         String url = "http://jsf-int.glodon.com/cost-management/openapi/attachments/" + objectId;
         Map<String, String> header = new HashMap<>();
@@ -128,79 +144,123 @@ public class TestController {
         if (StringUtil.isEmpty(fileName)) {
             fileName = "contract.pdf";
         }
-        HttpClientUtil.sendGETWithHeader_OutputStream(url, header,request, response, fileName);
+        HttpClientUtil.sendGETWithHeader_OutputStream(url, header, request, response, fileName);
 
     }
 
-    public static void main(String[] args) {
-        String creationDate = LocalDateUtil.localDateTimeFormat(LocalDateTime.now(), "yyyy-MM-dd HH:mm");
-        String creationDate2 = LocalDateUtil.localDateTimeFormat(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss");
+    // public static void main(String[] args) {
+    // String creationDate = LocalDateUtil.localDateTimeFormat(LocalDateTime.now(),
+    // "yyyy-MM-dd HH:mm");
+    // String creationDate2 = LocalDateUtil.localDateTimeFormat(LocalDateTime.now(),
+    // "yyyy-MM-dd HH:mm:ss");
 
-        String url = "http://218.201.101.181:8180" + "/seeyon/rest/token";
-        JSONObject object = new JSONObject();
-        object.put("userName", "zcxt");
-        object.put("password", "2679fc6b-df18-4563-9b8e-773b59bdcb62");
-        JSONObject resObject = HttpClientUtil.sendPOST(url, object.toJSONString());
-        System.out.println("查询OAtoken的res======>" + resObject.toJSONString());
-        String token = resObject.getString("id");
+    // String url = "http://218.201.101.181:8180" + "/seeyon/rest/token";
+    // JSONObject object = new JSONObject();
+    // object.put("userName", "zcxt");
+    // object.put("password", "2679fc6b-df18-4563-9b8e-773b59bdcb62");
+    // JSONObject resObject = HttpClientUtil.sendPOST(url, object.toJSONString());
+    // System.out.println("查询OAtoken的res======>" + resObject.toJSONString());
+    // String token = resObject.getString("id");
 
-        Map<String, String> header = new HashMap<>();
-        header.put("token", token);
-
-        // String sendTodoUrl = "http://218.201.101.181:8180" +
-        // "/seeyon/rest/thirdpartyPending/receive?token=" + token;
-        // object = new JSONObject();
-        // object.put("registerCode", "3007");
-        // object.put("taskId", "4e12f28b-8e15-4f82-afbf-59dd0b083394");
-        // object.put("title", "供应商评价");
-        // object.put("senderName", "guanglianda");
-        // object.put("classify", "招采系统");
-        // object.put("contentType", "招采系统");
-        // object.put("state", 0);
-        // object.put("thirdSenderId", "");
-        // object.put("thirdReceiverId", "");
-        // object.put("creationDate", creationDate);
-        // object.put("content", "");
-        // object.put("h5url", "");
-        // object.put("url", "http://172.16.1.150:8810/purchase/getDetail?"
-        // +
-        // "type=supplier_evaluate&path=supplier-evaluation-detail&businessId=d0ff0a8b-54bf-4351-ad8d-e7cd26fc181e");
-        // object.put("noneBindingSender", "guanglianda");
-        // object.put("noneBindingReceiver", "guanglianda");
-
-        // JSONObject resObj = HttpClientUtil.sendPOSTWithHeader(sendTodoUrl,
-        // object.toJSONString(), header);
-        // System.out.println("生成OA待办req======>" + object.toJSONString() + ",res======>"
-        // + resObj.toJSONString());
-
-        // String updateTodoUrl = "http://218.201.101.181:8180" +
-        // "/seeyon/rest/thirdpartyPending/updatePendingState?token=" + token;
-        // object = new JSONObject();
-        // object.put("registerCode", "3007");
-        // object.put("taskId","4e12f28b-8e15-4f82-afbf-59dd0b083394" );
-        // object.put("state",1 );
-        // object.put("subState",2 );
-        // JSONObject resObj =
-        // HttpClientUtil.sendPOSTWithHeader(updateTodoUrl,object.toJSONString(),
-        // header);
-        // System.out.println("更新OA待办req======>" + object.toJSONString() + ",res======>"
-        // + resObj.toJSONString());
-
-        String sendMessageUrl = "http://218.201.101.181:8180" +
-                "/seeyon/rest/thirdpartyMessage/receive/singleMessage?token=" + token;
-        object = new JSONObject();
-        object.put("thirdpartyRegisterCode", "3007");
-        object.put("thirdpartyMessageId", "1");
-        object.put("messageContent", "您有一条待测试的消息。");
-        object.put("thirdpartyReceiverId", 0);
-        object.put("creation_date", creationDate2);
-
-        object.put("noneBindingSender", "guanglianda");
-        object.put("noneBindingReceiver", "guanglianda");
-
-        JSONObject resObj = HttpClientUtil.sendPOSTWithHeader(sendMessageUrl, object.toJSONString(), header);
-        System.out.println("推送OA消息req======>" + object.toJSONString() + ",res======>" + resObj.toJSONString());
-    }
+    // Map<String, String> header = new HashMap<>();
+    // header.put("token", token);
+
+    // String sendTodoUrl = "http://218.201.101.181:8180" +
+    // "/seeyon/rest/thirdpartyPending/receive?token=" + token;
+    // object = new JSONObject();
+    // object.put("registerCode", "3007");
+    // object.put("taskId", "4e12f28b-8e15-4f82-afbf-59dd0b083394");
+    // object.put("title", "供应商评价");
+    // object.put("senderName", "guanglianda");
+    // object.put("classify", "招采系统");
+    // object.put("contentType", "招采系统");
+    // object.put("state", 0);
+    // object.put("thirdSenderId", "");
+    // object.put("thirdReceiverId", "");
+    // object.put("creationDate", creationDate);
+    // object.put("content", "");
+    // object.put("h5url", "");
+    // object.put("url", "http://172.16.1.150:8810/purchase/getDetail?"
+    // +
+    // "type=supplier_evaluate&path=supplier-evaluation-detail&businessId=d0ff0a8b-54bf-4351-ad8d-e7cd26fc181e");
+    // object.put("noneBindingSender", "guanglianda");
+    // object.put("noneBindingReceiver", "guanglianda");
+
+    // JSONObject resObj = HttpClientUtil.sendPOSTWithHeader(sendTodoUrl,
+    // object.toJSONString(), header);
+    // System.out.println("生成OA待办req======>" + object.toJSONString() + ",res======>"
+    // + resObj.toJSONString());
+
+    // String updateTodoUrl = "http://218.201.101.181:8180" +
+    // "/seeyon/rest/thirdpartyPending/updatePendingState?token=" + token;
+    // object = new JSONObject();
+    // object.put("registerCode", "3007");
+    // object.put("taskId","4e12f28b-8e15-4f82-afbf-59dd0b083394" );
+    // object.put("state",1 );
+    // object.put("subState",2 );
+    // JSONObject resObj =
+    // HttpClientUtil.sendPOSTWithHeader(updateTodoUrl,object.toJSONString(),
+    // header);
+    // System.out.println("更新OA待办req======>" + object.toJSONString() + ",res======>"
+    // + resObj.toJSONString());
+
+    // String sendMessageUrl = "http://218.201.101.181:8180" +
+    // "/seeyon/rest/thirdpartyMessage/receive/singleMessage?token=" + token;
+    // object = new JSONObject();
+    // object.put("thirdpartyRegisterCode", "3007");
+    // object.put("thirdpartyMessageId", "1");
+    // object.put("messageContent", "您有一条待测试的消息。");
+    // object.put("thirdpartyReceiverId", 0);
+    // object.put("creation_date", creationDate2);
+
+    // object.put("noneBindingSender", "guanglianda");
+    // object.put("noneBindingReceiver", "guanglianda");
+
+    // JSONObject resObj = HttpClientUtil.sendPOSTWithHeader(sendMessageUrl,
+    // object.toJSONString(), header);
+    // System.out.println("推送OA消息req======>" + object.toJSONString() + ",res======>"
+    // + resObj.toJSONString());
+    // }
+
+    // public static void main(String[] args) {
+    //     // 初始化RestHighLevelClient
+    //     RestClientBuilder builder = RestClient.builder(new HttpHost("172.16.1.150", 9200, "http"));
+       
+    //     // 进行用户名密码的验证
+    //     CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+    //     credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "_Easy2024"));
+    //     builder.setHttpClientConfigCallback((HttpAsyncClientBuilder httpAsyncclientBuidler) -> httpAsyncclientBuidler
+    //             .setDefaultCredentialsProvider(credentialsProvider));
+
+    //     RestHighLevelClient client = new RestHighLevelClient(builder);
+
+    //     // 创建查询请求并设置索引名
+    //     SearchRequest searchRequest = new SearchRequest("gld_member");
+
+    //     // 构建查询条件
+    //     SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+    //     searchSourceBuilder.query(QueryBuilders.matchQuery("user_id", "5600031"));
+    //     searchRequest.source(searchSourceBuilder);
+
+    //     // 执行查询
+    //     SearchResponse searchResponse;
+    //     try {
+    //         searchResponse = client.search(searchRequest);
+    //         // 处理查询结果
+    //         for (SearchHit hit : searchResponse.getHits().getHits()) {
+    //             System.out.println(hit.getSourceAsString());
+    //         }
+    //     } catch (IOException e) {
+    //         e.printStackTrace();
+    //     } finally {
+    //         // 关闭客户端
+    //         try {
+    //             client.close();
+    //         } catch (IOException e) {
+    //             e.printStackTrace();
+    //         }
+    //     }
+    // }
 
     // ScheduledExecutorService executorService =
     // Executors.newScheduledThreadPool(2);

+ 1 - 1
easydo-chengfa/src/main/resources/config/application.yml

@@ -3,7 +3,7 @@ spring:
   freemarker:
     check-template-location: false
   profiles:
-    active: dev
+    active: test
   jackson:
     time-zone: GMT+8
   data: