Ver código fonte

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

lyr 8 anos atrás
pai
commit
8fde5ef5d8

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

@ -14,12 +14,14 @@ 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.jdbc.core.JdbcTemplate;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -41,6 +43,9 @@ public class HealthEduArticleDoctorService extends BaseService {
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
	 * 根据文章标示获取数据
	 * @param article
@ -87,27 +92,43 @@ public class HealthEduArticleDoctorService extends BaseService {
	 * @param pagesize 分页大小
	 * @return
	 */
	public List<Object> list(int page, int pagesize,String filter,String doctor) {
	public List<Map<String, Object>> list(int page, int pagesize,String filter,String doctor,String patient) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		if(page<0){
			page = 0;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page, pagesize, sort);
		// 设置查询条件
		List<Object> params = new ArrayList<Object>();
		StringBuffer sql = new StringBuffer();
		sql.append("select a.id,a.article,a.doctor,a.title,a.url,a.czrq,b.content,b.keyword");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.article and c.status = 1) as readAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.article and c.status = 2) as collectionAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.article and c.status = 3) as repeatAmount");
		if(StringUtils.isNotBlank(patient)) {
			params.add(doctor);
			sql.append(",(select count(1) from wlyy_health_edu_article_patient c where c.article = a.article and c.doctor=?) as send");
		}
		sql.append(" from wlyy_health_edu_article_doctor a left join wlyy_health_edu_article b on a.article = b.code ");//内联取文章内容
		String where = " where a.doctor = ?";
		params.add(doctor);
		if(StringUtils.isNotBlank(filter)){
			//记录搜索记录
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter = "%"+filter+"%";
			return  healthEduArticleDoctorDao.listFilter(filter, filter,doctor,pageRequest);
			//return healthEduArticleDoctorDao.listFilter(filter,filter,filter,pageRequest);
		}else{
			return  healthEduArticleDoctorDao.list(doctor,pageRequest);
			filter="%"+filter+"%";
			params.add(filter);
			params.add(filter);
			where+=" and ( a.title like ? or b.keyword like ? )";
		}
		int start = page * pagesize;
		String pageInfo = " limit "+start+","+pagesize;
		String orderBy = " order by a.id,a.czrq desc";
		sql.append(where).append(orderBy).append(pageInfo);
		List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(),params.toArray());
		return result;
	}

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

@ -12,6 +12,7 @@ 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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
@ -41,6 +42,8 @@ public class HealthEduArticleService extends BaseService {
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
	 * 查询文章信息
@ -57,51 +60,44 @@ public class HealthEduArticleService extends BaseService {
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	public Page<HealthEduArticle> findAll(int page, int pagesize,String filter,String doctor) {
	public List<Map<String, Object>> findAll(int page, int pagesize,String filter,String doctor,String patient) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		if(page<0){
			page = 0;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if (StringUtils.isNotBlank(filter)) {
		List<Object> params = new ArrayList<Object>();
		StringBuffer sql = new StringBuffer();
		sql.append("select a.id,a.code,a.title,a.url,a.czrq,a.content,a.keyword");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 1) as readAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 2) as collectionAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 3) as repeatAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_doctor c where c.article = a.code and c.doctor =?) as collection");
		params.add(doctor);
		if(StringUtils.isNotBlank(patient)) {
			sql.append(",(select count(1) from wlyy_health_edu_article_patient c where c.article = a.code and c.doctor = ?) as send");
			params.add(doctor);
		}
		sql.append(" from wlyy_health_edu_article a ");//内联取文章内容
		String where = " ";
		if(StringUtils.isNotBlank(filter)){
			//记录搜索记录
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter="%"+filter+"%";
			return healthEduArticleDao.list(filter,filter, pageRequest);
			where+=" where ( a.title like ? or a.keyword like ? )";
			params.add(filter);
			params.add(filter);
		}
		Specification<HealthEduArticle> spec = DynamicSpecifications.bySearchFilter(filters.values(),HealthEduArticle.class);
		return healthEduArticleDao.findAll(spec, pageRequest);
	}
		int start = page * pagesize;
	/**
	 * 查询患者文章
	 * @param patient 患者标识
	 * @param pagesize 分页大小
	 * @return
	 */
	public Page<HealthEduArticlePatient> findByPatient(String patient, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		// 患者过滤
		filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<HealthEduArticlePatient> spec = DynamicSpecifications.bySearchFilter(filters.values(), HealthEduArticlePatient.class);
		return healthEduArticlePatientDao.findAll(spec, pageRequest);
		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;
	}
	/**

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

@ -66,51 +66,35 @@ 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,@RequestParam(value = "patient",required = false)String patient) {
		try {
			Page<HealthEduArticle> list = healthEduArticleService.findAll(page, pagesize,filter,getUID());
			List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize,filter,getUID(),patient);
			JSONArray jsonArray = new JSONArray();
			if (list != null) {
				for (HealthEduArticle article : list) {
				for (Map<String, Object> map : list) {
					JSONObject json = new JSONObject();
					json.put("id", article.getId());
					json.put("id", map.get("id"));
					// 文章标识
					json.put("code", article.getCode());
					json.put("code", map.get("code"));
					// 文章标题
					json.put("title", article.getTitle());
					json.put("title", map.get("title"));
					// 文章查看URL
					json.put("url", article.getUrl());
					json.put("url", map.get("url"));
					// 文章简介
					json.put("content", parsrHtml(article.getContent()));
					json.put("content", parsrHtml(map.get("content").toString()));
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
					json.put("czrq", DateUtil.dateToStrLong((Date)map.get("czrq")));
					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());
					if(StringUtils.isNotBlank(patient)){
						List<HealthEduArticlePatient> healthEduArticlePatients = healthEduArticlePatientService.findByArticleAndPatient(article.getCode(),patient);
						if(healthEduArticlePatients!=null&&healthEduArticlePatients.size()>0){
							json.put("send", 1);
						}else{
							json.put("send", 0);
						}
					}else{
						json.put("send", 0);
					}
					json.put("keyword", map.get("keyword")==null?"":map.get("keyword"));
					json.put("send", map.get("send"));
					//阅读量
					json.put("readAmount", readAmount);
					json.put("readAmount", map.get("readAmount"));
					//收藏量
					json.put("collectionAmount", collectionAmount);
					json.put("collectionAmount", map.get("collectionAmount"));
					//转发量
					json.put("repeatAmount", repeatAmount);
					//是否收藏
					if(healthEduArticleDoctor!=null){
						json.put("collection",1);
					}else{
						json.put("collection",0);
					}
					json.put("repeatAmount", map.get("repeatAmount"));
					json.put("collection",map.get("collection"));
					jsonArray.put(json);
				}
			}
@ -130,51 +114,34 @@ public class DoctorHealthEduArticleController extends BaseController {
	@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,@RequestParam(value = "patient",required = false)String patient) {
		try {
			List<Object> list = healthEduArticleDoctorService.list(page, pagesize,filter,getUID());
			List<Map<String, Object>> list = healthEduArticleDoctorService.list(page, pagesize,filter,getUID(),patient);
			JSONArray jsonArray = new JSONArray();
			for(Object obj:list){
				HealthEduArticle healthEduArticle= (HealthEduArticle)obj;
			for(Map<String, Object> map:list){
				JSONObject json = new JSONObject();
				json.put("id", healthEduArticle.getId());
				json.put("id", map.get("id"));
				// 文章标识
				json.put("code", healthEduArticle.getCode());
				json.put("code", map.get("article"));
				// 文章标题
				json.put("title", healthEduArticle.getTitle());
				json.put("title", map.get("title"));
				// 文章查看URL
				json.put("url", healthEduArticle.getUrl());
				json.put("url", map.get("url"));
				// 文章简介
				json.put("content", parsrHtml(healthEduArticle.getContent()));
				json.put("content", parsrHtml(map.get("content").toString()));
				// 添加日期
				json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
				json.put("czrq", DateUtil.dateToStrLong((Date)map.get("czrq")));
				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());
				if(StringUtils.isNotBlank(patient)){
					List<HealthEduArticlePatient> healthEduArticlePatients = healthEduArticlePatientService.findByArticleAndPatient(healthEduArticle.getCode(),patient);
					if(healthEduArticlePatients!=null&&healthEduArticlePatients.size()>0){
						json.put("send", 1);
					}else{
						json.put("send", 0);
					}
				}else{
					json.put("send", 0);
				}
				json.put("keyword", map.get("keyword"));
				json.put("send", map.get("send"));
				//阅读量
				json.put("readAmount", readAmount);
				json.put("readAmount", map.get("readAmount"));
				//收藏量
				json.put("collectionAmount", collectionAmount);
				json.put("collectionAmount", map.get("collectionAmount"));
				//转发量
				json.put("repeatAmount", repeatAmount);
				//是否收藏
				if(healthEduArticleDoctor!=null){
					json.put("collection",1);
				}else{
					json.put("collection",0);
				}
				json.put("repeatAmount", map.get("repeatAmount"));
				//是否收藏(医生收藏的列表肯定是收藏的无需额外校验)
				json.put("collection",1);
				jsonArray.put(json);
			}
			return write(200, "查询成功", "list", jsonArray);