Jelajahi Sumber

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

yeshijie 7 tahun lalu
induk
melakukan
ec9233581c

+ 40 - 406
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -58,7 +58,7 @@ public class JMJkEduArticleService extends BaseService {
    private String esIndex;
    @Autowired
    private AdminTeamService adminTeamService;
    
    @Autowired
    private ElasticFactory elasticFactory;
    @Autowired
@ -143,10 +143,11 @@ public class JMJkEduArticleService extends BaseService {
        HealthEduArticlePatientModel heapm = null;
        JSONObject article = null;
        Doctor doctor = null;
    
        List<HealthEduArticlePatientModel> resultList = new ArrayList<>();
        StringBuffer sql3 = null;
        StringBuffer sql4 = null;
        for (HealthEduArticleES one : esList) {
@ -181,29 +182,45 @@ public class JMJkEduArticleService extends BaseService {
                heapm.setReadNumber(0L);
            }
            //备注:因为1.4.1前端的阅读数取值的参数是browseNumber,到1.4.2前端再做调整为ReadNumber
            if(!StringUtils.isEmpty(article.getString("browseNumber"))){
                heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            }else{
                heapm.setBrowseNumbere(0);//文章浏览数
            }
//            if(num!=null){
//                heapm.setBrowseNumbere(Integer.valueOf(num.intValue()));//文章浏览数
//            }else{
//                heapm.setBrowseNumbere(0);//文章浏览数
//            }
            sql4 = new StringBuffer();
            sql4.append("SELECT COUNT(*) as num FROM "+esType+" WHERE  batchNo = '"+one.getBatchNo()+"' AND patientCode is not null AND articleId='"+article.getString("articleId")+"'");
//            sql4.append("SELECT COUNT(*) as num FROM "+esType+" WHERE  doctorCode='"+one.getDoctorCode()+"' AND patientCode is not null AND articleId='"+article.getString("articleId")+"'");
//            System.out.printf("AllCount:"+sql4.toString());
            Long num2 = elasticsearchUtil.excuteForLong(sql4.toString(), esType, esIndex);
            if(num2!=null){
                heapm.setAllCount(num2.intValue());//发送数
            }else{
                heapm.setAllCount(0);//发送数
            }
            if(!StringUtils.isEmpty(article.getString("commentNumber"))){
                heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            }else{
                heapm.setCommentNumber(0);//文章评论数
            }
            
            if(!StringUtils.isEmpty(article.getString("pointNumber"))){
                heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
            }else{
                heapm.setPointNumber(0);//文章点赞数
            }
            if(!StringUtils.isEmpty(article.getString("collectionNumberCount"))){
                heapm.setCollectionNumber(Integer.valueOf(article.getString("collectionNumberCount")));//文章点赞数
            if(!StringUtils.isEmpty(article.getString("collectionNumber"))){
                heapm.setCollectionNumber(Integer.valueOf(article.getString("collectionNumber")));//文章点赞数
            }else{
                heapm.setCollectionNumber(0);//文章点赞数
            }
            
            heapm.setArticleCover(article.getString("articleCover"));//封面
            if(article.getString("insertTime")!=null){
                heapm.setComputeTime(computeTime(article.getString("insertTime")));
@ -307,137 +324,6 @@ public class JMJkEduArticleService extends BaseService {
    }
//    public String fetchUserHighestAuthority(List<Map<String, Object>> resultMap){
//        String result = "";
//        for(Map<String, Object> one:resultMap){
//            String role = one.get("roleCode").toString();
//            if(role.length()==6){
//                if("00".equals(role.substring(4))){
//                    return role;
//                }else {
//                    result = role;
//                }
//            }else{
//                if(result.length()==6){
//
//                }else{
//
//                }
//            }
//        }
//    }
//    /**
//     * 保存发送信息
//     *
//     * @param patientSet  患者set集和
//     * @param sendCode    发送人code、
//     * @param sendMessage 发送人携带的信息
//     * @param teamId      发送人所属团队
//     * @param articleId   文章列表
//     */
//    @Transactional
//    public HealthEduArticlePatient saveArticle(Set<String> patientSet,
//                                                  String sendCode,
////                                                  String sendName,
//                                                  Integer sendType,
//                                                  String sendMessage,
//                                                  Long teamId,
//                                                  String articleId,
//                                                  String leaveWords) throws Exception {
//
//
//        String batchNo = UUID.randomUUID().toString();
//        List<Patient> patientList = new ArrayList<>();
//
//        for (String patient : patientSet) {
//            patientList.add(new Patient(patient));
//        }
//        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
//        //1、医生,2、卫计委(管理员)
//        //如果是卫计委得区别角色
//        Doctor doctor = doctorDao.findByCode(sendCode);
//        String sendName = doctor.getName();
//        //管理员
//        Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode);
//        Integer level = (Integer)resultMap.get("level");
//        List<String> roleList = (List<String>)resultMap.get("roleList");
//        if(doctor.getLevel()==10&&sendType==2){
//            String resultSql ="";
//            String whereSql ="";
//            String temp = "";
//            for(String one :roleList){
//                temp+=",'"+one+"'";
//            }
//            if(!StringUtils.isEmpty(temp)){
//                temp=temp.substring(1);
//            }
//            switch (level){
//                case 1:{resultSql +=" DISTINCT (province_name) as name";
//                    whereSql+=" and province in ("+temp+")";break;}
//                case 2:{resultSql +=" DISTINCT (city_name) as name";
//                    whereSql+=" and city in ("+temp+")";break;}
//                case 3:{resultSql +=" DISTINCT (town_name) as name";
//                    whereSql+=" and town in ("+temp+")";break;}
//                case 4:{resultSql +=" DISTINCT (name) as name";
//                    whereSql+=" and code in ("+temp+")";break;}
//
//            }
//            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ;
//            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql);
//            temp = "";
//            for(Map<String, Object> one :returnList){
//                temp +=","+one.get("name");
//            }
//            sendName = StringUtils.isEmpty(temp)?"":temp.substring(1);
//        }
//        List<RoleVo> roleVoLists= new ArrayList<>();
//        for(String one:roleList){
//            RoleVo roleVo = new RoleVo();
//            roleVo.setCode(one);
//            roleVoLists.add(roleVo);
//        }
//        healthEduArticlePatient.setRoleList(roleVoLists);
//        healthEduArticlePatient.setDoctorCode(sendCode);
//        healthEduArticlePatient.setSendName(sendName);
//        healthEduArticlePatient.setSendType(2);
//        healthEduArticlePatient.setAdminTeamCode(teamId);
//        healthEduArticlePatient.setLeaveWords(leaveWords);
//        if (doctor != null) {
//            healthEduArticlePatient.setDoctorName(doctor.getName());
//            healthEduArticlePatient.setHospital(doctor.getHospital());
//            healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
//            healthEduArticlePatient.setTown(doctor.getTown());
//            healthEduArticlePatient.setTownName(doctor.getTownName());
//            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
//            healthEduArticlePatient.setSendPic(doctor.getPhoto());
//            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
//        }
//        healthEduArticlePatient.setBatchNo(batchNo);
//        healthEduArticlePatient.setCreateTime(new Date());
//
//
//        //通过文章id 获取文章详情
//        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
//
//        healthEduArticlePatient.setArticleId(article.get("articleId") + "");
//        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + "");
//        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + "");
//        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + "");
//        healthEduArticlePatient.setAttachedMessage(sendMessage);
//        healthEduArticlePatient.setArticleType(article.get("articleType") + "");
//        healthEduArticlePatient.setLevel(article.get("articlelevel") + "");
//        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
//        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
//        healthEduArticlePatient.setType("1");//文章
////        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+);
//        healthEduArticlePatient.setPatients(patientList);
//
//        //保存到ES中
//        elastricSearchSave.save(healthEduArticlePatient, esIndex, esType);
//        return healthEduArticlePatient;
//    }
    /**
     * 保存PC端发送信息
@ -461,83 +347,6 @@ public class JMJkEduArticleService extends BaseService {
                                                     String currentUserRoleLevel) throws Exception {
//        String batchNo = UUID.randomUUID().toString();
//        List<Patient> patientList = new ArrayList<>();
//
//        for (String patient : patientSet) {
//            patientList.add(new Patient(patient));
//        }
//        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
//
//        Doctor doctor = doctorDao.findByCode(sendCode);
//        String sendName = doctor.getName();
//        //1、普通医生,2、管理员
//        if(sendType==2){
//            String resultSql ="";
//            String whereSql ="";
//            switch (currentUserRoleLevel){
//                case "1":{resultSql +=" DISTINCT (province_name) as name";
//                    whereSql+=" and province ='"+currentUserRoleCode+"'";break;}
//                case "2":{resultSql +=" DISTINCT (city_name) as name";
//                    whereSql+=" and city ='"+currentUserRoleCode+"'";break;}
//                case "3":{resultSql +=" DISTINCT (town_name) as name";
//                    whereSql+=" and town ='"+currentUserRoleCode+"'";break;}
//                case "4":{resultSql +=" DISTINCT (name) as name";
//                    whereSql+=" and code ='"+currentUserRoleCode+"'";break;}
//            }
//            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ;
//            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql);
//            sendName = returnList.get(0).get("name")+"";
//
//            Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode);
//            List<String> roleList = (List<String>)resultMap.get("roleList");
//            List<RoleVo> roleVoLists= new ArrayList<>();
//            for(String one:roleList){
//                RoleVo roleVo = new RoleVo();
//                roleVo.setCode(one);
//                roleVoLists.add(roleVo);
//            }
//            healthEduArticlePatient.setRoleList(roleVoLists);
//            healthEduArticlePatient.setCurrentUserRoleCode(currentUserRoleCode);
//            healthEduArticlePatient.setCurrentUserRoleLevel(currentUserRoleLevel);
//        }else{
//            healthEduArticlePatient.setCurrentUserRoleCode(doctor.getHospital());
//            healthEduArticlePatient.setCurrentUserRoleLevel("4");
//        }
//        healthEduArticlePatient.setSendType(sendType);
//        healthEduArticlePatient.setDoctorCode(sendCode);
//        healthEduArticlePatient.setSendName(sendName);
//        healthEduArticlePatient.setAdminTeamCode(teamId);
//        healthEduArticlePatient.setLeaveWords(leaveWords);
//        if (doctor != null) {
//            healthEduArticlePatient.setDoctorName(doctor.getName());
//            healthEduArticlePatient.setHospital(doctor.getHospital());
//            healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
//            healthEduArticlePatient.setTown(doctor.getTown());
//            healthEduArticlePatient.setTownName(doctor.getTownName());
//            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : "");
//            healthEduArticlePatient.setSendPic(doctor.getPhoto());
//            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : "");
//        }
//        healthEduArticlePatient.setBatchNo(batchNo);
//        healthEduArticlePatient.setCreateTime(new Date());
//
//        //通过文章id 获取文章详情
//        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
//
//        healthEduArticlePatient.setArticleId(article.get("articleId") + "");
//        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + "");
//        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + "");
//        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + "");
//        healthEduArticlePatient.setAttachedMessage(sendMessage);
//        healthEduArticlePatient.setArticleType(article.get("articleType") + "");
//        healthEduArticlePatient.setLevel(article.get("articlelevel") + "");
//        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
//        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
//        healthEduArticlePatient.setType("1");//文章
////        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+);
//        healthEduArticlePatient.setPatients(patientList);
        List<HealthEduArticleES> healthEduArticleESList = new ArrayList<>();
        Doctor doctor = doctorDao.findByCode(sendCode);
@ -551,21 +360,6 @@ public class JMJkEduArticleService extends BaseService {
        String sendName = "";
        List<DoctorRole> roleList = doctorRoleDao.findUserRole(sendCode);
        if(sendType==2){
//            String resultSql ="";
//            String whereSql ="";
//            switch (currentUserRoleLevel){
//                case "1":{resultSql +=" DISTINCT (province_name) as name";
//                    whereSql+=" and province ='"+currentUserRoleCode+"'";break;}
//                case "2":{resultSql +=" DISTINCT (city_name) as name";
//                    whereSql+=" and city ='"+currentUserRoleCode+"'";break;}
//                case "3":{resultSql +=" DISTINCT (town_name) as name";
//                    whereSql+=" and town ='"+currentUserRoleCode+"'";break;}
//                case "4":{resultSql +=" DISTINCT (name) as name";
//                    whereSql+=" and code ='"+currentUserRoleCode+"'";break;}
//            }
//            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ;
//            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql);
//            sendName = returnList.get(0).get("name")+"";
            //通过当前的登陆角色获取角色名称
            for(DoctorRole ones :roleList){
                if(ones.getCode().equals(currentUserRoleCode)){
@ -654,7 +448,7 @@ public class JMJkEduArticleService extends BaseService {
        e.setPatientCode(null);
        e.setPatientName(null);
        elastricSearchSave.save(e, esIndex, esType);
        thirdJkEduArticleService.saveBehavior(articleId,doctor.getCode(),7,patientSet.size());
        return healthEduArticleESList;
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
@ -680,61 +474,12 @@ public class JMJkEduArticleService extends BaseService {
     */
    public void initPatient(Set<String> patientSet, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) {
        //全选的时候前端传0,后台要去数据库再查询一次
//        if ("0".equals(labelUnit)) {
//            //查找全部的下属单位
////            String sql = "select Group_concat(code) code  from dm_hospital  where level=2 and town = '350211'";
////            labelUnit = jdbcTemplate.queryForObject(sql, String.class);
//            List<DictModel> dictModels = labelService.getUnitLabels(userCode);
//            labelUnit ="";
//            for(DictModel one:dictModels){
//                labelUnit+=","+one.getCode();
//            }
//
//            labelUnit=labelUnit.substring(1);
//        }
//        if ("0".equals(labelSex)) {
//            //查找全部的性别
//            labelSex = "1,2";
//        }
//        if ("0".equals(labelServe)) {
//            //查找全部的服务类型
//            String sql = "select Group_concat(s.code) from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
//            labelServe = jdbcTemplate.queryForObject(sql, String.class);
//        }
//        if ("0".equals(labelDisease)) {
//            //查找全部的疾病标签
//            String sql = "select Group_concat(s.label_code)  from wlyy_sign_patient_label s where s.label_type=3 and status=1";
//            labelDisease = jdbcTemplate.queryForObject(sql, String.class);
//        }
//        if ("0".equals(labelHealth)) {
//            //查找全部的健康情况
//            String sql = "select Group_concat(s.label_code)  from wlyy_sign_patient_label s where s.label_type=2 and status=1";
//            labelHealth = jdbcTemplate.queryForObject(sql, String.class);
//        }
        String tableSql = " select p.code from wlyy_sign_family w left join dm_hospital h on w.hospital=h.code ";
        String whereSql = " where w.status>0  ";
        //通过登录的角色区域权限 限制所属患者条件
//        Map<String,Object> resultLevel = labelService.fetchUserHighestAuthority(userCode);
//        List<String> list =  (List<String>)resultLevel.get("roleList");
//        Integer level = (Integer)resultLevel.get("level");
//        StringBuilder role = new StringBuilder();
//        for(String one :list){
//            role.append(",'"+one+"'");
//        }
//        String roleSql = !StringUtils.isEmpty(role+"")?role.substring(1):"";
//        if(StringUtils.isEmpty(roleSql)){
//
//            switch (level){
//                case 1:{whereSql+=" and h.province in ("+role+")" ;break;}
//                case 2:{whereSql+=" and h.city in ("+role+")" ;break;}
//                case 3:{whereSql+=" and h.town in ("+role+")" ;break;}
//                case 4:{whereSql+=" and h.code in ("+role+")" ;break;}
//            }
//
//        }
        if(!StringUtils.isEmpty(labelUnit)){
            switch (currentUserRoleLevel){
                case "1":{whereSql+=" and h.city in ("+labelUnit+")" ;break;}
@ -758,31 +503,21 @@ public class JMJkEduArticleService extends BaseService {
        if (!StringUtils.isEmpty(labelHealth) || !StringUtils.isEmpty(labelDisease)) {
            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
            whereSql += " and l.status=1 ";
    
            if (!StringUtils.isEmpty(labelHealth) && !StringUtils.isEmpty(labelDisease)) {
                whereSql += " and ( (l.label_type = 2 AND l.label in (" + labelHealth + ") ) or (l.label_type = 3 AND l.label in (" + labelDisease + ") ))";
            }else {
                if(!StringUtils.isEmpty(labelHealth)){
                    whereSql += " and (l.label_type = 2 AND l.label in (" + labelHealth + "))";
                }
                
                if(!StringUtils.isEmpty(labelDisease)){
                    whereSql += " and (l.label_type = 3 AND l.label in (" + labelDisease + "))";
                }
            }
        }
//        if (!StringUtils.isEmpty(labelDisease)) {
//            if (!whereSql.endsWith(" and ( ")) {
//                whereSql += " or (l.label_type = 3 AND l.label in (" + labelDisease + "))) ";
//            } else {
//                whereSql += " l.label_type = 3 AND l.label in (" + labelDisease + ")) ";
//            }
//        }
//        if (!StringUtils.isEmpty(labelHealth) || !StringUtils.isEmpty(labelDisease)) {
//            whereSql += ")";
//        }
        
        tableSql += " left join wlyy_patient p on p.code=w.patient AND p.openid IS NOT NULL and p.openid <>''";
        if (!StringUtils.isEmpty(labelSex)) {
            whereSql += " and p.sex in (" + labelSex + ") ";
@ -960,112 +695,10 @@ public class JMJkEduArticleService extends BaseService {
        return result;
    }
//    /**
//     * 医生推送文章初始化被推患者信息
//     * @param patientSet
//     * @param labelType
//     * @param condition
//     * @param groupType
//     * @param teamId
//     * @param doctorCode
//     */
//    public void initPatients(Set<String> patientSet, String labelType, String condition, String groupType,Long teamId,String doctorCode) {
//
//        String adminTeamCodetemp = "";
//        if(teamId!=null){
//            adminTeamCodetemp+=teamId.longValue();
//        }else{
//            List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
//            for(AdminTeam one:teamList){
//                adminTeamCodetemp+=","+one.getId();
//            }
//            adminTeamCodetemp=adminTeamCodetemp.length()>0?adminTeamCodetemp.substring(1):"";
//        }
//
//        String[] cond = {};
//        String[] group = {};
//        if (!StringUtils.isEmpty(condition)) {
//            cond = condition.split(",");
//        }
//        StringBuilder whereSql = new StringBuilder();
//        String tableSql = "";
//        for (String one : cond) {
//            if ("1".equals(one)) {//有绑定设备
//                tableSql = " LEFT JOIN wlyy_patient_device d on d.user=aa.patient and d.device_id is not null ";
//            } else if ("2".equals(one)) {//孕产妇
//                whereSql.append(" and tt LIKE '%41%' ");
//            } else if ("3".equals(one)) {//65岁以上老年人
//                whereSql.append(" and tt LIKE '%13%' ");
//            }
//        }
//
//        if (!StringUtils.isEmpty(groupType)) {
//            group = groupType.split(",");
//        }
//        String sql = "";
//        List<String> groupPatient = null;
//        List<String> resultList = new ArrayList<>();
//        switch (labelType) {
//            case "1": {
//                for (String one : group) {
//                    sql = " SELECT DISTINCT(aa.patient)  FROM " +
//                            " ( SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
//                            " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l, " +
//                            " wlyy_sign_family_server q WHERE w. STATUS > 0 AND l. STATUS = 1 AND w.admin_team_code in (" +adminTeamCodetemp+")"+
//                            " AND w.patient = l.patient " +//AND LEFT (w.hospital, 6) = '350211' " +
//                            " AND w. CODE = q.sign_code AND q.server_type = 1 ) a " +
//                            " GROUP BY a.patient HAVING 1 = 1  " + whereSql +  " and tt LIKE '%" + labelType + one + "%'  ) aa " + tableSql;
//                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
//                    resultList.addAll(groupPatient);
//                }
//                break;
//            }
//            case "2": {
//                for (String one : group) {
//                    sql = " select DISTINCT(aa.patient) from ( " +
//                            " SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
//                            " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
//                            " WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
//                            " GROUP BY a.patient HAVING 1=1 " + whereSql + "  and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
//                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
//                    resultList.addAll(groupPatient);
////                }
//                }
//                break;
//            }
//            case "3": {
//                for (String one : group) {
//                    sql = " select DISTINCT(aa.patient)  from ( " +
//                            " SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
//                            " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
//                            " WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
//                            " GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
//                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
//                    resultList.addAll(groupPatient);
////                }
//                }
//                break;
//            }
//            case "4": {
//                for (String one : group) {
//                    sql = " select DISTINCT(aa.patient) from ( " +
//                            " SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
//                            " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
//                            " WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
//                            " GROUP BY a.patient HAVING 1=1 " + whereSql.toString() + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
//                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
//                    resultList.addAll(groupPatient);
////                }
//                }
//                break;
//            }
//        }
//        patientSet.addAll(resultList);
//    }
    
    
    public void readAllArticle(String patient)throws Exception{
    
//        JestClient jestClient = null;
//
//        try {
@ -1107,16 +740,16 @@ public class JMJkEduArticleService extends BaseService {
//        for (HealthEduArticlePatient healthEduArticlePatient: esList) {
//            healthEduArticlePatient.setIsread("1");
//        }
        
    }
    
    /**
     * 一键修改居民推送文章的文章为已读
     * @param patient
     */
    public void readAllArticleNew(String patient,String firstLevelCategoryId){
        JestClient jestClient = null;
    
        try {
            jestClient = elasticFactory.getJestClient();
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -1124,7 +757,8 @@ public class JMJkEduArticleService extends BaseService {
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("patientCode", patient))
                            .must(QueryBuilders.matchQuery("firstLevelCategoryId", firstLevelCategoryId))
            );
                            .must(QueryBuilders.matchQuery("isRead", "0"))
            ).size(10000);
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
            SearchResult result = jestClient.execute(search);
            List<HealthEduArticleES> dataList = result.getSourceAsObjectList(HealthEduArticleES.class);
@ -1151,7 +785,7 @@ public class JMJkEduArticleService extends BaseService {
            }
        }
    }
    
    /**
     * 居民单条文章增加已读状态
     * @param patient
@ -1159,7 +793,7 @@ public class JMJkEduArticleService extends BaseService {
     */
    public void readPatientArticle(String patient,String articleId){
        JestClient jestClient = null;
        
        try {
            jestClient = elasticFactory.getJestClient();
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
@ -1194,14 +828,14 @@ public class JMJkEduArticleService extends BaseService {
            }
        }
    }
    
    public JSONArray pushArticleLogs(int page, int pagesize, String patientCode,String level1Type) throws Exception {
        page = (page - 1) * pagesize;
        String sql = "SELECT * FROM " + esType + "  where patientCode= '" + patientCode + "' and userType = 1";
        
        if(!StringUtils.isEmpty(level1Type)){
            sql= sql + " and firstLevelCategoryId = '"+level1Type+"' ";
        }
@ -1209,7 +843,7 @@ public class JMJkEduArticleService extends BaseService {
        if(pagesize !=0){
            sql= sql+  " limit " + page + "," + pagesize;
        }
        
        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql, HealthEduArticleES.class, esIndex, esType);
        HealthEduArticlePatientModel heapm = null;
        JSONObject article = null;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jkEduArticle/ThirdJkEduArticleService.java

@ -72,7 +72,7 @@ public class ThirdJkEduArticleService extends BaseService {
    private DoctorRoleDao doctorRoleDao;
    @Autowired
    private HospitalDao hospitalDao;
    
    //    private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
//    private String baseUrl = "http://172.17.110.230:83/WsPlatform/rest";
//    private String baseUrl = articleBaseUrl+"/WsPlatform/rest";

+ 39 - 41
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEduPC/DoctorJMJkEduArticlePCController.java

@ -156,7 +156,7 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
                        articleids.add(pushresponse.getJSONObject(i).getString("articleId"));
                    }
                }
                StringBuffer sql3 = null;
                JSONArray datas = response.getJSONArray("aaData");
                if(datas.size() > 0 && !articleids.isEmpty()){
                    for (int i = 0; i < datas.size(); i++) {
@ -166,10 +166,8 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
                        }else{
                            datas.getJSONObject(i).put("ispush","0");
                        }
//                        sql3 = new StringBuffer();
//                        sql3.append("SELECT COUNT(*) as num FROM "+esType+" WHERE  userType=2 AND articleId='"+dataarticleid+"'");
//                        Long num = elasticsearchUtil.excuteForLong(sql3.toString(), esType, esIndex);
//                        datas.getJSONObject(i).put("ispush","0");
//                        1.4.1版本正式环境目前的推送数量是以commentnumber字段获取,等1.4.2版本的时候调整为pushnumber
//                        datas.getJSONObject(i).put("commentnumber",datas.getJSONObject(i).getString("pushnumber"));
                    }
                    response.put("aaData",datas);
                }
@ -185,23 +183,23 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
    @RequestMapping(value = "authenArticlePCList", method = RequestMethod.GET)
    @ApiOperation("查询pc端文章认证列表")
    public  String authenArticlePCList(@ApiParam(name = "firstLevelCategoryId", value = "文章一级分类")
                                      @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                      @ApiParam(name = "secondLevelCategoryId", value = "文章二级分类")
                                      @RequestParam(value = "secondLevelCategoryId", required = false) String secondLevelCategoryId,
                                      @ApiParam(name = "insertTimeStart", value = "新增文章开始时间")
                                      @RequestParam(value = "insertTimeStart", required = false) String insertTimeStart,
                                      @ApiParam(name = "insertTimeEnd", value = "新增文章结束时间")
                                      @RequestParam(value = "insertTimeEnd", required = false) String insertTimeEnd,
                                      @ApiParam(name = "articleTitle", value = "文章标题关键字")
                                      @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                      @ApiParam(name = "isAuthentication", value = "是否认证")
                                      @RequestParam(value = "isAuthentication", required = false) String isAuthentication,
                                      @ApiParam(name = "iDisplayStart", value = "当前页")
                                      @RequestParam(value = "iDisplayStart", required = true) Integer page,
                                      @ApiParam(name = "iDisplayLength", value = "是否过滤我的文章")
                                      @RequestParam(value = "iDisplayLength", required = true) Integer pageSize,
                                      @ApiParam(name = "sEcho", value = "插件自带")
                                      @RequestParam(value = "sEcho", required = false) Integer sEcho){
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "secondLevelCategoryId", value = "文章二级分类")
                                       @RequestParam(value = "secondLevelCategoryId", required = false) String secondLevelCategoryId,
                                       @ApiParam(name = "insertTimeStart", value = "新增文章开始时间")
                                       @RequestParam(value = "insertTimeStart", required = false) String insertTimeStart,
                                       @ApiParam(name = "insertTimeEnd", value = "新增文章结束时间")
                                       @RequestParam(value = "insertTimeEnd", required = false) String insertTimeEnd,
                                       @ApiParam(name = "articleTitle", value = "文章标题关键字")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "isAuthentication", value = "是否认证")
                                       @RequestParam(value = "isAuthentication", required = false) String isAuthentication,
                                       @ApiParam(name = "iDisplayStart", value = "当前页")
                                       @RequestParam(value = "iDisplayStart", required = true) Integer page,
                                       @ApiParam(name = "iDisplayLength", value = "是否过滤我的文章")
                                       @RequestParam(value = "iDisplayLength", required = true) Integer pageSize,
                                       @ApiParam(name = "sEcho", value = "插件自带")
                                       @RequestParam(value = "sEcho", required = false) Integer sEcho){
        try {
@ -220,14 +218,14 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
    public  String saveOrUpdateArticleQR(
//                                        @ApiParam(name = "currentRoleLevel", value = "当前登录角色的级别")
//                                         @RequestParam(value = "currentRoleLevel", required = true) String currentRoleLevel,
                                         @ApiParam(name = "identification", value = "认证标识文字")
                                         @RequestParam(value = "identification", required = false) String identification,
                                         @ApiParam(name = "position", value = "位置")
                                         @RequestParam(value = "position", required = false) Integer position,
                                         @ApiParam(name = "imgUrl", value = "二维码图片地址")
                                         @RequestParam(value = "imgUrl", required = false) String imgUrl,
                                         @ApiParam(name = "id", value = "认证标识id")
                                         @RequestParam(value = "id", required = false) Integer id){
            @ApiParam(name = "identification", value = "认证标识文字")
            @RequestParam(value = "identification", required = false) String identification,
            @ApiParam(name = "position", value = "位置")
            @RequestParam(value = "position", required = false) Integer position,
            @ApiParam(name = "imgUrl", value = "二维码图片地址")
            @RequestParam(value = "imgUrl", required = false) String imgUrl,
            @ApiParam(name = "id", value = "认证标识id")
            @RequestParam(value = "id", required = false) Integer id){
        try{
            jmJkEduArticleService.saveOrUpdateArticleQR(getCurrentRoleLevel(),getCurrentRoleCode(),position,imgUrl,getUID(),id,identification);
@ -241,17 +239,17 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
    @RequestMapping(value = "authenticationArticle", method = RequestMethod.POST)
    @ApiOperation("文章认证")
    public  String authenticationArticle(@ApiParam(name = "articleId", value = "文章id,多个文章‘,’隔开")
                                          @RequestParam(value = "articleId", required = true) String articleId,
                                          @ApiParam(name = "isAuthentication", value = "认证,0取消认证,1认证")
                                          @RequestParam(value = "isAuthentication", required = true) String isAuthentication,
                                          @ApiParam(name = "firstLevelCategoryId", value = "文章一级分类")
                                          @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                          @ApiParam(name = "firstLevelCategoryName", value = "文章一级分类名称")
                                          @RequestParam(value = "firstLevelCategoryName", required = false) String firstLevelCategoryName,
                                          @ApiParam(name = "secondLevelCategoryId", value = "文章二级分类")
                                          @RequestParam(value = "secondLevelCategoryId", required = false) String secondLevelCategoryId,
                                          @ApiParam(name = "secondLevelCategoryName", value = "文章二级分类名称")
                                          @RequestParam(value = "secondLevelCategoryName", required = false) String secondLevelCategoryName){
                                         @RequestParam(value = "articleId", required = true) String articleId,
                                         @ApiParam(name = "isAuthentication", value = "认证,0取消认证,1认证")
                                         @RequestParam(value = "isAuthentication", required = true) String isAuthentication,
                                         @ApiParam(name = "firstLevelCategoryId", value = "文章一级分类")
                                         @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                         @ApiParam(name = "firstLevelCategoryName", value = "文章一级分类名称")
                                         @RequestParam(value = "firstLevelCategoryName", required = false) String firstLevelCategoryName,
                                         @ApiParam(name = "secondLevelCategoryId", value = "文章二级分类")
                                         @RequestParam(value = "secondLevelCategoryId", required = false) String secondLevelCategoryId,
                                         @ApiParam(name = "secondLevelCategoryName", value = "文章二级分类名称")
                                         @RequestParam(value = "secondLevelCategoryName", required = false) String secondLevelCategoryName){
        try{
            jmJkEduArticleService.authenticationArticle(articleId,isAuthentication,firstLevelCategoryId,firstLevelCategoryName,secondLevelCategoryId,secondLevelCategoryName);
            return success("认证成功!");

+ 25 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/HealthEduArticlePatientModel.java

@ -41,6 +41,8 @@ public class HealthEduArticlePatientModel {
    private Integer commentNumber=0;//文章评论数
    @ApiModelProperty(value = "文章点赞数", required = false, access = "response")
    private Integer pointNumber=0;//文章点赞数
    @ApiModelProperty(value = "文章发送数", required = false, access = "response")
    private Integer pushNumber=0;//文章发送数
    @ApiModelProperty(value = "文章阅读数", required = false, access = "response")
    private Long readNumber=0L;//文章阅读数
    @ApiModelProperty(value = "封面图", required = false, access = "response")
@ -55,7 +57,7 @@ public class HealthEduArticlePatientModel {
    private Integer collectionNumber;//收藏数
    @ApiModelProperty(value = "文章来源", required = false, access = "response")
    private String articleSource;//文章来源
    
    private String computeTime;//时间
    private String photo;//医生头像
    private String operatorName;//文章作者
@ -204,43 +206,43 @@ public class HealthEduArticlePatientModel {
    public void setOperatorName(String operatorName) {
        this.operatorName = operatorName;
    }
    
    public Integer getSendType() {
        return sendType;
    }
    
    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }
    
    public String getIsread() {
        return isread;
    }
    
    public void setIsread(String isread) {
        this.isread = isread;
    }
    
    public String getLeaveWords() {
        return leaveWords;
    }
    
    public void setLeaveWords(String leaveWords) {
        this.leaveWords = leaveWords;
    }
    
    public String getLevel1TypeName() {
        return level1TypeName;
    }
    
    public void setLevel1TypeName(String level1TypeName) {
        this.level1TypeName = level1TypeName;
    }
    
    public String getLevel2TypeName() {
        return level2TypeName;
    }
    
    public void setLevel2TypeName(String level2TypeName) {
        this.level2TypeName = level2TypeName;
    }
@ -252,11 +254,11 @@ public class HealthEduArticlePatientModel {
    public void setCollectionNumber(Integer collectionNumber) {
        this.collectionNumber = collectionNumber;
    }
    
    public String getArticleSource() {
        return articleSource;
    }
    
    public void setArticleSource(String articleSource) {
        this.articleSource = articleSource;
    }
@ -268,11 +270,19 @@ public class HealthEduArticlePatientModel {
    public void setReadNumber(Long readNumber) {
        this.readNumber = readNumber;
    }
    
    public Integer getPushNumber() {
        return pushNumber;
    }
    public void setPushNumber(Integer pushNumber) {
        this.pushNumber = pushNumber;
    }
    public String getCzrq() {
        return czrq;
    }
    
    public void setCzrq(String czrq) {
        this.czrq = czrq;
    }

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkEduArticle/ThirdJkEduArticleController.java

@ -85,7 +85,7 @@ public class ThirdJkEduArticleController extends BaseController {
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getRepUID(),userType,myArticle);
//            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"812f75071f434fde9a1fb64c6213a897",userType,myArticle);
    
            //判断文章列表是否有推送过该居民
            if(org.apache.commons.lang3.StringUtils.isNotBlank(patient)){
                com.alibaba.fastjson.JSONArray pushresponse = jmJkEduArticleService.pushArticleLogs(0,0,patient,"");
@ -95,7 +95,7 @@ public class ThirdJkEduArticleController extends BaseController {
                        articleids.add(pushresponse.getJSONObject(i).getString("articleId"));
                    }
                }
        
                if(response.size() > 0 && !articleids.isEmpty()){
                    for (int i = 0; i < response.size(); i++) {
                        String dataarticleid = response.getJSONObject(i).getString("articleId");
@ -122,11 +122,11 @@ public class ThirdJkEduArticleController extends BaseController {
                                 @RequestParam(value = "userType", required = false) String userType){
        try {
            com.alibaba.fastjson.JSONObject response = thirdJkEduArticleService.getArticalById(articleId,getUID());
            
            if("2".equals(userType)){
                jmJkEduArticleService.readPatientArticle(getRepUID(),articleId);
            }
            
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
@ -312,7 +312,7 @@ public class ThirdJkEduArticleController extends BaseController {
            return error(-1,"查询失败!");
        }
    }
    
    @RequestMapping(value = "getCategoryByName",method = RequestMethod.GET)
    @ApiOperation("根据一级类别名称获取二级分类下得所有分类")
    public String getCategoryList(@ApiParam(name = "name", value = "类别名称")