#2872 浙政钉

マージされた
yeshijie 2 年 前 に 2 件のコミットが xiaoyunquan/dev から Amoy2/dev にマージされました

+ 44 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/dingding/DingDingMessageEndpoint.java

@ -0,0 +1,44 @@
package com.yihu.jw.care.endpoint.dingding;

import com.yihu.jw.care.service.dingding.DingDingMessageService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xyq
 * @create 2022-06-02 10:54
 * @slogan 他化自在,我自逍遥
 */
@RestController
@RequestMapping(value = "/open/dingDingMessage")
@Api(description = "钉钉消息")
public class DingDingMessageEndpoint extends EnvelopRestEndpoint {

    @Autowired
    private DingDingMessageService dingDingMessageService;

    @PostMapping(value = "sendDingDingMessageToOne")
    @ApiOperation(value = "发送钉钉消息")
    public ObjEnvelop sendDingDingMessage(@ApiParam @RequestParam(required = false)String sendId,
                                          @ApiParam @RequestParam(required = false)String receiverId,
                                          @ApiParam @RequestParam(required = false)String content,
                                          @ApiParam @RequestParam(required = false,defaultValue = "text")String msgtype,
                                          @ApiParam @RequestParam(required = false)String url,
                                          @ApiParam @RequestParam(required = false)String title){

        try {
            return dingDingMessageService.sendMessageToOne(sendId, receiverId, content, msgtype, url, title);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }

    }
}

+ 2 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -307,8 +307,9 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                    }
                    }
                }catch (Exception e){}
                }catch (Exception e){}
                String body = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请关注并及时处理。";
                String body = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请关注并及时处理。";
                String dingDingBody = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请及时处理。";
                messageUtil.sendDoctorGetuiMessage(doctorDO.getId(),"2","/sos/index?tabActive=1","紧急呼叫",body);
                messageUtil.sendDoctorGetuiMessage(doctorDO.getId(),"2","/sos/index?tabActive=1","紧急呼叫",body);
                messageUtil.sendDoctorDingdingMessage(doctorDO,null,"text","2",body,null,null);
                messageUtil.sendDoctorDingdingMessage(doctorDO,null,"text","2",dingDingBody,null,null);
                imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
                imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
            }
            }
            //pc管理端端推送消息
            //pc管理端端推送消息

+ 72 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/dingding/DingDingMessageService.java

@ -0,0 +1,72 @@
package com.yihu.jw.care.service.dingding;

import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.DingdingUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xyq
 * @create 2022-06-02 16:21
 * @slogan 他化自在,我自逍遥
 */
@Service
public class DingDingMessageService {

    @Autowired
    private DingdingUtil dingdingUtil;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private MessageUtil messageUtil;

    /**
     *
     * @param sendId 发送者的钉钉id
     * @param receiverId 接收者的医生id
     * @param content 消息内容
     * @param msgtype 消息类型,text,link
     * @param url
     * @param title
     * @return
     */
    public ObjEnvelop sendMessageToOne(String sendId, String receiverId, String content, String msgtype, String url, String title){
        //messageUtil.sendDoctorDingdingMessage(null,receiverId,"text",null,content,null,null);
        if(StringUtils.isBlank(receiverId)){
            return ObjEnvelop.getError("医生id不能为空");
        }
        BaseDoctorDO doctorById = doctorDao.findById(receiverId);
        if(doctorById == null || StringUtils.isBlank(doctorById.getYktDoctorId())){
            return ObjEnvelop.getError("接收者id不能为空");
        }
        receiverId = doctorById.getYktDoctorId();
        JSONObject msg = new JSONObject();
        msg.put("msgtype",msgtype);
        if("text".equals(msgtype)){
            JSONObject text = new JSONObject();
            text.put("content",content);
            msg.put("text",text);
        }else if("link".equals(msgtype)){
            JSONObject link = new JSONObject();
            link.put("messageUrl",url);
            link.put("title",title);
            link.put("text",content);
            link.put("picMediaId",DingdingUtil.picMediaId);
            msg.put("link",link);
        }
        String s = dingdingUtil.sendP2pMsg(msg.toString(), receiverId,sendId);
        //String s = "{\\\"_RequestId\\\":\\\"da6c6a8716541404813972617d0011\\\",\\\"Message\\\":\\\"User not authorized to operate on the specified resource.\\\",\\\"success\\\":false,\\\"errorCode\\\":\\\"100\\\",\\\"HostId\\\":\\\"openplatform-pro.ding.zj.gov.cn\\\",\\\"Code\\\":\\\"Forbidden\\\",\\\"bizErrorCode\\\":\\\"OPF-B001-05-16-0002\\\",\\\"errorMsg\\\":\\\"User not authorized to operate on the specified resource.\\\",\\\"errorLevel\\\":\\\"error\\\"}";
        s = s.replace("\\","");
        JSONObject jsonObject = JSONObject.parseObject(s);
        if(jsonObject.getBooleanValue("success")){
            return ObjEnvelop.getSuccess("发送成功",jsonObject);
        }else {
            return ObjEnvelop.getSuccess("发送失败",jsonObject,-1);
        }
    }
}

+ 2 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -310,8 +310,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            } catch (Exception e) {
            } catch (Exception e) {
            }
            }
            String body = "您好," + orderDO.getPatientName() + "居民" + orderDO.getServeDesc() + ",请关注并及时处理。";
            String body = "您好," + orderDO.getPatientName() + "居民" + orderDO.getServeDesc() + ",请关注并及时处理。";
            String dingDingBody = orderDO.getPatientName()+"居民存在异常情况,请及时处理,异常内容:"+orderDO.getServeDesc()+"。";
            messageUtil.sendDoctorGetuiMessage(doctorDO.getId(), "1", "/securityMonitoring/index", "安防紧急预警", body);
            messageUtil.sendDoctorGetuiMessage(doctorDO.getId(), "1", "/securityMonitoring/index", "安防紧急预警", body);
            messageUtil.sendDoctorDingdingMessage(doctorDO,null,"text","1",body,null,null);
            messageUtil.sendDoctorDingdingMessage(doctorDO,null,"text","1",dingDingBody,null,null);
            imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(), message.toString());
            imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(), message.toString());
        }
        }
        //pc管理端端推送消息
        //pc管理端端推送消息

+ 12 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DingdingUtil.java

@ -8,6 +8,7 @@ import com.alibaba.xxpt.gateway.shared.client.http.GetClient;
import com.alibaba.xxpt.gateway.shared.client.http.PostClient;
import com.alibaba.xxpt.gateway.shared.client.http.PostClient;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -232,18 +233,26 @@ public class DingdingUtil {
    /**
    /**
     * 发送单聊消息
     * 发送单聊消息
     */
     */
    public void sendP2pMsg(String msg,String receiverId){
    public String sendP2pMsg(String msg,String receiverId){
        return this.sendP2pMsg(msg, receiverId,null);
    }
    /**
     * 发送单聊消息
     */
    public String sendP2pMsg(String msg,String receiverId,String sendId){
        PostClient postClient = executableClient.newPostClient(sendMsg);
        PostClient postClient = executableClient.newPostClient(sendMsg);
        //Set the parameters
        //Set the parameters
        postClient.addParameter("msg", msg);
        postClient.addParameter("msg", msg);
        postClient.addParameter("senderId", p2pSenderId);
        postClient.addParameter("senderId", StringUtils.isBlank(sendId)?p2pSenderId:sendId);
        postClient.addParameter("receiverId", receiverId);
        postClient.addParameter("receiverId", receiverId);
        postClient.addParameter("chatId", "");
        postClient.addParameter("chatId", "");
        postClient.addParameter("tenantId", tenantId);
        postClient.addParameter("tenantId", tenantId);
        postClient.addParameter("chatType", "1");
        postClient.addParameter("chatType", "1");
        //Call API
        //Call API
        String apiResult = postClient.post();
        String apiResult = postClient.post();
        logger.info(apiResult);
        logger.info("响应结果"+apiResult);
        return apiResult;
    }
    }
}
}