Pārlūkot izejas kodu

已推送文章列表
推送
获取推送患者列表

zd_123 7 gadi atpakaļ
vecāks
revīzija
9599c3ed2d

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

@ -32,8 +32,10 @@ import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.web.third.jkedu.vo.PatientModel;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -146,6 +148,7 @@ public class FamilyContractService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCodeAndType(code, 2);
    }
@ -4089,4 +4092,41 @@ public class FamilyContractService extends BaseService {
        return rs ;
    }
    /*public Map<String,Object> getPushPatientList(int type,String[] searchTypes,String doctor,String doctorHealth){
        StringBuffer sb = new StringBuffer("SELECT p.*,sf.server_type serverType,sf.server_type_name serverTypeName,sf.team_code teamCode " +
                "from wlyy_sign_family sf LEFT JOIN wlyy_patient p ON sf.patient=p.`code`" +
                "WHERE sf.`status`>0 and (sf.doctor=? OR sf.doctor_health=?) AND p.`status`=1");
        //searchType==1重点关注2有绑定设备3孕产妇4年纪在65以上
        for (String searchType:searchTypes) {
            if("1".equals(searchType)){
                sb.append(" AND p.disease_condition =3");
            }else if("2".equals(searchType)){
                sb.append(" AND sf.`patient` IN (SELECT pd.user from wlyy_patient_device pd)");
            }else if("3".equals(searchType)){
                sb.append(" AND sf.server_type=6");
            }else if ("4".equals(searchType)){
                Calendar cal = Calendar.getInstance();
                int year =cal.get(Calendar.YEAR)-65;
                String birthday = year+"-01-01";
                sb.append("p.birthday<"+birthday);
            }
        }
        List params = new ArrayList<>();
        params.add(doctor);
        params.add(doctorHealth);
        List<PatientModel> patients = jdbcTemplate.query(sb.toString(), params.toArray(), new BeanPropertyRowMapper(PatientModel.class));
        Map<String,Object> map = new HashedMap();
        if(type==1){
            for (PatientModel patientModle: patients) {
                int serverType = patientModle.getServerType();
                String serverTypeName = patientModle.getServerTypeName();
            }
        }
        map.put("list",patients);
        return map;
    }*/
}

+ 65 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/EduArticleController.java

@ -0,0 +1,65 @@
package com.yihu.wlyy.web.third.jkedu.controller;
import com.alibaba.fastjson.JSON;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.jkedu.vo.ArticleModel;
import com.yihu.wlyy.web.third.jkedu.vo.base.ResultOneModel;
import com.yihu.wlyy.web.third.jkedu.vo.state.ErrorStateMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/**
 * Created by zhangdan on 2017/10/10.
 */
@Controller
@RequestMapping(value = "/wlyygc/article/jkedu",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康教育文章类")
public class EduArticleController extends BaseController{
    @Autowired
    private  HttpUtil HttpUtil;
    @RequestMapping(value = "/getById",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取文章详情")
    public ResultOneModel<ArticleModel> getById(@ApiParam(name = "articleId",value = "文章ID")@RequestParam(value = "articleId")String articleId){
        int code  = 0;
        try{
            //调用福州接口
            String url ="http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Article.getArticalById&Param={\"articleId\":\""+articleId+"\"}&AuthInfo={ClientId:\"9000276\"}";
            String jsonStr = HttpUtil.sendPost(url,"");
            if(StringUtils.isNotBlank(jsonStr)){
                Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
                code = Integer.valueOf(String.valueOf(map.get("Code")));
                if(code == 10000){
                    String result = String.valueOf(map.get("Result"));
                    JSONArray jsonArray = JSONArray.fromObject(result);
                    Object o = jsonArray.get(0);
                    JSONObject jsonObject = JSONObject.fromObject(o);
                    ArticleModel articleModel = (ArticleModel) JSONObject.toBean(jsonObject,ArticleModel.class);
                    return  new ResultOneModel(code, ErrorStateMessage.getMessge(code),articleModel);
                }else{
                    return  new ResultOneModel(code,ErrorStateMessage.getMessge(code));
                }
            }
            return  new ResultOneModel(0,"远程请求出错");
        }catch (Exception e){
            e.printStackTrace();
            return  new ResultOneModel(code,ErrorStateMessage.getMessge(code)+","+e.getMessage());
        }
    }
}

+ 319 - 61
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/doctor/EduDoctorArticleController.java

@ -1,9 +1,15 @@
package com.yihu.wlyy.web.third.jkedu.controller.doctor;
import com.alibaba.fastjson.JSON;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
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.ResultPageListModel;
import com.yihu.wlyy.web.third.jkedu.vo.ArticleModel;
import com.yihu.wlyy.web.third.jkedu.vo.CategoryModel;
import com.yihu.wlyy.web.third.jkedu.vo.base.BaseResultModel;
@ -15,17 +21,21 @@ import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.*;
/**
 * Created by Zhang Dan on 2017/9/29.
@ -41,38 +51,62 @@ public class EduDoctorArticleController extends BaseController{
    @Autowired
    private DoctorInfoService doctorInfoService;
    @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
    @Autowired
    private GcEduArticleService gcEduArticleService;
    @Autowired
    private JmsTemplate jmsTemplate;
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    @Autowired
    private FamilyContractService familyContractService;
    /**
     * 获取文章类别
     * @param categoryLevel
     * @return
     */
    @RequestMapping(value = "/getCategoryList",method = RequestMethod.GET)
    @ApiOperation("获取文章类别")
    @ResponseBody
    public ResultListModel<List<CategoryModel>> getCategoryList(
            @ApiParam(name = "categoryLevel",value = "获取类别:1、一级类别 2、二级类别",required = false)@RequestParam(value = "categoryLevel")String categoryLevel){
        int errCode =0;
        int code =0;
        try {
            //调用福州接口
            String url ="http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Category.getCategoryList&Param={\"categoryLevel\":\""+categoryLevel+"\"}&AuthInfo={ClientId:\"9000276\"}";
            String jsonStr = HttpUtil.sendPost(url,"");
            //结果转map
            Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
            System.out.println(map);
            List<CategoryModel> list = new ArrayList<CategoryModel>();
            if("10000".equals(String.valueOf(map.get("Code")))){
                String result = String.valueOf(map.get("Result"));
                Map<String,Object> resultMap = JSON.parseObject(result);
                String resultStr = String.valueOf(resultMap.get("result"));
                JSONArray jsonArray = JSONArray.fromObject(resultStr);
                list = (List<CategoryModel>) JSONArray.toCollection(jsonArray, CategoryModel.class);//转换成列表
                return new ResultListModel(list);
            }else{
                errCode =Integer.valueOf(String.valueOf(map.get("Code")));
                return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode));
            if(StringUtils.isNotBlank(jsonStr)){
                Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
                code = Integer.valueOf(String.valueOf(map.get("Code")));
                List<CategoryModel> list = new ArrayList<CategoryModel>();
                if(code==10000){
                    String result = String.valueOf(map.get("Result"));
                    Map<String,Object> resultMap = JSON.parseObject(result);
                    String resultStr = String.valueOf(resultMap.get("result"));
                    JSONArray jsonArray = JSONArray.fromObject(resultStr);
                    list = (List<CategoryModel>) JSONArray.toCollection(jsonArray, CategoryModel.class);//转换成列表
                    return new ResultListModel(list);
                }else{
                    return new ResultListModel(code, ErrorStateMessage.getMessge(code));
                }
            }
            return  new ResultListModel(0,"远程请求出错");
        }catch (Exception e){
            return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
            return new ResultListModel(code, ErrorStateMessage.getMessge(code)+","+e.getMessage());
        }
    }
    /**
     * 添加文章收藏
     * @param ArticleId
     * @param articleCategoryId
     * @param articleCategoryName
     * @return
     */
    @RequestMapping(value = "/saveArticleCollection",method = RequestMethod.POST)
    @ApiOperation("APP端--医生添加收藏文章")
    @ResponseBody
@ -81,7 +115,7 @@ public class EduDoctorArticleController extends BaseController{
            @ApiParam(name = "articleCategoryId",value = "文章类别id")@RequestParam(value = "articleCategoryId")String articleCategoryId,
            @ApiParam(name = "articleCategoryName", value = "文章类别名称")@RequestParam(value = "articleCategoryName")String articleCategoryName) {
        int errCode = 0;
        int code = 0;
        try {
            //调用福州接口
            String url = "http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Behavior.saveArticleCollection&" +
@ -97,22 +131,23 @@ public class EduDoctorArticleController extends BaseController{
            //结果转map
            if(StringUtils.isNotBlank(jsonStr)){
                Map<String, Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
                System.out.println(map);
                if ("10000".equals(String.valueOf(map.get("Code")))) {
                    return new BaseResultModel(10000,ErrorStateMessage.getMessge(10000));
                } else {
                    errCode = Integer.valueOf(String.valueOf(map.get("Code")));
                    return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode));
                }
                code = Integer.valueOf(String.valueOf(map.get("Code")));
                return new BaseResultModel(code,ErrorStateMessage.getMessge(code));
            }else{
                return new BaseResultModel(0,"远程请求过程出错");
            }
        } catch (Exception e) {
            return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode) + "," + e.getMessage());
            return new BaseResultModel(code, ErrorStateMessage.getMessge(code) + "," + e.getMessage());
        }
    }
    /**
     * 取消收藏
     * @param articleId
     * @param userId
     * @param userType
     * @return
     */
    @RequestMapping(value = "/cancelArticleCollection",method = RequestMethod.POST)
    @ApiOperation("APP端--医生取消收藏文章")
    @ResponseBody
@ -121,41 +156,46 @@ public class EduDoctorArticleController extends BaseController{
            @ApiParam(name = "userId",value = "用户id")@RequestParam(value = "userId")String userId,
            @ApiParam(name = "userType",value = "1医生2居民")@RequestParam(value = "userType")String userType) {
        int errCode = 0;
        int code = 0;
        try {
            //调用福州接口
            String url = "http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Behavior.cancelArticleCollection&" +
                    "Param={\"articleId\":\"" + articleId + "\",\"userId\":\"" + userId + "\",\"userType\":\"" + userType + "\"}&AuthInfo={ClientId:\"9000276\"}";
            String jsonStr = HttpUtil.sendPost(url, "");
            //结果转map
            Map<String, Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
            System.out.println(map);
            if ("10000".equals(String.valueOf(map.get("Code")))) {
                return new BaseResultModel(10000,"成功!");
            } else {
                errCode = Integer.valueOf(String.valueOf(map.get("Code")));
                if (errCode == -10000) {
                    return new BaseResultModel(-10000, "没有找到相应的数据");
                }else{
                    return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode));
            if (StringUtils.isNotBlank(jsonStr)){
                Map<String, Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
                code = Integer.valueOf(String.valueOf(map.get("Code")));
                if (code == -10000) {
                    return new BaseResultModel(code, "没有找到相应的数据");
                } else {
                    return new BaseResultModel(code,ErrorStateMessage.getMessge(code));
                }
            }
            return  new BaseResultModel(0,"远程请求出错");
        } catch (Exception e) {
            return new BaseResultModel(errCode, ErrorStateMessage.getMessge(errCode) + "," + e.getMessage());
            return new BaseResultModel(code, ErrorStateMessage.getMessge(code) + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "/getCollectionArticalList",method = RequestMethod.POST)
    /**
     * 收藏文章列表
     * @param articleTitle
     * @param firstLevelCategoryId
     * @param pageIndex
     * @param userType
     * @return
     */
    @RequestMapping(value = "/getCollectionArticalList",method = RequestMethod.GET)
    @ApiOperation("APP端--医生收藏文章列表")
    @ResponseBody
    public ResultListModel getCollectionArticalList(
            @ApiParam(name = "articleTitle",value = "文章标题",required = false)@RequestParam(value = "articleTitle",required = false)String articleTitle,
            @ApiParam(name = "firstLevelCategoryId",value = "一级类别ID ,多个逗号隔开",required = false)@RequestParam(value = "firstLevelCategoryId",required = false)String firstLevelCategoryId,
            @ApiParam(name = "pageIndex",value = "起始页数 0开始,默认0",required = false)@RequestParam(value = "pageIndex",required = false)String pageIndex,
            @ApiParam(name = "userType",value = "1医生2居民")@RequestParam(value = "userType")String userType,
            @ApiParam(name = "userId",value = "用户id",required = false)@RequestParam(value = "userId",required = false)String userId){
            @ApiParam(name = "userType",value = "1医生2居民")@RequestParam(value = "userType")String userType){
        int errCode =0;
        int code =0;
        int pageNo=0;
        int pageSize=5;
        try {
@ -177,23 +217,241 @@ public class EduDoctorArticleController extends BaseController{
                url += "\"userType\":\""+userType+",\"userId\":\""+getUID()+"\"}&AuthInfo={ClientId:\"9000276\"}";
            }
            String jsonStr = HttpUtil.sendPost(url,"");
            //结果转map
            Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
            System.out.println(map);
            List<ArticleModel> list = new ArrayList<ArticleModel>();
            if("10000".equals(String.valueOf(map.get("Code")))){
                String result = String.valueOf(map.get("Result"));
                String resultStr = String.valueOf(result);
                JSONArray jsonArray = JSONArray.fromObject(resultStr);
                list = (List<ArticleModel>) JSONArray.toCollection(jsonArray, ArticleModel.class);//转换成列表
                return new ResultListModel(list);
            }else{
                errCode =Integer.valueOf(String.valueOf(map.get("Code")));
                return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode));
            if(StringUtils.isNotBlank(jsonStr)){
                //结果转map
                Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
                code = Integer.valueOf(String.valueOf(map.get("Code")));
                List<ArticleModel> list = new ArrayList<ArticleModel>();
                if(code == 10000){
                    String result = String.valueOf(map.get("Result"));
                    String resultStr = String.valueOf(result);
                    JSONArray jsonArray = JSONArray.fromObject(resultStr);
                    list = (List<ArticleModel>) JSONArray.toCollection(jsonArray, ArticleModel.class);//转换成列表
                    return new ResultListModel(list);
                }else{
                    return new ResultListModel(code, ErrorStateMessage.getMessge(code));
                }
            }
            return  new ResultListModel(0,"远程请求出错");
        }catch (Exception e){
            e.printStackTrace();
            return new ResultListModel(errCode, ErrorStateMessage.getMessge(errCode)+","+e.getMessage());
            return new ResultListModel(code, ErrorStateMessage.getMessge(code)+","+e.getMessage());
        }
    }
    /**
     *
     * @param articleTitle
     * @param firstLevelCategoryId
     * @param pageIndex
     * @return
     */
    @RequestMapping(value = "/getDoctorArticalList",method = RequestMethod.GET)
    @ApiOperation("获取卫计委认证文章+医生发表未认证文章")
    @ResponseBody
    public ResultListModel<List<ArticleModel>> getDoctorArticalList(
            @ApiParam(name = "articleTitle",value = "文章标题",required = false)@RequestParam(value = "articleTitle",required = false)String articleTitle,
            @ApiParam(name = "firstLevelCategoryId",value = "一级类别ID ,多个逗号隔开",required = false)@RequestParam(value = "firstLevelCategoryId",required = false)String firstLevelCategoryId,
            @ApiParam(name = "pageIndex",value = "起始页数 0开始,默认0",required = false)@RequestParam(value = "pageIndex",required = false)String pageIndex){
        int code =0;
        int pageNo=0;
        int pageSize=5;
        try {
            //调用福州接口
            String url ="http://172.17.110.230:83/WsPlatform/rest?Api=JkEdu.Article.getDoctorArticalList&Param={\"articleState\":\"1\",\"pageSize\":\""+pageSize+"\",";
            if(org.apache.commons.lang.StringUtils.isNotBlank(articleTitle)){
                url += "\"articleTitle\":\""+articleTitle+"\",";
            }
            if(org.apache.commons.lang.StringUtils.isNotBlank(firstLevelCategoryId)){
                url += "\"firstLevelCategoryId\":\""+firstLevelCategoryId+"\",";
            }
            if(org.apache.commons.lang.StringUtils.isNotBlank(pageIndex)){
                pageNo=Integer.valueOf(pageIndex);
                url += "\"pageIndex\":\""+pageNo+"\",";
            }
            url += "\"userId\":\""+getUID()+"\"}&AuthInfo={ClientId:\"9000276\"}";
            String jsonStr = HttpUtil.sendPost(url,"");
            if (StringUtils.isNotBlank(jsonStr)){
                //结果转map
                Map<String,Object> map = (Map<String, Object>) JSON.parseObject(jsonStr);
                code = Integer.valueOf(String.valueOf(map.get("Code")));
                List<ArticleModel> list = new ArrayList<ArticleModel>();
                if(code ==10000){
                    String result = String.valueOf(map.get("Result"));
                    String resultStr = String.valueOf(result);
                    JSONArray jsonArray = JSONArray.fromObject(resultStr);
                    list = (List<ArticleModel>) JSONArray.toCollection(jsonArray, ArticleModel.class);//转换成列表
                    return new ResultListModel(list);
                }else{
                    return new ResultListModel(code, ErrorStateMessage.getMessge(code));
                }
            }
            return  new ResultListModel(0,"远程请求出错");
        }catch (Exception e){
            e.printStackTrace();
            return new ResultListModel(code, ErrorStateMessage.getMessge(code)+","+e.getMessage());
        }
    }
    /**
     *
     * @param doctorCode
     * @param articleTitle
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/getPushedList", method = RequestMethod.GET)
    @ApiOperation("查询医生已推送文章 ")
    @ResponseBody
    public ResultPageListModel<HealthEduArticlePatientModel> getPatientHealthLogs(
            @ApiParam(name = "doctorCode", value = "医生code,为空从useragent取", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "articleTitle", value = "文章标题", required = false) @RequestParam(value = "articleTitle", required = false) String articleTitle,
            @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 (StringUtils.isEmpty(doctorCode)) {
                doctorCode = getUID();
            }
            //最大1000
            if (pagesize > 1000) {
                pagesize = 1000;
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.getPatientHealthLogs(doctorCode, "", "", "", "", articleTitle, "", "", page, pagesize);
            Long count = gcEduArticleService.getPatientHealthLogsCount(getUID(), "", "", "", "", articleTitle, "", "");
            return new ResultPageListModel(
                    page,
                    pagesize,
                    count.intValue()
                    , eduArticlePatients);
        } catch (Exception e) {
            return new ResultPageListModel(com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel.statusEm.find_error.getCode(), com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "/send", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("文章推送")
    public BaseResultModel send(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code", required = true) @RequestParam(value = "sendCode", required = true) String sendCode,
            @ApiParam(name = "sendName", value = "发送人名", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "sendMessage", value = "发送人信息", required = false) @RequestParam(value = "sendMessage", required = false) String sendMessage,
            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = false) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ) {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
            String[] unPatients = unReceiveCodes.split(",");//接收人的code
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        } catch (Exception e) {
            return new BaseResultModel(-10000, ErrorStateMessage.fail + ":" + e.getMessage());
        }
    }
    /**
     * 发送到redis
     *
     * @param healthEduArticlePatients
     */
    public void sender(List<HealthEduArticlePatient> healthEduArticlePatients) {
        //送到到队列
        healthEduArticlePatients.stream().forEach(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(one).toString());
                    return textMessage;
                }
            });
        });
    }
    @RequestMapping(value = "/sendPatients", method = RequestMethod.POST)
    @ResponseBody
    @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,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(-10000, ErrorStateMessage.fail + ":" + e.getMessage());
        }
    }
    /**
     * 获取要推送的患者
     * @param type
     * @param searchType
     * @return
     */
    /*@RequestMapping(value = "/getPatientList",method = RequestMethod.POST)
    @ApiOperation("获取要推送的患者")
    @ResponseBody
    public Map<String,Object> getPatienList(
            @ApiParam(name = "type",value = "分组类型1按服务类型2按疾病类型3按健康状况4按团队标签")@RequestParam(value = "type")Integer type,
            @ApiParam(name = "searchType",value = "筛选方式1重点关注2有绑定设备3孕产妇4年纪在65以上",required = false)@RequestParam(value = "searchType",required = false)String searchType){
        String[] searchTypes = {};
        if (StringUtils.isNotBlank(searchType)){
            searchTypes = searchType.split(",");
        }
        if(type==null){
            type=1;
        }
        Map<String,Object> map = familyContractService.getPushPatientList(type,searchTypes,getUID(),"");
        return map;
    }*/
}

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

@ -0,0 +1,137 @@
package com.yihu.wlyy.web.third.jkedu.controller.doctor;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;
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.PatientLabelModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultListModel;
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.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/8/30.
 */
@Controller
@RequestMapping(value = "/wlyygc/doctor/label", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@Api(description = "疾病标签")
public class EduLableController extends BaseController {
    @Autowired
    private SignPatientLabelService signPatientLabelService;
    @Autowired
    private SignPatientLabelInfoService signPatientLabelInfoService;
    @Autowired
    private GcLabelService labelService;
    @Autowired
    private PatientService patientService;
    @RequestMapping(value = "/labels", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签")
    public ResultListModel<List<PatientLabelModel>> labels(
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType
    ) {
        try {
            List<DictModel> dictModels = labelService.getLabelsByTypeAndTeam(labelType);
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "/labelsWithNum", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签已经标签下的患者数目")
    public ResultListModel<List<PatientLabelModel>> labelsWithNum(
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "teamCode", value = "医生所属的团队ID", required = false) @RequestParam(value = "teamCode", required = false) Long teamCode
    ) {
        try {
            JSONArray result = null;
            if ("1".equals(labelType)) {
                //卫纪委服务类型
                result = patientService.getSignByTeamCodeGpbyServer(teamCode);
            } else {
                //其他标签
                result = labelService.getPatientAmountByTeamGroupLable(teamCode, labelType);
            }
            List<PatientLabelModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);
                PatientLabelModel patientLabelModel = new PatientLabelModel();
                patientLabelModel.setLabelCode(jo.getString("labelCode"));
                patientLabelModel.setLabelName(jo.getString("labelName"));
                patientLabelModel.setAmount(jo.getInt("amount"));
                patientLabelModel.setFocusAmount(jo.getInt("focusAmount"));
                patientLabelModels.add(patientLabelModel);
            }
            return new ResultListModel(patientLabelModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @RequestMapping(value = "/signPatientsByLabel", method = RequestMethod.GET)
    @ApiOperation("获取医生签约的患者列表")
    public ResultPageListModel<PatientModel> signPatients(
            @ApiParam(name = "labelType", value = "标签类型", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "labelCode", value = "标签code", required = true) @RequestParam(value = "labelCode", required = true) String labelCode,
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "isSlowDisease", value = "是否是慢病管理", required = true) @RequestParam(value="isSlowDisease",required = false,defaultValue = "false") boolean isSlowDisease
    ) {
        try {
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize, isSlowDisease, "");
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);
                PatientModel patientModel = new PatientModel();
                patientModel.setCode(jo.getString("code"));
                patientModel.setName(jo.getString("name"));
                patientModel.setWechatFocusRemind(jo.getInt("wechatFocusRemind")+"");
                patientModel.setPhoto(jo.getString("photo"));
                patientModel.setSex(jo.getInt("sex"));
                patientModel.setAge(jo.getInt("age"));
                patientLabelModels.add(patientModel);
            }
            return new ResultPageListModel(
                    page,
                    pageSize,
                    signPatientLabelInfoService.getPatientByLabelCount(getUID(), labelCode, labelType, teamCode).length()
                    ,patientLabelModels);
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    @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
    ) {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels(areas);
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkedu/controller/patient/EduPatientArticleController.java

@ -37,7 +37,7 @@ public class EduPatientArticleController extends BaseController{
    @Autowired
    private com.yihu.wlyy.util.HttpUtil HttpUtil;
    @RequestMapping(value = "/getDoctorArticalByUserId",method = RequestMethod.POST)
    @RequestMapping(value = "/getDoctorArticalByUserId",method = RequestMethod.GET)
    @ApiOperation("获取医生主页中的文章列表(医生发表文章接口)")
    @ResponseBody
    public ResultListModel<List<ArticleModel>> getDoctorArticalByUserId(