wsl 2 lat temu
rodzic
commit
23b9642cbb

+ 6 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -343,7 +343,7 @@ public class PatientMessageService {
        String[] dateS ;
        String[] dateS ;
        ZhaohuiDailyEntity zhaohuiDailyEntity = null;
        ZhaohuiDailyEntity zhaohuiDailyEntity = null;
        if (StringUtils.isNotBlank(dailyId)){
        if (StringUtils.isNotBlank(dailyId)){
            zhaohuiDailyEntity = zhaohuiDailyDao.findById(Long.parseLong(dailyId));
                zhaohuiDailyEntity = zhaohuiDailyDao.findById(Long.parseLong(dailyId));
            dateS = zhaohuiDailyEntity.getServiceTime().split(",");
            dateS = zhaohuiDailyEntity.getServiceTime().split(",");
        }else {
        }else {
            String startDate = date+ " 00:00:00";
            String startDate = date+ " 00:00:00";
@ -365,10 +365,13 @@ public class PatientMessageService {
        //dateS[0] = "2022-01-01 00:00:00";
        //dateS[0] = "2022-01-01 00:00:00";
        //dateS[1] = "2022-11-29 23:59:59";
        //dateS[1] = "2022-11-29 23:59:59";
        ;
        JSONObject doctorBaseInfo = JSONObject.parseObject(JSON.toJSONString(zhaohuiDailyEntity));
        if ("4".equals(userType)) {
        if ("4".equals(userType)) {
            String orgSql = "select * from base_team where id = '"+orgId+"' ";
            String orgSql = "select * from base_team where id = '"+orgId+"' ";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(orgSql);
            List<Map<String, Object>> list = jdbcTemplate.queryForList(orgSql);
            zhaohuiDailyEntity.setMessage(zhaohuiDailyEntity.getMessage().replace("您",list.get(0).get("name").toString()));
            String replace = zhaohuiDailyEntity.getMessage().replace("您", list.get(0).get("name").toString());
            doctorBaseInfo.put("message",replace);
            String sql = "SELECT t.org_name orgName,d.photo photo,d.mobile mobile,d.id doctorId,d.`name` doctorName,t.id orgId from base_team t INNER JOIN base_team_member m ON t.id = m.team_code  " +
            String sql = "SELECT t.org_name orgName,d.photo photo,d.mobile mobile,d.id doctorId,d.`name` doctorName,t.id orgId from base_team t INNER JOIN base_team_member m ON t.id = m.team_code  " +
                    "INNER JOIN base_doctor d ON m.doctor_code = d.id  WHERE t.org_code = 'zdjsylfwyxgszhfgs' AND t.id = '"+orgId+"' ";
                    "INNER JOIN base_doctor d ON m.doctor_code = d.id  WHERE t.org_code = 'zdjsylfwyxgszhfgs' AND t.id = '"+orgId+"' ";
@ -400,7 +403,7 @@ public class PatientMessageService {
            System.out.println(endTime - startTime);
            System.out.println(endTime - startTime);
        }
        }
        resultObj.put("doctorBaseInfo", zhaohuiDailyEntity);
        resultObj.put("doctorBaseInfo", doctorBaseInfo);
        resultObj.put("patientBaseInfo", patientBasInfoList);
        resultObj.put("patientBaseInfo", patientBasInfoList);
        return resultObj;
        return resultObj;
    }
    }

+ 6 - 0
svr/svr-cloud-job/pom.xml

@ -122,6 +122,12 @@
            <artifactId>elasticsearch</artifactId>
            <artifactId>elasticsearch</artifactId>
            <version>2.4.4</version>
            <version>2.4.4</version>
        </dependency>
        </dependency>
        <!--钉钉sdk-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>zwdd-sdk-java</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <groupId>com.yihu.jw</groupId>
            <artifactId>sms-service</artifactId>
            <artifactId>sms-service</artifactId>

+ 23 - 2
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/message/ZhaohuiDailyService.java

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.pushLog.*;
import com.yihu.jw.care.dao.pushLog.*;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.util.DingdingUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.dict.service.BaseCopywritingService;
import com.yihu.jw.dict.service.BaseCopywritingService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -62,6 +63,8 @@ public class ZhaohuiDailyService {
    private ZhaohuifireGasSecDao zhaohuifireGasSecDao;
    private ZhaohuifireGasSecDao zhaohuifireGasSecDao;
    @Autowired
    @Autowired
    private BaseCopywritingService dictService;
    private BaseCopywritingService dictService;
    @Autowired
    private DingdingUtil dingdingUtil;
    public void allRound() {
    public void allRound() {
@ -480,7 +483,7 @@ public class ZhaohuiDailyService {
        zhaohuiDailyEntity.setMessage(old.getName()+sex+secMessage+","+deviceMessage);
        zhaohuiDailyEntity.setMessage("【"+old.getName()+"】"+sex+secMessage+","+deviceMessage);
        zhaohuiDailyDao.save(zhaohuiDailyEntity);
        zhaohuiDailyDao.save(zhaohuiDailyEntity);
@ -495,7 +498,7 @@ public class ZhaohuiDailyService {
        messageUtil.putTemplateWxMessage(wxId,"template_zhrb","zhrb","123456",first,null,null,1,null,"",key2+"",liftOlderTotal+"","【推送完成】",DateUtil.getStringDate());
        messageUtil.putTemplateWxMessage(wxId,"template_zhrb","zhrb","123456",first,null,null,1,null,"",key2+"",liftOlderTotal+"","【推送完成】",DateUtil.getStringDate());
*/
*/
        wxPush(old.getName(),familyCode, zhaohuiDailyEntity.getService(), emeTotal);
        //wxPush(old.getName(),familyCode, zhaohuiDailyEntity.getService(), emeTotal);
        zhaohuiDailySleepDao.save(zhaohuiDailySleepList);
        zhaohuiDailySleepDao.save(zhaohuiDailySleepList);
        zhaohuiDailyWatchDao.save(zhaohuiDailyWatchList);
        zhaohuiDailyWatchDao.save(zhaohuiDailyWatchList);
@ -610,6 +613,24 @@ public class ZhaohuiDailyService {
        }
        }
        zhaohuiDailyDao.save(zhaohuiDailyEntityList);
        zhaohuiDailyDao.save(zhaohuiDailyEntityList);
        String sql = "SELECT d.id AS doctorId ,d.ykt_doctor_id as yktDoctorId,t.id FROM base_doctor d INNER JOIN base_team_member m ON d.id = m.doctor_code INNER JOIN base_team t  ON m.team_code = t.id  " +
                " WHERE d.doctor_level = 2 AND t.org_code = 'zdjsylfwyxgszhfgs' AND d.ykt_doctor_id IS NOT NULL";
        List<Map<String, Object>> doctorList = jdbcTemplate.queryForList(sql);
        //社区
        for (Map<String, Object> map : doctorList) {
            for (ZhaohuiDailyEntity zhaohuiDailyEntity : zhaohuiDailyEntityList) {
                if (zhaohuiDailyEntity.getOrgCode().equals(map.get("doctorId"))) {
                    dingdingUtil.sendP2pMsg(zhaohuiDailyEntity.getMessage(),map.get("yktDoctorId").toString());
                    break;
                }
            }
        }
    }
    }

+ 258 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/DingdingUtil.java

@ -0,0 +1,258 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.xxpt.gateway.shared.client.http.ExecutableClient;
import com.alibaba.xxpt.gateway.shared.client.http.GetClient;
import com.alibaba.xxpt.gateway.shared.client.http.PostClient;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
/**
 * 阿里巴巴钉钉工具类
 * Created by yeshijie on 2022/3/23.
 */
@Component
public class DingdingUtil {
    private static final Logger logger = LoggerFactory.getLogger(DingdingUtil.class);
    //测试-专有钉钉
//    private static final String AppKey = "ceshiyzh-jtP6zf3cfZEqs8UmmYNra";
//    private static final String AppSecret = "NbbH9viHPDNTPTuQPz2Y0Y06F88krYWTTPLv0h01";
    //正式-浙政钉
    private static final String zhdAppKey = "zhyzh-r085NCVALJYmgcDc7oBVFRZj";
    private static final String zhdAppSecret = "fH8ZVDGAmJaeF7ujwAZgCi40w0U3im9J801vBaSF";
    private static final String zhdDomainName = "openplatform.dg-work.cn";
    private static final String zhdtenantId = "50495309";
    //正式-专有钉钉
    private static final String AppKey = "zhyzh-67H0tpyZr7m8crdJsxI3YVZb";
    private static final String AppSecret = "xK0VBIfeUj0gBm0Gp55180Qk6i866230Qch1T96v";
    private static final String DomainName = "openplatform-pro.ding.zj.gov.cn";
    private static final String tenantId = "196729";
    private static final String gettokenApi = "/gettoken.json";
    private static final String dingtalk_app_user = "/rpc/oauth2/dingtalk_app_user.json";
    private static final String get_by_mobiles = "/mozi/employee/get_by_mobiles";
    private static final String getuserinfo_bycode = "/rpc/oauth2/getuserinfo_bycode.json";
    private static final String sendMsg = "/chat/sendMsg";
    //单聊默认发送者id
    private static final String p2pSenderId = "78728186";
//    private static final String p2pSenderId = "821606";
    public static final String picMediaId = "$iwHSAADGgQoAC9EkWgKsb2N0ZXQtc3RyZWFtAwAEAAUABrzrLoqjhIdIKXPi5GCsroJXXzE3ZmI0OGFiNWJhBwAIAAmhMA";
    //executableClient要单例,并且使用前要初始化,只需要初始化一次
    private static ExecutableClient executableClient = null;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 测试浙政钉
     */
    public void testZzd() {
//        ExecutableClient executableClient = ExecutableClient.getInstance();
//        executableClient.setAccessKey(zhdAppKey);
//        executableClient.setSecretKey(zhdAppSecret);
//        executableClient.setDomainName(zhdDomainName);
//        executableClient.setProtocal("https");
//        executableClient.init();
//        logger.info("get_by_mobiles========="+zhdDomainName);
//        //调用API
//        PostClient postClient = executableClient.newPostClient(get_by_mobiles);
//        //设置参数
//        postClient.addParameter("areaCode", "86");
//        //手机号码列表,逗号分隔,最多50个
//        postClient.addParameter("mobiles", "15659713528");
//        postClient.addParameter("tenantId", zhdtenantId);
//        postClient.addParameter("namespace", "local");
//        //Call API
//        String apiResult2 = postClient.post();
//        logger.info("get_by_mobiles========="+apiResult2);
    }
    @PostConstruct
    public void clientInit(){
        if(executableClient == null){
            synchronized(ExecutableClient.class){
                if(executableClient == null){
                    executableClient = ExecutableClient.getInstance();
                    executableClient.setAccessKey(AppKey);
                    executableClient.setSecretKey(AppSecret);
                    executableClient.setDomainName(DomainName);
                    executableClient.setProtocal("https");
                    executableClient.init();
                }
            }
        }
    }
    /**
     * 获取AccessToken
     * @return
     */
    public String getAccessToken(){
        GetClient getClient = executableClient.newGetClient(gettokenApi);
        //设置参数
        getClient.addParameter("appkey", AppKey);
        getClient.addParameter("appsecret", AppSecret);
        //调用API
        String apiResult = getClient.get();
        logger.info(apiResult);
        //{"success":true,"content":{"data":{"expiresIn":7200,"accessToken":"app_4197121c698246cea9ec660902324edd"},"success":true,"requestId":"276077ca16480212814976877e76c6","responseMessage":"OK","responseCode":"0","bizErrorCode":"0"},"bizErrorCode":"0"}
        JSONObject jsonObject = JSON.parseObject(apiResult);
        if(jsonObject.getBoolean("success")){
            JSONObject content = jsonObject.getJSONObject("content");
            if(content.getBoolean("success")){
                return content.getJSONObject("data").getString("accessToken");
            }
        }
        return null;
    }
    /**
     * 获取用户信息
     * @return
     */
    public JSONObject dingtalk_app_user(String authCode){
        //调用API
        PostClient postClient = executableClient.newPostClient(dingtalk_app_user);
        //设置参数
        postClient.addParameter("access_token", getAccessToken());
        postClient.addParameter("auth_code", authCode);
        //Call API
        String apiResult = postClient.post();
        logger.info(apiResult);
        //{"success":true,"content":{"success":false,"responseMessage":"code失效或不存在","responseCode":"240111","bizErrorCode":"MBS-B001-02-16-240111"}}
        return JSON.parseObject(apiResult);
    }
    /**
     * 根据手机号获取员工账户id
     * @param mobiles
     * @return
     */
    public JSONArray get_by_mobiles(String mobiles){
        //调用API
        PostClient postClient = executableClient.newPostClient(get_by_mobiles);
        //设置参数
        postClient.addParameter("areaCode", "86");
        //手机号码列表,逗号分隔,最多50个
        postClient.addParameter("mobiles", mobiles);
        postClient.addParameter("tenantId", tenantId);
        postClient.addParameter("namespace", "local");
        //Call API
        String apiResult = postClient.post();
        logger.info(apiResult);
        //{"success":true,"content":{"data":[{"accountId":821685,"mobile":"15859634562","employeeCode":"GE_f27a7231e19f4b31b8f11d2859d1be07","status":0},{"accountId":821606,"mobile":"13559485270","employeeCode":"GE_10933a0f8bc949149143163cba5bb81f","status":0}],"success":true,"requestId":"2760828316480239373806874ed97b","responseMessage":"OK","responseCode":"0","bizErrorCode":"0"},"bizErrorCode":"0"}
        JSONObject jsonObject = JSON.parseObject(apiResult);
        if(jsonObject.getBoolean("success")){
            JSONObject content = jsonObject.getJSONObject("content");
            if(content.getBoolean("success")){
                return content.getJSONArray("data");
            }
        }
        return null;
    }
    /**
     * 初始化更新钉钉账户id
     */
    public void yktDoctorIdInit(){
        List<BaseDoctorDO> doctorDOList = doctorDao.findByYktDoctorIdNull();
        List<BaseDoctorDO> doctorDOs = new ArrayList<>();
        for (BaseDoctorDO doctorDO:doctorDOList){
            JSONArray jsonArray = get_by_mobiles(doctorDO.getMobile());
            if(jsonArray!=null&&jsonArray.size()>0){
                long accountId = jsonArray.getJSONObject(0).getLong("accountId");
                doctorDO.setYktDoctorId(accountId+"");
                doctorDOs.add(doctorDO);
            }
        }
        if(doctorDOs.size()>0){
            doctorDao.save(doctorDOs);
        }
    }
    /**
     * 更新单个钉钉账户id
     * @param mobile
     */
    public void updYktDoctorId(String mobile){
        List<BaseDoctorDO> doctorDOs = doctorDao.findByMobile(mobile);
        if(doctorDOs.size()>0){
            BaseDoctorDO doctorDO = doctorDOs.get(0);
            JSONArray jsonArray = get_by_mobiles(doctorDO.getMobile());
            if(jsonArray!=null&&jsonArray.size()>0){
                long accountId = jsonArray.getJSONObject(0).getLong("accountId");
                doctorDO.setYktDoctorId(accountId+"");
                doctorDao.save(doctorDOs);
            }
        }
    }
    public String getuserinfo_bycode(String code){
        //调用API
        PostClient postClient = executableClient.newPostClient(getuserinfo_bycode);
        //设置参数
        postClient.addParameter("access_token", getAccessToken());
        postClient.addParameter("code", code);
        //Call API
        String apiResult = postClient.post();
        logger.info(apiResult);
//        JSONObject jsonObject = JSON.parseObject(apiResult);
//        if(jsonObject.getBoolean("success")){
//            JSONObject content = jsonObject.getJSONObject("content");
//            if(content.getBoolean("success")){
//                return content.getJSONObject("data").getString("accessToken");
//            }
//        }
        return null;
    }
    /**
     * 发送单聊消息
     */
    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);
        //Set the parameters
        postClient.addParameter("msg", msg);
        postClient.addParameter("senderId", StringUtils.isBlank(sendId)?p2pSenderId:sendId);
        postClient.addParameter("receiverId", receiverId);
        postClient.addParameter("chatId", "");
        postClient.addParameter("tenantId", tenantId);
        postClient.addParameter("chatType", "1");
        //Call API
        String apiResult = postClient.post();
        logger.info("响应结果"+apiResult);
        return apiResult;
    }
}