Browse Source

顺丰快递相关接口

huangwenjie 7 years ago
parent
commit
8b3303a457
35 changed files with 1565 additions and 315 deletions
  1. 1 0
      common-lib/pom.xml
  2. 449 0
      patient-co/patient-co-pc/pom.xml
  3. 17 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/Application.java
  4. 37 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/MvcConfig.java
  5. 48 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/SwaggerConfig.java
  6. 54 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/async/AsyncConfig.java
  7. 27 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/jpa/HibernateProperties.java
  8. 67 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/jpa/WlyyJpa.java
  9. 44 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/security/WebSecurityConfig.java
  10. 15 0
      patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/war/ServletInitializer.java
  11. 73 0
      patient-co/patient-co-pc/src/main/resources/application.yml
  12. 2 2
      patient-co/patient-co-wlyy/pom.xml
  13. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java
  14. 82 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdjust.java
  15. 9 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  16. 34 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java
  17. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java
  18. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/organization/HospitalMappingDao.java
  19. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  20. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustDao.java
  21. 4 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDiagnosisService.java
  22. 30 45
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java
  23. 66 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  24. 11 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java
  25. 20 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  26. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/QrcodeUtil.java
  27. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  28. 76 38
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionCodeController.java
  29. 33 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  30. 72 28
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  31. 179 127
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java
  32. 16 16
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  33. 15 19
      patient-co/patient-co-wlyy/src/main/resources/application.yml
  34. 9 0
      patient-co/patient-co-wlyy/src/main/resources/system.properties
  35. 4 2
      pom.xml

+ 1 - 0
common-lib/pom.xml

@ -22,6 +22,7 @@
        <module>../patient-co/patient-co-wlyy</module> <!--i健康-->
        <module>../patient-co/patient-co-statistics</module> <!--i健康 mysql 版本统计-->
        <module>../patient-co/patient-co-statistics-es</module> <!--i健康 es 版本统计-->
        <module>../patient-co/patient-co-pc</module><!--im pc 版本-->
        <!--<module>../patient-co-figure</module>-->
    </modules>

+ 449 - 0
patient-co/patient-co-pc/pom.xml

@ -0,0 +1,449 @@
<?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">
    <parent>
        <artifactId>common-lib</artifactId>
        <groupId>com.yihu</groupId>
        <version>1.0.0</version>
        <relativePath>../../common-lib/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>patient-co-pc</artifactId>
    <name>patient-co-pc</name>
    <version>1.0.0</version>
    <packaging>war</packaging>
    <!-- 设定插件仓库, 如有Nexus私服, 取消注释并指向正确的服务器地址. -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://172.19.103.47:8081/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <!--Spring boot family-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-docs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-devtools</artifactId>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <!-- end -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <!-- spring start -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-keyvalue</artifactId>
        </dependency>
        <!-- spring end -->
        <!--Swagger start -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
        </dependency>
        <!--Swagger end -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>jave-ffmpegjave</artifactId>
        </dependency>
        <!-- poi start-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>
        <!-- poi end-->
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
        </dependency>
        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis-jaxrpc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <dependency>
            <groupId>sehrCrypto</groupId>
            <artifactId>sehrCrypto</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk16</artifactId>
        </dependency>
        <!-- Apache Commons fileupload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>
            <artifactId>springside-core</artifactId>
        </dependency>
        <!-- PERSISTENCE begin -->
        <!-- hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.kaptcha</groupId>
            <artifactId>kaptcha</artifactId>
        </dependency>
        <!-- spring data access -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
        </dependency>
        <!-- aspectjrt start -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>
        <!-- aspectjrt end -->
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <!-- jdbc driver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- PERSISTENCE end -->
        <!-- WEB begin -->
        <dependency>
            <groupId>opensymphony</groupId>
            <artifactId>sitemesh</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <!-- WEB end -->
        <!-- JSR303 BeanValidator -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>
        <!-- JSON begin -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <!-- JSON end -->
        <dependency>
            <groupId>org.htmlparser</groupId>
            <artifactId>htmlparser</artifactId>
        </dependency>
        <dependency>
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
        </dependency>
        <!-- LOGGING begin -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </dependency>
        <!-- 代码直接调用log4j会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </dependency>
        <!-- 代码直接调用common-logging会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
        </dependency>
        <!-- 代码直接调用java.util.logging会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
        </dependency>
        <!-- LOGGING end -->
        <!-- GENERAL UTILS begin -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <!-- GENERAL UTILS end -->
        <!-- selenium 2.0 -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-htmlunit-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-android-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-iphone-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-safari-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>cglib</groupId>
                    <artifactId>cglib-nodep</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--二维码生成 start-->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
        </dependency>
        <!--二维码生成 end-->
        <!-- quartz start  -->
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <!-- quartz end  -->
        <!-- redis start  -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <!-- redis end  -->
        <!--fastdfs start-->
        <dependency>
            <groupId>org.csource</groupId>
            <artifactId>fastdfs_lib</artifactId>
        </dependency>
        <!--fastdfs end-->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.ylz</groupId>
            <artifactId>onepay-java-sdk</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>
        <plugins>
            <!--打成war包需要的配置-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <verbose/>
                        <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
                <version>3.1</version>
            </plugin>
        </plugins>
    </build>
</project>

+ 17 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/Application.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.pc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
/**
 * Created by chenweida on 2017/8/2.
 */
@SpringBootApplication
public class Application {
    public static ApplicationContext ctx = null;
    public static void main(String[] args) {
        ctx = SpringApplication.run(Application.class, args);
    }
}

+ 37 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/MvcConfig.java

@ -0,0 +1,37 @@
package com.yihu.wlyy.pc.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
//        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**","/statistics/province/**","/statistics/**");
//        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
//        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        super.addInterceptors(registry);
    }
//    /**
//     * 为null的数据不返回
//     * @param converters
//     */
//    @Override
//    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
//        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
//        ObjectMapper objectMapper=new ObjectMapper();
//        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
//        mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
//        converters.add(mappingJackson2HttpMessageConverter);
//    }
}

+ 48 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/SwaggerConfig.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.pc.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    private static final String PUBLIC_API = "other";
    @Bean
    public Docket publicAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(PUBLIC_API)
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(PathSelectors.regex("/.*"))
                .build()
                .apiInfo(publicApiInfo());
    }
    private ApiInfo publicApiInfo() {
        ApiInfo apiInfo = new ApiInfo("三师平台API",
                "向PC端,微信、App等应用提供功能与数据接口。",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
}

+ 54 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/async/AsyncConfig.java

@ -0,0 +1,54 @@
package com.yihu.wlyy.pc.config.async;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created by chenweida on 2016.10.18.
 * 启用多綫程
 */
@Configuration
@EnableAsync
public class AsyncConfig {
    /**
     * 如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程
     */
    private int corePoolSize = 5;
    /**
     * 如果池中的线程数=maximumPoolSize,则有空闲线程使用空闲线程,否则新任务放入queueCapacity.
     * 设定 比 系统native thread个数要大的话,会优先抛出Java.lang.OutOfMemoryError: unable to create new native thread
     */
    private int maxPoolSize = 10;
    /**
     * 缓冲队列大小
     */
    private int queueCapacity = 100;
    /**
     * 线程池维护线程所允许的空闲时间  秒
     */
    private int keepAliveSeconds = 300;
    @Bean
    public Executor wlyyExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setKeepAliveSeconds(keepAliveSeconds);
        /** Reject策略预定义有四种:
         (1)ThreadPoolExecutor.AbortPolicy策略,是默认的策略,处理程序遭到拒绝将抛出运行时 RejectedExecutionException。
         (2)ThreadPoolExecutor.CallerRunsPolicy策略 ,调用者的线程会执行该任务,如果执行器已关闭,则丢弃.
         (3)ThreadPoolExecutor.DiscardPolicy策略,不能执行的任务将被丢弃.
         (4)ThreadPoolExecutor.DiscardOldestPolicy策略,如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程).
         */
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}

+ 27 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/jpa/HibernateProperties.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.pc.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 67 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/jpa/WlyyJpa.java

@ -0,0 +1,67 @@
package com.yihu.wlyy.pc.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "entityManagerFactory",
        transactionManagerRef = "wlyyTransactionManager",
        basePackages = {"com.yihu.wlyy.dao"})   //设置Repository所在位置
public class WlyyJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "wlyyDataSource")
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource wlyyDataSource() {
        return DataSourceBuilder.create().build();
    }
    @Bean(name = "entityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(
            @Qualifier("wlyyDataSource") DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.wlyy.entity");
        emfb.setPersistenceUnitName("wlyy");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyyTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("entityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 44 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/security/WebSecurityConfig.java

@ -0,0 +1,44 @@
package com.yihu.wlyy.pc.config.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
 * Created by Administrator on 2016.10.17.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Value("${security.basic.username}")
    String username;
    @Value("${security.basic.password}")
    String password;
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/swagger-ui.html").authenticated()
                .antMatchers("/swagger-ui.html").authenticated()
                .antMatchers("/configuration/security").authenticated()
                .anyRequest().permitAll()
                .and()
                .csrf().disable()
                .formLogin().defaultSuccessUrl("/swagger-ui.html").failureUrl("/login") //登录成功之后的跳转
                .permitAll()
                .and()
                .logout().logoutSuccessUrl("/login")
                .permitAll();
    }
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser(username).password(password).roles("USER");
    }
}

+ 15 - 0
patient-co/patient-co-pc/src/main/java/com/yihu/wlyy/pc/config/war/ServletInitializer.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.pc.config.war;//package com.yihu.wlyy.config.war;
import com.yihu.wlyy.pc.Application;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */
public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

+ 73 - 0
patient-co/patient-co-pc/src/main/resources/application.yml

@ -0,0 +1,73 @@
server:
  port: 8080
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    max-idle: 50 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 30000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 50 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
    # REDIS
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.
    timeout: 0 # Connection timeout in milliseconds.
      #sentinel:
      #  master: # Name of Redis server.
      #  nodes: # Comma-separated list of host:port pairs.
logging:
  level:
    root: INFO
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
multipart:
  enabled: true
  max-file-size: 50mb
  max-request-size: 50mb
security:
  basic:
    username: jkzl
    password: jkzlehr
---
spring:
  profiles: test
---
spring:
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.85/wlyy?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: linzhou
    password: linzhou
---
spring:
  profiles: prod

+ 2 - 2
patient-co/patient-co-wlyy/pom.xml

@ -410,12 +410,12 @@
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <!--易联众支付-->
        <dependency>
            <groupId>com.ylz</groupId>
            <artifactId>onepay-java-sdk</artifactId>
            <artifactId>onpay-java-sdk-all</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java

@ -82,6 +82,15 @@ public class SignFamily extends IdEntity {
    private String sickVillage;
    // 居委会字段名称
    private String sickVillageName;
    private Integer signPaySource;//签约支付渠道: 1线下 2线上
    public Integer getSignPaySource() {
        return signPaySource;
    }
    public void setSignPaySource(Integer signPaySource) {
        this.signPaySource = signPaySource;
    }
    public String getRenewFlag() {
        return renewFlag;

+ 82 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdjust.java

@ -0,0 +1,82 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方
 */
@Entity
@Table(name = "wlyy_prescription_adjust")
public class PrescriptionAdjust extends IdEntity {
    private String code;                    //业务主键
    private String prescriptionCode;// 处方code
    private Date createTime;               //调整时间
    private String reason;                      //调整原因
    private String userCode;    //调整用户code
    private String userName;    //调整用户名称
    private String userType;// 1医生 2患者
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getUserType() {
        return userType;
    }
    public void setUserType(String userType) {
        this.userType = userType;
    }
}

+ 9 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.event;
import com.yihu.wlyy.job.PrescriptionPayOverdueJob;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.SignAgainJob;
import com.yihu.wlyy.job.SignEndJob;
@ -50,7 +51,14 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("sign_again_job exist");
            }
            //续方支付到期,每天0点触发
            if (!quartzHelper.isExistJob("prescription_pay_overdue_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescription_pay_overdue_job");
                quartzHelper.addJob(PrescriptionPayOverdueJob.class, trigger, "prescription_pay_overdue_job", new HashMap<String, Object>());
                logger.info("prescription pay overdue job success");
            } else {
                logger.info("prescription pay overdue job exist");
            }
            //启动发送产检提醒模板消息
//            if (!quartzHelper.isExistJob("prenatal_inspector_job")) {
//                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prenatal_inspector_job_trigger");

+ 34 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java

@ -0,0 +1,34 @@
package com.yihu.wlyy.job;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
/**
 * Created by Trick on 2017/8/2.
 */
@Component
public class PrescriptionPayOverdueJob implements Job {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            logger.info("Prescription_Pay_Overdue_Job_start");
            StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription SET status = -3 WHERE TIMESTAMPDIFF(second,create_time,NOW())>=172800");
            jdbcTemplate.execute(sql.toString());
            logger.info("Prescription_Pay_Overdue_Job_end");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("Prescription_Pay_Overdue_Job_error");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java

@ -56,7 +56,7 @@ public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>,
    @Modifying
    @Query("update WlyyCharge a set a.tradeStatus = ?9,a.chargeTime = ?2, a.updateTime = ?3, a.totalAmount = ?4, " +
            " a.insuranceAmount = ?5, a.selfpayAmount =?6 ,a.billNo = ?7, a.miRegisterNo = ?8 where a.code = ?1 ")
    WlyyCharge updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    int updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/organization/HospitalMappingDao.java

@ -24,5 +24,8 @@ public interface HospitalMappingDao extends PagingAndSortingRepository<HospitalM
	@Query("select a.code from HospitalMapping a where a.mappingCode=?1 and a.type=?2")
	String getCodeByMapping(String mappingCode,String type);
	@Query("select a from HospitalMapping a where a.appId=?1 ")
	HospitalMapping findByAppId(String appId);
	HospitalMapping findByCode(String code);
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -408,8 +408,8 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    //      完成缴费后更新签约开始时间begin 缴费状态expensesStatus 医保流水号medical_insurance_num  扣费时间expenses_time
    @Modifying
    @Query("update SignFamily a set a.begin = ?2 ,a.medicalInsuranceNum=?3,a.expensesStatus = ?4,a.expensesTime = ?2 where a.code = ?1 ")
    int updatePatientBegin(String code, Date begin,String medicalInsuranceNum,String expensesStatus );
    @Query("update SignFamily a set a.begin = ?2 ,a.medicalInsuranceNum=?3,a.expensesStatus = ?4,a.expensesTime = ?2,a.signPaySource = ?5 where a.code = ?1 ")
    int updatePatientBegin(String code, Date begin,String medicalInsuranceNum,String expensesStatus,int signPaySource );
    //查询居民的扣费状态
    @Query( " select a from SignFamily a where a.patient = ?1 ")

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustDao.java

@ -0,0 +1,12 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjust;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/2.
 */
public interface PrescriptionAdjustDao extends PagingAndSortingRepository<PrescriptionAdjust, Long>,JpaSpecificationExecutor<PrescriptionAdjust> {
}

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDiagnosisService.java

@ -55,7 +55,7 @@ public class PrescriptionDiagnosisService extends BaseService{
                            jsonArray.add(json);
                        }
                        re = jsonArray.toString();
                        redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
                        redisTemplate.opsForValue().set(key,re,180, TimeUnit.DAYS);
                    }
                }else {
                    jsonArray = JSONArray.fromObject(re);
@ -89,7 +89,7 @@ public class PrescriptionDiagnosisService extends BaseService{
                    if(list!=null&&list.size()>0){
                        jsonArray = JSONArray.fromObject(list);
                        re = jsonArray.toString();
                        redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
                        redisTemplate.opsForValue().set(key,re,180, TimeUnit.DAYS);
                    }
                }else {
                    jsonArray = JSONArray.fromObject(re);
@ -124,7 +124,7 @@ public class PrescriptionDiagnosisService extends BaseService{
                        jsonArray.add(json);
                    }
                    String re = jsonArray.toString();
                    redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
                    redisTemplate.opsForValue().set(key,re,180, TimeUnit.DAYS);
                }
            }
        }
@ -149,7 +149,7 @@ public class PrescriptionDiagnosisService extends BaseService{
                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
                if(list!=null&&list.size()>0){
                    String re = JSONArray.fromObject(list).toString();
                    redisTemplate.opsForValue().set(key,re,2, TimeUnit.HOURS);
                    redisTemplate.opsForValue().set(key,re,180, TimeUnit.DAYS);
                }
            }
        }

+ 30 - 45
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -7,7 +7,9 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.QrcodeService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.QrcodeUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import org.apache.commons.lang3.StringUtils;
@ -22,8 +24,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@ -66,8 +67,9 @@ public class PrescriptionDispensaryCodeService extends BaseService {
                case 4:timeLimit = 7*24*60*60*31*12;break;//近一年
            }
        }
        List<Object> params = new ArrayList<>();
        String precriptionSql = "select p2.*,p1.diagnosis as diagnosis ,p3.address as address from wlyy_prescription_dispensary_code p2 left join  wlyy_prescription p1 on p2.prescription_code=p1.code LEFT JOIN wlyy_prescription_expressage p3 on p1.code=p3.prescription_code where p1.patient=? and p2.type=?  and p2.is_Use=0 ";
        List<Object> params = new ArrayList<>();//p2.*,p1.diagnosis as diagnosis ,p3.address as address
        String precriptionSql = "select p1.status , p1.diagnosis ,p3.address as address,p2.prescription_code as prescriptionCode,p2.code as dispensaryCode,p2.type  from wlyy_prescription_dispensary_code p2 " +
                " left join  wlyy_prescription p1 on p2.prescription_code=p1.code LEFT JOIN wlyy_prescription_expressage p3 on p1.code=p3.prescription_code where p1.patient=? and p2.type=?  and p2.is_Use=0 ";
        params.add(patientCode);
        params.add(type);
        if(status!=null){
@ -84,8 +86,8 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        List<Map<String, Object>> result = jdbcTemplate.queryForList(precriptionSql,params.toArray());
        List<Map<String, Object>> result2 = new ArrayList<>();
        for (Map<String, Object> m:result) {
            List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(m.get("prescription_code").toString());
            m.put("data",list);
            List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(m.get("prescriptionCode").toString());
            m.put("prescriptionInfo",list);
            result2.add(m);
        }
        JSONArray array = new JSONArray(result2);
@ -110,7 +112,7 @@ public class PrescriptionDispensaryCodeService extends BaseService {
    //生成居民端取药码
    @Transactional
    public PrescriptionDispensaryCode savePatientQRCode(String token,String prescriptionCode){
    public PrescriptionDispensaryCode savePatientQRCode(String token,String prescriptionCode) throws Exception {
        //获取年月日8位数
        Calendar cal  = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
@ -129,8 +131,9 @@ public class PrescriptionDispensaryCodeService extends BaseService {
            }
        }
        // 生成二维码
        ObjectNode imgNode = makeQrcodeFromWeiXin(token,code);
        //Prescription类  取药类型:1 自取 2快递配送 3健管师配送
        InputStream ipt = QrcodeUtil.createQrcode(code,300,"png");
        ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
//        Prescription类  取药类型:1 自取 2快递配送 3健管师配送
        String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
                + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"","");
@ -142,12 +145,11 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        prescriptionDispensaryCode.setPrescriptionCode(prescriptionCode);
        prescriptionDispensaryCode.setType(1);
        return prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
    }
    //生成配送员(健管师)取药码
    //生成配送员(健管师)(2、取药码  2、配送码)
    @Transactional
    public PrescriptionDispensaryCode saveDoctorQRCode(String code,String token,String prescriptionCode){
    public PrescriptionDispensaryCode saveQRCode(String code,String token,String prescriptionCode,Integer type) throws Exception {
        String jgsCode= "";
        synchronized (obj2){
            boolean bl = true;
@ -159,49 +161,23 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        }
        //String jgsID= "";//配送员用户ID后4位
//        String jgsCode = code+"1234";//code+jgsID.substring(jgsID.length()-4);
        ObjectNode imgNode2 = makeQrcodeFromWeiXin(token,jgsCode);
        String fileUrl = fastdfs_file_url + imgNode2.get("groupName").toString().replaceAll("\"","")
                + "/" + imgNode2.get("remoteFileName").toString().replaceAll("\"","");
        // 生成二维码
        InputStream ipt = QrcodeUtil.createQrcode(code,300,"png");
        ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
//        Prescription类  取药类型:1 自取 2快递配送 3健管师配送
        String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
                + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"","");
        //新增配送员处方取码记录
        PrescriptionDispensaryCode prescriptionDispensaryCode = new PrescriptionDispensaryCode();
        prescriptionDispensaryCode.setCode(jgsCode);
        prescriptionDispensaryCode.setCreateTime(new Date());
        prescriptionDispensaryCode.setImgUrl(fileUrl);
        prescriptionDispensaryCode.setPrescriptionCode(prescriptionCode);
        prescriptionDispensaryCode.setType(2);
        prescriptionDispensaryCode.setType(type);
        return prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
    }
    //在微信端生成二维码,并上传FastFDS
    public ObjectNode makeQrcodeFromWeiXin(String token,String content){
        String token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + token;
        String params = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"" + content + "\"}}}";
        String result = httpUtil.sendPost(token_url, params);
        if (!StringUtils.isEmpty(result)) {
            JSONObject json = new JSONObject(result);
            // 下载二维码图片
            URL urlGet = null;
            try {
                urlGet = new URL("https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
                        + URLEncoder.encode(json.get("ticket").toString(), "UTF-8"));
                HttpURLConnection connection = (HttpURLConnection) urlGet.openConnection();
                connection.connect();
                ObjectNode imgNode = FastDFSUtil.upload(connection.getInputStream(),"png","QRCode_"+System.currentTimeMillis());
                return imgNode;
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    //随机生成匹配数字
    public  String randomString(String base, int length) {
@ -213,4 +189,13 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        }
        return sb.toString();
    }
    public Map<String, Object> getQrcode(String dispensaryCode ,String patientCode ,Integer type){
        String sql = "select p2.code as dispensaryCode,p2.img_url,p3.hospital_name as hospitalName  from wlyy_prescription_dispensary_code p2 " +
                " left join  wlyy_prescription p1 on p2.prescription_code=p1.code LEFT JOIN wlyy_prescription_expressage p3 on p1.code=p3.prescription_code " +
                " where p2.prescription_code=? and p1.patient=? and p2.type=?  and p2.is_Use=0 ";
        Map<String, Object> result = jdbcTemplate.queryForMap(sql,dispensaryCode,patientCode,type);
        return result;
    }
}

+ 66 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -6,11 +6,13 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjust;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionAdjustDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
@ -49,6 +51,8 @@ public class PrescriptionInfoService extends BaseService {
    @Autowired
    private PrescriptionDiagnosisService prescriptionDiagnosisService;
    @Autowired
    private PrescriptionAdjustDao prescriptionAdjustDao;
    @Autowired
    private ImUtill imUtill;
    /**
@ -104,7 +108,7 @@ public class PrescriptionInfoService extends BaseService {
                }
                //本地库
                List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),params.toArray());
                //通过缓存查找药品和疾病
                for(Map<String,Object> map :rs){
                    String code = (String)map.get("code");
                    map.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(code));
@ -148,14 +152,24 @@ public class PrescriptionInfoService extends BaseService {
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
            Patient p = patientDao.findByCode(prescription.getPatient());
            rs.put("patient",p);
        }else{
            rs.put("patient","");
        }
        if(prescription.getStatus()==10){
            Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
            rs.put("time",s);
            if(s>172800){
                prescription.setStatus(-3);
                prescriptionDao.save(prescription);
            }
        }else{
            rs.put("time","");
        }
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        return rs;
    }
@ -194,7 +208,7 @@ public class PrescriptionInfoService extends BaseService {
    }
    public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate ){
    public JSONArray getDoctorPrescription(Integer teamCode,String state,String diseases,String startDate,String endDate,String nameKeyword){
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
@ -215,18 +229,25 @@ public class PrescriptionInfoService extends BaseService {
                    " AND pr.admin_team_id =? AND s.code = ?");
            params.add(teamCode);
            params.add(diseases);
            setSQL(pre_sql,params,state,startDate,endDate);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword);
        }else{
            //查询所有疾病类型表
            pre_sql.append(" WHERE pr.admin_team_id =?");
            params.add(teamCode);
            setSQL(pre_sql,params,state,startDate,endDate);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword);
        }
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
        //通过缓存查找药品和疾病
        for(Map<String,Object> map :rs){
            String code = (String)map.get("code");
            map.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(code));
            map.put("prescriptionDt", prescriptionDiagnosisService.getPrescriptionDiagnosis(code));
        }
        return new JSONArray(rs);
    }
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate){
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword){
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status = ?");
            params.add(state);
@ -239,7 +260,11 @@ public class PrescriptionInfoService extends BaseService {
            pre_sql.append(" AND pr.create_time <= ?");
            params.add(endDate);
        }
        pre_sql.append(" ORDER BY pr.create_time DESC");
        if(StringUtils.isNotBlank(nameKeyword)){
            pre_sql.append(" AND pr.patient_name like ?");
            params.add("%"+nameKeyword+"%");
        }
        pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");
    }
    /**
@ -267,14 +292,16 @@ public class PrescriptionInfoService extends BaseService {
            if("1".equals(state)){
                //审核通过
                p.setStatus(10);
                p.setReviewedTime(new Date());
            }else{
                //审核不通过
                p.setStatus(-1);
                p.setReviewedReason(reason);
                p.setReviewedTime(new Date());
            }
            prescriptionDao.save(p);
            //患者操作日志
            //医生操作日志
            PrescriptionLog log = new PrescriptionLog();
            log.setCode(getCode());
            log.setStatus(p.getStatus());
@ -306,7 +333,7 @@ public class PrescriptionInfoService extends BaseService {
        return 0;
    }
    public int updatePresInfo(String code,String infos){
    public int updatePresInfo(String code,String infos,String reason){
        if(StringUtils.isNotBlank(code)&&StringUtils.isNotBlank(infos)){
            //同步智业接口
            upload();
@ -333,6 +360,35 @@ public class PrescriptionInfoService extends BaseService {
            }
            //设置处方疾病类型
            prescriptionDiagnosisService.setPrescriptionDiagnosis(code);
            Prescription p = prescriptionDao.findByCode(code);
            //记录Log
            PrescriptionLog log = new PrescriptionLog();
            log.setCode(getCode());
            log.setStatus(p.getStatus());
            log.setType(4);
            log.setCreateTime(new Date());
            log.setPrescriptionCode(p.getCode());
            log.setUserCode(p.getDoctor());
            log.setUserName(p.getDoctorName());
            log.setHospitalName(p.getHospitalName());
            log.setHospital(p.getHospital());
            log.setUserType(2);
            log.setFlag(1);
            log.setRemark("调整处方");
            prescriptionLogDao.save(log);
            //记录流水
            PrescriptionAdjust prescriptionAdjust = new PrescriptionAdjust();
            prescriptionAdjust.setCode(getCode());
            prescriptionAdjust.setCreateTime(new Date());
            prescriptionAdjust.setReason(reason);
            prescriptionAdjust.setUserCode(p.getDoctor());
            prescriptionAdjust.setUserName(p.getDoctorName());
            prescriptionAdjust.setUserType("1");
            prescriptionAdjust.setPrescriptionCode(code);
            prescriptionAdjustDao.save(prescriptionAdjust);
            return 1 ;
        }
        return 0;

+ 11 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java

@ -14,7 +14,8 @@ public class Configure {
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
	private String onepayApi = "https://xmhealth.ylzpay.com:8070/";
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
@ -25,6 +26,15 @@ public class Configure {
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;

+ 20 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -19,11 +19,14 @@ import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.wx.OnePayController;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
@ -71,6 +74,9 @@ public class OnePayService {
    @Value("${wechat.accId}")
    private String accId;
    Properties systemConf = SystemConf.getInstance().getSystemProperties();
    private static final Logger LOGGER = LoggerFactory.getLogger(OnePayController.class);
    /**
     * 查询绑卡信息(本人)
     */
@ -361,16 +367,13 @@ public class OnePayService {
    /**
     * 家庭医生签约支付查询
     */
    public Charge chargeQuery(String code, String accessToken) throws Exception {
    public String chargeQuery(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        Charge result = null;
        String result = null;
//        String appId = config.getOnepayAppId();
//        String appSecret = config.getOnepayAppSecret();
//        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
        WlyyCharge charge = chargeDao.findByCode(code);
        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
@ -400,12 +403,15 @@ public class OnePayService {
            response = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
//                只返回业务出参  res.getResponseContent()返回医保机构体
                //业务处理*******************
//                只返回业务出参
                result = JSON.toJavaObject(res.getParam(), Charge.class);
//                result = JSON.toJavaObject(res.getParam(), Charge.class);
                result = JSON.toJSONString(res.getParam());
//                 返回医保机构体
                //业务处理*******************
                System.out.println("请求成功,返回参数:" + result.getTradeStatus() + "  " + result.getUserName());
//                System.out.println("请求成功,返回参数:" + result.getTradeStatus() + "  " + result.getUserName());
                LOGGER.info("请求成功,返回参数: "+result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
@ -504,7 +510,9 @@ public class OnePayService {
        if (list != null && list.size() > 0) {
            for (WlyyCharge item : list) {
                try {
                    Charge charge = chargeQuery(item.getCode(), accessToken);
//                    Charge charge = chargeQuery(item.getCode(), accessToken);
                    String result = chargeQuery(item.getCode(), accessToken);
                    Charge charge = objectMapper.readValue(result, Charge.class);
                    if (charge != null) {
                        item.setTradeStatus(charge.getTradeStatus());            //  交易状态0 成功 1 失败 2 已退款
                        item.setChargeNo(charge.getChargeNo());       //  流水号
@ -549,14 +557,14 @@ public class OnePayService {
     * 更改数据 wlyy_sign_family wlyy_charge
     */
    public void updateData(String chargeCode, String chargeNo, String chargeTime, String totalAmount, String insuranceAmount, String selfPayAmount, String billNo, String miRegisterNo) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        Date chargeSuccess = sdf.parse(chargeTime);
        Date updateTime = new Date();
        chargeDao.updateByChargeCode(chargeCode, chargeTime, updateTime, Integer.parseInt(totalAmount), Integer.parseInt(insuranceAmount), Integer.parseInt(selfPayAmount),
                billNo, miRegisterNo, "0");
//        根据wlyy_charge的code 去查找关联代码signCode在更新签约表
        WlyyCharge charge = chargeDao.findByCode(chargeCode);
        signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeSuccess, chargeNo, "1");
        signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeSuccess, chargeNo, "1",2);
    }
}

+ 33 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/QrcodeUtil.java

@ -6,6 +6,7 @@ import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -49,4 +50,36 @@ public class QrcodeUtil {
        MatrixToImageWriter.writeToFile(bitMatrix, imgType, outputFile);
        return outputFile;
    }
    /**
     * 创建二维码
     * @param content
     * @return
     */
    public static InputStream createQrcode(String content,int size,String imgType) {
        byte[] imagesStream=null;
        ByteArrayOutputStream os = null;
        try {
            HashMap<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
            hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
            hints.put(EncodeHintType.MARGIN, 0);
            BitMatrix bitMatrix = new MultiFormatWriter().encode(content,
              BarcodeFormat.QR_CODE, size, size, hints);
             os = new ByteArrayOutputStream();
            MatrixToImageWriter.writeToStream(bitMatrix, imgType, os);
            return new ByteArrayInputStream(os.toByteArray());
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            if(os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -296,6 +296,17 @@ public class ManagerUtilController extends BaseController {
        }
    }
    @RequestMapping(value = "/prescription_pay_overdue_job_now")
    @ResponseBody
    public String startPrescriptionPayOverdueJobNow() {
        try {
            quartzHelper.startNow(EvaluateScoreJob.class, "prescription_pay_overdue_job"+UUID.randomUUID(), new HashMap<String, Object>());
            return write(200, "启动成功");
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
    @RequestMapping(value = "/start_renew_to_sign_job")
    @ResponseBody
    public String startRenewToSignJob() {

+ 76 - 38
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionCodeController.java

@ -13,6 +13,8 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
 * Created by Trick on 2017/7/25.
 */
@ -36,49 +38,49 @@ public class PrescriptionCodeController extends BaseController{
     *  type 1、居民端扫码列表 2、配送员(健管师)扫码列表
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public String list(
            @RequestParam(value = "status",required = false) Integer status,
            @RequestParam(value = "timeType",required = false) Integer timeType,
            @RequestParam(value = "page",required = true) Integer page,
            @RequestParam(value = "pagesize",required = true) Integer pagesize) {
        //getUID()
        try{
            JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,getUID(),status,page,pagesize,2);
            return result.toString();
        }catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
//    @RequestMapping(value = "/list",method = RequestMethod.GET)
//    @ResponseBody
//    @ObserverRequired
//    public String list(
//            @RequestParam(value = "status",required = false) Integer status,
//            @RequestParam(value = "timeType",required = false) Integer timeType,
//            @RequestParam(value = "page",required = true) Integer page,
//            @RequestParam(value = "pagesize",required = true) Integer pagesize) {
//        //getUID()
//        try{
//            JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,getUID(),status,page,pagesize,2);
//            return result.toString();
//        }catch (Exception e) {
//            error(e);
//            return error(-1, "查询失败!");
//        }
//
//    }
    /**
     * 判断医生端是否有待取的药的接口
     * @return
     */
    @RequestMapping(value = "/whetherHaveCode", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public String whetherHaveCode() {
        try{
            JSONObject json = new JSONObject();
//        String patientCode = getUID();
            int count = prescriptionDispensaryCodeService.dispensaryCodeCount(getUID(),2);
            if (count > 0) {
                json.put("data", true);
                return json.toString();
            }
            json.put("data", false);
            return json.toString();
        }catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
//    @RequestMapping(value = "/whetherHaveCode", method = RequestMethod.GET)
//    @ResponseBody
//    @ObserverRequired
//    public String whetherHaveCode() {
//        try{
//            JSONObject json = new JSONObject();
////        String patientCode = getUID();
//            int count = prescriptionDispensaryCodeService.dispensaryCodeCount(getUID(),2);
//            if (count > 0) {
//                json.put("data", true);
//                return json.toString();
//            }
//            json.put("data", false);
//            return json.toString();
//        }catch (Exception e) {
//            error(e);
//            return error(-1, "查询失败!");
//        }
//
//    }
    /**
     * 确认配送 二维码方式
@ -102,4 +104,40 @@ public class PrescriptionCodeController extends BaseController{
        }
    }
    /**
     * 医生端获取取药码
     * @param dispensaryCode
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getDoctorDispensaryQrcode", method = RequestMethod.GET)
    @ObserverRequired
    public String getDoctorDispensaryQrcode(@RequestParam(value = "dispensaryCode",required = true) String dispensaryCode) {
        try{
            Map<String, Object> map = prescriptionDispensaryCodeService.getQrcode(dispensaryCode,getRepUID(),2);
            return write(200, "获取配送员取药码成功!", "data", map);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取配送员取药码失败!");
        }
    }
    /**
     * 医生端获取配送码
     * @param dispensaryCode
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getDoctorDeliveryQrcode", method = RequestMethod.GET)
    @ObserverRequired
    public String getDoctorDeliveryQrcode(@RequestParam(value = "dispensaryCode",required = true) String dispensaryCode) {
        try{
            Map<String, Object> map = prescriptionDispensaryCodeService.getQrcode(dispensaryCode,getRepUID(),3);
            return write(200, "获取配送员配送码成功!", "data", map);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取配送员配送码失败!");
        }
    }
}

+ 33 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -62,14 +62,15 @@ public class PrescriptionInfoController extends BaseController{
    @RequestMapping(value = "/getDoctorPrescription", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取全科医生/建管师续方列表")
    public String getDoctorPrescription(@RequestParam(required = false)@ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = true)@ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false)@ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false)@ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                        @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate){
                                        @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                        @RequestParam(required = false)@ApiParam(name="nameKeyword",value="患者姓名模糊匹配")String nameKeyword){
        try {
            return write(200, "查询成功!", "data",prescriptionInfoService.getDoctorPrescription(teamCode,state,diseases,startDate,endDate));
            return write(200, "查询成功!", "data",prescriptionInfoService.getDoctorPrescription(teamCode,state,diseases,startDate,endDate,nameKeyword));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -91,7 +92,7 @@ public class PrescriptionInfoController extends BaseController{
    @RequestMapping(value = "/reviewPrescription", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "续方详情")
    @ApiOperation(value = "续方审核")
    public String reviewPrescription(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false)@ApiParam(value = "不同意原因", name = "reason") String reason,
                                     @RequestParam(required = false)@ApiParam(value = "1同意,2不同意", name = "state") String state){
@ -108,9 +109,34 @@ public class PrescriptionInfoController extends BaseController{
    @ApiOperation(value = "调整处方")
    @ObserverRequired
    public String updatePresInfo(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                 @RequestParam(required = true)@ApiParam(value = "续方药品JSON", name = "infos") String infos){
                                 @RequestParam(required = true)@ApiParam(value = "续方药品JSON", name = "infos") String infos,
                                 @RequestParam(required = true)@ApiParam(value = "调整原因", name = "reason") String reason ){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.updatePresInfo(code,infos,reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getInfoTitle", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "调整处方-药品分类及种类数目")
    public String getInfoTitle(){
        try {
            return write(200, "操作成功!", "data","");
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getInfoListByParentCode", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "药品类别获取药品")
    private String getInfoListByParentCode(@RequestParam(required = true)@ApiParam(value = "药品类别Code", name = "code") String code){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.updatePresInfo(code,infos));
            return write(200, "操作成功!", "data","");
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");

+ 72 - 28
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
@ -58,13 +59,13 @@ public class PatientPrescriptionController extends WeixinBaseController {
        try {
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeService.savePatientQRCode(getAccessToken(),prescriptionCode);
            if (prescriptionDispensaryCode == null) {
                return error(-1, "生成居民二维码失败!");
                return error(-1, "生成居民取药码失败!");
            } else {
                return write(200, "生成居民二维码成功!", "code", prescriptionDispensaryCode.getCode());
                return write(200, "生成居民取药码成功!", "code", prescriptionDispensaryCode.getCode());
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "生成居民二维码失败!");
            return error(-1, "生成居民取药码失败!");
        }
    }
@ -80,19 +81,61 @@ public class PatientPrescriptionController extends WeixinBaseController {
            @RequestParam(value = "code",required = true) String code){
        try {
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeService.saveDoctorQRCode(code,getAccessToken(),prescriptionCode);
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeService.saveQRCode(code,getAccessToken(),prescriptionCode,2);
            if (prescriptionDispensaryCode == null) {
                return error(-1, "生成配送员二维码失败!");
                return error(-1, "生成配送员取药码失败!");
            } else {
                return write(200, "生成配送员二维码成功!", "code", prescriptionDispensaryCode.getCode());
                return write(200, "生成配送员取药码成功!", "code", prescriptionDispensaryCode.getCode());
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "生成配送员二维码失败!");
            return error(-1, "生成配送员取药码失败!");
        }
    }
    /**
     *生成配送员配送码
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/saveDoctorQRDeliveryCode",method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public String saveDoctorQRDeliveryCode(
            @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode,
            @RequestParam(value = "code",required = true) String code){
        try {
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeService.saveQRCode(code,getAccessToken(),prescriptionCode,3);
            if (prescriptionDispensaryCode == null) {
                return error(-1, "生成配送员配送码失败!");
            } else {
                return write(200, "生成配送员配送码成功!", "code", prescriptionDispensaryCode.getCode());
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "生成配送员配送码失败!");
        }
    }
    /**
     * 居民端获取取药码
     * @param dispensaryCode
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getPatientQrcode", method = RequestMethod.GET)
    public String getPatientQrcode(@RequestParam(value = "dispensaryCode",required = true) String dispensaryCode) {
        try{
            Map<String, Object> map = prescriptionDispensaryCodeService.getQrcode(dispensaryCode,getRepUID(),1);
            return write(200, "获取居民取药码成功!", "data", map);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取取药码失败!");
        }
    }
    /**
     * 显示居民所有的取药码列表
     * @param status
@ -112,8 +155,9 @@ public class PatientPrescriptionController extends WeixinBaseController {
            @RequestParam(value = "pagesize",required = true) Integer pagesize) {
        //getUID()"a663d0cf7f8c4d38a8327cedc921e65f"
        try {
            JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,getUID(),status,page,pagesize,1);
            return result.toString();
            JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,getRepUID(),status,page,pagesize,1);
            return write(200, "获取信息成功!", "result", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -124,25 +168,25 @@ public class PatientPrescriptionController extends WeixinBaseController {
     * 判断该居民是否有待取的药的接口
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/whetherHaveCode", method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String whetherHaveCode() {
        try {
            JSONObject json = new JSONObject();
//        String patientCode = getUID();
            int count = prescriptionDispensaryCodeService.dispensaryCodeCount(getUID(),1);
            if (count > 0) {
                json.put("data", true);
                return json.toString();
            }
            json.put("data", false);
            return json.toString();
        }catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
//    @RequestMapping(value = "/dispensaryCode/whetherHaveCode", method = RequestMethod.GET)
//    @ResponseBody
//    //@ObserverRequired
//    public String whetherHaveCode() {
//        try {
//            JSONObject json = new JSONObject();
////        String patientCode = getUID();
//            int count = prescriptionDispensaryCodeService.dispensaryCodeCount(getUID(),1);
//            if (count > 0) {
//                json.put("data", true);
//                return json.toString();
//            }
//            json.put("data", false);
//            return json.toString();
//        }catch (Exception e) {
//            error(e);
//            return error(-1, "查询失败!");
//        }
//    }
    /**
     * 订单跟踪 包含处方药品信息 订单记录  支付记录

+ 179 - 127
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -1,8 +1,11 @@
package com.yihu.wlyy.web.wx;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.third.httplog.LogService;
@ -19,6 +22,7 @@ import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -66,6 +70,10 @@ public class OnePayController extends WeixinBaseController {
    LogService logService;
    @Autowired
    private Configure config;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @RequestMapping(value = "createSicard", method = RequestMethod.POST)
@ -76,7 +84,8 @@ public class OnePayController extends WeixinBaseController {
            String sicardUrl = pay.createSicard("0cc6e4562de2437ab2dbbf51a9fc3b49", "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc");//getUID(), getOpenid());
            return write(200, "生成电子社保卡成功!", "data", sicardUrl);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "生成电子社保卡失败!");
        }
    }
@ -85,14 +94,11 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    public String bindCard() throws Exception {
        try {
//            String patient = getUID();
//            String openid = getOpenid();
//            逸祥
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openid = "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc";
            String patient = getUID();
            String openid = getOpenid();
//            在鑫
            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
            String openid = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openid = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
            BindCard bindCard = pay.bindCard(patient, openid);//getUID(), getOpenid());      oULM4xAj9sOsHJ95ttKYd_Fjh6Hc
            String sicardUrl = pay.createSicard(patient, openid);//getUID(), getOpenid());
            if (bindCard != null) {
@ -108,7 +114,8 @@ public class OnePayController extends WeixinBaseController {
                return write(200, "生成电子社保卡成功!", "data", json);
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "查询电子社保卡失败!");
        }
    }
@ -122,25 +129,25 @@ public class OnePayController extends WeixinBaseController {
            @RequestParam String chargeType,
            @ApiParam(name = "chargeRelation", value = "支付关联代码签约code", defaultValue = "044701ea-5b23-11e6-8344-fa163e8aee56")
            @RequestParam String chargeRelation,
            @ApiParam(name = "totalAmount", value = "交易总金额(分)", defaultValue = "12000")
            @ApiParam(name = "totalAmount", value = "交易总金额(分)", defaultValue = "9000")
            @RequestParam String totalAmount) throws Exception {
        try {
            //            获取居民个人信息
//            String patient = getUID();
//            String openId = getOpenid();
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openId = "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc";
            totalAmount = "9000";
            String patient = getUID();
            String openId = getOpenid();
//            在鑫
            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
            String openId = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openId = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
            if (StringUtils.isNotEmpty(openId)) {
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, patient, openId,getAccessToken());  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, patient, openId, getAccessToken());  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
                return write(200, "家庭医生签约支付成功!", "data", settleNo);
            } else {
                return write(-1, "openId为空!");
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "家庭医生签约支付失败!");
        }
    }
@ -151,10 +158,12 @@ public class OnePayController extends WeixinBaseController {
    public String chargeQuery(@ApiParam(name = "code", value = "接入应用业务流水号", defaultValue = "")
                              @RequestParam String code) throws Exception {
        try {
            Charge charge = pay.chargeQuery(code,getAccessToken());
            String result = pay.chargeQuery(code, getAccessToken());
            Charge charge = objectMapper.readValue(result, Charge.class);
            return write(200, "家庭医生签约支付查询成功!", "data", charge);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "家庭医生签约支付查询失败!");
        }
    }
@ -167,10 +176,11 @@ public class OnePayController extends WeixinBaseController {
                             @ApiParam(name = "chargeRelation", value = "支付关联代码", defaultValue = "044701ea5b2311e68344fa163e8aee56")
                             @RequestParam String chargeRelation) throws Exception {
        try {
            List<WlyyCharge> charge = pay.chargeList(chargeType, chargeRelation,getAccessToken());
            List<WlyyCharge> charge = pay.chargeList(chargeType, chargeRelation, getAccessToken());
            return write(200, "获取某次签约的支付记录成功!", "data", charge);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "获取某次签约的支付记录失败!");
        }
    }
@ -185,10 +195,11 @@ public class OnePayController extends WeixinBaseController {
                                      @ApiParam(name = "size", value = "每页几行", defaultValue = "10")
                                      @RequestParam Integer size) throws Exception {
        try {
            List<WlyyCharge> charge = pay.chargeListByPatient(patient,getAccessToken(), page, size);
            List<WlyyCharge> charge = pay.chargeListByPatient(patient, getAccessToken(), page, size);
            return write(200, "获取患者的支付记录成功!", "data", charge);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "获取患者的支付记录失败!");
        }
    }
@ -243,56 +254,87 @@ public class OnePayController extends WeixinBaseController {
    /**
     * 页面回调更新数据
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/returnUrl", method = RequestMethod.GET)
    @ApiOperation("商户页面跳转")
    public String testReturnUrl(@RequestParam String jsonData) throws IOException, PayException {
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        try {
            JSONObject json = new JSONObject(jsonData);
            JSONObject requestParam = json.getJSONObject("param");//业务出参
            String chargeNo = requestParam.getString("chargeNo"); //支付平台流水号
            String chargeTime = requestParam.getString("chargeTime");//支付平台交易成功时间
            String outChargeNo = requestParam.getString("outChargeNo");//接入应用业务流水号
            String outChargeTime = requestParam.getString("outChargeTime");//接入应用时间
            String channel = requestParam.getString("channel");//支付方式
            String billNo = requestParam.getString("billNo");//待结算费用单据号
            String cardNo = requestParam.getString("cardNo");//医保卡号
            String totalAmount = requestParam.getString("totalAmount");//交易总金额
            String insuranceAmount = requestParam.getString("insuranceAmount");//医保支付金额
            String selfPayAmount = requestParam.getString("selfPayAmount");//自付金额
            String userId = requestParam.getString("userId");//用户openID
            String userName = requestParam.getString("userName");//用户名字
            String idType = requestParam.getString("idType");//证件类型
            String idNo = requestParam.getString("idNo");//证件号码
            String tradeStatus = requestParam.getString("tradeStatus");//交易状态
            JSONObject responseContents = json.getJSONObject("responseContent");//医保结构体
            String miRegisterNo = responseContents.getString("miRegisterNo");//医保签约号
            String miCollectDate = responseContents.getString("miCollectDate");//扣费日期
            String miCollectTime = responseContents.getString("miCollectTime");//扣费时间
            String miSettleNo = responseContents.getString("miSettleNo");//扣费单据号
            String miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
            String miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
            String cadresPay = responseContents.getString("cadresPay");//政府补贴支付
            String miTotalFee = responseContents.getString("miTotalFee");//扣费总额
            String healthCarePay = responseContents.getString("healthCarePay");//医保统筹支付
//                responseContents.getString("healthPay");
            String heathPay = responseContents.getString("heathPay");//健康账户支付
            String accountPay = responseContents.getString("accountPay");//医保账户支付
            String selfPay = responseContents.getString("selfPay");//个人现金支付
            //		如:查询显示订单信息
            isSuccess = true;
            String appId = request.getParameter("appId");
            String billNo = request.getParameter("billNo");//待结算费用单据号
            String cardNo = request.getParameter("cardNo");//医保卡号
            String channel = request.getParameter("channel");//支付方式
            String chargeNo = request.getParameter("chargeNo");//支付平台流水号
            String chargeTime = request.getParameter("chargeTime");//支付平台交易成功时间
            String idNo = request.getParameter("idNo");//证件号码
            String idType = request.getParameter("idType");//证件类型
            String insuranceAmount = request.getParameter("insuranceAmount");//医保支付金额
            String outChargeNo = request.getParameter("outChargeNo");//接入应用业务流水号
            String outChargeTime = request.getParameter("outChargeTime");//接入应用时间
            String selfPayAmount = request.getParameter("selfPayAmount");//自付金额
            String sign = request.getParameter("sign");
            String signType = request.getParameter("signType");
            String timestamp = request.getParameter("timestamp");
            String totalAmount = request.getParameter("totalAmount");//交易总金额
            String tradeStatus = request.getParameter("tradeStatus");//交易状态
            String userId = request.getParameter("userId");//用户openID
            String userName = request.getParameter("userName");//用户名字
            String result = pay.chargeQuery(outChargeNo, getAccessToken());//业务出参
            JSONObject param = new JSONObject(result);
            String requestParam = param.getString("responseContent");
            JSONObject responseContents = new JSONObject(requestParam);//医保结构体
            String miRegisterNo = "";
            String miCollectDate = "";
            String miCollectTime = "";
            String miSettleNo = "";
            String miCollectStatus = "";
            String miRegisterStatus = "";
            String cadresPay = "";
            String miTotalFee = "";
            String healthCarePay = "";
            String heathPay = "";
            String accountPay = "";
            String selfPay = "";
            if (responseContents != null) {
               miRegisterNo = responseContents.getString("miRegisterNo");//医保签约号
                 miCollectDate = responseContents.getString("miCollectDate");//扣费日期
                 miCollectTime = responseContents.getString("miCollectTime");//扣费时间
                 miSettleNo = responseContents.getString("miSettleNo");//扣费单据号
                 miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
                 miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
                 cadresPay = responseContents.getString("cadresPay");//政府补贴支付
                 miTotalFee = responseContents.getString("miTotalFee");//扣费总额
                 healthCarePay = responseContents.getString("healthCarePay");//医保统筹支付
                 heathPay = responseContents.getString("heathPay");//健康账户支付
                 accountPay = responseContents.getString("accountPay");//医保账户支付
                 selfPay = responseContents.getString("selfPay");//个人现金支付
            }
//                判断是否需要更新数据 needUpload为0不需要更新
            WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
            if (charge!=null&&!("0".equals(charge.getNeedUpload()))){
                pay.updateData(outChargeNo, chargeNo,chargeTime,totalAmount,insuranceAmount,selfPayAmount,billNo,miRegisterNo);
            if (charge != null && !("0".equals(charge.getNeedUpload()))) {
                pay.updateData(outChargeNo, chargeNo, chargeTime, totalAmount, insuranceAmount, selfPayAmount, billNo, miRegisterNo);
            }
            return write(200, "请求成功!");
        } catch (Exception e) {
            return error(-1, e.getMessage());
            isSuccess = false;
            response.getWriter().write(e.getMessage());
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReturnUrl(), "支付页面跳转", "POST", null, "", responses, error, logService.onepayType);
    }
    /**
@ -303,17 +345,21 @@ public class OnePayController extends WeixinBaseController {
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotify", method = RequestMethod.POST)
    @ApiOperation("异步回调数据更改")
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        Boolean isSuccess = false;
        String error= "";
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        String appId = "1BHEOI11C00J7B2CA8C0000071FA53E1";
        String appSecret = "1BHEOH8HB0006E0A0A0A00002DB28BC5";
        InputStream inputStream = request.getInputStream();
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        JSONObject json = new JSONObject(params);
        String appId = json.getString("appId");
        HospitalMapping hospital = mappingDao.findByAppId(appId);
        String appSecret = hospital.getAppSecret();
//        String appSecret = json.getString("appId");
        LOGGER.info("回调参数:{}", params);
        if (StringUtil.isEmpty(params)) {
            response.getWriter().write("empty");
@ -324,69 +370,75 @@ public class OnePayController extends WeixinBaseController {
        OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
        try {
//            已经封装的加解密及签名验证
            RequestParams requestParams = JSON.parseObject(params, RequestParams.class);
            ResponseParams<com.alibaba.fastjson.JSONObject> res =  client.execute(requestParams);
            responses = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                isSuccess = true;
                String param = request.getParameter("param");//业务出参
                JSONObject requestParam = new JSONObject(param);
                String chargeNo = requestParam.getString("chargeNo"); //支付平台流水号
                String chargeTime = requestParam.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = requestParam.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = requestParam.getString("outChargeTime");//接入应用时间
                String channel = requestParam.getString("channel");//支付方式
                String billNo = requestParam.getString("billNo");//待结算费用单据号
                String cardNo = requestParam.getString("cardNo");//医保卡号
                String totalAmount = requestParam.getString("totalAmount");//交易总金额
                String insuranceAmount = requestParam.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = requestParam.getString("selfPayAmount");//自付金额
                String userId = requestParam.getString("userId");//用户openID
                String userName = requestParam.getString("userName");//用户名字
                String idType = requestParam.getString("idType");//证件类型
                String idNo = requestParam.getString("idNo");//证件号码
                String tradeStatus = requestParam.getString("tradeStatus");//交易状态
                String responseContent = request.getParameter("responseContent");//医保结构体
                JSONObject responseContents = new JSONObject(responseContent);
                String miRegisterNo = responseContents.getString("miRegisterNo");//医保签约号
                String miCollectDate = responseContents.getString("miCollectDate");//扣费日期
                String miCollectTime = responseContents.getString("miCollectTime");//扣费时间
                String miSettleNo = responseContents.getString("miSettleNo");//扣费单据号
                String miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
                String miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
                String cadresPay = responseContents.getString("cadresPay");//政府补贴支付
                String miTotalFee = responseContents.getString("miTotalFee");//扣费总额
                String healthCarePay = responseContents.getString("healthCarePay");//医保统筹支付
            LOGGER.info("解密前:{}", JSON.toJSONString(encryptRes));
            ResponseParams<?> decryptRes = client.decryptNotifyResponse(encryptRes);
            LOGGER.info("解密后:{}", JSON.toJSONString(decryptRes));
            boolean isDecrypt = ("-1".equals(decryptRes.getRespCode()) ? false : true); // 是否解密失败
            if (!isDecrypt) {
                response.getWriter().write("DECRYPT FAILURE");
            } else {
                boolean isVerify = client.verifyResponseSign(decryptRes);
                LOGGER.info("验签结果:{}", isVerify);
                if (!isVerify) {
                    response.getWriter().write("FAILURE");
                } else {
//					业务逻辑代码
                    isSuccess = true;
                    responses = JSON.toJSONString(decryptRes);
                    JSONObject requestParams = new JSONObject(responses);
                    JSONObject requestParam = requestParams.getJSONObject("param");//业务出参
                    String chargeNo = requestParam.getString("chargeNo"); //支付平台流水号
                    String chargeTime = requestParam.getString("chargeTime");//支付平台交易成功时间
                    String outChargeNo = requestParam.getString("outChargeNo");//接入应用业务流水号
                    String outChargeTime = requestParam.getString("outChargeTime");//接入应用时间
                    String channel = requestParam.getString("channel");//支付方式
                    String billNo = requestParam.getString("billNo");//待结算费用单据号
                    String cardNo = requestParam.getString("cardNo");//医保卡号
                    String totalAmount = requestParam.getString("totalAmount");//交易总金额
                    String insuranceAmount = requestParam.getString("insuranceAmount");//医保支付金额
                    String selfPayAmount = requestParam.getString("selfPayAmount");//自付金额
                    String userId = requestParam.getString("userId");//用户openID
                    String userName = requestParam.getString("userName");//用户名字
                    String idType = requestParam.getString("idType");//证件类型
                    String idNo = requestParam.getString("idNo");//证件号码
                    String tradeStatus = requestParam.getString("tradeStatus");//交易状态
                    String miRegisterNo = "";//医保签约号
                    if (requestParams.has("responseContent") && (requestParams.getJSONObject("responseContent") != null)) {
                        JSONObject responseContents = requestParams.getJSONObject("responseContent");//医保结构体
                        miRegisterNo = responseContents.getString("miRegisterNo");//医保签约号
                        String miCollectDate = responseContents.getString("miCollectDate");//扣费日期
                        String miCollectTime = responseContents.getString("miCollectTime");//扣费时间
                        String miSettleNo = responseContents.getString("miSettleNo");//扣费单据号
                        String miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
                        String miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
                        String cadresPay = responseContents.getString("cadresPay");//政府补贴支付
                        String miTotalFee = responseContents.getString("miTotalFee");//扣费总额
                        String healthCarePay = responseContents.getString("healthCarePay");//医保统筹支付
//                responseContents.getString("healthPay");
                String heathPay = responseContents.getString("heathPay");//健康账户支付
                String accountPay = responseContents.getString("accountPay");//医保账户支付
                String selfPay = responseContents.getString("selfPay");//个人现金支付
                        String heathPay = responseContents.getString("heathPay");//健康账户支付
                        String accountPay = responseContents.getString("accountPay");//医保账户支付
                        String selfPay = responseContents.getString("selfPay");//个人现金支付
                    }
//                判断是否需要更新数据 needUpload为0不需要更新
                WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
                if (charge!=null&&!("0".equals(charge.getNeedUpload()))){
                    pay.updateData(outChargeNo, chargeNo,chargeTime,totalAmount,insuranceAmount,selfPayAmount,billNo,miRegisterNo);
                    WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
                    if (charge != null && !("0".equals(charge.getNeedUpload()))) {
                        pay.updateData(outChargeNo, chargeNo, chargeTime, totalAmount, insuranceAmount, selfPayAmount, billNo, miRegisterNo);
                    }
                    response.getWriter().write("SUCCESS");
                }
            }else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
            response.getWriter().write(ex.getMessage());
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
        }
        //                记录log日志到数据库
                logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
}

+ 16 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -237,22 +237,22 @@ public class WeiXinEventProcess {
        articles.add(articleExamination);
//        新增处方记录图文消息
        Map<String, String> articlePrescription = new HashMap<>();
        // 图文URL
        String prescription = systemConf.getProperty("patient_prescription_url");
        // 图文消息图片URL
        String prescription_pic = systemConf.getProperty("patient_prescription_pic");
        // URL设置服务器URL、AppId
        prescription = prescription.replace("{server}",wechat_base_url)
                .replace("{appId}",appId);
        //图片地址
        prescription_pic = prescription_pic.replace("{server}",serverUrl);
        articlePrescription.put("Url", prescription);
        articlePrescription.put("Title", "处方记录");
        articlePrescription.put("Description", "处方记录");
        articlePrescription.put("PicUrl", prescription_pic);
        articles.add(articlePrescription);
//        Map<String, String> articlePrescription = new HashMap<>();
//        // 图文URL
//        String prescription = systemConf.getProperty("patient_prescription_url");
//        // 图文消息图片URL
//        String prescription_pic = systemConf.getProperty("patient_prescription_pic");
//        // URL设置服务器URL、AppId
//        prescription = prescription.replace("{server}",wechat_base_url)
//                .replace("{appId}",appId);
//        //图片地址
//        prescription_pic = prescription_pic.replace("{server}",serverUrl);
//
//        articlePrescription.put("Url", prescription);
//        articlePrescription.put("Title", "处方记录");
//        articlePrescription.put("Description", "处方记录");
//        articlePrescription.put("PicUrl", prescription_pic);
//        articles.add(articlePrescription);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);

+ 15 - 19
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -156,6 +156,11 @@ sign:
quartz:
  name: schedulerFactoryBean_test
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
---
##正式的配置
@ -241,11 +246,11 @@ sign:
quartz:
  name: schedulerFactoryBeanWlyy
express:
  sf_url: http://bsp-ois.sit.sf-express.com:9080/bsp-ois/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: BSPdevelop
  sf_check_word: j8DzkIFgmlomPt0aLuwU
ylzpay:
#  onepayApi: https://xmhealth.ylzpay.com:8080/
  onepayApi: http://xmhealth.ylzpay.com:8070/
  onepayAppId: 1BLF5SEGN00087165F0A000027362BE5
  onepayAppSecret: 1BLF5SCBO01V3E78A8C00000F3A0FFE7
---
##开发的配置
@ -332,13 +337,10 @@ sign:
quartz:
  name: schedulerFactoryBean_dev
express:
  sf_url: http://bsp-ois.sit.sf-express.com:9080/bsp-ois/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: BSPdevelop
  sf_check_word: j8DzkIFgmlomPt0aLuwU
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
---
##开发连测试用这个版本的配置
@ -419,10 +421,4 @@ sign:
quartz:
  name: schedulerFactoryBean_test_dev
express:
  sf_url: http://bsp-ois.sit.sf-express.com:9080/bsp-ois/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: BSPdevelop
  sf_check_word: j8DzkIFgmlomPt0aLuwU
  name: schedulerFactoryBean_test_dev

+ 9 - 0
patient-co/patient-co-wlyy/src/main/resources/system.properties

@ -78,7 +78,16 @@ sign_again_job_end=2017-10-1 00:00:00
prenatal_inspector_job_trigger=0 0 6 * * ?
evaluate_score_job = 0 0 */2 * * ?
#续方支付到期,每天0点触发
prescription_pay_overdue_job = 0 0 0 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html
#统一支付平台支付接口地址
bindCardType=onepay.sicard.bind.info
chargeType=onepay.trade.medical.charge
chargeQueryType=onepay.trade.medical.charge.query
createSicardType=onepay.sicard.createurl
receiveNotify=wlyy.onepay.receiveNotify
returnUrl=wlyy.onepay.returnUrl

+ 4 - 2
pom.xml

@ -517,11 +517,13 @@
                <artifactId>fastjson</artifactId>
                <version>${version.fastdfs}</version>
            </dependency>
            <!--易联众支付-->
            <dependency>
                <groupId>com.ylz</groupId>
                <artifactId>onepay-java-sdk</artifactId>
                <artifactId>onpay-java-sdk-all</artifactId>
                <version>${version.ylz}</version>
            </dependency> <!--elasticsearch start-->
            </dependency>
            <!--elasticsearch start-->
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>