loemkie 4 weeks ago
parent
commit
013a437f12

+ 19 - 1
pom.xml

@@ -443,6 +443,25 @@
             <version>3.5.1</version>
         </dependency>
     </dependencies>
+    <!--<build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>-->
     <build>
         <finalName>${project.artifactId}</finalName>
         <plugins>
@@ -477,5 +496,4 @@
             </plugin>
         </plugins>
     </build>
-
 </project>

File diff suppressed because it is too large
+ 358 - 0
sql/park_car_0226.sql


+ 1 - 2
src/main/java/com/qmrb/system/config/WebSocketConfig.java

@@ -2,11 +2,10 @@ package com.qmrb.system.config;
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.config.annotation.EnableWebSocket;
 import org.springframework.web.socket.server.standard.ServerEndpointExporter;
 
 @Configuration
-@EnableWebSocket
+//@EnableWebSocket
 public class WebSocketConfig {
 
     @Bean

+ 1 - 0
src/main/java/com/qmrb/system/controller/UserController.java

@@ -137,6 +137,7 @@ public class UserController extends CommonController {
                 userAuthInfo.setUsername(userInfo.getOpenId());
                 Set<String> roles = new HashSet<>();
                 roles.add("PARK_USER");
+                userAuthInfo.setRoles(roles);
                 userInfo.setAccessToken(getToken(userAuthInfo));
             }else{
                 userInfo.setId(userAuthInfo.getUserId().toString());

+ 5 - 4
src/main/java/com/qmrb/system/service/impl/UserServiceImpl.java

@@ -63,9 +63,9 @@ public class UserServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         Map hashMap = new HashMap();
         hashMap.put("appid", wxConfig.getAppId());
         hashMap.put("secret", wxConfig.getAppSecret());
-        hashMap.put("js_code", code);
+//        hashMap.put("js_code", code);
         hashMap.put("grant_type", "client_credential");
-        String json = HttpUtil.get(WxApiType.WX_LOGIN_URL.getValue(), hashMap);
+        String json = HttpUtil.get(WxApiType.WX_TOKEN.getValue(), hashMap);
         JSONObject jsonObject = JSONUtil.parseObj(json);
         log.info("json:{}",jsonObject);
         String access_token = jsonObject.getStr("access_token");
@@ -76,8 +76,9 @@ public class UserServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         String token =  getWxAccessToken(wxConfig, code);
         //获取当前的openid
         Map hashMap = new HashMap();
-        hashMap.put("access_token", token);
-        String json = HttpUtil.post(WxApiType.WX_LOGIN_URL.getValue(), hashMap);
+        hashMap.put("code", code);
+        String url = WxApiType.GET_MOBILE_URL.getValue()+"?access_token="+token;
+        String json = HttpUtil.post(url, hashMap);
         JSONObject jsonObject = JSONUtil.parseObj(json);
         log.info("json:{}",jsonObject);
         String access_token = jsonObject.getStr("access_token");

+ 322 - 0
src/main/java/com/qmrb/system/utils/HttpClient.java

@@ -0,0 +1,322 @@
+package com.qmrb.system.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.http.Consts;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.*;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.text.ParseException;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * http请求客户端
+ * 
+ * @author Administrator
+ * 
+ */
+public class HttpClient {
+	private String url;
+	private Map<String, String> param;
+	private int statusCode;
+	private String content;
+	private String xmlParam;
+	private boolean isHttps;
+
+	public boolean isHttps() {
+		return isHttps;
+	}
+
+	public void setHttps(boolean isHttps) {
+		this.isHttps = isHttps;
+	}
+
+	public String getXmlParam() {
+		return xmlParam;
+	}
+
+	public void setXmlParam(String xmlParam) {
+		this.xmlParam = xmlParam;
+	}
+
+	public HttpClient(String url, Map<String, String> param) {
+		this.url = url;
+		this.param = param;
+	}
+
+	public HttpClient(String url) {
+		this.url = url;
+	}
+
+	public void setParameter(Map<String, String> map) {
+		param = map;
+	}
+
+	public void addParameter(String key, String value) {
+		if (param == null)
+			param = new HashMap<String, String>();
+		param.put(key, value);
+	}
+
+	public void post() throws ClientProtocolException, IOException {
+		HttpPost http = new HttpPost(url);
+		setEntity(http);
+		execute(http);
+	}
+
+	public void put() throws ClientProtocolException, IOException {
+		HttpPut http = new HttpPut(url);
+		setEntity(http);
+		execute(http);
+	}
+
+	public void get() throws ClientProtocolException, IOException {
+		if (param != null) {
+			StringBuilder url = new StringBuilder(this.url);
+			boolean isFirst = true;
+			for (String key : param.keySet()) {
+				if (isFirst)
+					url.append("?");
+				else
+					url.append("&");
+				url.append(key).append("=").append(param.get(key));
+			}
+			this.url = url.toString();
+		}
+		HttpGet http = new HttpGet(url);
+		execute(http);
+	}
+
+	/**
+	 * set http post,put param
+	 */
+	private void setEntity(HttpEntityEnclosingRequestBase http) {
+		if (param != null) {
+			List<NameValuePair> nvps = new LinkedList<NameValuePair>();
+			for (String key : param.keySet())
+				nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数
+			http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数
+		}
+		if (xmlParam != null) {
+			http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));
+		}
+	}
+
+	private void execute(HttpUriRequest http) throws ClientProtocolException,
+			IOException {
+		CloseableHttpClient httpClient = null;
+		try {
+			if (isHttps) {
+				SSLContext sslContext = new SSLContextBuilder()
+						.loadTrustMaterial(null, new TrustStrategy() {
+							// 信任所有
+							public boolean isTrusted(X509Certificate[] chain,
+									String authType)
+									throws CertificateException {
+								return true;
+							}
+						}).build();
+				SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+						sslContext);
+				httpClient = HttpClients.custom().setSSLSocketFactory(sslsf)
+						.build();
+			} else {
+				httpClient = HttpClients.createDefault();
+			}
+			CloseableHttpResponse response = httpClient.execute(http);
+			try {
+				if (response != null) {
+					if (response.getStatusLine() != null)
+						statusCode = response.getStatusLine().getStatusCode();
+					HttpEntity entity = response.getEntity();
+					// 响应内容
+					content = EntityUtils.toString(entity, Consts.UTF_8);
+				}
+			} finally {
+				response.close();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			httpClient.close();
+		}
+	}
+
+	public int getStatusCode() {
+		return statusCode;
+	}
+
+	public String getContent() throws ParseException, IOException {
+		return content;
+	}
+
+	public static String getIPAddress(HttpServletRequest request) {
+		String ip = null;
+
+		//X-Forwarded-For:Squid 服务代理
+		String ipAddresses = request.getHeader("X-Forwarded-For");
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//Proxy-Client-IP:apache 服务代理
+			ipAddresses = request.getHeader("Proxy-Client-IP");
+		}
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//WL-Proxy-Client-IP:weblogic 服务代理
+			ipAddresses = request.getHeader("WL-Proxy-Client-IP");
+		}
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//HTTP_CLIENT_IP:有些代理服务器
+			ipAddresses = request.getHeader("HTTP_CLIENT_IP");
+		}
+
+		if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			//X-Real-IP:nginx服务代理
+			ipAddresses = request.getHeader("X-Real-IP");
+		}
+
+		//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
+		if (ipAddresses != null && ipAddresses.length() != 0) {
+			ip = ipAddresses.split(",")[0];
+		}
+
+		//还是不能获取到,最后再通过request.getRemoteAddr();获取
+		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
+			ip = request.getRemoteAddr();
+		}
+		return ip;
+	}
+
+	/**
+	 * 发起一个GET请求, 返回数据是以JSON格式返回
+	 * @param url
+	 * @return
+	 * @throws IOException
+	 */
+	public static JSONObject doGet(String url) throws IOException {
+		JSONObject jsonObject = null;
+		CloseableHttpClient client = HttpClients.createDefault();
+
+
+		HttpGet httpGet = new HttpGet(url);
+		HttpResponse response = client.execute(httpGet);
+		HttpEntity entity = response.getEntity();
+
+		if (entity != null) {
+			String result = EntityUtils.toString(entity, "UTF-8");
+			jsonObject = JSONObject.parseObject(result);
+		}
+
+		httpGet.releaseConnection();
+		return jsonObject;
+	}
+
+	/**
+	 * 发起一个POST请求, 返回数据是以JSON格式返回
+	 * @param params	请求参数
+	 * @param url
+	 * @param requestHeaders	请求头
+	 * @param parse	是否需要解析请求结果
+	 * @return
+	 * @throws IOException
+	 */
+	public static Object doPost(JSONObject params, String url, Map<String, String> requestHeaders, boolean parse) throws IOException {
+		JSONObject jsonObject = null;
+		CloseableHttpClient client = HttpClients.createDefault();
+
+		HttpPost httpPost = new HttpPost(url);
+		for (Map.Entry<String, String> entry: requestHeaders.entrySet()){
+			httpPost.setHeader(entry.getKey(), entry.getValue());
+		}
+
+		StringEntity postingString = new StringEntity(params.toString(),"utf-8");
+		httpPost.setEntity(postingString);
+		HttpResponse response = client.execute(httpPost);
+		HttpEntity entity = response.getEntity();
+		if (entity != null) {
+			if(parse){
+				String result = EntityUtils.toString(entity, "UTF-8");
+				jsonObject = JSONObject.parseObject(result);
+			}else{
+				InputStream content = response.getEntity().getContent();
+				byte[] bytes = toByteArray(content);
+				httpPost.releaseConnection();
+				return bytes;
+			}
+
+		}
+		httpPost.releaseConnection();
+		return jsonObject;
+	}
+
+	/**
+	 * 发起一个POST请求, 返回数据是以JSON格式返回
+	 * @param params	请求参数(给的是字符串)
+	 * @param url
+	 * @param requestHeaders	请求头
+	 * @param parse	是否需要解析请求结果
+	 * @return
+	 * @throws IOException
+	 */
+	public static Object doPostByString(String params, String url, Map<String, String> requestHeaders, boolean parse) throws IOException {
+		JSONObject jsonObject = null;
+		CloseableHttpClient client = HttpClients.createDefault();
+
+		HttpPost httpPost = new HttpPost(url);
+		for (Map.Entry<String, String> entry: requestHeaders.entrySet()){
+			httpPost.setHeader(entry.getKey(), entry.getValue());
+		}
+
+		StringEntity postingString = new StringEntity(params,"utf-8");
+		httpPost.setEntity(postingString);
+		HttpResponse response = client.execute(httpPost);
+		HttpEntity entity = response.getEntity();
+		if (entity != null) {
+			if(parse){
+				String result = EntityUtils.toString(entity, "UTF-8");
+				jsonObject = JSONObject.parseObject(result);
+			}else{
+				InputStream content = response.getEntity().getContent();
+				byte[] bytes = toByteArray(content);
+				httpPost.releaseConnection();
+				return bytes;
+			}
+
+		}
+		httpPost.releaseConnection();
+		return jsonObject;
+	}
+
+	public static byte[] toByteArray(InputStream input) throws IOException {
+		ByteArrayOutputStream output = new ByteArrayOutputStream();
+		byte[] buffer = new byte[1024*4];
+		int n = 0;
+		while (-1 != (n = input.read(buffer))) {
+			output.write(buffer, 0, n);
+		}
+		return output.toByteArray();
+	}
+
+}

+ 3 - 0
src/main/java/com/qmrb/system/wxpayback/Enum/WxApiType.java

@@ -8,6 +8,9 @@ package com.qmrb.system.wxpayback.Enum;
 public enum WxApiType {
 
     WX_LOGIN_URL ("https://api.weixin.qq.com/sns/jscode2session"),
+    WX_TOKEN ("https://api.weixin.qq.com/cgi-bin/token"),
+    GET_MOBILE_URL( "https://api.weixin.qq.com/wxa/business/getuserphonenumber"),
+
 
     /** 小程序 下单API */
     CREATE_ORDER("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"),

+ 0 - 28
src/main/resources/application-beans.xml

@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
-
-    <!-- Initialization for data source -->
-    <bean id="dataSourceMssql"
-          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-        <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
-        <property name="url" value="jdbc:sqlserver://192.0.33.230;DatabaseName=zsyydb;characterEncoding=utf8;userSSL=true;trustServerCertificate=true" />
-        <property name="username" value="mbzx" />
-        <property name="password" value="mbzx@2921" />
-    </bean>
-<!--    <bean id="dataSourceEmr"-->
-<!--          class="org.springframework.jdbc.datasource.DriverManagerDataSource">-->
-<!--        <property name="driverClassName" value="oracle.jdbc.OracleDriver" />-->
-<!--        <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" />-->
-<!--        <property name="username" value="ceshi" />-->
-<!--        <property name="password" value="ceshi@1234" />-->
-<!--    </bean>-->
-    <!-- Definition for studentJDBCTemplate bean -->
-    <bean id="commonJDBCTemplate" class="com.qmrb.system.common.proc.CommonJDBCTemplate">
-        <property name="dataSourceMssql" ref="dataSourceMssql" />
-    </bean>
-
-</beans>
-

+ 57 - 40
src/main/resources/application-prod.yml

@@ -1,15 +1,15 @@
 server:
-  port: 8989
+  port: 2203
 
 spring:
   main:
     allow-circular-references: true
-#  datasource:
-#    type: com.alibaba.druid.pool.DruidDataSource
-#    driver-class-name: com.mysql.cj.jdbc.Driver
-#    url: jdbc:mysql://192.10.33.120:3306/ca_sign?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true&useSSL=false
-#    username: root
-#    password: 3409git
+  #  datasource:
+  #    type: com.alibaba.druid.pool.DruidDataSource
+  #    driver-class-name: com.mysql.cj.jdbc.Driver
+  #    url: jdbc:mysql://192.10.33.120:3306/ca_sign?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true&useSSL=false
+  #    username: root
+  #    password: 3409git
   datasource:
     dynamic:
       primary: master
@@ -19,27 +19,17 @@ spring:
         master:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://192.10.33.120:3306/ca_sign?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true&useSSL=false
+          #          url: jdbc:mysql://192.168.2.21:3306/park_car?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true&useSSL=false
+          url: jdbc:mysql://127.0.0.1:3306/park_car?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true&useSSL=false
           username: root
-          password: 3409git
-        hissource:
-          type: com.alibaba.druid.pool.DruidDataSource
-          driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
-          url: jdbc:sqlserver://192.0.33.230:1433;DatabaseName=zsyydb;characterEncoding=UTF-8;userSSL=true;encrypt=true;trustServerCertificate=true
-          username: mbzx
-          password: mbzx@2921
-        emrsource:
-          type: com.alibaba.druid.pool.DruidDataSource
-          driver-class-name: oracle.jdbc.OracleDriver
-          url: jdbc:oracle:thin:@192.1.33.125:1521/jhemr
-          username: emr
-          password: Jhemr_2750
+          #          password: gentmysql123
+          password: qingbo#888My
   data:
     redis:
-      database: 6
+      database: 2
       host: 127.0.0.1
       port: 8379
-      password: "gitxm#redis"
+      password: gitxm#redis
       timeout: 10s
       lettuce:
         pool:
@@ -64,7 +54,6 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-
 logging:
   level:
     com.qmrb.system.mapper.mapper: debug
@@ -74,7 +63,7 @@ auth:
   token:
     secret_key: SecretKey012345678901234567890123456789012345678901234567890123456789
     # token 有效期(单位:秒)
-    ttl: 18000
+    ttl: 86400000
 
 # MinIO 分布式文件系统
 minio:
@@ -84,12 +73,14 @@ minio:
   # 存储桶名称
   bucket-name: default
   # 自定义域名(非必须),Nginx配置反向代理转发文件路径
-  custom-domain: https://oss.qmrb.tech
+  custom-domain:
 
-# 接口文档
+# springdoc配置: https://springdoc.org/properties.html
 springdoc:
   swagger-ui:
     enabled: true
+    operationsSorter: alpha
+    tags-sorter: alpha
   api-docs:
     enabled: true
 
@@ -124,18 +115,18 @@ system-config:
   data-permission:
     # 数据权限开关
     enabled: true
-    
+
 # 电子病历配置
-emr: 
+emr:
   # 电子病历图片上传
-  img-upload: 
-    # 图片上传路径    
+  img-upload:
+    # 图片上传路径
     file-path: /u01/ca_sign/img
     # 图片访问地址
-    file-url: https://etc.xmzsh.com/img/
+    file-url: http://localhost:9090/test/
 
 application:
-  soap-check: Y
+  soap-check: N
   default-dept-id: 5
   default-role-id: 13
   #登录校验
@@ -143,14 +134,15 @@ application:
   #登录二维码
   qr-url: http://192.0.33.91:8080/PKIQRCode/services/v1?wsdl
 
+
 config-setting:
   domain: http://meiqikeji.com
-  base-path: /u01/ca_sign
-  pdf-path: /pdf/emr
-
+  base-path: d:/u01/ca_sign
+  pdf-path: /pdf/ca_sign
 ca-sign:
-  domain: http://172.16.1.30
-  username: xmzsmbzx
+  domain: https://qy.jhsec.com.cn
+  #  domain:  http://172.16.1.30
+  username:  xmzsmbzx
   password: 385579956d67433689cc70a1628a3f09
   grant-type: password
   client-id: client
@@ -163,6 +155,31 @@ ca-sign:
   sign-domain: http://192.0.33.91:8080
   sys: qmrbETC
   wx-push-url: https://172.16.1.34
-  htemr-server: http://192.1.33.126
+  htemr-server: http://192.1.33.126:81
   rtms-server: http://192.0.33.104:8080
-  ocr-server: http://192.6.33.2:1224
+  ocr-server: http://192.6.33.2:1224
+
+wxpay:
+  #应用编号
+  appId: xxxxxxxxxxxxx
+
+  #商户号
+  mchId: xxxxxxxxxxxxx
+
+  # APIv3密钥
+  apiV3Key: xxxxxxxxxxxxx
+
+  # 支付通知回调, 本地测试内网穿透地址
+  notifyUrl: http://405c3382p5.goho.co:25325/wenbo-pay/notify/payNotify
+
+  # 退款通知回调,  本地测试内网穿透地址
+  refundNotifyUrl: http://405c3382p5.goho.co:25325/wenbo-pay/notify/refundNotify
+
+  # 密钥路径,resources根目录下
+  keyPemPath: apiclient_key.pem
+
+  # 商户证书序列号
+  serialNo: xxxxxxxxxxxxx
+
+  # 小程序密钥
+  appSecret: xxxxxxxxxxxxx

Some files were not shown because too many files changed in this diff