Переглянути джерело

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

linzhuo 8 роки тому
батько
коміт
653cb9eceb

+ 20 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java

@ -48,6 +48,26 @@ public class HealthEduArticlePatient extends IdEntity {
	private Long adminTeamCode;
	// 简介
	private String summary;
	//附加内容
	private String attachedContent;
	//批次号记录发送所属批次
	private String batchNo;
	public String getBatchNo() {
		return batchNo;
	}
	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}
	public String getAttachedContent() {
		return attachedContent;
	}
	public void setAttachedContent(String attachedContent) {
		this.attachedContent = attachedContent;
	}
	public String getPatient() {
		return patient;

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -27,6 +27,7 @@ public class DoctorInterceptor extends BaseInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        if(flag)return true;
        try {
            request.setCharacterEncoding("UTF-8");
            request.setAttribute("log-start", new Date().getTime());

+ 88 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticlePatientService.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.repository.education.HealthEduArticleDao;
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -95,7 +96,7 @@ public class HealthEduArticlePatientService extends BaseService {
     * @param pagesize 分页大小
     * @return
     */
    public List<HealthEduArticlePatient> findByPatient(String patient, long id, int pagesize) {
    public List<HealthEduArticlePatient> findByPatient(String patient,int wheaType, long id, int pagesize) {
        if (pagesize <= 0) {
            pagesize = 10;
        }
@ -110,6 +111,7 @@ public class HealthEduArticlePatientService extends BaseService {
                "    ,b.summary as content" +
                "    ,a.is_read as 'read'" +
                "    ,a.czrq" +
                "    ,a.attached_content" +
                " from" +
                "     wlyy_health_edu_article_patient a" +
                "     , wlyy_health_edu_article b" +
@ -117,12 +119,95 @@ public class HealthEduArticlePatientService extends BaseService {
                "      a.article = b.code" +
                " and a.patient = ?" +
                (id > 0 ? " and a.id < ? " : "") +
                (wheaType > 0 ? " and a.wheaType = ? " : "") +
                " order by a.id desc limit 0," + pagesize;
        List<HealthEduArticlePatient> list = jdbcTemplate.query(sql,
                id > 0 ? new Object[]{patient,id} : new Object[]{patient}, new BeanPropertyRowMapper(HealthEduArticlePatient.class));
        Object params[] = null;
        if(wheaType>0&&id>0){
            params = new Object[]{patient,id,wheaType};
        }else if(wheaType>0&&id<0){
            params = new Object[]{patient,wheaType};
        }
        else if(wheaType<0&&id>0){
            params = new Object[]{patient,id};
        }else{
            params = new Object[]{patient};
        }
        List<HealthEduArticlePatient> list = jdbcTemplate.query(sql,params, new BeanPropertyRowMapper(HealthEduArticlePatient.class));
        return list;
    }
    /**
     * 查询患者文章
     *
     * @param doctor  医生标识
     * @param  page 第几页
     * @param pagesize 分页大小
     * @return
     */
    public List<Map<String,Object>> findByDoctor(String doctor,int page, int pagesize) {
        if (pagesize <= 0) {
            pagesize = 10;
        }
        if(page<=0){
            page = 1 ;
        }
        int start = (page-1) * pagesize;
        String sql ="select a.article,b.summary,a.attached_content, a.czrq,count(a.patient) as amount,GROUP_CONCAT(p.name) as  patients,a.batch_no from "+
        " wlyy_health_edu_article_patient a, "+
        " wlyy_health_edu_article b,"+
        " wlyy_patient p"+
        " where"+
        " a.article = b.code"+
        " and a.patient = p.code"+
        " and a.doctor =? "+
        " group BY a.batch_no,a.article,a.attached_content,b.summary,a.doctor limit ?,?";
        Object params[] = new Object[]{doctor,start,pagesize};
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,params);
        return list;
    }
    /**
     * 查询批次号相关的文章及成员信息
     * @param doctor
     * @param article
     * @param batchNo
     * @return
     */
    public List<Map<String,Object>> findByBatchNo(String doctor,String article, String  batchNo) {
        String sql ="select a.article,b.content,a.attached_content, a.czrq,a.batch_no,sum(a.is_read) as no_read from "+
                " wlyy_health_edu_article_patient a, "+
                " wlyy_health_edu_article b,"+
                " wlyy_patient p"+
                " where"+
                " a.article = b.code"+
                " and a.patient = p.code"+
                " and a.doctor =? "+
                " and a.article =? "+
                (StringUtils.isNotBlank(batchNo)?" and a.batch_no =? ":"and a.batch_no is null ")+
                " group BY a.batch_no,a.article,b.content,b.summary,a.doctor";
        Object params[] =  (StringUtils.isNotBlank(batchNo)?new Object[]{doctor,article,batchNo}:new Object[]{doctor,article,});
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,params);
        for(Map<String,Object> dataMap :list){
            String patientListSql ="select a.patient,p.name,a.is_read,sum(a.is_read) as amount"+
            " from wlyy_health_edu_article_patient a,wlyy_health_edu_article b,wlyy_patient p"+
            " where "+
            " a.article = b.code " +
            " and a.doctor=? and  a.article =?"+
            (StringUtils.isNotBlank(batchNo)?" and a.batch_no =? ":" and a.batch_no is null ")+
            " and a.patient = p.code " +
            " group BY a.batch_no,a.article,b.content,a.attached_content,a.patient";
            List<Map<String,Object>> patientList = jdbcTemplate.queryForList(patientListSql,params);
            dataMap.put("patients",patientList);
            dataMap.put("read_amount",patientList.size()-Integer.parseInt(dataMap.get("no_read").toString()));
            dataMap.put("admount",patientList.size());
        }
        return list;
    }
    /**
     * 文章更新为已读
     *

+ 10 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -164,7 +164,7 @@ public class HealthEduArticleService extends BaseService {
     * @param pagesize 分页大小
     * @return 列表
     */
    public List<Map<String, Object>> findAll(int page, int pagesize, String filter, String doctor, String patient) {
    public List<Map<String, Object>> findAll(int page, int pagesize, String filter, String doctor, String patient,int wheaType) {
        if (pagesize <= 0) {
            pagesize = 10;
        }
@ -184,22 +184,23 @@ public class HealthEduArticleService extends BaseService {
            params.add(doctor);
            params.add(patient);
        }
        sql.append(" from wlyy_health_edu_article a ");//内联取文章内容
        String where = " ";
        sql.append(" from wlyy_health_edu_article a  ");//内联取文章内容
        String where = " where 1=1 ";
        if (StringUtils.isNotBlank(filter)) {
            //记录搜索记录
            healthEduArticleLabelService.saveOrUpdateLabel(filter, doctor);
            filter = "%" + filter + "%";
            where += " where ( a.title like ? or a.keyword like ? )";
            where += " and  ( a.title like ? or a.keyword like ? )";
            params.add(filter);
            params.add(filter);
        }
        if(wheaType>=0){
            where += " and  ( a.whea_type = ? )";
            params.add(wheaType);
        }
        int start = page * pagesize;
        String pageInfo = " limit " + start + "," + pagesize;
        String orderBy = " order by a.czrq,a.id desc";
        sql.append(where).append(orderBy).append(pageInfo);
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(), params.toArray());
        return result;
@ -226,6 +227,8 @@ public class HealthEduArticleService extends BaseService {
                "    ,d.name" +
                "    ,d.photo" +
                "    ,a.admin_team_code" +
                "    ,a.is_read" +
                "    ,a.attached_content" +
                "  from" +
                "    wlyy_health_edu_article_patient a" +
                "    ,wlyy_health_edu_article b" +

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -328,4 +328,6 @@ public class ImUtill {
    public  static final String SESSION_TYPE_SYSTEM = "0";
    public  static final String SESSION_STATUS_PROCEEDINGS= "0";
    public  static final String SESSION_STATUS_END= "1";
    public  static final String CONTENT_TYPE_TEXT= "1";
}

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

@ -11,6 +11,7 @@ import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.doctor.message.DoctorMessageController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
@ -84,13 +85,18 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
     * 查询
     *
     * @param pagesize 分页大小
     * @param wheaType 文章类型
     * @return 列表
     */
    @RequestMapping(value = "list")
    @ResponseBody
    public String list(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "filter", required = false) String filter, @RequestParam(value = "patient", required = false) String patient) {
    public String list(@RequestParam(value = "page", required = true) int page,
                       @RequestParam(value = "pagesize", required = true) int pagesize,
                       @RequestParam(value = "wheaType", required = true) int wheaType,
                       @RequestParam(value = "filter", required = false) String filter,
                       @RequestParam(value = "patient", required = false) String patient) {
        try {
            List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize, filter, getUID(), patient);
            List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize, filter, getUID(), patient,wheaType);
            JSONArray jsonArray = new JSONArray();
            if (list != null) {
                for (Map<String, Object> map : list) {
@ -170,6 +176,10 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                    // 文章简介
                    //json.put("content", parsrHtml(map.get("content").toString()));
                    json.put("content", map.get("content").toString());
                    json.put("read", map.get("is_read"));
                    json.put("attached_content", map.get("attached_content"));
                    // 发送日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                    // 发送团队
@ -302,6 +312,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
     * @param code    文章标识,多个以逗号分隔
     * @param patient 患者标识,多个以逗号分隔
     * @param group   所选群组,多个用逗号分隔
     * @param  attachedContent 附加内容
     * @return
     */
    @RequestMapping(value = "send")
@ -310,7 +321,8 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                       @RequestParam(value = "patient", required = false) String patient,
                       @RequestParam(value = "group", required = false, defaultValue = "") String group,
                       @RequestParam(value = "labelType", required = false) String labelType,
                       @RequestParam(value = "teamCode", required = false) long teamCode) {
                       @RequestParam(value = "teamCode", required = false) long teamCode,
                       @RequestParam(value = "attachedContent", required = false) String attachedContent) {
        try {
            List<HealthEduArticlePatient> list = new ArrayList<HealthEduArticlePatient>();
            if (StringUtils.isEmpty(code)) {
@ -347,11 +359,15 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
            }
            // 查询医生信息
            Doctor doctor = doctorService.findDoctorByCode(getUID());
            //Doctor doctor = doctorService.findDoctorByCode("test00000000005");
            String msgHead = doctor.getName() + "医生给您发来了一篇患教文章";
            String endMsg = "为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
            String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
            if(StringUtils.isNotBlank(attachedContent)){
                endMsg = attachedContent;
            }
            JSONArray messages = new JSONArray();
            Map<String, Map<String, Object>> msgs = new HashMap<>();
            String batchNo = UUID.randomUUID().toString();
            Date createTime = new Date();
            for (String p : patientSet) {
                Patient patientTemp = patientService.findByCode(p);
                SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
@ -390,25 +406,33 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                    heap.setSignType(2);
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    //附加内容
                    heap.setAttachedContent(attachedContent);
                    //批次号记录发送批次
                    heap.setBatchNo(batchNo);
                    //创建时间
                    heap.setCzrq(createTime);
                    list.add(heap);
                    consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
                    //if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
                        json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                        json.put("toUser", p);
                        json.put("article", temp.getCode() + "");
                        json.put("title", temp.getTitle());
                        json.put("doctorName", doctor.getName());
                        json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                        json.put("remark", endMsg);
                        Map<String, Object> content = new HashMap<>();
                        content.put("openid", patientTemp.getOpenid());
                        content.put("name", patientTemp.getName());
                        content.put("json", json);
                        content.put("code",patientTemp.getCode());
                        msgs.put(patientTemp.getCode(), content);
                    //}
                    if(StringUtils.isNotBlank(attachedContent)){
                        //发送备注
                        consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, attachedContent, ImUtill.CONTENT_TYPE_TEXT, patientTemp.getName());
                    }
                    // 推送消息给微信端
                    JSONObject json = new JSONObject();
                    json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                    json.put("toUser", p);
                    json.put("article", temp.getCode() + "");
                    json.put("title", temp.getTitle());
                    json.put("doctorName", doctor.getName());
                    json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                    json.put("remark", endMsg);
                    Map<String, Object> content = new HashMap<>();
                    content.put("openid", patientTemp.getOpenid());
                    content.put("name", patientTemp.getName());
                    content.put("json", json);
                    content.put("code",patientTemp.getCode());
                    msgs.put(patientTemp.getCode(), content);
                }
            }
            // 保存到数据库
@ -437,15 +461,10 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                            PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9, member.getOpenid(), member.getName(), data);
                        }
                    }
                    JSONObject json = (JSONObject) map.get("json");
                }
                for (HealthEduArticlePatient heap : list) {
                    BusinessLogs.info(BusinessLogs.BusinessType.article, getUID(), heap.getPatient(), new JSONObject(heap));
                }
                // 推送消息给患者
                PushMsgTask.getInstance().put(messages);
                return success("发送成功!");
@ -516,6 +535,29 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/logs")
    @ResponseBody
    public String getPatientHealthLogs(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize){
       try{
           List<Map<String,Object>> result  =  healthEduArticlePatientService.findByDoctor(getUID(),page,pagesize);
           return write(200,"查询成功!","list",result);
       }catch (Exception e){
           return write(-1,"查询失败!");
       }
    }
    @RequestMapping(value = "/log")
    @ResponseBody
    public String getPatientHealthLog(@RequestParam(value = "article", required = true) String article, @RequestParam(value = "batchNo", required = false) String batchNo){
        try{
            List<Map<String,Object>> result  =   healthEduArticlePatientService.findByBatchNo(getUID(),article,batchNo);
            return write(200,"查询成功!","list",result);
        }catch (Exception e){
            return write(-1,"查询失败!");
        }
    }
    private String parsrHtml(String html) {
        html = ("<span>" + html + "</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
        Parser parser = null;

+ 4 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -59,9 +59,9 @@ public class HealthEduArticleController extends BaseController {
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(@RequestParam("id")long id, @RequestParam("pagesize") int pagesize) {
	public String list(@RequestParam("id")long id, @RequestParam("pagesize") int pagesize,@RequestParam(required = true,value="wheaType")int wheaType) {
		try {
			List<HealthEduArticlePatient> list = healthEduArticlePatientService.findByPatient(getUID(), id, pagesize);
			List<HealthEduArticlePatient> list = healthEduArticlePatientService.findByPatient(getUID(),wheaType, id, pagesize);
			JSONArray jsonArray = new JSONArray();
			Map<String,Doctor> docMap = new HashMap<>();
			if (list != null) {
@ -83,6 +83,8 @@ public class HealthEduArticleController extends BaseController {
					json.put("read", article.getRead());
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
					//附加内容
					json.put("attached_content", article.getAttachedContent());
					if(docMap.get(article.getDoctor())==null){
						Doctor doctor = doctorService.findDoctorByCode(article.getDoctor());
@ -91,15 +93,6 @@ public class HealthEduArticleController extends BaseController {
					}else{
						json.put("photo",docMap.get(article.getDoctor()).getPhoto());
					}
					//int collectionAmount =  healthEduArticleOpHistoryService.countCollectionAmount(article.getArticle());
					//int readAmount = healthEduArticleOpHistoryService.countReadAmount(article.getArticle());
					//int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(article.getArticle());
					////阅读量
					//json.put("readAmount", readAmount);
					////收藏量
					//json.put("collectionAmount", collectionAmount);
					////转发量
					//json.put("repeatAmount", repeatAmount);
					jsonArray.put(json);
				}
			}

+ 7 - 7
patient-co-wlyy/src/main/resources/application.properties

@ -75,23 +75,23 @@ redis.host=172.19.103.47
redis.port=6379
redis.password=
#---------------------------------���Ի������ݿ�����---------------------------------------#
###### mysql database setting
##### mysql database setting
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#jdbc.username=luofaqiang
#jdbc.password=luofaqiang
#jdbc.username=root
#jdbc.password=123456
#
###### health index
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://172.19.103.85/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=luofaqiang
#health.jdbc.password=luofaqiang
#health.jdbc.username=root
#health.jdbc.password=123456
#
###### suifang
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=luofaqiang
#fv.jdbc.password=luofaqiang
#fv.jdbc.username=root
#fv.jdbc.password=123456
#
###### redis
#redis.host=172.19.103.88