Pārlūkot izejas kodu

居民咨询列表增加分页和总数

huangwenjie 5 gadi atpakaļ
vecāks
revīzija
c342ee75f5

+ 43 - 2
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -134,8 +134,12 @@ public class ImService {
	 * @param title 标题关键字
	 * @return
	 */
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,Integer type, int pagesize, String title) {
	public List<ConsultVO>  findConsultRecordByPatient(String patient, String id,Integer type, int page,int pagesize, String title) {
		if(page <= 0){
			pagesize = 1;
		}
		
		if (pagesize <= 0) {
			pagesize = 10;
		}
@ -167,13 +171,50 @@ public class ImService {
		if (!StringUtils.isEmpty(id)) {
			sql += " and a.id = '" + id + "'";
		}
		sql += " ORDER BY a.id desc limit 0,"+pagesize+"";
		sql += " ORDER BY a.czrq desc limit "+pagesize+","+pagesize+"";
		
		result = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ConsultVO.class));
		
		return result;
	}
	
	/**
	 * 查询患者所有的咨询记录总数
	 * @param patient 患者标识
	 * @param id 会话ID(等同IM表topicId)
	 * @param type 咨询会话类型
	 * @param pagesize 分页大小
	 * @param title 标题关键字
	 * @return
	 */
	public Long countConsultRecordByPatient(String patient, String id,Integer type, String title) {
		
		String  sql = "SELECT " +
				" COUNT(1) AS total " +
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_doctor d " +
				"WHERE a.id=b.consult " +
				"AND b.doctor=d.id AND a.patient='"+patient+"' AND a.type="+type;
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){
			title="%"+title+"%";
			sql +=" and a.title like '"+title+"'";
		}
		if (!StringUtils.isEmpty(id)) {
			sql += " and a.id = '" + id + "'";
		}
		
		List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
		Long count = 0L;
		if (rstotal != null && rstotal.size() > 0) {
			count = (Long) rstotal.get(0).get("total");
		}
		
		return count;
	}
	
	/**
	 * 查询居民与某个医生未结束的咨询
	 *

+ 12 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -53,7 +53,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	public ListEnvelop records(
	public Envelop records(
								@ApiParam(name = "patient", value = "居民id")
								@RequestParam(value = "patient",required = true) String patient,
								@ApiParam(name = "title", value = "咨询标题关键字")
@ -62,11 +62,14 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
								@RequestParam(value = "id",required = false) String id,
								@ApiParam(name = "type", value = "咨询类型")
								@RequestParam(value = "type",required = true) Integer type,
								@ApiParam(name = "page", value = "第几页")
								@RequestParam(value = "page",required = false) int page,
								@ApiParam(name = "pagesize", value = "分页大小")
								@RequestParam(value = "pagesize",required = false) int pagesize
								)throws Exception{
		JSONArray array = new JSONArray();
		List<ConsultVO>  data = imService.findConsultRecordByPatient(patient, id,type, pagesize, title);
		List<ConsultVO>  data = imService.findConsultRecordByPatient(patient, id,type, page,pagesize, title);
		
		if (data != null) {
			for (ConsultVO consult : data) {
				if (consult == null) {
@ -96,7 +99,13 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
				array.add(json);
			}
		}
		return success(array);
		
		Long total = imService.countConsultRecordByPatient(patient, id,type,title);
		
		JSONObject result = new JSONObject();
		result.put("total",total);
		result.put("list",data);
		return success(result);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedConsult)