Procházet zdrojové kódy

集美宣教代码提交

liuwenbin před 7 roky
rodič
revize
c78dabf136

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

@ -3,19 +3,25 @@ package com.yihu.wlyy.service.third.fzzb;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
 * 福州总部-健康教育医生APP接口文档
@ -31,6 +37,16 @@ public class HealthEducationArticleService extends BaseService{
    private HttpClientUtil httpClientUtil;
    @Autowired
    private DoctorDao doctorDao;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
//    private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
    private String baseUrl = "http://172.17.110.230:83/WsPlatform/rest";
@ -332,4 +348,123 @@ public class HealthEducationArticleService extends BaseService{
            throw new Exception(json.getString("Message"));
        }
    }
//    public JSONArray getPatientHealthLogs(int page, int pagesize,String sendCode, String articleType)throws Exception{
//
//        pagesize = page * pagesize;
//        page = (page - 1) * pagesize;
//        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from   " + esType +
//                " where  sendCode='" + sendCode + "' ");
//        if (!StringUtils.isEmpty(articleType)) {
//            sql.append(" and  articleType='" + articleType + "'  ");
//        }
//        sql.append(" group by articleId order by createTime limit " + page + "," + pagesize);
//        List<HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
//        for(HealthEduArticlePatient one :esList){
//            JSONObject jsonObject = getArticalById(one.getArticleId());
//
//        }
//        return null;
//    }
//    public JSONArray labelWithPushPatients(String labelType){
//
//        String sql = "";
//        List<DictModel> returnList = null;
//        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));
//                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' ";
//                for(DictModel one:returnList){
//                    sql +=" s.server_type='"+one.getCode()+"'";
//                    Map<String, Object> 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"));
//                }
//                break;
//            }
//            case "2": {
//                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=2 and status=1";
//                break;
//            }
//            case "3": {
//                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=3 and status=1";
//                break;
//            }
//            case "4": {
//                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=4 and status=1";
//                break;
//            }
//
//        }
//        return null;
//    }
    public JSONArray pushArticleLogs(int page, int pagesize,String patientCode)throws Exception{
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
//
//        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
//                " where  sendCode='" + sendCode + "' ");
//        sql2.append("  order by createTime limit " + page + "," + pagesize);
        String sql = "SELECT * FROM "+esType+"  where nested(patients.code)= '"+patientCode+"' order by createTime desc limit "+ page + "," + pagesize;
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        HealthEduArticlePatientModel heapm = null;
        com.alibaba.fastjson.JSONObject article = null;
        List<HealthEduArticlePatientModel> result = new ArrayList<>();
        for (HealthEduArticlePatient one : esList) {
            article = healthEducationArticleService.getArticalById(one.getArticleId());
            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")));
            result.add(heapm);
            // heapm.setTime();//时间  xx小时前  2017-10-11
        }
        JSONArray re = new JSONArray();
        re.addAll(result);
        return re;
    }
    public  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");
    }
}

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

@ -18,7 +18,9 @@ import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.web.WeixinBaseController;
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.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
@ -86,7 +88,8 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    private PushMsgTask pushMsgTask;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    @Autowired
    private GcEduArticleService gcEduArticleService;
    /**
     * 查询
     *
@ -755,5 +758,47 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
        }
    }
    /**医生端-已推送文章
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "logs", method = RequestMethod.GET)
    @ApiOperation("查询医生给患者推送记录 ")
    public ResultPageListModel<HealthEduArticlePatientModel> getPatientHealthLogs(
            @ApiParam(name = "articleType", value = "文章类别", required = false) @RequestParam(value = "articleType", required = false) String articleType,
//            @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);
            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 = "logs", method = RequestMethod.GET)
    @ApiOperation("查询推送对象 ")
    public String labelWithPushPatients(
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType){
        return "";
    }
}

+ 41 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -11,6 +11,9 @@ import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
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;
@ -217,6 +220,7 @@ public class HealthEduArticleController extends BaseController {
    /**********************************福州健康文章接口********************************************/
    @RequestMapping(value = "getDoctorArticalByUserId",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取医生发表的文章列表")
    public String getDoctorArticalByUserId(@ApiParam(name = "doctorCode", value = "医生code")
                                           @RequestParam(value = "doctorCode", required = true) String doctorCode,
@ -240,5 +244,42 @@ public class HealthEduArticleController extends BaseController {
        }
    }
    @RequestMapping(value = "getCollectionArticalList",method = RequestMethod.GET)
    @ResponseBody
    @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(),2);
//            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 = "pushArticleLogs", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("居民获取被推送文章列表 ")
    public String pushArticleLogs(
            @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 {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.pushArticleLogs(page,pagesize,getUID());
//            Long count = healthEducationArticleService.pushArticleLogsCount("ece5c665b16542b0847e52b4a9fee44a");
            return write(200,"查询成功!","data",response);
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}

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

@ -63,7 +63,7 @@ public class GcEduArticleController extends WeixinBaseController {
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    /**
    /**PC端
     * @param doctorCode
     * @param page
     * @param pagesize
@ -206,8 +206,8 @@ public class GcEduArticleController extends WeixinBaseController {
            if (pagesize > 1000) {
                pagesize = 1000;
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.pushArticleLogs(page,pagesize,"wjw00000001000e6badcfa163e424525");
            Long count = gcEduArticleService.pushArticleLogsCount("");
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.pushArticleLogs(page,pagesize,getUID(),1);
            Long count = gcEduArticleService.pushArticleLogsCount(getUID(),1);
            return new ResultPageListModel(
                    page,
                    pagesize,

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

@ -59,6 +59,8 @@ public class GcEduArticleService {
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Value("${jkEdu.web.articleBaseUrl}")
    private String articleBaseUrl;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
@ -261,7 +263,7 @@ public class GcEduArticleService {
        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + "");
        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + "");
        healthEduArticlePatient.setType("1");//文章
        healthEduArticlePatient.setArticleUrl("");
        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId);
        healthEduArticlePatient.setPatients(patientList);
        //保存到ES中
@ -486,15 +488,26 @@ public class GcEduArticleService {
//        return healthEduArticlePatients;
//    }
    public List<HealthEduArticlePatientModel> pushArticleLogs(int page, int pagesize, String sendCode) throws Exception {
    /**
     *
     * @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) throws Exception {
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        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 + "'";
        Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
        sendCode = resultMap.get("roleCode").toString();
        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 + "'";
            Map<String, Object> resultMap = jdbcTemplate.queryForMap(sql);
            sendCode = resultMap.get("roleCode").toString();
        }
        StringBuffer sql2 = new StringBuffer("select *  from   " + esType +
                " where  sendCode='" + sendCode + "' ");
        sql2.append("  order by createTime limit " + page + "," + pagesize);
@ -504,13 +517,6 @@ public class GcEduArticleService {
        com.alibaba.fastjson.JSONObject article = null;
        for (HealthEduArticlePatient one : esList) {
            article = healthEducationArticleService.getArticalById(one.getArticleId());
//            com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
//            if (p != null) {
//                p.setAllCount(one.getAllCount());
//                HealthEduArticlePatientModel heapm = new HealthEduArticlePatientModel();
//                BeanUtils.copyProperties(p, heapm);
//                returnList.add(heapm);
//            }
            if (result.get(one.getArticleId()) != null) {
                heapm = result.get(one.getArticleId());
@ -544,6 +550,7 @@ public class GcEduArticleService {
        return resultList;
    }
    public static String computeTime(String create) {
        Date createDate = DateUtil.strToDate(create, "yyyy-MM-dd HH:mm:ss.SSS");
        Date nowDate = new Date();
@ -569,8 +576,21 @@ public class GcEduArticleService {
        System.out.println(computeTime("2017-11-16 13:32:00.010"));
    }
    public Long pushArticleLogsCount(String sendCode) {
    /**
     *
     * @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 + "'";
            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);

+ 6 - 0
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -109,6 +109,12 @@ es:
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
#集美宣教居民端健康文章
jkEdu:
  web:
    articleBaseUrl: http://172.19.103.87:9088/jkeduweb
#消息队列
activemq:
  username: admin

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

@ -108,6 +108,11 @@ es:
  tHost: 172.19.103.68:9300
  clusterName: jkzl
#集美宣教居民端健康文章
#http://172.19.103.87:9088/JkEduWeb
jkEdu:
  web:
    articleBaseUrl: http://172.19.103.87:9088/jkeduweb
#消息队列

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

@ -106,6 +106,11 @@ es:
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl
#集美宣教居民端健康文章
jkEdu:
  web:
    articleBaseUrl: http://172.19.103.87:9088/jkeduweb
#消息队列
activemq:
  username: admin

+ 4 - 0
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -107,6 +107,10 @@ es:
  tHost: 172.19.103.68:9300
  clusterName: jkzl
#集美宣教居民端健康文章
jkEdu:
  web:
    articleBaseUrl: http://172.19.103.87:9088/jkeduweb
#消息队列
activemq:

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

@ -108,6 +108,11 @@ es:
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl
#集美宣教居民端健康文章
jkEdu:
  web:
    articleBaseUrl:
#消息队列
activemq:
  username: admin

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

@ -105,6 +105,11 @@ es:
  tHost: 172.19.103.68:9300
  clusterName: jkzl
#集美宣教居民端健康文章
jkEdu:
  web:
    articleBaseUrl: http://172.19.103.87:9088/jkeduweb
#消息队列
activemq:
  username: admin