Browse Source

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

yeshijie 7 years ago
parent
commit
9498e9ee0a

+ 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() {
    }
}

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

@ -736,6 +736,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());

+ 10 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -417,19 +417,19 @@ public class AdminTeamService extends BaseService {
     */
    public JSONArray findPatientDoctorTeam(String patient, String doctor) {
        JSONArray result = new JSONArray();
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        //判断是不是患者签约团队的团队长
        AdminTeam doctorTeam =  teamDao.findByLeaderCode(doctor);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        if (ssSign != null&&ssSign.getAdminTeamId()!=null && (doctor.equals(ssSign.getDoctor())
                || doctor.equals(ssSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(ssSign.getAdminTeamId());
            result.put(new JSONObject(team));
        //判断团队关系
        if(jtSign!=null&&doctorTeam!=null&&jtSign.getAdminTeamId().compareTo(doctorTeam.getId())==0){
            return result.put(new JSONObject(doctorTeam));
        }
        if (jtSign.getAdminTeamId()!=null&&jtSign != null && (doctor.equals(jtSign.getDoctor())
                || doctor.equals(jtSign.getDoctorHealth()))) {
        //判断签约关系
        if (jtSign.getAdminTeamId()!=null&&jtSign != null && (doctor.equals(jtSign.getDoctor()) || doctor.equals(jtSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(jtSign.getAdminTeamId());
            if(ssSign == null || ssSign.getAdminTeamId() != jtSign.getAdminTeamId()) {
                result.put(new JSONObject(team));
            }
            result.put(new JSONObject(team));
        }
        return result;
    }

+ 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