瀏覽代碼

医生端健康教育需求完善

8 年之前
父節點
當前提交
55f932348a

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticle.java

@ -32,6 +32,16 @@ public class HealthEduArticle extends IdEntity {
	private String content;
	// 发布时间
	private Date czrq;
	//文章关键字
	private String keyword;
	public String getKeyword(){
		return keyword;
	}
	public void setKeyword(String keyword){
		this.keyword = keyword;
	}
	public String getCode() {
		return code;

+ 88 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticleDoctor.java

@ -0,0 +1,88 @@
package com.yihu.wlyy.entity.education;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 患者健康教育文章
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_health_edu_article_doctor")
public class HealthEduArticleDoctor extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2828101406253527L;
	// 文章标识
	private String article;
	// 医生标识
	private String doctor;
	// 文章标题
	private String title;
	// 文章链接
	private String url;
	// 文章内容
	//private String content;
	// 发布时间
	private Date czrq;
	public String getArticle() {
		return article;
	}
	public void setArticle(String article) {
		this.article = article;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	//public String getContent() {
	//	return content;
	//}
    //
	//public void setContent(String content) {
	//	this.content = content;
	//}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 54 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticleLabel.java

@ -0,0 +1,54 @@
package com.yihu.wlyy.entity.education;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 患者健康教育文章
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_health_edu_article_label")
public class HealthEduArticleLabel extends IdEntity {
	/**
	 *
	 */
	private static final long serialVersionUID = -1828201403253527L;
	// 文章标识
	private String keyword;
	// 医生标识
	private int amount;
	// 文章标题
	private String creater;
	public String getKeyword() {
		return keyword;
	}
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	public int getAmount() {
		return amount;
	}
	public void setAmount(int amount) {
		this.amount = amount;
	}
	public String getCreater() {
		return creater;
	}
	public void setCreater(String creater) {
		this.creater = creater;
	}
}

+ 9 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/HealthEduArticleDao.java

@ -1,12 +1,20 @@
package com.yihu.wlyy.repository.education;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import java.util.Date;
public interface HealthEduArticleDao extends PagingAndSortingRepository<HealthEduArticle, Long>, JpaSpecificationExecutor<HealthEduArticle> {
	HealthEduArticle findByCode(String code);
	
	@Query("SELECT a FROM HealthEduArticle a WHERE (a.title like ?1 or a.content like ?2 or a.keyword like ?3) ORDER BY a.czrq DESC")
	Page<HealthEduArticle> list(String title, String content, String keyword, Pageable pageRequest);
}

+ 26 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/HealthEduArticleDoctorDao.java

@ -0,0 +1,26 @@
package com.yihu.wlyy.repository.education;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.education.HealthEduArticleDoctor;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import org.json.JSONArray;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface HealthEduArticleDoctorDao extends PagingAndSortingRepository<HealthEduArticleDoctor, Long>, JpaSpecificationExecutor<HealthEduArticleDoctor> {
	HealthEduArticleDoctor findByArticleAndDoctor(String article,String doctor);
	int deleteByArticleAndDoctor(String article,String doctor);
	@Query("SELECT b FROM HealthEduArticleDoctor a ,HealthEduArticle b where b.code = a.article and a.doctor =?1 ORDER BY a.czrq DESC")
	List<Object> list(String doctor,Pageable pageRequest);
	@Query("SELECT b FROM HealthEduArticleDoctor a ,HealthEduArticle b where b.code = a.article and (a.title like ?1 or b.content like?2 or b.keyword like?3) and a.doctor =?4 ORDER BY a.czrq DESC")
	List<Object> listFilter(String title,String content,String keyword,String doctor,Pageable pageRequest);
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/HealthEduArticleLabelDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.education;
import com.yihu.wlyy.entity.education.HealthEduArticleDoctor;
import com.yihu.wlyy.entity.education.HealthEduArticleLabel;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface HealthEduArticleLabelDao extends PagingAndSortingRepository<HealthEduArticleLabel, Long>, JpaSpecificationExecutor<HealthEduArticleLabel> {
	HealthEduArticleLabel findByKeywordAndCreater(String keyword, String creater);
	@Query("select b from HealthEduArticleLabel b where b.keyword=?1 and b.creater ='public'")
	HealthEduArticleLabel findByPublicKeyword(String keyword);
}

+ 109 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleDoctorService.java

@ -0,0 +1,109 @@
package com.yihu.wlyy.service.app.health;
import com.yihu.wlyy.entity.education.HealthEduArticleDoctor;
import com.yihu.wlyy.entity.education.HealthEduArticleLabel;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.repository.education.HealthEduArticleDoctorDao;
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.service.BaseService;
import org.json.JSONArray;
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;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 健康教育患者业务逻辑类
 * @author linz
 *
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class HealthEduArticleDoctorService extends BaseService {
	@Autowired
	private HealthEduArticleDoctorDao healthEduArticleDoctorDao;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	/**
	 * 根据文章标示获取数据
	 * @param article
	 * @return
	 *
	 */
	public HealthEduArticleDoctor findByArticle(String article,String doctor) {
		return healthEduArticleDoctorDao.findByArticleAndDoctor(article, doctor);
	}
	/**
	 * 根据文章删除
	 * @param article
	 * @return
	 *
	 */
	public int delete(String article,String doctor) {
		return healthEduArticleDoctorDao.deleteByArticleAndDoctor(article, doctor);
	}
	/**
	 * 保存
	 * @param healthEduArticleDoctor
	 * @return
	 */
	public HealthEduArticleDoctor save(HealthEduArticleDoctor healthEduArticleDoctor){
		return this.healthEduArticleDoctorDao.save(healthEduArticleDoctor);
	}
	/**
	 * 根据文章id获取数据
	 * @param id
	 * @return
	 */
	public HealthEduArticleDoctor findById(Long id) {
		return healthEduArticleDoctorDao.findOne(id);
	}
	/**
	 * 查询收藏的文章
	 * @param page 第几页
	 * @param pagesize 分页大小
	 * @return
	 */
	public List<Object> list(int page, int pagesize,String filter,String doctor) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		if(page<0){
			page = 0;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page, pagesize, sort);
		// 设置查询条件
		if(StringUtils.isNotBlank(filter)){
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter = "%"+filter+"%";
			return  healthEduArticleDoctorDao.listFilter(filter, filter, filter,doctor,pageRequest);
			//return healthEduArticleDoctorDao.listFilter(filter,filter,filter,pageRequest);
		}else{
			return  healthEduArticleDoctorDao.list(doctor,pageRequest);
		}
	}
}

+ 100 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleLabelService.java

@ -0,0 +1,100 @@
package com.yihu.wlyy.service.app.health;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.education.HealthEduArticleDoctor;
import com.yihu.wlyy.entity.education.HealthEduArticleLabel;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.repository.education.HealthEduArticleDoctorDao;
import com.yihu.wlyy.repository.education.HealthEduArticleLabelDao;
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;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 健康教育患者业务逻辑类
 * @author linz
 *
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class HealthEduArticleLabelService extends BaseService {
	@Autowired
	private HealthEduArticleLabelDao healthEduArticleLabelDao;
	/**
	 * 更新标签
	 * @param keyword 关键字
	 * @param user 人员
	 * @return
	 *
	 */
	public void saveOrUpdateLabel(String keyword,String user) {
		 HealthEduArticleLabel healthEduArticleLabel =  healthEduArticleLabelDao.findByPublicKeyword(keyword);
		 if(healthEduArticleLabel==null){//公共标签不存在则添加
			 HealthEduArticleLabel publicLabel = new HealthEduArticleLabel();
			 publicLabel.setAmount(1);
			 publicLabel.setCreater("public");
			 publicLabel.setKeyword(keyword);
			 this.healthEduArticleLabelDao.save(publicLabel);
		 }else{//存在更新次数
			 int amount = healthEduArticleLabel.getAmount();
			 healthEduArticleLabel.setAmount(amount+1);
			 this.healthEduArticleLabelDao.save(healthEduArticleLabel);
		 }
		HealthEduArticleLabel userLabel =  healthEduArticleLabelDao.findByKeywordAndCreater(keyword, user);
		if(userLabel==null){//个人标签
			userLabel = new HealthEduArticleLabel();
			userLabel.setAmount(1);
			userLabel.setCreater(user);
			userLabel.setKeyword(keyword);
			this.healthEduArticleLabelDao.save(userLabel);
		}else{//存在更新次数
			int amount = userLabel.getAmount();
			userLabel.setAmount(amount+1);
			this.healthEduArticleLabelDao.save(userLabel);
		}
	}
	/**
	 * 获取文章列表
	 * @param page 页码
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	public Page<HealthEduArticleLabel> findAll(int page, int pagesize,int type,String user) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		if(page<0){
			page = 0;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "amount");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if(type==1){
			filters.put("creater", new SearchFilter("creater", SearchFilter.Operator.EQ, "public"));
		}else if(type==2){
			filters.put("creater", new SearchFilter("creater", SearchFilter.Operator.EQ, user));
		}
		Specification<HealthEduArticleLabel> spec = DynamicSpecifications.bySearchFilter(filters.values(), HealthEduArticleLabel.class);
		return healthEduArticleLabelDao.findAll(spec, pageRequest);
	}
}

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

@ -39,6 +39,8 @@ public class HealthEduArticleService extends BaseService {
	private HealthEduArticlePatientDao healthEduArticlePatientDao;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	/**
	 * 查询文章信息
@ -55,7 +57,7 @@ public class HealthEduArticleService extends BaseService {
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	public Page<HealthEduArticle> findAll(int page, int pagesize,String filter) {
	public Page<HealthEduArticle> findAll(int page, int pagesize,String filter,String doctor) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
@ -69,7 +71,9 @@ public class HealthEduArticleService extends BaseService {
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if (StringUtils.isNotBlank(filter)) {
			filters.put("title", new SearchFilter("filter", Operator.LIKE, filter));
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter="%"+filter+"%";
			return healthEduArticleDao.list(filter, filter, filter, pageRequest);
		}
		Specification<HealthEduArticle> spec = DynamicSpecifications.bySearchFilter(filters.values(),HealthEduArticle.class);
		return healthEduArticleDao.findAll(spec, pageRequest);

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

@ -2,14 +2,14 @@ package com.yihu.wlyy.web.doctor.health;
import java.util.*;
import com.yihu.wlyy.entity.education.HealthEduArticleOpHistory;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.app.health.HealthEduArticlePatientService;
import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
@ -20,9 +20,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
@ -51,6 +48,12 @@ public class DoctorHealthEduArticleController extends BaseController {
	@Autowired
	private HealthEduArticlePatientService healthEduArticlePatientService;
	@Autowired
	private HealthEduArticleDoctorService healthEduArticleDoctorService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	/**
	 * 查询
	 * @param pagesize 分页大小
@ -60,7 +63,7 @@ public class DoctorHealthEduArticleController extends BaseController {
	@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) {
		try {
			Page<HealthEduArticle> list = healthEduArticleService.findAll(page, pagesize,filter);
			Page<HealthEduArticle> list = healthEduArticleService.findAll(page, pagesize,filter,getUID());
			JSONArray jsonArray = new JSONArray();
			if (list != null) {
				for (HealthEduArticle article : list) {
@ -76,6 +79,8 @@ public class DoctorHealthEduArticleController extends BaseController {
					json.put("content", article.getContent());
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
					json.put("keyword", article.getKeyword());
					int collectionAmount =  healthEduArticleOpHistoryService.countCollectionAmount(article.getCode());
					int readAmount = healthEduArticleOpHistoryService.countReadAmount(article.getCode());
					int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(article.getCode());
@ -83,6 +88,8 @@ public class DoctorHealthEduArticleController extends BaseController {
					json.put("readAmount", readAmount);
					//收藏量
					json.put("collectionAmount", collectionAmount);
					//转发量
					json.put("repeatAmount", repeatAmount);
					//是否收藏
@ -98,6 +105,40 @@ public class DoctorHealthEduArticleController extends BaseController {
		}
	}
	/**
	 * 查询医生收藏列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "listDoctor")
	@ResponseBody
	public String listDoctor(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "filter",required = false)String filter) {
		try {
			List<Object> list = healthEduArticleDoctorService.list(page, pagesize,filter,getUID());
			return write(200, "查询成功", "list", list);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询标签列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "listLabel")
	@ResponseBody
	public String listLabel(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "type",required = false,defaultValue = "0")int type) {
		try {
			Page<HealthEduArticleLabel> list = healthEduArticleLabelService.findAll(page,pagesize,type,getUID());
			return write(200, "查询成功", "list", list);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询文章列表
	 * @param code 数据文章唯一标示code
@ -242,7 +283,51 @@ public class DoctorHealthEduArticleController extends BaseController {
			patientSet.add(patient);
		}
		if(result.length()==100){
			getPatientByGroup( labelCode,labelType,teamCode,patientSet,page+1,pagesize);
			getPatientByGroup(labelCode,labelType,teamCode,patientSet,page+1,pagesize);
		}
	}
	/**
	 * 文章收藏
	 * @param article 文章CODE
	 * @return
	 */
	@RequestMapping(value = "collectionArticle")
	@ResponseBody
	public String collectionArticle(@RequestParam(value = "article",required = true)String article){
		HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article,getUID());
		if(healthEduArticleDoctor!=null){
			return error(-1, "收藏失败,该文章已经收藏!");
		}
		HealthEduArticle healthEduArticle =	healthEduArticleService.findArticleByCode(article);
		healthEduArticleDoctor = new HealthEduArticleDoctor();
		try{
			BeanUtils.copyProperties(healthEduArticle,healthEduArticleDoctor);
			healthEduArticleDoctor.setDoctor(getUID());
			healthEduArticleDoctor.setArticle(healthEduArticle.getCode());
			healthEduArticleDoctorService.save(healthEduArticleDoctor);
			//更新收藏量
			healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.COLLECTION_STATUS,healthEduArticle.getCode(),healthEduArticle.getTitle(),getUID());
			return success("收藏成功!");
		}catch (Exception e){
			error(e);
			return error(-1, "收藏失败!");
		}
	}
	/**
	 * 文章收藏
	 * @param article 文章CODE
	 * @return
	 */
	@RequestMapping(value = "uncollectionArticle")
	@ResponseBody
	public String uncollectionArticle(@RequestParam(value = "article",required = true)String article){
		try{
			healthEduArticleDoctorService.delete(article,getUID());
			return success("取消收藏成功!");
		}catch (Exception e){
			error(e);
			return error(-1, "取消收藏失败!");
		}
	}