Browse Source
Conflicts: epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.javadev_shibei_match
182 changed files with 5024 additions and 555 deletions
@ -0,0 +1,32 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 系统监控日志 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Data |
|||
public class SysMonitorLogDTO implements Serializable { |
|||
/** |
|||
* 访问路径 |
|||
*/ |
|||
private String path; |
|||
/** |
|||
* 耗时 |
|||
*/ |
|||
private Integer costTime; |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.controller; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 异常日志 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("monitorlog") |
|||
public class SysMonitorLogController { |
|||
|
|||
/** |
|||
* desc: 记录监控日志 |
|||
* |
|||
* @param params |
|||
* @return void |
|||
* @author LiuJanJun |
|||
* @date 2021/4/19 5:56 下午 |
|||
*/ |
|||
@RequestMapping("info") |
|||
public void infoLevel(@RequestBody Map<String,Object> params) { |
|||
log.info("monitor log info:{}", JSON.toJSONString(params)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.epmet; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; |
|||
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
/** |
|||
* desc:redisson测试类 |
|||
*/ |
|||
@Slf4j |
|||
@RunWith(value = SpringRunner.class) |
|||
@SpringBootTest(classes = {AuthApplication.class}) |
|||
public class ThirdPlatformTest { |
|||
|
|||
@Autowired |
|||
private JcetApiService jcetApiService; |
|||
|
|||
@Test |
|||
public void t() { |
|||
String ssoTicket = "ssoTicket-5kc8FY7Re2iv7Kfq74G9EWCN7QybBjxB"; |
|||
for (int i = 0; i < 50; i++) { |
|||
getUserINfoByTicket(ssoTicket); |
|||
} |
|||
|
|||
} |
|||
|
|||
private void getUserINfoByTicket(String ssoTicket) { |
|||
try { |
|||
ThirdPlatUserInfo cUserInfoByTicket = jcetApiService.getCUserInfoByTicket(ssoTicket); |
|||
log.info("result:{}", JSON.toJSONString(cUserInfoByTicket)); |
|||
} catch (Exception e) { |
|||
log.info("失败:{}", e.getMessage()); |
|||
if (e.getMessage().contains("Read timed out")) |
|||
log.info("失败了"); |
|||
//break;
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.epmet.commons.tools.utils.net; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import okhttp3.Interceptor; |
|||
import okhttp3.Request; |
|||
import okhttp3.Response; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* desc: |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2021/4/16 5:02 下午 |
|||
* @version: 1.0 |
|||
*/ |
|||
@Slf4j |
|||
class HttpLogInterceptor implements Interceptor { |
|||
@Override public Response intercept(Interceptor.Chain chain) throws IOException { |
|||
Request request = chain.request(); |
|||
long t1 = System.nanoTime(); |
|||
log.info(String.format("Sending request %s on %s%n%s", |
|||
request.url(), chain.connection(), request.headers())); |
|||
|
|||
Response response = chain.proceed(request); |
|||
|
|||
long t2 = System.nanoTime(); |
|||
log.info(String.format("Received response for %s in %.1fms%n%s", |
|||
response.request().url(), (t2 - t1) / 1e6d, response.headers())); |
|||
|
|||
return response; |
|||
} |
|||
} |
@ -0,0 +1,432 @@ |
|||
package com.epmet.commons.tools.utils.net; |
|||
|
|||
|
|||
import okhttp3.*; |
|||
import org.apache.http.client.utils.URIBuilder; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import javax.net.ssl.SSLContext; |
|||
import javax.net.ssl.SSLSocketFactory; |
|||
import javax.net.ssl.TrustManager; |
|||
import javax.net.ssl.X509TrustManager; |
|||
import java.io.IOException; |
|||
import java.net.MalformedURLException; |
|||
import java.net.URISyntaxException; |
|||
import java.security.SecureRandom; |
|||
import java.security.cert.CertificateException; |
|||
import java.security.cert.X509Certificate; |
|||
import java.util.*; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
|
|||
public class OkHttpUtil { |
|||
|
|||
private static final Logger logger = LoggerFactory.getLogger(OkHttpUtil.class); |
|||
|
|||
public final static int READ_TIMEOUT = 2; |
|||
public final static int CONNECT_TIMEOUT = 1; |
|||
public final static int WRITE_TIMEOUT = 5; |
|||
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); |
|||
|
|||
public static final String CONTENT_TYPE = "Content-Type"; |
|||
|
|||
private static final byte[] LOCKER = new byte[0]; |
|||
private static OkHttpUtil mInstance; |
|||
private OkHttpClient mOkHttpClient; |
|||
|
|||
|
|||
private OkHttpUtil() { |
|||
//todo 由于是静态工具类,只会创建client一次,如果以后需要不同请求不同超时时间,不能这样使用
|
|||
okhttp3.OkHttpClient.Builder clientBuilder = new okhttp3.OkHttpClient.Builder(); |
|||
//设置读取超市时间
|
|||
clientBuilder.readTimeout(READ_TIMEOUT, TimeUnit.SECONDS); |
|||
//设置超时连接时间
|
|||
clientBuilder.connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS); |
|||
//设置写入超时时间
|
|||
clientBuilder.writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS); |
|||
//支持HTTPS请求,跳过证书验证
|
|||
clientBuilder.sslSocketFactory(SSLSocketClient.getSSLSocketFactory(), SSLSocketClient.getX509TrustManager()) |
|||
.hostnameVerifier(SSLSocketClient.getHostnameVerifier()); |
|||
//clientBuilder.sslSocketFactory(createSSLSocketFactory());
|
|||
/*clientBuilder.hostnameVerifier(new HostnameVerifier() { |
|||
@Override |
|||
public boolean verify(String hostname, SSLSession session) { |
|||
return true; |
|||
} |
|||
});*/ |
|||
|
|||
//添加拦截器
|
|||
clientBuilder.addInterceptor(new HttpLogInterceptor()); |
|||
mOkHttpClient = clientBuilder.build(); |
|||
} |
|||
|
|||
/** |
|||
* 单例模式获取NetUtils |
|||
* |
|||
* @return |
|||
*/ |
|||
public static OkHttpUtil getInstance() { |
|||
if (mInstance == null) { |
|||
synchronized (LOCKER) { |
|||
if (mInstance == null) { |
|||
mInstance = new OkHttpUtil(); |
|||
} |
|||
} |
|||
} |
|||
return mInstance; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* get请求,同步方式,获取网络数据,是在主线程中执行的,需要新起线程,将其放到子线程中执行 |
|||
* |
|||
* @param url |
|||
* @return |
|||
*/ |
|||
public Response getData(String url) { |
|||
return getData(url, null); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* get请求,同步方式,获取网络数据,是在主线程中执行的,需要新起线程,将其放到子线程中执行 |
|||
* |
|||
* @param url |
|||
* @return |
|||
*/ |
|||
public Response getData(String url, Map<String, Object> headerMap) { |
|||
//1 构造Request
|
|||
Request.Builder builder = new Request.Builder().get().url(url); |
|||
//Request request = builder.get().url(url).build();
|
|||
//builder = builder.get().url(url);
|
|||
/*if (headerMap != null && headerMap.isEmpty()) { |
|||
for (Map.Entry<String, String> headerEntry : headerMap.entrySet()) { |
|||
builder.addHeader(headerEntry.getKey(), headerEntry.getValue()); |
|||
} |
|||
}*/ |
|||
addHeaders(headerMap,builder); |
|||
Request request = builder.build(); |
|||
|
|||
|
|||
//2 将Request封装为Call
|
|||
Call call = mOkHttpClient.newCall(request); |
|||
//3 执行Call,得到response
|
|||
Response response = null; |
|||
try { |
|||
response = call.execute(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
/** |
|||
* post form表单 请求,同步方式,提交数据,是在主线程中执行的,需要新起线程,将其放到子线程中执行 |
|||
* |
|||
* @param url |
|||
* @param bodyParams |
|||
* @return |
|||
*/ |
|||
/*public Response postFormData(String url, Map<String, String> bodyParams) { |
|||
//1构造RequestBody
|
|||
RequestBody body = setRequestBody(bodyParams); |
|||
//2 构造Request
|
|||
Request.Builder requestBuilder = new Request.Builder(); |
|||
Request request = requestBuilder.post(body).addHeader(CONTENT_TYPE, HttpContentTypeEnum.FORM.contentTypeValue).url(url).build(); |
|||
//3 将Request封装为Call
|
|||
Call call = mOkHttpClient.newCall(request); |
|||
//4 执行Call,得到response
|
|||
Response response = null; |
|||
try { |
|||
response = call.execute(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
}*/ |
|||
|
|||
/** |
|||
* post方式 |
|||
* |
|||
* @param url 请求url |
|||
* @param bodyParams requestbody |
|||
* @param headerMap 请求头信息 |
|||
* @return |
|||
* @throws IOException |
|||
*/ |
|||
public Response postData(String url, Map<String, Object> bodyParams, Map<String, Object> headerMap) throws Exception { |
|||
//1构造RequestBody
|
|||
RequestBody body = setRequestBody(bodyParams, headerMap); |
|||
//2 构造Request
|
|||
Request.Builder requestBuilder = new Request.Builder().post(body).url(url); |
|||
//requestBuilder = requestBuilder.post(body).url(url);
|
|||
addHeaders(headerMap, requestBuilder); |
|||
Request request = requestBuilder.build(); |
|||
//Request request = requestBuilder.post(body).addHeader(CONTENT_TYPE, HttpContentTypeEnum.JSON.contentTypeValue).url(url).build();
|
|||
//3 将Request封装为Call
|
|||
Call call = mOkHttpClient.newCall(request); |
|||
//4 执行Call,得到response
|
|||
Response response = null; |
|||
try { |
|||
response = call.execute(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* put请求方式 |
|||
* |
|||
* @param url |
|||
* @param bodyParams |
|||
* @return |
|||
*/ |
|||
public Response putData(String url, Map<String, Object> bodyParams, Map<String, Object> headerMap) throws Exception { |
|||
//1构造RequestBody
|
|||
RequestBody body = setRequestBody(bodyParams, headerMap); |
|||
//2 构造Request
|
|||
Request.Builder requestBuilder = new Request.Builder().put(body).url(url); |
|||
addHeaders(headerMap, requestBuilder); |
|||
Request request = requestBuilder.build(); |
|||
//3 将Request封装为Call
|
|||
Call call = mOkHttpClient.newCall(request); |
|||
//4 执行Call,得到response
|
|||
Response response = null; |
|||
try { |
|||
response = call.execute(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param url |
|||
* @param bodyParams |
|||
* @return |
|||
*/ |
|||
public Response delData(String url, Map<String, Object> bodyParams, Map<String, Object> headerMap) throws Exception { |
|||
//1构造RequestBody
|
|||
RequestBody body = setRequestBody(bodyParams, headerMap); |
|||
//2 构造Request
|
|||
Request.Builder requestBuilder = new Request.Builder().delete(body).url(url); |
|||
addHeaders(headerMap, requestBuilder); |
|||
Request request = requestBuilder.build(); |
|||
//3 将Request封装为Call
|
|||
Call call = mOkHttpClient.newCall(request); |
|||
//4 执行Call,得到response
|
|||
Response response = null; |
|||
try { |
|||
response = call.execute(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* post的请求参数,构造RequestBody |
|||
* |
|||
* @param bodyParams |
|||
* @return |
|||
*/ |
|||
private RequestBody setRequestBody(Map<String, Object> bodyParams, Map<String, Object> headerMap) throws Exception { |
|||
//判断请求头中是否存在 content-type字段
|
|||
if (headerMap == null || !headerMap.containsKey(CONTENT_TYPE)) { |
|||
throw new Exception("请求头信息配置中无 Content-Type配置,请先配置"); |
|||
} |
|||
|
|||
Object contentType = headerMap.get(CONTENT_TYPE); |
|||
String contentTypeStr = contentType != null?contentType.toString():null; |
|||
if ("application/x-www-form-urlencoded".equals(contentTypeStr)) { |
|||
//表单提交 就是key-value 都是字符串型
|
|||
//转换
|
|||
Map<String, String> strBodyParamMap = new HashMap<>(); |
|||
if (bodyParams != null && !bodyParams.isEmpty()) { |
|||
bodyParams.forEach((key, value) -> { |
|||
if (value != null) { |
|||
strBodyParamMap.put(key, (String) value); |
|||
} |
|||
}); |
|||
} |
|||
return buildRequestBodyByMap(strBodyParamMap); |
|||
} else { |
|||
//json
|
|||
return buildRequestBodyByJson(com.alibaba.fastjson.JSON.toJSONString(bodyParams)); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 表单方式提交构建 |
|||
* |
|||
* @param bodyParams |
|||
* @return |
|||
*/ |
|||
private RequestBody buildRequestBodyByMap(Map<String, String> bodyParams) { |
|||
RequestBody body = null; |
|||
okhttp3.FormBody.Builder formEncodingBuilder = new okhttp3.FormBody.Builder(); |
|||
if (bodyParams != null) { |
|||
Iterator<String> iterator = bodyParams.keySet().iterator(); |
|||
String key = ""; |
|||
while (iterator.hasNext()) { |
|||
key = iterator.next().toString(); |
|||
formEncodingBuilder.add(key, bodyParams.get(key)); |
|||
logger.info(" 请求参数:{},请求值:{} ", key, bodyParams.get(key)); |
|||
} |
|||
} |
|||
body = formEncodingBuilder.build(); |
|||
return body; |
|||
} |
|||
|
|||
/** |
|||
* json方式提交构建 |
|||
* |
|||
* @param jsonStr |
|||
* @return |
|||
*/ |
|||
private RequestBody buildRequestBodyByJson(String jsonStr) { |
|||
return RequestBody.create(JSON, jsonStr); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 生成安全套接字工厂,用于https请求的证书跳过 |
|||
* |
|||
* @return |
|||
*/ |
|||
public SSLSocketFactory createSSLSocketFactory() { |
|||
SSLSocketFactory ssfFactory = null; |
|||
try { |
|||
SSLContext sc = SSLContext.getInstance("TLS"); |
|||
sc.init(null, new TrustManager[]{new TrustAllCerts()}, new SecureRandom()); |
|||
ssfFactory = sc.getSocketFactory(); |
|||
} catch (Exception e) { |
|||
} |
|||
return ssfFactory; |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 针对json post处理 |
|||
* |
|||
* @param url |
|||
* @param json |
|||
* @return |
|||
* @throws IOException |
|||
*/ |
|||
public String postJson(String url, String json) throws IOException { |
|||
RequestBody body = RequestBody.create(JSON, json); |
|||
Request request = new Request.Builder() |
|||
.url(url) |
|||
.post(body) |
|||
.build(); |
|||
Response response = mOkHttpClient.newCall(request).execute(); |
|||
if (response.isSuccessful()) { |
|||
return response.body().string(); |
|||
} else { |
|||
throw new IOException("Unexpected code " + response); |
|||
} |
|||
} |
|||
|
|||
public void postJsonAsyn(String url, String json, final MyNetCall myNetCall) throws IOException { |
|||
RequestBody body = RequestBody.create(JSON, json); |
|||
//2 构造Request
|
|||
Request.Builder requestBuilder = new Request.Builder(); |
|||
Request request = requestBuilder.post(body).url(url).build(); |
|||
//3 将Request封装为Call
|
|||
Call call = mOkHttpClient.newCall(request); |
|||
//4 执行Call
|
|||
call.enqueue(new Callback() { |
|||
@Override |
|||
public void onFailure(Call call, IOException e) { |
|||
myNetCall.failed(call, e); |
|||
} |
|||
|
|||
@Override |
|||
public void onResponse(Call call, Response response) throws IOException { |
|||
myNetCall.success(call, response); |
|||
|
|||
} |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 自定义网络回调接口 |
|||
*/ |
|||
public interface MyNetCall { |
|||
void success(Call call, Response response) throws IOException; |
|||
|
|||
void failed(Call call, IOException e); |
|||
} |
|||
|
|||
/** |
|||
* 构建http get请求,将参数拼接到url后面 |
|||
* |
|||
* @param url |
|||
* @param para |
|||
* @return |
|||
* @throws URISyntaxException |
|||
* @throws MalformedURLException |
|||
*/ |
|||
public static String buildHttpGet(String url, Map<String, Object> para) |
|||
throws URISyntaxException, MalformedURLException { |
|||
URIBuilder builder = new URIBuilder(url); |
|||
Set<String> set = para.keySet(); |
|||
for (String key : set) { |
|||
builder.setParameter(key, String.valueOf(para.get(key))); |
|||
} |
|||
return builder.build().toURL().toString(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 添加header信息 |
|||
* |
|||
* @param headerMap |
|||
* @param builder |
|||
* @return |
|||
*/ |
|||
private static Request.Builder addHeaders(Map<String, Object> headerMap, Request.Builder builder) { |
|||
if (headerMap != null && !headerMap.isEmpty()) { |
|||
headerMap.forEach((key, value) -> builder.addHeader(key, value == null? null:value.toString())); |
|||
} |
|||
return builder; |
|||
} |
|||
|
|||
/** |
|||
* 用于信任所有证书 |
|||
*/ |
|||
class TrustAllCerts implements X509TrustManager { |
|||
@Override |
|||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { |
|||
} |
|||
|
|||
@Override |
|||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public X509Certificate[] getAcceptedIssuers() { |
|||
return new X509Certificate[0]; |
|||
} |
|||
} |
|||
public static void main(String[] args) { |
|||
try { |
|||
Response data = OkHttpUtil.getInstance().getData("http://218.88.215.93:10011/open-api/app/token?appKey=Y6FKNwWxaeSapJT8&appSecret=e87695b9010dec760f6787a90e32921c"); |
|||
System.out.println(Objects.requireNonNull(data.body()).string()); |
|||
System.out.println(Optional.ofNullable(null).get()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,64 @@ |
|||
package com.epmet.commons.tools.utils.net; |
|||
|
|||
|
|||
import javax.net.ssl.*; |
|||
import java.security.KeyStore; |
|||
import java.security.SecureRandom; |
|||
import java.security.cert.X509Certificate; |
|||
import java.util.Arrays; |
|||
|
|||
public class SSLSocketClient { |
|||
|
|||
//获取这个SSLSocketFactory
|
|||
public static SSLSocketFactory getSSLSocketFactory() { |
|||
try { |
|||
SSLContext sslContext = SSLContext.getInstance("SSL"); |
|||
sslContext.init(null, getTrustManager(), new SecureRandom()); |
|||
return sslContext.getSocketFactory(); |
|||
} catch (Exception e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
//获取TrustManager
|
|||
private static TrustManager[] getTrustManager() { |
|||
return new TrustManager[]{ |
|||
new X509TrustManager() { |
|||
@Override |
|||
public void checkClientTrusted(X509Certificate[] chain, String authType) { |
|||
} |
|||
|
|||
@Override |
|||
public void checkServerTrusted(X509Certificate[] chain, String authType) { |
|||
} |
|||
|
|||
@Override |
|||
public X509Certificate[] getAcceptedIssuers() { |
|||
return new X509Certificate[]{}; |
|||
} |
|||
} |
|||
}; |
|||
} |
|||
|
|||
//获取HostnameVerifier
|
|||
public static HostnameVerifier getHostnameVerifier() { |
|||
return (s, sslSession) -> true; |
|||
} |
|||
|
|||
public static X509TrustManager getX509TrustManager() { |
|||
X509TrustManager trustManager = null; |
|||
try { |
|||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); |
|||
trustManagerFactory.init((KeyStore) null); |
|||
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); |
|||
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { |
|||
throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers)); |
|||
} |
|||
trustManager = (X509TrustManager) trustManagers[0]; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return trustManager; |
|||
} |
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.epmet.dataaggre.dto.govorg.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/12 15:55 |
|||
*/ |
|||
@Data |
|||
public class NextAreaCodeFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -1974456701949979946L; |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
@NotBlank(message = "parentAgencyId不能为空",groups = AddUserInternalGroup.class) |
|||
private String parentAgencyId; |
|||
|
|||
private String areaCode; |
|||
|
|||
/** |
|||
* 社区级:community, |
|||
* 乡(镇、街道)级:street, |
|||
* 区县级: district, |
|||
* 市级: city |
|||
* 省级:province |
|||
*/ |
|||
@NotBlank(message = "level不能为空",groups = AddUserInternalGroup.class) |
|||
private String level; |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.epmet.dataaggre.dto.govorg.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/12 15:56 |
|||
*/ |
|||
@Data |
|||
public class NextAreaCodeResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 9188265480821079966L; |
|||
|
|||
private String areaCode; |
|||
private String areaName; |
|||
/** |
|||
* 社区级:community, |
|||
* 乡(镇、街道)级:street, |
|||
* 区县级: district, |
|||
* 市级: city |
|||
* 省级:province |
|||
*/ |
|||
private String level; |
|||
} |
@ -0,0 +1,39 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dataaggre.dao.commonservice; |
|||
|
|||
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-01-07 |
|||
*/ |
|||
@Mapper |
|||
public interface AreaCodeDao { |
|||
|
|||
List<NextAreaCodeResultDTO> selectCityList(String areaCode); |
|||
|
|||
List<NextAreaCodeResultDTO> selectDistrictList(String areaCode); |
|||
|
|||
List<NextAreaCodeResultDTO> selectStreetList(String areaCode); |
|||
|
|||
List<NextAreaCodeResultDTO> selectCommunityList(String areaCode); |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.epmet.dataaggre.dao.opercrm; |
|||
|
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/13 10:43 |
|||
*/ |
|||
@Mapper |
|||
public interface CustomerRelationDao { |
|||
List<String> selectUsedAreaCodeList(String areaCode); |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.dataaggre.service.commonservice; |
|||
|
|||
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; |
|||
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/12 15:45 |
|||
*/ |
|||
public interface AreaCodeService { |
|||
/** |
|||
* @return java.util.List<com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO> |
|||
* @param formDTO |
|||
* @author yinzuomei |
|||
* @description 新增组织-查询下一级可选的组织区划 |
|||
* @Date 2021/4/12 16:02 |
|||
**/ |
|||
List<NextAreaCodeResultDTO> queryNextLevelAreaCodeList(NextAreaCodeFormDTO formDTO); |
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.epmet.dataaggre.service.commonservice.impl; |
|||
|
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.dataaggre.constant.DataSourceConstant; |
|||
import com.epmet.dataaggre.dao.commonservice.AreaCodeDao; |
|||
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; |
|||
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO; |
|||
import com.epmet.dataaggre.service.commonservice.AreaCodeService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/12 15:46 |
|||
*/ |
|||
@DataSource(DataSourceConstant.EPMET_COMMON_SERVICE) |
|||
@Slf4j |
|||
@Service |
|||
public class AreaCodeServiceImpl implements AreaCodeService { |
|||
|
|||
@Autowired |
|||
private AreaCodeDao areaCodeDao; |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return java.util.List<com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO> |
|||
* @author yinzuomei |
|||
* @description 新增组织-查询下一级可选的组织区划 |
|||
* @Date 2021/4/12 16:02 |
|||
**/ |
|||
@Override |
|||
public List<NextAreaCodeResultDTO> queryNextLevelAreaCodeList(NextAreaCodeFormDTO formDTO) { |
|||
List<NextAreaCodeResultDTO> list = new ArrayList<>(); |
|||
NextAreaCodeResultDTO other = new NextAreaCodeResultDTO(); |
|||
other.setAreaCode("other"); |
|||
other.setAreaName("其它"); |
|||
switch (formDTO.getLevel()) { |
|||
/** |
|||
* 社区级:community, |
|||
* 乡(镇、街道)级:street, |
|||
* 区县级: district, |
|||
* 市级: city |
|||
* 省级:province |
|||
*/ |
|||
case "province": |
|||
list = areaCodeDao.selectCityList(formDTO.getAreaCode()); |
|||
other.setLevel("city"); |
|||
break; |
|||
case "city": |
|||
list = areaCodeDao.selectDistrictList(formDTO.getAreaCode()); |
|||
other.setLevel("district"); |
|||
break; |
|||
case "district": |
|||
list = areaCodeDao.selectStreetList(formDTO.getAreaCode()); |
|||
other.setLevel("street"); |
|||
break; |
|||
case "street": |
|||
list = areaCodeDao.selectCommunityList(formDTO.getAreaCode()); |
|||
other.setLevel("community"); |
|||
break; |
|||
default: |
|||
} |
|||
if (CollectionUtils.isEmpty(list)) { |
|||
list = new ArrayList<>(); |
|||
} |
|||
if(!"province".equals(formDTO.getLevel())){ |
|||
list.add(other); |
|||
} |
|||
return list; |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.dataaggre.service.opercrm; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/13 10:38 |
|||
*/ |
|||
public interface CustomerRelation { |
|||
List<String> selectUsedAreaCodeList(String areaCode); |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.epmet.dataaggre.service.opercrm.impl; |
|||
|
|||
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|||
import com.epmet.dataaggre.constant.DataSourceConstant; |
|||
import com.epmet.dataaggre.dao.opercrm.CustomerRelationDao; |
|||
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/13 10:38 |
|||
*/ |
|||
@DataSource(DataSourceConstant.OPER_CRM) |
|||
@Slf4j |
|||
@Service |
|||
public class CustomerRelationImpl implements CustomerRelation { |
|||
@Autowired |
|||
private CustomerRelationDao customerRelationDao; |
|||
|
|||
@Override |
|||
public List<String> selectUsedAreaCodeList(String areaCode) { |
|||
return customerRelationDao.selectUsedAreaCodeList(areaCode); |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dataaggre.dao.commonservice.AreaCodeDao"> |
|||
|
|||
<select id="selectCityList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> |
|||
SELECT DISTINCT |
|||
ac.CITY_CODE AS areaCode, |
|||
ac.CITY_NAME AS areaName, |
|||
'city' LEVEL |
|||
FROM |
|||
area_code ac |
|||
WHERE |
|||
ac.DEL_FLAG='0' |
|||
and ac.PROVINCE_CODE = #{areaCode} |
|||
ORDER BY |
|||
ac.CITY_CODE ASC |
|||
</select> |
|||
|
|||
<select id="selectDistrictList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> |
|||
SELECT DISTINCT |
|||
ac.COUNTY_CODE AS areaCode, |
|||
ac.COUNTY_NAME AS areaName, |
|||
'district' LEVEL |
|||
FROM |
|||
area_code ac |
|||
WHERE ac.DEL_FLAG='0' |
|||
and ac.CITY_CODE = #{areaCode} |
|||
ORDER BY |
|||
ac.COUNTY_CODE ASC |
|||
</select> |
|||
|
|||
<select id="selectStreetList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> |
|||
SELECT DISTINCT CODE AS areaCode, |
|||
NAME AS areaName, |
|||
'street' AS LEVEL |
|||
FROM |
|||
area_code_child acc |
|||
WHERE |
|||
acc.DEL_FLAG = '0' |
|||
AND acc.P_CODE = #{areaCode} |
|||
order by acc.CODE ASC |
|||
</select> |
|||
|
|||
<select id="selectCommunityList" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO"> |
|||
SELECT DISTINCT CODE AS areaCode, |
|||
NAME AS areaName, |
|||
'community' AS LEVEL |
|||
FROM |
|||
area_code_child acc |
|||
WHERE |
|||
acc.DEL_FLAG = '0' |
|||
AND acc.P_CODE = #{areaCode} |
|||
ORDER BY |
|||
acc.CODE ASC |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,17 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dataaggre.dao.opercrm.CustomerRelationDao"> |
|||
|
|||
<select id="selectUsedAreaCodeList" parameterType="java.lang.String" resultType="java.lang.String"> |
|||
SELECT |
|||
cr.AREA_CODE |
|||
FROM |
|||
customer_relation cr |
|||
WHERE |
|||
cr.DEL_FLAG = '0' |
|||
and cr.CUSTOMER_TYPE='external' |
|||
AND cr.AREA_CODE LIKE concat(#{areaCode}, '%') |
|||
AND cr.AREA_CODE != #{areaCode} |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,18 @@ |
|||
package com.epmet.dto.topic; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* desc: |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2021/4/13 5:33 下午 |
|||
* @version: 1.0 |
|||
*/ |
|||
@Data |
|||
public class TopicAttachmentDTO { |
|||
|
|||
private Integer sort; |
|||
private String attachmentUrl; |
|||
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.epmet.dto.topic.result; |
|||
|
|||
import com.epmet.dto.topic.TopicAttachmentDTO; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author liujianjun |
|||
* @Description 组-话题对象 |
|||
* @ClassName ResiGroupTopicResultDTO |
|||
* @Auth wangc |
|||
* @Date 2020-06-20 17:23 |
|||
*/ |
|||
@Data |
|||
public class ResiTopicAndImgResultDTO implements Serializable { |
|||
|
|||
private String topicId; |
|||
private String topicContent; |
|||
|
|||
private List<TopicAttachmentDTO> topicImgList; |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
ALTER TABLE `fact_origin_project_main_daily` |
|||
ADD COLUMN `ORIGIN` varchar(32) NULL COMMENT '项目来源 来源:议题issue 组织agency' AFTER `AGENCY_ID`, |
|||
MODIFY COLUMN `GRID_ID` varchar(32) DEFAULT '' COMMENT '网格ID(立项时的网格Id)' AFTER `TOPIC_ID`, |
|||
ADD COLUMN `ORIGIN_ID` varchar(64) NULL COMMENT '项目来源ID' AFTER `ORIGIN`; |
|||
|
|||
UPDATE fact_origin_project_main_daily t1 |
|||
INNER JOIN ( SELECT ID, ISSUE_ID FROM fact_origin_project_main_daily ) t2 ON t1.ID = t2.ID |
|||
SET t1.ORIGIN = 'issue', |
|||
t1.ORIGIN_ID = t2.ISSUE_ID; |
|||
UPDATE fact_origin_project_log_daily t1 |
|||
INNER JOIN ( SELECT ID, AGENCY_ID FROM fact_origin_project_log_daily ) t2 ON t1.ID = t2.ID AND t1.ORG_TYPE IS NULL |
|||
SET t1.ORG_TYPE = 'agency', |
|||
t1.ORG_ID = t2.AGENCY_ID; |
@ -0,0 +1,27 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/4/13 14:36 |
|||
*/ |
|||
@Data |
|||
public class AddAreaCodeFormDTO implements Serializable { |
|||
|
|||
@NotBlank(message = "currentAreaLevel不能为空") |
|||
private String currentAreaLevel; |
|||
@NotBlank(message = "parentAreaCode不能为空") |
|||
private String parentAreaCode; |
|||
|
|||
/** |
|||
* 新增的街道或者社区名称 |
|||
*/ |
|||
@NotBlank(message = "name不能为空") |
|||
private String name; |
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue