Pārlūkot izejas kodu

医生端健康教育需求完善

8 gadi atpakaļ
vecāks
revīzija
70f2e7f7ed

+ 5 - 1
patient-co-wlyy/pom.xml

@ -259,7 +259,11 @@
            <version>20160212</version>
        </dependency>
        <!-- JSON end -->
        <dependency>
            <groupId>org.htmlparser</groupId>
            <artifactId>htmlparser</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>

+ 13 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticleLabel.java

@ -21,12 +21,22 @@ public class HealthEduArticleLabel extends IdEntity {
	 */
	private static final long serialVersionUID = -1828201403253527L;
	// 文章标识
	// 文章搜索关键字
	private String keyword;
	// 医生标识
	// 总数
	private int amount;
	// 文章标题
	// 创建人
	private String creater;
	//创建日期
	private Date czrq;
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getKeyword() {
		return keyword;

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

@ -15,6 +15,6 @@ public interface HealthEduArticleDao extends PagingAndSortingRepository<HealthEd
	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);
	@Query("SELECT a FROM HealthEduArticle a WHERE (a.title like ?1 or a.keyword like ?2) ORDER BY a.czrq DESC")
	Page<HealthEduArticle> list(String title, String keyword, Pageable pageRequest);
}

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

@ -21,6 +21,6 @@ public interface HealthEduArticleDoctorDao extends PagingAndSortingRepository<He
	@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);
	@Query("SELECT b FROM HealthEduArticleDoctor a ,HealthEduArticle b where b.code = a.article and (a.title like ?1 or b.keyword like?2) and a.doctor =?3 ORDER BY a.czrq DESC")
	List<Object> listFilter(String title,String keyword,String doctor,Pageable pageRequest);
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/HealthEduArticleOpHistoryDao.java

@ -13,4 +13,6 @@ public interface HealthEduArticleOpHistoryDao extends PagingAndSortingRepository
	int countByCodeStatus(String code,String status);
	@Query("select count(1) from HealthEduArticleOpHistory a where a.creater = ?1 and a.status = ?2")
	int countByUserStatus(String user,String status);
	int deleteByCodeAndStatusAndCreater(String code,String status,String creater);
}

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

@ -38,6 +38,9 @@ public class HealthEduArticleDoctorService extends BaseService {
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	/**
	 * 根据文章标示获取数据
	 * @param article
@ -55,6 +58,8 @@ public class HealthEduArticleDoctorService extends BaseService {
	 *
	 */
	public int delete(String article,String doctor) {
		//删除收藏统计
		healthEduArticleOpHistoryService.delCollectAmount(article,doctor);
		return healthEduArticleDoctorDao.deleteByArticleAndDoctor(article, doctor);
	}
@ -97,7 +102,7 @@ public class HealthEduArticleDoctorService extends BaseService {
		if(StringUtils.isNotBlank(filter)){
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter = "%"+filter+"%";
			return  healthEduArticleDoctorDao.listFilter(filter, filter, filter,doctor,pageRequest);
			return  healthEduArticleDoctorDao.listFilter(filter, filter,doctor,pageRequest);
			//return healthEduArticleDoctorDao.listFilter(filter,filter,filter,pageRequest);
		}else{
			return  healthEduArticleDoctorDao.list(doctor,pageRequest);

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

@ -88,7 +88,7 @@ public class HealthEduArticleLabelService extends BaseService {
			page = 0;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC,"amount","cjrq");
		Sort sort = new Sort(Direction.DESC,"amount","czrq");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page, pagesize, sort);
		// 设置查询条件

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

@ -43,13 +43,15 @@ public class HealthEduArticleOpHistoryService extends BaseService {
		return healthEduArticleOpHistoryDao.countByCodeStatus(code,HealthEduArticleOpHistory.READ_STATUS);
	}
	/**
	 * 汇总转发量
	 * @param code
	 * @return
	 */
	public int countRepeatAmount(String code){
		return healthEduArticleOpHistoryDao.countByCodeStatus(code,HealthEduArticleOpHistory.COLLECTION_STATUS);
		return healthEduArticleOpHistoryDao.countByCodeStatus(code,HealthEduArticleOpHistory.REPEAT_STATUS);
	}
	/**
@ -58,7 +60,11 @@ public class HealthEduArticleOpHistoryService extends BaseService {
	 * @return
	 */
	public  int countCollectionAmount(String code){
		return healthEduArticleOpHistoryDao.countByCodeStatus(code,HealthEduArticleOpHistory.REPEAT_STATUS);
		return healthEduArticleOpHistoryDao.countByCodeStatus(code,HealthEduArticleOpHistory.COLLECTION_STATUS);
	}
	public int delCollectAmount(String code,String user){
		return healthEduArticleOpHistoryDao.deleteByCodeAndStatusAndCreater(code,HealthEduArticleOpHistory.COLLECTION_STATUS,user);
	}
	public int countByUserStatus(String user,String status){

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

@ -73,7 +73,7 @@ public class HealthEduArticleService extends BaseService {
		if (StringUtils.isNotBlank(filter)) {
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter="%"+filter+"%";
			return healthEduArticleDao.list(filter, filter, filter, pageRequest);
			return healthEduArticleDao.list(filter,filter, pageRequest);
		}
		Specification<HealthEduArticle> spec = DynamicSpecifications.bySearchFilter(filters.values(),HealthEduArticle.class);
		return healthEduArticleDao.findAll(spec, pageRequest);

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

@ -7,6 +7,10 @@ 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.htmlparser.Parser;
import org.htmlparser.beans.StringBean;
import org.htmlparser.util.ParserException;
import org.htmlparser.visitors.TextExtractingVisitor;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
@ -18,7 +22,6 @@ 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 com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
@ -75,26 +78,29 @@ public class DoctorHealthEduArticleController extends BaseController {
					json.put("title", article.getTitle());
					// 文章查看URL
					json.put("url", article.getUrl());
					// 文章简介
					json.put("content", article.getContent());
					json.put("content", parsrHtml(article.getContent()));
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
					json.put("keyword", article.getKeyword());
					json.put("keyword", StringUtils.isNotBlank(article.getKeyword())?article.getKeyword():"");
					int collectionAmount =  healthEduArticleOpHistoryService.countCollectionAmount(article.getCode());
					int readAmount = healthEduArticleOpHistoryService.countReadAmount(article.getCode());
					int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(article.getCode());
					HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article.getCode(), getUID());
					//阅读量
					json.put("readAmount", readAmount);
					//收藏量
					json.put("collectionAmount", collectionAmount);
					//转发量
					json.put("repeatAmount", repeatAmount);
					//是否收藏
					json.put("collection",1);
					if(healthEduArticleDoctor!=null){
						json.put("collection",1);
					}else{
						json.put("collection",0);
					}
					jsonArray.put(json);
				}
			}
@ -115,7 +121,43 @@ public class DoctorHealthEduArticleController extends BaseController {
	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);
			JSONArray jsonArray = new JSONArray();
			for(Object obj:list){
				HealthEduArticle healthEduArticle= (HealthEduArticle)obj;
				JSONObject json = new JSONObject();
				json.put("id", healthEduArticle.getId());
				// 文章标识
				json.put("code", healthEduArticle.getCode());
				// 文章标题
				json.put("title", healthEduArticle.getTitle());
				// 文章查看URL
				json.put("url", healthEduArticle.getUrl());
				// 文章简介
				json.put("content", parsrHtml(healthEduArticle.getContent()));
				// 添加日期
				json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
				json.put("keyword", StringUtils.isNotBlank(healthEduArticle.getKeyword())?healthEduArticle.getKeyword():"");
				int collectionAmount =  healthEduArticleOpHistoryService.countCollectionAmount(healthEduArticle.getCode());
				int readAmount = healthEduArticleOpHistoryService.countReadAmount(healthEduArticle.getCode());
				int repeatAmount = healthEduArticleOpHistoryService.countRepeatAmount(healthEduArticle.getCode());
				HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
				//阅读量
				json.put("readAmount", readAmount);
				//收藏量
				json.put("collectionAmount", collectionAmount);
				//转发量
				json.put("repeatAmount", repeatAmount);
				//是否收藏
				if(healthEduArticleDoctor!=null){
					json.put("collection",1);
				}else{
					json.put("collection",0);
				}
				jsonArray.put(json);
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
@ -162,13 +204,20 @@ public class DoctorHealthEduArticleController extends BaseController {
			json.put("code", healthEduArticle.getCode());
			// 文章标题
			json.put("title", healthEduArticle.getTitle());
			json.put("url", healthEduArticle.getUrl());
			// 文章内容
			json.put("content", healthEduArticle.getContent());
			// 添加日期
			json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
			int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
			json.put("readAmount",readAmount);
			json.put("collection",1);
			HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
			if(healthEduArticleDoctor==null){
				json.put("collection",0);
			}else{
				json.put("collection",1);
			}
			return write(200, "查询成功", "data", json);
		} catch (Exception ex) {
			error(ex);
@ -324,6 +373,7 @@ public class DoctorHealthEduArticleController extends BaseController {
	public String uncollectionArticle(@RequestParam(value = "article",required = true)String article){
		try{
			healthEduArticleDoctorService.delete(article,getUID());
			return success("取消收藏成功!");
		}catch (Exception e){
			error(e);
@ -331,4 +381,15 @@ public class DoctorHealthEduArticleController extends BaseController {
		}
	}
	private String parsrHtml(String html) throws ParserException{
		Parser parser = null;
		try{
			parser = new Parser(html);
		}catch (ParserException e){
			return html;//纯文本内容会转换失败,直接返回文本内容
		}
		TextExtractingVisitor visitor = new TextExtractingVisitor();
		parser.visitAllNodesWith(visitor);
		return StringUtils.isNotBlank(visitor.getExtractedText())?visitor.getExtractedText():"内容为图集,请点击查看";
	}
}