Browse Source

云招呼代码-20231115

suqinyi 1 year ago
parent
commit
b990d3b40a

+ 1 - 2
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -586,8 +586,6 @@ public class ImUtil {
    }
    }
    /**
    /**
     * 判断会话是否存在
     * 判断会话是否存在
     */
     */
@ -743,6 +741,7 @@ public class ImUtil {
     */
     */
    public JSONObject getTopic(String topicId) throws Exception {
    public JSONObject getTopic(String topicId) throws Exception {
        String url = im_host + "api/v2/sessions/topics/" + topicId + "?topic_id=" + topicId;
        String url = im_host + "api/v2/sessions/topics/" + topicId + "?topic_id=" + topicId;
        System.out.println("获取议题==>地址:" + url);
        try {
        try {
            String ret = httpClientUtil.get(url, "utf-8");
            String ret = httpClientUtil.get(url, "utf-8");
            System.out.println("getTopic结果==>" + ret);
            System.out.println("getTopic结果==>" + ret);

+ 8 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/controller/ConsultController.java

@ -1,6 +1,7 @@
package com.yihu.jw.hospital.module.consult.controller;
package com.yihu.jw.hospital.module.consult.controller;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -102,10 +103,10 @@ public class ConsultController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
//    @Value("${doctorAssistant.api}")
    //    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    private String doctorAssistant;
//    @Value("${doctorAssistant.target_url}")
    //    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
    private String targetUrl;
@ -1199,12 +1200,16 @@ public class ConsultController extends EnvelopRestEndpoint {
            @RequestParam String loginUser,
            @RequestParam String loginUser,
            @RequestParam int page, @RequestParam int pagesize) {
            @RequestParam int page, @RequestParam int pagesize) {
        try {
        try {
            System.out.println("查询聊天日志");
            System.out.println("参数==>consult:" + consult + "  loginUser:" + loginUser);
            ConsultTeamDo consultModel = consultTeamService.findByCode(consult);
            ConsultTeamDo consultModel = consultTeamService.findByCode(consult);
            System.out.println("ConsultTeamDo==>" + JSON.toJSONString(consultModel));
            if (consultModel == null) {
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
                return error(-1, "咨询记录不存在!");
            }
            }
            System.out.println("调用im查询");
            com.alibaba.fastjson.JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, loginUser);
            com.alibaba.fastjson.JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, loginUser);
            System.out.println("查询完成");
            //过滤续签
            //过滤续签
//            consultTeamService.removeRenewPerson(messageObj, getRepUID());
//            consultTeamService.removeRenewPerson(messageObj, getRepUID());
            return write(200, "查询成功", "list", messageObj);
            return write(200, "查询成功", "list", messageObj);

+ 6 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultTeamService.java

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.module.consult.service;
package com.yihu.jw.hospital.module.consult.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultDo;
@ -232,7 +233,7 @@ public class ConsultTeamService extends ConsultService {
         * 创建议题
         * 创建议题
         */
         */
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        System.out.println("创建议题成功了!!!!!!!!!!!!!!!!");
        if (imResponseJson == null || imResponseJson.getString("status").equals("-1")) {
        if (imResponseJson == null || imResponseJson.getString("status").equals("-1")) {
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
            throw new Exception(failMsg);
            throw new Exception(failMsg);
@ -240,9 +241,12 @@ public class ConsultTeamService extends ConsultService {
        if (imResponseJson != null && imResponseJson.get("start_msg_id") != null) {
        if (imResponseJson != null && imResponseJson.get("start_msg_id") != null) {
            consultTeam.setStartMsgId(imResponseJson.get("start_msg_id").toString());
            consultTeam.setStartMsgId(imResponseJson.get("start_msg_id").toString());
        }
        }
        System.out.println("准备保存consultTeam和consult");
        consultTeamDao.save(consultTeam);
        consultTeamDao.save(consultTeam);
        consultDao.save(consult);
        consultDao.save(consult);
        System.out.println("保存的consultTeam==>"+ JSON.toJSONString(consultTeam));
        System.out.println("保存的consult==>"+ JSON.toJSONString(consult));
        System.out.println("保存consultTeam和consult成功");
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, consultTeam);
        result.put(ResponseContant.resultMsg, consultTeam);
        return result;
        return result;

+ 16 - 7
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/DoorOrderService.java

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.module.door.service;
package com.yihu.jw.hospital.module.door.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -411,7 +412,8 @@ public class DoorOrderService {
     * @return
     * @return
     */
     */
    public List<Map<String, Object>> getDoorFeeDetailGroupByStatus(String orderId) {
    public List<Map<String, Object>> getDoorFeeDetailGroupByStatus(String orderId) {
        String sql = "SELECT d.id, d.status,d.name,d.code,sum(d.number) num,fee,sum(d.number)*fee sum from wlyy_door_fee_detail d where order_id=? and type=1 GROUP BY status,code";
        String sql = "SELECT d.id, d.status,d.name,d.code,sum(d.number) num,fee,sum(d.number)*fee sum " +
                " from wlyy_door_fee_detail d where order_id=? and type=1 GROUP BY status,code";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, orderId);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, orderId);
        return list;
        return list;
    }
    }
@ -423,7 +425,8 @@ public class DoorOrderService {
     * @return
     * @return
     */
     */
    public List<Map<String, Object>> getDoorServiceDoctor(String orderId) {
    public List<Map<String, Object>> getDoorServiceDoctor(String orderId) {
        String sql = "SELECT dd.id as id,CONCAT(d.`name`,' (',dd.doctor_job_name,')') as name, dd.doctor from wlyy_door_doctor dd join wlyy_doctor d on d.`code` = dd.doctor WHERE order_id=?";
        String sql = "SELECT dd.id as id,CONCAT(d.`name`,' (',dd.doctor_job_name,')') as name, " +
                "dd.doctor from wlyy_door_doctor dd join base_doctor d on d.`id` = dd.doctor WHERE order_id=?";
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
        return mapList;
        return mapList;
    }
    }
@ -478,9 +481,10 @@ public class DoorOrderService {
        if (null != doorServiceDoctors && doorServiceDoctors.size() > 0) {
        if (null != doorServiceDoctors && doorServiceDoctors.size() > 0) {
            doorServiceOrder.setDoctors(doorServiceDoctors);
            doorServiceOrder.setDoctors(doorServiceDoctors);
        }
        }
        System.out.println("准备获取咨询==>参数:" + id);
        //获取咨询
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(id);
        ConsultDo consult = consultDao.queryByRelationCode(id);
        System.out.println("consult==>" + JSON.toJSONString(consult));
        if (null != consult) {
        if (null != consult) {
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
        }
        }
@ -492,7 +496,7 @@ public class DoorOrderService {
        }
        }
        doorConclusion.setServiceCount(count);
        doorConclusion.setServiceCount(count);
        doorServiceOrder.setDoorConclusion(doorConclusion);
        doorServiceOrder.setDoorConclusion(doorConclusion);
        System.out.println("获取上门前后开方详情");
        //获取上门前后开方详情
        //获取上门前后开方详情
        List<WlyyDoorPrescriptionDO> doorBeforePrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 1);
        List<WlyyDoorPrescriptionDO> doorBeforePrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 1);
        List<WlyyDoorPrescriptionDO> doorAfterPrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 2);
        List<WlyyDoorPrescriptionDO> doorAfterPrescriptionDOList = doorPrescriptionDao.findByOrderIdAndIsAfterDoor(id, 2);
@ -645,7 +649,7 @@ public class DoorOrderService {
            //成功创建服务工单后,居民所在机构调度员向居民发起一条通知服务消息
            //成功创建服务工单后,居民所在机构调度员向居民发起一条通知服务消息
            // 发送IM消息通知患者医生已接单
            // 发送IM消息通知患者医生已接单
            String noticeContent = "我已接受您的服务工单预约," + doorServiceOrder.getDoctorName() + "医生正在为您服务!";
            String noticeContent = "已接受您的服务工单预约," + doorServiceOrder.getDoctorName() + "医生正在为您服务!";
            wlyyDoorServiceOrderService.qucikSendIM(doorServiceOrder.getId(), doorServiceOrder.getDoctor(), "智能助手", "1", noticeContent);
            wlyyDoorServiceOrderService.qucikSendIM(doorServiceOrder.getId(), doorServiceOrder.getDoctor(), "智能助手", "1", noticeContent);
            // 发送居民上门服务简要信息
            // 发送居民上门服务简要信息
            JSONObject orderInfoContent = wlyyDoorServiceOrderService.queryOrderCardInfo(doorServiceOrder);
            JSONObject orderInfoContent = wlyyDoorServiceOrderService.queryOrderCardInfo(doorServiceOrder);
@ -958,7 +962,9 @@ public class DoorOrderService {
                                       StringBuffer status, String createTimeStart, String createTimeEnd, String serverDoctorName,
                                       StringBuffer status, String createTimeStart, String createTimeEnd, String serverDoctorName,
                                       String doctorCode, Integer examPaperStatus, Integer page, Integer pageSize, Integer type, String name, String serverType) throws Exception {
                                       String doctorCode, Integer examPaperStatus, Integer page, Integer pageSize, Integer type, String name, String serverType) throws Exception {
        StringBuilder sqlList = new StringBuilder(
        StringBuilder sqlList = new StringBuilder(
                "select DISTINCT o.id as orderId,o.status,h.org_name AS hospitalName,  h.org_code AS hospital," +
                "select DISTINCT o.id as orderId,o.status," +
//                        "h.org_name AS hospitalName, " +//这个会重复
                        " h.org_code AS hospital," +
                        "o.is_trans_other_org,o.transed_org_code ,o.patient_name," +
                        "o.is_trans_other_org,o.transed_org_code ,o.patient_name," +
                        " o.patient_phone,o.remark,o.serve_desc,dc.service_time,o.patient as patientCode ," +
                        " o.patient_phone,o.remark,o.serve_desc,dc.service_time,o.patient as patientCode ," +
                        "o.exam_paper_status as examPaperStatus,o.number as serverCode,o.total_fee, " +
                        "o.exam_paper_status as examPaperStatus,o.number as serverCode,o.total_fee, " +
@ -1015,7 +1021,9 @@ public class DoorOrderService {
        }
        }
        String sql01 = sqlList.append(sql).append(" order by o.create_time desc LIMIT " + (page - 1) * pageSize + "," + pageSize).toString();
        String sql01 = sqlList.append(sql).append(" order by o.create_time desc LIMIT " + (page - 1) * pageSize + "," + pageSize).toString();
        String sql02 = sqlCount.append(sql).toString();
        String sql02 = sqlCount.append(sql).toString();
        System.out.println("getDoorOrderList----sql01==>" + sql01);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql01);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql01);
        System.out.println("工单的数量list==>" + list.size());
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql02);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql02);
        Long count = 0L;
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
        if (rstotal != null && rstotal.size() > 0) {
@ -1756,7 +1764,8 @@ public class DoorOrderService {
     * @throws Exception
     * @throws Exception
     */
     */
    public String serverPackagePriceByOrderId(String orderId) throws Exception {
    public String serverPackagePriceByOrderId(String orderId) throws Exception {
        String sql = "SELECT d.code itemCode,sum(d.number) number,fee from wlyy_door_fee_detail d where order_id=? and d.status in(1,2) and type=1 GROUP BY code";
        String sql = "SELECT d.code itemCode,sum(d.number) number,fee " +
                "from wlyy_door_fee_detail d where order_id=? and d.status in(1,2) and type=1 GROUP BY code";
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
        return objectMapper.writeValueAsString(mapList);
        return objectMapper.writeValueAsString(mapList);
    }
    }

+ 78 - 56
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.module.door.service;
package com.yihu.jw.hospital.module.door.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.fastdfs.FastDFSUtil;
@ -11,7 +12,6 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.hospital.HospitalDao;
import com.yihu.jw.hospital.HospitalDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
@ -664,7 +664,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    /**
    /**
     * 创建上门服务工单
     * 创建上门服务工单
     */
     */
    @Transactional(rollbackFor = Exception.class)
//    @Transactional(rollbackFor = Exception.class)
    public JSONObject create(String jsonData) throws Exception {
    public JSONObject create(String jsonData) throws Exception {
        logger.info("创建上门服务jsonData参数:" + jsonData);
        logger.info("创建上门服务jsonData参数:" + jsonData);
@ -762,50 +762,50 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        boolean flag = true;
        boolean flag = true;
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        //创建订单信息
        BasePatientDO pateint = patientDao.findById(orderDO.getPatient());
        //查询是否存在订单信息
        BusinessOrderDO businessOrderDO = businessOrderDao.findByOrderId(orderDO.getId());
        if (businessOrderDO == null) {
            businessOrderDO = new BusinessOrderDO();
            businessOrderDO.setPatient(pateint.getId());
            //支付账号
            businessOrderDO.setYkOrderId(pateint.getMobile());
            businessOrderDO.setPatientName(pateint.getName());
            businessOrderDO.setOrderType(1);
            businessOrderDO.setOrderCategory(type);
            Date date = new Date();
            Long lastPayTime = date.getTime() + 1000 * 60 * 30;//订单截至支付日期
            businessOrderDO.setDescription("上门服务");
            businessOrderDO.setRelationCode(orderDO.getId());//订单id
            businessOrderDO.setRelationName("上门服务");
            businessOrderDO.setCreateTime(date);
            businessOrderDO.setUpdateTime(date);
            businessOrderDO.setStatus(0);
            businessOrderDO.setOrderNo(orderDO.getNumber());
            businessOrderDO.setUploadStatus(0);
            businessOrderDO.setPayType(1);
            businessOrderDO.setPayPrice(Double.valueOf(orderDO.getTotalFee().doubleValue()));
            businessOrderDO.setLastPayTime(lastPayTime);
        } else {
            /**
             * 暂时没用,线下付款的
             * 1、是否付款完成
             * 2、判断付款时间是否超过时长了--还需要定时任务监听订单修改状态,把未付款改成已取消
             */
//            if (businessOrderDO.getStatus() != 1) {
//                long nowTime = System.currentTimeMillis();
//                Long lastPayTime = businessOrderDO.getLastPayTime();
//                if (lastPayTime > nowTime) {
//                    //超时了 修改工单状态成已取消
//                    orderDO.setStatus(-1);//-已取消
//                    wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
//                    businessOrderDO.setStatus(2);//已取消
//                    businessOrderDao.save(businessOrderDO);//更新业务表
//                    flag = false;//不用创建咨询内容
//                }
//            }
        }
//        //创建订单信息
//        BasePatientDO pateint = patientDao.findById(orderDO.getPatient());
//        //查询是否存在订单信息
//        BusinessOrderDO businessOrderDO = businessOrderDao.findByOrderId(orderDO.getId());
//        if (businessOrderDO == null) {
//            businessOrderDO = new BusinessOrderDO();
//            businessOrderDO.setPatient(pateint.getId());
//            //支付账号
//            businessOrderDO.setYkOrderId(pateint.getMobile());
//            businessOrderDO.setPatientName(pateint.getName());
//            businessOrderDO.setOrderType(1);
//            businessOrderDO.setOrderCategory(type);
//            Date date = new Date();
//            Long lastPayTime = date.getTime() + 1000 * 60 * 30;//订单截至支付日期
//            businessOrderDO.setDescription("上门服务");
//            businessOrderDO.setRelationCode(orderDO.getId());//订单id
//            businessOrderDO.setRelationName("上门服务");
//            businessOrderDO.setCreateTime(date);
//            businessOrderDO.setUpdateTime(date);
//            businessOrderDO.setStatus(0);
//            businessOrderDO.setOrderNo(orderDO.getNumber());
//            businessOrderDO.setUploadStatus(0);
//            businessOrderDO.setPayType(1);
//            businessOrderDO.setPayPrice(Double.valueOf(orderDO.getTotalFee().doubleValue()));
//            businessOrderDO.setLastPayTime(lastPayTime);
//        } else {
//            /**
//             * 暂时没用,线下付款的
//             * 1、是否付款完成
//             * 2、判断付款时间是否超过时长了--还需要定时任务监听订单修改状态,把未付款改成已取消
//             */
////            if (businessOrderDO.getStatus() != 1) {
////                long nowTime = System.currentTimeMillis();
////                Long lastPayTime = businessOrderDO.getLastPayTime();
////                if (lastPayTime > nowTime) {
////                    //超时了 修改工单状态成已取消
////                    orderDO.setStatus(-1);//-已取消
////                    wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
////                    businessOrderDO.setStatus(2);//已取消
////                    businessOrderDao.save(businessOrderDO);//更新业务表
////                    flag = false;//不用创建咨询内容
////                }
////            }
//        }
        /**
        /**
         *  1、费用0时无需支付
         *  1、费用0时无需支付
@ -825,7 +825,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
//        }
//        }
        //保存业务表
        //保存业务表
        businessOrderDao.save(businessOrderDO);
//        businessOrderDao.save(businessOrderDO);
        /**
        /**
         * 目前是线下付款的
         * 目前是线下付款的
@ -838,6 +838,13 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            //创建咨询
            //创建咨询
            JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
            JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
            ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
            ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
            System.out.println("===调度员的信息开始======");
            for (Map<String, Object> map : dispatcherList) {
                System.out.println("调度员=>" + JSON.toJSONString(map));
            }
            System.out.println("===调度员的信息结束======");
            //判断其是否有分配执行人。如果有不用走调度平台
            //判断其是否有分配执行人。如果有不用走调度平台
            if (StringUtils.isNotBlank(orderDO.getDoctor())) {
            if (StringUtils.isNotBlank(orderDO.getDoctor())) {
                orderDO.setStatus(2);//待接单
                orderDO.setStatus(2);//待接单
@ -880,9 +887,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
            JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
            orderInfoContent.put("re_msg_type", 0);//居民预约
            orderInfoContent.put("re_msg_type", 0);//居民预约
            System.out.println("准备发送预约卡片信息");
            int flagCount = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
            int flagCount = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
            System.out.println("flagCount==>" + flagCount);
            //模拟一,重试3次
            //模拟一,重试3次
//            int tryCount = 3;
//            int tryCount = 3;
@ -1384,8 +1391,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        String sql = "SELECT " +
        String sql = "SELECT " +
                "  d.photo AS doctorPhoto, " +
                "  d.photo AS doctorPhoto, " +
                "  d.`name` AS doctorName, " +
                "  d.`name` AS doctorName, " +
                "  d.`job_name` AS doctorJobName, " +
                "  d.hospital_name AS hospitalName, " +
                "  d.`job_title_name` AS doctorJobName, " +
                "  d.visit_hospital_name AS hospitalName, " +
                "  d.mobile AS doctorPhone, " +
                "  d.mobile AS doctorPhone, " +
                "  o.id, " +
                "  o.id, " +
                "  o.number, " +
                "  o.number, " +
@ -1400,8 +1407,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                "  o.sign_id 'signId' , o.package_id 'packageId' " +
                "  o.sign_id 'signId' , o.package_id 'packageId' " +
                " FROM " +
                " FROM " +
                "  ( wlyy_door_service_order o " +
                "  ( wlyy_door_service_order o " +
                " LEFT JOIN wlyy_doctor d ON o.doctor = d.`code`) " +
                " LEFT JOIN wlyy_door_fee_detail de on o.id = de.order_id " +
                " LEFT JOIN base_doctor d ON o.doctor = d.`id`) " +
                " LEFT JOIN wlyy_door_fee_detail de on o.id = de.order_id  and de.type='1' " +
                " LEFT JOIN base_org a on o.hospital = a.code " +
                " LEFT JOIN base_org a on o.hospital = a.code " +
                " WHERE " +
                " WHERE " +
                "  (o.patient = '{patient}') " +
                "  (o.patient = '{patient}') " +
@ -1419,7 +1426,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                "   count(DISTINCT o.id)  " +
                "   count(DISTINCT o.id)  " +
                " FROM  " +
                " FROM  " +
                "  ( wlyy_door_service_order o " +
                "  ( wlyy_door_service_order o " +
                " LEFT JOIN wlyy_doctor d ON o.doctor = d.`code`) " +
                " LEFT JOIN base_doctor d ON o.doctor = d.`id`) " +
                " LEFT JOIN wlyy_door_fee_detail de on o.id = de.order_id " +
                " LEFT JOIN wlyy_door_fee_detail de on o.id = de.order_id " +
                " LEFT JOIN base_org a on o.hospital = a.code " +
                " LEFT JOIN base_org a on o.hospital = a.code " +
                " WHERE  " +
                " WHERE  " +
@ -2640,9 +2647,22 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    public int sendMsg(String orderId, String sendId, String sendName, String contentType, String content) throws Exception {
    public int sendMsg(String orderId, String sendId, String sendName, String contentType, String content) throws Exception {
        System.out.println("发送消息的方法【sendMsg】");
        int result = -1;
        int result = -1;
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        System.out.println("查询ConsultDo==>参数:" + orderId);
        String sql = "SELECT * FROM wlyy_consult WHERE relation_code='" + orderId + "'";
        ConsultDo consult = null;
        List<ConsultDo> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ConsultDo.class));
        if (list != null && list.size() > 0) {
            consult = list.get(0);
            System.out.println("ConsultDo的list数量==>" + list.size());
        } else {
            throw new Exception("ConsultDo为空,参数RelationCode:" + orderId);
        }
//        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        System.out.println("方法:【sendMsg】 内容:consult==>" + JSON.toJSONString(consult));
        if (null == consult) {
        if (null == consult) {
            System.out.println("当前工单未关联咨询,工单id:" + orderId);
            System.out.println("当前工单未关联咨询,工单id:" + orderId);
            return result;
            return result;
@ -2651,6 +2671,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            String response = null;
            String response = null;
            if (StringUtils.isBlank(sendId)) {
            if (StringUtils.isBlank(sendId)) {
                WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findOne(orderId);
                WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findOne(orderId);
                System.out.println("方法:【wlyyDoorServiceOrder】 内容:consult==>" + JSON.toJSONString(consult));
                String sender = "system";
                String sender = "system";
                if (StringUtils.isNoneBlank(wlyyDoorServiceOrder.getDispatcher())) {
                if (StringUtils.isNoneBlank(wlyyDoorServiceOrder.getDispatcher())) {
                    sender = wlyyDoorServiceOrder.getDispatcher();
                    sender = wlyyDoorServiceOrder.getDispatcher();
@ -2659,6 +2680,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            } else {
            } else {
                response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
                response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
            }
            }
            System.out.println("sendTopicIM结果==>" + response);
            JSONObject resObj = JSONObject.parseObject(response);
            JSONObject resObj = JSONObject.parseObject(response);
            if (resObj.getIntValue("status") == -1) {
            if (resObj.getIntValue("status") == -1) {
                String msg = "上门服务工单消息发送失败:" + resObj.getString("message");
                String msg = "上门服务工单消息发送失败:" + resObj.getString("message");