Bläddra i källkod

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

lyr 8 år sedan
förälder
incheckning
9d7d4387eb

+ 63 - 50
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -700,8 +700,58 @@ public class ConsultController extends WeixinBaseController {
                return error(-1, "咨询记录不存在!");
            }
            List<JSONObject> jsonArray = new ArrayList<>();
            JSONObject group = talkGroupService.findConsultTalkGroup(consultModel.getConsult());
            if (group != null) {
                String urlG = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                        + "api/v1/chats/gm";
                String reG = HttpUtil.sendGet(urlG, "user_id=" + getUID() + "&group_id=" + group.getString("code"));
                JSONObject resultG = null;
                if (!org.springframework.util.StringUtils.isEmpty(reG)) {
                    resultG = new JSONObject(new String(reG.getBytes(), "utf-8"));
                }
                if (resultG != null && resultG.getInt("count") > 0) {
                    JSONArray list = resultG.getJSONArray("records");
                    for (int i = 0; i < list.length(); i++) {
                        JSONObject obj = list.getJSONObject(i);
                        if (obj.getInt("contentType") == 5 || obj.getInt("contentType") == 6) {
                            continue;
                        }
                        JSONObject json = new JSONObject();
                        json.put("id", obj.getInt("id"));
                        if (!obj.getString("from").equals(getUID())) {
                            Doctor doc = doctorService.findDoctorByCode(obj.getString("from"));
                            // 设置回复医生姓名
                            json.put("doctorName", doc.getName());
                        } else {
                            Patient p = patientDao.findByCode(obj.getString("from"));
                            // 设置回复医生姓名
                            json.put("doctorName", p.getName());
                        }
                        // 设置回复内容
                        json.put("content", obj.getString("content"));
                        // 设置咨询或回复时间
                        json.put("time", DateUtil.dateToStr(new Date(obj.getLong("timestamp")), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        // 设置记录类型:1文字,2图片,3语音
                        json.put("msgType", obj.getInt("contentType") == 2 ? 2 : 1);
                        // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
                        if (!obj.getString("from").equals(getUID())) {
                            json.put("type", 1);
                        } else {
                            json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
                        }
                        jsonArray.add(json);
                    }
                }
            }
            JSONObject result = null;
            JSONArray jsonArray = new JSONArray();
            String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                    + "api/v1/chats/pm";
            String re = HttpUtil.sendGet(url, "closed_interval=true&user_id=" + getUID() + "&peer_id=" + consultModel.getDoctor()
@ -745,62 +795,25 @@ public class ConsultController extends WeixinBaseController {
                    } else {
                        json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
                    }
                    jsonArray.put(json);
                    jsonArray.add(json);
                }
            }
            JSONObject group = talkGroupService.findConsultTalkGroup(consultModel.getConsult());
            if (group != null) {
                String urlG = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                        + "api/v1/chats/gm";
                String reG = HttpUtil.sendGet(url, "user_id=" + getUID() + "&group_id=" + group.getString("code"));
                JSONObject resultG = null;
                if (!org.springframework.util.StringUtils.isEmpty(re)) {
                    result = new JSONObject(new String(re.getBytes(), "utf-8"));
                }
                if (result != null && result.getInt("count") > 0) {
                    JSONArray list = result.getJSONArray("records");
                    for (int i = 0; i < list.length(); i++) {
                        JSONObject obj = list.getJSONObject(i);
                        if (obj.getInt("contentType") == 5 || obj.getInt("contentType") == 6) {
                            continue;
                        }
                        JSONObject json = new JSONObject();
                        json.put("id", obj.getInt("id"));
                        if (!obj.getString("from").equals(getUID())) {
                            Doctor doc = doctorService.findDoctorByCode(obj.getString("from"));
                            // 设置回复医生姓名
                            json.put("doctorName", doc.getName());
                        } else {
                            Patient p = patientDao.findByCode(obj.getString("from"));
                            // 设置回复医生姓名
                            json.put("doctorName", p.getName());
                        }
                        // 设置回复内容
                        json.put("content", obj.getString("content"));
                        // 设置咨询或回复时间
                        json.put("time", DateUtil.dateToStr(new Date(obj.getLong("timestamp")), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        // 设置记录类型:1文字,2图片,3语音
                        json.put("msgType", obj.getInt("contentType") == 2 ? 2 : 1);
                        // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
                        if (!obj.getString("from").equals(getUID())) {
                            json.put("type", 1);
                        } else {
                            json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
                        }
                        jsonArray.put(json);
            jsonArray.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if(o1.getString("time").compareTo(o2.getString("time")) > 0){
                        return -1;
                    } else if(o1.getString("time").compareTo(o2.getString("time")) < 0) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
            }
            });
            // 返回结果
            return write(200, "查询成功", "list", jsonArray);
            return write(200, "查询成功", "list", new JSONArray(jsonArray));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");