Pārlūkot izejas kodu

Merge branch 'dev' of lyr/patient-co-management into dev

lyr 8 gadi atpakaļ
vecāks
revīzija
7962613312

+ 8 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -40,6 +40,14 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.id < ?2 and a.del = '1' and b.del = '1' ")
	Page<ConsultTeam> findDoctorList(String doctor, long id, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?2 and b.to = ?1 and a.del = '1' and b.del = '1' ")
	Page<ConsultTeam> findDoctorPatientList(String doctor,String patient,  Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?2 and b.to = ?1 and a.id < ?3 and a.del = '1' and b.del = '1' ")
	Page<ConsultTeam> findDoctorPatientList(String doctor,String patient, long id, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.status = 0 and a.del = '1' and b.del = '1' and a.type<3 ")
	Page<ConsultTeam> findDoctorPointList(String doctor, Pageable pageRequest);

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

@ -34,6 +34,7 @@ import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.poi.hssf.util.HSSFColor;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -142,7 +143,7 @@ public class ConsultTeamService extends ConsultService {
     * @param pagesize 每页显示数,默认为10
     * @return
     */
    public Page<ConsultTeam> findByDoctor(String uid, int type, long id, int pagesize, String title) {
    public Page<ConsultTeam> findByDoctor(String uid, int type, long id, int pagesize, String patient, String title) {
        if (id < 0) {
            id = 0;
        }
@ -152,7 +153,7 @@ public class ConsultTeamService extends ConsultService {
        switch (type) {
            case 0:
                // 全部
                return findByDoctorType0(uid, id, pagesize);
                return findByDoctorType0(uid, id, patient, pagesize);
            case 1:
                // 咨询我的
                return findByDoctorType1(uid, type, id, pagesize);
@ -390,15 +391,23 @@ public class ConsultTeamService extends ConsultService {
     * @param pagesize
     * @return
     */
    public Page<ConsultTeam> findByDoctorType0(String uid, long id, int pagesize) {
    public Page<ConsultTeam> findByDoctorType0(String uid, long id, String patient, int pagesize) {
        // 排序
        Sort sort = new Sort(Direction.DESC, "id");
        // 分页信息
        PageRequest pageRequest = new PageRequest(0, pagesize, sort);
        if (id > 0) {
            return consultTeamDao.findDoctorList(uid, id, pageRequest);
        if (StringUtils.isEmpty(patient)) {
            if (id > 0) {
                return consultTeamDao.findDoctorList(uid, id, pageRequest);
            } else {
                return consultTeamDao.findDoctorList(uid, pageRequest);
            }
        } else {
            return consultTeamDao.findDoctorList(uid, pageRequest);
            if (id > 0) {
                return consultTeamDao.findDoctorPatientList(uid, patient, id, pageRequest);
            } else {
                return consultTeamDao.findDoctorPatientList(uid, patient, pageRequest);
            }
        }
    }
@ -543,17 +552,17 @@ public class ConsultTeamService extends ConsultService {
     * @param logs
     * @return
     */
    public void reply(List<ConsultTeamLog> logs, String patient) throws Exception{
        ConsultTeam consultTeam=consultTeamDao.findByConsult(logs.get(0).getConsult());
        WlyyTalkGroup wlyyTalkGroup=talkGroupService.findConsultTalkGroupByType(logs.get(0).getConsult(),2);
    public void reply(List<ConsultTeamLog> logs, String patient) throws Exception {
        ConsultTeam consultTeam = consultTeamDao.findByConsult(logs.get(0).getConsult());
        WlyyTalkGroup wlyyTalkGroup = talkGroupService.findConsultTalkGroupByType(logs.get(0).getConsult(), 2);
        for (ConsultTeamLog log : logs) {
            reply(log, patient, null, log.getType());
            //判断当前咨询是否创建讨论租
            if(wlyyTalkGroup!=null){
                sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType()+"", log.getContent());
            }else{
            if (wlyyTalkGroup != null) {
                sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType() + "", log.getContent());
            } else {
                //推送给IM
                sendIM(patient, consultTeam.getDoctor(), log.getChatType()+"", log.getContent());
                sendIM(patient, consultTeam.getDoctor(), log.getChatType() + "", log.getContent());
            }
        }
    }
@ -689,9 +698,9 @@ public class ConsultTeamService extends ConsultService {
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM文字消息
        String returnJson= sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        JSONObject jo=new JSONObject(returnJson);
        if(jo.has("startId")){
        String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        JSONObject jo = new JSONObject(returnJson);
        if (jo.has("startId")) {
            //设置消息ID
            ct.setStartMsgId(jo.getInt("startId"));
            //推送给IM图片
@ -713,10 +722,11 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 发送消息给IM
     * @param from 来自
     *
     * @param from        来自
     * @param to
     * @param contentType 1文字 2图片消息
     * @param content 内容
     * @param content     内容
     */
    private String sendIM(String from, String to, String contentType, String content) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/pm";
@ -728,24 +738,27 @@ public class ConsultTeamService extends ConsultService {
        String response = HttpClientUtil.post(imAddr, params, "UTF-8");
        return response;
    }
    /**
     * 发送消息给IM
     * @param from 来自
     *
     * @param from        来自
     * @param groupCode
     * @param contentType 1文字 2图片消息
     * @param content 内容
     * @param content     内容
     */
    private String sendGroupIM(String from, String groupCode, String contentType, String content) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/gm";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("from", from));
        params.add(new BasicNameValuePair("group", groupCode));
        params.add(new BasicNameValuePair("groupType","1"));
        params.add(new BasicNameValuePair("groupType", "1"));
        params.add(new BasicNameValuePair("contentType", contentType));
        params.add(new BasicNameValuePair("content", content));
        String response = HttpClientUtil.post(imAddr, params, "UTF-8");
        return response;
    }
    /**
     * 添加三师咨询日志
     *
@ -882,10 +895,11 @@ public class ConsultTeamService extends ConsultService {
     */
    public int finish(String consult) {
        ConsultTeam consultTeam=consultTeamDao.findByConsult(consult);
        ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
        //推送给IM文字消息
        String returnJson=  sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", "本次咨询结束");;
        JSONObject jo=new JSONObject(returnJson);
        String returnJson = sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", "本次咨询结束");
        ;
        JSONObject jo = new JSONObject(returnJson);
        //设置消息ID
        consultTeam.setEndMsgId(jo.getInt("startId"));
        return consultTeamDao.updateStatusByConsult(consult);
@ -899,7 +913,7 @@ public class ConsultTeamService extends ConsultService {
     */
    @Transactional
    public int readMessage(String consult) {
        ConsultTeam consultTeam=consultTeamDao.findByConsult(consult);
        ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
        consultTeam.setDoctorRead(0);
        return 1;
    }
@ -1130,10 +1144,11 @@ public class ConsultTeamService extends ConsultService {
        cd.setCzrq(new Date());
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content=addLogs(ct);
        String content = addLogs(ct);
        //推送给IM文字消息
        String returnJson=  sendIM(ct.getPatient(), ct.getDoctor(), "6", content);;
        JSONObject jo=new JSONObject(returnJson);
        String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        ;
        JSONObject jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(jo.getInt("startId"));
        //推送给IM图片

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

@ -82,7 +82,7 @@ public class DoctorConsultController extends WeixinBaseController {
                       @RequestParam(required = false) String patient,
                       @RequestParam(required = false) String title) {
        try {
            Page<ConsultTeam> list = consultTeamService.findByDoctor(getUID(), type, id, pagesize, title);
            Page<ConsultTeam> list = consultTeamService.findByDoctor(getUID(), type, id, pagesize,patient, title);
            JSONArray jsonArray = new JSONArray();
            if(list != null) {
                for (ConsultTeam consult : list) {