Browse Source

合并代码

LiTaohong 6 years ago
parent
commit
1acaadc59b

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -203,6 +203,7 @@ public class BaseRequestMapping {
        public static final String GET_TREE  = "/getTree";
        public static final String FIND_ALL  = "/findAll";
        public static final String findRoleMenuTree  = "/findRoleMenuTree";
        public static final String findLoginRoleMenuTree  = "/findLoginRoleMenuTree";
    }
    /**

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -87,6 +87,7 @@ public class SpecialistMapping {
        public static final String planListByPatient = "/planListByPatient";
        public static final String patientCount = "/patientCount";
        public static final String selectByIds = "/selectByIds";
        public static final String sendToFamilyDoctor = "/sendToFamilyDoctor";
    }
    public static class serviceItem{

+ 115 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxWechatVO.java

@ -22,6 +22,41 @@ public class WxWechatVO {
    private Integer status;
    @ApiModelProperty(value = "对接类型")
    private Integer publicType;
    @ApiModelProperty(value = "token")
    private String token;//token
    @ApiModelProperty(value = "加密密钥")
    private String encodingAesKey;//加密密钥
    @ApiModelProperty(value = "加密方式  0:明文模式   1:兼容模式   2:安全模式")
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    @ApiModelProperty(value = "1:服务号 2 订阅号")
    private String type;//'1:服务号 2 订阅号
    @ApiModelProperty(value = "微信app_id")
    private String appId;//'微信app_id'
    @ApiModelProperty(value = "微信app_secret")
    private String appSecret;//'微信app_secret'
    @ApiModelProperty(value = "原始ID")
    private String appOriginId;//原始ID
    @ApiModelProperty(value = "微信base_url")
    private String baseUrl;//'微信base_url'
    @ApiModelProperty(value = "公总号登录账户")
    private String userName;//公总号登录账户
    @ApiModelProperty(value = "用户密码")
    private String password;//用户密码
    //创建时间
    protected Date createTime;
    //创建者
    protected String createUser;
    //创建者
    protected String createUserName;
    //更新时间
    protected Date updateTime;
    //更新者
    protected String updateUser;
    //更新者
    protected String updateUserName;
    @ApiModelProperty(value = "租户")
    private List<WxSaasVO> saas;
@ -72,4 +107,84 @@ public class WxWechatVO {
    public void setSaas(List<WxSaasVO> saas) {
        this.saas = saas;
    }
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public String getEncodingAesKey() {
        return encodingAesKey;
    }
    public void setEncodingAesKey(String encodingAesKey) {
        this.encodingAesKey = encodingAesKey;
    }
    public Integer getEncType() {
        return encType;
    }
    public void setEncType(Integer encType) {
        this.encType = encType;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    public String getAppOriginId() {
        return appOriginId;
    }
    public void setAppOriginId(String appOriginId) {
        this.appOriginId = appOriginId;
    }
    public String getBaseUrl() {
        return baseUrl;
    }
    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
}

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

@ -112,4 +112,25 @@
    </dependencies>
    <build>
        <finalName>svr-authentication</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.yihu.AuthServer</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

+ 29 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/role/MenuEndpoint.java

@ -280,4 +280,33 @@ public class MenuEndpoint extends EnvelopRestEndpoint {
        }
        return false;
    }
    @GetMapping(value = BaseRequestMapping.Menu.findLoginRoleMenuTree)
    @ApiOperation(value = "获取角色登录菜单")
    public ListEnvelop<MenuVO> findLoginRoleMenuTree (
            @ApiParam(name = "roleId", value = "角色id")
            @RequestParam(value = "roleId", required = false)String roleId) throws Exception {
        List<MenuVO> menuVOs = roleMenuService.findMenuByRoleId(roleId);
        menuVOs.forEach(menuVO -> {
            if(CommonContant.DEFAULT_PARENTID.equals(menuVO.getParentId())){
                menuVO.setParentName(CommonContant.DEFAULT_PARENTNAME);
            }else {
                MenuDO menuDO = menuService.findOne(menuVO.getParentId());
                menuVO.setParentName(menuDO.getName());
            }
        });
        Map<String,List<MenuVO>> map = menuVOs.stream().collect(Collectors.groupingBy(MenuVO::getParentId));
        menuVOs.forEach(menu->{
            List<MenuVO> tmp = map.get(menu.getId());
            menu.setChildren(tmp);
        });
        menuVOs = menuVOs.stream()
                .filter(menu -> CommonContant.DEFAULT_PARENTID.equals(menu.getParentId()))
                .collect(Collectors.toList());
        return success(menuVOs);
    }
}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/role/RoleEndpoint.java

@ -53,11 +53,11 @@ public class RoleEndpoint extends EnvelopRestEndpoint {
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.Module.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Module.UPDATE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "实体json", required = true)
            @RequestParam(value = "jsonData") String jsonData) throws Exception {
        RoleDO roleDO = toEntity(jsonData, RoleDO.class);
        if (null == roleDO.getId()) {
            return failed("ID不能为空", Envelop.class);

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/role/RoleMenuService.java

@ -2,8 +2,11 @@ package com.yihu.jw.base.service.role;
import com.yihu.jw.base.dao.role.RoleMenuDao;
import com.yihu.jw.entity.base.role.RoleMenuDO;
import com.yihu.jw.restmodel.base.role.MenuVO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@ -17,8 +20,30 @@ public class RoleMenuService extends BaseJpaService<RoleMenuDO, RoleMenuDao> {
    @Autowired
    private RoleMenuDao roleMenuDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<RoleMenuDO> findRoleMenu(String roleId){
        return roleMenuDao.findByRoleId(roleId);
    }
    public List<MenuVO> findMenuByRoleId(String roleId){
        String sql ="SELECT " +
                " m.id, " +
                " m.parent_id AS parentId, " +
                " m.name, " +
                " m.sort, " +
                " m.url, " +
                " m.`status`," +
                " m.icon" +
                " FROM " +
                " base_menu m " +
                " JOIN base_role_menu r ON m.id = r.menu_id " +
                " WHERE " +
                " r.role_id = '"+roleId+"' " +
                " AND STATUS =1";
        List<MenuVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(MenuVO.class));
        return list;
    }
}

+ 61 - 40
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -1,23 +1,10 @@
package com.yihu.jw.base.service.user;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.role.BaseRoleMenuDao;
import com.yihu.jw.base.dao.role.RoleDao;
import com.yihu.jw.base.dao.saas.SaasDao;
import com.yihu.jw.base.dao.user.UserDao;
import com.yihu.jw.base.service.org.BaseOrgSaasService;
import com.yihu.jw.base.service.org.BaseOrgUserService;
import com.yihu.jw.base.service.org.OrgTree;
import com.yihu.jw.base.service.org.OrgTreeService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.org.BaseOrgUserDO;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.user.UserDO;
@ -25,16 +12,13 @@ import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Service - 后台管理员
@ -136,6 +120,18 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        return userDao.existsByMobile(mobile);
    }
    /**
     * 判断用户名是否存在
     * @param username
     * @return
     */
    public Boolean existUserName(String username){
        if(StringUtils.isEmpty(username)) {
            return null;
        }
        return userDao.existsByUsername(username);
    }
    /**
     * 用户管理,获取用户基本信息列表
     *
@ -154,17 +150,29 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        Map<String, Object> userinfo = new HashedMap();
        UserDO user = userDao.findOne(id);
        RoleDO role = roleDao.findByCode(user.getRoleCode());
        userinfo.put("id", user.getId());
        userinfo.put("name", user.getName());
        userinfo.put("role", role.getName());
        userinfo.put("roleCode", role.getCode());
        userinfo.put("system", role.getSystem());
        if(user!=null){
            userinfo.put("id",user.getId());
            userinfo.put("name",user.getName());
        }
        //获取角色
        RoleDO role = roleDao.findOne(user.getRoleCode());
        if(role!=null){
            userinfo.put("role",role.getId());
            userinfo.put("roleCode",role.getCode());
            userinfo.put("system",role.getSystem());
        if ("admin".equals(role.getCode())) {
            if("admin".equals(role.getCode())){
        } else if ("saasAdmin".equals(role.getCode())) {
            }else if("saasAdmin".equals(role.getCode())){
            if (org.apache.commons.lang3.StringUtils.isNotBlank(user.getId())) {
                SaasDO saas = saasDao.findOne(user.getSaasId());
@ -173,28 +181,41 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                ss.put("name", saas.getName());
                userinfo.put("saas", ss);
            }
                if(org.apache.commons.lang3.StringUtils.isNotBlank(user.getId())){
                    SaasDO saas = saasDao.findOne(user.getSaasId());
                    Map<String,Object> ss = new HashedMap();
                    ss.put("id",saas.getId());
                    ss.put("name",saas.getName());
                    userinfo.put("saas",ss);
                }
        } else if ("hosAdmin".equals(role.getCode())) {
            String sql = "SELECT " +
                    " g.code AS orgCode, " +
                    " g.province_code AS provinceCode, " +
                    " g.province_name AS privinceName, " +
                    " g.city_code AS cityCode, " +
                    " g.city_name AS cityName, " +
                    " g.town_code AS townCode, " +
                    " g.town_name AS townName, " +
                    " g.street_code AS streetCode, " +
                    " g.street_name AS streetName, " +
                    " g.name, " +
                    " address " +
                    " FROM " +
                    " base_org g " +
                    " JOIN base_org_user u ON g.`code` = u.org_code " +
                    " WHERE  " +
                    " u.user_id = '" + id + "'";
            List<Map<String, Object>> org = jdbcTemplate.queryForList(sql);
            userinfo.put("org", org.get(0));
            }else if("hosAdmin".equals(role.getCode())){
                String sql = "SELECT " +
                        " g.code AS orgCode, " +
                        " g.province_code AS provinceCode, " +
                        " g.province_name AS privinceName, " +
                        " g.city_code AS cityCode, " +
                        " g.city_name AS cityName, " +
                        " g.town_code AS townCode, " +
                        " g.town_name AS townName, " +
                        " g.street_code AS streetCode, " +
                        " g.street_name AS streetName, " +
                        " g.name, " +
                        " address " +
                        " FROM " +
                        " base_org g " +
                        " JOIN base_org_user u ON g.`code` = u.org_code " +
                        " WHERE  " +
                        " u.user_id = '"+id+"'";
                List<Map<String,Object>> org = jdbcTemplate.queryForList(sql);
                if(org!=null&&org.size()>0){
                    userinfo.put("org",org.get(0));
                }else{
                    userinfo.put("org",null);
                }
            }
        }
        return userinfo;

+ 16 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -64,7 +64,22 @@ public class WechatService {
                " w.`status`, " +
                " w.type, " +
                " w.public_type AS publicType," +
                " w.remark " +
                " w.token," +
                " w.encType," +
                " w.type," +
                " w.appId," +
                " w.appSecret," +
                " w.appOriginId," +
                " w.baseUrl," +
                " w.userName," +
                " w.password," +
                " w.remark," +
                " w.createTime," +
                " w.createUser," +
                " w.createUserName," +
                " w.updateTime," +
                " w.updateUser," +
                " w.updateUserName" +
                " FROM " +
                " wx_wechat w ";
        if (StringUtils.isNotBlank(saasName)) {

+ 25 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java

@ -18,6 +18,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.service.rehabilitation.RehabilitationPlanService;
import com.yihu.jw.util.DataUtils;
import com.yihu.jw.util.ImUtill;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -46,6 +47,8 @@ public class RehabilitationPlanController extends EnvelopRestEndpoint {
    private Tracer tracer;
    @Autowired
    private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao;
    @Autowired
    private ImUtill imUtill;
    @PostMapping(value = SpecialistMapping.rehabilitation.createRehabilitationPlanTemplate)
    @ApiOperation(value = "康复服务套餐模板创建")
@ -274,4 +277,26 @@ public class RehabilitationPlanController extends EnvelopRestEndpoint {
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.sendToFamilyDoctor)
    @ApiOperation(value = "给家医发送居民的康复计划")
    public Envelop sendBusinessCard(@ApiParam(name = "doctorCode", value = "专医code")
                                   @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                   @ApiParam(name = "doctorName", value = "专医名字")
                                   @RequestParam(value = "doctorName", required = true) String doctorName,
                                   @ApiParam(name = "sessionId", value = "会话id", defaultValue = "")
                                   @RequestParam(value = "sessionId", required = true) String sessionId,
                                   @ApiParam(name = "businessType", value = "businessType", defaultValue = "1")
                                   @RequestParam(value = "businessType", required = true) String businessType,
                                   @ApiParam(name = "contentJsonStr", value = "contentJsonStr")
                                   @RequestParam(value = "contentJsonStr", required = true) String contentJsonStr){
        try {
            imUtill.sendImMsg(doctorCode,doctorName,sessionId,ImUtill.ContentType.Rehabilitation.getValue(),contentJsonStr,businessType);
            return Envelop.getSuccess(SpecialistMapping.api_success);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 71 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/HttpClientUtil.java

@ -1,11 +1,21 @@
package com.yihu.jw.util;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
/**
 * Created by hmf on 2018/9/3.
 */
@ -22,4 +32,65 @@ public class HttpClientUtil {
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
    public  String postBody(String url, org.json.JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
    public  void putBody(String url, org.json.JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        restTemplate.put(url, formEntity, String.class);
    }
    /**
     * 发送get请求
     *
     * @param url     请求地址
     * @param chatSet 编码格式
     * @return
     */
    public  String get(String url, String chatSet) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            HttpGet httpget = new HttpGet(url);
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                // 获取响应实体
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

+ 574 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/ImUtill.java

@ -0,0 +1,574 @@
package com.yihu.jw.util;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
 * Created by 卓 on 2017/1/13.
 */
@Component
public class ImUtill {
    @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");
        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;
        }
    }
    /**
     * 发送消息
     * @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 imAddr = im_host + "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("business_type", businessType);
        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 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 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 = new JSONObject(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 = new JSONObject(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 = new JSONObject(ret);
            if(obj.getInt("status")==200&&sessionId.equals(obj.getString("sessionId"))){
                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 = new JSONObject(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 = new JSONObject(ret);
            if (obj.getInt("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 = new JSONArray(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 = new JSONObject(ret);
            if (obj.getInt("status") == -1) {
                throw new RuntimeException("人员更换失败!");
            } else {
                return obj;
            }
        } catch (Exception e) {
            throw new RuntimeException("人员更换失败!");
        }
    }
    /**
     * 获取议题
     *
     * @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 = new JSONObject(ret);
            if (obj.getInt("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 new JSONArray(ret);
        } catch (Exception e) {
            throw new RuntimeException("获取议题失败!");
        }
    }
    /**
     * 获取会话成员
     *
     * @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 new JSONArray(ret);
        } catch (Exception e) {
            throw new RuntimeException("获取议题失败!");
        }
    }
    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_STATUS_PROCEEDINGS = "0";
    public static final String SESSION_STATUS_END = "1";
    public static final String CONTENT_TYPE_TEXT = "1";
}

+ 18 - 0
svr/svr-wlyy-specialist/src/main/resources/application.yml

@ -96,6 +96,11 @@ wechat:
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
im:
  im_list_get: http://172.19.103.88:3000/
  #im_list_get: http://192.168.131.24:3000/
  data_base_name: ichat
---
spring:
  profiles: jwtest
@ -124,6 +129,11 @@ wechat:
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fehr.yihu.com%2fwlyy
  accId: gh_ffd64560fb21
im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
---
spring:
  profiles: jwdevtest
@ -152,6 +162,10 @@ wechat:
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fehr.yihu.com%2fwlyy
  accId: gh_ffd64560fb21
im:
  im_list_get: http://172.19.103.88:3000/
  data_base_name: im_new
---
spring:
  profiles: prod
@ -179,3 +193,7 @@ wechat:
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fwlyy
  accId: gh_ffd64560fb21
im:
  im_list_get: http://27.155.101.77:3000/
  data_base_name: im