Merge branch 'dev' of http://182.92.166.109:3000/xinyilu/PostDischargePatientManage into dev
This commit is contained in:
commit
760af62433
@ -59,12 +59,14 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
*/
|
*/
|
||||||
public void signPatientManageRouteNodeTask() {
|
public void signPatientManageRouteNodeTask() {
|
||||||
//微信小程序订阅消息记录表
|
//微信小程序订阅消息记录表
|
||||||
|
//1、获取已订阅 指定 小程序通知模版 的 患者列表;
|
||||||
List<PatientVO> patientList = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getHealthyPropagandaId());
|
List<PatientVO> patientList = homePageMapper.selectResidentAndSubscribeMessageRecord(SubscribeStatusEnum.accept.getValue(), weChatAppletChatConfig.getHealthyPropagandaId());
|
||||||
|
//1.1 获取已订阅 指定 小程序通知模版 的 患者ID列表;
|
||||||
List<Long> patientIdList = patientList.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
|
List<Long> patientIdList = patientList.stream().filter(Objects::nonNull).map(PatientVO::getPatientId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isEmpty(patientIdList)) {
|
if (CollectionUtils.isEmpty(patientIdList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 患者节点表
|
// 2、患者节点表(患者任务表)
|
||||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(patientIdList);
|
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(patientIdList);
|
||||||
if (CollectionUtils.isEmpty(signPatientManageRouteNodes)) {
|
if (CollectionUtils.isEmpty(signPatientManageRouteNodes)) {
|
||||||
return;
|
return;
|
||||||
@ -73,6 +75,7 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
List<PatientVO> patientVOList = new ArrayList<>();
|
List<PatientVO> patientVOList = new ArrayList<>();
|
||||||
//发送消息到期节点id集合
|
//发送消息到期节点id集合
|
||||||
List<Long> expiredManageRouteNodeIds = new ArrayList<>();
|
List<Long> expiredManageRouteNodeIds = new ArrayList<>();
|
||||||
|
//2.1 开始遍历患者任务,组装数据
|
||||||
for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) {
|
for (PatientVO signPatientManageRouteNode : signPatientManageRouteNodes) {
|
||||||
//判断推送状态
|
//判断推送状态
|
||||||
if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) {
|
if (Objects.isNull(signPatientManageRouteNode.getAppletPushSign()) || signPatientManageRouteNode.getAppletPushSign() != 1) {
|
||||||
@ -93,6 +96,7 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now());
|
boolean before = localDate.isBefore(LocalDate.now()) || localDate.isEqual(LocalDate.now());
|
||||||
if (before) {
|
if (before) {
|
||||||
long until = localDate.until(LocalDate.now(), ChronoUnit.DAYS);
|
long until = localDate.until(LocalDate.now(), ChronoUnit.DAYS);
|
||||||
|
//已过期 任务
|
||||||
if (until >= pushMessageRestrictions.getTime()) {
|
if (until >= pushMessageRestrictions.getTime()) {
|
||||||
expiredManageRouteNodeIds.add(signPatientManageRouteNode.getSignPatientManageRouteNodeId());
|
expiredManageRouteNodeIds.add(signPatientManageRouteNode.getSignPatientManageRouteNodeId());
|
||||||
continue;
|
continue;
|
||||||
@ -100,10 +104,11 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
signPatientManageRouteNode.setOpenId(patientVO.getOpenId());
|
||||||
//转换成中文……
|
//转换成中文……
|
||||||
signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(signPatientManageRouteNode.getRouteNodeName()).getName());
|
signPatientManageRouteNode.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(signPatientManageRouteNode.getRouteNodeName()).getName());
|
||||||
|
//待发送 任务列表
|
||||||
patientVOList.add(signPatientManageRouteNode);
|
patientVOList.add(signPatientManageRouteNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//更改过期执行状态
|
//2.2 对过期的任务,更改过期执行状态
|
||||||
if (CollectionUtils.isNotEmpty(expiredManageRouteNodeIds)) {
|
if (CollectionUtils.isNotEmpty(expiredManageRouteNodeIds)) {
|
||||||
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(expiredManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.EXPIRED.getInfo(), null, null);
|
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(expiredManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.EXPIRED.getInfo(), null, null);
|
||||||
}
|
}
|
||||||
@ -157,14 +162,18 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
if (CollectionUtils.isEmpty(patientVOList)) {
|
if (CollectionUtils.isEmpty(patientVOList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//节点推送数量
|
//2.3 节点推送数量,用于判断失败次数,若达到最大值,则认为失败;
|
||||||
List<Long> collect = patientVOList.stream().filter(Objects::nonNull).map(PatientVO::getSignPatientManageRouteNodeId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
List<Long> collect = patientVOList.stream().filter(Objects::nonNull).map(PatientVO::getSignPatientManageRouteNodeId)
|
||||||
|
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
//RecordNum,manageRouteNodeId:任务ID,num:已推送次数
|
||||||
List<RecordNum> recordNums = subscribeMessageSendRecordMapper.selectRecordCountByManageRouteNodeIds(collect);
|
List<RecordNum> recordNums = subscribeMessageSendRecordMapper.selectRecordCountByManageRouteNodeIds(collect);
|
||||||
//发送成功id集合
|
//发送成功id集合
|
||||||
List<Long> signPatientManageRouteNodeIds = new ArrayList<>();
|
List<Long> signPatientManageRouteNodeIds = new ArrayList<>();
|
||||||
//发送失败
|
//发送失败
|
||||||
List<Long> failSignPatientManageRouteNodeIds = new ArrayList<>();
|
List<Long> failSignPatientManageRouteNodeIds = new ArrayList<>();
|
||||||
Set<Long> patientIdSet = new HashSet<>();
|
Set<Long> patientIdSet = new HashSet<>();
|
||||||
|
|
||||||
|
//3、----------开始推送------------//
|
||||||
for (PatientVO patientVO : patientVOList) {
|
for (PatientVO patientVO : patientVOList) {
|
||||||
// 开始推送消息
|
// 开始推送消息
|
||||||
Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
|
Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
|
||||||
@ -180,6 +189,7 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
subscribeMessageSendRecord.setErrorCode(integer);
|
subscribeMessageSendRecord.setErrorCode(integer);
|
||||||
subscribeMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue());
|
subscribeMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue());
|
||||||
RecordNum recordNum = recordNums.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getManageRouteNodeId()) && item.getManageRouteNodeId().equals(patientVO.getSignPatientManageRouteNodeId())).findFirst().orElse(new RecordNum());
|
RecordNum recordNum = recordNums.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getManageRouteNodeId()) && item.getManageRouteNodeId().equals(patientVO.getSignPatientManageRouteNodeId())).findFirst().orElse(new RecordNum());
|
||||||
|
//若已推送次数达到 配置的 最大次数,则认为:失败;
|
||||||
if (Objects.nonNull(recordNum.getNum()) && recordNum.getNum() >= pushMessageRestrictions.getNumber()) {
|
if (Objects.nonNull(recordNum.getNum()) && recordNum.getNum() >= pushMessageRestrictions.getNumber()) {
|
||||||
failSignPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
failSignPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
||||||
}
|
}
|
||||||
@ -191,17 +201,20 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
|||||||
subscribeMessageSendRecord.setAppletId(weChatAppletChatConfig.getAppletId());
|
subscribeMessageSendRecord.setAppletId(weChatAppletChatConfig.getAppletId());
|
||||||
subscribeMessageSendRecord.setTemplateId(weChatAppletChatConfig.getHealthyPropagandaId());
|
subscribeMessageSendRecord.setTemplateId(weChatAppletChatConfig.getHealthyPropagandaId());
|
||||||
subscribeMessageSendRecord.setCreateTime(LocalDateTime.now());
|
subscribeMessageSendRecord.setCreateTime(LocalDateTime.now());
|
||||||
|
//3.1 托送记录入库
|
||||||
subscribeMessageSendRecordMapper.insertSubscribeMessageSendRecord(subscribeMessageSendRecord);
|
subscribeMessageSendRecordMapper.insertSubscribeMessageSendRecord(subscribeMessageSendRecord);
|
||||||
}
|
}
|
||||||
//更改成功执行状态
|
|
||||||
|
|
||||||
|
//4、更改成功执行状态
|
||||||
if (CollectionUtils.isNotEmpty(signPatientManageRouteNodeIds)) {
|
if (CollectionUtils.isNotEmpty(signPatientManageRouteNodeIds)) {
|
||||||
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(signPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.SUCCESS.getInfo(), null, null);
|
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(signPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.SUCCESS.getInfo(), null, null);
|
||||||
}
|
}
|
||||||
//更改失败执行状态
|
//4.2 更改失败执行状态
|
||||||
if (CollectionUtils.isNotEmpty(failSignPatientManageRouteNodeIds)) {
|
if (CollectionUtils.isNotEmpty(failSignPatientManageRouteNodeIds)) {
|
||||||
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(failSignPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.FAILURE.getInfo(), null, null);
|
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(failSignPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.FAILURE.getInfo(), null, null);
|
||||||
}
|
}
|
||||||
// 患者任务统计表修改
|
//5、 患者任务统计表修改
|
||||||
if (CollectionUtils.isNotEmpty(patientIdSet)) {
|
if (CollectionUtils.isNotEmpty(patientIdSet)) {
|
||||||
patientTaskStatisticsService.updateNum(new ArrayList<>(patientIdSet));
|
patientTaskStatisticsService.updateNum(new ArrayList<>(patientIdSet));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user