Explorar el Código

集美宣教代码提交

liuwenbin hace 7 años
padre
commit
4c4d900c53
Se han modificado 20 ficheros con 1375 adiciones y 864 borrados
  1. 26 8
      common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticlePatient.java
  2. 25 0
      common/common-entity/src/main/java/com/yihu/es/entity/RoleVo.java
  3. 1 1
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  4. 1 1
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java
  5. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  6. 708 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java
  7. 11 285
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java
  8. 3 272
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  9. 241 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEdu/DoctorJMJkEduArticleController.java
  10. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEduPC/DoctorJMJkEduArticlePCController.java
  11. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  12. 3 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  13. 18 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/jimeiJkEdu/PatientJMJkEduArticleController.java
  14. 24 93
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java
  16. 5 186
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  17. 74 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java
  18. 205 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkEduArticle/ThirdJkEduArticleController.java
  19. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduLableController.java
  20. 5 5
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

+ 26 - 8
common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticlePatient.java

@ -22,7 +22,7 @@ public class HealthEduArticlePatient {
    private String patientName;    // 患者标识
    private String doctorCode;  //推送的医生code(包括医生本人、卫计委)
    private String doctorName;  //推送的医生名称(包括医生本人、卫计委)
    private String sendCode;   // 发送人code
//    private String sendCode;   // 发送人code
    private String sendName;   // 发送人名称
    private String sendPic;   // 发送人头像
    private String sendSex;   // 发送人性别
@ -53,6 +53,8 @@ public class HealthEduArticlePatient {
    private String type;//推送类型 1:文章 2:健康课程
    private String articleUrl;//集美宣教,文章的url
    private List<Patient> patients;//被推送文章的患者
    private String operatorId;//文章作者Id
    private List<RoleVo> roleList;//发送者角色
    public String getId() {
        return id;
@ -63,13 +65,13 @@ public class HealthEduArticlePatient {
    }
    public String getSendCode() {
        return sendCode;
    }
    public void setSendCode(String sendCode) {
        this.sendCode = sendCode;
    }
//    public String getSendCode() {
//        return sendCode;
//    }
//
//    public void setSendCode(String sendCode) {
//        this.sendCode = sendCode;
//    }
    public String getSendName() {
        return sendName;
@ -310,4 +312,20 @@ public class HealthEduArticlePatient {
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getOperatorId() {
        return operatorId;
    }
    public void setOperatorId(String operatorId) {
        this.operatorId = operatorId;
    }
    public List<RoleVo> getRoleList() {
        return roleList;
    }
    public void setRoleList(List<RoleVo> roleList) {
        this.roleList = roleList;
    }
}

+ 25 - 0
common/common-entity/src/main/java/com/yihu/es/entity/RoleVo.java

@ -0,0 +1,25 @@
package com.yihu.es.entity;
/**
 * Created by ${liuwenbin} on 2017/11/29.
 */
public class RoleVo {
    private String name;
    private String code;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

+ 1 - 1
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -25,7 +25,7 @@ import com.yihu.wlyy.repository.statistics.WlyySignFamilyCodeDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.HealthEducationArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;

+ 1 - 1
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java

@ -1,4 +1,4 @@
package com.yihu.wlyy.service.third.fzzb;
package com.yihu.wlyy.service.third.jkEduArticle;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

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

@ -28,7 +28,7 @@ import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.SignUploadTask;
@ -140,7 +140,7 @@ public class FamilyContractService extends BaseService {
    @Autowired
    private FamilyContractService familyContractService;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    private ThirdJkEduArticleService healthEducationArticleService;
    @Autowired
    private ImUtill ImUtill;

+ 708 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -0,0 +1,708 @@
package com.yihu.wlyy.service.jimeiJkEdu;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.es.entity.RoleVo;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * Created by liuwenbin on 2017/8/12.
 * 集美健教
 */
@Service
public class JMJkEduArticleService extends BaseService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Autowired
    private GcLabelService labelService;
    @Autowired
    private AdminTeamService teamService;
    /**
     *
     * @param page
     * @param pagesize
     * @param sendCode
     * @param firstLevelCategoryId 一级分类
     * @param myArticle (条件:我的文章)
     * @param sendType  1、医生,2、卫计委(管理员)
     * @return
     * @throws Exception
     */
    public List<HealthEduArticlePatientModel> pushArticleList(int page, int pagesize, String sendCode,  String firstLevelCategoryId,Integer myArticle,Integer sendType) throws Exception {
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
//        if(loginType==2){
//
//            String sql = "select r.code as roleCode from wlyy_user_role u " +
//                    "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "' and LENGTH(u.role)=6";
//            List<Map<String, Object>> resultMap = jdbcTemplate.queryForList(sql);
//            sendCode = resultMap.size()>0?resultMap.get(0).get("roleCode").toString():sendCode;
//        }
        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
                " where  doctorCode='" + sendCode + "'");
        if(sendType==1){
            sql2.append(" and sendType='"+sendType+"' ");
        }
        if(!StringUtils.isEmpty(firstLevelCategoryId)){
            sql2.append("and level1Type="+firstLevelCategoryId);
        }
        if(myArticle==1){
            sql2.append("and operatorId="+sendCode);
        }
        sql2.append("  order by createTime limit " + page + "," + pagesize);
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        Map<String, HealthEduArticlePatientModel> result = new HashMap<>();
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
        Doctor doctor = null;
        for (HealthEduArticlePatient one : esList) {
            article = thirdJkEduArticleService.getArticalById(one.getArticleId());
            if (result.get(one.getArticleId()) != null) {
                heapm = result.get(one.getArticleId());
            } else {
                heapm = new HealthEduArticlePatientModel();
            }
            heapm.setSendName(one.getSendName());
            heapm.setSendCode(one.getDoctorCode());
            heapm.setCreateTime(one.getCreateTime());
            heapm.setArticleId(article.getString("articleId"));
            heapm.setAttachedTitle(article.getString("articleTitle"));
            heapm.setAttachedContent(article.getString("articleContent"));
            heapm.setArticleType(article.getString("articleType"));
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
            heapm.setArticleCover(article.getString("articleCover"));//封面
            heapm.setComputeTime(computeTime(article.getString("insertTime")));
            doctor = doctorDao.findByCode(one.getDoctorCode());
            heapm.setPhoto(doctor.getPhoto());
            heapm.setOperatorName(article.getString("operatorName"));
            // heapm.setTime();//时间  xx小时前  2017-10-11
            result.put(one.getArticleId(), heapm);
        }
        List<HealthEduArticlePatientModel> resultList = new ArrayList<>();
        for (Map.Entry<String, HealthEduArticlePatientModel> entry : result.entrySet()) {
            resultList.add(entry.getValue());
        }
        return resultList;
    }
    public static String computeTime(String create) {
        Date createDate = DateUtil.strToDate(create, "yyyy-MM-dd HH:mm:ss.SSS");
        Date nowDate = new Date();
        //计算2个时间差
        Long l = nowDate.getTime() - createDate.getTime();
        long hour = l / (60 * 60 * 1000); //小时
        long min = l / (60 * 1000);//分钟
        long s = l / 1000;//秒
        if(s<60){
            return s+"秒前";
        }
        if(min<60){
            return min+"分钟前";
        }
        if(hour<24){
            return hour+"小时前";
        }
        return DateUtil.dateToStr(createDate,"yyyy-MM-dd");
    }
    /**
     * 获取推送数量的总数(废弃)
     * @param sendCode
     * @param sendType 1、卫计委,2、医生
     * @return
     */
    public Long pushArticleListCount(String sendCode,int sendType) {
        if(sendType==1){
            String sql = "select r.code as roleCode from wlyy_user_role u " +
                    "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "'"+ " and LENGTH(u.role)=6";;
            Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
            sendCode = resultMap.get("roleCode").toString();
        }
        StringBuffer sql = new StringBuffer("select count(distinct articleId) count  from   " + esType +
                " where  sendCode='" + sendCode + "' ");
        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
    }
//    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) 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);
        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;
    }
//    public Map<String, Object> getUnitLabels(String userId) {
//        String sql2 = "select r.code as roleCode from wlyy_user_role u " +
//                "left join wlyy_role r on r.`code`=u.role where u.user='" + userId + "'";
//        List<Map<String, Object>> resultMap = jdbcTemplate.queryForList(sql2);
//        String whereSql = "";
//        String role = fetchUserHighestAuthority(resultMap);
//        String resultSql = "";
//        if(role.length()==6){
//
//            if("00".equals(role.substring(4))){
//                resultSql +=" DISTINCT (city_name) as name";
//                whereSql+=" and city = '"+role+"'";
//            }else{
//                resultSql +=" DISTINCT (town_name) as name";
//                whereSql+=" and town = '"+role+"'";
//            }
//        }else{
//            resultSql +=" DISTINCT (name) as name ";
//            whereSql+=" and code = '"+role+"'";
//        }
//
//        String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ;
//        List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql);
//
//        return returnList.get(0);
//    }
//    /**
//     * 获取用户的最高角色权限
//     * @param resultMap
//     * @return
//     */
//    public String fetchUserHighestAuthority(List<Map<String, Object>> resultMap){
//        String result = "";
//        String role = "";
//        for(Map<String, Object> one:resultMap){
//            role = one.get("roleCode").toString();
//            if(role.length()==6){
//                if("00".equals(role.substring(4))){//市级
//                    return role;
//                }else {
//                    result = role;
//                }
//            }else{
//                if(StringUtils.isEmpty(result)||result.length()>6){
//                    result = role;
//                }
//            }
//        }
//        return result;
//    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode) throws Exception {
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId);
        Set<String> patientSet = new HashSet<>();
        initPatient(patientSet, labelUnit, labelSex, labelServe, labelDisease, labelHealth,userCode);
        long num = patientSet.size();
        JSONObject result = new JSONObject();
        result.put("num", num);
        result.put("articleTitle", article.getString("articleTitle"));
        return result;
    }
    /**
     * 卫计委(管理员)推送文章初始化患者人数
     * @param patientSet
     * @param labelUnit
     * @param labelSex
     * @param labelServe
     * @param labelDisease
     * @param labelHealth
     * @param userCode
     */
    public void initPatient(Set<String> patientSet, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode) {
        //全选的时候前端传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(labelServe)) {
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
            whereSql += " and s.server_type in (" + labelServe + " ) ";
        }
        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 ";
            whereSql += " and ( ";
        }
        if (!StringUtils.isEmpty(labelHealth)) {
            whereSql += " (l.label_type = 2 AND l.label in (" + labelHealth + ")) ";
        }
        if (!StringUtils.isEmpty(labelDisease)) {
            if (!whereSql.endsWith(" and ( ")) {
                whereSql += " or (l.label_type = 3 AND l.label in (" + labelDisease + "))) ";
            } else {
                whereSql += " (l.label_type = 1 AND l.label in (" + labelDisease + "))) ";
            }
        }
        tableSql += " left join wlyy_patient p on p.code=w.patient ";
        if (!StringUtils.isEmpty(labelSex)) {
            whereSql += " and p.sex in (" + labelSex + ") ";
        }
        if (!StringUtils.isEmpty(labelUnit)) {
            whereSql += " and w.hospital in (" + labelUnit + ") ";
        }
        List<String> groupPatient = jdbcTemplate.queryForList(tableSql + whereSql, String.class);
        patientSet.addAll(groupPatient);
    }
    /***
     * 医生-查询推送对象
     * @param labelType
     * @param condition
     * @param teamId
     * @return
     */
    public JSONArray labelWithPushPatients(String labelType, String condition, 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 = {};
        if (!StringUtils.isEmpty(condition)) {
            cond = condition.split(",");
        }
        StringBuilder whereSql = new StringBuilder();
        String tableSql = "";
        String sql ="";
        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)) {//孕产妇
//                temp.add("41");
                whereSql.append(" and tt LIKE '%41%' ");
            } else if ("3".equals(one)) {//65岁以上老年人
//                temp.add("13");
                whereSql.append(" and tt LIKE '%13%' ");
            }
        }
        List<DictModel> returnList = null;
        Map<String, Object> map = null;
        JSONArray re = new JSONArray();
        switch (labelType) {
            case "1": {
                sql = "select s.code code,s.name as name from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
                    sql = " SELECT count(DISTINCT(aa.patient)) AS num 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 AND tt LIKE '%1" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
            case "2": {
                sql = "select label_code code,label_name as name from wlyy_sign_patient_label  where label_type=2 and status=1";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
                    sql = " select count(DISTINCT(aa.patient)) as num 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 " +//AND w.team_code=" +teamCode+
                            " 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 tt LIKE '%2" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
            case "3": {
                sql = "select label_code code, label_name as name from wlyy_sign_patient_label  where label_type=3 and status=1";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
                    sql = " select count(DISTINCT(aa.patient)) as num 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 tt LIKE '%3" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
            case "4": {
                sql = "select label_code code, label_name as name from wlyy_sign_patient_label  where label_type=4 and status=1";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
                    sql = " select count(DISTINCT(aa.patient)) as num 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 tt LIKE '%4" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
        }
        return re;
    }
    public JSONObject pushArticleConfirm(String articleId,String labelType, String condition, String groupType,Long teamId,String doctorCode) throws Exception{
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId);
        Set<String> patientSet = new HashSet<>();
        initPatients(patientSet,labelType,condition,groupType,teamId,doctorCode);
        long num = patientSet.size();
        JSONObject result = new JSONObject();
        result.put("num", num);
        result.put("articleTitle", article.getString("articleTitle"));
        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);
    }
}

+ 11 - 285
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java

@ -1,4 +1,4 @@
package com.yihu.wlyy.service.third.fzzb;
package com.yihu.wlyy.service.third.jkEduArticle;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@ -30,9 +30,9 @@ import java.util.*;
 * Created by yeshijie on 2017/9/11.
 */
@Service
public class HealthEducationArticleService extends BaseService {
public class ThirdJkEduArticleService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(HealthEducationArticleService.class);
    private static Logger logger = LoggerFactory.getLogger(ThirdJkEduArticleService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
@ -47,7 +47,7 @@ public class HealthEducationArticleService extends BaseService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    private ThirdJkEduArticleService healthEducationArticleService;
    @Autowired
    private PatientService patientService;
    @Value("${jkEdu.web.articleBaseUrl}")
@ -176,7 +176,7 @@ public class HealthEducationArticleService extends BaseService {
     * @return
     */
    public JSONArray getCollectionArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId,
                                              Integer pageIndex, Integer pageSize, String userId, Integer userType) throws Exception {
                                              Integer pageIndex, Integer pageSize, String userId, Integer userType,Boolean myArticle) throws Exception {
        JSONArray re = new JSONArray();
        JSONObject json = null;
        try {
@ -188,7 +188,7 @@ public class HealthEducationArticleService extends BaseService {
            param.put("pageSize", pageSize);
            param.put("userId", userId);
            param.put("userType", userType);
            param.put("myArticle", myArticle);
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getCollectionArticalList, param.toString(), "1"));
            json = JSON.parseObject(response);
        } catch (Exception e) {
@ -210,13 +210,13 @@ public class HealthEducationArticleService extends BaseService {
     * @param categoryLevel 是    获取类别:1、一级类别 2、二级类别
     * @return
     */
    public JSONArray getCategoryList(String categoryLevel) throws Exception {
    public JSONArray getCategoryList(String categoryLevel,String userId) throws Exception {
        JSONArray re = new JSONArray();
        JSONObject json = null;
        try {
            JSONObject param = new JSONObject();
            param.put("categoryLevel", categoryLevel);
            param.put("userId", userId);
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getCategoryList, param.toString(), "1"));
            json = JSON.parseObject(response);
        } catch (Exception e) {
@ -340,7 +340,7 @@ public class HealthEducationArticleService extends BaseService {
        }
    }
    public JSONArray getArticalList(String articleId, int articleState, int pageIndex, int pageSize) throws Exception {
    public JSONArray getArticalList(String articleId, int articleState, int pageIndex, int pageSize,String firstLevelCategoryId) throws Exception {
        JSONArray re = new JSONArray();
        JSONObject json = null;
        try {
@ -349,6 +349,7 @@ public class HealthEducationArticleService extends BaseService {
            param.put("articleState", articleState);
            param.put("pageIndex", pageIndex);
            param.put("pageSize", pageSize);
            param.put("firstLevelCategoryId", firstLevelCategoryId);
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(getArticalList, param.toString(), "1"));
            json = JSON.parseObject(response);
        } catch (Exception e) {
@ -380,128 +381,7 @@ public class HealthEducationArticleService extends BaseService {
//        return null;
//    }
    public JSONArray labelWithPushPatients(String labelType, String condition,String teamCode) {
        String[] cond = {};
        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)) {//孕产妇
//                temp.add("41");
                whereSql.append(" and tt LIKE '%41%' ");
            } else if ("3".equals(one)) {//65岁以上老年人
//                temp.add("13");
                whereSql.append(" and tt LIKE '%13%' ");
            }
        }
        String sql = "";
        List<DictModel> returnList = null;
        Map<String, Object> map = null;
        JSONArray re = new JSONArray();
        switch (labelType) {
            case "1": {
                sql = "select s.code code,s.name name from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
//                    sql = "select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_family_server s on w.code= s.sign_code "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211' ";
//                    sql +=" and s.server_type='"+one.getCode()+"'";
                    sql = " SELECT count(DISTINCT(aa.patient)) AS num 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.team_code=" +teamCode+
                            " 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 AND tt LIKE '%1" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
            case "2": {
                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=2 and status=1";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
//                    sql =" select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_patient_label_info l on w.patient=l.patient "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 2 AND l.label ="+one.getCode();
                    sql = " select count(DISTINCT(aa.patient)) as num 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 " +//AND w.team_code=" +teamCode+
                            " WHERE w. STATUS > 0 and l.status=1 AND  w.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
                            " GROUP BY a.patient HAVING tt LIKE '%2" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
            case "3": {
                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=3 and status=1";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
//                    sql =" select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_patient_label_info l on w.patient=l.patient "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211'  and l.status=1 and l.label_type = 3 AND l.label ="+one.getCode();
                    sql = " select count(DISTINCT(aa.patient)) as num 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.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
                            " GROUP BY a.patient HAVING tt LIKE '%3" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
            case "4": {
                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=4 and status=1";
                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel one : returnList) {
//                    sql =" select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_patient_label_info l on w.patient=l.patient "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211'  and l.status=1 and l.label_type = 4 AND l.label ='"+one.getCode()+"'";
                    sql = " select count(DISTINCT(aa.patient)) as num 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.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
                            " GROUP BY a.patient HAVING tt LIKE '%4" + one.getCode() + "%' " + whereSql.toString() + ") aa " + tableSql;
                    map = jdbcTemplate.queryForMap(sql);
                    JSONObject obj = new JSONObject();
                    obj.put("code", one.getCode());
                    obj.put("name", one.getName());
                    obj.put("num", (Long) map.get("num"));
                    re.add(obj);
                }
                break;
            }
        }
        return re;
    }
    public JSONArray pushArticleLogs(int page, int pagesize, String patientCode) throws Exception {
@ -521,7 +401,7 @@ public class HealthEducationArticleService extends BaseService {
            article = healthEducationArticleService.getArticalById(one.getArticleId());
            heapm = new HealthEduArticlePatientModel();
            heapm.setSendName(one.getSendName());
            heapm.setSendCode(one.getSendCode());
            heapm.setSendCode(one.getDoctorCode());
            heapm.setCreateTime(one.getCreateTime());
            heapm.setArticleId(article.getString("articleId"));
            heapm.setAttachedTitle(article.getString("articleTitle"));
@ -569,159 +449,5 @@ public class HealthEducationArticleService extends BaseService {
        return DateUtil.dateToStr(createDate, "yyyy-MM-dd");
    }
    public JSONObject pushArticleConfirm(String articleId,String labelType, String condition, String groupType,String teamCode) throws Exception{
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        Set<String> patientSet = new HashSet<>();
        initPatient(patientSet,labelType,condition,groupType,teamCode);
        long num = patientSet.size();
        JSONObject result = new JSONObject();
        result.put("num", num);
        result.put("articleTitle", article.getString("articleTitle"));
        return result;
    }
    public void initPatient(Set<String> patientSet, String labelType, String condition, String groupType,String teamCode) {
        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)) {//孕产妇
//                temp.add("41");
                whereSql.append(" and tt LIKE '%41%' ");
            } else if ("3".equals(one)) {//65岁以上老年人
//                temp.add("13");
                whereSql.append(" and tt LIKE '%13%' ");
            }
        }
        if (!StringUtils.isEmpty(groupType)) {
            group = groupType.split(",");
        }
        StringBuilder whereSql2 = new StringBuilder();
//        for (String one : group) {
//            whereSql2.append(" and tt LIKE '%" + labelType + one + "%' ");
//        }
//        String whereSql2Str = whereSql2.toString().substring(3);
        String sql = "";
        Map<String, Object> map = null;
        List<String> groupPatient = null;
        List<String> resultList = new ArrayList<>();
        switch (labelType) {
            case "1": {
//                sql = "select s.code code,s.name name from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
//                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
//                for(DictModel one:returnList){
//                    sql = "select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_family_server s on w.code= s.sign_code "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211' ";
//                    sql +=" and s.server_type='"+one.getCode()+"'";
                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.team_code=" +teamCode+
                            " 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);
//                    JSONObject obj = new JSONObject();
//                    obj.put("code",one.getCode());
//                    obj.put("name",one.getName());
//                    obj.put("num",(Long)map.get("num"));
//                    re.add(obj);
//                }
                    resultList.addAll(groupPatient);
                }
                break;
            }
            case "2": {
//                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=2 and status=1";
//                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
//                for(DictModel one:returnList){
//                    sql =" select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_patient_label_info l on w.patient=l.patient "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211' and l.status=1 and l.label_type = 2 AND l.label ="+one.getCode();
                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.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
                            " GROUP BY a.patient HAVING 1=1 " + whereSql + "  and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
//                    map = jdbcTemplate.queryForMap(sql);
//                JSONObject obj = new JSONObject();
//                obj.put("code",one.getCode());
//                obj.put("name",one.getName());
//                obj.put("num",(Long)map.get("num"));
//                re.add(obj);
                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
                    resultList.addAll(groupPatient);
//                }
                }
                break;
            }
            case "3": {
//                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=3 and status=1";
//                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
//                for(DictModel one:returnList){
//                    sql =" select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_patient_label_info l on w.patient=l.patient "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211'  and l.status=1 and l.label_type = 3 AND l.label ="+one.getCode();
                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.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
                            " GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
//                    map = jdbcTemplate.queryForMap(sql);
//                    JSONObject obj = new JSONObject();
//                    obj.put("code",one.getCode());
//                    obj.put("name",one.getName());
//                    obj.put("num",(Long)map.get("num"));
//                    re.add(obj);
                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
                    resultList.addAll(groupPatient);
//                }
                }
                break;
            }
            case "4": {
//                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=4 and status=1";
//                returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
//                for(DictModel one:returnList){
//                    sql =" select count(DISTINCT(w.patient)) as num from wlyy_sign_family w "+
//                            " left join wlyy_sign_patient_label_info l on w.patient=l.patient "+
//                            " left join wlyy_patient p on p.code=w.patient "+
//                            " where w.status>0 and p.town='350211'  and l.status=1 and l.label_type = 4 AND l.label ='"+one.getCode()+"'";
                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.team_code="+teamCode+" AND w.patient = l.patient AND LEFT (w.hospital, 6) = '350211' ) a " +
                            " GROUP BY a.patient HAVING 1=1 " + whereSql.toString() + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
//                    map = jdbcTemplate.queryForMap(sql);
//                    JSONObject obj = new JSONObject();
//                    obj.put("code",one.getCode());
//                    obj.put("name",one.getName());
//                    obj.put("num",(Long)map.get("num"));
//                    re.add(obj);
                    groupPatient = jdbcTemplate.queryForList(sql, String.class);
                    resultList.addAll(groupPatient);
//                }
                }
                break;
            }
        }
        patientSet.addAll(resultList);
    }
}

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

@ -1,13 +1,11 @@
package com.yihu.wlyy.web.doctor.health;
import com.yihu.es.entity.*;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.event.ApplicationEvent;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
@ -15,7 +13,7 @@ import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
@ -95,14 +93,8 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    @Autowired
    private GcEduArticleService gcEduArticleService;
    @Autowired
    private JmsTemplate jmsTemplate;
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    /**
     * 查询
     *
@ -623,265 +615,4 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    /**********************************福州健康文章接口********************************************/
    @RequestMapping(value = "getDoctorArticalList",method = RequestMethod.GET)
    @ApiOperation("获取健康教育文章列表")
    public String getDoctorArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true) Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false, defaultValue = "0") Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false, defaultValue = "5") Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
//            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getCategoryList",method = RequestMethod.GET)
    @ApiOperation("获取文章类别")
    public String getCategoryList(@ApiParam(name = "categoryLevel", value = "获取类别:1、一级类别 2、二级类别",defaultValue = "1")
                                       @RequestParam(value = "categoryLevel", required = true) String categoryLevel){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getCategoryList(categoryLevel);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getCollectionArticalList",method = RequestMethod.GET)
    @ApiOperation("获取收藏文章列表")
    public String getCollectionArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true) Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID(),1);
//            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56",1);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getArticalById",method = RequestMethod.GET)
    @ApiOperation("获取文章详情")
    public String getArticalById(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                  @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = healthEducationArticleService.getArticalById(articleId);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "cancelArticleCollection",method = RequestMethod.POST)
    @ApiOperation("取消收藏文章")
    @ObserverRequired
    public String cancelArticleCollection(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                 @RequestParam(value = "articleId", required = true) String articleId){
        try {
            healthEducationArticleService.cancelArticleCollection(articleId,getUID(),1);
//            healthEducationArticleService.cancelArticleCollection(articleId,"0de7295862dd11e69faffa163e8aee56",1);
            return success("取消成功!");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"取消失败!");
        }
    }
    @RequestMapping(value = "saveArticleCollection",method = RequestMethod.POST)
    @ApiOperation("收藏文章")
    @ObserverRequired
    public String saveArticleCollection(@ApiParam(name = "articleId", value = "文章id")
                                        @RequestParam(value = "articleId", required = true) String articleId,
                                        @ApiParam(name = "articleCategoryId", value = "文章类别ID")
                                        @RequestParam(value = "articleCategoryId", required = false,defaultValue = "1") String articleCategoryId,
                                        @ApiParam(name = "articleCategoryName", value = "文章类别名称")
                                        @RequestParam(value = "articleCategoryName", required = false) String articleCategoryName){
        try {
          healthEducationArticleService.saveArticleCollection(articleId,articleCategoryId,articleCategoryName,getUID(),1);
//            healthEducationArticleService.saveArticleCollection(articleId,articleCategoryId,articleCategoryName,"0de7295862dd11e69faffa163e8aee56",1);
            return success("收藏成功!");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"收藏失败!");
        }
    }
    @RequestMapping(value = "getDoctorArticalByUserId",method = RequestMethod.GET)
    @ApiOperation("获取医生发表的文章列表")
    public String getDoctorArticalByUserId(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true) Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false, defaultValue = "0") Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false, defaultValue = "5") Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
//            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getArticalList",method = RequestMethod.GET)
    @ApiOperation("获取文章列表 多ID")
    public String getDoctorArticalByUserId(@ApiParam(name = "articleId", value = "文章ID")
                                           @RequestParam(value = "articleId", required = false) String articleId,
                                           @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                           @RequestParam(value = "pageIndex", required = false ,defaultValue = "0") int pageIndex,
                                           @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                           @RequestParam(value = "pageSize", required = false ,defaultValue = "5") int pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getArticalList(articleId,1,pageIndex,pageSize);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    /**医生端-已推送文章
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "logs", method = RequestMethod.GET)
    @ApiOperation("查询医生给患者推送记录 ")
    public ResultPageListModel<HealthEduArticlePatientModel> getPatientHealthLogs(
            @ApiParam(name = "firstLevelCategoryId", value = "文章1级类别", required = false) @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
//            @ApiParam(name = "level1Type", value = "一级分类", required = false) @RequestParam(value = "level1Type", required = false) String level1Type,
//            @ApiParam(name = "level2Type", value = "二级分类", required = false) @RequestParam(value = "level2Type", required = false) String level2Type,
//            @ApiParam(name = "level", value = "等级", required = false) @RequestParam(value = "level", required = false) String level,
//            @ApiParam(name = "doctorCode", value = "医生code,为空从useragent取", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
//            @ApiParam(name = "patientCode", value = "接收人code", required = false) @RequestParam(value = "patientCode", required = false) String patientCode,
//            @ApiParam(name = "articleTitle", value = "文章标题", required = false) @RequestParam(value = "articleTitle", required = false) String articleTitle,
//            @ApiParam(name = "startTime", value = "开始时间yyyy-Mm-dd", required = false) @RequestParam(value = "startTime", required = false) String startTime,
//            @ApiParam(name = "endTime", value = "结束时间yyyy-Mm-dd", required = false) @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "当前页 起始1", required = true) @RequestParam(value = "page", required = true) Integer page,
            @ApiParam(name = "pagesize", value = "每页显示条数", required = true) @RequestParam(value = "pagesize", required = true) Integer pagesize) {
        try {
            if (pagesize > 1000) {
                pagesize = 1000;
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.pushArticleLogs(page,pagesize,getUID(),2,firstLevelCategoryId);
            Long count = gcEduArticleService.pushArticleLogsCount(getUID(),2);
            return new ResultPageListModel(
                    page,
                    pagesize,
                    count.intValue()
                    , eduArticlePatients);
        }catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "labelWithPushPatients", method = RequestMethod.GET)
    @ApiOperation("查询推送对象 ")
    public String labelWithPushPatients(
            @ApiParam(name = "teamCode", value = "团队code", required = true) @RequestParam(value = "teamCode", required = true) String teamCode,
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "codition", value = "多个筛选条件以逗号分割", required = false) @RequestParam(value = "codition", required = false) String codition){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.labelWithPushPatients(labelType,codition,teamCode);
//            Long count = healthEducationArticleService.pushArticleLogsCount("ece5c665b16542b0847e52b4a9fee44a");
            return write(200,"查询成功!","data",response);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @ApiOperation("确认推送人数")
    @RequestMapping(value = "pushArticleConfirm",method = RequestMethod.GET)
    public String pushArticleConfirm(
            @ApiParam(name = "teamCode", value = "团队code", required = true) @RequestParam(value = "teamCode", required = true) String teamCode,
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "condition", value = "多个筛选条件以逗号分割", required = false) @RequestParam(value = "condition", required = false) String condition,
            @ApiParam(name = "groupType", value = "多个分组以逗号分割", required = false) @RequestParam(value = "groupType", required = false) String groupType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = healthEducationArticleService.pushArticleConfirm(articleId,labelType,condition,groupType,teamCode);
            return write(200,"查询成功!","data",response);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "sendArticleToPatients", method = RequestMethod.POST)
    @ApiOperation("文章群推送")
    public BaseResultModel sendArticleToPatients(
            @ApiParam(name = "teamCode", value = "团队code", required = true) @RequestParam(value = "teamCode", required = true) String teamCode,
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "condition", value = "多个筛选条件以逗号分割", required = false) @RequestParam(value = "condition", required = false) String condition,
            @ApiParam(name = "groupType", value = "多个分组以逗号分割", required = false) @RequestParam(value = "groupType", required = false) String groupType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "sendName", value = "发送方名称(如:医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            healthEducationArticleService.initPatient(patientSet, labelType, condition, groupType,teamCode);
            com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = gcEduArticleService.getSaveArticle(patientSet, getUID(), sendName, 1, "", 0L, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
    /**
     * 发送到redis
     *
     */
    public void sender(com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient) {
        //送到到队列
        List<Patient> patients = healthEduArticlePatient.getPatients();
        patients.stream().forEach(one -> {
            healthEduArticlePatient.setPatient(one.getCode());
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(healthEduArticlePatient).toString());
                    return textMessage;
                }
            });
        });
    }
}

+ 241 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEdu/DoctorJMJkEduArticleController.java

@ -0,0 +1,241 @@
package com.yihu.wlyy.web.doctor.jimeiJkEdu;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.call.CustomerService;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.service.GcEduArticleService;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
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.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.web.bind.annotation.*;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
 * Created by Trick on 2017/11/14.
 */
@RestController
@RequestMapping(value = "/doctor/jkEdu/article", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生、卫计委")
public class DoctorJMJkEduArticleController extends BaseController {
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
    @Autowired
    private GcEduArticleService gcEduArticleService;
    @Autowired
    private JmsTemplate jmsTemplate;
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    @Value("${jkEdu.web.articleBaseUrl}")
    private String articleBaseUrl;
    /**
     * 发送到redis
     *
     */
    public void sender(HealthEduArticlePatient healthEduArticlePatient) {
        //送到到队列
        List<Patient> patients = healthEduArticlePatient.getPatients();
        patients.stream().forEach(one -> {
            healthEduArticlePatient.setPatient(one.getCode());
            healthEduArticlePatient.setPatients(null);
            healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+healthEduArticlePatient.getArticleId()+"&userId="+one);
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(healthEduArticlePatient).toString());
                    return textMessage;
                }
            });
        });
    }
    /*************************************************************************卫计委(管理员)角色start***************************************************************************************************/
    /**医生、卫计委(管理员)-已推送文章
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "pushArticleList", method = RequestMethod.GET)
    @ApiOperation("查询医生、卫计委(管理员)给患者推送健教文章列表 ")
    public ResultPageListModel<HealthEduArticlePatientModel> pushArticleList(
            @ApiParam(name = "firstLevelCategoryId", value = "文章一级分类", required = false) @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
            @ApiParam(name = "myArticle", value = "我的文章 1选中0未选", required = false) @RequestParam(value = "myArticle", required = false,defaultValue = "0") Integer myArticle,
            @ApiParam(name = "sendType", value = "1医生 2卫计委(管理员)", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "page", value = "当前页 起始1", required = true) @RequestParam(value = "page", required = true) Integer page,
            @ApiParam(name = "pagesize", value = "每页显示条数", required = true) @RequestParam(value = "pagesize", required = true) Integer pagesize) {
        try {
            List<HealthEduArticlePatientModel> eduArticlePatients = jmJkEduArticleService.pushArticleList(page,pagesize,getUID(),firstLevelCategoryId,myArticle,sendType);
//            Long count = jmJkEduArticleService.pushArticleListCount(getUID(),2);
            return new ResultPageListModel(
                    page,
                    pagesize,
                    null
                    , eduArticlePatients);
        }catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "manageSendArticleToPatients", method = RequestMethod.POST)
    @ApiOperation("卫计委(管理员)文章群推送")
    public BaseResultModel manageSendArticleToPatients(
//            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委(管理员)发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
//            @ApiParam(name = "sendName", value = "发送方名称(如:卫计委发送:集美区;医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId
    ){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            jmJkEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType,getUID());
//            patientSet.add(patientService.findByCode("wjw00000001000e6badcfa163e424525"));
            //获取保存发送记录
            HealthEduArticlePatient healthEduArticlePatient = jmJkEduArticleService.saveArticle(patientSet, getUID(), 2,"", 0L, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
    @RequestMapping(value = "managePushArticleConfirm",method = RequestMethod.GET)
    @ApiOperation("卫计委(管理员)确认健教推送人数")
    public String managePushArticleConfirm(@ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
                                     @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
                                     @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
                                     @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
                                     @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
                                     @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = jmJkEduArticleService.pushArticleConfirm(articleId, labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType,"wjw00000001000e6badcfa163e424525");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    /*************************************************************************卫计委(管理员)角色end***************************************************************************************************/
    /*************************************************************************医生角色start***************************************************************************************************/
    @RequestMapping(value = "labelWithPushPatients", method = RequestMethod.GET)
    @ApiOperation("医生-查询推送对象 ")
    public String labelWithPushPatients(
            @ApiParam(name = "teamId", value = "行政团队id", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "codition", value = "筛选多个条件以逗号分割", required = false) @RequestParam(value = "codition", required = false) String codition){
        try {
            com.alibaba.fastjson.JSONArray response = jmJkEduArticleService.labelWithPushPatients(labelType,codition,teamId,getUID());
            return write(200,"查询成功!","data",response);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @ApiOperation("医生确认健教推送人数")
    @ResponseBody
    @RequestMapping(value = "doctorPushArticleConfirm",method = RequestMethod.GET)
    public String doctorPushArticleConfirm(
            @ApiParam(name = "teamId", value = "行政团队id", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "condition", value = "多个筛选条件以逗号分割", required = false) @RequestParam(value = "condition", required = false) String condition,
            @ApiParam(name = "groupType", value = "多个分组以逗号分割", required = false) @RequestParam(value = "groupType", required = false) String groupType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = jmJkEduArticleService.pushArticleConfirm(articleId,labelType,condition,groupType,teamId,getUID());
            return write(200,"查询成功!","data",response);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "doctorSendArticleToPatients", method = RequestMethod.POST)
    @ApiOperation("医生文章群推送")
    public BaseResultModel doctorSendArticleToPatients(
            @ApiParam(name = "teamId", value = "行政团队id", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "condition", value = "多个筛选条件以逗号分割", required = false) @RequestParam(value = "condition", required = false) String condition,
            @ApiParam(name = "groupType", value = "多个分组以逗号分割", required = false) @RequestParam(value = "groupType", required = false) String groupType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            jmJkEduArticleService.initPatients(patientSet,labelType,condition,groupType,teamId,getUID());
            HealthEduArticlePatient healthEduArticlePatient = jmJkEduArticleService.saveArticle(patientSet, getUID(), 1,"", teamId, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
    @RequestMapping(value = "doctorSendArticleToSingle", method = RequestMethod.POST)
    @ApiOperation("医生文章单个患者推送")
    public BaseResultModel doctorSendArticleToSingle(
            @ApiParam(name = "patientCode", value = "患者Code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            patientSet.add(patientCode);
//            jmJkEduArticleService.initPatients(patientSet,labelType,condition,groupType,teamId,getUID());
            HealthEduArticlePatient healthEduArticlePatient = jmJkEduArticleService.saveArticle(patientSet, getUID(), 1,"", 0L, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
    /*************************************************************************医生角色end***************************************************************************************************/
}

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

@ -0,0 +1,19 @@
package com.yihu.wlyy.web.doctor.jimeiJkEduPC;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2017/11/14.
 */
@RestController
@RequestMapping(value = "/doctor/jkEdu/article/PC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生、卫计委")
public class DoctorJMJkEduArticlePCController extends BaseController {
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -8,6 +8,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.message.SendMessageService;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;

+ 3 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -8,12 +8,9 @@ import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.app.health.HealthEduArticlePatientService;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -56,7 +53,7 @@ public class HealthEduArticleController extends BaseController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    private ThirdJkEduArticleService healthEducationArticleService;
    /**
     * 查询文章列表
@ -258,7 +255,7 @@ public class HealthEduArticleController extends BaseController {
                                           @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                           @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID(),2);
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID(),2,null);
//            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56",1);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/jimeiJkEdu/PatientJMJkEduArticleController.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.web.patient.jimeiJkEdu;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2017/11/14.
 */
@RestController
@RequestMapping(value = "/patient/jkEdu/article", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "集美宣教微信端(患者端)")
public class PatientJMJkEduArticleController extends BaseController {
}

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

@ -62,6 +62,30 @@ public class GcEduArticleController extends WeixinBaseController {
    private JmsTemplate jmsTemplate;
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    @Value("${jkEdu.web.articleBaseUrl}")
    private String articleBaseUrl;
    /**
     * 发送到redis
     *
     */
    public void sender(HealthEduArticlePatient healthEduArticlePatient) {
        //送到到队列
        List<Patient> patients = healthEduArticlePatient.getPatients();
        patients.stream().forEach(one -> {
            healthEduArticlePatient.setPatient(one.getCode());
            healthEduArticlePatient.setPatients(null);
            healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+healthEduArticlePatient.getArticleId()+"&userId="+one);
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(healthEduArticlePatient).toString());
                    return textMessage;
                }
            });
        });
    }
    /**PC端
     * @param doctorCode
@ -143,97 +167,4 @@ public class GcEduArticleController extends WeixinBaseController {
        }
    }
    /**
     * 发送到redis
     *
     */
    public void sender(HealthEduArticlePatient healthEduArticlePatient) {
        //送到到队列
        List<Patient> patients = healthEduArticlePatient.getPatients();
        patients.stream().forEach(one -> {
            healthEduArticlePatient.setPatient(one.getCode());
            healthEduArticlePatient.setPatients(null);
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(healthEduArticlePatient).toString());
                    return textMessage;
                }
            });
        });
    }
    /************************************************************************集美健教卫计委相关接口***********************************************************************/
    @RequestMapping(value = "sendPatients", method = RequestMethod.POST)
    @ApiOperation("文章群推送")
    public BaseResultModel sendPatients(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
//            @ApiParam(name = "sendCode", value = "发送人code(医生发送时,必填医生code)", required = false) @RequestParam(value = "sendCode", required = false) String sendCode,
            @ApiParam(name = "sendName", value = "发送方名称(如:卫计委发送:集美区;医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId
    ){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
//            patientSet.add(patientService.findByCode("ac9e92622e0343c98861d41dfa5e4392"));
            //获取保存发送记录
            HealthEduArticlePatient healthEduArticlePatient = gcEduArticleService.getSaveArticle(patientSet, getUID(), sendName, sendType, "", 0L, articleId);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatient);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
    @RequestMapping(value = "pushArticleLogs", method = RequestMethod.GET)
    @ApiOperation("查询卫计委给患者推送记录 ")
    public ResultPageListModel<HealthEduArticlePatientModel> pushArticleLogs(
            @ApiParam(name = "firstLevelCategoryId", value = "文章所属一级类别ID", required = false) @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
            @ApiParam(name = "page", value = "当前页 起始1", required = true) @RequestParam(value = "page", required = true) Integer page,
            @ApiParam(name = "pagesize", value = "每页显示条数", required = true) @RequestParam(value = "pagesize", required = true) Integer pagesize){
        try {
            if (pagesize > 1000) {
                pagesize = 1000;
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.pushArticleLogs(page,pagesize,getUID(),1,firstLevelCategoryId);
            Long count = gcEduArticleService.pushArticleLogsCount(getUID(),1);
            return new ResultPageListModel(
                    page,
                    pagesize,
                    count.intValue()
                    , eduArticlePatients);
        }catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "pushArticleConfirm",method = RequestMethod.GET)
    public String pushArticleConfirm(@ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
                                   @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
                                   @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
                                   @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
                                   @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
                                   @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = gcEduArticleService.pushArticleConfirm(articleId, labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -126,7 +126,7 @@ public class GcLableController extends BaseController {
    @ApiOperation("根据地区查找卫计委下属单位标签")
    public ResultListModel<List<PatientLabelModel>> unitLabels() {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels();
            List<DictModel> dictModels = labelService.getUnitLabels("wjw00000001000e6badcfa163e424525");
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());

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

@ -13,21 +13,18 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -46,7 +43,7 @@ public class GcEduArticleService {
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    private ThirdJkEduArticleService healthEducationArticleService;
    @Autowired
    private PatientService patientService;
    @Autowired
@ -230,9 +227,9 @@ public class GcEduArticleService {
                    "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "' and LENGTH(u.role)=6";
            Map<String, Object> result = jdbcTemplate.queryForMap(sql);
            //角色的code值
            healthEduArticlePatient.setSendCode(result.get("roleCode") + "");
            healthEduArticlePatient.setDoctorCode(result.get("roleCode") + "");
        } else {
            healthEduArticlePatient.setSendCode(sendCode);
            healthEduArticlePatient.setDoctorCode(sendCode);
        }
        healthEduArticlePatient.setDoctorCode(sendCode);
        healthEduArticlePatient.setDoctorName(doctor.getName());
@ -265,7 +262,7 @@ public class GcEduArticleService {
        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);
//        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+);
        healthEduArticlePatient.setPatients(patientList);
        //保存到ES中
@ -390,66 +387,7 @@ public class GcEduArticleService {
//        patientSet.addAll(groupPatient);
//    }
    public void initPatient(Set<String> patientSet, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth) {
        //全选的时候前端传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);
        }
        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 ";
        String whereSql = " where w.status>0 and p.town='350211' ";
        if (!StringUtils.isEmpty(labelServe)) {
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
            whereSql += " and s.server_type in (" + labelServe + " ) ";
        }
        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 ";
            whereSql += " and ( ";
        }
        if (!StringUtils.isEmpty(labelHealth)) {
            whereSql += " (l.label_type = 2 AND l.label in (" + labelHealth + ")) ";
        }
        if (!StringUtils.isEmpty(labelDisease)) {
            if (!whereSql.endsWith(" and ( ")) {
                whereSql += " or (l.label_type = 3 AND l.label in (" + labelDisease + "))) ";
            } else {
                whereSql += " (l.label_type = 1 AND l.label in (" + labelDisease + "))) ";
            }
        }
        tableSql += " left join wlyy_patient p on p.code=w.patient ";
        if (!StringUtils.isEmpty(labelSex)) {
            whereSql += " and p.sex in (" + labelSex + ") ";
        }
        if (!StringUtils.isEmpty(labelUnit)) {
            whereSql += " and w.hospital in (" + labelUnit + ") ";
        }
        List<String> groupPatient = jdbcTemplate.queryForList(tableSql + whereSql, String.class);
        patientSet.addAll(groupPatient);
    }
//    /**
@ -490,126 +428,7 @@ public class GcEduArticleService {
//        return healthEduArticlePatients;
//    }
    /**
     *
     * @param page
     * @param pagesize
     * @param sendCode
     * @param sendType 1、卫计委,2、医生
     * @return
     * @throws Exception
     */
    public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize, String sendCode,int sendType,String firstLevelCategoryId) throws Exception {
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        if(sendType==1){
            String sql = "select r.code as roleCode from wlyy_user_role u " +
                    "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "' and LENGTH(u.role)=6";
            Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
            sendCode = resultMap.get("roleCode").toString();
        }
        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
                " where  sendCode='" + sendCode + "'");
        if(!StringUtils.isEmpty(firstLevelCategoryId)){
            sql2.append("and level1Type="+firstLevelCategoryId);
        }
        sql2.append("  order by createTime limit " + page + "," + pagesize);
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        Map<String, HealthEduArticlePatientModel> result = new HashMap<>();
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
        for (HealthEduArticlePatient one : esList) {
            article = healthEducationArticleService.getArticalById(one.getArticleId());
            if (result.get(one.getArticleId()) != null) {
                heapm = result.get(one.getArticleId());
            } else {
                heapm = new HealthEduArticlePatientModel();
            }
            heapm.setSendName(one.getSendName());
            heapm.setSendCode(one.getSendCode());
            heapm.setCreateTime(one.getCreateTime());
            heapm.setArticleId(article.getString("articleId"));
            heapm.setAttachedTitle(article.getString("articleTitle"));
            heapm.setAttachedContent(article.getString("articleContent"));
            heapm.setArticleType(article.getString("articleType"));
            heapm.setLevel1Type(article.getString("firstLevelCategoryId"));
            heapm.setLevel2Type(article.getString("secondLevelCategoryId"));
            heapm.setLevel(article.getString("articlelevel"));
            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size());
            heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数
            heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数
            heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数
            heapm.setArticleCover(article.getString("articleCover"));//封面
            heapm.setComputeTime(computeTime(article.getString("insertTime")));
            // heapm.setTime();//时间  xx小时前  2017-10-11
            result.put(one.getArticleId(), heapm);
        }
        List<HealthEduArticlePatientModel> resultList = new ArrayList<>();
        for (Map.Entry<String, HealthEduArticlePatientModel> entry : result.entrySet()) {
            resultList.add(entry.getValue());
        }
        return resultList;
    }
    public static String computeTime(String create) {
        Date createDate = DateUtil.strToDate(create, "yyyy-MM-dd HH:mm:ss.SSS");
        Date nowDate = new Date();
        //计算2个时间差
        Long l = nowDate.getTime() - createDate.getTime();
        long hour = l / (60 * 60 * 1000); //小时
        long min = l / (60 * 1000);//分钟
        long s = l / 1000;//秒
        if(s<60){
            return s+"秒前";
        }
        if(min<60){
            return min+"分钟前";
        }
        if(hour<24){
            return hour+"小时前";
        }
        return DateUtil.dateToStr(createDate,"yyyy-MM-dd");
    }
    public static void main(String[] args) {
        System.out.println(computeTime("2017-11-16 13:32:00.010"));
    }
    /**
     *
     * @param sendCode
     * @param sendType 1、卫计委,2、医生
     * @return
     */
    public Long pushArticleLogsCount(String sendCode,int sendType) {
        if(sendType==1){
            String sql = "select r.code as roleCode from wlyy_user_role u " +
                    "left join wlyy_role r on r.`code`=u.role where u.user='" + sendCode + "'"+ " and LENGTH(u.role)=6";;
            Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
            sendCode = resultMap.get("roleCode").toString();
        }
        StringBuffer sql = new StringBuffer("select count(distinct articleId) count  from   " + esType +
                " where  sendCode='" + sendCode + "' ");
        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth) throws Exception {
        JSONObject article = healthEducationArticleService.getArticalById(articleId);
        Set<String> patientSet = new HashSet<>();
        initPatient(patientSet, labelUnit, labelSex, labelServe, labelDisease, labelHealth);
        long num = patientSet.size();
        JSONObject result = new JSONObject();
        result.put("num", num);
        result.put("articleTitle", article.getString("articleTitle"));
        return result;
    }
}

+ 74 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java

@ -9,8 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -242,9 +244,79 @@ public class GcLabelService {
        return result;
    }
    public List<DictModel> getUnitLabels() {
        String sql = "select code, name  from dm_hospital  where level=2 and town = '350211'" ;
    public List<DictModel> getUnitLabels(String userCode) {
        Map<String,Object> resultLevel = 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):"";
        String whereSql = "";
        if(StringUtils.isEmpty(roleSql)){
            switch (level){
                case 1:{whereSql+=" and province in ("+role+")" ;break;}
                case 2:{whereSql+=" and city in ("+role+")" ;break;}
                case 3:{whereSql+=" and town in ("+role+")" ;break;}
                case 4:{whereSql+=" and code in ("+role+")" ;break;}
            }
        }
        String sql = "select code, name  from dm_hospital  where level=2 "+whereSql ;
        List<DictModel> returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
        return returnList;
    }
    public Map<String,Object> fetchUserHighestAuthority(String userCode){
        String sql2 = "select r.code as roleCode from wlyy_user_role u " +
                "left join wlyy_role r on r.`code`=u.role where u.user='" + userCode + "'";
        List<Map<String, Object>> resultMap = jdbcTemplate.queryForList(sql2);
        int resultLevel = 5;
        Map<Integer,List<String>> temp = new HashMap<>();
        List<String> tempList = null;
        for(Map<String, Object> one:resultMap){
            int level = roleConverse(one.get("roleCode")+"");
            tempList = temp.get(level);
            if(tempList==null){
                tempList=new ArrayList<>();
            }
            tempList.add(one.get("roleCode")+"");
            temp.put(level,tempList);
        }
        Map<Integer,List<String>> result = null;
        for (Integer one : temp.keySet()) {
            if(resultLevel>one){
                resultLevel=one;
            }
        }
        Map<String,Object> resultRole =new HashMap<>();
        resultRole.put("level",resultLevel);
        resultRole.put("roleList",temp.get(resultLevel));
        return resultRole;
    }
    /**
     *
     * @param roleCode 角色code
     * @return 1、省级,2、市级,3、区级,4、机构
     */
    public Integer roleConverse(String roleCode){
        if(roleCode.length()==6){
            if("0".equals(roleCode.substring(3,4))){
                return 1;
            }else if("00".equals(roleCode.substring(4))){
                return 2;
            }else{
                return 3;
            }
        }else{
            return 3;
        }
    }
}

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

@ -0,0 +1,205 @@
package com.yihu.wlyy.web.third.jkEduArticle;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.service.GcEduArticleService;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
 * 调用福州健教接口
 * Created by Reece on 2017/11/14.
 */
@Controller
@RestController
@RequestMapping(value = "/third/jkEdu/Article")
@Api(description = "调用第三方(福州)健教接口")
public class ThirdJkEduArticleController extends BaseController {
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    @Value("${jkEdu.web.articleBaseUrl}")
    private String articleBaseUrl;
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    @Autowired
    private GcEduArticleService gcEduArticleService;
    @Autowired
    private JmsTemplate jmsTemplate;
    /**********************************福州健康文章接口********************************************/
    @RequestMapping(value = "getDoctorArticalList",method = RequestMethod.GET)
    @ApiOperation("获取健康教育文章列表")
    public String getDoctorArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true) Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false, defaultValue = "0") Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false, defaultValue = "5") Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
//            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getCategoryList",method = RequestMethod.GET)
    @ApiOperation("获取文章类别")
    public String getCategoryList(@ApiParam(name = "categoryLevel", value = "获取类别:1、一级类别 2、二级类别",defaultValue = "1")
                                  @RequestParam(value = "categoryLevel", required = true) String categoryLevel){
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCategoryList(categoryLevel,getUID());
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getCollectionArticalList",method = RequestMethod.GET)
    @ApiOperation("获取收藏文章列表")
    public String getCollectionArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                           @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                           @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                           @RequestParam(value = "articleState", required = true) Integer articleState,
                                           @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                           @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                           @ApiParam(name = "myArticle", value = "文章作者为自己")
                                           @RequestParam(value = "myArticle", required = false) Boolean myArticle,
                                           @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                           @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                           @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                           @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID(),1,myArticle);
//            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56",1);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getArticalById",method = RequestMethod.GET)
    @ApiOperation("获取文章详情")
    public String getArticalById(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                 @RequestParam(value = "articleId", required = true) String articleId){
        try {
            com.alibaba.fastjson.JSONObject response = thirdJkEduArticleService.getArticalById(articleId);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "cancelArticleCollection",method = RequestMethod.POST)
    @ApiOperation("取消收藏文章")
    @ObserverRequired
    public String cancelArticleCollection(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                          @RequestParam(value = "articleId", required = true) String articleId){
        try {
            thirdJkEduArticleService.cancelArticleCollection(articleId,getUID(),1);
//            thirdJkEduArticleService.cancelArticleCollection(articleId,"0de7295862dd11e69faffa163e8aee56",1);
            return success("取消成功!");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"取消失败!");
        }
    }
    @RequestMapping(value = "saveArticleCollection",method = RequestMethod.POST)
    @ApiOperation("收藏文章")
    @ObserverRequired
    public String saveArticleCollection(@ApiParam(name = "articleId", value = "文章id")
                                        @RequestParam(value = "articleId", required = true) String articleId,
                                        @ApiParam(name = "articleCategoryId", value = "文章类别ID")
                                        @RequestParam(value = "articleCategoryId", required = false,defaultValue = "1") String articleCategoryId,
                                        @ApiParam(name = "articleCategoryName", value = "文章类别名称")
                                        @RequestParam(value = "articleCategoryName", required = false) String articleCategoryName){
        try {
            thirdJkEduArticleService.saveArticleCollection(articleId,articleCategoryId,articleCategoryName,getUID(),1);
//            thirdJkEduArticleService.saveArticleCollection(articleId,articleCategoryId,articleCategoryName,"0de7295862dd11e69faffa163e8aee56",1);
            return success("收藏成功!");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"收藏失败!");
        }
    }
    @RequestMapping(value = "getDoctorArticalByUserId",method = RequestMethod.GET)
    @ApiOperation("获取医生发表的文章列表")
    public String getDoctorArticalByUserId(@ApiParam(name = "articleTitle", value = "文章标题")
                                           @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                           @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                           @RequestParam(value = "articleState", required = true) Integer articleState,
                                           @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                           @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                           @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                           @RequestParam(value = "pageIndex", required = false, defaultValue = "0") Integer pageIndex,
                                           @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                           @RequestParam(value = "pageSize", required = false, defaultValue = "5") Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
//            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getArticalList",method = RequestMethod.GET)
    @ApiOperation("获取文章列表 多ID")
    public String getDoctorArticalByUserId(@ApiParam(name = "articleId", value = "文章ID")
                                           @RequestParam(value = "articleId", required = false) String articleId,
                                           @ApiParam(name = "firstLevelCategoryId", value = "文章一级类别")
                                           @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                           @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                           @RequestParam(value = "pageIndex", required = false ,defaultValue = "0") int pageIndex,
                                           @ApiParam(name = "pageSize", value = "每页显示数 ,默认10")
                                           @RequestParam(value = "pageSize", required = false ,defaultValue = "10") int pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = thirdJkEduArticleService.getArticalList(articleId,1,pageIndex,pageSize,firstLevelCategoryId);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduLableController.java

@ -125,10 +125,10 @@ public class EduLableController extends BaseController {
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("根据地区查找卫计委下属单位标签")
    public ResultListModel<List<PatientLabelModel>> unitLabels(
            @ApiParam(name = "areas", value = "地区code,多个地区用逗号分隔", required = true) @RequestParam(value = "areas", required = true) String areas
//            @ApiParam(name = "areas", value = "地区code,多个地区用逗号分隔", required = true) @RequestParam(value = "areas", required = true) String areas
    ) {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels();
            List<DictModel> dictModels = labelService.getUnitLabels(getUID());
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());

+ 5 - 5
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -97,11 +97,11 @@ pushMes:
  redis_prescription_title: redisPrescription
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test3
    HealthEduArticlePatient: health_edu_article_patient_test4
    FollowUp: wlyy_followup
    Statistics: wlyy_quota_test
  type:
    HealthEduArticlePatient: health_edu_article_patient_test3
    HealthEduArticlePatient: health_edu_article_patient_test4
    FollowUpContent: wlyy_followup_content
    Statistics: wlyy_quota_test
  host:  http://172.19.103.68:9200
@ -112,8 +112,8 @@ es:
#http://172.19.103.87:9088/JkEduWeb
jkEdu:
  web:
    articleBaseUrl: http://172.19.103.87:9088/
    articleBaseUrl: http://yihu.com:9088/
#    articleBaseUrl: http://172.19.103.87:9088/
#消息队列
activemq:
@ -121,7 +121,7 @@ activemq:
  password: admin
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送
##如果是外网项目就是flase 内网是true
neiwang: