Procházet zdrojové kódy

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

trick9191 před 7 roky
rodič
revize
2823be1a94
28 změnil soubory, kde provedl 527 přidání a 86 odebrání
  1. 5 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/SystemConfig.java
  2. 45 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/CommonController.java
  3. 21 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/common/SystemPropertiesDao.java
  4. 59 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/common/SystemProperties.java
  5. 34 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/event/ApplicationEvent.java
  6. 57 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/common/InitiSysProService.java
  7. 11 8
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCAService.java
  8. 4 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  9. 7 0
      patient-co/patient-co-wlyy-job/pom.xml
  10. 27 12
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  11. 4 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java
  12. 13 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  13. 6 6
      patient-co/patient-co-wlyy-job/src/main/resources/application.yml
  14. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/Application.java
  15. 17 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  16. 56 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/MutableHttpServletRequest.java
  17. 59 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/UserAgentFilter.java
  18. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java
  19. 9 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  20. 6 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  21. 5 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java
  22. 29 29
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  23. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  24. 21 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  25. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/device/DeviceController.java
  26. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  27. 5 5
      patient-co/patient-co-wlyy/src/main/resources/application.yml
  28. 2 2
      patient-co/patient-co-wlyy/src/main/resources/config/fdfs_client.conf

+ 5 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/SystemConfig.java

@ -4,6 +4,8 @@ import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
@ -18,6 +20,9 @@ public class SystemConfig {
    // 系统配置文件
    private Properties systemProperties;
    //从system_properties表中取到的系统参数集,key参数key,value参数值
    public static Map<String,String> sysPropertiesSets = new HashMap<>();
    public static SystemConfig getInstance() {
        if (systemConf == null) {
            synchronized (lock) {

+ 45 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/CommonController.java

@ -0,0 +1,45 @@
package com.yihu.wlyy.service.controller;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.service.common.InitiSysProService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
 * 公共请求接口
 * @author huangwenjie
 * @date 2017/8/22 21:06
 */
@Controller
@RestController
@RequestMapping(value = "/common/")
@Api(description = "长处方接口")
public class CommonController {
    private static Logger logger = LoggerFactory.getLogger(CommonController.class);
    @Autowired
    private InitiSysProService initiSysProService;
    @RequestMapping(value = "startInitiSysProperties",method = RequestMethod.POST)
    @ApiOperation("重新执行系统参数初始化")
    public Result startInitiSysProperties(){
        try {
            logger.info("START===执行系统参数初始化");
            initiSysProService.startInitiSysProperties();
            logger.info("END===执行系统参数初始化");
            return Result.success("重新执行系统参数初始化成功!",true);
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.info("ERROR===执行系统参数初始化:"+ex.getMessage());
            return Result.error(ex.getMessage());
        }
    }
}

+ 21 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/common/SystemPropertiesDao.java

@ -0,0 +1,21 @@
package com.yihu.wlyy.service.dao.common;
import com.yihu.wlyy.service.entity.common.SystemProperties;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2017/8/22 20:43
 */
public interface SystemPropertiesDao extends
        PagingAndSortingRepository<SystemProperties, Long>,
        JpaSpecificationExecutor<SystemProperties> {
    @Query("select a from SystemProperties a where a.client = ?1 and a.isdel = 0 ")
    List<SystemProperties> findSystemPropertiesByClientAndSpaValue(Integer client);
}

+ 59 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/common/SystemProperties.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.service.entity.common;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * @author huangwenjie
 * @date 2017/8/22 20:27
 */
@Entity
@Table(name = "system_properties")
public class SystemProperties  extends IdEntity {
    //工程类型-0:wlyy,1:wlyy_service
    private Integer client;
    //参数key
    private String key;
    //参数值
    private String value;
    //0为有效,1为删除状态
    private Integer isdel;
    public Integer getClient() {
        return client;
    }
    public void setClient(Integer client) {
        this.client = client;
    }
    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public Integer getIsdel() {
        return isdel;
    }
    public void setIsdel(Integer isdel) {
        this.isdel = isdel;
    }
}

+ 34 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/event/ApplicationEvent.java

@ -0,0 +1,34 @@
package com.yihu.wlyy.service.event;
import com.yihu.wlyy.service.service.common.InitiSysProService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
/**
 *启动执行系统参数初始化
 *@author huangwenjie
 *@date 2017/8/22 22:25
 */
@Service
public class ApplicationEvent implements ApplicationListener<ContextRefreshedEvent> {
    private Logger logger = LoggerFactory.getLogger(ApplicationEvent.class);
    @Autowired
    private InitiSysProService initiSysProService;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
        try {
            logger.info("START===开始执行执行系统参数初始化");
            initiSysProService.startInitiSysProperties();
            logger.info("END===成功执行系统参数初始化");
        } catch (Exception e) {
            logger.info("ERROR===执行系统参数初始化失败:"+e.getMessage());
        }
    }
}

+ 57 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/common/InitiSysProService.java

@ -0,0 +1,57 @@
package com.yihu.wlyy.service.service.common;
import com.yihu.wlyy.service.common.CommonContent;
import com.yihu.wlyy.service.common.SystemConfig;
import com.yihu.wlyy.service.dao.common.SystemPropertiesDao;
import com.yihu.wlyy.service.entity.common.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author huangwenjie
 * @date 2017/8/22 20:01
 */
@Service("InitiSysProService")
public class InitiSysProService {
    @Autowired
    private SystemPropertiesDao systemPropertiesDao;
    /**
     * 重新执行系统参数初始化
     */
    public void startInitiSysProperties() throws Exception{
        if(!SystemConfig.sysPropertiesSets.isEmpty()){
            SystemConfig.sysPropertiesSets.clear();
        }
        Map<String,String> sysPropertiesSets = new HashMap<>();
        List<SystemProperties> sysvalueList = systemPropertiesDao.findSystemPropertiesByClientAndSpaValue(1);
        if(!sysvalueList.isEmpty()){
            for (SystemProperties systemProperties : sysvalueList) {
                sysPropertiesSets.put(systemProperties.getKey(),systemProperties.getValue());
            }
            SystemConfig.sysPropertiesSets = sysPropertiesSets;
        }
    }
//
//    public String returnSysProValue(String key) throws Exception {
//        if(CommonContent.sysPropertiesSets.keySet().contains(key)){
//            return  CommonContent.sysPropertiesSets.get(key);
//        }else{
//            boolean result = this.startInitiSysProperties();
//            if(result){
//                return  CommonContent.sysPropertiesSets.get(key);
//            }else{
//                throw new Exception("无法获取系统参数,key:"+key);
//            }
//        }
//    }
}

+ 11 - 8
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCAService.java

@ -25,8 +25,6 @@ public class PrescriptionCAService {
    private String MODIFY_PASSWD = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd"; //修改实名软证书调用保护口令
    private String VERIFY_SIGN = "XMCA3_JMSVR_verifySignOnMultiServer"; //验证签名(带多服务器负载均衡)
    private String caUrl = SystemConfig.getInstance().getCAUrl();
    private String caNamespace = SystemConfig.getInstance().getCANamespace();
    private String unifiedCallInterface = "XMCA6_UnifiedCallInterface";
    @Autowired
    private LogService logService;
@ -58,8 +56,12 @@ public class PrescriptionCAService {
    /**
     * CA认证服务二次封装
     */
    private String postCAServer(String urlString,String namespace,String api, Map<String,String> params) throws Exception
    private String postCAServer(String api, Map<String,String> params) throws Exception
    {
        String urlString = SystemConfig.sysPropertiesSets.get("ca_url");
        String namespace = SystemConfig.sysPropertiesSets.get("ca_namespace");
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                         "<root>\n";
        if(params!=null && params.size()>0)
@ -96,7 +98,7 @@ public class PrescriptionCAService {
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(caUrl, caNamespace, action, params);
            re = postCAServer(action, params);
            if(StringUtil.isEmpty(re))
            {
@ -145,7 +147,7 @@ public class PrescriptionCAService {
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(caUrl,caNamespace,action, params);
            re = postCAServer(action, params);
            if(StringUtil.isEmpty(re))
            {
@ -193,7 +195,8 @@ public class PrescriptionCAService {
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(caUrl, caNamespace, action, params);
            re = postCAServer(action, params);
            if(StringUtil.isEmpty(re))
            {
@ -241,7 +244,7 @@ public class PrescriptionCAService {
            params.put("strNewCalledPasswd",strNewCalledPasswd);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(caUrl, caNamespace, action, params);
            re = postCAServer(action, params);
            if(StringUtil.isEmpty(re))
            {
@ -294,7 +297,7 @@ public class PrescriptionCAService {
            params.put("strOriginalData",strOriginalData);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(caUrl,caNamespace,action, params);
            re = postCAServer(action, params);
            if(StringUtil.isEmpty(re))
            {

+ 4 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -673,7 +673,8 @@ public class PrescriptionService extends ZysoftBaseService{
        String[] hospitalMapping = getHospitalMapping(prescription.getHospital()); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
//        String licence = hospitalMapping[1];
        String licence = "5YGl5bq35LmL6Lev";
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
@ -702,7 +703,8 @@ public class PrescriptionService extends ZysoftBaseService{
        String[] hospitalMapping = getHospitalMapping(prescription.getHospital()); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
//        String licence = hospitalMapping[1];
        String licence = "5YGl5bq35LmL6Lev";
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);

+ 7 - 0
patient-co/patient-co-wlyy-job/pom.xml

@ -428,6 +428,13 @@
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>

+ 27 - 12
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -3,11 +3,15 @@ package com.yihu.wlyy.redis;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
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.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
 * Created by Trick on 2017/8/7.
@ -15,8 +19,9 @@ import redis.clients.jedis.Jedis;
@Component
public class RedisThread implements Runnable {
    private static Logger logger = LoggerFactory.getLogger(RedisThread.class);
    @Value("${channel.redis.host}")
    private String url;
    private String host;
    @Value("${channel.redis.port}")
    private Integer port;
    @Value("${channel.redis.password}")
@ -30,21 +35,31 @@ public class RedisThread implements Runnable {
    @Override
    public void run() {
        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
        Jedis jedis = new Jedis(url,port);
        if(StringUtils.isNotBlank(password)){
            jedis.auth(password);
        }
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxIdle(8);
        poolConfig.setMaxTotal(8);
        poolConfig.setMaxWaitMillis(-1);
        poolConfig.setMinIdle(1);
        JedisPool pool = new JedisPool(poolConfig,host,port,100000,password);
        while (true){
            String message = jedis.rpop(key);
            if(StringUtils.isEmpty(message)){
                try{
            try {
                Jedis jedis = pool.getResource();
//                if(StringUtils.isNotBlank(password)){
//                    jedis.auth(password);
//                }
                String message = jedis.rpop(key);
                if(StringUtils.isEmpty(message)){
                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒
                }catch (Exception e){
                    e.printStackTrace();
                }else {
                    prescriptionService.redisMessage(message);
                }
            }else {
                prescriptionService.redisMessage(message);
            }catch (Exception e){
                e.printStackTrace();
                logger.info(e.getMessage());
            }
        }
    }
}

+ 4 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -24,4 +24,8 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Query(value = "select p.prescription_code from wlyy_prescription_pay p LEFT JOIN  wlyy_prescription a on a.code = p.prescription_code where p.trade_status = 1 and a.jw_pay_status = 0",nativeQuery = true)
    List<String> findCodesByPayStautsAndExecuteSickStatus();
    @Modifying
    @Query("update Prescription p set p.jwPayStatus=1 where p.code=?1")
    void updatejwPayStatus(String prescriptionCode);
}

+ 13 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -156,6 +156,7 @@ public class JwPrescriptionService {
        return response;
    }
    /**
     * 院内结算确认接口
     * @param prescriptionCode 处方CODE
@ -167,6 +168,18 @@ public class JwPrescriptionService {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
        String response = httpClientUtil.post(url, params, "UTF-8");
        if(StringUtils.isNotBlank(response)){
            JSONObject reobj =  JSON.parseObject(response);
            Integer status = reobj.getInteger("status");
            String errmsg = reobj.getString("msg");
            if(-1 == status){
                throw new Exception("基卫接口(院内结算确认接口)请求失败,"+errmsg);
            }else{
                prescriptionDao.updatejwPayStatus(prescriptionCode);
            }
        }else{
            throw new Exception("基卫接口(院内结算确认接口)请求失败,无数据返回!");
        }
        return response;
    }

+ 6 - 6
patient-co/patient-co-wlyy-job/src/main/resources/application.yml

@ -1,5 +1,6 @@
server:
  port: 8080
  context-path: /wlyy-job
spring:
  datasource:
@ -182,21 +183,20 @@ express:
##正式的配置
spring:
  profiles: prod
  datasource:
    wlyy:
      url: jdbc:mysql://59.61.92.90:8079/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: jkzl_root
      password: jkzlehr@321465
      username: wlyy
      password: jkzlehr@123
    health:
      url: jdbc:mysql://59.61.92.90:8079/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
#      username: wlyy
#      password: jkzlehr@321465
      username: jkzl_root
      password: jkzlehr@321465
      username: wlyy
      password: jkzlehr@123
  redis:
    host: 120.41.253.95 # Redis server host.
    host: 27.155.101.77 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr

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

@ -14,5 +14,7 @@ public class Application {
    public static void main(String[] args) {
        ctx = SpringApplication.run(Application.class, args);
    }
}

+ 17 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -3,9 +3,12 @@ package com.yihu.wlyy.config;
import com.yihu.wlyy.interceptors.DoctorInterceptor;
import com.yihu.wlyy.interceptors.GateWayInterceptor;
import com.yihu.wlyy.interceptors.PatientInterceptor;
import com.yihu.wlyy.interceptors.UserAgentFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@ -15,7 +18,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@Profile({"test", "prod"})
//@Profile({"test", "prod"})
public class MvcConfig extends WebMvcConfigurerAdapter {
    private Logger logger = LoggerFactory.getLogger(MvcConfig.class);
@ -31,13 +34,24 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**").excludePathPatterns("/wlyygc/doctor/**","/wlyygc/patient/**");
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**").excludePathPatterns("/wlyygc/doctor/**", "/wlyygc/patient/**");
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**", "wlyygc/doctor/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**","/wlyygc/patient/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**", "/wlyygc/patient/**");
        super.addInterceptors(registry);
        logger.info("init doctorInterceptor,patientInterceptor");
    }
    @Bean
    public FilterRegistrationBean testFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new UserAgentFilter());
        registration.addUrlPatterns("/*");
        registration.setName("UserAgentFilter");
        registration.setOrder(1);
        return registration;
    }
//    /**
//     * 为null的数据不返回
//     * @param converters

+ 56 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/MutableHttpServletRequest.java

@ -0,0 +1,56 @@
package com.yihu.wlyy.interceptors;
/**
 * Created by chenweida on 2017/8/22.
 */
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
final class MutableHttpServletRequest extends HttpServletRequestWrapper {
    // holds custom header and value mapping
    private final Map<String, String> customHeaders;
    public MutableHttpServletRequest(HttpServletRequest request){
        super(request);
        this.customHeaders = new HashMap<String, String>();
    }
    public void putHeader(String name, String value){
        this.customHeaders.put(name, value);
    }
    public String getHeader(String name) {
        // check the custom headers first
        String headerValue = customHeaders.get(name);
        if (headerValue != null){
            return headerValue;
        }
        // else return from into the original wrapped object
        return ((HttpServletRequest) getRequest()).getHeader(name);
    }
    public Enumeration<String> getHeaderNames() {
        // create a set of the custom header names
        Set<String> set = new HashSet<String>(customHeaders.keySet());
        // now add the headers from the wrapped request object
        @SuppressWarnings("unchecked")
        Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames();
        while (e.hasMoreElements()) {
            // add the names of the request headers into the list
            String n = e.nextElement();
            set.add(n);
        }
        // create an enumeration from the set and return
        return Collections.enumeration(set);
    }
}

+ 59 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/UserAgentFilter.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.interceptors;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
 * Created by chenweida on 2017/8/22.
 */
@Component
public class UserAgentFilter implements javax.servlet.Filter {
    private Logger logger= LoggerFactory.getLogger(UserAgentFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(request);
        String is_switch = request.getParameter("userAgent_is_switch");
        if ("1".equals(is_switch)) {
            String token = request.getParameter("userAgent_token");
            String uid = request.getParameter("userAgent_uid");
            String imei = request.getParameter("userAgent_imei");
            String openid = request.getParameter("userAgent_openid");
            String platform = request.getParameter("userAgent_platform");
            String lastUid = request.getParameter("userAgent_lastUid");
            String represented = request.getParameter("userAgent_represented");
            JSONObject jo = new JSONObject();
            jo.put("token", token);
            jo.put("imei", imei);
            jo.put("openid", openid);
            jo.put("uid", uid);
            jo.put("platform", platform);
            jo.put("lastUid", lastUid);
            jo.put("represented", represented);
            mutableRequest.putHeader("userAgent", jo.toString());
            logger.info("------filter:"+jo.toString());
            chain.doFilter(mutableRequest, response);
        }else{
           // logger.info("------filter:noswitch");
            chain.doFilter(servletRequest, response);
        }
    }
    @Override
    public void destroy() {
    }
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -30,4 +30,8 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Query("from Prescription p where p.visitNo=?1 and p.recipeNo=?2 ")
    Prescription findByVisitNoAndRecipeNo(String visitNo,String recipeNo);
    @Modifying
    @Query("update Prescription p set p.jwPayStatus=1 where p.code=?1")
    void updatejwPayStatus(String prescriptionCode);
}

+ 9 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -946,6 +946,12 @@ public class ConsultTeamService extends ConsultService {
            if(signFamily==null){
                return -2;
            }
            String checkPre = prescriptionInfoService.checkPre(patient,DateUtil.getStringDateShort()+" 00:00:00");
            if("0".equals(checkPre)){//存在未结算的续方
                return -3;
            }
            Doctor doctor = doctorDao.findByCode(doctorCode);
            // 查询患者信息
            Patient p = patientDao.findByCode(patient);
@ -1037,7 +1043,7 @@ public class ConsultTeamService extends ConsultService {
            consultTeamDoctorDao.save(cd);
            //7、发送系统消息提示团队长有未审核的消息
            addCheckMessage(prescription,sessionId);
            addCheckMessage(prescription,sessionId,p);
            //8、 保存医生咨询信息
            // 添加咨询转发记录
@ -1052,12 +1058,13 @@ public class ConsultTeamService extends ConsultService {
     * 保存审核提醒消息
     * @param prescription
     */
    public void addCheckMessage(Prescription prescription,String sessionId){
    public void addCheckMessage(Prescription prescription,String sessionId,Patient p){
        Message message = new Message();
        message.setCzrq(new Date());
        message.setCreateTime(new Date());
        message.setRead(1);//设置未读
        message.setOver("1");
        message.setSenderPhoto(p.getPhoto());
        message.setReceiver(prescription.getDoctor());
        message.setSender(prescription.getPatient());
        message.setCode(getCode());

+ 6 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -541,9 +541,11 @@ public class PatientPrescriptionPayService extends BaseService {
                            messageDao.save(message);
                        }
                        //支付成功发起结算
                        LOGGER.debug("=================> start exexuteSickSettle");
                        jwPrescriptionService.executeSickSettle(prescriptionCode);
                        LOGGER.debug("=================> end exexuteSickSettle");
                        try {
                            jwPrescriptionService.executeSickSettle(prescriptionCode);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } else if ("1".equals(tradeStatus) || "FAIL".equals(tradeStatus)) {
                        prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_error.getValue());////续费状态 30支付成功 21支付失败
@ -736,6 +738,7 @@ public class PatientPrescriptionPayService extends BaseService {
                JSONObject jsonObject = new JSONObject();
                jsonObject = JSON.parseObject(count);
                int amount = jsonObject.getInteger("count");
                amount+=1;
                //增加wlyy_message 团队长健管师待分配系统消息记录
                Message message = new Message();
                message.setCode(getCode());

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

@ -259,11 +259,12 @@ public class PrescriptionDispensaryCodeService extends BaseService {
            throw new Exception("编码已使用!");
        } else if (status == -3) {
            throw new Exception("编码类型错误!");
        } else if (status == -4) {
            throw new Exception("未到达服务站!");
        } else if (status == -5) {
            throw new Exception("不可配送!");
        }
//        else if (status == -4) {
//            throw new Exception("未到达服务站!");
//        } else if (status == -5) {
//            throw new Exception("不可配送!");
//        }
        return prescriptionDispensaryCode;
    }

+ 29 - 29
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -171,20 +171,20 @@ public class PrescriptionExpressageService {
        //修改处方状态为完成
        Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
        if(prescription.getStatus()<=65){
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("该状态不可取药");
            prescriptionLogDao.save(prescriptionLog);
            return -4;
        }
//        if(prescription.getStatus()<=65){
//            PrescriptionLog prescriptionLog = new PrescriptionLog();
//            prescriptionLog.setCode(UUID.randomUUID().toString());
//            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
//            prescriptionLog.setCreateTime(new Date());
//            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
//            prescriptionLog.setFlag(1);
//            prescriptionLog.setUserCode(userCode);
//            prescriptionLog.setUserType(2);
//            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
//            prescriptionLog.setRemark("该状态不可取药");
//            prescriptionLogDao.save(prescriptionLog);
//            return -4;
//        }
        Date finshTime = new Date();
        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        prescription.setFinishTime(finshTime);
@ -226,20 +226,20 @@ public class PrescriptionExpressageService {
        Prescription prescription = prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
        if(prescription.getStatus()<=50){
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("该状态不可配送");
            prescriptionLogDao.save(prescriptionLog);
            return -5;
        }
//        if(prescription.getStatus()<=50){
//            PrescriptionLog prescriptionLog = new PrescriptionLog();
//            prescriptionLog.setCode(UUID.randomUUID().toString());
//            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
//            prescriptionLog.setCreateTime(new Date());
//            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
//            prescriptionLog.setFlag(1);
//            prescriptionLog.setUserCode(userCode);
//            prescriptionLog.setUserType(2);
//            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
//            prescriptionLog.setRemark("该状态不可配送");
//            prescriptionLogDao.save(prescriptionLog);
//            return -5;
//        }
        //修改处方状态为配送中
        Date expressageing = new Date();
        prescription.setExpressageTime(expressageing);
@ -273,7 +273,7 @@ public class PrescriptionExpressageService {
                "&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName();
        prescriptionNoticesService.sendMessages(userCode, doctor.getName(), DateUtil.dateToStrLong(expressageing), 3, 0, url);
        prescriptionNoticesService.sendMessages(patient.getCode(), doctor.getName(), DateUtil.dateToStrLong(expressageing), 3, 0, url);
        return prescriptionDispensaryCode.getType();
    }

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

@ -1138,6 +1138,22 @@ public class PrescriptionInfoService extends BaseService {
        }
    }
    /**
     * 判断丹田
     * @param patient
     * @param currentDay
     * @return
     */
    public String checkPre(String patient,String currentDay){
        StringBuffer sql = new StringBuffer("SELECT code from wlyy_prescription WHERE patient = ? and `status`> "+PrescriptionLog.PrescriptionLogStatus.revieweding.getValue()+" and create_time>? and jw_pay_status = '0'");
        List<Map<String, Object>> mp = jdbcTemplate.queryForList(sql.toString(), patient,currentDay);
        if (mp != null && mp.size() > 0) {
            return "0";
        } else {
            return "1";
        }
    }
    public String presCheckStateObj(String code) {
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND pr.status >= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() + " AND pr.status < " + PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue());
        List<Map<String, Object>> mp = jdbcTemplate.queryForList(sql.toString(), code);

+ 21 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -17,7 +17,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 基位长处方接口
@ -87,14 +86,14 @@ public class JwPrescriptionService {
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
//        String response = httpClientUtil.post(url, params, "UTF-8");
        String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
        List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
        String response = list.get(0).get("response").toString();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",200);
        jsonObject.put("data",response);
        response = jsonObject.toString();
        String response = httpClientUtil.post(url, params, "UTF-8");
//        String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
//        List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
//        String response = list.get(0).get("response").toString();
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("status",200);
//        jsonObject.put("data",response);
//        response = jsonObject.toString();
        return response;
    }
@ -168,6 +167,19 @@ public class JwPrescriptionService {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
        String response = httpClientUtil.post(url, params, "UTF-8");
        if(StringUtils.isNotBlank(response)){
            JSONObject reobj =  JSON.parseObject(response);
            Integer status = reobj.getInteger("status");
            String errmsg = reobj.getString("msg");
            if(-1 == status){
                throw new Exception("基卫接口(院内结算确认接口)请求失败,"+errmsg);
            }else{
                prescriptionDao.updatejwPayStatus(prescriptionCode);
            }
        }else{
            throw new Exception("基卫接口(院内结算确认接口)请求失败,无数据返回!");
        }
        return response;
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/device/DeviceController.java

@ -50,7 +50,7 @@ public class DeviceController extends BaseController {
    }
    @ApiOperation("获取设备信息")
    @RequestMapping(value = "DeviceInfo", method = RequestMethod.POST)
    @RequestMapping(value = "DeviceInfo", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String getDeviceInfo(@ApiParam(name = "id", value = "设备ID", defaultValue = "19")
                                @RequestParam(value = "id", required = true) String id) {

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -999,6 +999,8 @@ public class ConsultController extends WeixinBaseController {
                return error(-1, "该处方存在未审核的续方,无法进行续方咨询!");
            } if (res == -2) {
                return error(-1, "您还未签约,不能发起续方咨询!");
            } if (res == -3) {
                return error(-1, "您当天有未完成的续方,不能发起续方咨询!");
            }
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());

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

@ -194,17 +194,17 @@ spring:
  datasource:
    wlyy:
      url: jdbc:mysql://59.61.92.90:8079/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: jkzl_root
      password: jkzlehr@321465
      username: wlyy
      password: jkzlehr@123
    health:
      url: jdbc:mysql://59.61.92.90:8079/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
#      username: wlyy
#      password: jkzlehr@321465
      username: jkzl_root
      password: jkzlehr@321465
      username: wlyy
      password: jkzlehr@123
  redis:
    host: 120.41.253.95 # Redis server host.
    host: 27.155.101.77 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr

+ 2 - 2
patient-co/patient-co-wlyy/src/main/resources/config/fdfs_client.conf

@ -9,7 +9,7 @@ http.secret_key = FastDFS1234567890
#tracker_server = 172.19.103.54:22122
#-------------测试环境---------------#
tracker_server = 172.19.103.54:22122
#tracker_server = 172.19.103.54:22122
#-------------正式环境---------------#
#tracker_server = 192.168.0.239:22122
tracker_server = 192.168.120.153:22122