Prechádzať zdrojové kódy

fix 调节项目规则,由esb往web变化

DYH2020 2 rokov pred
commit
8220ee56f3
39 zmenil súbory, kde vykonal 2542 pridanie a 0 odobranie
  1. 25 0
      .gitignore
  2. 3 0
      README.md
  3. 7 0
      config_filters/filters-dev.properties
  4. 2 0
      config_filters/filters-preproduct.properties
  5. 4 0
      config_filters/filters-product.properties
  6. 4 0
      config_filters/filters-test.properties
  7. 197 0
      pom.xml
  8. 20 0
      src/main/java/com/ywt/mg/Main.java
  9. 19 0
      src/main/java/com/ywt/mg/configs/GrpcChannelBeans.java
  10. 28 0
      src/main/java/com/ywt/mg/configs/ParameterConfigurer.java
  11. 18 0
      src/main/java/com/ywt/mg/configs/ServiceGrpcStubBeans.java
  12. 11 0
      src/main/java/com/ywt/mg/core/AppMessageException.java
  13. 174 0
      src/main/java/com/ywt/mg/core/Checker.java
  14. 52 0
      src/main/java/com/ywt/mg/core/JsonSerializer.java
  15. 69 0
      src/main/java/com/ywt/mg/core/JwtUtil.java
  16. 43 0
      src/main/java/com/ywt/mg/core/MD5CheckSum.java
  17. 17 0
      src/main/java/com/ywt/mg/core/NullOrEmptyException.java
  18. 9 0
      src/main/java/com/ywt/mg/core/ParameterException.java
  19. 26 0
      src/main/java/com/ywt/mg/core/SpringContext.java
  20. 64 0
      src/main/java/com/ywt/mg/core/utils/qrcode/MatrixToImageWriter.java
  21. 124 0
      src/main/java/com/ywt/mg/core/utils/qrcode/QRCodeFactory.java
  22. 52 0
      src/main/java/com/ywt/mg/core/utils/serializers/JsonSerializer.java
  23. 97 0
      src/main/java/com/ywt/mg/core/utils/serializers/XMLSerializer.java
  24. 113 0
      src/main/java/com/ywt/mg/models/BaseResponse.java
  25. 76 0
      src/main/java/com/ywt/mg/models/DataResponse.java
  26. 262 0
      src/main/java/com/ywt/mg/models/DrugInfo.java
  27. 46 0
      src/main/java/com/ywt/mg/models/PageDataResponse.java
  28. 187 0
      src/main/java/com/ywt/mg/models/PrescriptionData.java
  29. 24 0
      src/main/java/com/ywt/mg/web/CookiesHelper.java
  30. 22 0
      src/main/java/com/ywt/mg/web/configs/WebMvcConfigurer.java
  31. 39 0
      src/main/java/com/ywt/mg/web/controller/DrugController.java
  32. 74 0
      src/main/java/com/ywt/mg/web/interceptors/AccessBehaviorInterceptor.java
  33. 139 0
      src/main/java/com/ywt/mg/web/interceptors/AuthInterceptor.java
  34. 59 0
      src/main/java/com/ywt/mg/web/interceptors/ExceptionIntercept.java
  35. 78 0
      src/main/java/com/ywt/mg/web/interceptors/HttpContextUtil.java
  36. 120 0
      src/main/java/com/ywt/mg/web/interceptors/HttpServletRequestFilter.java
  37. 194 0
      src/main/java/com/ywt/mg/web/interceptors/WebAppContext.java
  38. 13 0
      src/main/resources/application.properties
  39. 31 0
      src/main/resources/logback-spring.xml

+ 25 - 0
.gitignore

@@ -0,0 +1,25 @@
+*.class
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+!mybatis-generator/mybatis-generator-core-1.3.2.jar
+!mybatis-generator/sqljdbc4-4.0.jar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+.DS_Store
+.idea
+*.iml
+out
+target
+
+*.log
+*.log
+*.pyc
+

+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+# his_esb_api
+
+白云、太和之类的his esb api

+ 7 - 0
config_filters/filters-dev.properties

@@ -0,0 +1,7 @@
+#redis 配置
+redis.address=192.168.3.202:6379
+
+logging.level.root=INFO
+
+ywt.msite.domain=m.ywtinfo.com
+

+ 2 - 0
config_filters/filters-preproduct.properties

@@ -0,0 +1,2 @@
+#redis 配置
+redis.address=192.168.3.202:6379

+ 4 - 0
config_filters/filters-product.properties

@@ -0,0 +1,4 @@
+#redis 配置
+redis.address=192.168.3.202:6379
+
+ywt.msite.domain=m.ywtinfo.com

+ 4 - 0
config_filters/filters-test.properties

@@ -0,0 +1,4 @@
+#redis 配置
+redis.address=172.18.82.224:6339
+
+ywt.msite.domain=m-qa.ywtinfo.com

+ 197 - 0
pom.xml

@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.ywt</groupId>
+    <artifactId>his-open-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>his-open-api</name>
+    <description>HIS OPEN API</description>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.0.5.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+    <!-- maven 私服  start -->
+    <repositories>
+        <repository>
+            <id>nexus</id>
+            <name>Team Nexus Repository</name>
+            <url>http://nexus.ywtinfo.com/repository/maven-public/</url>
+        </repository>
+    </repositories>
+    <pluginRepositories>
+        <pluginRepository>
+            <id>nexus</id>
+            <name>Team Nexus Repository</name>
+            <url>http://nexus.ywtinfo.com/repository/maven-public/</url>
+        </pluginRepository>
+    </pluginRepositories>
+    <!-- end maven 私服  -->
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jetty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>20.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-netty</artifactId>
+            <version>1.7.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-protobuf</artifactId>
+            <version>1.7.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-stub</artifactId>
+            <version>1.7.0</version>
+        </dependency>
+
+
+        <!-- https://mvnrepository.com/artifact/net.sf.barcode4j/barcode4j-light -->
+        <dependency>
+            <groupId>net.sf.barcode4j</groupId>
+            <artifactId>barcode4j-light</artifactId>
+            <version>2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>ywt</groupId>
+            <artifactId>ywt-rpc-core</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <!--   qrCode生成器     -->
+        <!-- https://mvnrepository.com/artifact/net.glxn.qrgen/javase -->
+        <dependency>
+            <groupId>net.glxn.qrgen</groupId>
+            <artifactId>javase</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.18.3</version>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>dev</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <properties>
+                <active.profile>dev</active.profile>
+            </properties>
+        </profile>
+        <profile>
+            <id>test</id>
+            <properties>
+                <active.profile>test</active.profile>
+            </properties>
+        </profile>
+        <profile>
+            <id>product</id>
+            <properties>
+                <active.profile>product</active.profile>
+            </properties>
+        </profile>
+        <profile>
+            <id>preproduct</id>
+            <properties>
+                <active.profile>preproduct</active.profile>
+            </properties>
+        </profile>
+    </profiles>
+
+    <build>
+        <filters>
+            <filter>config_filters/filters-${active.profile}.properties</filter>
+        </filters>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.2</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jaxb2-maven-plugin</artifactId>
+                <version>1.6</version>
+                <executions>
+                    <execution>
+                        <id>xjc</id>
+                        <goals>
+                            <goal>xjc</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
+                    <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
+                    <clearOutputDir>false</clearOutputDir>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 20 - 0
src/main/java/com/ywt/mg/Main.java

@@ -0,0 +1,20 @@
+package com.ywt.mg;
+
+import com.ywt.rpc.core.RestServerStarter;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@Configuration
+@EnableAutoConfiguration
+@ComponentScan(basePackages = "com.ywt.mg")
+public class Main {
+
+    public static void main(String[] args) {
+        SpringApplication.run(Main.class, args);
+        System.out.println("-------- reg service ------------------");
+        RestServerStarter.build(null).registry("com.ywt.HisEsbApiService", null, "");
+    }
+}

+ 19 - 0
src/main/java/com/ywt/mg/configs/GrpcChannelBeans.java

@@ -0,0 +1,19 @@
+package com.ywt.mg.configs;
+
+import io.grpc.Channel;
+import io.grpc.ManagedChannelBuilder;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+@Component
+public class GrpcChannelBeans {
+    @Value("${service.agent.grpc.addr}")
+    private String agentAddr;
+
+    @Bean(name = "agentChannel")
+    public Channel getAgentChannel() {
+        String[] hostAndPort = agentAddr.split(":");
+        return ManagedChannelBuilder.forAddress(hostAndPort[0], Integer.parseInt(hostAndPort[1])).usePlaintext(true).build();
+    }
+}

+ 28 - 0
src/main/java/com/ywt/mg/configs/ParameterConfigurer.java

@@ -0,0 +1,28 @@
+package com.ywt.mg.configs;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * @author daiyihua
+ * @create 2012-02-12 11:54 AM
+ * @desc 配置文件传过来的参数配置
+ **/
+@Component
+public class ParameterConfigurer {
+
+
+    /**
+     * 接入的密钥
+     * <p>
+     * 格式如下:
+     * [{"hospital_3th_gz1","afe6aaa2-d79b-4e7f-982f-6b19edea59f5"},{"hospital_3th_gz_test2", "afe6aaa2-d79b-4e7f-982f-6b19edea59f5dfdf"}]
+     */
+    @Value("${com.parm.checkAppIdMap}")
+    private String checkAppIdMap;
+
+    public String getCheckAppIdMap() {
+        return checkAppIdMap;
+    }
+}

+ 18 - 0
src/main/java/com/ywt/mg/configs/ServiceGrpcStubBeans.java

@@ -0,0 +1,18 @@
+package com.ywt.mg.configs;
+
+import io.grpc.Channel;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class ServiceGrpcStubBeans {
+    @Resource(name = "agentChannel")
+    private Channel agentChannel;
+
+//    @Bean(name = "drugServiceBlockingStub")
+//    public DrugServiceGrpc.DrugServiceBlockingStub getDrugServiceBlockingStub(){
+//        return DrugServiceGrpc.newBlockingStub(agentChannel);
+//    }
+}

+ 11 - 0
src/main/java/com/ywt/mg/core/AppMessageException.java

@@ -0,0 +1,11 @@
+package com.ywt.mg.core;
+
+/**
+ * Created by huangguoping.
+ */
+public class AppMessageException extends Exception {
+    public AppMessageException(){}
+    public AppMessageException(String msg){
+        super(msg);
+    }
+}

+ 174 - 0
src/main/java/com/ywt/mg/core/Checker.java

@@ -0,0 +1,174 @@
+package com.ywt.mg.core;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by huangguoping on 14/12/10.
+ */
+public class Checker {
+    public static boolean isNone(Map map) {
+        if (map == null || map.size() == 0) {
+            return true;
+        }
+        return false;
+    }
+
+    public static void checkNone(Map map, String paramName) throws NullOrEmptyException {
+        if (map == null || map.size() == 0) {
+            throw new NullOrEmptyException(paramName + " is null or empty");
+        }
+    }
+
+    public static boolean isNone(List lst) {
+        if (lst == null || lst.size() == 0)
+            return true;
+        return false;
+    }
+
+    public static boolean isNone(Set s) {
+        if (s == null || s.size() == 0)
+            return true;
+        return false;
+    }
+
+    public static void checkNone(List lst, String paramName) throws NullOrEmptyException {
+        if (lst == null || lst.size() == 0) {
+            throw new NullOrEmptyException(paramName + " is null or empty");
+        }
+    }
+
+    public static boolean isNone(String str) {
+        if (str == null || str.equals(""))
+            return true;
+        return false;
+    }
+
+    public static void checkNone(String str, String paramName) throws NullOrEmptyException {
+        if (str == null || str.equals("")) {
+            throw new NullOrEmptyException(paramName + " is null or empty");
+        }
+    }
+
+    public static boolean isNone(Object object) {
+        if (object == null) return true;
+        return false;
+    }
+
+    public static void checkNone(Object object, String paramName) throws NullOrEmptyException {
+        if (object == null) {
+            throw new NullOrEmptyException(paramName + " is null or empty");
+        }
+    }
+
+    public static boolean isNone(Object[] objects) {
+        if (objects == null || objects.length == 0) return true;
+        return false;
+    }
+
+    public static void checkNone(Object[] objects, String paramName) throws NullOrEmptyException {
+        if (objects == null || objects.length == 0) {
+            throw new NullOrEmptyException(paramName + " is null or empty");
+        }
+    }
+
+    public static boolean isNone(byte[] bytes) {
+        if (bytes == null || bytes.length == 0)
+            return true;
+        else
+            return false;
+    }
+
+    public static void checkNone(byte[] bytes, String paramName) throws NullOrEmptyException {
+        if (bytes == null || bytes.length == 0) {
+            throw new NullOrEmptyException(paramName + " is null or empty");
+        }
+    }
+
+    public static int getIntegerValue(Integer value, int defaultValue) {
+        return value != null ? value.intValue() : defaultValue;
+    }
+
+    public static byte getByteValue(Byte value, byte defaultValue) {
+        return value != null ? value.byteValue() : defaultValue;
+    }
+
+    public static short getShortValue(Short value, short defaultValue) {
+        return value != null ? value.shortValue() : defaultValue;
+    }
+
+    public static double getDoubleValue(Double value, double defaultValue) {
+        return value != null ? value.doubleValue() : defaultValue;
+    }
+
+    public static boolean getBooleanValue(Boolean value, boolean defaultValue) {
+        return value != null ? value.booleanValue() : defaultValue;
+    }
+
+    public static String getStringValue(String value, String defaultValue) {
+        return value != null ? value : defaultValue;
+    }
+
+    public static String getStringValue(String value) {
+        return value != null ? value : "";
+    }
+
+    public static long getLongValue(Long value, long defaultValue) {
+        return value != null ? value.longValue() : defaultValue;
+    }
+
+    public static Date getDateValue(Date date, Date defaultDate) {
+        return date != null ? date : defaultDate;
+    }
+
+    public static int getIntegerValue(Integer value) {
+        return value != null ? value.intValue() : 0;
+    }
+
+    public static byte getByteValue(Byte value) {
+        return value != null ? value.byteValue() : (byte)0;
+    }
+
+    public static short getShortValue(Short value) {
+        return value != null ? value.shortValue() : (short)0;
+    }
+
+    public static double getDoubleValue(Double value) {
+        return value != null ? value.doubleValue() : (double)0;
+    }
+
+    public static boolean getBooleanValue(Boolean value) {
+        return value != null ? value.booleanValue() : false;
+    }
+
+    public static long getLongValue(Long value) {
+        return value != null ? value.longValue() : 0L;
+    }
+
+    public static String NullStringToEmpty(String value) {
+        return value != null ? value : "";
+    }
+
+    public static Date getDateValue(Date date) {
+        return date != null ? date : new Date(System.currentTimeMillis());
+    }
+
+    public static int parseInt(String numStr, int defaultValue){
+        try {
+            return Integer.parseInt(numStr);
+        }catch (Exception e){
+            return defaultValue;
+        }
+    }
+    public static int parseInt(String numStr){
+        return parseInt(numStr, 0);
+    }
+
+    public static boolean isNull(Object obj) {
+        return obj == null;
+    }
+
+
+}

+ 52 - 0
src/main/java/com/ywt/mg/core/JsonSerializer.java

@@ -0,0 +1,52 @@
+package com.ywt.mg.core;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+/**
+ * Created by huangguoping
+ */
+public class JsonSerializer {
+    static ObjectMapper mapper = new ObjectMapper();
+    public static String toJson(Object object){
+        try {
+            StringWriter str = new StringWriter();
+            mapper.writeValue(str,object);
+            return str.toString();
+        } catch (JsonProcessingException e) {
+            //e.printStackTrace();
+        } catch (IOException e) {
+            //e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static <T>T from(String json, Class<T> type){
+        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+        mapper.setVisibilityChecker(VisibilityChecker.Std.defaultInstance().withFieldVisibility(JsonAutoDetect.Visibility.ANY));
+        try {
+            mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true) ;
+            T t = mapper.readValue(json, type);
+            return t;
+        } catch (IOException e) {
+            //e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static JsonNode readToNode (String json) throws IOException {
+        try{
+            return mapper.readTree(json);
+        }catch (Exception e) {
+            throw e;
+        }
+    }
+}

+ 69 - 0
src/main/java/com/ywt/mg/core/JwtUtil.java

@@ -0,0 +1,69 @@
+package com.ywt.mg.core;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.DecodedJWT;
+
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * JwtUtil Class
+ *
+ * @author daiyihua
+ * @date 2020/02/12
+ */
+public class JwtUtil {
+
+    /**
+     * 使用Hs256算法  生成jwt
+     * @param content 加密的内容
+     * @param appid appid
+     * @param appsecret 私钥
+     * @return jwt
+     */
+    public static String createJWT(String content, String appid, String appsecret) {
+
+        String checksum = MD5CheckSum.md5(content.trim()).toUpperCase();
+        // 给定一个算法,如HmacSHA-256 (HS256)
+        Algorithm alg = Algorithm.HMAC256(appsecret);
+
+        //  签发Token
+        Date currentTime = new Date();
+        return JWT.create()
+                // 发行者
+                .withIssuer(appid)
+                // 用户身份标识
+                .withSubject("userid")
+                // 签发时间
+                .withIssuedAt(currentTime)
+                // 一天有效期
+                .withExpiresAt(new Date(currentTime.getTime() + 24*3600*1000L))
+                // 分配JWT的ID
+                .withJWTId(UUID.randomUUID().toString())
+                // 定义公共域信息
+                .withClaim("appid", appid)
+                .withClaim("checksum", checksum)
+                .sign(alg);
+    }
+
+    /**
+     * @desc   验证token,通过返回true
+     * @params [token]需要校验的串
+     **/
+    public static DecodedJWT verify(String token, String appsecret){
+        try {
+            Algorithm algorithm = Algorithm.HMAC256(appsecret);
+            JWTVerifier verifier = JWT.require(algorithm).build();
+            DecodedJWT jwt = verifier.verify(token);
+            return jwt;
+        }catch (Exception e){
+            e.printStackTrace();
+            return  null;
+        }
+    }
+
+
+
+}

+ 43 - 0
src/main/java/com/ywt/mg/core/MD5CheckSum.java

@@ -0,0 +1,43 @@
+package com.ywt.mg.core;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Created by huangguoping on 16/4/21.
+ */
+public class MD5CheckSum {
+    public static String md5(String str){
+        try {
+            if (str == null) return "";
+            MessageDigest md5 = MessageDigest.getInstance("md5");
+            byte[] bytes = md5.digest(str.getBytes());
+            StringBuilder builder = new StringBuilder();
+            for(byte cipher : bytes) {
+                String toHexStr = Integer.toHexString(cipher & 0xff);
+                builder.append(toHexStr.length() == 1 ? "0" + toHexStr : toHexStr);
+            }
+            return builder.toString();
+        } catch (NoSuchAlgorithmException e) {
+            //e.printStackTrace();
+        }
+        return "";
+    }
+
+    public static String md5(byte[] data){
+        try {
+            if (data == null) return "";
+            MessageDigest md5 = MessageDigest.getInstance("md5");
+            byte[] bytes = md5.digest(data);
+            StringBuilder builder = new StringBuilder();
+            for(byte cipher : bytes) {
+                String toHexStr = Integer.toHexString(cipher & 0xff);
+                builder.append(toHexStr.length() == 1 ? "0" + toHexStr : toHexStr);
+            }
+            return builder.toString();
+        } catch (NoSuchAlgorithmException e) {
+            //e.printStackTrace();
+        }
+        return "";
+    }
+}

+ 17 - 0
src/main/java/com/ywt/mg/core/NullOrEmptyException.java

@@ -0,0 +1,17 @@
+package com.ywt.mg.core;
+
+/**
+ * Created by huangguoping.
+ */
+public class NullOrEmptyException extends Exception {
+    private String message = "";
+    public NullOrEmptyException(){}
+    public NullOrEmptyException(String msg){
+        this.message = msg;
+    }
+
+    @Override
+    public String getMessage() {
+        return this.message;
+    }
+}

+ 9 - 0
src/main/java/com/ywt/mg/core/ParameterException.java

@@ -0,0 +1,9 @@
+package com.ywt.mg.core;
+
+public class ParameterException extends Exception {
+    public ParameterException(){
+    }
+    public ParameterException(String msg){
+        super(msg);
+    }
+}

+ 26 - 0
src/main/java/com/ywt/mg/core/SpringContext.java

@@ -0,0 +1,26 @@
+package com.ywt.mg.core;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by huangguoping.
+ */
+@Service("springContext")
+public class SpringContext implements ApplicationContextAware {
+    private static ApplicationContext context;
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        context = applicationContext;
+    }
+
+    public static Object getBean(String name){
+        return context.getBean(name);
+    }
+
+    public static <T> Object getBean(Class<T> tClass){
+        return context.getBean(tClass);
+    }
+}

+ 64 - 0
src/main/java/com/ywt/mg/core/utils/qrcode/MatrixToImageWriter.java

@@ -0,0 +1,64 @@
+package com.ywt.mg.core.utils.qrcode;
+
+
+import com.google.zxing.common.BitMatrix;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/*
+  二维码的生成需要借助MatrixToImageWriter类,该类是由Google提供的,可以将该类直接拷贝到源码中使用,当然你也可以自己写个
+  生产条形码的基类
+ */
+public class MatrixToImageWriter {
+    private static final int BLACK = 0xFF000000;//用于设置图案的颜色
+    private static final int WHITE = 0xFFFFFFFF; //用于背景色
+
+    private MatrixToImageWriter() {
+    }
+
+    public static BufferedImage toBufferedImage(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        for (int x = 0; x < width; x++) {
+            for (int y = 0; y < height; y++) {
+                image.setRGB(x, y, (matrix.get(x, y) ? BLACK : WHITE));
+//              image.setRGB(x, y,  (matrix.get(x, y) ? Color.YELLOW.getRGB() : Color.CYAN.getRGB()));
+            }
+        }
+        return image;
+    }
+
+    public static void writeToFile(BitMatrix matrix, String format, File file, String logUri) throws IOException {
+
+        System.out.println("write to file");
+        BufferedImage image = toBufferedImage(matrix);
+        //设置logo图标
+        QRCodeFactory logoConfig = new QRCodeFactory();
+        image = logoConfig.setMatrixLogo(image, logUri);
+
+        if (!ImageIO.write(image, format, file)) {
+            System.out.println("生成图片失败");
+            throw new IOException("Could not write an image of format " + format + " to " + file);
+        } else {
+            System.out.println("图片生成成功!");
+        }
+    }
+
+    public static void writeToStream(BitMatrix matrix, String format, OutputStream stream, String logUri) throws IOException {
+
+        BufferedImage image = toBufferedImage(matrix);
+
+        //设置logo图标
+        QRCodeFactory logoConfig = new QRCodeFactory();
+        image = logoConfig.setMatrixLogo(image, logUri);
+
+        if (!ImageIO.write(image, format, stream)) {
+            throw new IOException("Could not write an image of format " + format);
+        }
+    }
+}

+ 124 - 0
src/main/java/com/ywt/mg/core/utils/qrcode/QRCodeFactory.java

@@ -0,0 +1,124 @@
+package com.ywt.mg.core.utils.qrcode;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+
+/**
+ * 本类用于对我们二维码进行参数的设定,生成我们的二维码:
+ * @author kingwen
+ */
+public class QRCodeFactory {
+
+    /**
+     * 给生成的二维码添加中间的logo
+     * @param matrixImage 生成的二维码
+     * @param logUri      logo地址
+     * @return            带有logo的二维码
+     * @throws IOException logo地址找不到会有io异常
+     */
+    public BufferedImage setMatrixLogo(BufferedImage matrixImage,String logUri) throws IOException{
+        /**
+         * 读取二维码图片,并构建绘图对象
+         */
+        Graphics2D g2 = matrixImage.createGraphics();
+        int matrixWidth = matrixImage.getWidth();
+        int matrixHeigh = matrixImage.getHeight();
+
+        /**
+         * 读取Logo图片
+         */
+        BufferedImage logo = ImageIO.read(new File(logUri));
+
+        //开始绘制图片
+        g2.drawImage(logo,matrixWidth/5*2,matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5, null);
+        //绘制边框
+        BasicStroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+        // 设置笔画对象
+        g2.setStroke(stroke);
+        //指定弧度的圆角矩形
+        RoundRectangle2D.Float round = new RoundRectangle2D.Float(matrixWidth/5*2, matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5,20,20);
+        g2.setColor(Color.white);
+        // 绘制圆弧矩形
+        g2.draw(round);
+
+        //设置logo 有一道灰色边框
+        BasicStroke stroke2 = new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+        // 设置笔画对象
+        g2.setStroke(stroke2);
+        RoundRectangle2D.Float round2 = new RoundRectangle2D.Float(matrixWidth/5*2+2, matrixHeigh/5*2+2, matrixWidth/5-4, matrixHeigh/5-4,20,20);
+        g2.setColor(new Color(128,128,128));
+        g2.draw(round2);// 绘制圆弧矩形
+
+
+        g2.dispose();
+        matrixImage.flush() ;
+        return matrixImage ;
+
+    }
+
+
+
+    /**
+     * 创建我们的二维码图片
+     * @param content            二维码内容
+     * @param format             生成二维码的格式
+     * @param outFileUri         二维码的生成地址
+     * @param logUri             二维码中间logo的地址
+     * @param size               用于设定图片大小(可变参数,宽,高)
+     * @throws IOException       抛出io异常
+     * @throws WriterException   抛出书写异常
+     */
+    public  void CreatQrImage(String content,String format,String outFileUri,String logUri, int ...size) throws IOException, WriterException{
+
+
+        int width = 430; // 二维码图片宽度 430
+        int height = 430; // 二维码图片高度430
+
+        //如果存储大小的不为空,那么对我们图片的大小进行设定
+        if(size.length==2){
+            width=size[0];
+            height=size[1];
+        }else if(size.length==1){
+            width=height=size[0];
+        }
+
+
+        Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
+        // 指定纠错等级,纠错级别(L 7%、M 15%、Q 25%、H 30%)
+        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+        // 内容所使用字符集编码
+        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
+        //hints.put(EncodeHintType.MAX_SIZE, 350);//设置图片的最大值
+        //hints.put(EncodeHintType.MIN_SIZE, 100);//设置图片的最小值
+        hints.put(EncodeHintType.MARGIN, 1);//设置二维码边的空度,非负数
+
+        BitMatrix bitMatrix = new MultiFormatWriter().encode(content,//要编码的内容
+                //编码类型,目前zxing支持:Aztec 2D,CODABAR 1D format,Code 39 1D,Code 93 1D ,Code 128 1D,
+                //Data Matrix 2D , EAN-8 1D,EAN-13 1D,ITF (Interleaved Two of Five) 1D,
+                //MaxiCode 2D barcode,PDF417,QR Code 2D,RSS 14,RSS EXPANDED,UPC-A 1D,UPC-E 1D,UPC/EAN extension,UPC_EAN_EXTENSION
+                BarcodeFormat.QR_CODE,
+                width, //条形码的宽度
+                height, //条形码的高度
+                hints);//生成条形码时的一些配置,此项可选
+
+        // 生成二维码图片文件
+        File outputFile = new File(outFileUri);
+
+        //指定输出路径
+        System.out.println("输出文件路径为"+outputFile.getPath());
+
+        MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile,logUri);
+    }
+}

+ 52 - 0
src/main/java/com/ywt/mg/core/utils/serializers/JsonSerializer.java

@@ -0,0 +1,52 @@
+package com.ywt.mg.core.utils.serializers;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+/**
+ * Created by huangguoping
+ */
+public class JsonSerializer {
+    static ObjectMapper mapper = new ObjectMapper();
+    public static String toJson(Object object){
+        try {
+            StringWriter str = new StringWriter();
+            mapper.writeValue(str,object);
+            return str.toString();
+        } catch (JsonProcessingException e) {
+            //e.printStackTrace();
+        } catch (IOException e) {
+            //e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static <T>T from(String json, Class<T> type){
+        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+        mapper.setVisibilityChecker(VisibilityChecker.Std.defaultInstance().withFieldVisibility(JsonAutoDetect.Visibility.ANY));
+        try {
+            mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true) ;
+            T t = mapper.readValue(json, type);
+            return t;
+        } catch (IOException e) {
+            //e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static JsonNode readToNode (String json){
+        try{
+            return mapper.readTree(json);
+        }catch (Exception e) {
+        }
+        return null;
+    }
+}

+ 97 - 0
src/main/java/com/ywt/mg/core/utils/serializers/XMLSerializer.java

@@ -0,0 +1,97 @@
+package com.ywt.mg.core.utils.serializers;
+
+import org.xml.sax.InputSource;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import java.io.*;
+
+/**
+ * Created by huangguoping.
+ */
+public class XMLSerializer {
+    public static byte[] objectToBytes(Object obj) {
+        byte[] result = null;
+        ByteArrayOutputStream byteOutputStream = null;
+        ObjectOutputStream objectOutputStream = null;
+
+        try {
+            byteOutputStream = new ByteArrayOutputStream();
+            objectOutputStream = new ObjectOutputStream(byteOutputStream);
+
+            objectOutputStream.writeObject(obj);
+            objectOutputStream.flush();
+
+            result = byteOutputStream.toByteArray();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (null != objectOutputStream) {
+                try {
+                    objectOutputStream.close();
+                    byteOutputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public static Object bytesToObject(byte[] bytes) {
+        Object obj = null;
+
+        if (bytes == null) {
+            return null;
+        }
+
+        ByteArrayInputStream byteInputStream = null;
+        ObjectInputStream objectInputStream = null;
+
+        try {
+            byteInputStream = new ByteArrayInputStream(bytes);
+            objectInputStream = new ObjectInputStream(byteInputStream);
+            obj = objectInputStream.readObject();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (null != objectInputStream) {
+                try {
+                    objectInputStream.close();
+                    byteInputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        return obj;
+    }
+
+    public static <T> T xmlToObject(String xml, Class<T> clazz) throws IllegalAccessException, InstantiationException, JAXBException {
+        if (xml == null || xml.equals("")) {
+            return clazz.newInstance();
+        }
+
+        StringReader xmlString = new StringReader(xml);
+        InputSource source = new InputSource(xmlString);
+
+        JAXBContext jc = JAXBContext.newInstance(clazz);
+        Unmarshaller u = jc.createUnmarshaller();
+        return (T) u.unmarshal(source);
+    }
+
+    public static <T> String objectToXml(T t, Class<T> clazz) throws JAXBException {
+        Writer writer = new StringWriter();
+        JAXBContext context = JAXBContext.newInstance(clazz);
+        Marshaller marshaller = context.createMarshaller();
+
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        marshaller.marshal(t, writer);
+
+        return writer.toString();
+    }
+}

+ 113 - 0
src/main/java/com/ywt/mg/models/BaseResponse.java

@@ -0,0 +1,113 @@
+package com.ywt.mg.models;
+
+import java.io.Serializable;
+
+/**
+ * Created by huangguoping.
+ */
+public class BaseResponse implements Serializable {
+    public static final int SUCCEED = 0;//成功
+    /**
+     * 参数错误
+     */
+    public static final int PARAMETER_ERROR = 1;//参数错误
+    /**
+     * 应用级别错误
+     */
+    public static final int APP_ERROR = 2;//应用级别错误
+    /**
+     * 应用级别异常
+     */
+    public static final int APP_EXCEPTION = 3;//应用级别异常
+    /**
+     * 不合法的权限
+     */
+    public static final int NO_RIGHT = 4;//不合法的权限
+    /**
+     * 其他错误
+     */
+    public static final int OTHER_ERROR = 5;//其他错误
+
+    int code;
+    String info;
+
+    public BaseResponse succeed(){
+        this.code = BaseResponse.SUCCEED;
+        this.info = "处理成功";
+        return this;
+    }
+
+    public BaseResponse succeed(String info){
+        this.code = BaseResponse.SUCCEED;
+        this.info = info;
+        return this;
+    }
+
+
+    public BaseResponse failed(int code){
+        this.code = code;
+        return this;
+    }
+
+    public BaseResponse failed(int code, String info){
+        this.code = code;
+        this.info = info;
+        return this;
+    }
+
+
+    public int getCode() {
+        return code;
+    }
+
+    public BaseResponse setCode(int code) {
+        this.code = code;
+        return this;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public BaseResponse setInfo(String info) {
+        this.info = info;
+        return this;
+    }
+
+    public BaseResponse failedWithParameterError(){
+        this.code = BaseResponse.PARAMETER_ERROR;
+        this.info = "参数错误";
+        return this;
+    }
+
+    public BaseResponse failedWithParameterError(String info){
+        this.code = BaseResponse.PARAMETER_ERROR;
+        this.info = info;
+        return this;
+    }
+
+    public BaseResponse failedWithAppError(){
+        this.code = BaseResponse.APP_ERROR;
+        this.info = "处理失败";
+        return this;
+    }
+
+    public BaseResponse failedWithAppError(String info){
+        this.code = BaseResponse.APP_ERROR;
+        this.info = info;
+        return this;
+    }
+    public BaseResponse error() {
+        this.code = BaseResponse.APP_EXCEPTION;
+        this.info = "系统开小差,请稍后重试";
+        return this;
+    }
+
+    public BaseResponse error(String info) {
+        this.code = BaseResponse.APP_EXCEPTION;
+        this.info = info;
+        return this;
+    }
+
+
+}

+ 76 - 0
src/main/java/com/ywt/mg/models/DataResponse.java

@@ -0,0 +1,76 @@
+package com.ywt.mg.models;
+
+/**
+ * Created by huangguoping.
+ */
+public class DataResponse<T> extends BaseResponse {
+    private T data;
+
+
+    public T getData() {
+        return data;
+    }
+
+    public DataResponse<T> setData(T data) {
+        this.data = data;
+        return this;
+    }
+
+    public DataResponse<T> failed(int code, String info){
+        this.code = code;
+        this.info = info;
+        return this;
+    }
+
+
+    public DataResponse<T> error(String info) {
+        this.code = BaseResponse.APP_EXCEPTION;
+        this.info = info;
+        return this;
+    }
+
+    public DataResponse<T> succeed(String info){
+        this.code = BaseResponse.SUCCEED;
+        this.info = info;
+        return this;
+    }
+
+    public DataResponse<T> succeed(T data){
+        this.code = BaseResponse.SUCCEED;
+        this.info = "操作成功";
+        this.data = data;
+        return this;
+    }
+
+
+    public DataResponse<T> failedWithParameterError(){
+        this.code = BaseResponse.PARAMETER_ERROR;
+        this.info = "参数错误";
+        return this;
+    }
+
+    public DataResponse<T> failedWithParameterError(String info){
+        this.code = BaseResponse.PARAMETER_ERROR;
+        this.info = info;
+        return this;
+    }
+
+    public DataResponse<T> failedWithAppError(){
+        this.code = BaseResponse.APP_ERROR;
+        this.info = "处理失败";
+        return this;
+    }
+
+    public DataResponse<T> failedWithAppError(String info){
+        this.code = BaseResponse.APP_ERROR;
+        this.info = info;
+        return this;
+    }
+    public DataResponse<T> error() {
+        this.code = BaseResponse.APP_EXCEPTION;
+        this.info = "系统开小差,请稍后重试";
+        return this;
+    }
+
+
+}

+ 262 - 0
src/main/java/com/ywt/mg/models/DrugInfo.java

@@ -0,0 +1,262 @@
+package com.ywt.mg.models;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.io.Serializable;
+
+public class DrugInfo implements Serializable {
+
+    @JsonProperty("drug_code")
+    private String drugCode;
+
+    @JsonProperty("drug_name")
+    private String drugName;
+
+    @JsonProperty("drug_spec")
+    private String drugSpec;
+
+    @JsonProperty("one_dosage")
+    private double oneDosage;
+
+    @JsonProperty("one_dosage_unit")
+    private String oneDosageUnit;
+
+    @JsonProperty("amount")
+    private int amount;
+
+    @JsonProperty("units")
+    private String units;
+
+    @JsonProperty("frequency_code")
+    private String frequencyCode;
+
+    @JsonProperty("frequency")
+    private String frequency;
+
+    @JsonProperty("frequency_qty")
+    private int frequencyQty;
+
+    @JsonProperty("usage_code")
+    private String usageCode;
+
+    @JsonProperty("usage")
+    private String usage;
+
+    @JsonProperty("quantity")
+    private int quantity;
+
+    @JsonProperty("course")
+    private int course;
+
+    @JsonProperty("unit_price")
+    private String unitPrice;
+
+    @JsonProperty("execute_date")
+    private String executeDate;
+
+    @JsonProperty("group_no")
+    private String groupNo;
+
+    @JsonProperty("injections")
+    private int injections;
+
+    @JsonProperty("pack_detail")
+    private String packDetail;
+
+    @JsonProperty("one_dosage_detail")
+    private String oneDosageDetail;
+
+    @JsonProperty("usage_remarks")
+    private String usageRemarks;
+
+    @JsonProperty( "drug_print_name")
+    private String drugPrintName;
+
+    @JsonProperty("drug_refrigeration")
+    private String drugRefrigeration;
+
+    public String getDrugCode() {
+        return drugCode;
+    }
+
+    public void setDrugCode(String drugCode) {
+        this.drugCode = drugCode;
+    }
+
+    public String getDrugName() {
+        return drugName;
+    }
+
+    public void setDrugName(String drugName) {
+        this.drugName = drugName;
+    }
+
+    public String getDrugSpec() {
+        return drugSpec;
+    }
+
+    public void setDrugSpec(String drugSpec) {
+        this.drugSpec = drugSpec;
+    }
+
+    public double getOneDosage() {
+        return oneDosage;
+    }
+
+    public void setOneDosage(double oneDosage) {
+        this.oneDosage = oneDosage;
+    }
+
+    public String getOneDosageUnit() {
+        return oneDosageUnit;
+    }
+
+    public void setOneDosageUnit(String oneDosageUnit) {
+        this.oneDosageUnit = oneDosageUnit;
+    }
+
+    public int getAmount() {
+        return amount;
+    }
+
+    public void setAmount(int amount) {
+        this.amount = amount;
+    }
+
+    public String getUnits() {
+        return units;
+    }
+
+    public void setUnits(String units) {
+        this.units = units;
+    }
+
+    public String getFrequencyCode() {
+        return frequencyCode;
+    }
+
+    public void setFrequencyCode(String frequencyCode) {
+        this.frequencyCode = frequencyCode;
+    }
+
+    public String getFrequency() {
+        return frequency;
+    }
+
+    public void setFrequency(String frequency) {
+        this.frequency = frequency;
+    }
+
+    public int getFrequencyQty() {
+        return frequencyQty;
+    }
+
+    public void setFrequencyQty(int frequencyQty) {
+        this.frequencyQty = frequencyQty;
+    }
+
+    public String getUsageCode() {
+        return usageCode;
+    }
+
+    public void setUsageCode(String usageCode) {
+        this.usageCode = usageCode;
+    }
+
+    public String getUsage() {
+        return usage;
+    }
+
+    public void setUsage(String usage) {
+        this.usage = usage;
+    }
+
+    public int getQuantity() {
+        return quantity;
+    }
+
+    public void setQuantity(int quantity) {
+        this.quantity = quantity;
+    }
+
+    public int getCourse() {
+        return course;
+    }
+
+    public void setCourse(int course) {
+        this.course = course;
+    }
+
+    public String getUnitPrice() {
+        return unitPrice;
+    }
+
+    public void setUnitPrice(String unitPrice) {
+        this.unitPrice = unitPrice;
+    }
+
+    public String getExecuteDate() {
+        return executeDate;
+    }
+
+    public void setExecuteDate(String executeDate) {
+        this.executeDate = executeDate;
+    }
+
+    public String getGroupNo() {
+        return groupNo;
+    }
+
+    public void setGroupNo(String groupNo) {
+        this.groupNo = groupNo;
+    }
+
+    public int getInjections() {
+        return injections;
+    }
+
+    public void setInjections(int injections) {
+        this.injections = injections;
+    }
+
+    public String getPackDetail() {
+        return packDetail;
+    }
+
+    public void setPackDetail(String packDetail) {
+        this.packDetail = packDetail;
+    }
+
+    public String getOneDosageDetail() {
+        return oneDosageDetail;
+    }
+
+    public void setOneDosageDetail(String oneDosageDetail) {
+        this.oneDosageDetail = oneDosageDetail;
+    }
+
+    public String getUsageRemarks() {
+        return usageRemarks;
+    }
+
+    public void setUsageRemarks(String usageRemarks) {
+        this.usageRemarks = usageRemarks;
+    }
+
+    public String getDrugPrintName() {
+        return drugPrintName;
+    }
+
+    public void setDrugPrintName(String drugPrintName) {
+        this.drugPrintName = drugPrintName;
+    }
+
+
+    public String getDrugRefrigeration() {
+        return drugRefrigeration;
+    }
+
+    public void setDrugRefrigeration(String drugRefrigeration) {
+        this.drugRefrigeration = drugRefrigeration;
+    }
+}

+ 46 - 0
src/main/java/com/ywt/mg/models/PageDataResponse.java

@@ -0,0 +1,46 @@
+package com.ywt.mg.models;
+
+/**
+ * Created by huangguoping.
+ */
+
+public class PageDataResponse<T> extends BaseResponse {
+    private T data;
+    private int totalCount = 0;
+    private int pageIndex = 1;
+    private int pageSize = 10;
+
+    public T getData() {
+        return data;
+    }
+
+    public PageDataResponse<T> setData(T data) {
+        this.data = data;
+        return this;
+    }
+
+    public int getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(int totalCount) {
+        this.totalCount = totalCount;
+    }
+
+    public int getPageIndex() {
+        return pageIndex;
+    }
+
+    public void setPageIndex(int pageIndex) {
+        this.pageIndex = pageIndex;
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
+}

+ 187 - 0
src/main/java/com/ywt/mg/models/PrescriptionData.java

@@ -0,0 +1,187 @@
+package com.ywt.mg.models;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+public class PrescriptionData implements Serializable {
+
+    @JsonProperty("no")
+    private String no;
+
+    @JsonProperty("doctor_name")
+    private String doctorName;
+
+    @JsonProperty("patient_name")
+    private String patientName;
+
+    @JsonProperty("patient_id_no")
+    private String patientIdNo;
+
+    @JsonProperty("patient_age")
+    private String patientAge;
+
+    @JsonProperty("patient_sex")
+    private String patientSex;
+
+    @JsonProperty("patient_no")
+    private String patientNo;
+
+    @JsonProperty("patient_phone")
+    private String patientPhone;
+
+    @JsonProperty("diagnose")
+    private String diagnose;
+
+    @JsonProperty("dept")
+    private String dept;
+
+    @JsonProperty("date")
+    private String date;
+
+    @JsonProperty("medical_card_no")
+    private String medicalCardNo;
+
+    @JsonProperty("other_pro")
+    private String otherPro;
+
+    @JsonProperty("check_result")
+    private String checkResult;
+
+    @JsonProperty("enforce_detail")
+    private String enforceDetail;
+
+    @JsonProperty("drugs")
+    private List<DrugInfo> drugs;
+
+    public String getNo() {
+        return no;
+    }
+
+    public void setNo(String no) {
+        this.no = no;
+    }
+
+    public String getDoctorName() {
+        return doctorName;
+    }
+
+    public void setDoctorName(String doctorName) {
+        this.doctorName = doctorName;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getPatientIdNo() {
+        return patientIdNo;
+    }
+
+    public void setPatientIdNo(String patientIdNo) {
+        this.patientIdNo = patientIdNo;
+    }
+
+    public String getPatientAge() {
+        return patientAge;
+    }
+
+    public void setPatientAge(String patientAge) {
+        this.patientAge = patientAge;
+    }
+
+    public String getPatientSex() {
+        return patientSex;
+    }
+
+    public void setPatientSex(String patientSex) {
+        this.patientSex = patientSex;
+    }
+
+    public String getPatientNo() {
+        return patientNo;
+    }
+
+    public void setPatientNo(String patientNo) {
+        this.patientNo = patientNo;
+    }
+
+    public String getPatientPhone() {
+        return patientPhone;
+    }
+
+    public void setPatientPhone(String patientPhone) {
+        this.patientPhone = patientPhone;
+    }
+
+    public String getDiagnose() {
+        return diagnose;
+    }
+
+    public void setDiagnose(String diagnose) {
+        this.diagnose = diagnose;
+    }
+
+    public String getDept() {
+        return dept;
+    }
+
+    public void setDept(String dept) {
+        this.dept = dept;
+    }
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getMedicalCardNo() {
+        return medicalCardNo;
+    }
+
+    public void setMedicalCardNo(String medicalCardNo) {
+        this.medicalCardNo = medicalCardNo;
+    }
+
+    public String getOtherPro() {
+        return otherPro;
+    }
+
+    public void setOtherPro(String otherPro) {
+        this.otherPro = otherPro;
+    }
+
+    public String getCheckResult() {
+        return checkResult;
+    }
+
+    public void setCheckResult(String checkResult) {
+        this.checkResult = checkResult;
+    }
+
+    public String getEnforceDetail() {
+        return enforceDetail;
+    }
+
+    public void setEnforceDetail(String enforceDetail) {
+        this.enforceDetail = enforceDetail;
+    }
+
+    public List<DrugInfo> getDrugs() {
+        return drugs;
+    }
+
+    public void setDrugs(List<DrugInfo> drugs) {
+        this.drugs = drugs;
+    }
+
+}

+ 24 - 0
src/main/java/com/ywt/mg/web/CookiesHelper.java

@@ -0,0 +1,24 @@
+package com.ywt.mg.web;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by huangguoping.
+ */
+public class CookiesHelper {
+    public static Map<String,Cookie> getCookiesDict(HttpServletRequest httpServletRequest){
+        Cookie[] cookies = httpServletRequest.getCookies();
+        if (cookies != null && cookies.length > 0){
+            Map<String, Cookie> map = new HashMap<>();
+            for (Cookie cookie : cookies){
+                if (cookie.getName() == null || cookie.getName().equals("")) continue;
+                map.put(cookie.getName(), cookie);
+            }
+            return map;
+        }
+        return null;
+    }
+}

+ 22 - 0
src/main/java/com/ywt/mg/web/configs/WebMvcConfigurer.java

@@ -0,0 +1,22 @@
+package com.ywt.mg.web.configs;
+
+import com.ywt.mg.core.SpringContext;
+import com.ywt.mg.web.interceptors.AccessBehaviorInterceptor;
+import com.ywt.mg.web.interceptors.AuthInterceptor;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+/**
+ * Created by huangguoping.
+ */
+@Configuration
+public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+
+        registry.addInterceptor((AccessBehaviorInterceptor) SpringContext.getBean(AccessBehaviorInterceptor.class)).addPathPatterns("/**");
+        registry.addInterceptor((AuthInterceptor) SpringContext.getBean(AuthInterceptor.class)).addPathPatterns("/**");
+        super.addInterceptors(registry);
+    }
+}

+ 39 - 0
src/main/java/com/ywt/mg/web/controller/DrugController.java

@@ -0,0 +1,39 @@
+package com.ywt.mg.web.controller;
+
+import com.ywt.mg.models.BaseResponse;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * @author daiyihua
+ * @create 2022-12-05 11:15
+ * @program his_open_api
+ * @description 太和、白云药品服务
+ **/
+@RestController("/drug")
+@RequestMapping({"/drug"})
+public class DrugController {
+
+    /**
+     * 查询药品订单列表
+     *
+     */
+    @RequestMapping(value = {"/prescriptionPush"}, method = RequestMethod.POST)
+    BaseResponse prescriptionPush(@RequestBody Map<String, String> dataMap) {
+        BaseResponse response = new BaseResponse();
+        String eventNo = dataMap.getOrDefault("eventNo","");
+        String eventType = dataMap.getOrDefault("eventType","");
+        String eventData = dataMap.getOrDefault("eventData","");
+
+        System.out.println(eventNo);
+        System.out.println(eventType);
+        System.out.println(eventData);
+        return response.succeed("返回成功");
+    }
+
+}
+

+ 74 - 0
src/main/java/com/ywt/mg/web/interceptors/AccessBehaviorInterceptor.java

@@ -0,0 +1,74 @@
+package com.ywt.mg.web.interceptors;
+
+import com.ywt.mg.models.BaseResponse;
+import com.ywt.mg.web.CookiesHelper;
+import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 全局拦截
+ * 采集访问日志
+ * Created by huangguoping.
+ */
+@Service("accessBehaviorInterceptor")
+public class AccessBehaviorInterceptor implements HandlerInterceptor {
+
+    private void toResponse(BaseResponse response, HttpServletResponse httpServletResponse) throws IOException {
+//        httpServletResponse.addHeader("Content-Type", "application/json;charset=UTF-8");
+//        String responseData = JsonSerializer.toJson(response);
+//        httpServletResponse.setStatus(200);
+//        byte[] responseDataBytes = responseData.getBytes("utf-8");
+//        httpServletResponse.setContentLength(responseDataBytes.length);
+//        httpServletResponse.getOutputStream().write(responseDataBytes);
+    }
+
+    @Override
+    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
+        try {
+            WebAppContext.current().init();
+            WebAppContext.current().setRequestStartTime(System.currentTimeMillis())
+                    .setRequestID(UUID.randomUUID().toString())
+                    .setIP("")
+                    .setCookies(CookiesHelper.getCookiesDict(httpServletRequest));
+            WebAppContext.current().setHost(httpServletRequest.getHeader("host"))
+                    .setToken(httpServletRequest.getHeader("at"));
+        } catch (Exception e) {
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
+
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
+        try {
+            Map<String, Object> logData = new HashMap<>();
+            logData.put("url", httpServletRequest.getRequestURI());
+            //logData.put("ip", WebHelper.getIP(httpServletRequest));
+            logData.put("method", httpServletRequest.getMethod());
+            logData.put("referer", httpServletRequest.getHeader("referer"));
+            logData.put("reqid", WebAppContext.current().getRequestID());
+            logData.put("starttime", WebAppContext.current().getRequestStartTime() / 1000);
+            logData.put("endtime", System.currentTimeMillis() / 1000);
+            logData.put("comsumtime", System.currentTimeMillis() - WebAppContext.current().getRequestStartTime());
+            logData.put("capchecked", WebAppContext.current().capChecked());
+            logData.put("host", WebAppContext.current().getHost());
+
+
+            //System.out.println("AccessBehavior completion: " + JsonSerializer.toJson(logData));
+            //behaviorLogService.addAccessLog(logData);
+        } catch (Exception e_s) {
+        }
+    }
+}

+ 139 - 0
src/main/java/com/ywt/mg/web/interceptors/AuthInterceptor.java

@@ -0,0 +1,139 @@
+package com.ywt.mg.web.interceptors;
+
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.ywt.mg.configs.ParameterConfigurer;
+import com.ywt.mg.core.*;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.models.BaseResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by huangguoping.
+ */
+@Service
+public class AuthInterceptor implements HandlerInterceptor {
+    private static Logger logger = LoggerFactory.getLogger(AuthInterceptor.class);
+
+    @Autowired
+    private ParameterConfigurer parameterConfigurer;
+
+    @Autowired
+    private HttpServletRequestFilter httpServletRequestFilter;
+
+    private void toResponse(BaseResponse response, HttpServletResponse httpServletResponse) throws IOException {
+        httpServletResponse.addHeader("Content-Type", "application/json;charset=UTF-8");
+        httpServletResponse.setDateHeader("Expires", 0);
+        // 禁止缓存的指令:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Cache-Control#%E7%A6%81%E6%AD%A2%E7%BC%93%E5%AD%98
+        httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+        httpServletResponse.setHeader("Pragma", "no-cache");
+        String responseData = JsonSerializer.toJson(response);
+        byte[] responseDataBytes = responseData.getBytes("utf-8");
+        httpServletResponse.setContentLength(responseDataBytes.length);
+        httpServletResponse.getOutputStream().write(responseDataBytes);
+    }
+
+    @Override
+    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
+        // 不需要验证
+        if (checkSign(httpServletRequest)) {
+            return true;
+        }
+        BaseResponse baseResponse = new BaseResponse();
+        baseResponse.setCode(BaseResponse.NO_RIGHT);
+        baseResponse.setInfo("权限校验不通过");
+        toResponse(baseResponse, httpServletResponse);
+        return false;
+    }
+
+    /**
+     * 获取需要校验的appId
+     *
+     * @return Map 数组
+     */
+    public Map<String, String> getCheckAppIdMap() {
+        Map appIdMap = new HashMap<String, String>();
+        String checkAppIdMap = parameterConfigurer.getCheckAppIdMap();
+        try {
+            if (!Checker.isNone(checkAppIdMap)) {
+                List list = JsonSerializer.from(checkAppIdMap, List.class);
+                if (!Checker.isNone(list)) {
+                    for (Object o : list) {
+                        Map<String, Object> map = (Map<String, Object>) o;
+                        String appId = (String) map.getOrDefault("appId", "");
+                        String appSecret = (String) map.getOrDefault("appSecret", "");
+                        if (!Checker.isNone(appId) && !Checker.isNone(appSecret)) {
+                            appIdMap.put(appId, appSecret);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            logger.error("ParameterConfigurer#getCheckappIdMap(checkappIdMap{}参数有误,{})", checkAppIdMap, e.getMessage(), e);
+        }
+        return appIdMap;
+    }
+
+    /**
+     * 判断是否是合格的来源
+     *
+     * @return boolean
+     */
+    /**
+     * 验证签名
+     *
+     * @return
+     * @throws UnsupportedEncodingException
+     */
+    private boolean checkSign(HttpServletRequest httpServletRequest) throws Exception {
+        String authorization = httpServletRequest.getHeader("Authorization");
+        String appId = httpServletRequest.getHeader("appId");
+        String[] arrValue = authorization.split("Bearer ");
+        if (arrValue.length > 1 && !Checker.isNone(appId)) {
+            String token = arrValue[1];
+            Map<String, String> appIdMap = getCheckAppIdMap();
+            String appSecret = appIdMap.getOrDefault(appId, "");
+            DecodedJWT jwt = JwtUtil.verify(token, appSecret);
+            if (!Checker.isNone(jwt)) {
+                String payload = jwt.getClaim("checksum").asString();
+                String bodyParam = "";
+                if (httpServletRequest instanceof HttpServletRequestFilter.RequestWrapper) {
+                    HttpServletRequestFilter.RequestWrapper requestWrapper = (HttpServletRequestFilter.RequestWrapper) httpServletRequest;
+                    bodyParam = requestWrapper.getBody();
+                }
+                String bodyMd5CheckSum = MD5CheckSum.md5(bodyParam).toUpperCase();
+                if (payload.equals(bodyMd5CheckSum)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+        return false;
+    }
+
+
+    @Override
+    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
+
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
+
+    }
+
+
+}
+

+ 59 - 0
src/main/java/com/ywt/mg/web/interceptors/ExceptionIntercept.java

@@ -0,0 +1,59 @@
+package com.ywt.mg.web.interceptors;
+
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.models.BaseResponse;
+import com.ywt.mg.models.PageDataResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author daiyihua
+ * @create 2019-03-18 11:31 AM
+ * @desc 异常全局拦截
+ **/
+@ControllerAdvice
+@ResponseBody
+public class ExceptionIntercept {
+
+    private static Logger logger = LoggerFactory.getLogger(ExceptionIntercept.class);
+
+
+    /**
+     * MethodArgumentNotValidException 异常处理,用于处理 validation 里面的验证
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    public BaseResponse handleMethodArgumentNotValidException(HttpServletRequest request, MethodArgumentNotValidException ex) {
+        FieldError fieldError = ex.getBindingResult().getFieldError();
+        int code = BaseResponse.PARAMETER_ERROR;
+        return dealExceptionCommon(request, ex,code, fieldError.getDefaultMessage());
+    }
+
+    /**
+     * Exception 异常处理
+     */
+    @ExceptionHandler(value = Exception.class)
+    public BaseResponse defaultExceptionHandler(HttpServletRequest request, Exception e){
+        int code = BaseResponse.OTHER_ERROR;
+        String info = "数据读取失败";
+        return dealExceptionCommon(request, e,code, info);
+    }
+
+    private BaseResponse dealExceptionCommon(HttpServletRequest request, Throwable e,int code, String info){
+        PageDataResponse<Object> dataResponse = new PageDataResponse<>();
+        e.printStackTrace();
+        // 生成返回结果
+        logger.error("url{}:",request.getRequestURL());
+        logger.error("params:{}", JsonSerializer.toJson(request.getParameterMap()));
+        logger.error(e.getMessage(), e);
+        return dataResponse.failed(code, info);
+    }
+
+}

+ 78 - 0
src/main/java/com/ywt/mg/web/interceptors/HttpContextUtil.java

@@ -0,0 +1,78 @@
+package com.ywt.mg.web.interceptors;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author daiyihua
+ * @create 2022-12-03 21:19
+ * @program his_open_api
+ * @description HttpContextUtil
+ **/
+public class HttpContextUtil {
+
+    /**
+     * 获取query参数
+     *
+     * @param request
+     * @return
+     */
+    public static Map<String, String> getParameterMapAll(HttpServletRequest request) {
+        Enumeration<String> parameters = request.getParameterNames();
+
+        Map<String, String> params = new HashMap<>();
+        while (parameters.hasMoreElements()) {
+            String parameter = parameters.nextElement();
+            String value = request.getParameter(parameter);
+            params.put(parameter, value);
+        }
+
+        return params;
+    }
+
+    /**
+     * 获取请求Body
+     *
+     * @param request
+     * @return
+     */
+    public static String getBodyString(ServletRequest request) {
+        StringBuilder sb = new StringBuilder();
+        InputStream inputStream = null;
+        BufferedReader reader = null;
+        try {
+            inputStream = request.getInputStream();
+            reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+            String line = "";
+            while ((line = reader.readLine()) != null) {
+                sb.append(line);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return sb.toString();
+    }
+}

+ 120 - 0
src/main/java/com/ywt/mg/web/interceptors/HttpServletRequestFilter.java

@@ -0,0 +1,120 @@
+package com.ywt.mg.web.interceptors;
+
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
+/***
+ * HttpServletRequest 过滤器
+ * 解决: request.getInputStream()只能读取一次的问题
+ * 目标: 流可重复读
+ * @create 2022-12-03 21:43
+ * @author daiyihua
+ */
+@Component
+@WebFilter(filterName = "HttpServletRequestFilter", urlPatterns = "/")
+@Order(99)
+public class HttpServletRequestFilter implements Filter {
+
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+
+    }
+
+    @Override
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+        ServletRequest requestWrapper = null;
+        if(servletRequest instanceof HttpServletRequest) {
+            requestWrapper = new RequestWrapper((HttpServletRequest) servletRequest);
+        }
+        //获取请求中的流,将取出来的字符串,再次转换成流,然后把它放入到新 request对象中
+        // 在chain.doFiler方法中传递新的request对象
+        if(null == requestWrapper) {
+            filterChain.doFilter(servletRequest, servletResponse);
+        } else {
+            filterChain.doFilter(requestWrapper, servletResponse);
+        }
+    }
+
+    @Override
+    public void destroy() {
+
+    }
+
+    /***
+     * HttpServletRequest 包装器
+     * 解决: request.getInputStream()只能读取一次的问题
+     * 目标: 流可重复读
+     */
+    public class RequestWrapper extends HttpServletRequestWrapper {
+
+        /**
+         * 请求体
+         */
+        private String mBody;
+
+        public RequestWrapper(HttpServletRequest request) {
+            super(request);
+            // 将body数据存储起来
+            mBody = getBody(request);
+        }
+
+        /**
+         * 获取请求体
+         * @param request 请求
+         * @return 请求体
+         */
+        private String getBody(HttpServletRequest request) {
+            return HttpContextUtil.getBodyString(request);
+        }
+
+        /**
+         * 获取请求体
+         * @return 请求体
+         */
+        public String getBody() {
+            return mBody;
+        }
+
+        @Override
+        public BufferedReader getReader() throws IOException {
+            return new BufferedReader(new InputStreamReader(getInputStream()));
+        }
+
+        @Override
+        public ServletInputStream getInputStream() throws IOException {
+            // 创建字节数组输入流
+            final ByteArrayInputStream bais = new ByteArrayInputStream(mBody.getBytes(StandardCharsets.UTF_8));
+
+            return new ServletInputStream() {
+                @Override
+                public boolean isFinished() {
+                    return false;
+                }
+
+                @Override
+                public boolean isReady() {
+                    return false;
+                }
+
+                @Override
+                public void setReadListener(ReadListener readListener) {
+
+                }
+
+                @Override
+                public int read() throws IOException {
+                    return bais.read();
+                }
+            };
+        }
+    }
+}

+ 194 - 0
src/main/java/com/ywt/mg/web/interceptors/WebAppContext.java

@@ -0,0 +1,194 @@
+package com.ywt.mg.web.interceptors;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpSession;
+import java.util.Map;
+
+/**
+ * 保存当前请求与业务相关的信息上下文
+ * 由拦截器层提供信息初始化
+ * Created by huangguoping.
+ */
+public class WebAppContext {
+    private volatile static WebAppContext _webAppContext = null;
+    private static Object _lockObj = new Object();
+
+    private ThreadLocal<Boolean> _capChecked = new ThreadLocal<>();
+    private ThreadLocal<Long> _requestStartTime = new ThreadLocal<>();
+    private ThreadLocal<String> _requestID = new ThreadLocal<>();
+    private ThreadLocal<String> _ip = new ThreadLocal<>();
+    private ThreadLocal<Map<String, Cookie>> _cookies = new ThreadLocal<>();
+    private ThreadLocal<String> _host = new ThreadLocal<>();
+    private ThreadLocal<String> _token = new ThreadLocal<>();
+    private ThreadLocal<HttpSession> sessionThreadLocal = new ThreadLocal<>();
+    private ThreadLocal<Integer> _adminid = new ThreadLocal<>();
+    private ThreadLocal<Integer> _pharmacyId = new ThreadLocal<>();
+    private ThreadLocal<Integer> _terminal = new ThreadLocal<>();
+    private ThreadLocal<String> _gwProtocol = new ThreadLocal<>();
+    private ThreadLocal<String> _gwAuthAppid = new ThreadLocal<>();
+    private ThreadLocal<Integer> _userid = new ThreadLocal<>();
+    private ThreadLocal<Integer> _hospitalid = new ThreadLocal<>();
+
+    private WebAppContext() {
+    }
+
+    public boolean capChecked() {
+        return _capChecked.get() == null ? false : _capChecked.get();
+    }
+
+    protected WebAppContext setCapChecked(boolean flag) {
+        _capChecked.set(flag);
+        return this;
+    }
+
+    public long getRequestStartTime() {
+        return _requestStartTime.get() == null ? 0L : _requestStartTime.get();
+    }
+
+    protected WebAppContext setRequestStartTime(long time) {
+        _requestStartTime.set(time);
+        return this;
+    }
+
+    public String getRequestID() {
+        return _requestID.get() == null ? "" : _requestID.get();
+    }
+
+    protected WebAppContext setRequestID(String id) {
+        _requestID.set(id);
+        return this;
+    }
+
+    public String getIP() {
+        return _ip.get() == null ? "" : _ip.get();
+    }
+
+    protected WebAppContext setIP(String ip) {
+        _ip.set(ip);
+        return this;
+    }
+
+    public Map<String, Cookie> getCookies() {
+        return _cookies.get();
+    }
+
+    protected WebAppContext setCookies(Map<String, Cookie> cookies) {
+        _cookies.set(cookies);
+        return this;
+    }
+
+    public String getHost() {
+        return this._host.get();
+    }
+
+    protected WebAppContext setHost(String host) {
+        this._host.set(host);
+        return this;
+    }
+
+    protected WebAppContext setToken(String token) {
+        this._token.set(token);
+        return this;
+    }
+
+    public String getToken() {
+        return this._token.get();
+    }
+
+    protected WebAppContext setSession(HttpSession session) {
+        this.sessionThreadLocal.set(session);
+        return this;
+    }
+
+    public HttpSession getSession() {
+        return this.sessionThreadLocal.get();
+    }
+
+    protected WebAppContext setAdminId(int adminid) {
+        this._adminid.set(adminid);
+        return this;
+    }
+
+    public Integer getAdminId() {
+        return this._adminid.get();
+    }
+
+    protected WebAppContext setPharmacyId(int id) {
+        this._pharmacyId.set(id);
+        return this;
+    }
+
+    public Integer getPharmacyId() {
+        return this._pharmacyId.get();
+    }
+
+    public Integer getTerminal() {
+        return _terminal.get() == null ? 0 : _terminal.get();
+    }
+
+    protected void setTerminal(Integer terminal) {
+        this._terminal.set(terminal);
+    }
+
+    public String getGWProtocol() {
+        return _gwProtocol.get() == null ? "" : _gwProtocol.get();
+    }
+
+    protected void setGWProtocol(String protocol) {
+        _gwProtocol.set(protocol);
+    }
+
+    protected void setGWAuthAppid(String appid) {
+        this._gwAuthAppid.set(appid);
+    }
+
+    public String getGWAuthAppid() {
+        return this._gwAuthAppid.get();
+    }
+
+    public WebAppContext setUserId(int userid) {
+        this._userid.set(userid);
+        return this;
+    }
+
+    public Integer getUserId() {
+        return this._userid.get();
+    }
+
+    public WebAppContext setHospitalId(int hospitalId) {
+        this._hospitalid.set(hospitalId);
+        return this;
+    }
+
+    public Integer getHospitalId() {
+        return this._hospitalid.get();
+    }
+
+    protected void init() {
+        _capChecked.set(false);
+        _requestStartTime.set(0L);
+        _requestID.set("");
+        _ip.set("");
+        _cookies.set(null);
+        _host.set("");
+        _token.set("");
+        sessionThreadLocal.set(null);
+        _adminid.set(0);
+        _pharmacyId.set(0);
+        _terminal.set(0);
+        _gwProtocol.set("");
+        _gwAuthAppid.set("");
+        _hospitalid.set(0);
+    }
+
+    public static WebAppContext current() {
+        if (_webAppContext == null) {
+            synchronized (_lockObj) {
+                if (_webAppContext == null) {
+                    _webAppContext = new WebAppContext();
+                }
+            }
+        }
+        return _webAppContext;
+    }
+}

+ 13 - 0
src/main/resources/application.properties

@@ -0,0 +1,13 @@
+server.port=13900
+
+server.servlet.context-path=/hisEsbApi
+
+#server.api.url=https://openapi-qa.ywtinfo.com/hosp/notify/v2
+#server.api.url=http://127.0.0.1:7668/hosp/notify/v2
+#server.api.url=http://127.0.0.1:7668/hosp/notify/v2
+server.api.url=https://openapi-qa.ywtinfo.com/hosp/notify/v2
+#server.api.url=http://127.0.0.1:9999
+
+com.parm.checkAppIdMap=[{"appId":"ywt-common-push-taihe","appSecret":"ywt-common-push-Ux8$6x0Dz1l-taihe"},{"appId":"hospital_3th_gz_test2", "appSecret":"afe6aaa2-d79b-4e7f-982f-6b19edea59f5dfdf"}]
+
+

+ 31 - 0
src/main/resources/logback-spring.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false">
+    <appender name="FILE"  class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志文件输出的文件名-->
+            <FileNamePattern>./logs/mg.%d{yyyy-MM-dd}.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <MaxHistory>30</MaxHistory>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+        </encoder>
+        <!--日志文件最大的大小-->
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+            <MaxFileSize>100MB</MaxFileSize>
+        </triggeringPolicy>
+    </appender>
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="org.hibernate" level="ERROR" />
+    <!-- 日志输出级别 -->
+    <root level="@logging.level.root@">
+        <appender-ref ref="FILE" />
+        <appender-ref ref="console" />
+    </root>
+</configuration>