trick9191 8 роки тому
батько
коміт
cdedc135e6

+ 55 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -3452,6 +3452,9 @@ public class FamilyContractService extends BaseService {
                " AND s.doctor_health IS NULL";
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(patientSql);
        JSONObject rs = new JSONObject();
        rs.put("count",(patientList!=null&&patientList.size()>0)?patientList.size():0);
        List<Map<String,Object>> serlist = jdbcTemplate.queryForList(serverSql);
        if(serlist!=null&&serlist.size()>0){
            if(patientList!=null){
@ -3484,9 +3487,59 @@ public class FamilyContractService extends BaseService {
                }
            }
        }
        JSONObject rs = new JSONObject();
        rs.put("patients",serlist);
        rs.put("count",(patientList!=null&&patientList.size()>0)?patientList.size():0);
        return rs;
    }
    public List<Map<String,Object>> patientGroupByServerType(String doctor) {
        // 先根据server_type分组查找wlyy_sign_family表中该医生的签约的患者,然后wlyy_sign_dict left join 得到全部的类型
        String sql=" select sd.code labelCode,sd.name labelName,IFNULL(t.count,0) amount from wlyy_sign_dict sd  " +
                " left join " +
                " ( " +
                " SELECT " +
                "  sf.server_type type, " +
                "  sf.server_type_name name, " +
                "  count(id) count " +
                " FROM " +
                "  wlyy_sign_family sf " +
                " WHERE " +
                "  sf. STATUS > 0 " +
                " AND ( " +
                "  sf.doctor =? " +
                "  or sf.doctor_health =? " +
                " ) " +
                " group by sf.server_type " +
                " ) t " +
                " on sd.`code`=t.type " +
                " where  sd.id in (4,5,6,7,8,9,10,11,12)";
        List<Map<String,Object>> queryData=jdbcTemplate.queryForList(sql,doctor,doctor);
        return queryData;
    }
}

+ 66 - 62
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -371,71 +371,75 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
            String batchNo = UUID.randomUUID().toString();
            Date createTime = new Date();
            for (String p : patientSet) {
                Patient patientTemp = patientService.findByCode(p);
                SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
                if (signFamily == null) {
                    throw new Exception("can not find patient's family sign info");
                }
                for (String a : articles) {
                    // 查询文章信息
                    HealthEduArticle temp = maps.get(a);
                    if (temp == null) {
                        temp = healthEduArticleService.findArticleByCode(a);
                        // 添加到缓存
                        maps.put(a, temp);
                try{
                    Patient patientTemp = patientService.findByCode(p);
                    SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
                    if (signFamily == null) {
                        throw new Exception("can not find patient's family sign info");
                    }
                    for (String a : articles) {
                        // 查询文章信息
                        HealthEduArticle temp = maps.get(a);
                        if (temp == null) {
                            temp = healthEduArticleService.findArticleByCode(a);
                            // 添加到缓存
                            maps.put(a, temp);
                        }
                    HealthEduArticlePatient heap = new HealthEduArticlePatient();
                    // 设置文章标识
                    heap.setArticle(a);
                    // 设置文章简介
                    //heap.setContent(temp.getContent());
                    // 设置文章标题
                    //heap.setTitle(temp.getTitle());
                    // 设置文章查看URL
                    //heap.setUrl(temp.getUrl());
                    // 设置发送时间
                    heap.setCzrq(new Date());
                    // 设置医生标识
                    heap.setDoctor(doctor.getCode());
                    // 设置医生姓名
                    heap.setDoctorName(doctor.getName());
                    // 设置患者标识
                    heap.setPatient(p);
                    // 设置为示读
                    heap.setRead(1);
                    // 签约类型
                    heap.setSignType(2);
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    //附加内容
                    heap.setAttachedContent(attachedContent);
                    //批次号记录发送批次
                    heap.setBatchNo(batchNo);
                    //创建时间
                    heap.setCzrq(createTime);
                    heap.setSignCode(patientService.getSignCodeByPatient(p));
                    list.add(heap);
                    consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
                    if(StringUtils.isNotBlank(attachedContent)){
                        //发送备注
                        consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, attachedContent, ImUtill.CONTENT_TYPE_TEXT, patientTemp.getName());
                        HealthEduArticlePatient heap = new HealthEduArticlePatient();
                        // 设置文章标识
                        heap.setArticle(a);
                        // 设置文章简介
                        //heap.setContent(temp.getContent());
                        // 设置文章标题
                        //heap.setTitle(temp.getTitle());
                        // 设置文章查看URL
                        //heap.setUrl(temp.getUrl());
                        // 设置发送时间
                        heap.setCzrq(new Date());
                        // 设置医生标识
                        heap.setDoctor(doctor.getCode());
                        // 设置医生姓名
                        heap.setDoctorName(doctor.getName());
                        // 设置患者标识
                        heap.setPatient(p);
                        // 设置为示读
                        heap.setRead(1);
                        // 签约类型
                        heap.setSignType(2);
                        // 行政团队
                        heap.setAdminTeamCode(signFamily.getAdminTeamId());
                        //附加内容
                        heap.setAttachedContent(attachedContent);
                        //批次号记录发送批次
                        heap.setBatchNo(batchNo);
                        //创建时间
                        heap.setCzrq(createTime);
                        heap.setSignCode(patientService.getSignCodeByPatient(p));
                        list.add(heap);
                        consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
                        if(StringUtils.isNotBlank(attachedContent)){
                            //发送备注
                            consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, attachedContent, ImUtill.CONTENT_TYPE_TEXT, patientTemp.getName());
                        }
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
                        json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                        json.put("toUser", p);
                        json.put("article", temp.getCode() + "");
                        json.put("title", temp.getTitle());
                        json.put("doctorName", doctor.getName());
                        json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                        json.put("remark", endMsg);
                        Map<String, Object> content = new HashMap<>();
                        content.put("openid", patientTemp.getOpenid());
                        content.put("name", patientTemp.getName());
                        content.put("json", json);
                        content.put("code",patientTemp.getCode());
                        msgs.put(patientTemp.getCode(), content);
                    }
                    // 推送消息给微信端
                    JSONObject json = new JSONObject();
                    json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                    json.put("toUser", p);
                    json.put("article", temp.getCode() + "");
                    json.put("title", temp.getTitle());
                    json.put("doctorName", doctor.getName());
                    json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                    json.put("remark", endMsg);
                    Map<String, Object> content = new HashMap<>();
                    content.put("openid", patientTemp.getOpenid());
                    content.put("name", patientTemp.getName());
                    content.put("json", json);
                    content.put("code",patientTemp.getCode());
                    msgs.put(patientTemp.getCode(), content);
                }catch (Exception e){
                    error(e);
                }
            }
            // 保存到数据库