消息推送修改
This commit is contained in:
parent
46f2696f05
commit
a8050ed6fe
@ -101,7 +101,7 @@ public class SubscribeMessageSendRecord extends BaseEntity {
|
||||
* 推送结果状态码(0表示成功)
|
||||
*/
|
||||
@ApiModelProperty(value = "推送结果状态码")
|
||||
@Excel(name = "推送结果状态码", readConverterExp = "0=表示成功")
|
||||
@Excel(name = "推送结果状态码", readConverterExp = "0表示成功")
|
||||
private Integer errorCode;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.xinelu.manage.mapper.subscribemessagesendrecord;
|
||||
|
||||
import com.xinelu.manage.domain.subscribemessagesendrecord.SubscribeMessageSendRecord;
|
||||
import com.xinelu.manage.vo.subscribemessagesendrecord.RecordNum;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -66,4 +68,12 @@ public interface SubscribeMessageSendRecordMapper {
|
||||
* @return int
|
||||
**/
|
||||
int insertSubscribeMessageSendRecordList(List<SubscribeMessageSendRecord> subscribeMessageSendRecordList);
|
||||
|
||||
/**
|
||||
* 节点推送数量
|
||||
*
|
||||
* @param manageRouteNodeIds 节点id
|
||||
* @return RecordNum
|
||||
*/
|
||||
List<RecordNum> selectRecordCountByManageRouteNodeIds(@Param("manageRouteNodeIds") List<Long> manageRouteNodeIds);
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.xinelu.manage.vo.subscribemessagesendrecord;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 微信小程序订阅消息发送结果记录数量
|
||||
*
|
||||
* @author zh
|
||||
* @date 2024-07-31
|
||||
*/
|
||||
@Data
|
||||
public class RecordNum {
|
||||
|
||||
/*
|
||||
*推送数量
|
||||
*/
|
||||
private Long num;
|
||||
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
private Long manageRouteNodeId;
|
||||
}
|
||||
@ -231,4 +231,17 @@
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectRecordCountByManageRouteNodeIds"
|
||||
resultType="com.xinelu.manage.vo.subscribemessagesendrecord.RecordNum">
|
||||
select
|
||||
manage_route_node_id,
|
||||
COUNT(1) num
|
||||
from subscribe_message_send_record
|
||||
where manage_route_node_id IN
|
||||
<foreach item="manageRouteNodeId" collection="manageRouteNodeId" open="(" separator="," close=")">
|
||||
#{manageRouteNodeId}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@ -6,6 +6,7 @@ import com.xinelu.common.enums.*;
|
||||
import com.xinelu.common.utils.SecurityUtils;
|
||||
import com.xinelu.manage.domain.subscribemessagesendrecord.SubscribeMessageSendRecord;
|
||||
import com.xinelu.manage.mapper.subscribemessagesendrecord.SubscribeMessageSendRecordMapper;
|
||||
import com.xinelu.manage.vo.subscribemessagesendrecord.RecordNum;
|
||||
import com.xinelu.mobile.domain.TemplateContent;
|
||||
import com.xinelu.mobile.mapper.homepage.HomePageMapper;
|
||||
import com.xinelu.mobile.utils.WeChatOfficialAccountUtils;
|
||||
@ -53,6 +54,9 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
||||
}
|
||||
// 患者节点表
|
||||
List<PatientVO> signPatientManageRouteNodes = homePageMapper.selectSignPatientManageRouteNode(patientIdList);
|
||||
if (CollectionUtils.isEmpty(signPatientManageRouteNodes)) {
|
||||
return;
|
||||
}
|
||||
// 注:PatientVO 包含签约路径节点相关属性,后面用于推送消息
|
||||
List<PatientVO> patientVOList = new ArrayList<>();
|
||||
//发送消息到期节点id集合
|
||||
@ -138,11 +142,19 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//发送
|
||||
//发送失败id集合
|
||||
if (CollectionUtils.isEmpty(patientVOList)) {
|
||||
return;
|
||||
}
|
||||
//节点推送数量
|
||||
List<Long> collect = patientVOList.stream().filter(Objects::nonNull).map(PatientVO::getSignPatientManageRouteNodeId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
List<RecordNum> recordNums = subscribeMessageSendRecordMapper.selectRecordCountByManageRouteNodeIds(collect);
|
||||
//发送成功id集合
|
||||
List<Long> signPatientManageRouteNodeIds = new ArrayList<>();
|
||||
//发送失败
|
||||
List<Long> failSignPatientManageRouteNodeIds = new ArrayList<>();
|
||||
for (PatientVO patientVO : patientVOList) {
|
||||
try {
|
||||
//判断推送内容格式是否符合
|
||||
JSON.parseArray(patientVO.getAppletNodeContent(), TemplateContent.class);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
@ -150,13 +162,18 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
||||
// 开始推送消息
|
||||
Integer integer = weChatOfficialAccountUtils.sendAppletTemplateMessage(patientVO);
|
||||
SubscribeMessageSendRecord subscribeMessageSendRecord = new SubscribeMessageSendRecord();
|
||||
//推送结果
|
||||
if (integer == 0) {
|
||||
signPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
||||
subscribeMessageSendRecord.setErrorCode(0);
|
||||
subscribeMessageSendRecord.setErrorStatus(ErrorStatusEnum.success.getValue());
|
||||
} else {
|
||||
subscribeMessageSendRecord.setErrorCode(1);
|
||||
subscribeMessageSendRecord.setErrorCode(integer);
|
||||
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());
|
||||
if (Objects.nonNull(recordNum.getNum()) && recordNum.getNum() >= 2) {
|
||||
failSignPatientManageRouteNodeIds.add(patientVO.getSignPatientManageRouteNodeId());
|
||||
}
|
||||
}
|
||||
subscribeMessageSendRecord.setPatientId(patientVO.getPatientId());
|
||||
subscribeMessageSendRecord.setManageRouteNodeId(patientVO.getSignPatientManageRouteNodeId());
|
||||
@ -172,5 +189,9 @@ public class subscribeTaskServiceImpl implements SubscribeTaskService {
|
||||
if (CollectionUtils.isNotEmpty(signPatientManageRouteNodeIds)) {
|
||||
homePageMapper.updateNodeExecuteStatusByIds(signPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.SUCCESS.getInfo());
|
||||
}
|
||||
//更改失败执行状态
|
||||
if (CollectionUtils.isNotEmpty(failSignPatientManageRouteNodeIds)) {
|
||||
homePageMapper.updateNodeExecuteStatusByIds(failSignPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), NodeExecuteResultStatusEnum.FAILURE.getInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user