Commit d20bf0ef4b6fe1d2c382be5206063d9563ad8baf
1 parent
75e5726a41
Exists in
dev
开发消息通知模块小程序获取数据等接口
Showing 14 changed files with 157 additions and 12 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ICourseDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ICourseEvalDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/MsgDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/CourseDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/CourseEvalDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/MygDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseEvalService.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseService.java
- platform-dal/src/main/java/com/lyms/platform/pojo/MsgModel.java
- platform-dal/src/main/java/com/lyms/platform/query/MsgQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CourseController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ICourseDao.java
View file @
d20bf0e
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/ICourseEvalDao.java
View file @
d20bf0e
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/MsgDao.java
View file @
d20bf0e
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/CourseDaoImpl.java
View file @
d20bf0e
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import com.lyms.platform.common.dao.operator.MongoQuery; |
7 | 7 | import com.lyms.platform.pojo.CourseModel; |
8 | 8 | import com.lyms.platform.pojo.CourseTypeModel; |
9 | +import com.lyms.platform.pojo.MsgModel; | |
9 | 10 | import org.springframework.stereotype.Repository; |
10 | 11 | |
11 | 12 | import java.util.List; |
... | ... | @@ -34,5 +35,7 @@ |
34 | 35 | public void updateCourse(MongoQuery mongoQuery,CourseModel model) { |
35 | 36 | update(mongoQuery.convertToMongoQuery(),model); |
36 | 37 | } |
38 | + | |
39 | + | |
37 | 40 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/CourseEvalDaoImpl.java
View file @
d20bf0e
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/MygDaoImpl.java
View file @
d20bf0e
... | ... | @@ -33,5 +33,11 @@ |
33 | 33 | public void updateMsg(MongoQuery mongoQuery, MsgModel model) { |
34 | 34 | update(mongoQuery.convertToMongoQuery(),model); |
35 | 35 | } |
36 | + | |
37 | + @Override | |
38 | + public void updateReadCount(MongoQuery id, MsgModel model) { | |
39 | + update(id.convertToMongoQuery(),model); | |
40 | + } | |
41 | + | |
36 | 42 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseEvalService.java
View file @
d20bf0e
... | ... | @@ -80,5 +80,11 @@ |
80 | 80 | public void updateMsg(MsgModel model) { |
81 | 81 | msgDao.updateMsg(new MongoQuery(new MongoCondition("id", model.getId(), MongoOper.IS)), model); |
82 | 82 | } |
83 | + | |
84 | + | |
85 | + public void updateMsgReadCount(MsgModel model) { | |
86 | + msgDao.updateReadCount(new MongoQuery(new MongoCondition("id", model.getId(), MongoOper.IS)), model); | |
87 | + } | |
88 | + | |
83 | 89 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseService.java
View file @
d20bf0e
... | ... | @@ -10,9 +10,11 @@ |
10 | 10 | import com.lyms.platform.common.enums.YnEnums; |
11 | 11 | import com.lyms.platform.pojo.CourseModel; |
12 | 12 | import com.lyms.platform.pojo.MeasureInfoModel; |
13 | +import com.lyms.platform.pojo.MsgModel; | |
13 | 14 | import com.lyms.platform.pojo.PersonModel; |
14 | 15 | import com.lyms.platform.query.CourseQuery; |
15 | 16 | import com.lyms.platform.query.MeasureInfoQuery; |
17 | +import com.lyms.platform.query.MsgQuery; | |
16 | 18 | import com.lyms.platform.query.PersonModelQuery; |
17 | 19 | import org.apache.commons.collections.CollectionUtils; |
18 | 20 | import org.apache.commons.lang.StringUtils; |
... | ... | @@ -77,5 +79,6 @@ |
77 | 79 | } |
78 | 80 | return null; |
79 | 81 | } |
82 | + | |
80 | 83 | } |
platform-dal/src/main/java/com/lyms/platform/pojo/MsgModel.java
View file @
d20bf0e
... | ... | @@ -39,10 +39,20 @@ |
39 | 39 | |
40 | 40 | private String hospitalId; |
41 | 41 | |
42 | - private String readIds; | |
43 | - | |
44 | 42 | private String readCount; |
45 | 43 | |
44 | + | |
45 | + //阅读量 | |
46 | + private Integer readNum; | |
47 | + | |
48 | + public Integer getReadNum() { | |
49 | + return readNum; | |
50 | + } | |
51 | + | |
52 | + public void setReadNum(Integer readNum) { | |
53 | + this.readNum = readNum; | |
54 | + } | |
55 | + | |
46 | 56 | public String getReadCount() { |
47 | 57 | return readCount; |
48 | 58 | } |
... | ... | @@ -51,13 +61,6 @@ |
51 | 61 | this.readCount = readCount; |
52 | 62 | } |
53 | 63 | |
54 | - public String getReadIds() { | |
55 | - return readIds; | |
56 | - } | |
57 | - | |
58 | - public void setReadIds(String readIds) { | |
59 | - this.readIds = readIds; | |
60 | - } | |
61 | 64 | |
62 | 65 | public String getHospitalId() { |
63 | 66 | return hospitalId; |
platform-dal/src/main/java/com/lyms/platform/query/MsgQuery.java
View file @
d20bf0e
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | public class MsgQuery extends BaseQuery implements IConvertToNativeQuery { |
12 | 12 | |
13 | 13 | //消息id |
14 | - private Integer id; | |
14 | + private String id; | |
15 | 15 | //1.用户端APP 2. 医生端APP |
16 | 16 | private Integer type; |
17 | 17 | //消息内容 |
... | ... | @@ -39,6 +39,16 @@ |
39 | 39 | |
40 | 40 | private String readCount; |
41 | 41 | |
42 | + private Integer readNum; | |
43 | + | |
44 | + public Integer getReadNum() { | |
45 | + return readNum; | |
46 | + } | |
47 | + | |
48 | + public void setReadNum(Integer readNum) { | |
49 | + this.readNum = readNum; | |
50 | + } | |
51 | + | |
42 | 52 | public String getReadCount() { |
43 | 53 | return readCount; |
44 | 54 | } |
45 | 55 | |
... | ... | @@ -63,11 +73,11 @@ |
63 | 73 | this.hospitalId = hospitalId; |
64 | 74 | } |
65 | 75 | |
66 | - public Integer getId() { | |
76 | + public String getId() { | |
67 | 77 | return id; |
68 | 78 | } |
69 | 79 | |
70 | - public void setId(Integer id) { | |
80 | + public void setId(String id) { | |
71 | 81 | this.id = id; |
72 | 82 | } |
73 | 83 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CourseController.java
View file @
d20bf0e
... | ... | @@ -367,5 +367,35 @@ |
367 | 367 | HttpServletRequest request) { |
368 | 368 | return courseFacade.getMsgList(); |
369 | 369 | } |
370 | + | |
371 | + | |
372 | + /** | |
373 | + * 消息详情 | |
374 | + * @param msgId | |
375 | + * @param parentId | |
376 | + * @param request | |
377 | + * @return | |
378 | + */ | |
379 | + @RequestMapping(method = RequestMethod.GET, value = "/getMsgById") | |
380 | + @ResponseBody | |
381 | + public BaseResponse getMsgById(@RequestParam(required = false) String msgId, | |
382 | + @RequestParam(required = false) String parentId, | |
383 | + HttpServletRequest request) { | |
384 | + return courseFacade.getMsgById(msgId,parentId); | |
385 | + } | |
386 | + | |
387 | + | |
388 | + /** | |
389 | + * 未读数量 | |
390 | + * @param parentId | |
391 | + * @param request | |
392 | + * @return | |
393 | + */ | |
394 | + @RequestMapping(method = RequestMethod.GET, value = "/getMsgCountById") | |
395 | + @ResponseBody | |
396 | + public String getMsgCountById(@RequestParam(required = false) String parentId, | |
397 | + HttpServletRequest request) { | |
398 | + return courseFacade.getMsgCountById(parentId); | |
399 | + } | |
370 | 400 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java
View file @
d20bf0e
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
View file @
d20bf0e
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | import com.lyms.platform.common.utils.PropertiesUtils; |
16 | 16 | import com.lyms.platform.operate.web.request.CourseRequest; |
17 | 17 | import com.lyms.platform.operate.web.result.CourseResult; |
18 | +import com.lyms.platform.operate.web.result.MsgMessageResult; | |
18 | 19 | import com.lyms.platform.operate.web.worker.CourseCountWorker; |
19 | 20 | import com.lyms.platform.permission.model.*; |
20 | 21 | import com.lyms.platform.permission.service.OrganizationService; |
... | ... | @@ -1224,6 +1225,79 @@ |
1224 | 1225 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
1225 | 1226 | objectResponse.setErrormsg("成功"); |
1226 | 1227 | return objectResponse; |
1228 | + } | |
1229 | + | |
1230 | + public BaseResponse getMsgById(String msgId, String parentId) { | |
1231 | + MsgQuery msgQuery = new MsgQuery(); | |
1232 | + msgQuery.setYn(YnEnums.YES.getId()); | |
1233 | + msgQuery.setNeed("true"); | |
1234 | + msgQuery.setId(msgId); | |
1235 | + BaseListResponse objectResponse = new BaseListResponse(); | |
1236 | + List<MsgModel> models = courseEvalService.queryMsgList(msgQuery); | |
1237 | + for (MsgModel model : models) { | |
1238 | + if (parentId!=null){ | |
1239 | + String readCount = model.getReadCount(); | |
1240 | + //判断此条信息有没有值 | |
1241 | + if (readCount.isEmpty()){ | |
1242 | + //如果没有值,直接添加数据 | |
1243 | + model.setReadCount(parentId); | |
1244 | + courseEvalService.updateMsgReadCount(model); | |
1245 | + }else{ | |
1246 | + // 判断 parentId 是否存在于 readCount 中 | |
1247 | + if (!readCount.contains(parentId)) { | |
1248 | + // 如果不存在,执行下面的逻辑 | |
1249 | + // 继续添加 parentId,并设置到 model 中 | |
1250 | + readCount += "," + parentId; | |
1251 | + model.setReadCount(readCount); | |
1252 | + | |
1253 | + // 统计逗号数量,用于计算字段数量 | |
1254 | + int commaCount = 0; | |
1255 | + for (int i = 0; i < readCount.length(); i++) { | |
1256 | + if (readCount.charAt(i) == ',') { | |
1257 | + commaCount++; | |
1258 | + } | |
1259 | + } | |
1260 | + | |
1261 | + // 计算字段数量 | |
1262 | + int fieldCount = commaCount + 1; | |
1263 | + model.setReadNum(fieldCount); | |
1264 | + | |
1265 | + // 更新消息阅读量 | |
1266 | + courseEvalService.updateMsgReadCount(model); | |
1267 | + } | |
1268 | + } | |
1269 | + } | |
1270 | + } | |
1271 | + objectResponse.setData(models); | |
1272 | + objectResponse.setPageInfo(msgQuery.getPageInfo()); | |
1273 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
1274 | + objectResponse.setErrormsg("成功"); | |
1275 | + return objectResponse; | |
1276 | + } | |
1277 | + | |
1278 | + public String getMsgCountById(String parentId) { | |
1279 | + MsgQuery msgQuery = new MsgQuery(); | |
1280 | + msgQuery.setYn(YnEnums.YES.getId()); | |
1281 | + msgQuery.setNeed("true"); | |
1282 | + List<MsgModel> models = courseEvalService.queryMsgList(msgQuery); | |
1283 | + // 初始化计数器 | |
1284 | + int userIdCount = 0; | |
1285 | + // 遍历 models 列表 | |
1286 | + for (MsgModel model : models) { | |
1287 | + // 获取当前消息的 readCount | |
1288 | + String readCount = model.getReadCount(); | |
1289 | + // 检查 readCount 是否包含当前登录人的 ID | |
1290 | + if (readCount != null && readCount.contains(parentId)) { | |
1291 | + // 使用正则表达式将 readCount 拆分为多个 ID,并计算包含当前登录人 ID 的数量 | |
1292 | + String[] ids = readCount.split(","); | |
1293 | + for (String id : ids) { | |
1294 | + if (id.equals(parentId)) { | |
1295 | + userIdCount++; | |
1296 | + } | |
1297 | + } | |
1298 | + } | |
1299 | + } | |
1300 | + return String.valueOf(userIdCount); | |
1227 | 1301 | } |
1228 | 1302 | } |