| 
					
				 | 
			
			
				@ -10,8 +10,11 @@ import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.survey.service.SurveyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientBusinessDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.hospital.survey.WlyySurveyLabelInfoVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.hibernate.HibenateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -44,6 +47,8 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private SurveyTemplateDao surveyTemplateDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private HibenateUtils hibenateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private SurveyService surveyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -205,47 +210,78 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						knowledgeArticleUserDao.save(knowledgeArticleUserDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						surveyTemplateDao.save(wlyySurveyTemplateDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public List<Map<String,Object>> getUsedList(String title,String doctor,Integer used,Integer page,Integer pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public MixEnvelop getUsedList(String title, String doctor, Integer used, Integer page, Integer pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						StringBuffer sql = new StringBuffer(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						sql.append("select a.id AS \"id\" ,a.title AS \"title\",a.template_comment AS \"template_comment\" ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" a.organization AS \"organization\",a.create_time AS \"create_time\" ," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"a.creater AS \"creater\"FROM wlyy_survey_template a "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						MixEnvelop mixEnvelop = new MixEnvelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						sql.append("SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.id, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" b.used as \"used\","+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.title, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.template_comment AS templateComment, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.organization, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.creater, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.create_time AS createTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.del, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" t.update_time AS updateTime" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" wlyy_survey_template t "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						//1为查询常用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (null != used) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (1 == used) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append("JOIN wlyy_knowledge_article_user b on a.id = b.relation_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										"where 1=1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append("JOIN wlyy_knowledge_article_user b on t.id = b.relation_code "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append("JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code where 1=1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append(" and b.used = 1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (StringUtils.isNotEmpty(doctor)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									sql.append(" and a.title like '%" + title + "%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									sql.append(" and t.title like '%" + title + "%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (StringUtils.isNotEmpty(doctor)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									sql.append(" and a.creater = '" + doctor + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									sql.append(" and t.creater = '" + doctor + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								String sqlCount = "select Count(1) as \"total\" from ("+sql+") l"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql.toString(), page, pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (listCount.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									count = hibenateUtils.objTransformLong(listCount.get(0).get("total")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									for (Map<String, Object> map : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										List<WlyySurveyLabelInfoVO>  wlyySurveyLabelInfoVOS= surveyService.findSurveyTemplateLabel(null==map.get("id")?"":map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										String createTime = null == map.get("create_time") ? "" : map.get("create_time").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										String creater = null == map.get("creater") ? "" : map.get("creater").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										map.put("create_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										map.put("labels",wlyySurveyLabelInfoVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										BaseDoctorDO doctorDO = doctorDao.findById(creater); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										if (null!=doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
											map.put("doctrName", doctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setPageSize(pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setCurrPage(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setTotalCount(count.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setDetailModelList(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								//0为查询模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append("where a.del = 1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append("JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code where 1=1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append(" and t.del = 1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (StringUtils.isNotEmpty(doctor)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									sql.append(" and a.title like '%" + title + "%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									sql.append(" and t.title like '%" + title + "%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								String sqlCount = "select Count(1) as \"total\" from ("+sql+") l"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql.toString(), page, pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (listCount.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									count = hibenateUtils.objTransformLong(listCount.get(0).get("total")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									for (Map<String, Object> map : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										List<WlyySurveyLabelInfoVO>  wlyySurveyLabelInfoVOS= surveyService.findSurveyTemplateLabel(null==map.get("id")?"":map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										map.put("labels",wlyySurveyLabelInfoVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										String createTime = null == map.get("create_time") ? "" : map.get("create_time").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										String creater = null == map.get("creater") ? "" : map.get("creater").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										map.put("create_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime))); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -255,20 +291,33 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setPageSize(pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setCurrPage(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setTotalCount(count.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								mixEnvelop.setDetailModelList(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//空位查我的问卷 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql.append("where a.del = 1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql.append("JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code where 1=1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql.append(" and t.del = 1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isNotEmpty(doctor)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append(" and a.creater = '" + doctor + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append(" and t.creater = '" + doctor + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isNotEmpty(doctor)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append(" and a.title like '%" + title + "%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql.append(" and t.title like '%" + title + "%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							String sqlCount = "select Count(1) as \"total\" from ("+sql+") l"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql.toString(), page, pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (listCount.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								count = hibenateUtils.objTransformLong(listCount.get(0).get("total")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (Map<String, Object> map : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									List<WlyySurveyLabelInfoVO>  wlyySurveyLabelInfoVOS= surveyService.findSurveyTemplateLabel(null==map.get("id")?"":map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									map.put("labels",wlyySurveyLabelInfoVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									String createTime = null == map.get("create_time") ? "" : map.get("create_time").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									String creater = null == map.get("creater") ? "" : map.get("creater").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									map.put("create_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime))); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -279,7 +328,11 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							mixEnvelop.setPageSize(pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							mixEnvelop.setCurrPage(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							mixEnvelop.setTotalCount(count.intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							mixEnvelop.setDetailModelList(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return mixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |