Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into baseCopy1

wangjun 3 years ago
parent
commit
f4cdc9fa79
20 changed files with 1175 additions and 117 deletions
  1. 5 1
      common/common-entity/sql记录
  2. 22 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/login/BaseLoginLogDO.java
  3. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java
  4. 27 58
      common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java
  5. 0 1
      server/svr-authentication/pom.xml
  6. 50 12
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  7. 10 10
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  8. 895 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/ImUtil.java
  9. 63 9
      server/svr-authentication/src/main/resources/application.yml
  10. 11 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java
  11. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  12. 34 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java
  13. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceService.java
  14. 4 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  15. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  16. 5 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  17. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java
  18. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  19. 6 4
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  20. 3 2
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java

+ 5 - 1
common/common-entity/sql记录

@ -1159,9 +1159,13 @@ CREATE TABLE `base_getui_client` (
  UNIQUE KEY `index_1` (`user`,`type`,`client_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='个推clientid表';
-- 2021-07-21 ysj
ALTER table base.base_login_log add column name varchar(50) DEFAULT NULL COMMENT '用户姓名';
ALTER table base.base_login_log add column client_type varchar(10) DEFAULT NULL COMMENT '客服端类型app,wx,pad,pc';
-- 2021-7-22 lb
alter table base_life_care_item_dict add column pad_icon_img varchar(255) DEFAULT NULL COMMENT 'pad图标'

+ 22 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/login/BaseLoginLogDO.java

@ -20,6 +20,10 @@ public class BaseLoginLogDO extends UuidIdentityEntity implements java.io.Serial
	private String openid;//微信openid
	private String loginType;
	private Date operateTime;
	private String name;//用户姓名
	private String clientType;//客服端类型app,wx,pad,pc
	@Column(name="operate_time")
	public Date getOperateTime() {
		return operateTime;
@ -74,4 +78,22 @@ public class BaseLoginLogDO extends UuidIdentityEntity implements java.io.Serial
	public void setLoginType(String loginType) {
		this.loginType = loginType;
	}
	@Column(name="name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name="client_type")
	public String getClientType() {
		return clientType;
	}
	public void setClientType(String clientType) {
		this.clientType = clientType;
	}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java

@ -21,6 +21,7 @@ public class LifeCareItemDictDO extends UuidIdentityEntity{
    private Integer sort;//排序字段
    private Integer del;//删除标志 1正常,0删除
    private String lifeCareImg;//服务项目图片
    private String padIconImg;//pad图标
    public String getCode() {
        return code;
@ -78,4 +79,12 @@ public class LifeCareItemDictDO extends UuidIdentityEntity{
    public void setLifeCareImg(String lifeCareImg) {
        this.lifeCareImg = lifeCareImg;
    }
    public String getPadIconImg() {
        return padIconImg;
    }
    public void setPadIconImg(String padIconImg) {
        this.padIconImg = padIconImg;
    }
}

+ 27 - 58
common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java

@ -55,25 +55,14 @@ public class HealthIndexUtil {
            String value1 = values[0];
            // 餐后
            if (index % 2 == 0) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) {
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",true);
                }else {
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",false);
                }
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter));
            } else { //餐前
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",true);
                }else {
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",false);
                }
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore));
            }
            result.add(tmp);
        }
@ -89,54 +78,30 @@ public class HealthIndexUtil {
            Double maxValueSZY = HEALTH_STANDARD_SZY_MAX;
            Double minValueSZY = HEALTH_STANDARD_SZY_MIN;
            // 收缩压/舒张压校验
            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY) ) {
                tmp.put("value1",value1);
                tmp.put("indexName","收缩压");
                tmp.put("error",true);
            }else {
                tmp.put("value1",value1);
                tmp.put("indexName","收缩压");
                tmp.put("error",false);
            }
            tmp.put("value1",value1);
            tmp.put("indexName","收缩压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY));
            result.add(tmp);
            //舒张压校验
            tmp = new JSONObject();
            if (!checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)){
                tmp.put("value1",value1);
                tmp.put("indexName","舒张压");
                tmp.put("error",true);
            }else {
                tmp.put("value1",value1);
                tmp.put("indexName","舒张压");
                tmp.put("error",false);
            }
            tmp.put("value1",value1);
            tmp.put("indexName","舒张压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY));
            result.add(tmp);
            tmp = new JSONObject();
            //脉搏检验
            if (StringUtils.isNotBlank(value3)){
                if (!checkHealthIndex(NumberUtils.toDouble(value3), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN)){
                    tmp.put("value1",value1);
                    tmp.put("indexName","脉搏");
                    tmp.put("error",true);
                }else {
                    tmp.put("value1",value1);
                    tmp.put("indexName","脉搏");
                    tmp.put("error",false);
                }
                tmp.put("value1",value1);
                tmp.put("indexName","脉搏");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value3), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
                result.add(tmp);
            }
        }
        else if (type == 5) {//心率
            String value1 = values[0];//心率
            if (!checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN)){
                tmp.put("value1",value1);
                tmp.put("indexName","心率");
                tmp.put("error",true);
            }else {
                tmp.put("value1",value1);
                tmp.put("indexName","心率");
                tmp.put("error",false);
            }
            tmp.put("value1",value1);
            tmp.put("indexName","心率");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
            result.add(tmp);
        }
        return result;
@ -145,10 +110,14 @@ public class HealthIndexUtil {
    /**
     * 判断当前值是否在区间内
     */
    private boolean checkHealthIndex(Double current, Double max, Double min) {
        if (current > max || current < min || current < 0) {
            return false;
    private Integer checkHealthIndex(Double current, Double max, Double min) {
        if (current > max  ) {
            return 1;//指标过高
        }else if(current < min || current < 0) {
            return -1;//指标过低
        }
        else {//正常
            return 0;
        }
        return true;
    }
}

+ 0 - 1
server/svr-authentication/pom.xml

@ -164,7 +164,6 @@
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis-jaxrpc</artifactId>

+ 50 - 12
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -1,6 +1,7 @@
package com.yihu.jw.security.core.userdetails.jdbc;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
@ -14,6 +15,8 @@ import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang.StringUtils;
@ -101,6 +104,10 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    private WlyyPatientFamilyMemberDao familyMemberDao;
    @Autowired
    private BaseGetuiClientDao baseGetuiClientDao;
    @Autowired
    private ImUtil imUtil;
    @Value("${kick.eachOther}")
    private String kickEachOther;
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
@ -639,14 +646,14 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
     * @param clientId
     * @param padImei
     * @param loginType
     * @param username
     * @param id
     */
    public void updateInfo(String clientId,String padImei,String loginType,String username){
    public void updateInfo(String clientId,String padImei,String loginType,String id,BaseLoginLogDO baseLoginLogDO){
        int isPateint = isPatient(loginType);
        if(StringUtils.isNotBlank(padImei)){
            try {
                if(isPateint == 1){
                    this.getJdbcTemplate().update("update base_patient p set p.pad_imei = ? where p.mobile = ? or p.idcard = ?", padImei, username, username);
                    this.getJdbcTemplate().update("update base_patient p set p.pad_imei = ? where p.id = ? or p.idcard = ?", padImei, id);
                }
            }catch (Exception e){
                e.printStackTrace();
@ -654,19 +661,12 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        }
        if(StringUtils.isNotBlank(clientId)&&isPateint<3){
            try {
                List<WlyyUserDetails> users;
                if(isPateint==1){
                    users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username);
                }else{
                    users = this.getJdbcTemplate().query(DEFAULT_DOCTOR_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username);
                }
                String user = users.get(0).getId();
                List<GetuiClientDO> list = baseGetuiClientDao.findByUser(user,isPateint,clientId);
                List<GetuiClientDO> list = baseGetuiClientDao.findByUser(id,isPateint,clientId);
                if(list.size() == 0){
                    GetuiClientDO getuiClientDO = new GetuiClientDO();
                    getuiClientDO.setClientId(clientId);
                    getuiClientDO.setType(isPateint);
                    getuiClientDO.setUser(user);
                    getuiClientDO.setUser(id);
                    getuiClientDO.setCreateTime(new Date());
                    baseGetuiClientDao.save(getuiClientDO);
                }
@ -674,7 +674,45 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                e.printStackTrace();
            }
        }
        if(StringUtils.isNotBlank(baseLoginLogDO.getClientType())&&"0".equals(kickEachOther)){
            try {
                //pc管理端端推送消息
                JSONObject message = new JSONObject();
                //陈XXX登录云照护平台   登录终端:多媒体平板   2021-7-7 16:38:25
                String content = baseLoginLogDO.getName() + "登录云照护平台 登录终端:" + getClientName(baseLoginLogDO.getClientType())
                        + " " + DateUtil.dateToStrLong(baseLoginLogDO.getCreateTime());
                message.put("content",content);
                message.put("content_type",41);
                imUtil.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
    /**
     * app,wx,pad,pc
     * @param clientType
     * @return
     */
    private String getClientName(String clientType){
        String result = "";
        switch (clientType){
            case "app":
                result = "APP";
                break;
            case "wx":
                result = "微信公众号";
                break;
            case "pad":
                result = "多媒体平板";
                break;
            case "pc":
                result = "脑端";
                break;
        }
        return result;
    }
    /**

+ 10 - 10
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -264,11 +264,6 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
        String isNeedGeet= "1";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO= wlyyhospitalSysdictDao.findDictById("isNeedGeet");
        if (wlyyHospitalSysDictDO!=null){
            isNeedGeet=wlyyHospitalSysDictDO.getDictValue();
        }
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
@ -371,19 +366,24 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            userDetailsService.addFailureCount(username, 0);
        }
        //个推 clientId
        String clientId = parameters.get("getuiClientId");
        String padImei = parameters.get("padImei");
        userDetailsService.updateInfo(clientId,padImei,loginType,username);
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        String clientType = parameters.get("clientType");
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setName(wlyyUserSimple.getName());
        baseLoginLogDO.setClientType(clientType);
        baseLoginLogService.save(baseLoginLogDO);
        //个推 clientId
        String clientId = parameters.get("getuiClientId");
        String padImei = parameters.get("padImei");
        //客户端类型 app,wx,pad,pc
        userDetailsService.updateInfo(clientId,padImei,loginType,wlyyUserSimple.getId(),baseLoginLogDO);
        return getResponse(wlyyUserSimple);
    }

+ 895 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/ImUtil.java

@ -0,0 +1,895 @@
package com.yihu.jw.security.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
 * IM工具类
 * @author huangwenjie
 */
@Component
public class ImUtil {
	
	@Autowired
	private HttpClientUtil HttpClientUtil;
	
	@Value("${im.im_list_get}")
	private String im_host;
	
	
	public enum ContentType {
		plainText("信息", "1"),
		image("图片信息", "2"),
		audio("创建处方", "3"),
		article("文章信息", "4"),
		goTo("跳转信息,求组其他医生或者邀请其他医生发送的推送消息", "5"),
		topicBegin("议题开始", "6"),
		topicEnd("议题结束", "7"),
		personalCard("个人名片", "18"),
		messageForward("消息转发", "19"),
		topicInto("进入议题", "14"),
		video("视频", "12"),
		system("系统消息", "13"),
		prescriptionCheck("续方审核消息消息", "15"),
		prescriptionBloodStatus("续方咨询血糖血压咨询消息", "16"),
		prescriptionFollowupContent("续方咨询随访问卷消息", "17"),
		Rehabilitation("康复计划发送","20"),
		Reservation("转诊预约发送","21"),
		Know("已知悉","22");
		
		private String name;
		private String value;
		ContentType(String name, String value) {
			this.name = name;
			this.value = value;
		}
		
		public String getName() {
			return name;
		}
		
		public void setName(String name) {
			this.name = name;
		}
		
		public String getValue() {
			return value;
		}
		
		public void setValue(String value) {
			this.value = value;
		}
	}
	public String sendMDTSocketMessageToDoctor(String targetUserId, String message) {
		String imAddr = im_host + "api/v2/message/doctorSystemMessage";
		JSONObject params = new JSONObject();
		params.put("targetUserId", targetUserId);
		params.put("message", message);
		String response = HttpClientUtil.postBody(imAddr,params);
		return response;
	}
	public String sendPcManageMessageToPc(String clientType, String message) {
		String imAddr = im_host + "api/v2/message/cloudCarePcManageMessage";
		JSONObject params = new JSONObject();
		params.put("clientType", clientType);
		params.put("message", message);
		String response = HttpClientUtil.postBody(imAddr,params);
		return response;
	}
	public String sendPatientSystemMessage(String targetUserId, String message) {
		String imAddr = im_host + "api/v2/message/patientSystemMessage";
		JSONObject params = new JSONObject();
		params.put("targetUserId", targetUserId);
		params.put("message", message);
		String response = HttpClientUtil.postBody(imAddr,params);
		return response;
	}
	/**
	 * 发送消息
	 * @param senderId 发送者的code
	 * @param receiverId 接受者code
	 * @param contentType 消息类型 1二维码内容
	 * @param content 消息内容
	 * @return
	 */
	public String sendMessage(String senderId,String receiverId,String contentType,String content){
		String imAddr = im_host + "api/v2/message/send";
		JSONObject params = new JSONObject();
		params.put("sender_id", senderId);
		params.put("sender_name", receiverId);
		params.put("content_type", contentType);
		params.put("content", content);
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 获取医生统计数据
	 * status reply 为空值是是该医生总咨询量
	 *
	 * @param user          团队就把团队的医生合并起来用,隔开(医生编码)
	 * @param adminTeamCode
	 * @param status
	 * @param reply
	 * @return
	 */
	public String getConsultData(String user, Integer adminTeamCode, Integer status, Integer reply) {
		String imAddr = im_host + "api/v2/sessions/topics/count/reply";
		imAddr = imAddr + "?user=" + user;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (adminTeamCode != null) {
			imAddr += ("&adminTeamCode=" + adminTeamCode);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	public void updateTopics(String topicId, String jsonValue) {
		String imAddr = im_host + "api/v2/sessions/" + topicId + "/topics";
		JSONObject params = new JSONObject();
		params.put("topic_id", topicId);
		params.put("data", jsonValue);
		HttpClientUtil.putBody(imAddr, params);
	}
	
	/**
	 * 当前医生下当前团队列表接口
	 * 获取团队内医生的健康咨询状况
	 * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 *
	 * @param user          团队就把团队的医生合并起来用,隔开(医生编码)
	 * @param adminTeamCode 行政团队code
	 * @param page
	 * @param pagesize
	 * @param status
	 * @param reply
	 * @return
	 */
	public String getTeamConsultByStatus(String user, Integer adminTeamCode, Integer status, Integer reply, int page, int pagesize) {
		String imAddr = im_host + "api/v2/sessions/healthTeamTopics";
		imAddr = imAddr + "?user=" + user + "&page=" + page + "&pagesize=" + pagesize;
		if (adminTeamCode != null) {
			imAddr += ("&adminTeamCode=" + adminTeamCode);
		}
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 列表接口
	 * 获取团队内医生的健康咨询状况
	 * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 *
	 * @param user     团队就把团队的医生合并起来用,隔开(医生编码)
	 * @param page
	 * @param pagesize
	 * @param status
	 * @param reply
	 * @return
	 */
	public String getConsultByStatus(String user, Integer status, Integer reply, int page, int pagesize) {
		String imAddr = im_host + "api/v2/sessions/healthTopics";
		imAddr = imAddr + "?user=" + user + "&page=" + page + "&pagesize=" + pagesize;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 咨询列表
	 * @param user
	 * @param status status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 * @param reply
	 * @param type 1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询 10医生发起的求助
	 * @param page
	 * @param pagesize
	 * @return
	 */
	public String getConsultByStatusAndType(String user,Integer status,Integer reply,Integer type,String patientName,String startTime,String endTime,int page,int pagesize){
		String imAddr = im_host + "api/v2/sessions/topicListByType";
		imAddr = imAddr + "?user="+user + "&page=" + page + "&pagesize=" + pagesize;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		if (type != null) {
			imAddr += ("&type=" + type);
		}
		if (patientName != null) {
			imAddr += ("&patientName=" + patientName);
		}
		if (startTime != null) {
			imAddr += ("&startTime=" + startTime);
		}
		if (endTime != null) {
			imAddr += ("&endTime=" + endTime);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 咨询列表总数
	 * @param user
	 * @param status status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
	 * @param reply
	 * @param type 1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询 10医生发起的求助
	 * @return
	 */
	public String getConsultCountByStatusAndType(String user,Integer status,Integer reply,Integer type,String patientName,String startTime,String endTime){
		String imAddr = im_host + "api/v2/sessions/topicListCountByType";
		imAddr = imAddr + "?user="+user;
		if (status != null) {
			imAddr += ("&status=" + status);
		}
		if (reply != null) {
			imAddr += ("&reply=" + reply);
		}
		if (type != null) {
			imAddr += ("&type=" + type);
		}
		if (patientName != null) {
			imAddr += ("&patientName=" + patientName);
		}
		if (startTime != null) {
			imAddr += ("&startTime=" + startTime);
		}
		if (endTime != null) {
			imAddr += ("&endTime=" + endTime);
		}
		String response = HttpClientUtil.get(imAddr, "UTF-8");
		return response;
	}
	
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendImMsg(String from, String fromName, String sessionId, String contentType, String content, String businessType,String extend) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages";
		System.out.println("im地址"+imAddr);
		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("business_type", businessType);
		params.put("extend",extend);
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 更新会话状态
	 *
	 * @param sessionId 会话ID
	 * @param status    状态
	 */
	public String updateSessionStatus(String sessionId, String status) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/status?status=" + status + "&sessionId=" + sessionId;
		JSONObject params = new JSONObject();
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 更新会话状态
	 *
	 * @param sessionId 会话ID
	 * @param status    状态
	 */
	public String updateTopicEvaluate(String sessionId, String status) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/status?status=" + status + "&sessionId=" + sessionId;
		JSONObject params = new JSONObject();
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendTopicIM(String from, String fromName, String topicId, String contentType, String content, String agent) {
		String url = im_host + "api/v2/sessions/topic/" + topicId + "/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("topic_id", topicId);
		params.put("agent", agent);
		String response = HttpClientUtil.postBody(url, params);
		return response;
	}
	
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendTopicIM(String from, String fromName, String topicId, String contentType, String content, String agent,String patient_name,int patient_sex,int patient_age) {
		String url = im_host + "api/v2/sessions/topic/" + topicId + "/messages";
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("sender_name", fromName);
		params.put("patient_name", patient_name);
		params.put("patient_sex", patient_sex);
		params.put("patient_age", patient_age);
		params.put("content_type", contentType);
		params.put("content", content);
		params.put("topic_id", topicId);
		params.put("agent", agent);
		String response = HttpClientUtil.postBody(url, params);
		return response;
	}
	
	/**
	 * 发送进入im消息
	 * IM: ParticipantUpdate:'/:session_id/participant/update'
	 *
	 * @param from
	 * @param sessionId
	 * @param topicId
	 * @return
	 */
	public String sendIntoTopicIM(String from, String sessionId, String topicId, String content, String intoUser, String intoUserName) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/topics/" + topicId + "/into";
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("topic_id", topicId);
		params.put("into_user", intoUser);
		params.put("into_user_name", intoUserName);
		params.put("content", content);
		String response = HttpClientUtil.postBody(url, params);
		return response;
	}
	
	
	/**
	 * 更新会话成员(新增或删除)
	 * @param sessionId 会话id
	 * @param user 新增的成员id
	 * @param oldUserId  删除的成员id
	 */
	public String updateParticipant(String sessionId, String user,String oldUserId) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/update";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId );
		params.put("user_id", user );
		if(!StringUtils.isEmpty(oldUserId)){
			params.put("old_user_id", oldUserId);
		}
		return HttpClientUtil.postBody(imAddr, params);
	}
	/**
	 * 更新会话成员(新增或删除) 活跃成员
	 * @param sessionId 会话id
	 * @param user 新增的成员id
	 * @param oldUserId  删除的成员id
	 */
	public String updateParticipantNew(String sessionId, String user,String oldUserId) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/updateNew";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId );
		params.put("user_id", user );
		if(!StringUtils.isEmpty(oldUserId)){
			params.put("old_user_id", oldUserId);
		}
		return HttpClientUtil.postBody(imAddr, params);
	}
	
	/**
	 * 更新消息内容
	 * @param sessionId 会话id
	 * @param sessionType 会话类型
	 * @param msgId  消息id
	 * @param content  消息内容
	 */
	public String updateMessage(String sessionId, String sessionType,String msgId,String content) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages/"+ msgId +"/update";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId );
		params.put("session_type", sessionType );
		params.put("message_id", msgId );
		params.put("content", content );
		return HttpClientUtil.postBody(imAddr, params);
	}
	
	/**
	 * 结束议题
	 *
	 * @param topicId     议题ID
	 * @param endUser     结束人
	 * @param endUserName 结束人名字
	 * @param sessionId   会话ID
	 */
	public JSONObject endTopics(String sessionId, String endUser, String endUserName, String topicId) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/topics/" + topicId + "/ended";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId);
		params.put("end_user", endUser);
		params.put("end_user_name", endUserName);
		params.put("topic_id", topicId);
		String ret = HttpClientUtil.postBody(imAddr, params);
		JSONObject obj = null;
		try {
			obj = JSON.parseObject(ret);
		} catch (Exception e) {
			return null;
		}
		return obj;
	}
	
	
	/**
	 * 议题邀请人员
	 *
	 * @param user      结束人名字
	 * @param sessionId 会话ID
	 */
	public void updateTopicUser(String sessionId, String user) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participants/" + user;
		JSONObject params = new JSONObject();
		params.put("user", user + ":" + 0);
		HttpClientUtil.putBody(imAddr, params);
	}
	
	/**
	 * 创建议题
	 *
	 * @param topicId      议题ID
	 * @param topicName    议题名称
	 * @param participants 成员
	 */
	public JSONObject createTopics(String sessionId, String topicId, String topicName, JSONObject participants, JSONObject messages, String sessionType) {
		String imAddr = im_host + "api/v2/sessions/" + topicId + "/topics";
		JSONObject params = new JSONObject();
		params.put("topic_id", topicId);
		params.put("topic_name", topicName);
		params.put("participants", participants.toString());
		params.put("messages", messages.toString());
		params.put("session_id", sessionId);
		params.put("session_type", sessionType);
		String ret = HttpClientUtil.postBody(imAddr, params);
		JSONObject obj = null;
		try {
			obj = JSON.parseObject(ret);
		} catch (Exception e) {
			return null;
		}
		return obj;
	}
	
	/**
	 * 判断会话是否存在
	 */
	public Boolean sessionIsExist(String sessionId) {
		Boolean re = false;
		String url = im_host + "api/v2/sessions/isExist?session_id="+sessionId;
		JSONObject params = new JSONObject();
		String ret = HttpClientUtil.get(url, "UTF-8");
		JSONObject obj = null;
		try {
			obj = JSON.parseObject(ret);
			if(obj.getInteger("status") ==200&&sessionId.equals(obj.getString("sessionId"))){
				String sessionStatus = obj.getString("sessionId");
				if (StringUtils.isNoneBlank(sessionStatus)){
					String sessionStatusUrl = im_host + "api/v2/sessions/"+sessionId+"/status?status=0&sessionId="+sessionId;
					JSONObject object = new JSONObject();
					String rs = HttpClientUtil.postBody(sessionStatusUrl, object);
				}
				re = true;
			}
		} catch (Exception e) {
			return null;
		}
		return re;
	}
	
	/**
	 * 创建会话(system)
	 */
	public JSONObject createSession(JSONObject participants, String sessionType, String sessionName, String sessionId) {
		String imAddr = im_host + "api/v2/sessions";
		JSONObject params = new JSONObject();
		params.put("participants", participants.toString());
		params.put("session_name", sessionName);
		params.put("session_type", sessionType);
		params.put("session_id", sessionId);
		String ret = HttpClientUtil.postBody(imAddr, params);
		JSONObject obj = null;
		try {
			obj = JSON.parseObject(ret);
		} catch (Exception e) {
			return null;
		}
		return obj;
	}
	
	/**
	 * 获取会话实例的消息对象
	 *
	 * @param senderId
	 * @param senderName
	 * @param title
	 * @param description
	 * @param images
	 * @param agent
	 * @return
	 */
	public JSONObject getCreateTopicMessage(String senderId, String senderName, String title, String description, String images, String agent) {
		JSONObject messages = new JSONObject();
		messages.put("description", description);
		messages.put("title", title);
		messages.put("img", images);
		messages.put("sender_id", senderId);
		messages.put("sender_name", senderName);
		messages.put("agent", agent);
		return messages;
	}
	
	public JSONObject getTopicMessage(String topicId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
		String url = im_host
				+ "api/v2/sessions/topic/" + topicId + "/messages?topic_id=" + topicId + "&end=" + startMsgId
				+ "&start=" + (endMsgId == null ? "" : endMsgId) + "&page=" + page + "&pagesize=" + pagesize + "&user=" + uid;
		try {
			String ret = HttpClientUtil.get(url, "UTF-8");
			JSONObject obj = JSON.parseObject(ret);
			if (obj.getInteger("status") == -1) {
				throw new RuntimeException(obj.getString("message"));
			} else {
				return obj.getJSONObject("data");
			}
		} catch (Exception e) {
			return null;
		}
		
	}
	
	public JSONArray getSessionMessage(String sessionId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/messages?session_id=" + sessionId + "&user=" + uid + "&start_message_id=" + startMsgId + "&end_message_id=" + endMsgId + "&page=" + page + "&pagesize=" + pagesize;
		try {
			String ret = HttpClientUtil.get(url, "UTF-8");
			JSONArray obj = JSON.parseArray(ret);
			return obj;
		} catch (Exception e) {
			return null;
		}
	}
	
	/**
	 * 删除对应的成员信息在MUC模式中
	 *
	 * @param userId
	 * @param oldUserId
	 * @param sessionId
	 * @return
	 */
	public JSONObject deleteMucUser(String userId, String oldUserId, String sessionId) throws Exception {
		String url = im_host + "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 = JSON.parseObject(ret);
			if (obj.getInteger("status") == -1) {
				throw new RuntimeException("人员更换失败!");
			} else {
				return obj;
			}
		} catch (Exception e) {
			throw new RuntimeException("人员更换失败!");
		}
	}
	/**
	 * 删除会话人员
	 * @param sessionId
	 * @param participants
	 * @return
	 */
	public JSONObject deleteParticipants(String sessionId,String participants){
		String url  = im_host+"api/v2/sessions/"+sessionId+"/participants/"+participants;
		String rs = HttpClientUtil.doDelete(url,null,null);
		JSONObject obj = JSONObject.parseObject(rs);
		if (obj.getInteger("status")==-1){
			throw new RuntimeException("删除会话人员失败!");
		}else {
			return obj;
		}
	}
	
	
	/**
	 * 获取议题
	 *
	 * @param topicId
	 * @return
	 */
	public JSONObject getTopic(String topicId) throws Exception {
		String url = im_host + "api/v2/sessions/topics/" + topicId + "?topic_id=" + topicId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			JSONObject obj = JSON.parseObject(ret);
			if (obj.getInteger("status") == -1) {
				throw new RuntimeException("获取议题失败!");
			} else {
				return obj;
			}
		} catch (Exception e) {
			throw new RuntimeException("获取议题失败!");
		}
	}
	
	/**
	 * 获取会话成员
	 *
	 * @param sessionId
	 * @return
	 * @throws Exception
	 */
	public JSONArray getParticipants(String sessionId) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/participants?session_id=" + sessionId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			return JSON.parseArray(ret);
		} catch (Exception e) {
			throw new RuntimeException("获取会话成员!sessionId =" + sessionId);
		}
	}
	
	/**
	 * 获取会话成员
	 *
	 * @param sessionId
	 * @return
	 * @throws Exception
	 */
	public JSONArray getSessions(String sessionId) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/participants?session_id=" + sessionId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			return JSON.parseArray(ret);
		} catch (Exception e) {
			throw new RuntimeException("获取议题失败!");
		}
	}
	
	public JSONObject cleanMessageToRedis(String sessionId){
		String url = im_host + "api/v2/message/dataMessage?sessionId="+sessionId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	public JSONObject cleanMessageLastFetchTime(String sessionId,String userId){
		String url = im_host + "api/v2/message/cleanMessageLastFetchTimeToRedis?sessionId="+sessionId+"&userId="+userId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	
	/**
	 * 根据session和userid获取单个会话
	 * @param sessionId
	 * @param userId
	 * @return
	 */
	public JSONObject getSingleSessionInfo(String sessionId,String userId){
		String url = im_host + "api/v2/sessions/" + sessionId + "/session?user_id=" + userId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param to
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendIM(String from, String to, String contentType, String content) {
		String imAddr = im_host + "api/v1/chats/pm";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("from", from));
		params.add(new BasicNameValuePair("to", to));
		params.add(new BasicNameValuePair("contentType", contentType));
		params.add(new BasicNameValuePair("content", content));
		String response = HttpClientUtil.post(imAddr, params, "UTF-8");
		return response;
	}
	
	
	public static final String SESSION_TYPE_MUC = "1";
	public static final String SESSION_TYPE_P2P = "2";
	public static final String SESSION_TYPE_GROUP = "3";
	public static final String SESSION_TYPE_SYSTEM = "0";
	public static final String SESSION_TYPE_PRESCRIPTION = "8";//续方
	public static final String SESSION_TYPE_KANGFU = "18";//续方
	public static final String SESSION_TYPE_EXAMINATION = "9";//在线复诊-图文
	public static final String SESSION_TYPE_ONDOOR_NURSING = "11";//上门护理
	public static final String SESSION_TYPE_COLLABORATION_HOSPITAL = "12";///互联网医院协同门诊
	public static final String SESSION_TYPE_GUIDANCE_HOSPITAL = "14";//互联网医院居民导诊聊天
	public static final String SESSION_TYPE_GENERAL_EXPERT = "15";//全科医生发起求助专科医生的专家咨询
	public static final String SESSION_TYPE_EXAMINATION_VIDEO = "16";//在线复诊-视频
	public static final String SESSION_TYPE_MUC_VIDEO = "17";//专家-视频
	public static final String SESSION_TYPE_GUIDANCE_ASSISTANT = "18";//导诊助手
	public static final String SESSION_STATUS_PROCEEDINGS = "0";
	public static final String SESSION_STATUS_END = "1";
	public static final String SESSION_TYPE_EMERGENCY_ASSISTANCE = "20";//紧急救助
	public static final String SESSION_TYPE_DOOR_COACH = "21";//上门辅导(上门预约)
	public static final String SESSION_TYPE_SECURITY_WARN = "22";//安防咨询
	public static final String SESSION_TYPE_ONLINE = "23";//新生儿在线咨询
	public static final String SESSION_TYPE_ONLINEAged = "24";//老人在线咨询
	public static final String CONTENT_TYPE_TEXT = "1";
	
	
	/**
	 *按会话类型获取会话总数
	 * @param userid
	 * @param type
	 * @param status
	 * @return
	 */
	public Integer sessionCountByType(String userid,Integer type,Integer status){
		String url = im_host + "api/v2/sessions/sessionCountByType?user_id="+userid+"&type="+type+"&status="+status;
		String ret = HttpClientUtil.get(url,"utf-8");
		JSONObject obj = JSON.parseObject(ret);
		if(obj.getInteger("status") ==200){
			return obj.getInteger("count");
		}else{
			return 0;
		}
	}
	public Integer SessionsUnreadMessageCountByUserId(String userid){
		String url = im_host + "api/v2/sessions/unread_message_count?user_id="+userid;
//		String url = "http://ehr.yihu.com/api/v2/sessions/unread_message_count?user_id="+userid;
		String ret = HttpClientUtil.get(url,"utf-8");
		JSONObject obj = JSON.parseObject(ret);
//		if(obj.getInteger("count") ==200){
		return obj.getInteger("count");
//		}else{
//			return 0;
//		}
	}
	/**
	 *获取所有会话未读消息数。
	 * @param userid
	 * @param type
	 * @return
	 */
	public Integer SessionsUnreadMessageCount(String userid,String type){
		String url = im_host + "api/v2/sessions/unread_message_count?user_id="+userid+"&type="+type;
		String ret = HttpClientUtil.get(url,"utf-8");
		JSONObject obj = JSON.parseObject(ret);
//		if(obj.getInteger("count") ==200){
		return obj.getInteger("count");
//		}else{
//			return 0;
//		}
	}
	/**
	 *获取某个会话某个对象的未读消息数。
	 * @param
	 * @return
	 */
	public Integer UserSessionsUnreadMessageCount(String session,String userid){
		String url = im_host + "api/v2/sessions/"+session+"/unread_message_count?user_id="+userid;
		String ret = HttpClientUtil.get(url,"utf-8");
		JSONObject obj = JSON.parseObject(ret);
//		if(obj.getInteger("count") ==200){
		return obj.getInteger("count");
//		}else{
//			return 0;
//		}
	}
	/**
	 * 获取会话未读消息数量
	 * @param sessionId
	 * @param userId
	 * @return
	 */
	public JSONObject getSessionUnreadMessageCount(String sessionId, String userId) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/unread_message_count?user_id=" + userId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			return  JSONObject.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("获取会话成员!sessionId =" + sessionId);
		}
	}
	/**
	 * 获取在线人数
	 * helper 助老员,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板
	 */
	public String getOnlineCountByType(String type) {
		String url = im_host + "api/v2/sessions/getOnlineCountByType?type="+type;
		String ret = HttpClientUtil.get(url, "UTF-8");
		return ret;
	}
	/**
	 * 获取在线人数列表
	 * helper 助老员,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板
	 */
	public String getOnlineListByType(String type) {
		String url = im_host + "api/v2/sessions/getOnlineListByType?type="+type;
		String ret = HttpClientUtil.get(url, "UTF-8");
		return ret;
	}
	/**
	 * 获取在线状态
	 * helper 助老员,teacher 教师,child 幼儿,older 老人
	 * 返回 {"status":200,"data":1} data>0 说明在线 data =0 不在线
	 */
	public String findByUserIdAndType(String userId,String type) {
		String url = im_host + "api/v2/sessions/findByUserIdAndType?userId="+userId+"&type="+type;
		String ret = HttpClientUtil.get(url, "UTF-8");
		return ret;
	}
}

+ 63 - 9
server/svr-authentication/src/main/resources/application.yml

@ -54,9 +54,6 @@ fast-dfs:
    max-size: 20
    wait-time: 500
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: jwdev
@ -82,6 +79,11 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
im:
  im_list_get: http://172.26.0.105:3000/
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
@ -114,6 +116,11 @@ testPattern:
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 0
---
spring:
  profiles: jwOracleTest
@ -153,7 +160,11 @@ testPattern:
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: iottest
@ -182,7 +193,11 @@ testPattern:
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: iotyanshi
@ -210,6 +225,11 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: jwprod
@ -237,6 +257,11 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
## 心脏中心外网
spring:
@ -265,6 +290,11 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_xzzx_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
## 卫计委
spring:
@ -293,7 +323,11 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ihealth_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: iotprod
@ -320,7 +354,11 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
@ -350,7 +388,11 @@ testPattern:
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
@ -379,7 +421,11 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: hzprod
@ -410,6 +456,9 @@ testPattern:
wechat:
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://10.18.43.41:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 0
@ -439,3 +488,8 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: wjw
im:
  im_list_get: http://172.26.0.105:3000/
kick:
    ##互踢 1开通 0关闭
    eachOther: 1

+ 11 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java

@ -116,7 +116,7 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
        }
    }
    @ApiOperation("获取医生签约患者当天生日未发生")
    @ApiOperation("获取医生签约患者当天生日未发送")
    @RequestMapping(value = "getPatientByDoctor", method = RequestMethod.GET)
    public String getPatientByDoctor(){
        try {
@ -126,6 +126,16 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
        }
    }
    @ApiOperation("获取医生签约患者当天生日未发送数量")
    @RequestMapping(value = "getPatientByDoctorCount", method = RequestMethod.GET)
    public String getPatientByDoctorCount(){
        try {
            return write(200, "查询成功", "data", birthdayWishesService.getPatientByDoctorCount(getUID()));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @ApiOperation("获取生日居民列表")
    @RequestMapping(value = "getBirthdayPatientList", method = RequestMethod.GET)
    public String getBirthdayPatientList(@ApiParam(name = "patientName", value = "居民姓名")

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java

@ -204,7 +204,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
     */
    @RequestMapping(value = "/membersWithOnLineFlag", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员查询带是否在线标识")
    public ObjEnvelop getPatientFamilyMembersmembersWithOnLineFlag(@RequestParam(required = false) String patient) {
    public ObjEnvelop membersWithOnLineFlag(@RequestParam(required = false) String patient) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();

+ 34 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java

@ -197,6 +197,40 @@ public class BirthdayWishesService {
    }
    /**
     * 获取医生当天未发送生日祝福居民数量
     * @param doctor
     * @return
     */
    public Integer getPatientByDoctorCount(String doctor) throws Exception{
        //es日期格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String createTime = sdf.format(new Date()) + " 00:00:00";
        //今日推送的居民
        Set<String> sendPatients = (Set<String>) redisTemplate.opsForValue().get("birthday:wish:sendPatient");
        Date currentTime = new Date();
        SimpleDateFormat format = new SimpleDateFormat("MMdd");
        String dateString = format.format(currentTime);
        //获取当天0点
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String now = f.format(new Date());
        String sql = "SELECT p.id patient, p.`name`, " +
                "CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex," +
                "p.idcard, p.photo," +
                " CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END date " +
                "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "' " ;
        List<Map<String, Object>> patientInfos =  jdbcTemplate.queryForList(sql);
        return patientInfos.size();
    }
    /**
     * 获取医生生日列表
     */

+ 24 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceService.java

@ -1,13 +1,17 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 设备管理
@ -19,6 +23,8 @@ public class DeviceService extends BaseJpaService<Device, DeviceDao> {
	@Autowired
	private DeviceDao deviceDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
@ -35,4 +41,22 @@ public class DeviceService extends BaseJpaService<Device, DeviceDao> {
	{
		return deviceDao.findOne(Long.valueOf(id));
	}
	/**
	 * 获取用户设备绑定类型
	 * @param patient
	 * @return
	 */
	public String getPatientDeviceCategoryCode(String patient){
		if (StringUtils.isNotBlank(patient)){
			String sql = "select Distinct category_code from wlyy_patient_device where user='"+patient+"' and del=0 order by category_code asc";
			List<String> categorys = jdbcTemplate.queryForList(sql,String.class);
			if (categorys.size()>0){
				String categoryStr =  categorys.stream().map(String::valueOf).collect(Collectors.joining(","));
				return categoryStr;
			}
		}
		return "0";
	}
}

+ 4 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -57,6 +58,8 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private BaseDoorCoachOrderDao baseDoorCoachOrderDao;
    @Autowired
    private ImService imService;
    @Autowired
    private DeviceService deviceService;
    /**
     * 获取医生详情
@ -364,17 +367,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            }else {
                map.put("age", null);
            }
            if (map.get("deviceType")!=null){
                if ("1,2".equals(map.get("deviceType").toString())){
                    map.put("deviceType",3);//deviceType 设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                }
                else {
                    map.put("deviceType",Integer.valueOf(map.get("deviceType").toString()));
                }
            }
            else {
                map.put("deviceType",0);
            }
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -494,7 +494,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                }
                obj.put("state", "1");//0 :未处理;1:已同意;2:已拒绝
                String archive_type = null;
                Integer oneLineFlag =0;
                Integer onLineFlag =0;
                switch (map.get("archive_type").toString()){
                    case "1":
                        archive_type = "older";//老人
@ -508,11 +508,11 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                    JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
                    if (200 == oneLineObj.getInteger("status")){
                        if (oneLineObj.getInteger("data")>0){
                            oneLineFlag=1;
                            onLineFlag=1;
                        }
                    }
                }
                obj.put("oneLineFlag", oneLineFlag);
                obj.put("onLineFlag", onLineFlag);
                resultArray.add(obj);
            }
        }

+ 5 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.label;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -24,6 +25,8 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private DictService dictService;
    @Autowired
    private DeviceService deviceService;
    /**
     * 按团队查找签约居民的标签统计
@ -58,7 +61,7 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findSignPatientLabelListByTeamCode(String teamCode, String labelCode, String name, int page, int size){
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex " ;
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei " ;
        String countSql = "SELECT count(DISTINCT p.id) ";
        String filters = "from base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_patient p,wlyy_patient_label l " +
@ -74,6 +77,7 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
        for (Map<String,Object> map : list){
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -95,7 +95,7 @@ public class PatientMessageService {
     */
    public List<Map<String,Object>> getSystemMessageList(String patient,String type,String isRead){
        String typeIn = " '"+type.replace(",","','")+"' ";
        String sql = " select id,title,type,relation_code,sender,sender_name,is_read,code,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,data " +
        String sql = " select id,title,type,relation_code,sender,content,sender_name,is_read,code,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,data " +
                "from base_system_message where receiver = '"+patient+"' and del=1 and type in ("+typeIn+" )  " ;
        if (StringUtils.isNotBlank(isRead)){
            if ("1".equals(isRead)){

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -524,7 +524,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as oneLineFlag\n" +
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.service_package_id in (\n" +
                "SELECT spc.service_package_id FROM base_service_package_record spc ,base_service_package_sign_record spsr\n" +
@ -541,7 +541,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                    String doctorCode = tmp.get("doctor").toString();
                    if (oneLineInfo.containsKey(doctorCode)){
                        if (oneLineInfo.getInteger(doctorCode)>0){
                            tmp.put("oneLineFlag",1);
                            tmp.put("onLineFlag",1);
                        }
                    }
                }

+ 6 - 4
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -382,7 +382,6 @@ public class DeviceService {
                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty));
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    systemMessageDao.save(messageDO);
                    //推送socket
                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                    message.put("title","您刚刚测量了一次心率");
@ -394,7 +393,7 @@ public class DeviceService {
                    String content_notice = null;
                    for (int i=0;i<errorIndex.size();i++){
                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i);
                        if (tmp.getBooleanValue("error")){
                        if (1 == tmp.getInteger("error")){
                            content_notice += tmp.getString("indexName"+"、");
                        }
                    }
@ -402,6 +401,8 @@ public class DeviceService {
                        content_notice.substring(0,content_notice.length()-2);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    }
                    messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
@ -465,7 +466,6 @@ public class DeviceService {
                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty));
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    systemMessageDao.save(messageDO);
                    //推送socket
                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                    message.put("title","您刚刚测量了一次血压");
@ -477,7 +477,7 @@ public class DeviceService {
                    String content_notice = null;
                    for (int i=0;i<errorIndex.size();i++){
                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i);
                        if (tmp.getBooleanValue("error")){
                        if (1 == tmp.getInteger("error")){
                            content_notice += tmp.getString("indexName"+"、");
                        }
                    }
@ -485,6 +485,8 @@ public class DeviceService {
                        content_notice.substring(0,content_notice.length()-2);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    }
                    messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
            }

+ 3 - 2
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java

@ -149,7 +149,6 @@ public class DeviceUploadService {
                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty));
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    systemMessageDao.save(messageDO);
                    //推送socket
                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                    message.put("title",typeName2);
@ -161,7 +160,7 @@ public class DeviceUploadService {
                    String content_notice = null;
                    for (int i=0;i<errorIndex.size();i++){
                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i);
                        if (tmp.getBooleanValue("error")){
                        if (1 == tmp.getInteger("error")){
                            content_notice += tmp.getString("indexName"+"、");
                        }
                    }
@ -169,6 +168,8 @@ public class DeviceUploadService {
                        content_notice.substring(0,content_notice.length()-2);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    }
                    messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
            }