1、添加家医发送微信订阅消息接口;

2、签约审核、解约审核、服务申请、筛查项目预约添加微信订阅消息提醒;
3、修改其他问题;
This commit is contained in:
mengkuiliang 2023-10-20 10:41:06 +08:00
parent 65b017c383
commit 3775e9ca7e
27 changed files with 830 additions and 90 deletions

View File

@ -79,10 +79,6 @@
<groupId>com.xinelu</groupId> <groupId>com.xinelu</groupId>
<artifactId>xinelu-nurse-applet</artifactId> <artifactId>xinelu-nurse-applet</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.xinelu</groupId>
<artifactId>xinelu-familydoctor</artifactId>
</dependency>
<!-- 家医相关模块 --> <!-- 家医相关模块 -->
<dependency> <dependency>

View File

@ -0,0 +1,80 @@
package com.xinelu.web.controller.applet;
import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R;
import com.xinelu.familydoctor.applet.pojo.body.MessagePushBody;
import com.xinelu.familydoctor.applet.pojo.dto.FDMessageDto;
import com.xinelu.familydoctor.applet.pojo.vo.SignInfoDataVo;
import com.xinelu.framework.config.AsyncExecutorConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
/**
* @Author mengkuiliang
* @Description 家医消息推送控制器
* @Date 2023-10-19 019 11:18
* @Param
* @return
**/
@Api(tags = "家医消息推送控制器")
@RestController
@RequestMapping("/applet/message")
public class FdMessageController extends BaseController {
@Resource
private MessagePushService messagePushService;
@Resource
private AsyncExecutorConfig asyncExecutorConfig;
@ApiOperation(value = "家医推送订阅消息", notes = "向接收方推送订阅消息")
@PostMapping("/push")
public R<String> pushMessage(@RequestBody FDMessageDto message) throws Exception {
if (StringUtils.isBlank(message.getRecipientIdentity())) {
return R.fail("接收方参数异常");
}
if (StringUtils.isBlank(message.getTemplateType())) {
return R.fail("消息模版参数异常");
}
messagePushService.FdPushMessage(JSONObject.parseObject(JSONObject.toJSONString(message)));
return R.ok();
}
@ApiOperation(value = "测试接口")
@GetMapping("/test/")
public R<SignInfoDataVo> test(MessagePushBody body, @RequestHeader("region") String region) {
// JSONObject jsonObject = null;
// try {
// String result = (String) httpService.get(SpringUtils.getFdUrl(region) + "/resident/signinfo/detail/2334", null, String.class);
// jsonObject = JSONObject.parseObject(result);
// if ("0".equals(jsonObject.get("code"))) {
// return R.fail(jsonObject.get("msg").toString());
// }
// if (!jsonObject.containsKey("data") || jsonObject.get("data") == null) {
// return R.ok();
// }
// return R.ok(JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), SignInfoDataVo.class));
// } catch (Exception e) {
// System.out.println("注册完善信息-更新签约标识出错:" + e.getMessage());
// }
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//设置子线程共享
RequestContextHolder.setRequestAttributes(servletRequestAttributes, true);
asyncExecutorConfig.asyncThreadServiceExecutor().execute(new Runnable() {
@Override
public void run() {
System.out.println("发送消息");
messagePushService.fdApprovePush(JSONObject.parseObject(JSONObject.toJSONString(body)));
}
});
System.out.println("执行成功");
return R.ok();
}
}

View File

@ -47,7 +47,7 @@ public class ResidentServiceApplyController extends BaseController {
@Resource @Resource
private IOrderEvaluateInfoService orderEvaluateInfoService; private IOrderEvaluateInfoService orderEvaluateInfoService;
@ApiOperation("提交服务预约") @ApiOperation("提交服务申请")
@PostMapping("/save") @PostMapping("/save")
public R<?> save(@RequestBody ResidentServiceApplyBody body) { public R<?> save(@RequestBody ResidentServiceApplyBody body) {
if (body == null || StringUtils.isBlank(body.getPackageNo()) || StringUtils.isBlank(body.getFormNo())) { if (body == null || StringUtils.isBlank(body.getPackageNo()) || StringUtils.isBlank(body.getFormNo())) {
@ -60,14 +60,14 @@ public class ResidentServiceApplyController extends BaseController {
return R.ok(); return R.ok();
} }
@ApiOperation("取消服务预约") @ApiOperation("取消服务申请")
@GetMapping("/cancel/{bookingNo}") @GetMapping("/cancel/{bookingNo}")
public R<?> cancel(@PathVariable String bookingNo) { public R<?> cancel(@PathVariable String bookingNo) {
residentServiceAppletService.cancel(bookingNo); residentServiceAppletService.cancel(bookingNo);
return R.ok(); return R.ok();
} }
@ApiOperation("服务预约列表") @ApiOperation("服务申请列表")
@PostMapping("/list") @PostMapping("/list")
public TableDataInfo performanceBookingList(@RequestBody ApplyQuery query) { public TableDataInfo performanceBookingList(@RequestBody ApplyQuery query) {
if (StringUtils.isBlank(query.getIdentity())) { if (StringUtils.isBlank(query.getIdentity())) {
@ -82,13 +82,13 @@ public class ResidentServiceApplyController extends BaseController {
} }
} }
@ApiOperation("服务预约详情") @ApiOperation("服务申请详情")
@GetMapping("/detail/{bookingNo}") @GetMapping("/detail/{bookingNo}")
public R<ResidentServiceApplyVo> performanceBookingDetail(@PathVariable String bookingNo) { public R<ResidentServiceApplyVo> performanceBookingDetail(@PathVariable String bookingNo) {
return R.ok(residentServiceAppletService.detail(bookingNo)); return R.ok(residentServiceAppletService.detail(bookingNo));
} }
@ApiOperation(value = "获取服务预约项目列表", notes = "获取家医个性服务包和筛查项目") @ApiOperation(value = "获取服务申请项目列表", notes = "获取家医个性服务包和筛查项目")
@GetMapping("/getForm/{identity}") @GetMapping("/getForm/{identity}")
public R<List<ScreeningProjectVo>> getForm(@PathVariable String identity, String projectName, @RequestHeader("region") String region) { public R<List<ScreeningProjectVo>> getForm(@PathVariable String identity, String projectName, @RequestHeader("region") String region) {
return R.ok(residentServiceAppletService.getForm(identity, projectName, region)); return R.ok(residentServiceAppletService.getForm(identity, projectName, region));

View File

@ -2,6 +2,7 @@ package com.xinelu.web.controller.applet;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R; import com.xinelu.common.core.domain.R;
import com.xinelu.common.core.page.TableDataInfo; import com.xinelu.common.core.page.TableDataInfo;
@ -13,6 +14,7 @@ import com.xinelu.familydoctor.applet.pojo.query.NearbyOrgQuery;
import com.xinelu.familydoctor.applet.pojo.query.PackageQuery; import com.xinelu.familydoctor.applet.pojo.query.PackageQuery;
import com.xinelu.familydoctor.applet.pojo.query.TeamListQuery; import com.xinelu.familydoctor.applet.pojo.query.TeamListQuery;
import com.xinelu.familydoctor.applet.pojo.vo.*; import com.xinelu.familydoctor.applet.pojo.vo.*;
import com.xinelu.framework.config.AsyncExecutorConfig;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -280,4 +282,5 @@ public class SignInfoController extends BaseController {
} }
return R.ok(JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), SignInfoDataVo.class)); return R.ok(JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), SignInfoDataVo.class));
} }
} }

View File

@ -163,7 +163,7 @@ token:
# 令牌有效期默认30分钟 # 令牌有效期默认30分钟
expireTime: 1440 expireTime: 1440
#请求拦截白名单 #请求拦截白名单
ant-matchers: /nurseApplet/**,/nurseApp/**,/applet/**,webSocket/** ant-matchers: /nurseApplet/**,/nurseApp/**,/applet/**,webSocket/**,/message/**
# MyBatis-Plus配置 # MyBatis-Plus配置
mybatis-plus: mybatis-plus:

View File

@ -65,19 +65,4 @@ public class AppletChatConfig {
*/ */
private String signTemplateId; private String signTemplateId;
/**
* 家庭医生消息通知默认模版
*/
private String fdMessageDefaultTempId;
/**
* 家庭医生预约成功通知模版
*/
private String fdMessageApplyTempId;
/**
* 家庭医生用药提醒通知模版
*/
private String fdMessageMedicineTempId;
} }

View File

@ -0,0 +1,79 @@
package com.xinelu.common.enums;
import lombok.Getter;
import java.util.*;
/**
* @Author mengkuiliang
* @Description 订阅消息枚举
* @Date 2023-01-11 17:32
* @Param
* @return
**/
@Getter
public enum MessageTemplateType {
JTYSXXTZ("1", "家庭医生消息通知", "8InV9jXDT5sMj9OWfXEvlLQGlw2UaWfZ9OBMFxufmfk", "默认通知模版"),
YYTX_1("9", "用药提醒", "2wn1BssReKjZasxKKZRWxBN0VqSmGmkuhc3AhTr18I0", "提醒居民用药"),
YYCGTZ("10", "预约成功", "MSSKCxOdtMUkY1ACu-u3itz8Vh_w5xDkO2llAOGwElU", "筛查项目预约成功");
/**
* 模版类型
*/
private final String type;
/**
* 标题
*/
private final String title;
/**
* 模版ID
*/
private final String templateId;
/**
* 说明
*/
private final String description;
MessageTemplateType(String type,String title, String templateId, String description) {
this.type = type;
this.title = title;
this.templateId = templateId;
this.description = description;
}
public static MessageTemplateType getFolllowupTypeByCode(String type) {
for (MessageTemplateType templateType : MessageTemplateType.values()) {
if (type.equals(templateType.getType())) {
return templateType;
}
}
return MessageTemplateType.JTYSXXTZ;
}
/**
* 获得所有枚举类型到list
*/
public static List<MessageTemplateType> getAllToList() {
List<MessageTemplateType> list = new ArrayList<>();
MessageTemplateType[] values = values();
Collections.addAll(list, values);
return list;
}
/**
* 获得所有枚举类型到map
*/
public static Map<String, MessageTemplateType> getAllToMap() {
Map<String, MessageTemplateType> map = new HashMap<>();
for (MessageTemplateType templateType : values()) {
map.put(templateType.getType(), templateType);
}
return map;
}
}

View File

@ -0,0 +1,45 @@
package com.xinelu.common.enums;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
/**
* @Author haown
* @Description 订阅消息跳转路径枚举类
* @Date 2023-05-11 17:32
* @return
**/
@Getter
public enum MessageTypePath {
//消息类型1健康推送2日常提醒, 3:风险评估完成, 4:推送筛查项目5:预约筛查成功, 6:筛查完成,
// 7:康复处方8随访提醒9纳入管理10申请转诊11转诊申请通过12申请会诊13会诊申请通过14处理异常"
JKTS("1", "pages/index/index"),
RCTX("2", "pages/dailyhealth/dailyhealth"),
FXPG("3", "pages/index/index"),
SCXM("4", "pagesB/screeningUserInfo/screeningUserInfo?assessRecordId="),
YYCG("5", "pages/index/index"),
SCWC("6", "pages/screeningResult/screeningResult?screeningId="),
KFCF("7", "pages/boughtRecoveryPrescription/boughtRecoveryPrescription?prescriptionRecordId="),
DEFAULT("0", "pages/index/index");
private final String messageType;
private final String path;
MessageTypePath(String messageType, String path) {
this.messageType = messageType;
this.path = path;
}
public static MessageTypePath getPathByType(String type) {
if(StringUtils.isBlank(type)) {
return MessageTypePath.DEFAULT;
}
for (MessageTypePath typePath : MessageTypePath.values()) {
if (type.equals(typePath.getMessageType())) {
return typePath;
}
}
return MessageTypePath.DEFAULT;
}
}

View File

@ -0,0 +1,72 @@
package com.xinelu.common.utils.map;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author mengkuiliang
* @Description Obj转Map
* @Date 2022-04-27 13:39
* @Param
* @return
**/
public class MapUtil {
/**
* Pojo -> Map<String, Object>
*
* @param obj
* @return
* @throws Exception
*/
public static Map<String, Object> object2Map(Object obj) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
return map;
}
/**
* List<T> --> List<Map<String, Object>>
*
* @param objectList
* @param <T>
* @return
* @throws Exception
*/
public static <T> List<Map<String, Object>> objectList2ListMap(List<T> objectList) throws Exception {
ArrayList<Map<String, Object>> resultList = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
for (T t : objectList) {
resultList.add(object2Map(t));
}
return resultList;
}
/**
* List<T> --> Map<String, List<Object>>
*
* @param objectList
* @param keyName
* @param <T>
* @return
* @throws Exception
*/
public static <T> Map<String, List<Object>> objectList2MapList(List<T> objectList, String[] keyName) throws Exception {
Map<String, List<Object>> resultMap = new HashMap<>();
for (int i = 0; i < keyName.length; i++) {
List<Object> arrayList = new ArrayList<>();
// List有序所以对每个对象依次变为map,然后得到对应的值存入arrayList
for (T t : objectList) {
arrayList.add(object2Map(t).get(keyName[i]));
}
resultMap.put(keyName[i], arrayList);//将keyName和对应List集合存入resultMap
}
return resultMap;
}
}

View File

@ -16,9 +16,9 @@ import lombok.Data;
public class MessagePushBody { public class MessagePushBody {
/** /**
* 业务类型1 预约申请通知 2 审批结果通知 3用药提醒通知 * 业务类型1 默认 9申请 10用药提醒通知
*/ */
@ApiModelProperty(value = "务类型1 预约申请通知 2 审批结果通知 3:用药提醒通知)") @ApiModelProperty(value = "务类型1 家医默认通知 10申请通知 9:用药提醒通知)")
private String busType; private String busType;
/** /**
@ -39,11 +39,40 @@ public class MessagePushBody {
@ApiModelProperty(value = "发送标题") @ApiModelProperty(value = "发送标题")
private String sendTitle; private String sendTitle;
/**
* 发送内容
*/
@ApiModelProperty(value = "发送内容")
private String sendContent;
/** /**
* 发送时间(yyyy-MM-dd HH:mm:ss) * 发送时间(yyyy-MM-dd HH:mm:ss)
*/ */
@ApiModelProperty(value = "发送时间(yyyy-MM-dd HH:mm:ss)") @ApiModelProperty(value = "发送时间(yyyy-MM-dd HH:mm:ss)")
private String sendTime; private String sendTime;
/**
* 接收人
*/
@ApiModelProperty(value = "接收人")
private String receiveName;
/**
* 发送内容1
*/
@ApiModelProperty(value = "发送内容1")
private String text1;
/**
* 发送内容2
*/
@ApiModelProperty(value = "发送内容2")
private String text2;
/**
* 发送内容3
*/
@ApiModelProperty(value = "发送内容3")
private String text3;
} }

View File

@ -0,0 +1,63 @@
package com.xinelu.familydoctor.applet.pojo.dto;
import com.xinelu.familydoctor.applet.pojo.dto.FDMessageExtentDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 发家医送订阅消息传输对象
* @Date 2023-10-19 019 10:14
* @Param
* @return
**/
@ApiModel("发家医送订阅消息传输对象")
@Data
public class FDMessageDto extends FDMessageExtentDto {
@ApiModelProperty("消息类别 1通知公告2健康推送3在线咨询")
private String messageCategory;
@ApiModelProperty("通知适用人群0全部人群")
private String crowds;
@ApiModelProperty(value = "发送人编号", required = true)
private String senderNo;
@ApiModelProperty("发送人身份证号")
private String senderIdentity;
@ApiModelProperty("发送人姓名")
private String senderName;
@ApiModelProperty(value = "发送时间yyyy-MM-dd HH:mm:ss", hidden = true)
private String sendTime;
@ApiModelProperty(value = "接收人编号")
private String recipientNo;
@ApiModelProperty("接收人身份证号")
private String recipientIdentity;
@ApiModelProperty("接收人姓名")
private String recipientName;
@ApiModelProperty("消息类型1健康推送2日常提醒, 3:风险评估完成, 4:推送筛查项目5:预约筛查成功, 6:筛查完成,7:康复处方8随访提醒9纳入管理10申请转诊11转诊申请通过12申请会诊13会诊申请通过14处理异常")
private String messageType;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("消息内容")
private String content;
@ApiModelProperty("消息内容Id用于点击跳转")
private String contentId;
@ApiModelProperty("消息来源")
private String source;
@ApiModelProperty(value = "模版类型MessageTemplateType枚举", required = true)
private String templateType;
}

View File

@ -0,0 +1,43 @@
package com.xinelu.familydoctor.applet.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 家医订阅消息请求参数扩展类
* @Date 2023-10-19 019 10:15
* @Param
* @return
**/
@Data
public class FDMessageExtentDto {
@ApiModelProperty("居民姓名")
private String residentName;
@ApiModelProperty("医院名称")
private String hospitalName;
@ApiModelProperty("医生名称")
private String doctorName;
@ApiModelProperty("团队名称")
private String teamName;
@ApiModelProperty("申请内容(比如:申请签约、申请随访、申请转诊等)")
private String applyContent;
@ApiModelProperty("申请结果(比如:成功、失败、处理中等)")
private String applyResult;
@ApiModelProperty("处理时间")
private String handleDate;
@ApiModelProperty("药品名称")
private String drugName;
@ApiModelProperty("药品用法")
private String drugUsage;
}

View File

@ -155,4 +155,39 @@ public class ResidentServiceApplyVo {
@ApiModelProperty("签约编号") @ApiModelProperty("签约编号")
private String signNo; private String signNo;
/**
* 预约机构编号
*/
@ApiModelProperty(value = "预约机构编号", required = true)
private String orgNo;
/**
* 预约机构名称
*/
@ApiModelProperty(value = "预约机构名称", required = true)
private String orgName;
/**
* 预约团队编号
*/
@ApiModelProperty(value = "预约团队编号", required = true)
private String teamNo;
/**
* 预约团队名称
*/
@ApiModelProperty(value = "预约团队名称", required = true)
private String teamName;
/**
* 预约医生编号
*/
@ApiModelProperty(value = "预约医生编号", required = true)
private String userNo;
/**
* 预约医生姓名
*/
@ApiModelProperty(value = "预约医生姓名", required = true)
private String userName;
} }

View File

@ -1,11 +1,14 @@
package com.xinelu.familydoctor.applet.service.impl; package com.xinelu.familydoctor.applet.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.exception.ServiceException; import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.DateUtils; import com.xinelu.common.utils.DateUtils;
import com.xinelu.common.utils.StringUtils; import com.xinelu.common.utils.StringUtils;
import com.xinelu.common.utils.uuid.IdUtils; import com.xinelu.common.utils.uuid.IdUtils;
import com.xinelu.familydoctor.applet.mapper.ResidentRescindApplyMapper; import com.xinelu.familydoctor.applet.mapper.ResidentRescindApplyMapper;
import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody; import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody;
import com.xinelu.familydoctor.applet.pojo.body.MessagePushBody;
import com.xinelu.familydoctor.applet.pojo.body.ResidentRescindApplyBody; import com.xinelu.familydoctor.applet.pojo.body.ResidentRescindApplyBody;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo; import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
import com.xinelu.familydoctor.applet.pojo.entity.ResidentRescindApplyEntity; import com.xinelu.familydoctor.applet.pojo.entity.ResidentRescindApplyEntity;
@ -34,6 +37,8 @@ public class ResidentRescindApplyServiceImpl implements IResidentRescindApplySer
private ResidentRescindApplyMapper residentRescindApplyMapper; private ResidentRescindApplyMapper residentRescindApplyMapper;
@Resource @Resource
private IResidentPatientInfoService patientInfoService; private IResidentPatientInfoService patientInfoService;
@Resource
private MessagePushService messagePushService;
@Override @Override
public List<ResidentRescindApplyVo> findList(ApplyQuery query) { public List<ResidentRescindApplyVo> findList(ApplyQuery query) {
@ -61,11 +66,11 @@ public class ResidentRescindApplyServiceImpl implements IResidentRescindApplySer
ResidentRescindApplyEntity entity = new ResidentRescindApplyEntity(); ResidentRescindApplyEntity entity = new ResidentRescindApplyEntity();
BeanUtils.copyProperties(body, entity); BeanUtils.copyProperties(body, entity);
PatientInfo patientInfo = patientInfoService.getByCardNo(body.getIdentity());
if (patientInfo == null) {
throw new ServiceException("未查询到注册信息");
}
if(StringUtils.isBlank(body.getPatientId())) { if(StringUtils.isBlank(body.getPatientId())) {
PatientInfo patientInfo = patientInfoService.getByCardNo(body.getIdentity());
if (patientInfo == null) {
throw new ServiceException("未查询到注册信息");
}
entity.setPatientId(patientInfo.getPatientCode()); entity.setPatientId(patientInfo.getPatientCode());
} }
@ -74,6 +79,16 @@ public class ResidentRescindApplyServiceImpl implements IResidentRescindApplySer
entity.setBookingStatus("0"); entity.setBookingStatus("0");
entity.setApprovalStatus("0"); entity.setApprovalStatus("0");
residentRescindApplyMapper.insert(entity); residentRescindApplyMapper.insert(entity);
MessagePushBody messagePushBody = new MessagePushBody();
messagePushBody.setBusType("10");
messagePushBody.setOpenid(patientInfo.getOpenid());
messagePushBody.setReceiveName(patientInfo.getPatientName());
messagePushBody.setText1(body.getOrgName());
messagePushBody.setText2("解约申请");
messagePushBody.setSendTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
messagePushBody.setSendContent(patientInfo.getPatientName() + "已提交申请");
messagePushService.fdApprovePush(JSONObject.parseObject(JSONObject.toJSONString(messagePushBody)));
} }
/** /**

View File

@ -2,6 +2,7 @@ package com.xinelu.familydoctor.applet.service.impl;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.core.domain.R; import com.xinelu.common.core.domain.R;
import com.xinelu.common.exception.ServiceException; import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.DateUtils; import com.xinelu.common.utils.DateUtils;
@ -11,6 +12,7 @@ import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.common.utils.uuid.IdUtils; import com.xinelu.common.utils.uuid.IdUtils;
import com.xinelu.familydoctor.applet.mapper.ResidentServiceApplyMapper; import com.xinelu.familydoctor.applet.mapper.ResidentServiceApplyMapper;
import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody; import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody;
import com.xinelu.familydoctor.applet.pojo.body.MessagePushBody;
import com.xinelu.familydoctor.applet.pojo.body.ResidentServiceApplyBody; import com.xinelu.familydoctor.applet.pojo.body.ResidentServiceApplyBody;
import com.xinelu.familydoctor.applet.pojo.dto.ResidentServiceFormApplyDto; import com.xinelu.familydoctor.applet.pojo.dto.ResidentServiceFormApplyDto;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo; import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
@ -49,6 +51,8 @@ public class ResidentServiceApplyServiceImpl implements IResidentServiceAppletSe
private IHospitalInfoService hospitalInfoService; private IHospitalInfoService hospitalInfoService;
@Resource @Resource
private IScreeningProjectService screeningProjectService; private IScreeningProjectService screeningProjectService;
@Resource
private MessagePushService messagePushService;
/** /**
* 新增服务申请 * 新增服务申请
@ -64,22 +68,20 @@ public class ResidentServiceApplyServiceImpl implements IResidentServiceAppletSe
applyQuery.setIdentity(body.getIdentity()); applyQuery.setIdentity(body.getIdentity());
applyQuery.setBookingStatus("0"); applyQuery.setBookingStatus("0");
applyQuery.setApprovalStatus("0"); applyQuery.setApprovalStatus("0");
applyQuery.setFormNo(body.getFormNo());
List<ResidentServiceApplyVo> serviceBookingInfoVoList = residentServiceApplyMapper.findByBody(applyQuery); List<ResidentServiceApplyVo> serviceBookingInfoVoList = residentServiceApplyMapper.findByBody(applyQuery);
if (serviceBookingInfoVoList != null && serviceBookingInfoVoList.size() > 0) { if (serviceBookingInfoVoList != null && serviceBookingInfoVoList.size() > 0) {
throw new ServiceException("提交服务申请,不能重复提交"); throw new ServiceException("提交服务申请,不能重复提交");
} }
ResidentServiceApplyEntity entity; ResidentServiceApplyEntity entity;
PatientInfo patientInfo = null; PatientInfo patientInfo = patientInfoService.getByCardNo(body.getIdentity());
if (StringUtils.isBlank(body.getPatientId())) { if (patientInfo == null) {
patientInfo = patientInfoService.getByCardNo(body.getIdentity()); throw new ServiceException("未查询到注册信息");
if (patientInfo == null) {
throw new ServiceException("未查询到注册信息");
}
} }
entity = new ResidentServiceApplyEntity(); entity = new ResidentServiceApplyEntity();
BeanUtils.copyProperties(body, entity); BeanUtils.copyProperties(body, entity);
if (patientInfo != null) { if (StringUtils.isBlank(entity.getPatientId())) {
entity.setPatientId(patientInfo.getPatientCode()); entity.setPatientId(patientInfo.getPatientCode());
} }
entity.setApplyTime(new Date()); entity.setApplyTime(new Date());
@ -92,6 +94,16 @@ public class ResidentServiceApplyServiceImpl implements IResidentServiceAppletSe
entity.setServiceWay("2"); entity.setServiceWay("2");
} }
residentServiceApplyMapper.insert(entity); residentServiceApplyMapper.insert(entity);
MessagePushBody messagePushBody = new MessagePushBody();
messagePushBody.setBusType("10");
messagePushBody.setOpenid(patientInfo.getOpenid());
messagePushBody.setReceiveName(patientInfo.getPatientName());
messagePushBody.setText1(body.getOrgName());
messagePushBody.setText2(body.getFormName().length() >= 20? body.getFormName().substring(0,17) + "...": body.getFormName());
messagePushBody.setSendTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
messagePushBody.setSendContent(patientInfo.getPatientName() + "已提交服务申请");
messagePushService.fdApprovePush(JSONObject.parseObject(JSONObject.toJSONString(messagePushBody)));
} }
/** /**
@ -286,6 +298,10 @@ public class ResidentServiceApplyServiceImpl implements IResidentServiceAppletSe
sp.setDiscountPrice(per.getPackSignCost()); sp.setDiscountPrice(per.getPackSignCost());
sp.setServiceFreq(per.getServiceFreq()); sp.setServiceFreq(per.getServiceFreq());
sp.setPerformanceCount(per.getPerformanceCount()); sp.setPerformanceCount(per.getPerformanceCount());
sp.setTeamNo(per.getTeamNo());
sp.setTeamName(per.getTeamName());
sp.setUserNo(per.getUserNo());
sp.setUserName(per.getUserName());
projectList.add(sp); projectList.add(sp);
} }
} }

View File

@ -1,6 +1,7 @@
package com.xinelu.familydoctor.applet.service.impl; package com.xinelu.familydoctor.applet.service.impl;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.exception.ServiceException; import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.DateUtils; import com.xinelu.common.utils.DateUtils;
import com.xinelu.common.utils.StringUtils; import com.xinelu.common.utils.StringUtils;
@ -9,6 +10,7 @@ import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.common.utils.uuid.IdUtils; import com.xinelu.common.utils.uuid.IdUtils;
import com.xinelu.familydoctor.applet.mapper.ResidentSignApplyMapper; import com.xinelu.familydoctor.applet.mapper.ResidentSignApplyMapper;
import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody; import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody;
import com.xinelu.familydoctor.applet.pojo.body.MessagePushBody;
import com.xinelu.familydoctor.applet.pojo.body.ResidentSignApplyBody; import com.xinelu.familydoctor.applet.pojo.body.ResidentSignApplyBody;
import com.xinelu.familydoctor.applet.pojo.dto.CrowdDto; import com.xinelu.familydoctor.applet.pojo.dto.CrowdDto;
import com.xinelu.familydoctor.applet.pojo.dto.PackageDto; import com.xinelu.familydoctor.applet.pojo.dto.PackageDto;
@ -45,6 +47,8 @@ public class ResidentSignApplyServiceImpl implements IResidentSignAppletService
private HttpService httpService; private HttpService httpService;
@Resource @Resource
private IResidentPatientInfoService patientInfoService; private IResidentPatientInfoService patientInfoService;
@Resource
private MessagePushService messagePushService;
/** /**
* 新增签约申请 * 新增签约申请
@ -67,11 +71,11 @@ public class ResidentSignApplyServiceImpl implements IResidentSignAppletService
ResidentSignApplyEntity entity = new ResidentSignApplyEntity(); ResidentSignApplyEntity entity = new ResidentSignApplyEntity();
BeanUtils.copyProperties(body, entity); BeanUtils.copyProperties(body, entity);
PatientInfo patientInfo = patientInfoService.getByCardNo(body.getIdentity());
if (patientInfo == null) {
throw new ServiceException("未查询到注册信息");
}
if(StringUtils.isBlank(body.getPatientId())) { if(StringUtils.isBlank(body.getPatientId())) {
PatientInfo patientInfo = patientInfoService.getByCardNo(body.getIdentity());
if (patientInfo == null) {
throw new ServiceException("未查询到注册信息");
}
entity.setPatientId(patientInfo.getPatientCode()); entity.setPatientId(patientInfo.getPatientCode());
} }
@ -92,6 +96,16 @@ public class ResidentSignApplyServiceImpl implements IResidentSignAppletService
entity.setPackagesNo(body.getPackageList().stream().map(PackageDto::getPackageNo).collect(Collectors.joining(","))); entity.setPackagesNo(body.getPackageList().stream().map(PackageDto::getPackageNo).collect(Collectors.joining(",")));
entity.setPackagesName(body.getPackageList().stream().map(PackageDto::getPackageName).collect(Collectors.joining(","))); entity.setPackagesName(body.getPackageList().stream().map(PackageDto::getPackageName).collect(Collectors.joining(",")));
residentSignApplyMapper.insert(entity); residentSignApplyMapper.insert(entity);
MessagePushBody messagePushBody = new MessagePushBody();
messagePushBody.setBusType("10");
messagePushBody.setOpenid(patientInfo.getOpenid());
messagePushBody.setReceiveName(body.getResidentName());
messagePushBody.setText1(body.getOrgName());
messagePushBody.setText2("签约申请");
messagePushBody.setSendTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
messagePushBody.setSendContent(body.getResidentName() + "已提交申请");
messagePushService.fdApprovePush(JSONObject.parseObject(JSONObject.toJSONString(messagePushBody)));
} }
/** /**

View File

@ -34,7 +34,7 @@
approval_status,refuse_reason,approval_time approval_status,refuse_reason,approval_time
</sql> </sql>
<sql id="Base_Column_List_fd"> <sql id="Base_Column_List_fd">
p.id,p.apply_no,p.patient_id,sign_no,p.identity, p.id,p.apply_no,p.patient_id,p.sign_no,p.identity,
p.org_no,p.org_name,p.team_no, p.org_no,p.org_name,p.team_no,
p.team_name,p.user_no,p.user_name, p.team_name,p.user_no,p.user_name,
p.apply_time,booking_status,cancel_time,p.rescind_type,p.rescind_reason, p.apply_time,booking_status,cancel_time,p.rescind_type,p.rescind_reason,

View File

@ -176,6 +176,8 @@
</if> </if>
<if test="remark != null">remark, <if test="remark != null">remark,
</if> </if>
<if test="serviceWay != null">service_way,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bookingNo != null and bookingNo != ''">#{bookingNo}, <if test="bookingNo != null and bookingNo != ''">#{bookingNo},
@ -186,9 +188,9 @@
</if> </if>
<if test="identity != null and identity != ''">#{identity}, <if test="identity != null and identity != ''">#{identity},
</if> </if>
<if test="packagesNo != null">#{packagesNo}, <if test="packageNo != null">#{packageNo},
</if> </if>
<if test="packagesName != null">#{packagesName}, <if test="packageName != null">#{packageName},
</if> </if>
<if test="formNo != null">#{formNo}, <if test="formNo != null">#{formNo},
</if> </if>
@ -222,6 +224,8 @@
</if> </if>
<if test="remark != null">#{remark}, <if test="remark != null">#{remark},
</if> </if>
<if test="serviceWay != null">#{serviceWay},
</if>
</trim> </trim>
</insert> </insert>
@ -252,7 +256,7 @@
<select id="findByBody" resultType="com.xinelu.familydoctor.applet.pojo.vo.ResidentServiceApplyVo"> <select id="findByBody" resultType="com.xinelu.familydoctor.applet.pojo.vo.ResidentServiceApplyVo">
select <include refid="Base_Column_Service_Apply"></include>,p.address,p.phone select <include refid="Base_Column_Service_Apply"></include>,p.address,p.phone
from resident_service_apply s from resident_service_apply s
left join patient_info p on p.patient_code = s.patient_id left join patient_info p on p.card_no = s.identity
where 1=1 where 1=1
<if test="identity != null and identity != ''"> <if test="identity != null and identity != ''">
and s.identity = #{identity} and s.identity = #{identity}
@ -269,6 +273,9 @@
<if test="userNo != null and userNo != ''"> <if test="userNo != null and userNo != ''">
and s.user_no = #{userNo} and s.user_no = #{userNo}
</if> </if>
<if test="formNo != null and formNo != ''">
and s.form_no = #{formNo}
</if>
<if test="startDate != null"> <if test="startDate != null">
and s.booking_time >= #{startDate} and s.booking_time >= #{startDate}
</if> </if>

View File

@ -1,6 +1,7 @@
package com.xinelu.applet.controller.appletscreeningrecord; package com.xinelu.applet.controller.appletscreeningrecord;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.annotation.RepeatSubmit; import com.xinelu.common.annotation.RepeatSubmit;
import com.xinelu.common.config.XinELuConfig; import com.xinelu.common.config.XinELuConfig;
import com.xinelu.common.constant.ScreeningProjectConstants; import com.xinelu.common.constant.ScreeningProjectConstants;
@ -19,6 +20,7 @@ import com.xinelu.manage.vo.screeningrecord.ScreeningRecordVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.io.File; import java.io.File;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -45,6 +47,9 @@ public class AppletScreeningRecordController extends BaseController {
@Resource @Resource
private IScreeningRecordService screeningRecordService; private IScreeningRecordService screeningRecordService;
@Resource
private MessagePushService messagePushService;
@GetMapping("/record") @GetMapping("/record")
@ApiOperation(value = "获取筛查结果记录") @ApiOperation(value = "获取筛查结果记录")
public TableDataInfo record(ScreeningRecordDTO query) { public TableDataInfo record(ScreeningRecordDTO query) {
@ -83,7 +88,11 @@ public class AppletScreeningRecordController extends BaseController {
if(!DateUtils.formatDate(body.getApplyStartTime(), "yyyy-MM-dd").equals(DateUtils.formatDate(body.getApplyEndTime(), "yyyy-MM-dd"))) { if(!DateUtils.formatDate(body.getApplyStartTime(), "yyyy-MM-dd").equals(DateUtils.formatDate(body.getApplyEndTime(), "yyyy-MM-dd"))) {
return R.fail("预约日期请选择在同一天"); return R.fail("预约日期请选择在同一天");
} }
return R.ok(screeningRecordService.save(body)); JSONObject result = screeningRecordService.save(body);
if(result != null && result.containsKey("openid")) {
messagePushService.fdApprovePush(result);
}
return R.ok(result.getString("patientId"));
} catch (Exception e) { } catch (Exception e) {
return R.fail(e.getMessage()); return R.fail(e.getMessage());
} }

View File

@ -0,0 +1,43 @@
package com.xinelu.applet.dto.messagepush;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 家医订阅消息请求参数扩展类
* @Date 2023-10-19 019 10:15
* @Param
* @return
**/
@Data
public class FDMessageExtentDto {
@ApiModelProperty("居民姓名")
private String residentName;
@ApiModelProperty("医院名称")
private String hospitalName;
@ApiModelProperty("医生名称")
private String doctorName;
@ApiModelProperty("团队名称")
private String teamName;
@ApiModelProperty("申请内容(比如:申请签约、申请随访、申请转诊等)")
private String applyContent;
@ApiModelProperty("申请结果(比如:成功、失败、处理中等)")
private String applyResult;
@ApiModelProperty("处理时间")
private String handleDate;
@ApiModelProperty("药品名称")
private String drugName;
@ApiModelProperty("药品用法")
private String drugUsage;
}

View File

@ -0,0 +1,66 @@
package com.xinelu.applet.dto.messagepush;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 消息推送请求对象
* @Date 2023-10-18 018 14:26
* @Param
* @return
**/
@Data
@ApiModel(value = "消息推送请求对象")
public class FDMessagePushDto extends FDMessageExtentDto{
@ApiModelProperty("业务主键")
private String messageNo;
@ApiModelProperty(value = "消息类别 1通知公告2健康推送3在线咨询", required = true)
private String messageCategory;
@ApiModelProperty("通知适用人群0全部人群")
private String crowds;
@ApiModelProperty("通知适用人群名称")
private String crowdsName;
@ApiModelProperty("发送人编号")
private String senderNo;
@ApiModelProperty("发送人姓名")
private String senderName;
@ApiModelProperty("发送时间")
private String sendTime;
@ApiModelProperty("接收人身份证号")
private String recipientIdentity;
@ApiModelProperty("接收人编号")
private String recipientNo;
@ApiModelProperty("接收人姓名")
private String recipientName;
@ApiModelProperty("消息类型1健康推送2日常提醒, 3:风险评估完成, 4:推送筛查项目5:预约筛查成功, 6:筛查完成,7:康复处方8随访提醒9纳入管理10申请转诊11转诊申请通过12申请会诊13会诊申请通过14处理异常")
private String messageType;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("消息内容")
private String content;
@ApiModelProperty("消息内容Id用于点击跳转")
private String contentId;
@ApiModelProperty("已读状态0未读1已读")
private String readStatus;
@ApiModelProperty(value = "模版类型MessageTemplateType枚举", required = true)
private String templateType;
}

View File

@ -0,0 +1,35 @@
package com.xinelu.applet.dto.messagepush;
import lombok.Data;
import java.util.Map;
/**
* @Author mengkuiliang
* @Description 小程序推送所需数据
* @Date 2023-10-19 019 10:36
* @Param
* @return
**/
@Data
public class FDWxMegDto {
/**
* 用户openid
* */
private String touser;
/**
* 订阅消息模版id
* */
private String template_id;
/**
* 默认跳到小程序首页
* */
private String page = "pages/index/index";
/**
* 推送文字
* */
private Map<String, TemplateData> data;
}

View File

@ -0,0 +1,17 @@
package com.xinelu.applet.dto.messagepush;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 消息的内容
* @Date 2023-10-19 019 10:36
* @Param
* @return
**/
@Data
@AllArgsConstructor
public class TemplateData {
private String value;
}

View File

@ -2,23 +2,26 @@ package com.xinelu.applet.service.messagepush.Impl;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.dto.messagepush.FDMessagePushDto;
import com.xinelu.applet.dto.messagepush.FDWxMegDto;
import com.xinelu.applet.dto.messagepush.TemplateData;
import com.xinelu.applet.service.messagepush.MessagePushService; import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.common.config.AppletChatConfig; import com.xinelu.common.config.AppletChatConfig;
import com.xinelu.common.config.AppletPageConfig; import com.xinelu.common.config.AppletPageConfig;
import com.xinelu.common.constant.Constants; import com.xinelu.common.constant.Constants;
import com.xinelu.common.entity.AppletAccessToken; import com.xinelu.common.entity.AppletAccessToken;
import com.xinelu.common.entity.MessageValueEntity; import com.xinelu.common.entity.MessageValueEntity;
import com.xinelu.common.enums.AppletSubscriptionMessageEnum; import com.xinelu.common.enums.*;
import com.xinelu.common.enums.CouponTypeEnum;
import com.xinelu.common.enums.SettingsTypeEnum;
import com.xinelu.common.enums.SubscribeStatusEnum;
import com.xinelu.common.utils.AppletChatUtil; import com.xinelu.common.utils.AppletChatUtil;
import com.xinelu.common.utils.http.HttpUtils; import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.common.utils.map.MapUtil;
import com.xinelu.manage.domain.subscribemessagerecord.SubscribeMessageRecord; import com.xinelu.manage.domain.subscribemessagerecord.SubscribeMessageRecord;
import com.xinelu.manage.domain.systemsettingsinfo.SystemSettingsInfo; import com.xinelu.manage.domain.systemsettingsinfo.SystemSettingsInfo;
import com.xinelu.manage.mapper.subscribemessagerecord.SubscribeMessageRecordMapper; import com.xinelu.manage.mapper.subscribemessagerecord.SubscribeMessageRecordMapper;
import com.xinelu.manage.mapper.systemsettingsinfo.SystemSettingsInfoMapper; import com.xinelu.manage.mapper.systemsettingsinfo.SystemSettingsInfoMapper;
import com.xinelu.manage.service.patientinfo.IPatientInfoService;
import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO; import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO;
import com.xinelu.manage.vo.patientinfo.PatientInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@ -28,10 +31,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/** /**
* @Description 消息推送实现层 * @Description 消息推送实现层
@ -50,6 +50,8 @@ public class MessagePushServiceImpl implements MessagePushService {
private SystemSettingsInfoMapper systemSettingsInfoMapper; private SystemSettingsInfoMapper systemSettingsInfoMapper;
@Resource @Resource
private AppletPageConfig appletPageConfig; private AppletPageConfig appletPageConfig;
@Resource
private IPatientInfoService patientInfoService;
/** /**
* 微信消息推送url * 微信消息推送url
@ -209,7 +211,7 @@ public class MessagePushServiceImpl implements MessagePushService {
log.error("不合法的 template_id"); log.error("不合法的 template_id");
break; break;
case Constants.ARGUMENT_INVALID: case Constants.ARGUMENT_INVALID:
log.error("参数无效!"); log.error("参数无效!{}", result);
break; break;
case Constants.DENY_SUBSCRIPTION: case Constants.DENY_SUBSCRIPTION:
log.error("用户拒接订阅!"); log.error("用户拒接订阅!");
@ -223,11 +225,12 @@ public class MessagePushServiceImpl implements MessagePushService {
/** /**
* @return void * @return void
* @Author mengkuiliang * @Author mengkuiliang
* @Description 家医申请审批结果消息推送 * @Description 家医申请审批结果订阅消息推送
* @Date 2023-10-18 018 14:03 * @Date 2023-10-18 018 14:03
* @Param [appletAccessToken, paramsMap, busType] * @Param [appletAccessToken, paramsMap, busType]
**/ **/
@Override @Override
@Async("asyncThreadServiceExecutor")
public void fdApprovePush(JSONObject body) { public void fdApprovePush(JSONObject body) {
AppletAccessToken appletAccessToken = AppletChatUtil.getAppletAccessToken(appletChatConfig.getAppletId(), appletChatConfig.getSecret()); AppletAccessToken appletAccessToken = AppletChatUtil.getAppletAccessToken(appletChatConfig.getAppletId(), appletChatConfig.getSecret());
if (Objects.isNull(appletAccessToken)) { if (Objects.isNull(appletAccessToken)) {
@ -240,29 +243,106 @@ public class MessagePushServiceImpl implements MessagePushService {
log.error("accessToken信息为空"); log.error("accessToken信息为空");
} }
String tempId = ""; //模板内容
switch (body.getString("1")) { Map<String, MessageValueEntity> messageValueEntityMap = new LinkedHashMap<>();
switch (body.getString("busType")) {
// 申请 // 申请
case "2": case "10":
tempId = appletChatConfig.getFdMessageApplyTempId(); messageValueEntityMap.put("name2", new MessageValueEntity(body.getString("receiveName")));
// 用药 messageValueEntityMap.put("thing6", new MessageValueEntity(body.getString("text1")));
case "3": messageValueEntityMap.put("thing5", new MessageValueEntity(body.getString("text2")));
tempId = appletChatConfig.getFdMessageMedicineTempId(); messageValueEntityMap.put("thing8", new MessageValueEntity(body.getString("sendTime")));
// 默认 messageValueEntityMap.put("thing9", new MessageValueEntity(body.getString("sendContent")));
break;
// 用药
case "9":
messageValueEntityMap.put("thing1", new MessageValueEntity(body.getString("text1")));
messageValueEntityMap.put("thing2", new MessageValueEntity(body.getString("text2")));
messageValueEntityMap.put("time3", new MessageValueEntity(body.getString("sendTime")));
messageValueEntityMap.put("thing4", new MessageValueEntity(body.getString("sendContent")));
break;
// 默认
default: default:
tempId = appletChatConfig.getFdMessageDefaultTempId(); messageValueEntityMap.put("thing1", new MessageValueEntity(body.getString("senderName")));
messageValueEntityMap.put("time2", new MessageValueEntity(body.getString("sendTime")));
messageValueEntityMap.put("thing3", new MessageValueEntity(body.getString("sendContent")));
break;
} }
Map<String, Object> paramsMap = new HashMap<>(); Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("touser", body.getString("openid")); paramsMap.put("touser", body.getString("openid"));
paramsMap.put("template_id", tempId); paramsMap.put("template_id", MessageTemplateType.getFolllowupTypeByCode(body.getString("busType")).getTemplateId());
paramsMap.put("page", appletPageConfig.getIntegralPageUrl()); paramsMap.put("page", appletPageConfig.getIntegralPageUrl());
//模板内容 paramsMap.put("data", messageValueEntityMap);
Map<String, MessageValueEntity> messageValueEntityMap = new LinkedHashMap<>();
messageValueEntityMap.put("thing1", new MessageValueEntity(body.getString("senderName")));
messageValueEntityMap.put("time2", new MessageValueEntity(body.getString("sendTime")));
messageValueEntityMap.put("thing3", new MessageValueEntity(body.getString("sendTitle")));
//发送 //发送
this.sendPosts(appletAccessToken, paramsMap); this.sendPosts(appletAccessToken, paramsMap);
} }
/**
* @return void
* @Author mengkuiliang
* @Description 家医推送订阅消息
* @Date 2023-10-19 019 10:20
* @Param [body]
**/
@Override
@Async("asyncThreadServiceExecutor")
public void FdPushMessage(JSONObject req) throws Exception {
log.info("订阅消息-请求参数:{}", JSON.toJSONString(req));
FDMessagePushDto body = JSONObject.parseObject(req.toJSONString()).toJavaObject(FDMessagePushDto.class);
if (!StringUtils.isBlank(body.getRecipientIdentity())) {
PatientInfoVO patientInfo = patientInfoService.selectPatientInfoByCardNo(body.getRecipientIdentity());
if (patientInfo == null) {
log.error("接收方未注册 {}", body.getRecipientIdentity());
}
AppletAccessToken appletAccessToken = AppletChatUtil.getAppletAccessToken(appletChatConfig.getAppletId(), appletChatConfig.getSecret());
if (Objects.isNull(appletAccessToken)) {
log.error("获取微信小程序accessToken信息失败");
}
if (Objects.nonNull(appletAccessToken.getErrcode()) && appletAccessToken.getErrcode() != AppletSubscriptionMessageEnum.SUCCESS_ERRCODE.getValue()) {
log.error("获取微信小程序accessToken信息失败失败信息为" + appletAccessToken.getErrmsg(), 201);
}
if (StringUtils.isBlank(appletAccessToken.getAccessToken())) {
log.error("accessToken信息为空");
}
//发送
this.sendPosts(appletAccessToken, MapUtil.object2Map(getTemplate(body, patientInfo.getOpenid())));
}
}
/**
* 配置消息模版请求参数
*/
private FDWxMegDto getTemplate(FDMessagePushDto message, String openid) {
FDWxMegDto wxMegDto = new FDWxMegDto();
wxMegDto.setTouser(openid);
wxMegDto.setTemplate_id(MessageTemplateType.getFolllowupTypeByCode(message.getTemplateType()).getTemplateId());
Map<String, TemplateData> meg = new HashMap<>();
switch (message.getTemplateType()) {
// 用药提醒
case "9":
meg.put("thing1", new TemplateData(message.getDrugName()));
meg.put("thing2", new TemplateData(message.getDrugUsage()));
meg.put("time3", new TemplateData(message.getHandleDate()));
meg.put("thing4", new TemplateData((!StringUtils.isBlank(message.getRecipientName())? message.getRecipientName(): "") + message.getContent()));
break;
// 筛查预约成功
case "10":
meg.put("name2", new TemplateData(message.getRecipientName()));
meg.put("thing5", new TemplateData(message.getApplyContent()));
meg.put("thing6", new TemplateData(message.getHospitalName()));
meg.put("thing8", new TemplateData(message.getHandleDate()));
meg.put("thing9", new TemplateData(message.getContent()));
break;
// 家庭医生消息通知
default:
meg.put("thing1", new TemplateData(message.getDoctorName()));
meg.put("time2", new TemplateData(message.getSendTime()));
meg.put("thing3", new TemplateData(message.getContent()));
break;
}
wxMegDto.setPage(MessageTypePath.getPathByType(message.getMessageType()).getPath() + (StringUtils.isBlank(message.getContentId()) ? "" : message.getContentId()));
wxMegDto.setData(meg);
return wxMegDto;
}
} }

View File

@ -2,6 +2,7 @@ package com.xinelu.applet.service.messagepush;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.dto.messagepush.FDMessagePushDto;
import com.xinelu.common.entity.AppletAccessToken; import com.xinelu.common.entity.AppletAccessToken;
import com.xinelu.manage.domain.subscribemessagerecord.SubscribeMessageRecord; import com.xinelu.manage.domain.subscribemessagerecord.SubscribeMessageRecord;
import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO; import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO;
@ -48,4 +49,13 @@ public interface MessagePushService {
* @return void * @return void
**/ **/
void fdApprovePush(JSONObject body); void fdApprovePush(JSONObject body);
/**
* @Author mengkuiliang
* @Description 家医推送订阅消息
* @Date 2023-10-19 019 10:20
* @Param [message]
* @return void
**/
void FdPushMessage(JSONObject req) throws Exception;
} }

View File

@ -43,7 +43,7 @@ public interface IScreeningRecordService {
* @Param [body] * @Param [body]
* @return void * @return void
**/ **/
String save(ScreeningApplyDTO body) throws Exception; JSONObject save(ScreeningApplyDTO body) throws Exception;
/** /**
* 修改 * 修改

View File

@ -97,7 +97,7 @@ public class ScreeningRecordServiceImpl implements IScreeningRecordService {
**/ **/
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String save(ScreeningApplyDTO body) throws Exception { public JSONObject save(ScreeningApplyDTO body) throws Exception {
// 校验是否已经注册 // 校验是否已经注册
PatientInfoVO registerVo = patientService.selectPatientInfoByCardNo(body.getIdentity()); PatientInfoVO registerVo = patientService.selectPatientInfoByCardNo(body.getIdentity());
if(registerVo == null) { if(registerVo == null) {
@ -130,24 +130,22 @@ public class ScreeningRecordServiceImpl implements IScreeningRecordService {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
JSONObject result = new JSONObject();
result.put("patientId", body.getPatientId());
int flag = screeningRecordMapper.insert(recordBody); int flag = screeningRecordMapper.insert(recordBody);
if(flag > 0) { if(flag > 0) {
// 推送消息 // 组装发送消息通知参数
//JSONObject jsonObject = new JSONObject(); result.put("busType", "10");
//jsonObject.fluentPut("recipientName", registerVo.getPatientName()) result.put("openid", registerVo.getOpenid());
// .fluentPut("handleDate", recordBody.getApplyStartTime()) result.put("receiveName", registerVo.getPatientName());
// .fluentPut("hospitalName", recordBody.getDeptName()) result.put("text1", body.getHospitalName());
// .fluentPut("applyContent", recordBody.getProjectName()) result.put("text2", (body.getProjectName().length() >= 17? (body.getProjectName().substring(0, 17) + "..."): body.getProjectName()));
// .fluentPut("recipientIdentity", registerVo.getIdentity()) result.put("sendTime", DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
// .fluentPut("sendTime", DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss")) result.put("busType", "10");
// .fluentPut("messageType", "5") result.put("sendContent", registerVo.getPatientName() + "预约筛查成功");
// .fluentPut("messageCategory", "1") result.put("messageType", "5");
// .fluentPut("templateType", MessageTypeEnum.SCREENING_APPLY.getType())
// .fluentPut("content", "预约成功,请准时赴约筛查!")
// .fluentPut("contentId", recordBody.getScreeningId());
//FdmpPushMegUtil.sendPost(jsonObject);
} }
return body.getPatientId(); return result;
} }
@Override @Override