Browse Source

问卷查询修改

wangjun 4 years ago
parent
commit
19745022da

+ 2 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/survey/SurveyEndpoint.java

@ -231,7 +231,7 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.WlyySurvey.getSurveyList)
    @ApiOperation(value = "查询问卷模板")
    public Envelop getUsedList(@ApiParam(name = "title", value = "模板名称")
    public MixEnvelop getUsedList(@ApiParam(name = "title", value = "模板名称")
                                     @RequestParam(value = "title",required = false) String title,
                               @ApiParam(name = "doctor", value = "医生id")
                                     @RequestParam(value = "doctor",required = false) String doctor,
@ -241,7 +241,7 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
                                     @RequestParam(value = "page",required = true,defaultValue = "1")Integer page,
                               @ApiParam(name = "pageSize", value = "每页大小",defaultValue = "10")
                                     @RequestParam(value = "pageSize",required = true,defaultValue = "10")Integer pageSize)throws Exception {
        return success(businessService.getUsedList(title,doctor,used,page,pageSize));
        return businessService.getUsedList(title,doctor,used,page,pageSize);
    }
    @GetMapping(value = BaseHospitalRequestMapping.WlyySurvey.setUsed)

+ 44 - 16
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java

@ -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,43 +210,64 @@ 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, " +
				" 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("where t.del = 1");
				if (StringUtils.isNotEmpty(doctor)) {
					sql.append(" and a.title like '%" + title + "%'");
					sql.append(" and t.title like '%" + title + "%'");
				}
				List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql.toString(), page, pageSize);
				if (list.size() > 0) {
@ -255,16 +281,17 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
						}
					}
				}
				return list;
				mixEnvelop.setDetailModelList(list);
				return mixEnvelop;
			}
			//空位查我的问卷
		} else {
			sql.append("where a.del = 1");
			sql.append("where 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 + "%'");
			}
			List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql.toString(), page, pageSize);
			if (list.size() > 0) {
@ -279,7 +306,8 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
				}
			}
			return list;
			mixEnvelop.setDetailModelList(list);
			return mixEnvelop;
		}
	}
}

+ 13 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

@ -9,11 +9,13 @@ import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDeptDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.dao.SurveyUserDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
@ -53,6 +55,8 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
	private ImUtil imUtil;
	@Autowired
	private SurveyUserDao surveyUserDao;
	@Autowired
	private SurveyTemplateDao surveyTemplateDao;
	
	/**
	 * 删除,支持批量
@ -251,7 +255,15 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
					wlyySurveyUserDO.setSurveyTempCode(patientBusinessDO.getRelationCode());
					wlyySurveyUserDO.setSurveyTempTitle(patientBusinessDO.getRelationName());
					wlyySurveyUserDO.setCreateTime(new Date());
					surveyUserDao.save(wlyySurveyUserDO);
					wlyySurveyUserDO = surveyUserDao.save(wlyySurveyUserDO);
					JSONObject object = new JSONObject();
					WlyySurveyTemplateDO wlyySurveyTemplateDO = surveyTemplateDao.findOne(wlyySurveyUserDO.getSurveyTempCode());
					if (null!=wlyySurveyTemplateDO){
						object.put("title",wlyySurveyTemplateDO.getTitle());
						object.put("content",wlyySurveyTemplateDO.getTemplateComment());
						object.put("id",wlyySurveyTemplateDO.getId());
					}
					imUtil.sendImMsg(patientBusinessDO.getDoctor(), patientBusinessDO.getDoctorName(), patientBusinessDO.getSessionId(), "36", object.toJSONString(),"1");
				}
			}