From a7618f220343f69e7b82d962988243f4dc125e96 Mon Sep 17 00:00:00 2001 From: dongqin <123456> Date: Tue, 20 Aug 2019 17:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/MatdeliverFollowController.java | 34 ++- .../operate/web/facade/MatdeliverFollowFacade.java | 121 ++++++++++- .../web/request/QuestionnairePushRequest.java | 231 +++++++++++++++++++++ 3 files changed, 378 insertions(+), 8 deletions(-) create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/QuestionnairePushRequest.java diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatdeliverFollowController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatdeliverFollowController.java index 415635d..7c78482 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatdeliverFollowController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatdeliverFollowController.java @@ -8,15 +8,14 @@ import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.operate.web.facade.MatdeliverFollowFacade; import com.lyms.platform.operate.web.request.MatDeliverFollowAddRequest; import com.lyms.platform.operate.web.request.MatdeliverFollowRequest; +import com.lyms.platform.operate.web.request.QuestionnairePushRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; /** *

@@ -121,4 +120,31 @@ public class MatdeliverFollowController extends BaseController { matdeliverFollowRequest.setNeed("need"); return matdeliverFollowFacade.getPostpartumFollowMake(matdeliverFollowRequest, loginState.getId()); } + + /** + * 推送问卷 + * + * @param request + * @return + */ + @ResponseBody + @TokenRequired + @RequestMapping(value = "/questionnaire/push", method = RequestMethod.POST) + public BaseResponse questionnairePush(@RequestBody @Valid QuestionnairePushRequest questionnairePushRequest, HttpServletRequest request) { + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); + return matdeliverFollowFacade.questionnairePush(questionnairePushRequest, loginState.getId()); + } + + /** + * 推送问卷 -- 保存产、妇在小程序端填写的数据 + * + * @param param + * @return + */ + @ResponseBody + @RequestMapping(value = "/questionnaire/upload", method = RequestMethod.POST) + public BaseResponse addQuestionnaire(@RequestBody @Valid QuestionnairePushRequest param) { + return matdeliverFollowFacade.addQuestionnaire(param); + } + } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatdeliverFollowFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatdeliverFollowFacade.java index e227d88..e953d91 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatdeliverFollowFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatdeliverFollowFacade.java @@ -1,22 +1,25 @@ package com.lyms.platform.operate.web.facade; +import com.alibaba.fastjson.JSONObject; +import com.lyms.platform.beans.MsgListRequest; +import com.lyms.platform.beans.MsgRequest; import com.lyms.platform.biz.service.*; import com.lyms.platform.common.constants.ErrorCodeConstants; -import com.lyms.platform.common.enums.OptActionEnums; -import com.lyms.platform.common.enums.PostpartumFollowMakeEnums; -import com.lyms.platform.common.enums.TrackDownDateEnums; -import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.common.enums.*; import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.common.utils.BeanUtils; import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.common.utils.ExcelUtil; import com.lyms.platform.operate.web.request.MatDeliverFollowAddRequest; import com.lyms.platform.operate.web.request.MatdeliverFollowRequest; +import com.lyms.platform.operate.web.request.QuestionnairePushRequest; import com.lyms.platform.operate.web.result.MatdeliverFollowListResult; import com.lyms.platform.operate.web.result.MatdeliverFollowResult; import com.lyms.platform.operate.web.service.ITrackDownService; import com.lyms.platform.operate.web.utils.CollectionUtils; +import com.lyms.platform.operate.web.utils.MessageCenterService; import com.lyms.platform.operate.web.utils.ResponseUtil; import com.lyms.platform.operate.web.utils.UnitConstants; import com.lyms.platform.permission.model.Organization; @@ -38,6 +41,10 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.poi.ss.util.CellRangeAddress; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletResponse; @@ -77,6 +84,9 @@ public class MatdeliverFollowFacade { @Autowired private PersonService personService; + @Autowired + protected MongoTemplate mongoTemplate; + public BaseResponse matdeliverFollowMakeInit(Integer id) { Map map = new HashMap(); //是否结案 @@ -663,4 +673,107 @@ public class MatdeliverFollowFacade { } return out; } + + /** + * 问卷推送 + * + * @param questionnairePushRequest + * @param userId + * @return + */ + public BaseResponse questionnairePush(QuestionnairePushRequest questionnairePushRequest, Integer userId) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + + // 新增追访信息 + + String phone = questionnairePushRequest.getPhone(); + String parentid = questionnairePushRequest.getParentid(); + String deliverId = questionnairePushRequest.getDeliverId(); + String pid = questionnairePushRequest.getPid(); + + if (StringUtils.isNotEmpty(phone) && StringUtils.isNotEmpty(parentid) + && StringUtils.isNotEmpty(deliverId) && StringUtils.isNotEmpty(pid)) { + MatDeliverFollowAddRequest param = new MatDeliverFollowAddRequest(); + // 联系结果、访视类型、备注 + param.setContactResult(1); + param.setMakeType(PostpartumFollowMakeEnums.TypeEnum.WJTS.getId()); + param.setMakeRemark(""); + param.setVisitDoctor(userId.toString()); + param.setMakeVisitDateStr(new Date()); + param.setDeliverId(deliverId); + param.setPid(pid); + BaseResponse baseResponse = addOrUpdateMatDeliverFollow(param, userId); + String followModelId = (String) baseResponse.getObject(); + + + // 推送到指定用户中 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(parentid)), Patients.class); + Organization organization = organizationService.getOrganization(Integer.parseInt(hospitalId)); + Users users = usersService.getUsers(userId); + MsgListRequest msgListRequest = new MsgListRequest(); + List msgRequests = new ArrayList<>(); + // 1 推送服务, 2 推送和短信服务 3短信服务 + MsgRequest request = new MsgRequest(); + request.setFirst(String.format("%s 女士您好!您身边的 %s,%s医生温馨提醒," + + "请及时填写产后健康情况记录表,便于医生掌握您产后情况更好的守护您的健康。", patients.getUsername(), organization.getName(), users.getName())); + // 产妇 + request.setObjType(ServiceObjEnums.CHANOBJ.getId()); + request.setPhone(phone); + request.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); + request.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); + request.setSubTypeId(SmsServiceEnums.FWKT.getId()); + request.setStatus(SmsStatusEnums.WFS.getId()); + request.setHospitalId(hospitalId); + request.setPatientId(parentid); + request.setSmsStatus(SmsStatusEnums.WFS.getId()); + request.setServiceType(1); + + request.setTypeId(0); + + request.setKeyword1(""); + request.setKeyword2(""); + + // 参数传递 医院id + 产后访视主键 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("hosptialId", hospitalId); + jsonObject.put("id", followModelId); + request.setRemark(jsonObject.toJSONString()); + request.setCreated(DateUtil.getyyyy_MM_dd_hms(new Date())); + + // todo 微信模板ID + request.setWxTempId(WxTempleteIdEnums.FU_WU_DING_GOU_TX.getId()); + + msgRequests.add(request); + msgListRequest.setMessages(msgRequests); + MessageCenterService.saveMsgCenter(msgListRequest); + } + + BaseResponse baseResponse = new BaseResponse(); + return baseResponse; + } + + /** + * 推送问卷 -- 保存产、妇在小程序端填写的数据 + * + * @param param + * @return + */ + public BaseResponse addQuestionnaire(QuestionnairePushRequest param) { + String id = param.getId(); + BaseResponse baseResponse = new BaseResponse(); + if (StringUtils.isNotEmpty(id)) { + Update update = new Update(); + param.setId(null); + Map map = BeanUtils.objectToObjectMap(param); + Set> entries = map.entrySet(); + for (Map.Entry entry : entries) { + update.set(entry.getKey(), entry.getValue()); + } + mongoTemplate.updateFirst(Query.query(Criteria.where("_id").is(id)), update, MatdeliverFollowModel.class); + return baseResponse; + } + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); + baseResponse.setErrormsg("参数缺失"); + return baseResponse; + } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/QuestionnairePushRequest.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/QuestionnairePushRequest.java new file mode 100644 index 0000000..1e5ea80 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/QuestionnairePushRequest.java @@ -0,0 +1,231 @@ +package com.lyms.platform.operate.web.request; + +import java.io.Serializable; +import java.util.Date; + +/** + * + * @Author dongqin + * @Description + * @Date 18:00 2019/8/13 + */ +public class QuestionnairePushRequest implements Serializable { + + private static final long serialVersionUID = 6439168172427430950L; + + private String parentid; + + private String deliverId; + + private String phone; + + private String pid; + + private String id; + + /** + * 分娩时间 + */ + private Date deliveryDate; + + /** + * 出院时间 + */ + private Date leaveDate; + + /** + * 体温 + */ + private String temperature; + + /** + * 健康状况 + */ + private String fitnessDesc; + + /** + * 心理状况 + */ + private String mentalityDesc; + + /** + * 血压 {\"szy\":13,\"ssy\":12} + */ + private String bp; + + /** + * 乳房 + */ + private String breast; + + /** + * 恶露 + */ + private String lochia; + + /** + * 子宫 + */ + private String matrix; + + /** + * 伤口 + */ + private String wound; + + /** + * 其他 + */ + private String otherDesc; + + /** + * 分类 + */ + private String healthType; + + private String hospitalId; + + public String getHospitalId() { + return hospitalId; + } + + public void setHospitalId(String hospitalId) { + this.hospitalId = hospitalId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getDeliveryDate() { + return deliveryDate; + } + + public void setDeliveryDate(Date deliveryDate) { + this.deliveryDate = deliveryDate; + } + + public Date getLeaveDate() { + return leaveDate; + } + + public void setLeaveDate(Date leaveDate) { + this.leaveDate = leaveDate; + } + + public String getTemperature() { + return temperature; + } + + public void setTemperature(String temperature) { + this.temperature = temperature; + } + + public String getFitnessDesc() { + return fitnessDesc; + } + + public void setFitnessDesc(String fitnessDesc) { + this.fitnessDesc = fitnessDesc; + } + + public String getMentalityDesc() { + return mentalityDesc; + } + + public void setMentalityDesc(String mentalityDesc) { + this.mentalityDesc = mentalityDesc; + } + + public String getBp() { + return bp; + } + + public void setBp(String bp) { + this.bp = bp; + } + + public String getBreast() { + return breast; + } + + public void setBreast(String breast) { + this.breast = breast; + } + + public String getLochia() { + return lochia; + } + + public void setLochia(String lochia) { + this.lochia = lochia; + } + + public String getMatrix() { + return matrix; + } + + public void setMatrix(String matrix) { + this.matrix = matrix; + } + + public String getWound() { + return wound; + } + + public void setWound(String wound) { + this.wound = wound; + } + + public String getOtherDesc() { + return otherDesc; + } + + public void setOtherDesc(String otherDesc) { + this.otherDesc = otherDesc; + } + + public String getHealthType() { + return healthType; + } + + public void setHealthType(String healthType) { + this.healthType = healthType; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getParentid() { + return parentid; + } + + public void setParentid(String parentid) { + this.parentid = parentid; + } + + public String getDeliverId() { + return deliverId; + } + + public void setDeliverId(String deliverId) { + this.deliverId = deliverId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } +} -- 1.8.3.1