Browse Source

上门服务和im咨询

suqinyi 1 năm trước cách đây
mục cha
commit
e1ecf5c878

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxTemplateConfigDao.java

@ -15,7 +15,9 @@ import java.util.List;
public interface WxTemplateConfigDao extends PagingAndSortingRepository<WxTemplateConfigDO, String>, JpaSpecificationExecutor<WxTemplateConfigDO> {
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndSceneAndStatus(String wechatId, String templateName, String scene, Integer status);
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndScene(String wechatId, String templateName, String scene);
    List<WxTemplateConfigDO> findByWechatIdAndScene(String wechatId, String scene);
    //根据自定义模板名称、场景值查询有效模板内容

+ 1 - 1
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java

@ -14,7 +14,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String>, JpaSpecificationExecutor<ConsultDo> {
	ConsultDo findByCode(String code);
//	ConsultDo findByCode(String code);
	
	@Query("from ConsultDo a where a.relationCode = ?1")
	ConsultDo findByRelationCode(String outpatientid);

+ 11 - 7
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -401,6 +401,7 @@ public class ImUtil {
        params.put("topic_id", topicId);
        params.put("agent", agent);
        String response = HttpClientUtil.postBody(url, params);
        System.out.println("[sendTopicIM]发送消息给IM==>" + response);
        return response;
    }
@ -653,21 +654,23 @@ public class ImUtil {
    }
    public JSONObject getTopicMessage(String topicId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
        JSONObject jsonObject = new JSONObject();
        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 {
            System.out.println("地址:" + url);
            String ret = httpClientUtil.get(url, "UTF-8");
            System.out.println("响应结果==>" + ret);
            JSONObject obj = JSON.parseObject(ret);
            if (obj.getInteger("status") == -1) {
                throw new RuntimeException(obj.getString("message"));
            } else {
                return obj.getJSONObject("data");
            }
            return obj.getJSONObject("data");
        } catch (Exception e) {
            return null;
            e.printStackTrace();
            jsonObject.put("msg", e.getMessage());
            return jsonObject;
        }
    }
    public JSONArray getSessionMessage(String sessionId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
@ -738,6 +741,7 @@ public class ImUtil {
        String url = im_host + "api/v2/sessions/topics/" + topicId + "?topic_id=" + topicId;
        try {
            String ret = httpClientUtil.get(url, "utf-8");
            System.out.println("getTopic结果==>" + ret);
            JSONObject obj = JSON.parseObject(ret);
            if (obj.getInteger("status") == -1) {
                throw new RuntimeException("获取议题失败!");

+ 9 - 8
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java

@ -15,7 +15,7 @@ import java.util.Date;
@Table(name = "wlyy_consult")
public class ConsultDo extends UuidIdentityEntity {
	private String code;//新补充字段
//	private String code;//新补充字段
	// 患者标识
	private String patient;
@ -37,6 +37,7 @@ public class ConsultDo extends UuidIdentityEntity {
	private String del;
	// 结束时间
	private Date endTime;
	//关联业务表的code
	private String relationCode;
	//支付状态
@ -44,13 +45,13 @@ public class ConsultDo extends UuidIdentityEntity {
	//来源
	private String source;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
//	public String getCode() {
//		return code;
//	}
//
//	public void setCode(String code) {
//		this.code = code;
//	}
	public String getSource() {
		return source;

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java

@ -17,7 +17,7 @@ import java.util.Date;
@Table(name = "wlyy_consult_team")
public class ConsultTeamDo extends UuidIdentityEntity {
	
	private String consult;         // 咨询标识
	private String consult;         // 咨询标识  --这个对应的是wlyy_consult的Id
	private String doctor;          // 医生标识
	private String team;            // 三师团队标识
	private Integer type;           //  1、15三师咨询,2、家庭医生咨询,

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

@ -22,6 +22,7 @@ import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.im.util.ImageCompress;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
@ -1123,7 +1124,7 @@ public class ConsultController extends EnvelopRestEndpoint {
                                String doctorOpenID = doctor.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String title = "";
                                    ConsultDo consultSingle = consultDao.findByCode(log.getConsult());
                                    ConsultDo consultSingle = consultDao.findOne(log.getConsult());
                                    if (consultSingle != null) {
                                        Integer singleType = consultSingle.getType();
                                        if (singleType != null && singleType == 8) {
@ -1203,13 +1204,17 @@ public class ConsultController extends EnvelopRestEndpoint {
     */
    @RequestMapping(value = "loglist")
    @ApiOperation("网络咨询咨询日志查询")
    public String loglist(@RequestParam String consult, @RequestParam int page, @RequestParam int pagesize) {
    public String loglist(
            @RequestParam String consult,
            @RequestParam String loginUser,
            @RequestParam int page, @RequestParam int pagesize) {
        try {
            ConsultTeamDo consultModel = consultTeamService.findById(consult);
            ConsultTeamDo consultModel = consultTeamService.findByCode(consult);
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            com.alibaba.fastjson.JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
            com.alibaba.fastjson.JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, loginUser);
            //过滤续签
//            consultTeamService.removeRenewPerson(messageObj, getRepUID());
            return write(200, "查询成功", "list", messageObj);
@ -1322,11 +1327,10 @@ public class ConsultController extends EnvelopRestEndpoint {
    /**
     * 三师咨询评论
     *
     * @param consult 咨询标识
     * @param content 评价内容
     * @param star    星级
     * @return 操作结果
     * consult 咨询标识
     * content 评价内容
     * star    星级
     *  操作结果
     */
//    @RequestMapping(value = "comment")
//    @ApiOperation("三师咨询评论")
@ -1358,17 +1362,14 @@ public class ConsultController extends EnvelopRestEndpoint {
//
//    }
//    @RequestMapping(value = "getTopic")
//    public String getTopic(String consult) {
//        try {
//            return success(imUtill.getTopic(consult).get("data").toString());
//        } catch (ServiceException se) {
//            return error(-1, se.getMessage());
//        } catch (Exception e) {
//            error(e);
//            return error(-1, e.getMessage());
//        }
//    }
    @RequestMapping(value = "getTopic")
    public Envelop getTopic(String consult) {
        try {
            return success(imUtill.getTopic(consult).get("data").toString());
        } catch (Exception e) {
            return failed( e.getMessage());
        }
    }
//    @RequestMapping(value = "getConsult")
//    public String getConsult(String consult) {
@ -1737,17 +1738,19 @@ public class ConsultController extends EnvelopRestEndpoint {
//    }
//    @RequestMapping(value = "queryByRelationCode", method = RequestMethod.GET)
//    @ApiOperation("根据关联业务code查询咨询记录")
//    public String queryByRelationCode(@ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code) {
//        try {
//            ConsultTeam consultTeam = consultTeamService.queryByRelationCode(code);
//            return write(200, "提交成功", "data", consultTeam);
//        } catch (Exception e) {
//            error(e);
//            return error(-1, "添加失败");
//        }
//    }
    @RequestMapping(value = "queryByRelationCode", method = RequestMethod.GET)
    @ApiOperation("根据关联业务code查询咨询记录")
    public String queryByRelationCode(
            @ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code
    ) {
        try {
            ConsultTeamDo consultTeam = consultTeamService.queryByRelationCode(code);
            return write(200, "提交成功", "data", consultTeam);
        } catch (Exception e) {
            error(e);
            return error(-1, "添加失败");
        }
    }
//    @RequestMapping(value = "queryByConsultCode", method = RequestMethod.GET)
//    @ApiOperation("根据咨询code查询关联业务项详情")

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultService.java

@ -71,7 +71,7 @@ public class ConsultService {
            String patient, String title, String symptoms, String images, int type
    ) throws Exception {
        ConsultDo consult = new ConsultDo();
        consult.setCode(UUID.randomUUID().toString().replaceAll("-", ""));//UUID
//        consult.setCode(UUID.randomUUID().toString().replaceAll("-", ""));//UUID
        consult.setCzrq(new Date());
        consult.setDel("1");
        consult.setPatient(patient);

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

@ -217,7 +217,8 @@ public class ConsultTeamService extends ConsultService {
        consultTeam.setEvaluate(0);
        consultTeam.setDoctorRead(1); // 医生未读数量为1
        consult.setRelationCode(doorServiceOrderDO.getId());//关联业务code
        consultTeam.setConsult(consult.getCode()); // 设置咨询标识
//        consultTeam.setConsult(consult.getCode()); // 设置咨询标识
        consultTeam.setConsult(consult.getId()); // 设置咨询标识
        /**
         * 原本:(im创建咨询) 上门服务咨询的sessionid为居民code+咨询code+工单编号+咨询类型
@ -238,7 +239,7 @@ public class ConsultTeamService extends ConsultService {
        /**
         * 创建议题
         */
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getCode(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        if (imResponseJson == null || imResponseJson.getString("status").equals("-1")) {
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
@ -2180,6 +2181,7 @@ public class ConsultTeamService extends ConsultService {
//    public int cancel(String consult) {
//        return consultTeamDao.cancel(consult);
//    }
    public ConsultTeamDo findByCode(String code) {
        return consultTeamDao.findByConsult(code);
    }
@ -3336,13 +3338,13 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 根据关联业务code查询咨询记录 wlyyDoorServiceOrderService.queryOneDetail(consult.getRelationCode());
     */
//    public ConsultTeamDo queryByRelationCode(String relationCode) {
//        if (StringUtils.isEmpty(relationCode)) {
//            return null;
//        }
//        ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(relationCode);
//        return consultTeam;
//    }
    public ConsultTeamDo queryByRelationCode(String relationCode) {
        if (StringUtils.isEmpty(relationCode)) {
            return null;
        }
        ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(relationCode);
        return consultTeam;
    }
    /**
     * 根据咨询查关联业务记录

+ 15 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/DoorOrderController.java

@ -97,6 +97,16 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    /**
     * 查询所有社区医生的机构
     */
    @GetMapping(value = "getDotorOrgList")
    @ApiOperation(value = "查询所有社区医生的机构")
    public Envelop getDotorOrgList() {
        List<Map<String, Object>> list = wlyyDoorServiceOrderService.getDotorOrgList();
        return success("查询成功", list);
    }
    @GetMapping(value = "queryDoctorList")
    @ApiOperation(value = "服务人员列表(医生列表)")
    public Envelop queryDoctorList(
@ -107,6 +117,11 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            //初始化接单人员信息,社区医生的level=1
            wlyyDoorServiceOrderService.initDoorStatus(town);
            //查询医生信息
            JSONObject result = wlyyDoorServiceOrderService.queryDoctorList(patient, town, doctorName, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return failed(result.getString(ResponseContant.resultMsg));
@ -368,7 +383,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    @GetMapping("/topStatusBarNum")
    @ApiOperation(value = "顶部状态栏订单分类tab")
    public Envelop topStatusBarNum(
@ -987,9 +1001,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = "updateServiceStatus")
    @ApiOperation(value = "更新预约服务项目类型")

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

@ -9,13 +9,11 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.wechat.WechatTemplateConfig;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.module.door.dao.*;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.im.dao.ConsultDao;
@ -25,6 +23,7 @@ import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import jxl.Workbook;
import jxl.write.*;
import org.apache.commons.collections.CollectionUtils;
@ -119,8 +118,8 @@ public class DoorOrderService {
    private ConsultDao consultDao;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
//    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    //    @Autowired
//    private HttpUtil httpUtil;
    @Autowired
    private WlyyDoorCommentDao doorCommentDao;
@ -398,7 +397,7 @@ public class DoorOrderService {
            doorServiceOrder.setAge(age);
            doorServiceOrder.setPhoto(patient.getPhoto());
//            String typeValues = this.getTypeValueByPatientCode(patient.getCode());
           String typeValues = this.getTypeValueByPatientCode(patient.getId());
            String typeValues = this.getTypeValueByPatientCode(patient.getId());
            doorServiceOrder.setTypeValue(typeValues);
        }
        // 获取服务次数
@ -434,7 +433,7 @@ public class DoorOrderService {
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(id);
        if (null != consult) {
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
        }
        // 设置服务小结
@ -612,13 +611,13 @@ public class DoorOrderService {
        if (doorServiceOrder == null) {
            return;
        }
        
        // 发送微信模板消息通知患者医生已接单
        BasePatientDO patient = patientService.findPatientById(doorServiceOrder.getPatient());
        // 获取微信模板
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "smyyyjjd");
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "smyyyjjd");
            String first = templateConfig.getFirst();
            first = first.replace("key1", (patient.getName() == null ? "" : patient.getName()));
            first = first.replace("key2", null != doorServiceOrder.getDoctorName() ? doorServiceOrder.getDoctorName() : "");
@ -630,7 +629,7 @@ public class DoorOrderService {
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            if (consult != null) {
                json.put("consult", consult.getCode());
                json.put("consult", consult.getId());
            }
            logger.info("上门服务已接单推送前");
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
@ -851,7 +850,7 @@ public class DoorOrderService {
            object.put("feeDetailResultList", feeDetailResultList);
            // 获取或者基本信息
            
            BasePatientDO patient = patientService.findPatientById(String.valueOf(one.get("patientCode")));
            if (patient != null) {
                String sex = IdCardUtil.getSexForIdcard(patient.getIdcard());
@ -868,7 +867,7 @@ public class DoorOrderService {
            //获取咨询
            ConsultDo consult = consultDao.queryByRelationCode(id);
            if (null != consult) {
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            }
            object.put("sessionId", doorServiceOrder.getSessionId());
@ -1068,7 +1067,7 @@ public class DoorOrderService {
            //获取咨询
            ConsultDo consult = consultDao.queryByRelationCode(id);
            if (null != consult) {
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            }
            object.put("sessionId", doorServiceOrder.getSessionId());
@ -1354,7 +1353,7 @@ public class DoorOrderService {
        // 获取微信模板 smfwdwk-上门服务待付款
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "fwyspf");
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "fwyspf");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first.replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
@ -1376,19 +1375,6 @@ public class DoorOrderService {
                json.put("finish", finish);
            }
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
            /*WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","smfwdwk");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
           // String keyword1 = templateConfig.getKeyword1();
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "上门服务待付款");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("consult",consult.getCode());*/
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
@ -2018,9 +2004,9 @@ public class DoorOrderService {
        if (org.apache.commons.lang3.StringUtils.isBlank(sendId)) {
            wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findOne(orderId);
            response = imUtill.sendTopicIM(wlyyDoorServiceOrder.getDispatcher(), "智能助手", consult.getCode(), contentType, content, null);
            response = imUtill.sendTopicIM(wlyyDoorServiceOrder.getDispatcher(), "智能助手", consult.getId(), contentType, content, null);
        } else {
            response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
            response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
        }
        JSONObject resObj = JSONObject.parseObject(response);
        if (resObj.getIntValue("status") == -1) {

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorPrescriptionService.java

@ -231,7 +231,7 @@ public class WlyyDoorPrescriptionService {
            logger.error("当前工单未关联咨询,工单id:" + orderId);
            return result;
        }
        String response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
        String response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
        JSONObject resObj = JSONObject.parseObject(response);
        if (resObj.getIntValue("status") == -1) {
            logger.error("上门服务工单消息发送失败:" + resObj.getString("message"));

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

@ -542,7 +542,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            ConsultDo consult = consultDao.queryByRelationCode(orderDO.getId());
            String sessionId = null;
            if (consult != null) {
                sessionId = orderDO.getPatient() + "_" + consult.getCode() + "_" + orderDO.getNumber() + "_" + consult.getType();
                sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + orderDO.getNumber() + "_" + consult.getType();
            }
            for (Object one : doctorArray) {
                WlyyDoorDoctorDO doorDoctorDO = null;
@ -1558,7 +1558,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        json.put("url", templateConfig.getUrl());
        json.put("remark", templateConfig.getRemark());
        if (consult != null) {
            json.put("consult", consult.getCode());
            json.put("consult", consult.getId());
        } else {
            json.put("id", orderDO.getId());
        }
@ -1594,7 +1594,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
//        appoint_service/html/appoint-serviceDetail.html?openid=ojsU-1XJVftkfdbP1F5bi8JVPtOo&consult=e0d17c67ab07477f8e96534bc610e51b
        json.put("remark", templateConfig.getRemark());
        if (consult != null) {
            json.put("consult", consult.getCode());
            json.put("consult", consult.getId());
        } else {
            json.put("id", orderDO.getId());
        }
@ -2033,6 +2033,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        int end = 0 == size ? 15 : size;
        String sql = "SELECT " +
                "  a.dept_code 'deptCode',\ta.dept_name 'deptName',a.org_code 'orgCode',\ta.org_name 'orgName', " +
                "  d.id as doctor, " +
                "  d.photo as photo, " +
                "  d.name as name," +
@ -2041,7 +2042,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                "  when 1 then '男' " +
                "  when 2 then '女' " +
                "  end as sex, " +
                "  d.`job_title_name` AS jobName, " +
                "  d.job_title_code 'jobCode', d.`job_title_name` AS jobName, " +
                "  d.mobile as phone," +
                "  CONCAT(d.doctor_lat ,',',d.doctor_lon) 'position', " +
                "  IFNULL(ds.`status`,5) as status," +
@ -2261,7 +2262,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        imUtill.updateParticipant(sessionId, doctor, null);
        // 调度员处理完该单(新增预约的,或者是拒单重新派单的)
@ -2362,7 +2363,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        imUtill.updateParticipant(sessionId, doctor, null);
        // 调度员处理完该单(新增预约的,或者是拒单重新派单的)
@ -2527,9 +2528,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                if (StringUtils.isNoneBlank(wlyyDoorServiceOrder.getDispatcher())) {
                    sender = wlyyDoorServiceOrder.getDispatcher();
                }
                response = imUtill.sendTopicIM(sender, "智能助手", consult.getCode(), contentType, content, null);
                response = imUtill.sendTopicIM(sender, "智能助手", consult.getId(), contentType, content, null);
            } else {
                response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
                response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
            }
            JSONObject resObj = JSONObject.parseObject(response);
            if (resObj.getIntValue("status") == -1) {
@ -2925,4 +2926,38 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        }
        return map;
    }
    /**
     * 初始化社区医生
     */
    public void initDoorStatus(String hospital) {
        String sql = "SELECT * from base_doctor doc WHERE doctor_level=1 and id not in ( " +
                "SELECT doctor from wlyy_door_doctor_status " +
                ")";
        if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)) {
            sql += "and EXISTS (select id from base_doctor_hospital dh where doc.id = dh.doctor_code and dh.org_code='" + hospital + "' and dh.del=1 ) ";
        }
        List<BaseDoctorDO> doctorDOs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseDoctorDO.class));
        List<WlyyDoorDoctorStatusDO> doctorList = new ArrayList<>(doctorDOs.size());
        for (BaseDoctorDO baseDoctorDO : doctorDOs) {
            WlyyDoorDoctorStatusDO doctorDoor = new WlyyDoorDoctorStatusDO();
            doctorDoor.setDoctor(baseDoctorDO.getId());
            doctorDoor.setStatus(1);
            doctorDoor.setCreateTime(new Date());
            doctorDoor.setCreateUser("System");
            doctorDoor.setCreateUserName("System");
            doctorList.add(doctorDoor);
        }
        wlyyDoorDoctorStatusDao.save(doctorList);
    }
    public List<Map<String, Object>> getDotorOrgList() {
        String sql = "SELECT a.org_code 'hospitalCode',a.org_name 'hospitalName' \n" +
                "FROM base_doctor_hospital a INNER JOIN base_doctor b\n" +
                "WHERE b.doctor_level='1'\n" +
                "GROUP BY a.org_code,a.org_name ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 58 - 50
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/task/PushMsgTask.java

@ -2,14 +2,14 @@ package com.yihu.jw.hospital.task;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.wechat.WechatPushLog;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import com.yihu.jw.entity.wechat.WechatTemplate;
import com.yihu.jw.entity.wechat.WechatTemplateData;
import com.yihu.jw.hospital.module.wx.dao.WechatPushLogDao;
import com.yihu.jw.hospital.utils.HttpUtil;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.hospital.utils.WeiXinOpenIdUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@ -43,57 +43,62 @@ public class PushMsgTask {
    private String putMesMethod;
    @Value("${pushMes.redis_prescription_title}")
    private String redisQueue;
//    @Value("${putMesType.wechat}")
    //    @Value("${putMesType.wechat}")
    private String putMesType;
    //模板id
//    @Value("${wechat.message.template_sign_success}")
    private String template_sign_success;
//    @Value("${wechat.message.template_sign_failed}")
    //    @Value("${wechat.message.template_sign_failed}")
    private String template_sign_failed;
//    @Value("${wechat.message.template_consult_notice}")
    //    @Value("${wechat.message.template_consult_notice}")
    private String template_consult_notice;
//    @Value("${wechat.message.template_health_notice}")
    //    @Value("${wechat.message.template_health_notice}")
    private String template_health_notice;
//    @Value("${wechat.message.template_termination}")
    //    @Value("${wechat.message.template_termination}")
    private String template_termination;
//    @Value("${wechat.message.template_appoint_success}")
    //    @Value("${wechat.message.template_appoint_success}")
    private String template_appoint_success;
//    @Value("${wechat.message.template_appoint_failed}")
    //    @Value("${wechat.message.template_appoint_failed}")
    private String template_appoint_failed;
//    @Value("${wechat.message.template_expenses_remind}")
    //    @Value("${wechat.message.template_expenses_remind}")
    private String template_expenses_remind;
//    @Value("${wechat.message.template_healthy_article}")
    //    @Value("${wechat.message.template_healthy_article}")
    private String template_healthy_article;
//    @Value("${wechat.message.template_doctor_change}")
    //    @Value("${wechat.message.template_doctor_change}")
    private String template_doctor_change;
//    @Value("${wechat.message.template_doctor_survey}")
    //    @Value("${wechat.message.template_doctor_survey}")
    private String template_doctor_survey;
//    @Value("${wechat.message.template_doctor_audit}")
    //    @Value("${wechat.message.template_doctor_audit}")
    private String template_doctor_audit;//审核结果通知
//    @Value("${wechat.message.template_doctor_service}")
    //    @Value("${wechat.message.template_doctor_service}")
    private String template_doctor_service;//服务结果通知
//    @Value("${wechat.message.template_physical_examination}")
    //    @Value("${wechat.message.template_physical_examination}")
    private String template_physical_examination;//体检提醒
//    @Value("${wechat.message.doctor_invitel_template}")
    //    @Value("${wechat.message.doctor_invitel_template}")
    private String doctor_invitel_template;
//    @Value("${wechat.message.template_deal_with}")
    //    @Value("${wechat.message.template_deal_with}")
    private String template_deal_with;
//    @Value("${wechat.message.template_patient_bind_device}")
    //    @Value("${wechat.message.template_patient_bind_device}")
    private String template_patient_bind_device;
//    @Value("${wechat.message.template_healthbank_credit}")
    //    @Value("${wechat.message.template_healthbank_credit}")
    private String template_healthbank_credit;
//    @Value("${wechat.message.template_rehabilitation_plan}")
    //    @Value("${wechat.message.template_rehabilitation_plan}")
    private String template_rehabilitation_plan;
//    @Value("${wechat.message.template_process_feedback}")
    //    @Value("${wechat.message.template_process_feedback}")
    private String template_process_feedback;
//    @Value("${wechat.message.template_birthday_wishes}")
    //    @Value("${wechat.message.template_birthday_wishes}")
    private String template_birthday_wishes;//生日祝福
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private WechatPushLogDao wechatPushLogDao;
//    @Autowired
//    private WechatPushLogDao wechatPushLogDao;
    WxPushLogDao wxPushLogDao;
    @Autowired
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
@ -293,6 +298,7 @@ public class PushMsgTask {
     * @return
     */
    public boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
        WxPushLogDO log = new WxPushLogDO();
        try {
            if (StringUtils.isEmpty(openid)) {
                logger.error("send wechat message failed:openid is empty");
@ -305,26 +311,26 @@ public class PushMsgTask {
                    logger.error("参数错误!error");
                    return false;
                }
                WechatPushLog log = new WechatPushLog();
                log.setType(type);
                log.setCreateTime(new Date());
                log.setName(name);
                log.setOpenid(openid);
                if (!json.isNull("toUser")) {
                    log.setPatient(json.getString("toUser"));
                }
                log.setCreateTime(new Date());
//                //这里没这些字段,后面看要不要补充
//                log.setName(name);
//                log.setType(type);
//                if (!json.isNull("toUser")) {
//                    log.setPatient(json.getString("toUser"));
//                }
                log.setRequest(json.toString());
                String result = HttpUtil.sendPost(token_url, params);
                JSONObject jsonResult = new JSONObject(result);
                log.setResponse(result);
                if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
                    logger.info("微信信息推送成功!success");
                    log.setStatus(1);
                    wechatPushLogDao.save(log);
                    log.setStatus("1");
                    wxPushLogDao.save(log);
                    return true;
                } else {
                    log.setStatus(0);
                    wechatPushLogDao.save(log);
                    log.setStatus("0");
                    wxPushLogDao.save(log);
                    logger.error("错误编码:" + jsonResult.get("errcode").toString() + "  错误提示:" + jsonResult.get("errmsg").toString());
                    return false;
                }
@ -361,27 +367,29 @@ public class PushMsgTask {
                    logger.error("参数错误!error");
                    return false;
                }
                WechatPushLog log = new WechatPushLog();
                log.setType(type);
                WxPushLogDO log = new WxPushLogDO();
                log.setScene(scene);
                log.setCreateTime(new Date());
                log.setName(name);
                log.setOpenid(openid);
                if (!json.isNull("toUser")) {
                    log.setPatient(json.getString("toUser"));
                }
//                //这里没这些字段,后面看要不要补充
//                log.setName(name);
//                log.setType(type);
//                if (!json.isNull("toUser")) {
//                    log.setPatient(json.getString("toUser"));
//                }
                log.setRequest(json.toString());
                String result = HttpUtil.sendPost(token_url, params);
                JSONObject jsonResult = new JSONObject(result);
                log.setResponse(result);
                if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
                    logger.info("微信信息推送成功!success");
                    log.setStatus(1);
                    wechatPushLogDao.save(log);
                    log.setStatus("1");
                    wxPushLogDao.save(log);
                    return true;
                } else {
                    log.setStatus(0);
                    wechatPushLogDao.save(log);
                    log.setStatus("0");
                    wxPushLogDao.save(log);
                    logger.error("错误编码:" + jsonResult.get("errcode").toString() + "  错误提示:" + jsonResult.get("errmsg").toString());
                    return false;
                }
@ -467,7 +475,7 @@ public class PushMsgTask {
                    } else if (json.has("agent") && ("0".equals(json.getString("agent")))) {
//                        发送给自己
                        temp.setUrl(url + "qygl/html/pay_flow.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + json.getString("represented") + "&signCode=" + json.getString("signCode"));
                    }else {
                    } else {
                        temp.setUrl((String) json.get("url"));
                    }
                }
@ -482,7 +490,7 @@ public class PushMsgTask {
                if (json.has("content")) {
                    keyword1.setValue(json.getString("content"));
                    keyword2.setValue(json.getString("doctorName"));
                }else {
                } else {
                    keyword1.setValue(json.getString("first"));
                    keyword2.setValue(json.getString("remark"));
                }
@ -584,7 +592,7 @@ public class PushMsgTask {
                if (json.has("doctorName")) {
                    keyword1.setValue(json.getString("doctorName"));
                    keyword4.setValue(json.getString("content"));
                }else {
                } else {
                    keyword1.setValue(json.getString("first"));
                    keyword4.setValue(json.getString("remark"));
                }
@ -1176,7 +1184,7 @@ public class PushMsgTask {
    /**
     * 根据type 匹配对应模板ID
     *
     * @param type 见WechatPushLog说明
     * @param type 见WxPushLogDO说明
     * @return
     */
    private String getTemplateId(int type) throws Exception {