Commit 467b803ffd866756c7eeb7e223ceb99323bbbde7
1 parent
18ca94d80a
Exists in
dev
#fix:新增血糖统计管理
Showing 7 changed files with 471 additions and 59 deletions
- platform-dal/src/main/java/com/lyms/platform/pojo/BloodSugarStatistics.java
- platform-dal/src/main/java/com/lyms/platform/query/BloodSugarStatisticsQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SmsConfigController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/StatisticsController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBloodSugarService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
platform-dal/src/main/java/com/lyms/platform/pojo/BloodSugarStatistics.java
View file @
467b803
| 1 | +package com.lyms.platform.pojo; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.result.BaseModel; | |
| 4 | +import org.springframework.data.mongodb.core.mapping.Document; | |
| 5 | + | |
| 6 | +import java.util.Date; | |
| 7 | + | |
| 8 | +@Document(collection="lyms_blood_sugar_statistics") | |
| 9 | +public class BloodSugarStatistics extends BaseModel { | |
| 10 | + private static final long serialVersionUID = -1; | |
| 11 | + private String id; | |
| 12 | + | |
| 13 | + private String parentId; | |
| 14 | + | |
| 15 | + private String pid; | |
| 16 | + | |
| 17 | + private Date created; | |
| 18 | + | |
| 19 | + private String ymdDate; | |
| 20 | + | |
| 21 | + private Integer yn; | |
| 22 | + private String hospitalId; | |
| 23 | + | |
| 24 | + private Date modified; | |
| 25 | + /** | |
| 26 | + * 1正常血糖管理、2低血糖管理、3高血糖管理 | |
| 27 | + */ | |
| 28 | + private Integer sugarType; | |
| 29 | + | |
| 30 | + public String getId() { | |
| 31 | + return id; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setId(String id) { | |
| 35 | + this.id = id; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getParentId() { | |
| 39 | + return parentId; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setParentId(String parentId) { | |
| 43 | + this.parentId = parentId; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public String getPid() { | |
| 47 | + return pid; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setPid(String pid) { | |
| 51 | + this.pid = pid; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public Date getCreated() { | |
| 55 | + return created; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void setCreated(Date created) { | |
| 59 | + this.created = created; | |
| 60 | + } | |
| 61 | + public String getYmdDate() { | |
| 62 | + return ymdDate; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setYmdDate(String ymdDate) { | |
| 66 | + this.ymdDate = ymdDate; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public Integer getYn() { | |
| 70 | + return yn; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setYn(Integer yn) { | |
| 74 | + this.yn = yn; | |
| 75 | + } | |
| 76 | + | |
| 77 | + | |
| 78 | + public String getHospitalId() { | |
| 79 | + return hospitalId; | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void setHospitalId(String hospitalId) { | |
| 83 | + this.hospitalId = hospitalId; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public Date getModified() { | |
| 87 | + return modified; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void setModified(Date modified) { | |
| 91 | + this.modified = modified; | |
| 92 | + } | |
| 93 | + public Integer getSugarType() { | |
| 94 | + return sugarType; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setSugarType(Integer sugarType) { | |
| 98 | + this.sugarType = sugarType; | |
| 99 | + } | |
| 100 | +} |
platform-dal/src/main/java/com/lyms/platform/query/BloodSugarStatisticsQuery.java
View file @
467b803
| 1 | +package com.lyms.platform.query; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.base.IConvertToNativeQuery; | |
| 4 | +import com.lyms.platform.common.dao.BaseQuery; | |
| 5 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
| 6 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
| 7 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 8 | +import com.lyms.platform.common.utils.StringUtils; | |
| 9 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 10 | + | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 13 | +public class BloodSugarStatisticsQuery extends BaseQuery implements IConvertToNativeQuery { | |
| 14 | + | |
| 15 | + private String pid; | |
| 16 | + | |
| 17 | + private Date created; | |
| 18 | + | |
| 19 | + private Date startTime; | |
| 20 | + private Date endTime; | |
| 21 | + | |
| 22 | + private String ymdDate; | |
| 23 | + | |
| 24 | + private Integer yn; | |
| 25 | + private String hospitalId; | |
| 26 | + /** | |
| 27 | + * 1正常血糖管理、2低血糖管理、3高血糖管理 | |
| 28 | + */ | |
| 29 | + private Integer sugarType; | |
| 30 | + | |
| 31 | + public String getPid() { | |
| 32 | + return pid; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setPid(String pid) { | |
| 36 | + this.pid = pid; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public Date getCreated() { | |
| 40 | + return created; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setCreated(Date created) { | |
| 44 | + this.created = created; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public String getYmdDate() { | |
| 48 | + return ymdDate; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void setYmdDate(String ymdDate) { | |
| 52 | + this.ymdDate = ymdDate; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public Integer getYn() { | |
| 56 | + return yn; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void setYn(Integer yn) { | |
| 60 | + this.yn = yn; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public String getHospitalId() { | |
| 64 | + return hospitalId; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setHospitalId(String hospitalId) { | |
| 68 | + this.hospitalId = hospitalId; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public Integer getSugarType() { | |
| 72 | + return sugarType; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setSugarType(Integer sugarType) { | |
| 76 | + this.sugarType = sugarType; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public Date getStartTime() { | |
| 80 | + return startTime; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void setStartTime(Date startTime) { | |
| 84 | + this.startTime = startTime; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public Date getEndTime() { | |
| 88 | + return endTime; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void setEndTime(Date endTime) { | |
| 92 | + this.endTime = endTime; | |
| 93 | + } | |
| 94 | + | |
| 95 | + @Override | |
| 96 | + public MongoQuery convertToQuery() { | |
| 97 | + MongoCondition condition = MongoCondition.newInstance(); | |
| 98 | + if (StringUtils.isNotEmpty(hospitalId)) { | |
| 99 | + condition = condition.and("hospitalId", hospitalId, MongoOper.IS); | |
| 100 | + } | |
| 101 | + if (null != yn) { | |
| 102 | + condition = condition.and("yn", yn, MongoOper.IS); | |
| 103 | + } | |
| 104 | + if (null !=sugarType) { | |
| 105 | + condition = condition.and("sugarType", sugarType, MongoOper.IS); | |
| 106 | + } | |
| 107 | + if (StringUtils.isNotEmpty(pid)) { | |
| 108 | + condition = condition.and("pid", pid, MongoOper.IS); | |
| 109 | + } | |
| 110 | + Criteria c = null; | |
| 111 | + if (startTime!=null && endTime!=null){ | |
| 112 | + if (null != c) { | |
| 113 | + c = c.where("created").gte(startTime).lte(endTime); | |
| 114 | + } else { | |
| 115 | + } | |
| 116 | + } | |
| 117 | + | |
| 118 | + if (null != c) { | |
| 119 | + condition = condition.andCondition(new MongoCondition(c)); | |
| 120 | + } | |
| 121 | + return condition.toMongoQuery(); | |
| 122 | + } | |
| 123 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SmsConfigController.java
View file @
467b803
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | import com.lyms.platform.common.utils.DateUtil; |
| 12 | 12 | import com.lyms.platform.common.utils.StringUtils; |
| 13 | 13 | import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; |
| 14 | +import com.lyms.platform.operate.web.facade.PatientServiceFacade; | |
| 14 | 15 | import com.lyms.platform.operate.web.facade.SmsConfigFacade; |
| 15 | 16 | import com.lyms.platform.operate.web.request.MessageListRequest; |
| 16 | 17 | import com.lyms.platform.operate.web.request.MessageRequest; |
| ... | ... | @@ -46,6 +47,8 @@ |
| 46 | 47 | |
| 47 | 48 | @Autowired |
| 48 | 49 | private SmsTemplateService smsTemplateService; |
| 50 | + @Autowired | |
| 51 | + private PatientServiceFacade patientServiceFacade; | |
| 49 | 52 | |
| 50 | 53 | /** |
| 51 | 54 | * 添加/更新 短信服务配置 |
| ... | ... | @@ -410,6 +413,14 @@ |
| 410 | 413 | } |
| 411 | 414 | } |
| 412 | 415 | return "sendBabyBuildSms finish"; |
| 416 | + } | |
| 417 | + | |
| 418 | + @RequestMapping(value = "/send/serviceMsg", method = RequestMethod.GET) | |
| 419 | + @ResponseBody | |
| 420 | + @TokenRequired | |
| 421 | + public BaseResponse sendServiceMsg(@RequestParam("hospitalId")String hospitalId){ | |
| 422 | + patientServiceFacade.sendMsg(hospitalId); | |
| 423 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); | |
| 413 | 424 | } |
| 414 | 425 | |
| 415 | 426 | @RequestMapping(value = "/sms/build/send", method = RequestMethod.GET) |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/StatisticsController.java
View file @
467b803
| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | import com.lyms.platform.operate.web.facade.PatientServiceFacade; |
| 17 | 17 | import com.lyms.platform.operate.web.request.CjStatisticsQueryRequest; |
| 18 | 18 | import com.lyms.platform.operate.web.request.JdStatisticsQueryRequest; |
| 19 | +import com.lyms.platform.operate.web.service.IBloodSugarService; | |
| 19 | 20 | import com.lyms.platform.query.AntExRecordQuery; |
| 20 | 21 | import com.lyms.platform.query.PatientsQuery; |
| 21 | 22 | import com.lymsh.platform.reportdata.model.AreaData; |
| 22 | 23 | |
| ... | ... | @@ -1194,7 +1195,27 @@ |
| 1194 | 1195 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 1195 | 1196 | return patientServiceFacade.queryStatistics(loginState.getId(),jdStatisticsQueryRequest); |
| 1196 | 1197 | } |
| 1198 | + @Autowired | |
| 1199 | + private IBloodSugarService bloodSugarService; | |
| 1197 | 1200 | |
| 1201 | + @RequestMapping(value = "/xtStatistics", method = RequestMethod.GET) | |
| 1202 | + @ResponseBody | |
| 1203 | + @TokenRequired | |
| 1204 | + public BaseResponse xtStatistics(HttpServletRequest request, String startTime,String endTime){ | |
| 1205 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 1206 | + return bloodSugarService.getXtStatistics(loginState.getId(),startTime,endTime); | |
| 1207 | + } | |
| 1208 | + | |
| 1209 | + @RequestMapping(value = "/xtStatistics/list", method = RequestMethod.GET) | |
| 1210 | + @ResponseBody | |
| 1211 | + @TokenRequired | |
| 1212 | + public BaseResponse xtStatisticsList(HttpServletRequest request, | |
| 1213 | + String startTime,String endTime, | |
| 1214 | + Integer id,Integer page,Integer limit){ | |
| 1215 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 1216 | + return bloodSugarService.getXtStatisticsList(loginState.getId(),startTime,endTime,id,page,limit); | |
| 1217 | + } | |
| 1218 | + | |
| 1198 | 1219 | @RequestMapping(value = "/yjStatistics", method = RequestMethod.GET) |
| 1199 | 1220 | @ResponseBody |
| 1200 | 1221 | @TokenRequired |
| 1201 | 1222 | |
| 1202 | 1223 | |
| 1203 | 1224 | |
| ... | ... | @@ -1202,22 +1223,21 @@ |
| 1202 | 1223 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 1203 | 1224 | return antenatalExaminationFacade.antenatalExaminationStatistics(loginState.getId()); |
| 1204 | 1225 | } |
| 1205 | - @RequestMapping(value = "/yjStatistics/list", method = RequestMethod.GET) | |
| 1226 | + @RequestMapping(value = "/yjStatistics/list", method = RequestMethod.POST) | |
| 1206 | 1227 | @ResponseBody |
| 1207 | 1228 | @TokenRequired |
| 1208 | - public BaseResponse yjStatisticsList(String parentIds, | |
| 1209 | - Integer page, | |
| 1210 | - Integer limit){ | |
| 1211 | - if (StringUtils.isEmpty(parentIds)){ | |
| 1229 | + public BaseResponse yjStatisticsList(@RequestBody Map<String,Object> params){ | |
| 1230 | + Object parentIds=params.get("parentIds"); | |
| 1231 | + if (parentIds==null){ | |
| 1212 | 1232 | return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
| 1213 | 1233 | } |
| 1214 | 1234 | PatientsQuery patientsQuery = new PatientsQuery(); |
| 1215 | 1235 | patientsQuery.setNeed("1"); |
| 1216 | 1236 | patientsQuery.setYn(1); |
| 1217 | - patientsQuery.setIds(com.lyms.platform.common.utils.StringUtils.covertToList(parentIds, String.class)); | |
| 1237 | + patientsQuery.setIds(com.lyms.platform.common.utils.StringUtils.covertToList(String.valueOf(parentIds), String.class)); | |
| 1218 | 1238 | patientsQuery.setNeed("true"); |
| 1219 | - patientsQuery.setLimit(limit); | |
| 1220 | - patientsQuery.setPage(page); | |
| 1239 | + patientsQuery.setLimit(Integer.valueOf(String.valueOf(params.get("limit")))); | |
| 1240 | + patientsQuery.setPage(Integer.valueOf(String.valueOf(params.get("page")))); | |
| 1221 | 1241 | return antenatalExaminationFacade.antenatalExaminationStatisticsList(patientsQuery); |
| 1222 | 1242 | } |
| 1223 | 1243 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java
View file @
467b803
| ... | ... | @@ -26,6 +26,8 @@ |
| 26 | 26 | import org.slf4j.Logger; |
| 27 | 27 | import org.slf4j.LoggerFactory; |
| 28 | 28 | import org.springframework.beans.factory.annotation.Autowired; |
| 29 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 30 | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | |
| 29 | 31 | import org.springframework.stereotype.Component; |
| 30 | 32 | |
| 31 | 33 | import java.util.*; |
| ... | ... | @@ -84,6 +86,9 @@ |
| 84 | 86 | private AreaCountFacade areaCountFacade; |
| 85 | 87 | @Autowired |
| 86 | 88 | private SmsConfigFacade smsConfigFacade; |
| 89 | + @Autowired | |
| 90 | + @Qualifier("commonThreadPool") | |
| 91 | + private ThreadPoolTaskExecutor commonThreadPool; | |
| 87 | 92 | |
| 88 | 93 | private static Logger logger = LoggerFactory.getLogger(PatientServiceFacade.class); |
| 89 | 94 | |
| ... | ... | @@ -566,7 +571,8 @@ |
| 566 | 571 | @Override |
| 567 | 572 | public void run() { |
| 568 | 573 | sendServiceMsg(patients, SmsServiceEnums.FWKT.getId(), "您好,请点击此处查看开通服务内容详情。", "大同市第一人民医院", ServiceObjEnums.YUNOBJ.getId(), 1); |
| 569 | - }}).start(); | |
| 574 | + } | |
| 575 | + }).start(); | |
| 570 | 576 | |
| 571 | 577 | } else if (PatientSerEnums.SerTypeEnums.bzfw.getId().intValue() == Integer.parseInt(serInfo.get("serType"))) { |
| 572 | 578 | |
| 573 | 579 | |
| ... | ... | @@ -603,11 +609,54 @@ |
| 603 | 609 | return baseResponse; |
| 604 | 610 | } |
| 605 | 611 | |
| 612 | + public void sendMsg(String hospitalId) { | |
| 613 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 614 | + patientsQuery.setYn(1); | |
| 615 | + patientsQuery.setHospitalId(hospitalId); | |
| 616 | + List<Patients> list = patientsService.queryPatient(patientsQuery); | |
| 617 | + if (CollectionUtils.isNotEmpty(list)) { | |
| 618 | + List<MsgRequest> messages = new ArrayList<>(); | |
| 619 | + for (Patients patients : list) { | |
| 620 | + Organization organization = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())); | |
| 621 | + if (organization != null) { | |
| 622 | + MsgRequest mr = new MsgRequest(); | |
| 623 | + mr.setPhone(patients.getPhone()); | |
| 624 | + mr.setTypeId(ProjectTypeEnums.YNXT.getId()); | |
| 625 | + mr.setStatus(SmsStatusEnums.WFS.getId()); | |
| 626 | + mr.setHospitalId(patients.getHospitalId()); | |
| 627 | + mr.setTempId(patients.getId()); | |
| 628 | + mr.setPatientId(patients.getId()); | |
| 629 | + mr.setSmsStatus(SmsStatusEnums.WFS.getId()); | |
| 630 | + mr.setServiceType(1); //判断发送类型 | |
| 631 | + mr.setFirst("系统已更新,请刷新小程序进行体验");// | |
| 632 | + mr.setObjType(1); | |
| 633 | + mr.setSubTypeId(SmsServiceEnums.FWKT.getId()); | |
| 634 | + mr.setKeyword1(organization.getName());// | |
| 635 | + //planTime 和 timeType为必填 否则推送中心会推送异常 | |
| 636 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
| 637 | + mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
| 638 | + mr.setKeyword2("产科(系统已更新,请刷新小程序进行体验)"); | |
| 639 | + mr.setRemark(patients.getUsername()); | |
| 640 | + mr.setCreated(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
| 641 | + mr.setWxTempId("tx-UmDE3YMqYgAeFccXB7HIlTuG_tiP9LMdX2bvBpus"); | |
| 642 | + messages.add(mr); | |
| 643 | + } | |
| 644 | + } | |
| 645 | + if (CollectionUtils.isNotEmpty(messages)){ | |
| 646 | + smsConfigFacade.saveMsg(messages, hospitalId); | |
| 647 | + } | |
| 648 | + | |
| 649 | + } | |
| 650 | + } | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 606 | 655 | //大同医院服务推送\短信 |
| 607 | 656 | public void sendServiceMsg(Patients patient, Integer subTypeId, String first, String keyWord1, Integer objType, Integer type) { |
| 608 | 657 | if ("2100002419".equals(patient.getHospitalId())) { |
| 609 | 658 | try { |
| 610 | - // Thread.sleep(3000); | |
| 659 | + // Thread.sleep(3000); | |
| 611 | 660 | logger.info("sendServiceMsg startup"); |
| 612 | 661 | List<MsgRequest> messages = new ArrayList<>(); |
| 613 | 662 | if (type != null) { |
| ... | ... | @@ -636,7 +685,7 @@ |
| 636 | 685 | request.setKeyword1(title); |
| 637 | 686 | request.setKeyword2(DateUtil.getyyyy_MM_dd(DateUtil.addDay(new Date(), 0))); |
| 638 | 687 | messages.add(request); |
| 639 | - }else { | |
| 688 | + } else { | |
| 640 | 689 | MsgRequest mr = new MsgRequest(); |
| 641 | 690 | mr.setPhone(patient.getPhone()); |
| 642 | 691 | mr.setTypeId(ProjectTypeEnums.YNXT.getId()); |
| ... | ... | @@ -686,7 +735,7 @@ |
| 686 | 735 | |
| 687 | 736 | if (serviceWeek != null) { |
| 688 | 737 | Date endTime = DateUtil.addWeek(currentDate, serviceWeek); |
| 689 | - if (pser.getPerType()==1){ | |
| 738 | + if (pser.getPerType() == 1) { | |
| 690 | 739 | if (endTime.getTime() > DateUtil.addWeek(lastMenses, 42).getTime()) { |
| 691 | 740 | endTime = DateUtil.addWeek(lastMenses, 42); |
| 692 | 741 | } |
| ... | ... | @@ -700,7 +749,7 @@ |
| 700 | 749 | } |
| 701 | 750 | if (doctorService != null) { |
| 702 | 751 | Date endTime = DateUtil.addWeek(currentDate, doctorService); |
| 703 | - if (pser.getPerType()==1){ | |
| 752 | + if (pser.getPerType() == 1) { | |
| 704 | 753 | if (endTime.getTime() > DateUtil.addWeek(lastMenses, 42).getTime()) { |
| 705 | 754 | endTime = DateUtil.addWeek(lastMenses, 42); |
| 706 | 755 | } |
| ... | ... | @@ -729,7 +778,7 @@ |
| 729 | 778 | |
| 730 | 779 | Date startTime = pser.getSerStartTime(); |
| 731 | 780 | Date endTime = DateUtil.addWeek(pser.getSerEndTime(), serviceWeek); |
| 732 | - if (pser.getPerType()==1){ | |
| 781 | + if (pser.getPerType() == 1) { | |
| 733 | 782 | if (endTime.getTime() > DateUtil.addWeek(lastMenses, 42).getTime()) { |
| 734 | 783 | endTime = DateUtil.addWeek(lastMenses, 42); |
| 735 | 784 | } |
| ... | ... | @@ -756,7 +805,7 @@ |
| 756 | 805 | if (doctorWeek != null && doctorWeek > 0) { |
| 757 | 806 | if (pser.getDocEndTime() != null && pser.getDocEndTime().getTime() > new Date().getTime()) { |
| 758 | 807 | Date endTime = DateUtil.addWeek(pser.getDocEndTime(), doctorWeek); |
| 759 | - if (pser.getPerType()==1){ | |
| 808 | + if (pser.getPerType() == 1) { | |
| 760 | 809 | if (endTime.getTime() > DateUtil.addWeek(lastMenses, 42).getTime()) { |
| 761 | 810 | endTime = DateUtil.addWeek(lastMenses, 42); |
| 762 | 811 | } |
| ... | ... | @@ -1289,7 +1338,7 @@ |
| 1289 | 1338 | //指定医生 |
| 1290 | 1339 | jsonObject.put("serDoct", ps.getSerDoct() == null ? "" : ps.getSerDoct()); |
| 1291 | 1340 | //开通医生 |
| 1292 | - jsonObject.put("createUser", StringUtils.isNotEmpty(ps.getCreateUser())? ps.getCreateUser():""); | |
| 1341 | + jsonObject.put("createUser", StringUtils.isNotEmpty(ps.getCreateUser()) ? ps.getCreateUser() : ""); | |
| 1293 | 1342 | //服务状态 |
| 1294 | 1343 | jsonObject.put("serStatus", ps.getSerStatus()); |
| 1295 | 1344 | jsonObject.put("hospitalId", ps.getHospitalId()); |
| ... | ... | @@ -1542,6 +1591,7 @@ |
| 1542 | 1591 | // } |
| 1543 | 1592 | // } |
| 1544 | 1593 | } |
| 1594 | + | |
| 1545 | 1595 | @Autowired |
| 1546 | 1596 | private CommunityConfigService communityConfigService; |
| 1547 | 1597 | @Autowired |
| 1548 | 1598 | |
| 1549 | 1599 | |
| 1550 | 1600 | |
| 1551 | 1601 | |
| 1552 | 1602 | |
| ... | ... | @@ -1555,33 +1605,33 @@ |
| 1555 | 1605 | return baseResponse; |
| 1556 | 1606 | } |
| 1557 | 1607 | |
| 1558 | - PatientsQuery patientsQuery=new PatientsQuery(); | |
| 1608 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 1559 | 1609 | patientsQuery.setYn(1); |
| 1560 | 1610 | patientsQuery.setHospitalId(hospitalId); |
| 1561 | 1611 | patientsQuery.setNeed("1"); |
| 1562 | 1612 | patientsQuery.setPage(statisticsQueryRequest.getPage()); |
| 1563 | 1613 | patientsQuery.setLimit(statisticsQueryRequest.getLimit()); |
| 1564 | - if (StringUtils.isNotEmpty(statisticsQueryRequest.getDueDate())){ | |
| 1565 | - String time=statisticsQueryRequest.getDueDate(); | |
| 1566 | - String array[]= time.split(" - "); | |
| 1567 | - patientsQuery.setDueDateStart(DateUtil.parseYMDHMS(array[0]+" 00:00:00")); | |
| 1568 | - patientsQuery.setDueDateEnd(DateUtil.parseYMDHMS(array[1]+" 23:59:59")); | |
| 1614 | + if (StringUtils.isNotEmpty(statisticsQueryRequest.getDueDate())) { | |
| 1615 | + String time = statisticsQueryRequest.getDueDate(); | |
| 1616 | + String array[] = time.split(" - "); | |
| 1617 | + patientsQuery.setDueDateStart(DateUtil.parseYMDHMS(array[0] + " 00:00:00")); | |
| 1618 | + patientsQuery.setDueDateEnd(DateUtil.parseYMDHMS(array[1] + " 23:59:59")); | |
| 1569 | 1619 | } |
| 1570 | - if (StringUtils.isNotEmpty(statisticsQueryRequest.getBookbuildingDoctor())){ | |
| 1620 | + if (StringUtils.isNotEmpty(statisticsQueryRequest.getBookbuildingDoctor())) { | |
| 1571 | 1621 | patientsQuery.setBookbuildingDoctor(statisticsQueryRequest.getBookbuildingDoctor()); |
| 1572 | 1622 | } |
| 1573 | - if (StringUtils.isNotEmpty(statisticsQueryRequest.getBookbuildingDate())){ | |
| 1574 | - String time=statisticsQueryRequest.getBookbuildingDate(); | |
| 1575 | - String array[]= time.split(" - "); | |
| 1576 | - patientsQuery.setBookbuildingDateStart(DateUtil.parseYMDHMS(array[0]+" 00:00:00")); | |
| 1577 | - patientsQuery.setBookbuildingDateEnd(DateUtil.parseYMDHMS(array[1]+" 23:59:59")); | |
| 1623 | + if (StringUtils.isNotEmpty(statisticsQueryRequest.getBookbuildingDate())) { | |
| 1624 | + String time = statisticsQueryRequest.getBookbuildingDate(); | |
| 1625 | + String array[] = time.split(" - "); | |
| 1626 | + patientsQuery.setBookbuildingDateStart(DateUtil.parseYMDHMS(array[0] + " 00:00:00")); | |
| 1627 | + patientsQuery.setBookbuildingDateEnd(DateUtil.parseYMDHMS(array[1] + " 23:59:59")); | |
| 1578 | 1628 | } |
| 1579 | 1629 | List data = new ArrayList<>(); |
| 1580 | - if (statisticsQueryRequest.getType()==0){ | |
| 1581 | - if (StringUtils.isEmpty(statisticsQueryRequest.getBookbuildingDoctor())){ | |
| 1630 | + if (statisticsQueryRequest.getType() == 0) { | |
| 1631 | + if (StringUtils.isEmpty(statisticsQueryRequest.getBookbuildingDoctor())) { | |
| 1582 | 1632 | patientsQuery.setNebookbuildingDoctor("1"); |
| 1583 | 1633 | } |
| 1584 | - List<HashMap> list = patientsService.aggregatbookbuildingDoctore(patientsQuery); | |
| 1634 | + List<HashMap> list = patientsService.aggregatbookbuildingDoctore(patientsQuery); | |
| 1585 | 1635 | for (HashMap map : list) { |
| 1586 | 1636 | CjStatisticsResult cjStatisticsResult = new CjStatisticsResult(); |
| 1587 | 1637 | String dId = null; |
| ... | ... | @@ -1601,7 +1651,7 @@ |
| 1601 | 1651 | Users users = usersService.getUsers(Integer.valueOf(dId)); |
| 1602 | 1652 | if (null != users) { |
| 1603 | 1653 | cjStatisticsResult.setdName(users.getName()); |
| 1604 | - }else { | |
| 1654 | + } else { | |
| 1605 | 1655 | continue; |
| 1606 | 1656 | } |
| 1607 | 1657 | } |
| 1608 | 1658 | |
| ... | ... | @@ -1611,10 +1661,10 @@ |
| 1611 | 1661 | } |
| 1612 | 1662 | Collections.sort(data, new CjStatisticsResult()); |
| 1613 | 1663 | baseResponse.setObject(data); |
| 1614 | - }else { | |
| 1664 | + } else { | |
| 1615 | 1665 | List<Patients> patientsList = patientsService.queryPatient(patientsQuery); |
| 1616 | - List <PatientManagerQueryModel> patientManagerQueryModelList = new ArrayList <>(); | |
| 1617 | - if (CollectionUtils.isNotEmpty(patientsList)){ | |
| 1666 | + List<PatientManagerQueryModel> patientManagerQueryModelList = new ArrayList<>(); | |
| 1667 | + if (CollectionUtils.isNotEmpty(patientsList)) { | |
| 1618 | 1668 | if (CollectionUtils.isNotEmpty(patientsList)) { |
| 1619 | 1669 | for (Patients patients : patientsList) { |
| 1620 | 1670 | PatientManagerQueryModel patientManagerQueryModel = new PatientManagerQueryModel(); |
| 1621 | 1671 | |
| ... | ... | @@ -1643,14 +1693,11 @@ |
| 1643 | 1693 | } |
| 1644 | 1694 | |
| 1645 | 1695 | if (!"-".equals(patientManagerQueryModel.getRiskFactorId()) && org.apache.commons.lang.StringUtils.isNotEmpty(patients.getoRiskFactor())) { |
| 1646 | - patientManagerQueryModel.setRiskFactorId(patientManagerQueryModel.getRiskFactorId()+","+patients.getoRiskFactor()); | |
| 1647 | - }else if (org.apache.commons.lang.StringUtils.isNotEmpty(patients.getoRiskFactor())) | |
| 1648 | - { | |
| 1696 | + patientManagerQueryModel.setRiskFactorId(patientManagerQueryModel.getRiskFactorId() + "," + patients.getoRiskFactor()); | |
| 1697 | + } else if (org.apache.commons.lang.StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 1649 | 1698 | patientManagerQueryModel.setRiskFactorId(patients.getoRiskFactor()); |
| 1650 | 1699 | } |
| 1651 | - } | |
| 1652 | - else if (org.apache.commons.lang.StringUtils.isNotEmpty(patients.getoRiskFactor())) | |
| 1653 | - { | |
| 1700 | + } else if (org.apache.commons.lang.StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 1654 | 1701 | patientManagerQueryModel.setRiskFactorId(patients.getoRiskFactor()); |
| 1655 | 1702 | } |
| 1656 | 1703 | |
| 1657 | 1704 | |
| 1658 | 1705 | |
| 1659 | 1706 | |
| ... | ... | @@ -1674,21 +1721,21 @@ |
| 1674 | 1721 | } |
| 1675 | 1722 | |
| 1676 | 1723 | Organization org = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())); |
| 1677 | - if(null != org){ | |
| 1724 | + if (null != org) { | |
| 1678 | 1725 | patientManagerQueryModel.setOrgType(org.getType()); |
| 1679 | 1726 | } |
| 1680 | 1727 | |
| 1681 | 1728 | String comm = "未分配"; |
| 1682 | - if(StringUtils.isNotEmpty(patients.getCommunityId())){ | |
| 1729 | + if (StringUtils.isNotEmpty(patients.getCommunityId())) { | |
| 1683 | 1730 | CommunityConfig communityConfig = communityConfigService.getCommunityById(patients.getCommunityId()); |
| 1684 | - if(null != communityConfig){ | |
| 1731 | + if (null != communityConfig) { | |
| 1685 | 1732 | comm = communityConfig.getName(); |
| 1686 | 1733 | } |
| 1687 | 1734 | } |
| 1688 | 1735 | patientManagerQueryModel.setCouponCommunity(comm); |
| 1689 | 1736 | patientManagerQueryModel.setTypeStr(patients.getType() == 1 ? "未分娩" : "已分娩"); |
| 1690 | 1737 | patientManagerQueryModel.setYyzyfmHospitalName( |
| 1691 | - (patients.getYyzyfmHospitalId() != null && "-1".equals(patients.getYyzyfmHospitalId())) ? "其他" : couponMapper.getHospitalName(patients.getYyzyfmHospitalId())); | |
| 1738 | + (patients.getYyzyfmHospitalId() != null && "-1".equals(patients.getYyzyfmHospitalId())) ? "其他" : couponMapper.getHospitalName(patients.getYyzyfmHospitalId())); | |
| 1692 | 1739 | patientManagerQueryModel.setAge(DateUtil.getAge(patients.getBirth())); |
| 1693 | 1740 | patientManagerQueryModel.setpId(patients.getPid()); |
| 1694 | 1741 | String dueWeek = ""; |
| ... | ... | @@ -1784,7 +1831,7 @@ |
| 1784 | 1831 | return baseResponse; |
| 1785 | 1832 | } |
| 1786 | 1833 | |
| 1787 | - public BaseResponse getPatientList(PatientsQuery patientsQuery,Integer userId){ | |
| 1834 | + public BaseResponse getPatientList(PatientsQuery patientsQuery, Integer userId) { | |
| 1788 | 1835 | BaseListResponse baseResponse = new BaseListResponse(); |
| 1789 | 1836 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
| 1790 | 1837 | if (StringUtils.isEmpty(hospitalId)) { |
| ... | ... | @@ -1795,7 +1842,7 @@ |
| 1795 | 1842 | patientsQuery.setYn(1); |
| 1796 | 1843 | patientsQuery.setServiceType(1); |
| 1797 | 1844 | patientsQuery.setNeed("true"); |
| 1798 | - List<Patients> list= patientsService.queryPatient(patientsQuery); | |
| 1845 | + List<Patients> list = patientsService.queryPatient(patientsQuery); | |
| 1799 | 1846 | baseResponse.setPageInfo(patientsQuery.getPageInfo()); |
| 1800 | 1847 | baseResponse.setData(list); |
| 1801 | 1848 | return baseResponse; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBloodSugarService.java
View file @
467b803
| ... | ... | @@ -45,5 +45,7 @@ |
| 45 | 45 | BaseResponse queryDiabetesRecord(String patientId); |
| 46 | 46 | |
| 47 | 47 | BaseResponse getDoctorWx(String patientId); |
| 48 | + BaseResponse getXtStatistics(Integer userId,String startTime,String endTime); | |
| 49 | + BaseResponse getXtStatisticsList(Integer userId,String startTime,String endTime,Integer id,Integer page,Integer limit); | |
| 48 | 50 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
467b803
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | import com.lyms.platform.beans.MsgRequest; |
| 6 | 6 | import com.lyms.platform.biz.service.*; |
| 7 | 7 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 8 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
| 8 | 9 | import com.lyms.platform.common.enums.*; |
| 9 | 10 | import com.lyms.platform.common.result.*; |
| 10 | 11 | import com.lyms.platform.common.utils.BeanUtils; |
| 11 | 12 | |
| ... | ... | @@ -29,16 +30,16 @@ |
| 29 | 30 | import com.lyms.platform.permission.service.PatientServiceService; |
| 30 | 31 | import com.lyms.platform.permission.service.UsersService; |
| 31 | 32 | import com.lyms.platform.pojo.*; |
| 32 | -import com.lyms.platform.query.AntExChuQuery; | |
| 33 | -import com.lyms.platform.query.AntExRecordQuery; | |
| 34 | -import com.lyms.platform.query.BloodSugarQuery; | |
| 35 | -import com.lyms.platform.query.PatientsQuery; | |
| 33 | +import com.lyms.platform.query.*; | |
| 36 | 34 | import org.apache.commons.collections.MapUtils; |
| 37 | 35 | import org.apache.commons.collections.map.HashedMap; |
| 38 | 36 | import org.springframework.beans.factory.annotation.Autowired; |
| 39 | 37 | import org.springframework.beans.factory.annotation.Qualifier; |
| 40 | 38 | import org.springframework.data.domain.Sort; |
| 41 | 39 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 40 | +import org.springframework.data.mongodb.core.aggregation.Aggregation; | |
| 41 | +import org.springframework.data.mongodb.core.aggregation.AggregationOperation; | |
| 42 | +import org.springframework.data.mongodb.core.aggregation.AggregationResults; | |
| 42 | 43 | import org.springframework.data.mongodb.core.query.Criteria; |
| 43 | 44 | import org.springframework.data.mongodb.core.query.Query; |
| 44 | 45 | import org.springframework.data.mongodb.core.query.Update; |
| 45 | 46 | |
| ... | ... | @@ -111,11 +112,13 @@ |
| 111 | 112 | private ThreadPoolTaskExecutor commonThreadPool; |
| 112 | 113 | |
| 113 | 114 | public BaseResponse add(Integer userId, BloodSugar bloodSugar) { |
| 114 | - | |
| 115 | + String ymd= DateUtil.getyyyy_MM_dd(new Date()); | |
| 116 | + String hospitalId= autoMatchFacade.getHospitalId(userId); | |
| 115 | 117 | Patients patients = mongoTemplate.findById(bloodSugar.getParentId(), Patients.class); |
| 116 | 118 | String pid = patients.getPid(); |
| 117 | 119 | BloodSugar one = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("created").gt(DateUtil.getYMDTime()).and("bloodSugarType").is(bloodSugar.getBloodSugarType())), BloodSugar.class); |
| 118 | - | |
| 120 | + BloodSugarStatistics sugarStatistics=mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("ymdDate").is(ymd)), BloodSugarStatistics.class); | |
| 121 | + Integer sugarType=0; | |
| 119 | 122 | if (one != null) { |
| 120 | 123 | //one.setSugarType(sugarType); |
| 121 | 124 | one.setModified(new Date()); |
| 122 | 125 | |
| 123 | 126 | |
| 124 | 127 | |
| 125 | 128 | |
| ... | ... | @@ -125,26 +128,52 @@ |
| 125 | 128 | } |
| 126 | 129 | one.setRiskFactorId(patients.getRiskFactorId()); |
| 127 | 130 | bloodSugarService.update(one); |
| 131 | + sugarType=one.getSugarType(); | |
| 132 | + saveOrUpdate(sugarStatistics,patients,hospitalId,ymd,sugarType); | |
| 128 | 133 | return RespBuilder.buildSuccess(one.getId()); |
| 129 | 134 | } |
| 130 | 135 | // bloodSugar.setSugarType(sugarType); |
| 131 | 136 | bloodSugar.setParentId(patients.getId()); |
| 132 | - bloodSugar.setHospitalId(autoMatchFacade.getHospitalId(userId)); | |
| 137 | + bloodSugar.setHospitalId(hospitalId); | |
| 133 | 138 | bloodSugar.setCreated(new Date()); |
| 134 | 139 | bloodSugar.setCreateUser(userId); |
| 135 | 140 | bloodSugar.setYn(YnEnums.YES.getId()); |
| 136 | 141 | bloodSugar.setModified(new Date()); |
| 137 | - bloodSugar.setCreatYmdDate(DateUtil.getyyyy_MM_dd(new Date())); | |
| 142 | + bloodSugar.setCreatYmdDate(ymd); | |
| 138 | 143 | bloodSugar.setPid(pid); |
| 139 | 144 | bloodSugar.setRiskFactorId(patients.getRiskFactorId()); |
| 140 | 145 | bloodSugarService.add(bloodSugar); |
| 141 | - | |
| 146 | + sugarType=bloodSugar.getSugarType(); | |
| 147 | + saveOrUpdate(sugarStatistics,patients,hospitalId,ymd,sugarType); | |
| 142 | 148 | Update up = new Update(); |
| 143 | 149 | up.set("exceptionSend", 0); |
| 144 | 150 | mongoTemplate.updateMulti(Query.query(Criteria.where("pid").is(pid)), up, BloodSugar.class); |
| 145 | 151 | return RespBuilder.buildSuccess(bloodSugar.getId()); |
| 146 | 152 | } |
| 147 | 153 | |
| 154 | + public void saveOrUpdate(BloodSugarStatistics sugarStatistics, | |
| 155 | + Patients patients, | |
| 156 | + String hospitalId, | |
| 157 | + String ymd, | |
| 158 | + Integer sugarType){ | |
| 159 | + if (sugarStatistics!=null){ | |
| 160 | + Update up = new Update(); | |
| 161 | + up.set("sugarType", sugarType); | |
| 162 | + up.set("modified",new Date()); | |
| 163 | + mongoTemplate.updateMulti(Query.query(Criteria.where("id").is(sugarStatistics.getId())), up, BloodSugarStatistics.class); | |
| 164 | + }else { | |
| 165 | + sugarStatistics=new BloodSugarStatistics(); | |
| 166 | + sugarStatistics.setParentId(patients.getId()); | |
| 167 | + sugarStatistics.setPid(patients.getPid()); | |
| 168 | + sugarStatistics.setSugarType(sugarType); | |
| 169 | + sugarStatistics.setCreated(new Date()); | |
| 170 | + sugarStatistics.setHospitalId(hospitalId); | |
| 171 | + sugarStatistics.setYn(YnEnums.YES.getId()); | |
| 172 | + sugarStatistics.setYmdDate(ymd); | |
| 173 | + mongoTemplate.save(sugarStatistics); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 148 | 177 | /** |
| 149 | 178 | * |
| 150 | 179 | * @param type 1正常血糖管理、2低血糖管理、3高血糖管理 |
| ... | ... | @@ -224,7 +253,6 @@ |
| 224 | 253 | temp.put("vcCardNo", p.getVcCardNo()); |
| 225 | 254 | temp.put("pcerteTypeId", p.getPcerteTypeId()); |
| 226 | 255 | temp.put("cardNo", p.getCardNo()); |
| 227 | - temp.put("cardNo", p.getCardNo()); | |
| 228 | 256 | temp.put("isPrint", null==bloodSugar.getIsPrint()?"":bloodSugar.getIsPrint()==1?"已打印":"未打印"); |
| 229 | 257 | } |
| 230 | 258 | restList.add(temp); |
| 231 | 259 | |
| 232 | 260 | |
| ... | ... | @@ -414,12 +442,17 @@ |
| 414 | 442 | public BaseResponse wxAdd(String parentId, String bloodSugar, Integer bloodSugarType, boolean flag) { |
| 415 | 443 | Patients patients = mongoTemplate.findById(parentId, Patients.class); |
| 416 | 444 | String pid = patients.getPid(); |
| 445 | + String ymd=DateUtil.getyyyy_MM_dd(new Date()); | |
| 417 | 446 | BloodSugar one = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("created").gt(DateUtil.getYMDTime()).and("bloodSugarType").is(bloodSugarType)), BloodSugar.class); |
| 447 | + BloodSugarStatistics sugarStatistics=mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("ymdDate").is(ymd)), BloodSugarStatistics.class); | |
| 448 | + Integer sugarType=0; | |
| 418 | 449 | if (one != null) { |
| 419 | 450 | one.setModified(new Date()); |
| 420 | 451 | one.setBloodSugar(bloodSugar); |
| 421 | 452 | one.setRiskFactorId(patients.getRiskFactorId()); |
| 422 | 453 | bloodSugarService.update(one); |
| 454 | + sugarType=one.getSugarType(); | |
| 455 | + saveOrUpdate(sugarStatistics,patients,patients.getHospitalId(),ymd,sugarType); | |
| 423 | 456 | Update up = new Update(); |
| 424 | 457 | up.set("exceptionSend", 0); |
| 425 | 458 | mongoTemplate.updateMulti(Query.query(Criteria.where("pid").is(pid)), up, BloodSugar.class); |
| 426 | 459 | |
| ... | ... | @@ -435,9 +468,10 @@ |
| 435 | 468 | one.setYn(YnEnums.YES.getId()); |
| 436 | 469 | one.setModified(new Date()); |
| 437 | 470 | one.setRiskFactorId(patients.getRiskFactorId()); |
| 438 | - one.setCreatYmdDate(DateUtil.getyyyy_MM_dd(new Date())); | |
| 471 | + one.setCreatYmdDate(ymd); | |
| 439 | 472 | if (!flag) { |
| 440 | 473 | bloodSugarService.add(one); |
| 474 | + sugarType=one.getSugarType(); | |
| 441 | 475 | } else { |
| 442 | 476 | String str= getBloodSugarStatus(patients.getRiskFactorId(),patients.getHospitalId(),one.getBloodSugarType(), one.getBloodSugar()); |
| 443 | 477 | Integer type=1; |
| 444 | 478 | |
| ... | ... | @@ -448,8 +482,9 @@ |
| 448 | 482 | } |
| 449 | 483 | one.setSugarType(type); |
| 450 | 484 | mongoTemplate.save(one); |
| 485 | + sugarType=type; | |
| 451 | 486 | } |
| 452 | - | |
| 487 | + saveOrUpdate(sugarStatistics,patients,patients.getHospitalId(),ymd,sugarType); | |
| 453 | 488 | Update up = new Update(); |
| 454 | 489 | up.set("exceptionSend", 0); |
| 455 | 490 | mongoTemplate.updateMulti(Query.query(Criteria.where("pid").is(pid)), up, BloodSugar.class); |
| ... | ... | @@ -1766,6 +1801,80 @@ |
| 1766 | 1801 | } |
| 1767 | 1802 | return RespBuilder.buildSuccess(restList); |
| 1768 | 1803 | } |
| 1804 | + | |
| 1805 | + @Override | |
| 1806 | + public BaseResponse getXtStatistics(Integer userId, String startTime, String endTime) { | |
| 1807 | + String hospitalId= autoMatchFacade.getHospitalId(userId); | |
| 1808 | + BloodSugarStatisticsQuery query=new BloodSugarStatisticsQuery(); | |
| 1809 | + query.setHospitalId(hospitalId); | |
| 1810 | + query.setYn(1); | |
| 1811 | + query.setStartTime(DateUtil.parseYMDHMS(startTime+" 00:00:00")); | |
| 1812 | + query.setEndTime(DateUtil.parseYMDHMS(endTime+" 23:59:59")); | |
| 1813 | + BaseResponse baseResponse=new BaseResponse(); | |
| 1814 | + baseResponse.setObject(aggregateOne(query.convertToQuery())); | |
| 1815 | + baseResponse.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); | |
| 1816 | + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 1817 | + return baseResponse; | |
| 1818 | + } | |
| 1819 | + | |
| 1820 | + @Override | |
| 1821 | + public BaseResponse getXtStatisticsList(Integer userId, | |
| 1822 | + String startTime, String endTime, Integer id, | |
| 1823 | + Integer page,Integer limit) { | |
| 1824 | + String hospitalId= autoMatchFacade.getHospitalId(userId); | |
| 1825 | + Criteria criteria = Criteria.where("hospitalId").is(hospitalId); | |
| 1826 | + criteria.and("yn").is(1); | |
| 1827 | + if (id!=null){ | |
| 1828 | + //1正常血糖管理、2低血糖管理、3高血糖管理 | |
| 1829 | + criteria.and("sugarType").is(id); | |
| 1830 | + } | |
| 1831 | + Query query = Query.query(criteria).with(new Sort(Sort.Direction.DESC, "created")); | |
| 1832 | + PageResult pageResult = findMongoPage(BloodSugarStatistics.class, query, page, limit); | |
| 1833 | + List<BloodSugarStatistics> bloodSugars = (List<BloodSugarStatistics>) pageResult.getGrid(); | |
| 1834 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 1835 | + for (BloodSugarStatistics bloodSugar : bloodSugars) { | |
| 1836 | + Map<String, Object> temp = new HashMap<>(); | |
| 1837 | + Patients p = mongoTemplate.findById(bloodSugar.getParentId(), Patients.class); | |
| 1838 | + temp.put("id", bloodSugar.getParentId()); | |
| 1839 | + temp.put("zid", bloodSugar.getId()); | |
| 1840 | + if (p != null) { | |
| 1841 | + temp.put("username", p.getUsername()); | |
| 1842 | + temp.put("time", DateUtil.getyyyy_MM_dd(bloodSugar.getModified())); | |
| 1843 | + temp.put("age", DateUtil.getAge(p.getBirth())); | |
| 1844 | + temp.put("week", DateUtil.getWeekDesc(p.getLastMenses(), new Date())); | |
| 1845 | + temp.put("riskLevel", commonService.findRiskLevel(p.getRiskLevelId())); //高危等级(颜色) | |
| 1846 | + String rFactor = commonService.resloveFactor(p.getRiskFactorId()); | |
| 1847 | + if (p.getoRiskFactor() != null && !"null".equals(p.getoRiskFactor())) { | |
| 1848 | + if (StringUtils.isNotEmpty(rFactor)) { | |
| 1849 | + rFactor += "," + p.getoRiskFactor(); | |
| 1850 | + } else { | |
| 1851 | + rFactor = p.getoRiskFactor(); | |
| 1852 | + } | |
| 1853 | + } | |
| 1854 | + temp.put("riskFactor", rFactor); // 高危因素 | |
| 1855 | + temp.put("dueDate", DateUtil.getyyyy_MM_dd(p.getDueDate())); | |
| 1856 | + temp.put("status", bloodSugar.getSugarType()); | |
| 1857 | + temp.put("vcCardNo", p.getVcCardNo()); | |
| 1858 | + temp.put("pcerteTypeId", p.getPcerteTypeId()); | |
| 1859 | + temp.put("cardNo", p.getCardNo()); | |
| 1860 | + } | |
| 1861 | + restList.add(temp); | |
| 1862 | + } | |
| 1863 | + pageResult.setGrid(restList); | |
| 1864 | + return RespBuilder.buildSuccess(pageResult); | |
| 1865 | + } | |
| 1866 | + | |
| 1867 | + public List<HashMap> aggregateOne(MongoQuery mongoQuery) { | |
| 1868 | + AggregationOperation match = Aggregation.match(mongoQuery.getCriteria()); | |
| 1869 | + | |
| 1870 | + AggregationOperation group = Aggregation.group("sugarType").count().as("count"); | |
| 1871 | + | |
| 1872 | + Aggregation aggregation = Aggregation.newAggregation(match, group); | |
| 1873 | + | |
| 1874 | + AggregationResults<HashMap> result = mongoTemplate.aggregate(aggregation, "lyms_blood_sugar_statistics", HashMap.class); | |
| 1875 | + return result.getMappedResults(); | |
| 1876 | + } | |
| 1877 | + | |
| 1769 | 1878 | |
| 1770 | 1879 | public void initSugar(){ |
| 1771 | 1880 | final List<BloodSugar> bloodSugars = mongoTemplate.find( new Query(new Criteria().and("yn").is(1)),BloodSugar.class); |