gaodm 5 rokov pred
rodič
commit
3625be8aa6

+ 7 - 7
zzcx-service/src/main/java/com/diagbot/aggregate/OptAggregate.java

@@ -33,24 +33,24 @@ public class OptAggregate {
             @DataConsumer("getUV") List<UVDTO> uvdtoList,
             @DataConsumer("getUVSum") Long uvSum,
             @DataConsumer("getZZ") List<ZZDTO> zzdtoList,
-            @DataConsumer("getZZSum") Long zzSum){
+            @DataConsumer("getZZSum") Long zzSum) {
         OptDTO optDTO = new OptDTO();
-        if(ListUtil.isNotEmpty(pvdtoList)){
+        if (ListUtil.isNotEmpty(pvdtoList)) {
             optDTO.setPvdto(pvdtoList);
         }
-        if (null != pvSum){
+        if (null != pvSum) {
             optDTO.setPvSum(pvSum);
         }
-        if(ListUtil.isNotEmpty(uvdtoList)){
+        if (ListUtil.isNotEmpty(uvdtoList)) {
             optDTO.setUvdto(uvdtoList);
         }
-        if (null != uvSum){
+        if (null != uvSum) {
             optDTO.setUvSum(uvSum);
         }
-        if(ListUtil.isNotEmpty(zzdtoList)){
+        if (ListUtil.isNotEmpty(zzdtoList)) {
             optDTO.setZzdto(zzdtoList);
         }
-        if (null != zzSum){
+        if (null != zzSum) {
             optDTO.setZzSum(zzSum);
         }
         return optDTO;

+ 0 - 67
zzcx-service/src/main/java/com/diagbot/entity/Client.java

@@ -1,67 +0,0 @@
-
-package com.diagbot.entity;
-
-import com.diagbot.util.AESUtils;
-import com.diagbot.util.JSONUtils;
-import com.diagbot.util.MessageDigestUtil;
-import com.diagbot.util.OpenApiUtils;
-import com.diagbot.util.SignUtil;
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.UUID;
-
-/**
- * Client
- */
-public class Client {
-
-    private String apiUrl;
-    private String appKey;
-    private String appSecret;
-    private String encodingAesKey;
-
-    public Client(String apiUrl, String appKey, String appSecret, String encodingAesKey) {
-        this.apiUrl = apiUrl;
-        this.appKey = appKey;
-        this.appSecret = appSecret;
-        this.encodingAesKey = encodingAesKey;
-    }
-
-    /**
-     * 发送请求
-     *
-     * @param request request对象
-     * @return Response
-     * @throws Exception
-     */
-    public Response execute(Request request) throws Exception {
-        request.setApiUrl(this.apiUrl);
-        request.setAppKey(this.appKey);
-        request.setAppSecret(this.appSecret);
-        request.setEncodingAesKey(this.encodingAesKey);
-        request.addHeader(SystemHeader.X_CA_KEY, request.getAppKey());
-        request.addHeader(SystemHeader.X_CA_NONCE, UUID.randomUUID().toString());
-        request.addHeader(SystemHeader.X_CA_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
-        String jsonStr = JSONUtils.toString(request.getBodys());
-        String encryptStr;
-        if (StringUtils.isNotEmpty(request.getEncodingAesKey())) {
-            encryptStr = AESUtils.encrypt(jsonStr, request.getEncodingAesKey());
-        } else {
-            encryptStr = jsonStr;
-        }
-        String contentMd5 = MessageDigestUtil.base64AndMD5(encryptStr);
-        request.addHeader(SystemHeader.X_CONTENT_MD5, contentMd5);
-        String signature = SignUtil.sign(request.getAppSecret(), request.getHeaders());
-        request.addHeader(SystemHeader.X_CA_SIGNATURE, signature);
-        request.setStringBody(encryptStr);
-        return OpenApiUtils.post(request);
-    }
-
-    public static void main(String[] args) throws Exception {
-        String body = "[1]";
-        String encryptStr = AESUtils.encrypt(body, "1234567890123456");
-        String contentMd5 = MessageDigestUtil.base64AndMD5(encryptStr.getBytes());
-        System.out.println(contentMd5);
-
-    }
-}

+ 0 - 47
zzcx-service/src/main/java/com/diagbot/entity/Constants.java

@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.diagbot.entity;
-
-/**
- * 通用常量
- */
-public class Constants {
-    //签名算法HmacSha256
-    public static final String HMAC_SHA256 = "HmacSHA256";
-    //编码UTF-8
-    public static final String ENCODING = "UTF-8";
-    //UserAgent
-    public static final String USER_AGENT = "demo/aliyun/java";
-    //换行符
-    public static final String LF = "\n";
-    //串联符
-    public static final String SPE1 = ",";
-    //示意符
-    public static final String SPE2 = ":";
-    //连接符
-    public static final String SPE3 = "&";
-    //赋值符
-    public static final String SPE4 = "=";
-    //问号符
-    public static final String SPE5 = "?";
-    //默认请求超时时间,单位毫秒
-    public static final int DEFAULT_TIMEOUT = 1000;
-    //参与签名的系统Header前缀,只有指定前缀的Header才会参与到签名中
-    public static final String CA_HEADER_TO_SIGN_PREFIX_SYSTEM = "X-Ca-";
-}

+ 0 - 53
zzcx-service/src/main/java/com/diagbot/entity/JSONResponseBean.java

@@ -1,53 +0,0 @@
-package com.diagbot.entity;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class JSONResponseBean {
-	private int code = 200;
-	private String msg;
-	private Object body;
-	private Map<String, Object> properties;
-	
-	public int getCode() {
-		return code;
-	}
-	
-	public void setCode(int code) {
-		this.code = code;
-	}
-	
-	public String getMsg() {
-		return msg;
-	}
-	
-	public void setMsg(String msg) {
-		this.msg = msg;
-	}
-	
-	public Object getBody() {
-		return body;
-	}
-	
-	public void setBody(Object body) {
-		this.body = body;
-	}
-	
-	public Map<String, Object> getProperties() {
-		return properties;
-	}
-	
-	public Object getProperty(String nm){
-		if(properties == null || properties.isEmpty()){
-			return null;
-		}
-		return properties.get(nm);
-	}
-	
-	public void setProperty(String name, Object val){
-		if(properties == null){
-			properties = new HashMap<>();
-		}
-		properties.put(name, val);
-	}
-}

+ 0 - 142
zzcx-service/src/main/java/com/diagbot/entity/Request.java

@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.diagbot.entity;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Request
- */
-public class Request {
-
-    public Request() {
-    }
-
-    public Request(String serviceId, String method, List<Object> bodys) {
-        this.appKey = appKey;
-        this.appSecret = appSecret;
-        this.bodys=bodys;
-        headers = new HashMap<>();
-        headers.put(SystemHeader.X_CA_KEY, appKey);
-        headers.put(SystemHeader.X_SERVICE_ID, serviceId);
-        headers.put(SystemHeader.X_SERVICE_METHOD, method);
-    }
-    /**
-     * (必选)服务请求地址
-     */
-    private String apiUrl;
-
-
-
-    /**
-     * (必选)APP KEY
-     */
-    private String appKey;
-
-    /**
-     * (必选)APP密钥
-     */
-    private String appSecret;
-
-    private String encodingAesKey;
-
-
-    /**
-     * (必选) HTTP头
-     */
-    private Map<String, String> headers;
-    
-
-
-    /**
-     * (必选)请求参数
-     */
-    private List<Object> bodys;
-
-    /**
-     * (可选)字符串Body体
-     */
-    private String stringBody;
-
-
-    public String getAppKey() {
-        return appKey;
-    }
-
-    public void setAppKey(String appKey) {
-        this.appKey = appKey;
-    }
-
-    public String getAppSecret() {
-        return appSecret;
-    }
-
-    public void setAppSecret(String appSecret) {
-        this.appSecret = appSecret;
-    }
-
-
-    public Map<String, String> getHeaders() {
-        return headers;
-    }
-
-    public void setHeaders(Map<String, String> headers) {
-        this.headers = headers;
-    }
-
-    public List<Object> getBodys() {
-        return bodys;
-    }
-
-    public void setBodys(List<Object> bodys) {
-        this.bodys = bodys;
-    }
-
-    public String getStringBody() {
-        return stringBody;
-    }
-
-    public void setStringBody(String stringBody) {
-        this.stringBody = stringBody;
-    }
-
-    public String getEncodingAesKey() {
-        return encodingAesKey;
-    }
-
-    public void setEncodingAesKey(String encodingAesKey) {
-        this.encodingAesKey = encodingAesKey;
-    }
-
-    public String getApiUrl() {
-        return apiUrl;
-    }
-
-    public void setApiUrl(String apiUrl) {
-        this.apiUrl = apiUrl;
-    }
-    public void addHeader(String name, String value){
-        if(headers==null){
-            headers = new HashMap<>();
-        }
-        headers.put(name, value);
-    }
-}

+ 0 - 120
zzcx-service/src/main/java/com/diagbot/entity/Response.java

@@ -1,120 +0,0 @@
-package com.diagbot.entity;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Response {
-    /**
-     * http 请求状态码
-     */
-    private int statusCode;
-    private String contentType;
-    /**
-     * 请求唯一 ID,请求一旦进入 API 网关应用后,API 网关就会生成请求 ID 并通过响应头返回给客户端,
-     * 建议客户端与后端服务都记录此请求 ID,可用于问题排查与跟踪。
-     */
-    private String requestId;
-    /**
-     * API网关会将服务端的StringToSign放到HTTP应答的Header中返回到客户端,Key为:X-Ca-Error-Message
-     * 只需要将本地计算的StringToSign与服务端返回的StringToSign进行对比即可找到问题;
-     * 如果服务端与客户端的签名串是一致的,请检查用于签名计算的密钥是否正确;
-     */
-    private String caErrorMsg;
-    /**
-     * 业务接口返回的错误信息
-     */
-    private String errorMessage;
-    private Map<String, String> headers;
-    private String body;
-    private JSONResponseBean jsonResponseBean;
-
-    public boolean isSuccess() {
-        return (200 == statusCode && jsonResponseBean != null && 200 == jsonResponseBean.getCode());
-    }
-
-    public Response() {
-
-    }
-
-    public int getStatusCode() {
-        return statusCode;
-    }
-
-    public void setStatusCode(int statusCode) {
-        this.statusCode = statusCode;
-    }
-
-    public String getContentType() {
-        return contentType;
-    }
-
-    public void setContentType(String contentType) {
-        this.contentType = contentType;
-    }
-
-    public String getRequestId() {
-        return requestId;
-    }
-
-    public void setRequestId(String requestId) {
-        this.requestId = requestId;
-    }
-
-    public String getErrorMessage() {
-        if (jsonResponseBean != null && !"200".equals(jsonResponseBean.getCode())) {
-            return jsonResponseBean.getMsg();
-        }
-        return null;
-    }
-
-    public void setErrorMessage(String errorMessage) {
-        this.errorMessage = errorMessage;
-    }
-
-    public Map<String, String> getHeaders() {
-        return headers;
-    }
-
-    public String getHeader(String key) {
-        if (null != headers) {
-            return headers.get(key);
-        } else {
-            return null;
-        }
-    }
-
-    public void setHeaders(Map<String, String> headers) {
-        this.headers = headers;
-    }
-
-    public void setHeader(String key, String value) {
-        if (null == this.headers) {
-            this.headers = new HashMap<String, String>();
-        }
-        this.headers.put(key, value);
-    }
-
-    public String getBody() {
-        return body;
-    }
-
-    public void setBody(String body) {
-        this.body = body;
-    }
-
-    public JSONResponseBean getJsonResponseBean() {
-        return jsonResponseBean;
-    }
-
-    public void setJsonResponseBean(JSONResponseBean jsonResponseBean) {
-        this.jsonResponseBean = jsonResponseBean;
-    }
-
-    public String getCaErrorMsg() {
-        return caErrorMsg;
-    }
-
-    public void setCaErrorMsg(String caErrorMsg) {
-        this.caErrorMsg = caErrorMsg;
-    }
-}

+ 0 - 29
zzcx-service/src/main/java/com/diagbot/entity/SystemHeader.java

@@ -1,29 +0,0 @@
-
-package com.diagbot.entity;
-
-/**
- * 系统HTTP头常量
- */
-public class SystemHeader {
-    //签名Header
-    public static final String X_CA_SIGNATURE = "X-Ca-Signature";
-    //所有参与签名的Header
-    public static final String X_CA_SIGNATURE_HEADERS = "X-Ca-Signature-Headers";
-    //请求时间戳
-    public static final String X_CA_TIMESTAMP = "X-Ca-Timestamp";
-    //请求放重放Nonce,15分钟内保持唯一,建议使用UUID
-    public static final String X_CA_NONCE = "X-Ca-Nonce";
-    //APP KEY
-    public static final String X_CA_KEY = "X-Ca-Key";
-    //服务id
-    public static final String X_SERVICE_ID = "X-Service-Id";
-    //具体method
-    public static final String X_SERVICE_METHOD = "X-Service-Method";
-    //MD5加密的请求体信息
-    public static final String X_CONTENT_MD5 = "X-Content-MD5";
-
-    //MD5加密的请求体信息
-    public static final String X_CA_REQUESTID = "X-Ca-RequestId";
-    //API网关会将服务端的StringToSign放到HTTP应答的Header中返回到客户端,Key为:X-Ca-Error-Message
-    public static final String X_CA_ERROR_MESSAGE = "X-Ca-Error-Message";
-}

+ 0 - 142
zzcx-service/src/main/java/com/diagbot/entity/User.java

@@ -1,142 +0,0 @@
-package com.diagbot.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * <p>
- * 系统用户表
- * </p>
- *
- * @author gaodm
- * @since 2018-08-30
- */
-@TableName("sys_user")
-public class User implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 用户ID
-     */
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 是否删除,N:未删除,Y:删除
-     */
-    private String isDeleted;
-
-    /**
-     * 记录创建时间
-     */
-    private Date gmtCreate;
-
-    /**
-     * 记录修改时间,如果时间是1970年则表示纪录未修改
-     */
-    private Date gmtModified;
-
-    /**
-     * 创建人,0表示无创建人值
-     */
-    private String creator;
-
-    /**
-     * 修改人,如果为0则表示纪录未修改
-     */
-    private String modifier;
-
-    /**
-     * 用户密码
-     */
-    private String password;
-
-    /**
-     * 用户名
-     */
-    private String username;
-
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getIsDeleted() {
-        return isDeleted;
-    }
-
-    public void setIsDeleted(String isDeleted) {
-        this.isDeleted = isDeleted;
-    }
-
-    public Date getGmtCreate() {
-        return gmtCreate;
-    }
-
-    public void setGmtCreate(Date gmtCreate) {
-        this.gmtCreate = gmtCreate;
-    }
-
-    public Date getGmtModified() {
-        return gmtModified;
-    }
-
-    public void setGmtModified(Date gmtModified) {
-        this.gmtModified = gmtModified;
-    }
-
-    public String getCreator() {
-        return creator;
-    }
-
-    public void setCreator(String creator) {
-        this.creator = creator;
-    }
-
-    public String getModifier() {
-        return modifier;
-    }
-
-    public void setModifier(String modifier) {
-        this.modifier = modifier;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    @Override
-    public String toString() {
-        return "User{" +
-                "id=" + id +
-                ", isDeleted=" + isDeleted +
-                ", gmtCreate=" + gmtCreate +
-                ", gmtModified=" + gmtModified +
-                ", creator=" + creator +
-                ", modifier=" + modifier +
-                ", password=" + password +
-                ", username=" + username +
-                "}";
-    }
-}

+ 0 - 12
zzcx-service/src/main/java/com/diagbot/facade/InquiryInfoFacade.java

@@ -1,31 +1,19 @@
 package com.diagbot.facade;
 
-import com.diagbot.dto.SaveInquiryDTO;
-import com.diagbot.entity.Client;
 import com.diagbot.entity.InquiryDetail;
 import com.diagbot.entity.InquiryInfo;
-import com.diagbot.entity.JSONResponseBean;
-import com.diagbot.entity.Request;
-import com.diagbot.entity.Response;
-import com.diagbot.exception.CommonErrorCode;
-import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.InquiryDetailServiceImpl;
 import com.diagbot.service.impl.InquiryInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.HttpUtils;
-import com.diagbot.util.StringUtil;
 import com.diagbot.vo.SaveInquiryVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description:

+ 7 - 7
zzcx-service/src/main/java/com/diagbot/facade/OptInfoFacade.java

@@ -57,18 +57,18 @@ public class OptInfoFacade extends OptInfoServiceImpl {
 
         try {
             Map<String, Object> invokeParams = new HashMap<>();
-            invokeParams.put("optVO",optVO);
+            invokeParams.put("optVO", optVO);
             optDTO
                     = dataBeanAggregateQueryFacade.get("getAllOptSum", invokeParams, OptDTO.class);
         } catch (Exception e) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
         }
-//        optDTO.setPvdto(this.getPV(optVO));
-//        optDTO.setPvSum(this.getPVSum(optVO));
-//        optDTO.setUvdto(this.getUV(optVO));
-//        optDTO.setUvSum(this.getUVSum(optVO));
-//        optDTO.setZzdto(this.getZZ(optVO));
-//        optDTO.setZzSum(this.getZZSum(optVO));
+        //        optDTO.setPvdto(this.getPV(optVO));
+        //        optDTO.setPvSum(this.getPVSum(optVO));
+        //        optDTO.setUvdto(this.getUV(optVO));
+        //        optDTO.setUvSum(this.getUVSum(optVO));
+        //        optDTO.setZzdto(this.getZZ(optVO));
+        //        optDTO.setZzSum(this.getZZSum(optVO));
         return optDTO;
     }
 }

+ 0 - 95
zzcx-service/src/main/java/com/diagbot/util/AESUtils.java

@@ -1,95 +0,0 @@
-package com.diagbot.util;
-
-import com.diagbot.entity.Constants;
-import org.apache.commons.codec.binary.Base64;
-
-import javax.crypto.Cipher;
-import javax.crypto.KeyGenerator;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-import java.security.Key;
-
-public class AESUtils {
-
-    private static final String KEY_ALGORITHM = "AES";
-    private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
-
-    public static byte[] initSecretKey() throws Exception {
-        KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM);
-        kg.init(128);
-        SecretKey secretKey = kg.generateKey();
-
-        return secretKey.getEncoded();
-    }
-
-    public static Key toKey(byte[] key) {
-        return new SecretKeySpec(key, KEY_ALGORITHM);
-    }
-
-    public static String encrypt(String data, String key) throws Exception {
-        return Base64.encodeBase64String(encrypt(data.getBytes(Constants.ENCODING), toKey(key.getBytes()), DEFAULT_CIPHER_ALGORITHM));
-    }
-
-    public static String decrypt(String data, String key) throws Exception {
-        return new String(decrypt(Base64.decodeBase64(data.getBytes(Constants.ENCODING)), toKey(key.getBytes()), DEFAULT_CIPHER_ALGORITHM));
-    }
-
-    public static byte[] encrypt(byte[] data, Key key) throws Exception {
-        return encrypt(data, key, DEFAULT_CIPHER_ALGORITHM);
-    }
-
-    public static byte[] encrypt(byte[] data, byte[] key) throws Exception {
-        return encrypt(data, toKey(key), DEFAULT_CIPHER_ALGORITHM);
-    }
-
-    public static byte[] encrypt(byte[] data, Key key, String cipherAlgorithm) throws Exception {
-        Cipher cipher = Cipher.getInstance(cipherAlgorithm);
-        cipher.init(Cipher.ENCRYPT_MODE, key);
-        return cipher.doFinal(data);
-    }
-
-    public static byte[] decrypt(byte[] data, byte[] key) throws Exception {
-        return decrypt(data, key, DEFAULT_CIPHER_ALGORITHM);
-    }
-
-    public static byte[] decrypt(byte[] data, Key key) throws Exception {
-        return decrypt(data, key, DEFAULT_CIPHER_ALGORITHM);
-    }
-
-    public static byte[] decrypt(byte[] data, byte[] key, String cipherAlgorithm) throws Exception {
-        Key k = toKey(key);
-        return decrypt(data, k, cipherAlgorithm);
-    }
-
-    public static byte[] decrypt(byte[] data, Key key, String cipherAlgorithm) throws Exception {
-        Cipher cipher = Cipher.getInstance(cipherAlgorithm);
-        cipher.init(Cipher.DECRYPT_MODE, key);
-        return cipher.doFinal(data);
-    }
-
-    private static String showByteArray(byte[] data) {
-        if (null == data) {
-            return null;
-        }
-        StringBuilder sb = new StringBuilder("{");
-        for (byte b : data) {
-            sb.append(b).append(",");
-        }
-        sb.deleteCharAt(sb.length() - 1);
-        sb.append("}");
-        return sb.toString();
-    }
-
-
-    public static void main(String[] args) throws Exception {
-        String original = "[1]";
-        String key = "1234567890123456";
-        System.out.println("original: " + original);
-        String encrypt = encrypt(original, key);
-        System.out.println("encrypt: " + encrypt + ", key: " + key);
-        String decrypt = decrypt(encrypt, key);
-        System.out.println("decrypt: " + decrypt);
-
-    }
-
-}

+ 0 - 71
zzcx-service/src/main/java/com/diagbot/util/Demo.java

@@ -1,71 +0,0 @@
-package com.diagbot.util;
-
-import com.diagbot.entity.Client;
-import com.diagbot.entity.JSONResponseBean;
-import com.diagbot.entity.Request;
-import com.diagbot.entity.Response;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class Demo {
-
-    public static void main(String[] args) throws Exception {
-        //必填 apiUrl
-        String apiUrl = "http://116.62.170.131:8096/openapi-devtest/gateway";
-        //必填
-        String appKey = "ngari5e34e52511dc394f";
-        //必填
-        String appSecret = "11dc394fc05518c1";
-        //如果开启加密,则必填
-        String encodingAesKey = "";
-        Client client = new Client(apiUrl, appKey, appSecret, encodingAesKey);
-
-        //调用相应的接口请求
-        Response response = client.execute(getltcs());
-//        System.out.println(JSONUtils.toString(response));
-        if (response.isSuccess()) {
-            //接口返回的结果
-            JSONResponseBean result = response.getJsonResponseBean();
-//            System.out.println(JSONUtils.toString(result));
-            System.out.println(result.getBody().toString());
-
-        } else {
-            System.out.println(response.getCaErrorMsg());
-            System.out.println(response.getErrorMessage());
-        }
-
-    }
-
-    public static Request getltcs() {
-        //入参赋值,注意最外层是个json数组
-        List bodyList = new ArrayList<>();
-
-        List<Map<String, Object>> details = new ArrayList<>();
-        Map<String, Object> detail1 = new HashMap<>();
-        detail1.put("question", "问题1");
-        detail1.put("answer", "答案1");
-        Map<String, Object> detail2 = new HashMap<>();
-        detail2.put("question", "问题2");
-        detail2.put("answer", "答案2");
-        details.add(detail1);
-        details.add(detail2);
-
-        Map<String, Object> body = new HashMap<>();
-        body.put("details", details);
-        body.put("doctorId", 1182);
-        body.put("mpiId", "2c90818958b4f5f10158b50289020001");
-        body.put("appId", "wx6a80dd109228fd4b");
-        body.put("diagnosis", "Summary");
-
-        bodyList.add(body);
-
-        //X-Service-Id对应的值
-        String serviceId = "consult.questionRecordService";
-        //X-Service-Method对应的值
-        String method = "saveQuestionRecord";
-        return new Request(serviceId, method, bodyList);
-    }
-}

+ 0 - 139
zzcx-service/src/main/java/com/diagbot/util/JSONUtils.java

@@ -1,139 +0,0 @@
-package com.diagbot.util;
-
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.text.SimpleDateFormat;
-
-public class JSONUtils {
-	private static ObjectMapper mapper =  new ObjectMapper();
-
-	static{
-		mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
-		mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
-		mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
-
-		mapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING,true);
-		mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
-		mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
-		mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-		mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
-
-	}
-
-	public static <T> T parse(String value, Class<T> clz){
-
-		if (StringUtils.isEmpty(value)) {
-			return null;
-		}
-		try {
-			return mapper.readValue(value, clz);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	public static <T> T parse(byte[] bytes, Class<T> clz){
-		try {
-			return mapper.readValue(bytes, clz);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-
-	public static <T> T parse(InputStream ins, Class<T> clz){
-		try {
-			return mapper.readValue(ins, clz);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-
-	public static <T> T  parse(Reader reader, Class<T> clz){
-		try {
-			return mapper.readValue(reader, clz);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	@SuppressWarnings("unchecked")
-	public static <T> T update(String value, T object) {
-		try {
-			return (T) mapper.readerForUpdating(object).readValue(value);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	public static String writeValueAsString(Object o){
-		try {
-			return mapper.writeValueAsString(o);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	public static void write(OutputStream outs, Object o){
-		try {
-			mapper.writeValue(outs,o);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-    }
-
-	public static void write(Writer writer, Object o){
-		try {
-			mapper.writeValue(writer,o);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	public static String toString(Object o){
-		try {
-			return mapper.writeValueAsString(o);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	public static String toString(Object o, Class<?> clz){
-		try {
-			return mapper.writerFor(clz).writeValueAsString(o);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-	public static byte[] toBytes(Object o){
-		try {
-			return mapper.writeValueAsBytes(o);
-		}
-		catch (Exception e) {
-			throw new IllegalStateException(e);
-		}
-	}
-
-}

+ 0 - 118
zzcx-service/src/main/java/com/diagbot/util/MessageDigestUtil.java

@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.diagbot.util;
-
-import com.diagbot.entity.Constants;
-import org.apache.commons.codec.binary.Base64;
-
-import java.io.UnsupportedEncodingException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * 消息摘要工具
- */
-public class MessageDigestUtil {
-    /**
-     * 先进行MD5摘要再进行Base64编码获取摘要字符串
-     *
-     * @param str
-     * @return
-     */
-    public static String base64AndMD5(String str) {
-        if (str == null) {
-            throw new IllegalArgumentException("inStr can not be null");
-        }
-        return base64AndMD5(toBytes(str));
-    }
-
-    /**
-     * 先进行MD5摘要再进行Base64编码获取摘要字符串
-     *
-     * @return
-     */
-    public static String base64AndMD5(byte[] bytes) {
-        if (bytes == null) {
-            throw new IllegalArgumentException("bytes can not be null");
-        }
-        try {
-            final MessageDigest md = MessageDigest.getInstance("MD5");
-            md.reset();
-            md.update(bytes);
-            final Base64 base64 = new Base64();
-            final byte[] enbytes = base64.encode(md.digest());
-            return new String(enbytes);
-        } catch (final NoSuchAlgorithmException e) {
-            throw new IllegalArgumentException("unknown algorithm MD5");
-        }
-    }
-
-    /**
-     * UTF-8编码转换为ISO-9959-1
-     *
-     * @param str
-     * @return
-     */
-    public static String utf8ToIso88591(String str) {
-        if (str == null) {
-            return str;
-        }
-
-        try {
-            return new String(str.getBytes("UTF-8"), "ISO-8859-1");
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * ISO-9959-1编码转换为UTF-8
-     *
-     * @param str
-     * @return
-     */
-    public static String iso88591ToUtf8(String str) {
-        if (str == null) {
-            return str;
-        }
-
-        try {
-            return new String(str.getBytes("ISO-8859-1"), "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * String转换为字节数组
-     *
-     * @param str
-     * @return
-     */
-    private static byte[] toBytes(final String str) {
-        if (str == null) {
-            return null;
-        }
-        try {
-            return str.getBytes(Constants.ENCODING);
-        } catch (final UnsupportedEncodingException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
-    }
-}

+ 0 - 118
zzcx-service/src/main/java/com/diagbot/util/OpenApiUtils.java

@@ -1,118 +0,0 @@
-package com.diagbot.util;
-
-import com.diagbot.entity.JSONResponseBean;
-import com.diagbot.entity.Request;
-import com.diagbot.entity.Response;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.util.EntityUtils;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.X509Certificate;
-import java.util.Map;
-
-public class OpenApiUtils {
-    public static Response post(Request request) throws Exception {
-        return convert(doPost(request));
-    }
-
-    /**
-     * post form
-     *
-     * @param request
-     * @return
-     * @throws Exception
-     */
-    private static HttpResponse doPost(Request request)
-            throws Exception {
-        HttpClient httpClient = wrapClient(request.getApiUrl());
-
-        HttpPost httpPost = new HttpPost(request.getApiUrl());
-        for (Map.Entry<String, String> e : request.getHeaders().entrySet()) {
-            httpPost.addHeader(e.getKey(), e.getValue());
-        }
-        if (request.getBodys() != null || StringUtils.isNotEmpty(request.getStringBody())) {
-            if (StringUtils.isNotEmpty(request.getStringBody())) {
-                httpPost.setEntity(new StringEntity(request.getStringBody(), ContentType.APPLICATION_JSON));
-            } else {
-                httpPost.setEntity(new StringEntity(JSONUtils.toString(request.getBodys()), ContentType.APPLICATION_JSON));
-            }
-        }
-        return httpClient.execute(httpPost);
-    }
-
-    private static HttpClient wrapClient(String host) {
-        HttpClient httpClient = new DefaultHttpClient();
-        if (host.startsWith("https://")) {
-            sslClient(httpClient);
-        }
-        return httpClient;
-    }
-
-    private static void sslClient(HttpClient httpClient) {
-        try {
-            SSLContext ctx = SSLContext.getInstance("TLS");
-            X509TrustManager tm = new X509TrustManager() {
-                public X509Certificate[] getAcceptedIssuers() {
-                    return null;
-                }
-
-                public void checkClientTrusted(X509Certificate[] xcs, String str) {
-
-                }
-
-                public void checkServerTrusted(X509Certificate[] xcs, String str) {
-
-                }
-            };
-            ctx.init(null, new TrustManager[] { tm }, null);
-            SSLSocketFactory ssf = new SSLSocketFactory(ctx);
-            ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-            ClientConnectionManager ccm = httpClient.getConnectionManager();
-            SchemeRegistry registry = ccm.getSchemeRegistry();
-            registry.register(new Scheme("https", 443, ssf));
-        } catch (KeyManagementException ex) {
-            throw new RuntimeException(ex);
-        } catch (NoSuchAlgorithmException ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    private static Response convert(HttpResponse response) throws IOException {
-        Response res = new Response();
-
-        if (null != response) {
-            res.setStatusCode(response.getStatusLine().getStatusCode());
-            for (Header header : response.getAllHeaders()) {
-                res.setHeader(header.getName(), MessageDigestUtil.iso88591ToUtf8(header.getValue()));
-            }
-            res.setContentType(res.getHeader("Content-Type"));
-            res.setRequestId(res.getHeader("X-Ca-Request-Id"));
-            res.setBody(EntityUtils.toString(response.getEntity()));
-            res.setJsonResponseBean(JSONUtils.parse(res.getBody(), JSONResponseBean.class));
-            res.setCaErrorMsg(res.getHeader("X-Ca-Error-Message"));
-
-        } else {
-            //服务器无回应
-            res.setStatusCode(500);
-            res.setErrorMessage("No Response");
-        }
-
-        return res;
-    }
-}

+ 0 - 126
zzcx-service/src/main/java/com/diagbot/util/SignUtil.java

@@ -1,126 +0,0 @@
-
-package com.diagbot.util;
-
-
-import com.diagbot.entity.Constants;
-import com.diagbot.entity.SystemHeader;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.UUID;
-
-/**
- * 签名工具
- */
-public class SignUtil {
-    /**
-     * 需要参与签名的请求头
-     */
-    private static final List<String> SIGN_HEADER_LIST = Arrays.asList("X-Service-Id","X-Service-Method","X-Ca-Key",
-            "X-Ca-Nonce","X-Ca-Timestamp","X-Content-MD5");
-    /**
-     * 计算签名
-     *
-     * @param secret APP密钥
-     * @param headers 请求头参数
-     * @return 签名后的字符串
-     */
-    public static String sign(String secret,
-                              Map<String, String> headers) {
-        try {
-            Mac hmacSha256 = Mac.getInstance(Constants.HMAC_SHA256);
-            byte[] keyBytes = secret.getBytes(Constants.ENCODING);
-            hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, Constants.HMAC_SHA256));
-//            String contentMd5 = MessageDigestUtil.base64AndMD5(bodyContent);
-
-            return new String(Base64.encodeBase64(
-                    hmacSha256.doFinal((buildHeaders(headers, SIGN_HEADER_LIST))
-                            .getBytes(Constants.ENCODING))),
-                    Constants.ENCODING);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * 构建待签名Http头
-     *
-     * @param headers 请求中所有的Http头
-     * @param signHeaderList 自定义参与签名Header前缀
-     * @return 待签名Http头
-     */
-    public static String buildHeaders(Map<String, String> headers, List<String> signHeaderList) {
-
-    	List<String> sbList=new ArrayList<>();
-    	if (null != signHeaderList) {
-    		Collections.sort(signHeaderList);
-    		if (null != headers) {
-    			Map<String, String> sortMap = new TreeMap<String, String>();
-    			sortMap.putAll(headers);
-    			StringBuilder signHeadersStringBuilder = new StringBuilder();
-    			for (Map.Entry<String, String> header : sortMap.entrySet()) {
-                    if (isHeaderToSign(header.getKey(), signHeaderList)) {
-                        StringBuilder sb = new StringBuilder();
-                    	sb.append(header.getKey().toLowerCase());
-                    	sb.append(Constants.SPE2);
-                        if (!StringUtils.isBlank(header.getValue())) {
-                        	sb.append(header.getValue());
-                        }
-                        sbList.add(sb.toString());
-                        if (0 < signHeadersStringBuilder.length()) {
-                        	signHeadersStringBuilder.append(Constants.SPE1);
-                        }
-                        signHeadersStringBuilder.append(header.getKey().toLowerCase());
-                    }
-                }
-    			headers.put(SystemHeader.X_CA_SIGNATURE_HEADERS, signHeadersStringBuilder.toString());
-    		}
-    	}
-        return StringUtils.join(sbList,Constants.SPE3);
-    }
-
-    /**
-     * Http头是否参与签名 return
-     */
-    private static boolean isHeaderToSign(String headerName, List<String> signHeaderList) {
-        if (StringUtils.isBlank(headerName)) {
-            return false;
-        }
-
-        if (headerName.startsWith(Constants.CA_HEADER_TO_SIGN_PREFIX_SYSTEM)) {
-            return true;
-        }
-
-        if (null != signHeaderList) {
-            for (String signHeaderPrefix : signHeaderList) {
-                if (headerName.equalsIgnoreCase(signHeaderPrefix)) {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    }
-
-    public static void main(String[] args) {
-        String secret = "1234567890123456";
-        Map<String, String> headers = new HashMap<>();
-        headers.put("X-Service-Id", "eh.organ");
-        headers.put("X-Service-Method", "");
-        headers.put("X-Ca-Key", "hello");
-        headers.put("X-Ca-Timestamp", String.valueOf(System.currentTimeMillis()));
-        headers.put("X-Ca-Nonce", UUID.randomUUID().toString());
-        headers.put(SystemHeader.X_CONTENT_MD5, UUID.randomUUID().toString());
-        System.out.println(sign(secret, headers));
-
-    }
-}

+ 2 - 0
zzcx-service/src/main/java/com/diagbot/web/InquiryInfoController.java

@@ -1,5 +1,6 @@
 package com.diagbot.web;
 
+import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SaveInquiryDTO;
 import com.diagbot.facade.InquiryInfoFacade;
@@ -30,6 +31,7 @@ public class InquiryInfoController {
 
     @ApiOperation(value = "问诊记录保存[by:zhoutg]")
     @PostMapping("/saveInquiry")
+    @SysLogger("saveInquiry")
     @Transactional
     public RespDTO<Boolean> saveInquiry(@Valid @RequestBody SaveInquiryVO saveInquiryVO) {
         inquiryInfoFacade.saveInquiry(saveInquiryVO);

+ 1 - 1
zzcx-service/src/main/java/com/diagbot/web/OptInfoController.java

@@ -43,7 +43,7 @@ public class OptInfoController {
                     "endDate: 结束时间,Date<br>")
     @PostMapping("/getOptSum")
     @SysLogger("getOptSum")
-    public RespDTO<OptDTO> getOptSum(@RequestBody OptVO optVO){
+    public RespDTO<OptDTO> getOptSum(@RequestBody OptVO optVO) {
         return RespDTO.onSuc(optInfoFacade.getOptSum(optVO));
     }
 }