Browse Source

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

lyr 8 years ago
parent
commit
57ffaf8c8d

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

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

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

@ -703,7 +703,7 @@ public class ConsultTeamService extends ConsultService {
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                users.put(doctorTeamMember.getMemberCode(),0);
            }else{
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                if(doctorTeamMember!=null){
@ -1492,6 +1492,7 @@ public class ConsultTeamService extends ConsultService {
        // 设置患者信息
        ct.setPatient(uid);
        Doctor doctorTemp = doctorDao.findByCode(uid);
        Doctor doctor = doctorDao.findByCode(ct.getDoctor());
        // 设置医生姓名
        ct.setName(doctorTemp.getName());
        // 设置医生生日
@ -1520,28 +1521,45 @@ public class ConsultTeamService extends ConsultService {
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content = addLogs(ct);
        JSONObject messages  = ImUtill.getCreateTopicMessage(doctorTemp.getCode(),doctorTemp.getName(),consult.getTitle(),content,consult.getImages());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        //设置消息ID
        JSONObject obj = ImUtill.createTopics(null,consult.getCode(),doctorTemp.getName(),jsonObject,messages,"2");
        if(obj==null||obj.getInt("status")==-1){
            throw new RuntimeException("im消息创建异常!"+obj==null?"":obj.getString("message"));
        }
        ct.setStartMsgId(obj.get("start_msg_id").toString());
        //转发咨询问题
        if(StringUtils.isNotBlank(oldConsultCode)){
        if(StringUtils.isBlank(oldConsultCode)) {
            JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages());
            JSONObject jsonObject = new JSONObject();
            jsonObject.put(ct.getPatient(), 0);
            jsonObject.put(ct.getDoctor(), 0);
            //设置消息ID
            JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
            if (obj == null || obj.getInt("status") == -1) {
                throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
            }
            ct.setStartMsgId(obj.get("start_msg_id").toString());
        }else{
            //转发咨询问题
            Consult oldConsult = consultDao.findByCode(oldConsultCode);
            ct.setTeam(oldConsultCode);
            if(oldConsult!=null&&isSend==1){
                ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"6",oldConsult.getSymptoms());
                if(StringUtils.isNotBlank(oldConsult.getImages())){
                    String imgs[] = oldConsult.getImages().split(",");
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), oldConsult.getSymptoms(), oldConsult.getImages());
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
                if (obj == null || obj.getInt("status") == -1) {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
                ct.setStartMsgId(obj.get("start_msg_id").toString());
                ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"6",content);
                if(StringUtils.isNotBlank(consult.getImages())){
                    String imgs[] = consult.getImages().split(",");
                    for(String url :imgs)
                        ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"2",url);
                }
            }
            JSONObject qiuzuObj = new JSONObject();
            qiuzuObj.put("session_id",oldConsult.getPatient()+"_consult_"+consult.getType());
            qiuzuObj.put("patient",ct.getPatient());
            qiuzuObj.put("old_consult_code",oldConsultCode);
            qiuzuObj.put("doctor",ct.getDoctor());
            qiuzuObj.put("doctor_name",doctor.getName());
            ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),oldConsultCode,"5",qiuzuObj.toString());
        }
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
@ -1567,7 +1585,7 @@ public class ConsultTeamService extends ConsultService {
            throw new RuntimeException("IM消息结束异常!");
        }
        if(obj.getInt("status")==-1){
            throw new RuntimeException(obj.getString("message"));
            throw new RuntimeException(String.valueOf(obj.get("message")));
        }
        consultTeam.setType(endType);
        consultTeam.setEndMsgId(obj.getString("id"));

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

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

+ 29 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -169,4 +169,33 @@ public class ImUtill {
        }
    }
    /**
     * 删除对应的成员信息在MUC模式中
     * @param userId
     * @param oldUserId
     * @param sessionId
     * @return
     */
    public static JSONObject deleteMucUser(String userId,String oldUserId,String sessionId) throws  Exception{
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "api/v2/sessions/"+sessionId+"/participant/update";
        try{
            JSONObject params = new JSONObject();
            params.put("user_id", userId);
            params.put("old_user_id", oldUserId);
            params.put("session_id", sessionId);
            String ret = HttpClientUtil.postBody(url,params);
            JSONObject obj = new JSONObject(ret);
            if(obj.getInt("status")==-1){
                throw new RuntimeException("人员更换失败!");
            }else{
                return obj;
            }
        }catch (Exception e){
           throw new RuntimeException("人员更换失败!");
        }
    }
}

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

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

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

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

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

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

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

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

+ 47 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -4,7 +4,6 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.guahao.GuahaoDoctor;
@ -58,8 +57,6 @@ public class BookingController extends WeixinBaseController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private SMSService smsService;
    /**
     * 根据城市编码获取相应挂号服务
     *
@ -76,7 +73,7 @@ public class BookingController extends WeixinBaseController {
    /**
     * 发送短信参数
     */
    private static List<NameValuePair> buildSmsParams(String content, String mobile) {
    private List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
        params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
@ -89,6 +86,24 @@ public class BookingController extends WeixinBaseController {
        return params;
    }
    private JSONObject toJson(String result) {
        JSONObject json = new JSONObject();
        try {
            String[] temps = result.split("&");
            for (String temp : temps) {
                if (temp.split("=").length != 2) {
                    continue;
                }
                String key = temp.split("=")[0];
                String value = temp.split("=")[1];
                json.put(key, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
    /**
     * 获取时间
     */
@ -357,6 +372,29 @@ public class BookingController extends WeixinBaseController {
    /****************************************** 内网预约 ***************************************************************/
/*    @RequestMapping(value = "sendMessage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("发送短信测试")
    public String sendMessage()
    {
        try {
            //发送短信消息,调用总部发送信息的接口
            String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams("测试", "13559207522"), "GBK");
            System.out.print(result);
            *//*JSONObject json = toJson(result);
            JSONObject result = smsService.sendMsg("13559207522", "测试");
            if (result != null && result.getInt("result") != 0) {
                System.out.print("短信提醒失败!(原因:" + result.getString("description") + ")");
            }*//*
            return error(-1, "创建挂号单失败!"+result);
        }
        catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }*/
    @RequestMapping(value = "CreateOrderByDoctor", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("(内网)转诊预约挂号")
@ -399,9 +437,11 @@ public class BookingController extends WeixinBaseController {
                            obj.getDeptName() + obj.getDeptName() + "医生的号源。您可直接前往医院就诊。";
                    //发送短信消息,调用总部发送信息的接口
                    JSONObject result = smsService.sendMsg(patientPhone, msg);
                    if (result != null && result.getInt("result") != 0) {
                        des = "短信提醒失败!(原因:"+result.getString("description")+")";
                    String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, patientPhone), "GBK");
                    System.out.print(result);
                    JSONObject resultJson = toJson(result);
                    if (resultJson != null && resultJson.getInt("result") != 0) {
                        des = "短信提醒失败!(原因:"+resultJson.getString("description")+")";
                    }
                    // 推送消息给微信端