Преглед на файлове

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

chenweida преди 7 години
родител
ревизия
28435adf2e

+ 25 - 21
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -87,12 +87,14 @@ public class GcEduArticleController extends WeixinBaseController {
            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
            @ApiParam(name = "labelType", value = "标签类型  1 服务类型  2 健康情况 3 疾病类型 4 自定义标签", required = true) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
            @ApiParam(name = "articleIds", value = "文章ID,多个逗号分割", required = true) @RequestParam(value = "articleIds", required = true) String articleIds,
            @ApiParam(name = "articlePics", value = "文章封面,多个逗号分割", required = true) @RequestParam(value = "articlePics", required = true) String articlePics,
            @ApiParam(name = "articleTitles", value = "文章标题,多个逗号分割", required = true) @RequestParam(value = "articleTitles", required = true) String articleTitles
    ) {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
            String[] unPatients = unReceiveCodes.split(",");//接收人的code
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            String[] articleIdArr = articleIds.split(",");
            String[] articlePicArr = articlePics.split(",");
@ -101,11 +103,11 @@ public class GcEduArticleController extends WeixinBaseController {
                return new ResultBatchModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":文章参数长度错误");
            }
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, labelType, labelCode, teamId);
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //保存发送记录
            List<HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.saveArticle(patientSet, sendCode, sendName, sendMessage, teamId, articleIdArr, articlePicArr, articleTitleArr);
            //推送微信模板消息和发送im消息
            sendWxTemplateAndIM(healthEduArticlePatients);
            sendWxTemplateAndIM(healthEduArticlePatients, sendType);
            return new BaseResultModel();
@ -114,49 +116,51 @@ public class GcEduArticleController extends WeixinBaseController {
        }
    }
    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients) throws  Exception{
    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients, String sendType) throws Exception {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient=patientService.findByCode(one.getPatient());
            consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle()+ "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
            if(StringUtils.isNotBlank(one.getAttachedContent())){
                //发送备注
                consultService.sendMucMessageBySingnType(one.getDoctor(),one.getDoctorName(), patient.getCode(), one.getAttachedContent(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
            Patient patient = patientService.findByCode(one.getPatient());
            //卫纪委发送不推IM
            if ("1".equals(sendType)) {
                consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                if (StringUtils.isNotBlank(one.getAttachedContent())) {
                    //发送备注
                    consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), one.getAttachedContent(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                }
            }
            // 推送消息给微信端
            JSONObject json = new JSONObject();
            json.put("first", patient.getName() + ",您好!\n" +  one.getDoctorName() + "医生给您发来了一篇患教文章");
            json.put("first", patient.getName() + ",您好!\n" + one.getDoctorName() + "医生给您发来了一篇患教文章");
            json.put("toUser", patient.getCode());
            json.put("article", one.getId()+ "");
            json.put("article", one.getId() + "");
            json.put("title", one.getAttachedTitle());
            json.put("doctorName", one.getDoctorName());
            json.put("represented",patient.getCode());//被代理人
            json.put("represented", patient.getCode());//被代理人
            json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
            json.put("remark", one.getAttachedContent());
            json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedContent())?"  ":one.getAttachedContent());
            if(StringUtils.isNotBlank(patient.getOpenid())){
            if (StringUtils.isNotBlank(patient.getOpenid())) {
                pushMsgTask.putWxMsg(getAccessToken(), 9,
                        patient.getOpenid(),
                        patient.getName(),
                        json);
            }
            //发送代理人
            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(),patient.getOpenid());
            if(jsonArray!=null&&jsonArray.length()>0){
                for (int i=0;i<jsonArray.length();i++){
            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid());
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient)j.get("member");
                    Patient member = (Patient) j.get("member");
                    json.remove("toUser");
                    json.put("toUser",member.getCode());
                    json.put("toUser", member.getCode());
                    json.remove("first");
                    try {
                        json.put("first",weiXinOpenIdUtils.getTitleMes(patient,j.isNull("relation")?1:j.getInt("relation"),patient.getName()));
                        json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if(StringUtils.isNotBlank(member.getOpenid())){
                    if (StringUtils.isNotBlank(member.getOpenid())) {
                        pushMsgTask.putWxMsg(getAccessToken(), 9, member.getOpenid(), patient.getName(), json);
                    }
                }

+ 20 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -36,14 +36,21 @@ public class GcEduArticleService {
     * @param labelCode
     * @param teamId
     */
    public void initPatient(Set<String> patientSet, String[] patients, String labelType, String labelCode, Long teamId) {
    public void initPatient(Set<String> patientSet, String[] patients, String[] unPatients, String labelType, String labelCode, Long teamId) {
        List params = new ArrayList();//sql参数
        StringBuffer sb = new StringBuffer();//sql
        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
            switch (labelType) {
                case "1": {
                    sb.append(" select w.patient from wlyy_sign_family w where w.server_type=? and w.`status`>0 ");
                    sb.append(" SELECT " +
                            "  w.patient " +
                            "FROM " +
                            "  wlyy_sign_family w " +
                            " WHERE " +
                            "  w.`status` > 0 " +
                            " AND w.code in ( select sign_code from  " +
                            "  wlyy_sign_family_server where server_type=? ) ");
                    params.add(labelCode);
                    if (teamId != null && teamId > 0) {
@ -57,7 +64,7 @@ public class GcEduArticleService {
                case "4": {
                    sb.append("SELECT w.patient FROM wlyy_sign_family w " +
                            "WHERE " +
                            "  w.patient in (SELECT  l.patient FROM  wlyy_sign_patient_label_info l WHERE l.label_type = ? AND l.label = ?) " +
                            "  w.patient in (SELECT  l.patient FROM  wlyy_sign_patient_label_info l WHERE l.label_type = ? AND l.label = ? and l.status=1) " +
                            "AND w.`status` > 0");
                    params.add(labelType);
                    params.add(labelCode);
@ -75,6 +82,13 @@ public class GcEduArticleService {
            List<String> arrPatient = java.util.Arrays.asList(patients);
            patientSet.addAll(arrPatient);
        }
        if (unPatients != null && unPatients.length > 0) {
            for (String unPatient : unPatients) {
                if(patientSet.contains(unPatient)){
                    patientSet.remove(unPatient);
                }
            }
        }
    }
    /**
@ -97,6 +111,9 @@ public class GcEduArticleService {
        Date createTime = new Date();
        for (String patient : patientSet) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            if(signFamily==null){
                continue;
            }
            for (int i = 0; i < articleIds.length; i++) {
                HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
                // 设置文章标识