parent
b78fee1dd0
commit
cd010d3be7
|
@ -18,12 +18,17 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.ProtocolException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业 BusinessServiceImpl
|
* 企业 BusinessServiceImpl
|
||||||
|
@ -132,41 +137,34 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void extracted(Business business) {
|
private void extracted(Business business){
|
||||||
String postUrl="http://175.24.138.82:10006/webhook/%E6%9C%AA%E5%91%BD%E5%90%8D%E9%A1%B9%E7%9B%AE";
|
String postUrl = "http://192.168.120.128/webhook/%E6%96%B0%E5%BB%BAmysql%E6%9C%8D%E5%8A%A1";
|
||||||
HashMap<String, String> hashMap = new HashMap<>();
|
HashMap<String, String> hashMap = new HashMap<>();
|
||||||
hashMap.put("businessId", business.getId()+ business.getName());
|
hashMap.put("businessId",business.getId() + business.getName());
|
||||||
hashMap.put("mysqlPort",String.valueOf(3306+ business.getId()));
|
hashMap.put("mysqlPort",String.valueOf(3306 + business.getId()));
|
||||||
String json = JSON.toJSONString(hashMap);
|
String json = JSON.toJSONString(hashMap);
|
||||||
// 3.创建连接与设置连接参数
|
|
||||||
|
// 3.创建链接与设置连接参数
|
||||||
URL urlObj = null;
|
URL urlObj = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
urlObj = new URL(postUrl);
|
urlObj = new URL(postUrl);
|
||||||
HttpURLConnection httpConn = (HttpURLConnection) urlObj.openConnection();
|
HttpURLConnection httpConn = (HttpURLConnection) urlObj.openConnection();
|
||||||
httpConn.setRequestMethod("POST");
|
httpConn.setRequestMethod("POST");
|
||||||
httpConn.setRequestProperty("Charset", "UTF-8");
|
httpConn.setRequestProperty("Charset","UTF-8");
|
||||||
// POST请求且JSON数据,必须设置
|
|
||||||
httpConn.setRequestProperty("Content-Type", "application/json");
|
//post请求且json数据,必须设置
|
||||||
// 打开输出流,默认是false
|
httpConn.setRequestProperty("Content-Type","application/json");
|
||||||
|
|
||||||
|
//打开输出流,默认false
|
||||||
httpConn.setDoOutput(true);
|
httpConn.setDoOutput(true);
|
||||||
// // 打开输入流,默认是true,可省略
|
|
||||||
// httpConn.setDoInput(true);
|
//4.从httpURLConnection获取输出流和写数据
|
||||||
// 4.从HttpURLConnection获取输出流和写数据
|
|
||||||
OutputStream oStream = httpConn.getOutputStream();
|
OutputStream oStream = httpConn.getOutputStream();
|
||||||
oStream.write(json.getBytes());
|
oStream.write(json.getBytes());
|
||||||
oStream.flush();
|
oStream.flush();
|
||||||
// 5.发起http调用(getInputStream触发http请求)
|
|
||||||
if (httpConn.getResponseCode() != 200) {
|
} catch (MalformedURLException e) {
|
||||||
throw new Exception("调用服务端异常.");
|
|
||||||
}
|
|
||||||
// 6.从HttpURLConnection获取输入流和读数据
|
|
||||||
BufferedReader br = new BufferedReader(
|
|
||||||
new InputStreamReader(httpConn.getInputStream()));
|
|
||||||
String resultData = br.readLine();
|
|
||||||
System.out.println("从服务端返回结果: " + resultData);
|
|
||||||
// 7.关闭HttpURLConnection连接
|
|
||||||
httpConn.disconnect();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +172,6 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteBusinessByIds(Long[] ids) {
|
public int deleteBusinessByIds(Long[] ids) {
|
||||||
return businessMapper.deleteBusinessByIds(ids);
|
return businessMapper.deleteBusinessByIds(ids);
|
||||||
|
|
Loading…
Reference in New Issue