Commit d616422b7df225b93c543ad65691df091961dffe
1 parent
c1dbc04d8a
Exists in
master
and in
6 other branches
问卷调查
Showing 4 changed files with 145 additions and 4 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/QuestionEnums.java
- platform-dal/src/main/java/com/lyms/platform/query/QuestionQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/QuestionController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/QuestionFacade.java
platform-common/src/main/java/com/lyms/platform/common/enums/QuestionEnums.java
View file @
d616422
| 1 | 1 | package com.lyms.platform.common.enums; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import com.lyms.platform.common.utils.StringUtils; | |
| 5 | + | |
| 4 | 6 | import java.util.ArrayList; |
| 5 | 7 | import java.util.HashMap; |
| 6 | 8 | import java.util.List; |
| ... | ... | @@ -50,6 +52,19 @@ |
| 50 | 52 | if (score >= e.getStart() && score <= e.getEnd()) |
| 51 | 53 | { |
| 52 | 54 | return e.getId()+""; |
| 55 | + } | |
| 56 | + } | |
| 57 | + } | |
| 58 | + return ""; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public static String getTitleById(String id) { | |
| 62 | + if (StringUtils.isNotEmpty(id)) | |
| 63 | + { | |
| 64 | + for (QuestionEnums e : QuestionEnums.values()) { | |
| 65 | + if (e.getId() == Integer.parseInt(id)) | |
| 66 | + { | |
| 67 | + return e.getTitle(); | |
| 53 | 68 | } |
| 54 | 69 | } |
| 55 | 70 | } |
platform-dal/src/main/java/com/lyms/platform/query/QuestionQuery.java
View file @
d616422
| ... | ... | @@ -36,14 +36,22 @@ |
| 36 | 36 | private Date investDateEnd; |
| 37 | 37 | |
| 38 | 38 | private String patientId; |
| 39 | + private List<String> patientIds; | |
| 39 | 40 | private String resultId; |
| 40 | 41 | |
| 42 | + private String queryNo; | |
| 43 | + | |
| 41 | 44 | @Override |
| 42 | 45 | public MongoQuery convertToQuery() { |
| 43 | 46 | MongoCondition condition=MongoCondition.newInstance(); |
| 44 | 47 | if(null != patientId){ |
| 45 | 48 | condition= condition.and("patientId",patientId, MongoOper.IS); |
| 46 | 49 | } |
| 50 | + | |
| 51 | + if(null != patientIds && patientId.length() > 0){ | |
| 52 | + condition= condition.and("patientId",patientIds, MongoOper.IN); | |
| 53 | + } | |
| 54 | + | |
| 47 | 55 | if(null != resultId){ |
| 48 | 56 | condition= condition.and("resultId",resultId, MongoOper.IS); |
| 49 | 57 | } |
| ... | ... | @@ -74,6 +82,31 @@ |
| 74 | 82 | condition = condition.andCondition(new MongoCondition(c1)); |
| 75 | 83 | } |
| 76 | 84 | return condition.toMongoQuery(); |
| 85 | + } | |
| 86 | + | |
| 87 | + | |
| 88 | + public List<String> getPatientIds() { | |
| 89 | + return patientIds; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setPatientIds(List<String> patientIds) { | |
| 93 | + this.patientIds = patientIds; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public String getQueryNo() { | |
| 97 | + return queryNo; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setQueryNo(String queryNo) { | |
| 101 | + this.queryNo = queryNo; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public String getResultId() { | |
| 105 | + return resultId; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public void setResultId(String resultId) { | |
| 109 | + this.resultId = resultId; | |
| 77 | 110 | } |
| 78 | 111 | |
| 79 | 112 | public String getId() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/QuestionController.java
View file @
d616422
| 1 | 1 | package com.lyms.platform.operate.web.controller; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.common.annotation.TokenRequired; | |
| 3 | 4 | import com.lyms.platform.common.base.BaseController; |
| 5 | +import com.lyms.platform.common.base.LoginContext; | |
| 4 | 6 | import com.lyms.platform.common.result.BaseResponse; |
| 5 | 7 | import com.lyms.platform.operate.web.facade.AssistBuildFacade; |
| 6 | 8 | import com.lyms.platform.operate.web.facade.QuestionFacade; |
| ... | ... | @@ -43,6 +45,28 @@ |
| 43 | 45 | public BaseResponse getQuertionByPatientId(@PathVariable String patientId, |
| 44 | 46 | HttpServletRequest httpServletRequest) { |
| 45 | 47 | return questionFacade.getQuestionByPatientId(patientId); |
| 48 | + } | |
| 49 | + | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 列表 | |
| 53 | + * @param investDate | |
| 54 | + * @param queryNo | |
| 55 | + * @param resultId | |
| 56 | + * @param httpServletRequest | |
| 57 | + * @return | |
| 58 | + */ | |
| 59 | + @RequestMapping(method = RequestMethod.GET, value = "/queryQestions") | |
| 60 | + @ResponseBody | |
| 61 | + @TokenRequired | |
| 62 | + public BaseResponse queryQestions(@RequestParam(required = false) String investDate, | |
| 63 | + @RequestParam(required = false) String queryNo, | |
| 64 | + @RequestParam(required = false) String resultId, | |
| 65 | + @RequestParam(required = false) Integer page, | |
| 66 | + @RequestParam(required = false) Integer limit, | |
| 67 | + HttpServletRequest httpServletRequest) { | |
| 68 | + LoginContext loginState = (LoginContext) httpServletRequest.getAttribute("loginContext"); | |
| 69 | + return questionFacade.queryQestions(investDate,queryNo,resultId,page,limit,loginState.getId()); | |
| 46 | 70 | } |
| 47 | 71 | |
| 48 | 72 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/QuestionFacade.java
View file @
d616422
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 9 | 9 | import com.lyms.platform.common.enums.QuestionEnums; |
| 10 | 10 | import com.lyms.platform.common.enums.YnEnums; |
| 11 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 11 | 12 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 12 | 13 | import com.lyms.platform.common.result.BaseResponse; |
| 13 | 14 | |
| 14 | 15 | |
| 15 | 16 | |
| ... | ... | @@ -21,14 +22,13 @@ |
| 21 | 22 | import com.lyms.platform.pojo.QuestionModel; |
| 22 | 23 | |
| 23 | 24 | import com.lyms.platform.query.AntExChuQuery; |
| 25 | +import com.lyms.platform.query.PatientsQuery; | |
| 24 | 26 | import com.lyms.platform.query.QuestionQuery; |
| 27 | +import org.apache.commons.lang.StringUtils; | |
| 25 | 28 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | 29 | import org.springframework.stereotype.Component; |
| 27 | 30 | |
| 28 | -import java.util.Date; | |
| 29 | -import java.util.HashMap; | |
| 30 | -import java.util.List; | |
| 31 | -import java.util.Map; | |
| 31 | +import java.util.*; | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | |
| ... | ... | @@ -48,7 +48,11 @@ |
| 48 | 48 | @Autowired |
| 49 | 49 | private AntenatalExaminationService antenatalExaminationService; |
| 50 | 50 | |
| 51 | + | |
| 51 | 52 | @Autowired |
| 53 | + private AutoMatchFacade autoMatchFacade; | |
| 54 | + | |
| 55 | + @Autowired | |
| 52 | 56 | private UsersService usersService; |
| 53 | 57 | |
| 54 | 58 | @Autowired |
| ... | ... | @@ -146,6 +150,71 @@ |
| 146 | 150 | |
| 147 | 151 | response.setErrormsg("无调查"); |
| 148 | 152 | response.setErrorcode(ErrorCodeConstants.NO_DATA); |
| 153 | + return response; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public BaseResponse queryQestions(String investDate, String queryNo, String resultId,Integer page,Integer limit, Integer userId) { | |
| 157 | + | |
| 158 | + BaseListResponse response = new BaseListResponse(); | |
| 159 | + | |
| 160 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 161 | + | |
| 162 | + QuestionQuery questionQuery = new QuestionQuery(); | |
| 163 | + questionQuery.setLimit(limit); | |
| 164 | + questionQuery.setPage(page); | |
| 165 | + questionQuery.setNeed("need"); | |
| 166 | + questionQuery.setResultId(resultId); | |
| 167 | + if (hospitalId != null) { | |
| 168 | + questionQuery.setInvestHospitalId(hospitalId); | |
| 169 | + } | |
| 170 | + if (StringUtils.isNotEmpty(investDate)) | |
| 171 | + { | |
| 172 | + String[] arrs = investDate.split(" - "); | |
| 173 | + questionQuery.setInvestDateStart(DateUtil.parseYMD(arrs[0])); | |
| 174 | + questionQuery.setInvestDateEnd(new Date(DateUtil.parseYMD(arrs[1]).getTime() + 24 * 60 * 60 * 1000 - 1)); | |
| 175 | + } | |
| 176 | + | |
| 177 | + if (StringUtils.isNotEmpty(queryNo)) | |
| 178 | + { | |
| 179 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 180 | + patientsQuery.setQueryNo(queryNo); | |
| 181 | + List<Patients> list = patientsService.queryPatient(patientsQuery); | |
| 182 | + if (CollectionUtils.isNotEmpty(list)) | |
| 183 | + { | |
| 184 | + List<String> patientIds = new ArrayList<>(); | |
| 185 | + for (Patients p : list) | |
| 186 | + { | |
| 187 | + patientIds.add(p.getId()); | |
| 188 | + } | |
| 189 | + questionQuery.setPatientIds(patientIds); | |
| 190 | + } | |
| 191 | + } | |
| 192 | + | |
| 193 | + List<Map> datas = new ArrayList<>(); | |
| 194 | + List<QuestionModel> questions = questionService.queryQuestions(questionQuery); | |
| 195 | + if (CollectionUtils.isNotEmpty(questions)) | |
| 196 | + { | |
| 197 | + | |
| 198 | + for (QuestionModel model : questions) | |
| 199 | + { | |
| 200 | + Map map = new HashMap(); | |
| 201 | + Patients patients = patientsService.findOnePatientById(model.getPatientId()); | |
| 202 | + map.put("id",model.getId()); | |
| 203 | + map.put("patientId",model.getPatientId()); | |
| 204 | + map.put("userName",patients.getUsername()); | |
| 205 | + map.put("investDate",DateUtil.getyyyy_MM_dd(model.getInvestDate())); | |
| 206 | + map.put("week",DateUtil.getWeekDesc(patients.getLastMenses(), model.getInvestDate())); | |
| 207 | + map.put("dueDate",DateUtil.getyyyy_MM_dd(patients.getDueDate())); | |
| 208 | + map.put("phone",patients.getPhone()); | |
| 209 | + map.put("scoreAndResult", model.getScore()+" "+QuestionEnums.getTitleById(model.getResultId())); | |
| 210 | + datas.add(map); | |
| 211 | + } | |
| 212 | + } | |
| 213 | + | |
| 214 | + response.setErrormsg("成功"); | |
| 215 | + response.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 216 | + response.setData(datas); | |
| 217 | + response.setPageInfo(questionQuery.getPageInfo()); | |
| 149 | 218 | return response; |
| 150 | 219 | } |
| 151 | 220 | } |