Explorar o código

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

chenweida %!s(int64=8) %!d(string=hai) anos
pai
achega
de6eb4869a
Modificáronse 35 ficheiros con 887 adicións e 224 borrados
  1. 44 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/url/CudUrl.java
  2. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/BaseInterceptor.java
  3. 145 67
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  4. 30 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  5. 30 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/UserInterceptor.java
  6. 65 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/logs/BusinessLogs.java
  7. 26 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/logs/InterfaceCallLogs.java
  8. 13 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/url/CudUrlDao.java
  9. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  10. 110 81
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  11. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  12. 9 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  13. 5 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  14. 14 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  15. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java
  16. 3 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java
  17. 32 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java
  18. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendPatientUtil.java
  19. 2 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/WeixinBaseController.java
  20. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java
  21. 9 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  22. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  23. 6 13
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  24. 8 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  25. 11 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  26. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java
  27. 7 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  28. 15 22
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  29. 50 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  30. 190 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  31. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinMessageReplyUtils.java
  32. 26 0
      patient-co-wlyy/src/main/resources/logback.xml
  33. 13 1
      patient-co-wlyy/src/main/resources/system.properties
  34. 6 1
      patient-co-wlyy/src/main/resources/weixin_menu.txt
  35. BIN=BIN
      patient-co-wlyy/src/main/webapp/images/operatinginstructions.png

+ 44 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/url/CudUrl.java

@ -0,0 +1,44 @@
package com.yihu.wlyy.entity.url;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by lyr-pc on 2017/1/18.
 */
@Entity
@Table(name = "wlyy_cud_url")
public class CudUrl extends IdEntity{
    private String url;
    private String method;
    private String comment;
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public String getComment() {
        return comment;
    }
    public void setComment(String comment) {
        this.comment = comment;
    }
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/BaseInterceptor.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.interceptors;
import javax.servlet.http.HttpServletRequest;
import com.yihu.wlyy.repository.url.CudUrlDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,6 +14,8 @@ abstract public class BaseInterceptor implements HandlerInterceptor {
	@Autowired
	public TokenDao tokenDao;
	@Autowired
	public CudUrlDao cudUrlDao;
	public JSONObject getAgent(HttpServletRequest request) {
		try {

+ 145 - 67
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -4,14 +4,24 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.entity.url.CudUrl;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
 * 医生权限校验
@ -20,76 +30,144 @@ import java.util.Date;
 */
public class DoctorInterceptor extends BaseInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		try {
			response.setCharacterEncoding("UTF-8");
			JSONObject json = getAgent(request);
			if (json == null) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			String tokenStr = json.has("token") ? json.getString("token") : "";
			String uid = json.has("uid") ? json.getString("uid") : "";
			String imei = json.has("imei") ? json.getString("imei") : "";
			String observer = json.has("observer") ? json.getString("observer") : "";
			//如果是观察者直接返回true
			if (!org.springframework.util.StringUtils.isEmpty(observer) && observer.equals("1")) {
				return true;
			}
			if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        try {
            request.setAttribute("log-start", new Date().getTime());
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
			Token token = SystemData.doctorTokens.get(uid);
			if (token == null) {
				token = tokenDao.findByPatient(uid, 2);
				if (token != null) {
					// 加入缓存
					SystemData.doctorTokens.put(uid, token);
				}
			}
			if (token == null || token.getPlatform() != 2) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				flag = false;
			} else {
				if (token.getTimeout().getTime() < new Date().getTime()) {
					// 登录超时
					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
					flag = false;
				} else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
					// 别处登录
					response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
					flag = false;
				} else {
					// 一天只更新一次
					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
						// 今天未更新,则更新缓存
						token.setCzrq(new Date());
						// 更新内存
						SystemData.doctorTokens.put(uid, token);
						// 更新数据库
						tokenDao.save(token);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                return false;
            }
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
            if (json.has("uid") && json.has("admin_token") && StringUtils.isNotEmpty(json.getString("admin_token"))) {
                String adminToken = SystemConf.getInstance().getSystemProperties().getProperty("admin_token");
                String adminUid = SystemConf.getInstance().getSystemProperties().getProperty("admin_uid");
                if (json.getString("uid").equals(adminUid) && json.getString("admin_token").equals(adminToken)) {
                    return true;
                }
            }
	}
            String tokenStr = json.has("token") ? json.getString("token") : "";
            String uid = json.has("uid") ? json.getString("uid") : "";
            String imei = json.has("imei") ? json.getString("imei") : "";
            String observer = json.has("observer") ? json.getString("observer") : "";
            //如果是观察者直接返回true
            if (!org.springframework.util.StringUtils.isEmpty(observer) && observer.equals("1")) {
                Class cls = ((HandlerMethod) handler).getBeanType();
                RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
                Method method = ((HandlerMethod) handler).getMethod();
                RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
                String url = "";
                String urlCls = "";
                String urlMth = "";
                if (clsRm.value() != null && clsRm.value().length > 0) {
                    urlCls = clsRm.value()[0];
                }
                if (mthRm.value() != null && mthRm.value().length > 0) {
                    urlMth = mthRm.value()[0];
                }
                if (StringUtils.isNotEmpty(urlCls)) {
                    url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
                }
                if (StringUtils.isNotEmpty(urlMth)) {
                    url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
                }
                url = url.replace("\\", "/").replace("//", "/");
                CudUrl cudUrl = cudUrlDao.findByUrl(url);
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
                if (cudUrl != null) {
                    if (StringUtils.isNotEmpty(cudUrl.getMethod()) &&
                            request.getMethod().toUpperCase().compareTo(cudUrl.getMethod()) != 0) {
                        return true;
                    } else {
                        response.getOutputStream().write(error(403, "该操作没有权限").getBytes());
                        return false;
                    }
                }
	}
                return true;
            }
            if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                return false;
            }
            Token token = SystemData.doctorTokens.get(uid);
            if (token == null) {
                token = tokenDao.findByPatient(uid, 2);
                if (token != null) {
                    // 加入缓存
                    SystemData.doctorTokens.put(uid, token);
                }
            }
            if (token == null || token.getPlatform() != 2) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                flag = false;
            } else {
                if (token.getTimeout().getTime() < new Date().getTime()) {
                    // 登录超时
                    response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
                    flag = false;
                } else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
                    flag = false;
                } else {
                    // 一天只更新一次
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        SystemData.doctorTokens.put(uid, token);
                        // 更新数据库
                        tokenDao.save(token);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        long start = (long) request.getAttribute("log-start");
        long end = new Date().getTime();
        Class cls = ((HandlerMethod) handler).getBeanType();
        RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
        Method method = ((HandlerMethod) handler).getMethod();
        RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
        String url = "";
        String urlCls = "";
        String urlMth = "";
        if (clsRm.value() != null && clsRm.value().length > 0) {
            urlCls = clsRm.value()[0];
        }
        if (mthRm.value() != null && mthRm.value().length > 0) {
            urlMth = mthRm.value()[0];
        }
        if (StringUtils.isNotEmpty(urlCls)) {
            url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
        }
        if (StringUtils.isNotEmpty(urlMth)) {
            url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
        }
        url = url.replace("\\", "/").replace("//", "/");
        JSONObject json = getAgent(request);
        String uid = json.has("uid") ? json.getString("uid") : "";
        InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
    }
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
}

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -1,12 +1,16 @@
package com.yihu.wlyy.interceptors;
import java.lang.reflect.Method;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import com.yihu.wlyy.entity.security.Token;
@ -25,6 +29,7 @@ public class PatientInterceptor extends BaseInterceptor {
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		try {
			request.setAttribute("log-start", new Date().getTime());
			if(request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode")){
				return true;
			}
@ -92,7 +97,32 @@ public class PatientInterceptor extends BaseInterceptor {
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		long start = (long) request.getAttribute("log-start");
		long end = new Date().getTime();
		Class cls = ((HandlerMethod) handler).getBeanType();
		RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
		Method method = ((HandlerMethod) handler).getMethod();
		RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
		String url = "";
		String urlCls = "";
		String urlMth = "";
		if (clsRm.value() != null && clsRm.value().length > 0) {
			urlCls = clsRm.value()[0];
		}
		if (mthRm.value() != null && mthRm.value().length > 0) {
			urlMth = mthRm.value()[0];
		}
		if (StringUtils.isNotEmpty(urlCls)) {
			url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
		}
		if (StringUtils.isNotEmpty(urlMth)) {
			url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
		}
		url = url.replace("\\", "/").replace("//", "/");
		JSONObject json = getAgent(request);
		String uid = json.has("uid") ? json.getString("uid") : "";
		InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
	}
	@Override

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/UserInterceptor.java

@ -1,12 +1,16 @@
package com.yihu.wlyy.interceptors;
import java.lang.reflect.Method;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import com.yihu.wlyy.entity.security.Token;
@ -24,6 +28,7 @@ public class UserInterceptor extends BaseInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		try {
			request.setAttribute("log-start", new Date().getTime());
			response.setCharacterEncoding("UTF-8");
			JSONObject json = getAgent(request);
			if (json == null) {
@ -97,7 +102,32 @@ public class UserInterceptor extends BaseInterceptor {
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		long start = (long) request.getAttribute("log-start");
		long end = new Date().getTime();
		Class cls = ((HandlerMethod) handler).getBeanType();
		RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
		Method method = ((HandlerMethod) handler).getMethod();
		RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
		String url = "";
		String urlCls = "";
		String urlMth = "";
		if (clsRm.value() != null && clsRm.value().length > 0) {
			urlCls = clsRm.value()[0];
		}
		if (mthRm.value() != null && mthRm.value().length > 0) {
			urlMth = mthRm.value()[0];
		}
		if (StringUtils.isNotEmpty(urlCls)) {
			url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
		}
		if (StringUtils.isNotEmpty(urlMth)) {
			url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
		}
		url = url.replace("\\", "/").replace("//", "/");
		JSONObject json = getAgent(request);
		String uid = json.has("uid") ? json.getString("uid") : "";
		InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
	}
	@Override

+ 65 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/logs/BusinessLogs.java

@ -0,0 +1,65 @@
package com.yihu.wlyy.logs;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 业务日志输出
 * <p>
 * Created by lyr-pc on 2017/1/19.
 */
public class BusinessLogs {
    // 日志输出
    private static Logger logger = LoggerFactory.getLogger(BusinessLogs.class);
    /**
     * 业务类型
     */
    public enum BusinessType {
        // 咨询
        consult
        // 指导
        , guidance
        // 健康教育
        , article
        // 随访
        , followup
        // 预约
        , appointment
        // 标签
        , label
        // 签约
        , register
    }
    /**
     * 业务日志输出
     *
     * @param type 业务类别
     * @param info 日志信息
     */
    public static void info(BusinessType type, String user, JSONObject info) {
        try {
            logger.info(type.ordinal() + " - " + user + " - " + info.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 业务日志输出
     *
     * @param type 业务类别
     * @param info 日志信息
     */
    public static void info(BusinessType type, String user, JSONArray info) {
        try {
            logger.info(type.ordinal() + " - " + user + " - " + info.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 26 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/logs/InterfaceCallLogs.java

@ -0,0 +1,26 @@
package com.yihu.wlyy.logs;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Created by lyr-pc on 2017/1/22.
 */
public class InterfaceCallLogs {
    // 日志输出
    private static Logger logger = LoggerFactory.getLogger(InterfaceCallLogs.class);
    /**
     * 接口调用日志输出
     *
     * @param info 日志信息
     */
    public static void info(long time, String url, String user, String info) {
        try {
            logger.info(user + " - " + url + " - " + time + "ms - " + info.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 13 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/url/CudUrlDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.url;
import com.yihu.wlyy.entity.url.CudUrl;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by lyr-pc on 2017/1/18.
 */
public interface CudUrlDao extends PagingAndSortingRepository<CudUrl, Long>, JpaSpecificationExecutor<CudUrl> {
    CudUrl findByUrl(String url);
}

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -35,6 +35,7 @@ import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
@ -879,6 +880,7 @@ public class DoctorInfoService extends BaseService {
        Integer error = 0;//转移失败
        for (int i = 0; i < patiensString.length; i++) {
            try {
                ImUtill.deleteMucUser(newDoctorCode,oldDoctorCode,patiensString[i]+"_consult_2");
                updateTeamHealthDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
                successs++;
            } catch (Exception e) {
@ -911,6 +913,7 @@ public class DoctorInfoService extends BaseService {
                    if (updateTeamHealthDoctorAll(newDoctorCode, patient) == -1) {
                        hasNoTeam = true;
                    }
                    ImUtill.deleteMucUser(newDoctorCode,doctor,patient+"_consult_2");
                } catch (Exception e) {
                    e.printStackTrace();
                }
@ -1083,6 +1086,7 @@ public class DoctorInfoService extends BaseService {
        for (int i = 0; i < patiensString.length; i++) {
            try {
                ImUtill.deleteMucUser(newDoctorCode,oldDoctorCode,patiensString[i]+"_consult_2");
                updateTeamDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
                successs++;
            } catch (Exception e) {

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

@ -677,11 +677,11 @@ public class ConsultTeamService extends ConsultService {
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMember.getMemberCode(),0);
            }else{
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                if(doctorTeamMember!=null){
                    users.put(doctorTeamMember.getMemberCode(),1);
                users.put(doctorTeamMember.getMemberCode(), 0);
            } else {
                users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
                if (doctorTeamMember != null) {
                    users.put(doctorTeamMember.getMemberCode(), 1);
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            }
@ -703,11 +703,11 @@ public class ConsultTeamService extends ConsultService {
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
            }else{
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                if(doctorTeamMember!=null){
                    users.put(doctorTeamMember.getMemberCode(),1);
                users.put(doctorTeamMember.getMemberCode(), 0);
            } else {
                users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
                if (doctorTeamMember != null) {
                    users.put(doctorTeamMember.getMemberCode(), 1);
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            }
@ -748,10 +748,10 @@ public class ConsultTeamService extends ConsultService {
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM去创建议题,取得成员消息
        JSONObject messages  = ImUtill.getCreateTopicMessage(patient,tempPatient.getName(),consult.getTitle(),consult.getSymptoms(),consult.getImages());
        users.put(patient,0);
        JSONObject obj  = ImUtill.createTopics(patient+"_consult_"+ct.getType(),consult.getCode(),"咨询问题:"+consult.getSymptoms(),users,messages,"1");
        if(obj==null){
        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages());
        users.put(patient, 0);
        JSONObject obj = ImUtill.createTopics(patient + "_consult_" + ct.getType(), consult.getCode(), tempPatient.getName() + " " + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard()), users, messages, "1");
        if (obj == null) {
            throw new RuntimeException("IM消息结束异常!");
        }
        ct.setStartMsgId(obj.get("start_msg_id").toString());
@ -954,7 +954,7 @@ public class ConsultTeamService extends ConsultService {
            throw new Exception("send consult finished IM message failed");
        } else {
            JSONObject jo = new JSONObject(returnJson);            //设置消息ID
            consultTeam.setEndMsgId(jo.getInt("startId")+"");
            consultTeam.setEndMsgId(jo.getInt("startId") + "");
            consultTeam.setEndOperator(endOperator);
            consultTeam.setEndType(endType);
        }
@ -1217,7 +1217,7 @@ public class ConsultTeamService extends ConsultService {
        ;
        JSONObject jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(jo.getInt("startId")+"");
        ct.setStartMsgId(jo.getInt("startId") + "");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
@ -1289,6 +1289,7 @@ public class ConsultTeamService extends ConsultService {
    public List<ConsultTeamLog> getConsultLog(String consultCode) {
        return consultTeamLogDao.getConsultLogByConsultLog(consultCode);
    }
    /**
     * @param ct
     * @param uid
@ -1329,10 +1330,10 @@ public class ConsultTeamService extends ConsultService {
        //推送给IM文字消息
        String returnJson = null;
        JSONObject jo;
        if(StringUtils.isNotEmpty(oldConsultCode)){
            ConsultTeam oldConsult =  consultTeamDao.findByConsult(oldConsultCode);
            if(oldConsult!=null){
                returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
        if (StringUtils.isNotEmpty(oldConsultCode)) {
            ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
            if (oldConsult != null) {
                returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" + oldConsult.getSymptoms());
                //推送给IM图片
                if (StringUtils.isNotEmpty(oldConsult.getImages())) {
                    String[] images = oldConsult.getImages().split(",");
@ -1344,13 +1345,13 @@ public class ConsultTeamService extends ConsultService {
                }
            }
        }
        if(StringUtils.isEmpty(returnJson))
        if (StringUtils.isEmpty(returnJson))
            returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        else
            sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(jo.getInt("startId")+"");
        ct.setStartMsgId(jo.getInt("startId") + "");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
@ -1373,10 +1374,10 @@ public class ConsultTeamService extends ConsultService {
    public void sendForHelpMsg(ConsultTeam ct, String uid, String oldConsultCode) throws Exception {
        ct.setPatient(uid);
        //推送给IM文字消息
        if(StringUtils.isNotEmpty(oldConsultCode)){
            ConsultTeam oldConsult =  consultTeamDao.findByConsult(oldConsultCode);
            if(oldConsult!=null){
                sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
        if (StringUtils.isNotEmpty(oldConsultCode)) {
            ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
            if (oldConsult != null) {
                sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" + oldConsult.getSymptoms());
                //推送给IM图片
                if (StringUtils.isNotEmpty(oldConsult.getImages())) {
                    String[] images = oldConsult.getImages().split(",");
@ -1388,7 +1389,7 @@ public class ConsultTeamService extends ConsultService {
                }
            }
        }
        sendIM(ct.getPatient(), ct.getDoctor(), "6", "咨询问题:"+ ct.getSymptoms());
        sendIM(ct.getPatient(), ct.getDoctor(), "6", "咨询问题:" + ct.getSymptoms());
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
@ -1410,73 +1411,76 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 判断两医生是否在同一团队内
     *
     * @param docCode1
     * @param docCode2
     * @return
     */
    public boolean isCommonTeam(String docCode1, String docCode2){
    public boolean isCommonTeam(String docCode1, String docCode2) {
        String sqlQuSum =
                "SELECT c.team_id FROM " +
                        "(SELECT a.* FROM wlyy_admin_team_member a where a.doctor_code='"+ docCode1 +"' ) c " +
                        "(SELECT a.* FROM wlyy_admin_team_member a where a.doctor_code='" + docCode1 + "' ) c " +
                        "LEFT JOIN " +
                        "(SELECT b.* FROM wlyy_admin_team_member b where b.doctor_code='"+ docCode2 +"' ) d " +
                        "(SELECT b.* FROM wlyy_admin_team_member b where b.doctor_code='" + docCode2 + "' ) d " +
                        "on c.team_id=d.team_id " +
                        "WHERE d.team_id IS NOT NULL";
        List ls = jdbcTemplate.queryForList(sqlQuSum);
        return ls!=null && ls.size()>0;
        return ls != null && ls.size() > 0;
    }
    /**
     * 通过team获取医生code
     *
     * @param consult 关联的上一个咨询
     * @return
     */
    public List findByTeam(String consult){
    public List findByTeam(String consult) {
        return consultTeamDao.findByTeamAndType(consult, 10);
    }
    /**
     * 全科医生求助专科医生(同团队)
     *
     * @param ct
     * @param uid
     * @param oldConsultCode
     * @param isSend 是否转发患者咨询内容
     * @param isSend         是否转发患者咨询内容
     */
    public void addSeekHelpTeam(ConsultTeam ct, String uid,String oldConsultCode,int isSend){
    public void addSeekHelpTeam(ConsultTeam ct, String uid, String oldConsultCode, int isSend) {
        ct.setPatient(uid);
        //推送给IM文字消息
        JSONObject participants = new JSONObject();
        participants.put(ct.getPatient(),0);
        participants.put(ct.getDoctor(),0);
        participants.put(ct.getPatient(), 0);
        participants.put(ct.getDoctor(), 0);
        Doctor doctor = doctorService.findDoctorByCode(uid);
        JSONObject sessionJson =  ImUtill.createSession(participants,"2",doctor.getName()+"发起求助!","");
        if(sessionJson.getInt("status")==-1){
            throw  new RuntimeException(sessionJson.getString("message"));
        JSONObject sessionJson = ImUtill.createSession(participants, "2", doctor.getName() + "发起求助!", "");
        if (sessionJson.getInt("status") == -1) {
            throw new RuntimeException(sessionJson.getString("message"));
        }
        JSONObject session = sessionJson.getJSONObject("data");
        if(StringUtils.isNotEmpty(oldConsultCode)){
        if (StringUtils.isNotEmpty(oldConsultCode)) {
            ct.setTeam(oldConsultCode);
            ConsultTeam oldConsult =  consultTeamDao.findByConsult(oldConsultCode);
            if(oldConsult!=null&&isSend==1){
                ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","居民问题:" +oldConsult.getSymptoms());
            ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
            if (oldConsult != null && isSend == 1) {
                ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "居民问题:" + oldConsult.getSymptoms(), "1");
                //推送给IM图片
                if (StringUtils.isNotEmpty(oldConsult.getImages())) {
                    String[] images = oldConsult.getImages().split(",");
                    for (String image : images) {
                        if (StringUtils.isNoneEmpty(image)) {
                            ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2",image);
                            ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
                        }
                    }
                }
            }
        }
        ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","咨询问题:"+ ct.getSymptoms());
        ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "咨询问题:" + ct.getSymptoms(), "1");
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2",image);
                    ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
                }
            }
        }
@ -1484,14 +1488,16 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 全科医生求助专科医生(不同团队)
     *
     * @param ct
     * @param uid
     * @param oldConsultCode
     */
    public void addSeekHelpOtherTeam(ConsultTeam ct, String uid,String oldConsultCode,int isSend) throws Exception{
    public void addSeekHelpOtherTeam(ConsultTeam ct, String uid, String oldConsultCode, int isSend) throws Exception {
        // 设置患者信息
        ct.setPatient(uid);
        Doctor doctorTemp = doctorDao.findByCode(uid);
        Doctor doctor = doctorDao.findByCode(ct.getDoctor());
        // 设置医生姓名
        ct.setName(doctorTemp.getName());
        // 设置医生生日
@ -1520,35 +1526,52 @@ public class ConsultTeamService extends ConsultService {
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content = addLogs(ct);
        JSONObject messages  = ImUtill.getCreateTopicMessage(doctorTemp.getCode(),doctorTemp.getName(),consult.getTitle(),content,consult.getImages());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        //设置消息ID
        JSONObject obj = ImUtill.createTopics(null,consult.getCode(),doctorTemp.getName(),jsonObject,messages,"2");
        if(obj==null||obj.getInt("status")==-1){
            throw new RuntimeException("im消息创建异常!"+obj==null?"":obj.getString("message"));
        }
        ct.setStartMsgId(obj.get("start_msg_id").toString());
        //转发咨询问题
        if(StringUtils.isNotBlank(oldConsultCode)){
        if (StringUtils.isBlank(oldConsultCode)) {
            JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages());
            JSONObject jsonObject = new JSONObject();
            jsonObject.put(ct.getPatient(), 0);
            jsonObject.put(ct.getDoctor(), 0);
            //设置消息ID
            JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
            if (obj == null || obj.getInt("status") == -1) {
                throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
            }
            ct.setStartMsgId(obj.get("start_msg_id").toString());
        } else {
            //转发咨询问题
            Consult oldConsult = consultDao.findByCode(oldConsultCode);
            ct.setTeam(oldConsultCode);
            if(oldConsult!=null&&isSend==1){
                ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"6",oldConsult.getSymptoms());
                if(StringUtils.isNotBlank(oldConsult.getImages())){
                    String imgs[] = oldConsult.getImages().split(",");
                    for(String url :imgs)
                        ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"2",url);
            if (oldConsult != null && isSend == 1) {
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), oldConsult.getSymptoms(), oldConsult.getImages());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
                if (obj == null || obj.getInt("status") == -1) {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
                ct.setStartMsgId(obj.get("start_msg_id").toString());
                ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content);
                if (StringUtils.isNotBlank(consult.getImages())) {
                    String imgs[] = consult.getImages().split(",");
                    for (String url : imgs)
                        ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url);
                }
            }
            JSONObject qiuzuObj = new JSONObject();
            qiuzuObj.put("session_id", oldConsult.getPatient() + "_consult_" + consult.getType());
            qiuzuObj.put("patient", ct.getPatient());
            qiuzuObj.put("old_consult_code", oldConsultCode);
            qiuzuObj.put("doctor", ct.getDoctor());
            qiuzuObj.put("doctor_name", doctor.getName());
            ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString());
        }
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
        consultDao.save(consult);
    }
    public int finishConsult(String consult, String endOperator, int endType){
    public int finishConsult(String consult, String endOperator, int endType) {
        ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
        String endName = "";
        String endId = "";
@ -1558,16 +1581,21 @@ public class ConsultTeamService extends ConsultService {
            endName = p.getName();
            endId = p.getCode();
        } else {
            Doctor d = doctorDao.findByCode(endOperator);
            endId = d.getCode();
            endName = d.getName();
            if (endOperator.equals("admin")) {
                endId = "system";
                endName = "system";
            } else {
                Doctor d = doctorDao.findByCode(endOperator);
                endId = d.getCode();
                endName = d.getName();
            }
        }
        JSONObject obj = ImUtill.endTopics(consultTeam.getPatient(),endId,endName,consultTeam.getConsult());
        if(obj==null){
        JSONObject obj = ImUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
        if (obj == null) {
            throw new RuntimeException("IM消息结束异常!");
        }
        if(obj.getInt("status")==-1){
            throw new RuntimeException(obj.getString("message"));
        if (obj.getInt("status") == -1) {
            throw new RuntimeException(String.valueOf(obj.get("message")));
        }
        consultTeam.setType(endType);
        consultTeam.setEndMsgId(obj.getString("id"));
@ -1577,6 +1605,7 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 新增名医咨询
     *
     * @param ct
     * @param uid
     * @param type 1患者 2医生
@ -1585,8 +1614,8 @@ public class ConsultTeamService extends ConsultService {
    public void famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
        // 设置患者信息
        ct.setPatient(uid);
        String senderId="";
        String senderName="";
        String senderId = "";
        String senderName = "";
        if ("1".equals(type)) {
            // 查询患者信息
            Patient tempPatient = patientDao.findByCode(uid);
@ -1640,16 +1669,16 @@ public class ConsultTeamService extends ConsultService {
        String content = addLogs(ct);
        //推送给IM文字消息
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        jsonObject.put(ct.getPatient(), 0);
        jsonObject.put(ct.getDoctor(), 0);
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId,senderName,senderName+"发起咨询",content,ct.getImages());
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages());
        JSONObject obj = ImUtill.createTopics(null,consult.getCode(),consult.getSymptoms(),jsonObject,messages,"2");
        if(obj==null){
        JSONObject obj = ImUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, "2");
        if (obj == null) {
            throw new RuntimeException("im消息创建异常!");
        }
        if(obj.getInt("status")==-1){
        if (obj.getInt("status") == -1) {
            throw new RuntimeException(obj.getString("message"));
        }
        //设置消息ID

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -255,7 +255,7 @@ public class FollowUpService extends BaseService {
     * 新增随访计划(批量)
     */
    @Transactional
    public void addFollowupPlan(String doctorCode, String patientCode, String data) throws Exception {
    public Iterable<Followup> addFollowupPlan(String doctorCode, String patientCode, String data) throws Exception {
        //批量随访计划
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
@ -299,8 +299,10 @@ public class FollowUpService extends BaseService {
                followupPlan.add(followup);
            }
            followupDao.save(followupPlan);
            return followupDao.save(followupPlan);
        }
        return null;
    }

+ 9 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
@ -954,6 +955,7 @@ public class SignPatientLabelInfoService extends BaseService {
            }
        }
        JSONArray logArray = new JSONArray();
        JSONArray teams = adminTeamService.findPatientDoctorTeam(patient, doctor);
        List<String> teamCodes = new ArrayList<>();
@ -991,6 +993,7 @@ public class SignPatientLabelInfoService extends BaseService {
                healthLabel.setCzrq(new Date());
                labelInfoDao.save(healthLabel);
                logArray.put(new JSONObject(label));
            }
        } else {
            return -2;
@ -1034,6 +1037,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    disLabel.setCzrq(new Date());
                    labelInfoDao.save(disLabel);
                    logArray.put(new JSONObject(label));
                }
            }
        } else {
@ -1081,6 +1085,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    cusLabel.setCzrq(new Date());
                    labelInfoDao.save(cusLabel);
                    logArray.put(new JSONObject(label));
                }
            }
        }
@ -1103,6 +1108,7 @@ public class SignPatientLabelInfoService extends BaseService {
                disLabel.setCzrq(new Date());
                labelInfoDao.save(disLabel);
                logArray.put(new JSONObject("{\"labelCode\":\"1\",\"labelName\":\"慢病人群\",\"labelType\":\"1\"}"));
            }
        } else {
            int age = IdCardUtil.getAgeForIdcard(idcard);
@ -1131,9 +1137,12 @@ public class SignPatientLabelInfoService extends BaseService {
                disLabel.setLabelName(lbName);
                labelInfoDao.save(disLabel);
                logArray.put(new JSONObject("{\"labelCode\":\"" + lbCode + "\",\"labelName\":\"" + lbName + "\",\"labelType\":\"1\"}"));
            }
        }
        BusinessLogs.info(BusinessLogs.BusinessType.label, patient, logArray);
        return 1;
    }

+ 5 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -334,9 +334,7 @@ public class MessageService extends BaseService {
                map.put("type", type);
                map.put("read", String.valueOf(item.getRead()));
                map.put("sex", String.valueOf(item.getSex()));
                map.put("value1", String.valueOf(item.getValue1()));
                String value2 = String.valueOf(item.getValue2().intValue());
                map.put("value2",value2);
                map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
                DevicePatientHealthIndex data =devicePatientHealthIndexDao.findOne(Long.valueOf(item.getTzCode()));
@ -345,6 +343,10 @@ public class MessageService extends BaseService {
                    //记录时间
                    map.put("recordDate",DateUtil.dateToStrLong(data.getRecordDate()));
                    //指标数据
                    map.put("value1", data.getValue1());
                    String value2 = Integer.valueOf(data.getValue2()).toString();
                    map.put("value2",value2);
                    /*//获取上次血糖值
                    if("1".equals(type))
                    {

+ 14 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1739,7 +1739,13 @@ public class FamilyContractService extends BaseService {
                    result.put("msg", "与当前健管师有未结束的咨询");
                    return result;
                }
                try{
                    ImUtill.deleteMucUser(healthDoctor,signFamily.getDoctorHealth(),patient+"_consult_2");
                }catch (Exception e){
                    result.put("status", -1);
                    result.put("msg", e.getMessage());
                    return result;
                }
                DoctorTeamMember teamMember = doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(), signFamily.getDoctorHealth());
                if (teamMember != null) {
@ -1817,7 +1823,13 @@ public class FamilyContractService extends BaseService {
            String oldDoctorName = signFamily.getDoctorName();
            if (StringUtils.isNotEmpty(signFamily.getDoctor())) {
                DoctorTeamMember teamMember = doctorTeamDoctor.findMemberByTeamAndQkCode(signFamily.getTeamCode(), signFamily.getDoctor());
                 try{
                    ImUtill.deleteMucUser(doctor,signFamily.getDoctor(),patient+"_consult_2");
                }catch (Exception e){
                    result.put("status", -1);
                    result.put("msg", e.getMessage());
                    return result;
                }
                if (teamMember != null) {
                    teamMember.setDel("0");
                    teamMember.setCzrq(new Date());

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -187,6 +187,7 @@ public class CommonUtil {
                fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + serverUrl
                        + result.get("groupName").toString().replaceAll("\"", "") + "/"
                        + result.get("remoteFileName").toString().replaceAll("\"", "");
                f.delete();
            }
        }
        return fileUrls;

+ 3 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -126,12 +126,12 @@ public class HttpUtil {
	 * 消息推送
	 *
	 * @param receiver 消息接收人
	 * @param msgType 消息类型
	 * @param businessType 消息类型
	 * @param title 消息标题
	 * @param msg 消息内容
	 * @param data 消息数据
	 */
	public static boolean pushMessage(String receiver, String msgType, String title, String msg, String data) {
	public static boolean pushMessage(String receiver, String businessType, String title, String msg, String data) {
		try{
			JSONObject participants = new JSONObject();
			participants.put("system",0);
@ -141,7 +141,7 @@ public class HttpUtil {
				throw  new RuntimeException(sessionObj.getString("message"));
			}
			JSONObject session = sessionObj.getJSONObject("data");
			ImUtill.sendImMsg("system","系统",session.getString("id"),msgType, msg);
			ImUtill.sendImMsg("system","系统",session.getString("id"),"1", msg,businessType);
			return true;
		}catch (Exception e){
			e.printStackTrace();

+ 32 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -14,14 +14,15 @@ public class ImUtill {
     * @param contentType 1文字 2图片消息
     * @param content     内容
     */
    public static String sendImMsg(String from,String fromName, String sessionId, String contentType, String content) {
    public static String sendImMsg(String from,String fromName, String sessionId, String contentType, String content,String businessType) {
        String imAddr = SystemConf.getInstance().getImListGet() + "/api/v2/sessions/"+sessionId+"/messages";
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("content_type", contentType);
        params.put("content", content);
        params.put("session_id", sessionId);;
        params.put("session_id", sessionId);
        params.put("business_type", businessType);
        String response = HttpClientUtil.postBody(imAddr, params);
        return response;
    }
@ -168,4 +169,33 @@ public class ImUtill {
        }
    }
    /**
     * 删除对应的成员信息在MUC模式中
     * @param userId
     * @param oldUserId
     * @param sessionId
     * @return
     */
    public static JSONObject deleteMucUser(String userId,String oldUserId,String sessionId) throws  Exception{
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "api/v2/sessions/"+sessionId+"/participant/update";
        try{
            JSONObject params = new JSONObject();
            params.put("user_id", userId);
            params.put("old_user_id", oldUserId);
            params.put("session_id", sessionId);
            String ret = HttpClientUtil.postBody(url,params);
            JSONObject obj = new JSONObject(ret);
            if(obj.getInt("status")==-1){
                throw new RuntimeException("人员更换失败!");
            }else{
                return obj;
            }
        }catch (Exception e){
           throw new RuntimeException("人员更换失败!");
        }
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendPatientUtil.java

@ -22,6 +22,6 @@ public class SendPatientUtil {
			throw  new RuntimeException(sessionJson.getString("message"));
		}
		JSONObject session = sessionJson.getJSONObject("data");
		return ImUtill.sendImMsg(from,fromName,session.getString("id"),contentType,content);
		return ImUtill.sendImMsg(from,fromName,session.getString("id"),contentType,content,"1");
	}
}

+ 2 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/WeixinBaseController.java

@ -12,6 +12,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,11 +24,6 @@ import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.ImageCompress;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
public class WeixinBaseController extends BaseController {
@ -424,7 +420,7 @@ public class WeixinBaseController extends BaseController {
		// 拼接年月日路径
		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
		// 重命名文件
		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".wav";
		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".mp3";
		// 保存路径
		File uploadFile = new File(tempPath + datePath + newFileName);

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

@ -188,7 +188,7 @@ public class FileUploadController extends BaseController {
                fileName = mf.getOriginalFilename();
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                if("3".equals(type)){
                    fileExt ="wav";
                    fileExt ="mp3";
                }
                ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")

+ 9 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -9,6 +9,7 @@ import java.util.UUID;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyService;
@ -302,13 +303,19 @@ public class WechatController extends WeixinBaseController {
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
            if(!org.springframework.util.StringUtils.isEmpty(openid)){
            if (!org.springframework.util.StringUtils.isEmpty(openid)) {
                patient.setOpenid(openid);
                patient.setOpenidTime(new Date());
            }
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
            if (json != null) {
                try {
                    Patient p = patientDao.findByIdcard(idcard);
                    BusinessLogs.info(BusinessLogs.BusinessType.register, p.getCode(), new JSONObject(p));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 注册成功
                return write(200, "注册成功!", "data", json);
            } else {
@ -336,7 +343,7 @@ public class WechatController extends WeixinBaseController {
            @RequestParam(required = false) String captcha,
            @RequestParam(required = false) String password,
            String openid) {
        System.out.println("login openid : " + openid );
        System.out.println("login openid : " + openid);
        String errorMessage;
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -1575,6 +1575,7 @@ public class DoctorController extends BaseController {
                return error(-2, "正在分配,请勿重复操作");
            }
            if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                int result = doctorInfoService.updateTeamHealthDoctorsAll(newDoctorCode, getUID());
                redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
                redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);

+ 6 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -660,7 +660,7 @@ public class DoctorConsultController extends WeixinBaseController {
                }
            }
            if (StringUtils.isEmpty(voice)) {
            if (StringUtils.isNotEmpty(voice)) {
                voice = fetchWxVoices();
            }
            if (StringUtils.isNotEmpty(voice)) {
@ -875,26 +875,19 @@ public class DoctorConsultController extends WeixinBaseController {
                json.put("isCommonTeam", 1);
                return write(200, "查询成功", "data", json);
            }
            List<ConsultTeam>  ls = consultTeamService.hasUnfinished(doctorCode, curDoc);
            if(ls!=null && ls.size() > 0){
                ConsultTeam ct =  ls.get(0);
                json.put("consult", ct.getConsult());
                //是否是医生求助医生
                if(ct.getType()==10){
                    List<WlyyTalkGroup> wlyyTalkGroups = talkGroupService.findAllConsultTalkGroup(ct.getTeam());
                    if(wlyyTalkGroups!=null && wlyyTalkGroups.size()>0){
                        for (WlyyTalkGroup g : wlyyTalkGroups){
                            if(g.getType()==1){
                                json.put("zxGroupCode", g.getCode());
                                json.put("from", ct.getPatient());
                                break;
                            }
                        }
                    }
                    ConsultTeam consultTeam = consultTeamService.findByConsultCode(ct.getTeam());
                    Patient patient = patientService.findByCode(consultTeam.getPatient());
                    json.put("zxGroupCode",consultTeam.getPatient()+"_consult_"+consultTeam.getType());
                    json.put("from", ct.getPatient());
                    json.put("patient_name", patient.getName());
                }
            }
            return write(200, "查询成功", "data", json);
        } catch (Exception ex) {
            error(ex);

+ 8 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.followup;
import java.util.*;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -116,7 +117,13 @@ public class DoctorFollowUpController extends BaseController {
                                  @ApiParam(name = "data", value = "随访计划列表json", defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
                                  @RequestParam(value = "data", required = true) String data) {
        try {
            followUpService.addFollowupPlan(getUID(), patient, data);
            Iterable<Followup> followups = followUpService.addFollowupPlan(getUID(), patient, data);
            if (followups != null) {
                for (Followup followup : followups) {
                    BusinessLogs.info(BusinessLogs.BusinessType.followup, followup.getPatientCode(), new JSONObject(followup));
                }
            }
            return write(200, "新增随访计划成功!");
        } catch (Exception e) {

+ 11 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -5,6 +5,7 @@ import java.util.*;
import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.health.*;
@ -75,6 +76,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    @Autowired
    ConsultService consultService;
    /**
     * 查询
     *
@ -383,7 +385,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    list.add(heap);
                    consultService.sendMucMessageBySingnType(doctor.getCode(),doctor.getName(), p, "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4","医生:"+doctor.getName()+"给患者:"+patientTemp.getName()+"发送了健康教育文章!");
                    consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", "医生:" + doctor.getName() + "给患者:" + patientTemp.getName() + "发送了健康教育文章!");
                    if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
@ -408,11 +410,16 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                return error(-1, "发送失败!");
            } else {
                for (String key : msgs.keySet()) {
                    Map<String,Object> map = msgs.get(key);
                    Map<String, Object> map = msgs.get(key);
                    PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9,
                            map.get("openid") == null ? "":map.get("openid").toString(),
                            map.get("name") == null ? "":map.get("name").toString(),
                            map.get("openid") == null ? "" : map.get("openid").toString(),
                            map.get("name") == null ? "" : map.get("name").toString(),
                            (JSONObject) map.get("json"));
                    JSONObject json = (JSONObject) map.get("json");
                }
                for (HealthEduArticlePatient heap : list) {
                    BusinessLogs.info(BusinessLogs.BusinessType.article, heap.getPatient(), new JSONObject(heap));
                }
                // 推送消息给患者

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
@ -98,6 +99,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				Patient p = patientService.findByCode(patient);
				consultService.sendMucMessageBySingnType(getUID(),doctor.getName(),patient,content,"1","医生:"+doctor.getName()+"给患者:"+p.getName()+"发送了健康指导!");
				BusinessLogs.info(BusinessLogs.BusinessType.guidance, patient, new JSONObject(guidance));
				return success("保存成功!");
			} else {
				return error(-1, "保存失败!");

+ 7 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -10,6 +10,7 @@ import java.util.concurrent.TimeUnit;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.sign.PatientRemindService;
@ -315,6 +316,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            if (sf == null) {
                return error(-1, "代理签约失败!");
            } else {
                try {
                    Patient p = patientService.findByIdcard(idcard);
                    BusinessLogs.info(BusinessLogs.BusinessType.register, p.getCode(), new JSONObject(p));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return success("代理签约成功!");
            }
        } catch (Exception e) {

+ 15 - 22
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.util.*;
@ -326,7 +327,7 @@ public class ConsultController extends WeixinBaseController {
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);
        } catch (Exception ex) {
            error(ex);
@ -398,6 +399,7 @@ public class ConsultController extends WeixinBaseController {
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);
        } catch (Exception ex) {
            error(ex);
@ -591,7 +593,7 @@ public class ConsultController extends WeixinBaseController {
     */
    @RequestMapping(value = "append")
    @ResponseBody
    public String append(@RequestParam String consult, @RequestParam String content, @RequestParam int type,@RequestParam(required = false,defaultValue = "0") Integer times) {
    public String append(@RequestParam String consult, @RequestParam String content, @RequestParam int type, @RequestParam(required = false, defaultValue = "0") Integer times) {
        try {
            List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
            ConsultTeam consultModel = consultTeamService.findByCode(consult);
@ -605,14 +607,14 @@ public class ConsultController extends WeixinBaseController {
            }
            String[] arr = null;
            if(type==3){
               String path =  fetchWxVoices();
               JSONObject obj = new JSONObject();
            if (type == 3) {
                String path = fetchWxVoices();
                JSONObject obj = new JSONObject();
                // 将临时语音拷贝到正式存储路径下
                if (StringUtils.isNotEmpty(path)) {
                    content = CommonUtil.copyTempVoice(path);
                    obj.put("path",content);
                    obj.put("times",times);
                    obj.put("path", content);
                    obj.put("times", times);
                    content = obj.toString();
                }
                ConsultTeamLog log = new ConsultTeamLog();
@ -622,18 +624,9 @@ public class ConsultController extends WeixinBaseController {
                log.setChatType(type);
                log.setType(3);
                logs.add(log);
            }else if (type == 2) {
            } else if (type == 2) {
                // 图片消息
                if (StringUtils.isEmpty(content)) {
                    String images = request.getParameter("mediaIds");
                    if (!StringUtils.isEmpty(images)) {
                        arr = images.split(",");
                    }
                } else {
                    arr = content.split(",");
                }
                content = fetchWxImages();
                // 将临时图片拷贝到正式存储路径下
                if (StringUtils.isNotEmpty(content)) {
                    content = CommonUtil.copyTempImage(content);
@ -667,11 +660,11 @@ public class ConsultController extends WeixinBaseController {
            List<String> failed = new ArrayList<>();
            for (ConsultTeamLog log : logs) {
                String response = ImUtill.sendTopicIM(getUID(),patient.getName(),consult,String.valueOf(log.getType()),log.getContent());
                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
                if (StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = new JSONObject(response);
                    if(resObj.getInt("status")==-1){
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!"+resObj.getString("message"));
                    if (resObj.getInt("status") == -1) {
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                }
@ -699,7 +692,7 @@ public class ConsultController extends WeixinBaseController {
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            JSONObject messageObj =  ImUtill.getTopicMessage(consultModel.getConsult(),consultModel.getStartMsgId(),consultModel.getEndMsgId(),page,pagesize,getUID());
            JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getUID());
            return write(200, "查询成功", "list", messageObj);
        } catch (Exception e) {
            error(e);

+ 50 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -1,10 +1,9 @@
package com.yihu.wlyy.web.third;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.guahao.GuahaoDoctor;
@ -24,14 +23,12 @@ import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
@ -60,8 +57,6 @@ public class BookingController extends WeixinBaseController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private SMSService smsService;
    /**
     * 根据城市编码获取相应挂号服务
     *
@ -78,7 +73,7 @@ public class BookingController extends WeixinBaseController {
    /**
     * 发送短信参数
     */
    private static List<NameValuePair> buildSmsParams(String content, String mobile) {
    private List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
        params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
@ -91,6 +86,24 @@ public class BookingController extends WeixinBaseController {
        return params;
    }
    private JSONObject toJson(String result) {
        JSONObject json = new JSONObject();
        try {
            String[] temps = result.split("&");
            for (String temp : temps) {
                if (temp.split("=").length != 2) {
                    continue;
                }
                String key = temp.split("=")[0];
                String value = temp.split("=")[1];
                json.put(key, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
    /**
     * 获取时间
     */
@ -299,6 +312,7 @@ public class BookingController extends WeixinBaseController {
//				} else {
//					//发送成功,保存到数据库
//				}
                BusinessLogs.info(BusinessLogs.BusinessType.appointment, p.getCode(), new JSONObject(obj));
                return write(200, "创建挂号单成功!");
            } else {
                return error(-1, "创建挂号单失败!");
@ -358,6 +372,29 @@ public class BookingController extends WeixinBaseController {
    /****************************************** 内网预约 ***************************************************************/
/*    @RequestMapping(value = "sendMessage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("发送短信测试")
    public String sendMessage()
    {
        try {
            //发送短信消息,调用总部发送信息的接口
            String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams("测试", "13559207522"), "GBK");
            System.out.print(result);
            *//*JSONObject json = toJson(result);
            JSONObject result = smsService.sendMsg("13559207522", "测试");
            if (result != null && result.getInt("result") != 0) {
                System.out.print("短信提醒失败!(原因:" + result.getString("description") + ")");
            }*//*
            return error(-1, "创建挂号单失败!"+result);
        }
        catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }*/
    @RequestMapping(value = "CreateOrderByDoctor", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("(内网)转诊预约挂号")
@ -400,9 +437,11 @@ public class BookingController extends WeixinBaseController {
                            obj.getDeptName() + obj.getDeptName() + "医生的号源。您可直接前往医院就诊。";
                    //发送短信消息,调用总部发送信息的接口
                    JSONObject result = smsService.sendMsg(patientPhone, msg);
                    if (result != null && result.getInt("result") != 0) {
                        des = "短信提醒失败!(原因:"+result.getString("description")+")";
                    String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, patientPhone), "GBK");
                    System.out.print(result);
                    JSONObject resultJson = toJson(result);
                    if (resultJson != null && resultJson.getInt("result") != 0) {
                        des = "短信提醒失败!(原因:"+resultJson.getString("description")+")";
                    }
                    // 推送消息给微信端
@ -424,6 +463,7 @@ public class BookingController extends WeixinBaseController {
                    else{
                        des +=" 微信提醒失败,患者无绑定微信!";
                    }
                    BusinessLogs.info(BusinessLogs.BusinessType.appointment, p.getCode(), new JSONObject(obj));
                }
                catch (Exception ex)
                {

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

@ -38,6 +38,8 @@ public class WeiXinEventProcess {
                    result = subscribeEventProcess(message);
                }
                break;
            case WeiXinMessageUtils.EVENT_TYPE_CLICK: //菜单点击
                result = WeiXinEventProcess.clickProcess(message);
            default:
                break;
        }
@ -46,18 +48,132 @@ public class WeiXinEventProcess {
    }
    /**
     * 关注事件消息发送
     * 微信菜单点击处理
     *
     * @param message
     * @return
     */
    public static String clickProcess(Map<String, String> message) throws Exception {
        String result = "";
        if(message.get("EventKey").equals("caozuoshuoming")){
            String tempStr = clickEventProcess(message);
            /*int firsIndex = tempStr.indexOf("<item>");
            String result1 = tempStr.substring(0,firsIndex-1);
            int secondIndex = tempStr.indexOf("<item>",firsIndex+10);
            String result2 = tempStr.substring(secondIndex-1);*/
            result=tempStr.replace("<ArticleCount>5</ArticleCount>","<ArticleCount>4</ArticleCount>");
        }
        return result;
    }
    /**
     * 菜单点击消息发送
     *
     * @param message
     * @return
     * @throws Exception
     */
    private static String clickEventProcess(Map<String,String> message) throws Exception{
        String result = "";
        // 配置信息
        Properties systemConf = SystemConf.getInstance().getSystemProperties();
        // 图文信息
        List<Map<String,String>> articles =  new ArrayList<>();
        Map<String,String> articleConsult = new HashMap<>();
        // 图文URL
        String urlConsult = systemConf.getProperty("patient_consult_url");
        // 图文消息图片URL
        String picUrlConsult = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlConsult = urlConsult.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlConsult = picUrlConsult.replace("{server}", systemConf.getProperty("server_url"));
        articleConsult.put("Url",urlConsult);
        articleConsult.put("Title", "医生咨询功能使用说明");
        articleConsult.put("Description","功能使用说明");
        articleConsult.put("PicUrl",picUrlConsult);
        articles.add(articleConsult);
        Map<String,String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = systemConf.getProperty("patient_booking_url");
        // 图文消息图片URL
        String picUrlBooking = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlBooking = urlBooking.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlBooking = picUrlBooking.replace("{server}", systemConf.getProperty("server_url"));
        articleBooking.put("Url",urlBooking);
        articleBooking.put("Title", "预约挂号功能使用说明");
        articleBooking.put("Description","功能使用说明");
        articleBooking.put("PicUrl",picUrlBooking);
        articles.add(articleBooking);
        Map<String,String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = systemConf.getProperty("patient_device_url");
        // 图文消息图片URL
        String picUrlDevice = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlDevice = urlDevice.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlDevice = picUrlDevice.replace("{server}", systemConf.getProperty("server_url"));
        articleDevice.put("Url",urlDevice);
        articleDevice.put("Title", "体征设备管理功能使用说明");
        articleDevice.put("Description","功能使用说明");
        articleDevice.put("PicUrl",picUrlDevice);
        articles.add(articleDevice);
        Map<String,String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = systemConf.getProperty("patient_family_url");
        // 图文消息图片URL
        String picUrlFamily = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlFamily = urlFamily.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlFamily = picUrlFamily.replace("{server}", systemConf.getProperty("server_url"));
        articleFamily.put("Url",urlFamily);
        articleFamily.put("Title", "我的家庭功能使用说明");
        articleFamily.put("Description","功能使用说明");
        articleFamily.put("PicUrl",picUrlFamily);
        articles.add(articleFamily);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"),message.get("ToUserName"),articles);
        return result;
    }
    /**
     * 关注事件消息发送
     * @param message
     * @return
     * @throws Exception
     */
    private static String subscribeEventProcess(Map<String,String> message) throws Exception{
        String result = "";
        // 配置信息
        Properties systemConf = SystemConf.getInstance().getSystemProperties();
        // 图文信息
        List<Map<String,String>> articles =  new ArrayList<>();
        Map<String,String> article = new HashMap<>();
        // 图文URL
        String url = systemConf.getProperty("doctor_subscribe_url");
@ -75,6 +191,79 @@ public class WeiXinEventProcess {
        article.put("PicUrl",picUrl);
        articles.add(article);
        Map<String,String> articleConsult = new HashMap<>();
        // 图文URL
        String urlConsult = systemConf.getProperty("patient_consult_url");
        // 图文消息图片URL
        String picUrlConsult = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlConsult = urlConsult.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlConsult = picUrlConsult.replace("{server}", systemConf.getProperty("server_url"));
        articleConsult.put("Url",urlConsult);
        articleConsult.put("Title", "医生咨询功能使用说明");
        articleConsult.put("Description","功能使用说明");
        articleConsult.put("PicUrl",picUrlConsult);
        articles.add(articleConsult);
        Map<String,String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = systemConf.getProperty("patient_booking_url");
        // 图文消息图片URL
        String picUrlBooking = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlBooking = urlBooking.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlBooking = picUrlBooking.replace("{server}", systemConf.getProperty("server_url"));
        articleBooking.put("Url",urlBooking);
        articleBooking.put("Title", "预约挂号功能使用说明");
        articleBooking.put("Description","功能使用说明");
        articleBooking.put("PicUrl",picUrlBooking);
        articles.add(articleBooking);
        Map<String,String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = systemConf.getProperty("patient_device_url");
        // 图文消息图片URL
        String picUrlDevice = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlDevice = urlDevice.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlDevice = picUrlDevice.replace("{server}", systemConf.getProperty("server_url"));
        articleDevice.put("Url",urlDevice);
        articleDevice.put("Title", "体征设备管理功能使用说明");
        articleDevice.put("Description","功能使用说明");
        articleDevice.put("PicUrl",picUrlDevice);
        articles.add(articleDevice);
        Map<String,String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = systemConf.getProperty("patient_family_url");
        // 图文消息图片URL
        String picUrlFamily = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlFamily = urlFamily.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlFamily = picUrlFamily.replace("{server}", systemConf.getProperty("server_url"));
        articleFamily.put("Url",urlFamily);
        articleFamily.put("Title", "我的家庭功能使用说明");
        articleFamily.put("Description","功能使用说明");
        articleFamily.put("PicUrl",picUrlFamily);
        articles.add(articleFamily);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"),message.get("ToUserName"),articles);

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinMessageReplyUtils.java

@ -31,7 +31,7 @@ public class WeiXinMessageReplyUtils {
        result.append("<FromUserName>" + fromUser + "</FromUserName>");
        result.append("<CreateTime>" + new Date().getTime() + "</CreateTime>");
        result.append("<MsgType>news</MsgType>");
        result.append("<ArticleCount>1</ArticleCount>");
        result.append("<ArticleCount>5</ArticleCount>");
        result.append("<Articles>");
        for(Map<String,String>  article : articles){

+ 26 - 0
patient-co-wlyy/src/main/resources/logback.xml

@ -16,12 +16,38 @@
		</encoder>
	</appender>
	<appender name="business" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>/usr/local/wlyy_logs/business.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>/usr/local/wlyy_logs/business.%d{yyyy-MM-dd}.log</fileNamePattern>
		</rollingPolicy>
		<encoder>
			<pattern>%date{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern>
		</encoder>
	</appender>
	<appender name="interface_call" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>/usr/local/wlyy_logs/interface_call.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>/usr/local/wlyy_logs/interface_call.%d{yyyy-MM-dd}.log</fileNamePattern>
		</rollingPolicy>
		<encoder>
			<pattern>%date{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern>
		</encoder>
	</appender>
	<!-- project default level -->
	<logger name="com.yihu.wlyy" level="INFO" />
	<!--log4jdbc -->
	<logger name="jdbc.sqltiming" level="INFO"/>
	<logger name="com.yihu.wlyy.logs.BusinessLogs" level="INFO" additivity="false">
		<appender-ref ref="business" />
	</logger>
	<logger name="com.yihu.wlyy.logs.InterfaceCallLogs" level="INFO" additivity="false">
		<appender-ref ref="interface_call" />
	</logger>
	<root level="WARN">
		<appender-ref ref="console" />
		<appender-ref ref="rollingFile" />

+ 13 - 1
patient-co-wlyy/src/main/resources/system.properties

@ -19,6 +19,14 @@ doctor_town_qrcode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid
doctor_qrcode_pic_url={server}/images/familycontract.png
doctor_invitel_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&redirect_uri={server}%2fwx%2fhtml%2fssgg%2fhtml%2fdoctor-homepage-new.html&response_type=code&scope=snsapi_base&state={doctorCode}__{invilogcode}__{currentPatient}__{currentZH}__{currentName}#wechat_redirect
patient_operatinginstrutions_pic_url={server}/images/operatinginstructions.png
patient_consult_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyszx.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_booking_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyygh.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_device_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2ftzsb.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_family_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2ffamily.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
# SMS短信配置
yihu_sms_url=https://smsapi.ums86.com:9600/sms/Api/Send.do
yihu_sms_code=229336
@ -34,6 +42,10 @@ image_path=/var/local/upload/images
voice_path=/var/local/upload/voice
chat_file_path=/var/local/upload/chat
#系统管理员token
admin_uid=admin
admin_token=0a5c5258-8863-4b07-a3f9-88c768528ab4
#-------------------------开发环境配置-------------------------#
# 服务器基本配置
server_ip=weixin.xmtyw.cn
@ -54,7 +66,7 @@ im_list_get=http://172.19.103.29:3000/
im_group_server=http://172.19.103.29:3000/api/v1/chats/gm
msg_push_server=http://172.19.103.29:3000/api/v1/chats/sm
# 微信基本配置
# 微信基本配置 wxb3827510b2e15012 c5bdedd909ded9c2ee08028487e6f50d
appId=wxd03f859efdf0873d
appSecret=2935b54b53a957d9516c920a544f2537
wechat_base_url=http%3a%2f%2fweixin.xmtyw.cn%2fwlyy

+ 6 - 1
patient-co-wlyy/src/main/resources/weixin_menu.txt

@ -78,7 +78,12 @@
		   "type":"view",
		   "name":"我的预约",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fmy-appointment.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		}
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        }
	 ]
  }
]

BIN=BIN
patient-co-wlyy/src/main/webapp/images/operatinginstructions.png