添加家医pc端健康知识推送相关接口;

This commit is contained in:
mengkuiliang 2023-10-25 14:39:31 +08:00
parent c399e2e922
commit 343527df23
10 changed files with 350 additions and 4 deletions

View File

@ -1,21 +1,33 @@
package com.xinelu.web.controller.applet;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.service.chatRecord.IChatRecordService;
import com.xinelu.applet.service.messagepush.MessagePushService;
import com.xinelu.applet.vo.chatrecord.MessageVo;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R;
import com.xinelu.common.exception.ServiceException;
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 com.xinelu.manage.domain.chatRecord.ChatRecord;
import com.xinelu.manage.domain.hospitalpersoninfo.HospitalPersonInfo;
import com.xinelu.manage.service.hospitalpersoninfo.IHospitalPersonInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import java.util.Date;
/**
* @Author mengkuiliang
@ -32,6 +44,10 @@ public class FdMessageController extends BaseController {
private MessagePushService messagePushService;
@Resource
private AsyncExecutorConfig asyncExecutorConfig;
@Resource
private IChatRecordService chatRecordService;
@Resource
private IHospitalPersonInfoService hospitalPersonInfoService;
@ApiOperation(value = "家医推送订阅消息", notes = "向接收方推送订阅消息")
@PostMapping("/push")
@ -77,4 +93,59 @@ public class FdMessageController extends BaseController {
System.out.println("执行成功");
return R.ok();
}
@ApiOperation("查询通知推送列表-家医PC端")
@PostMapping("/getNoticList")
public R<PageInfo<MessageVo>> getNoticList(@RequestBody MessageSearchDto messageDto) {
if (StringUtils.isBlank(messageDto.getSenderNo())) {
return R.fail("发送人编号不能为空");
}
return R.ok(chatRecordService.getNoticList(messageDto));
}
@ApiOperation("查询通知详情-PC端")
@GetMapping("/getNoticDetail/{messageNo}")
public R<MessageVo> getNoticDetail(@PathVariable String messageNo) {
return R.ok(chatRecordService.getNoticDetail(messageNo));
}
@ApiOperation(value = "保存通知-PC端", notes = "健康推送和通知公告消息通知")
@PostMapping("/noticeSave")
@Transactional
public R<?> noticeSave(@RequestBody ChatRecordDTO message) {
// 根据发送人编号查询家医用户信息
HospitalPersonInfo hospitalPersonInfo = hospitalPersonInfoService.getByPersonCode(message.getSenderNo(), null);
if(hospitalPersonInfo == null) {
throw new ServiceException("未查询到医生信息");
}
if(StringUtils.isBlank(message.getMessageNo())) {
message.setSendTime(new Date());
message.setSenderId(hospitalPersonInfo.getId());
message.setSenderName(hospitalPersonInfo.getPersonName());
chatRecordService.insertChatRecord(message);
} else {
MessageVo messageVo = chatRecordService.getNoticDetail(message.getMessageNo());
if(messageVo != null) {
ChatRecord entity = new ChatRecord();
BeanUtils.copyProperties(messageVo, entity);
entity.setMessageType(message.getMessageType());
entity.setContent(message.getContent());
entity.setCrowds(message.getCrowds());
entity.setCrowdsName(message.getCrowdsName());
entity.setTitle(message.getTitle());
entity.setUpdateTime(new Date());
entity.setUpdateBy(message.getSenderNo());
chatRecordService.updateChatRecordOfNo(entity);
}
}
return R.ok();
}
@ApiOperation("删除通知-家医PC端")
@GetMapping("/noticDel/{messageNo}")
public R<String> noticDel(@PathVariable String messageNo) {
chatRecordService.del(messageNo);
return R.ok();
}
}

View File

@ -3,6 +3,10 @@ package com.xinelu.web.controller.fd;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.service.chatRecord.IChatRecordService;
import com.xinelu.applet.vo.chatrecord.MessageVo;
import com.xinelu.common.core.domain.R;
import com.xinelu.familydoctor.applet.pojo.body.ApprovalBody;
import com.xinelu.familydoctor.applet.pojo.body.SyncHospitalPersonInfoBody;
@ -13,6 +17,7 @@ import com.xinelu.familydoctor.applet.pojo.vo.ResidentSignApplyVo;
import com.xinelu.familydoctor.applet.service.IResidentRescindApplyService;
import com.xinelu.familydoctor.applet.service.IResidentServiceAppletService;
import com.xinelu.familydoctor.applet.service.IResidentSignAppletService;
import com.xinelu.manage.domain.chatRecord.ChatRecord;
import com.xinelu.manage.domain.hospitalinfo.HospitalInfo;
import com.xinelu.manage.domain.hospitalpersoninfo.HospitalPersonInfo;
import com.xinelu.manage.service.hospitalinfo.IHospitalInfoService;
@ -23,6 +28,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -45,6 +53,7 @@ public class FDController {
@Resource
private IHospitalInfoService hospitalInfoService;
@ApiOperation("服务申请列表")
@PostMapping("/performanceBooking/list")
public R<PageInfo<ResidentServiceApplyVo>> performanceBookingList(@RequestBody ApplyQuery query) {
@ -191,5 +200,4 @@ public class FDController {
}
return R.ok();
}
}

View File

@ -2,6 +2,7 @@ package com.xinelu.applet.dto.chatrecord;
import com.xinelu.common.core.domain.BaseEntity;
import com.xinelu.common.custominterface.Insert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.sf.jsqlparser.statement.update.Update;
import org.hibernate.validator.constraints.Length;
@ -29,9 +30,9 @@ public class ChatRecordDTO extends BaseEntity implements Serializable {
private Long consultationId;
/**
* 发送人
* 消息业务主键
*/
@NotNull(message = "发送人信息不能为空", groups = {Insert.class})
@NotNull(message = "消息业务主键", groups = {Insert.class})
private String messageNo;
/**
@ -40,6 +41,11 @@ public class ChatRecordDTO extends BaseEntity implements Serializable {
@NotNull(message = "发送人信息不能为空", groups = {Insert.class})
private Long senderId;
/**
* 发送人(家医医生编号)
*/
private String senderNo;
/**
* 发送人姓名
*/
@ -85,4 +91,10 @@ public class ChatRecordDTO extends BaseEntity implements Serializable {
*/
private String messageCategory;
@ApiModelProperty("通知适用人群0全部人群")
private String crowds;
@ApiModelProperty("通知适用人群名称")
private String crowdsName;
}

View File

@ -26,6 +26,9 @@ public class MessageSearchDto {
@ApiModelProperty("发送人编号")
private Long senderId;
@ApiModelProperty("发送人编号(家医医生编号)")
private String senderNo;
@ApiModelProperty("接收人编号")
private Long recipientId;
@ -47,6 +50,17 @@ public class MessageSearchDto {
@ApiModelProperty(value = "居民绑定时间", hidden = true)
private Date bindingTime;
/**
* 页码
*/
@ApiModelProperty(value = "页码")
private Integer pageNum = 1;
/**
* 每页大小
*/
@ApiModelProperty(value = "每页大小")
private Integer pageSize = 15;
@ApiModelProperty(value = "通知适用人群编号集合", hidden = true)
private List<String> crowdNoList;
}

View File

@ -68,4 +68,40 @@ public interface ChatRecordMapper {
public int deleteChatRecordByIds(Long[] ids);
Integer updateReadStatus(MarkReadDto markReadDto);
/**
* @Author mengkuiliang
* @Description 查询健康知识推送列表
* @Date 2023-10-25 025 11:27
* @Param [messageDto]
* @return java.lang.Object
**/
List<MessageVo> getNoticList(MessageSearchDto messageDto);
/**
* @Author mengkuiliang
* @Description 查询消息详情
* @Date 2023-10-25 025 11:45
* @Param [messageNo]
* @return com.xinelu.applet.vo.chatrecord.MessageVo
**/
MessageVo getByNo(String messageNo);
/**
* @Author mengkuiliang
* @Description 删除通知
* @Date 2023-10-25 025 13:15
* @Param [messageNo]
* @return void
**/
void del(String messageNo);
/**
* @Author mengkuiliang
* @Description 更新通知
* @Date 2023-10-25 025 14:05
* @Param [entity]
* @return void
**/
void updateChatRecordOfNo(ChatRecord entity);
}

View File

@ -1,8 +1,10 @@
package com.xinelu.applet.service.chatRecord;
import com.github.pagehelper.PageInfo;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
import com.xinelu.applet.vo.chatrecord.MessageVo;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.exception.file.InvalidExtensionException;
import com.xinelu.manage.domain.chatRecord.ChatRecord;
@ -78,4 +80,40 @@ public interface IChatRecordService {
public AjaxResult uploadChatRecordFile(MultipartFile multipartFile, Long consultationId) throws IOException, InvalidExtensionException;
List<MessageCenterVo> getMegVoList(MessageSearchDto messageDto);
/**
* @Author mengkuiliang
* @Description 查询健康知识推送列表
* @Date 2023-10-25 025 11:24
* @Param [messageDto]
* @return com.github.pagehelper.PageInfo<MessageVo>
**/
PageInfo<MessageVo> getNoticList(MessageSearchDto messageDto);
/**
* @Author mengkuiliang
* @Description 查询健康知识推送详情
* @Date 2023-02-18 14:58
* @Param [messageNo]
* @return java.lang.Object
**/
MessageVo getNoticDetail(String messageNo);
/**
* @Author mengkuiliang
* @Description 删除通知
* @Date 2023-10-25 025 13:15
* @Param [messageNo]
* @return void
**/
void del(String messageNo);
/**
* @Author mengkuiliang
* @Description 更新通知
* @Date 2023-10-25 025 14:04
* @Param [entity]
* @return void
**/
void updateChatRecordOfNo(ChatRecord entity);
}

View File

@ -1,5 +1,7 @@
package com.xinelu.applet.service.chatRecord.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.mapper.chatrecord.ChatRecordMapper;
@ -8,6 +10,7 @@ import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
import com.xinelu.applet.vo.chatrecord.MessageVo;
import com.xinelu.common.config.XinELuConfig;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.domain.R;
import com.xinelu.common.core.dto.MessageTemplate;
import com.xinelu.common.enums.MessageContentType;
import com.xinelu.common.exception.ServiceException;
@ -17,6 +20,7 @@ import com.xinelu.common.utils.DateUtils;
import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.common.utils.file.FileUploadUtils;
import com.xinelu.common.utils.file.MimeTypeUtils;
import com.xinelu.common.utils.uuid.IdUtils;
import com.xinelu.manage.domain.chatRecord.ChatRecord;
import java.io.IOException;
import java.util.ArrayList;
@ -25,6 +29,9 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.xinelu.manage.domain.hospitalpersoninfo.HospitalPersonInfo;
import com.xinelu.manage.service.hospitalpersoninfo.IHospitalPersonInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -42,6 +49,8 @@ public class ChatRecordServiceImpl implements IChatRecordService {
private ChatRecordMapper chatRecordMapper;
@Resource
private XinELuConfig xinYiLuConfig;
@Resource
private IHospitalPersonInfoService hospitalPersonInfoService;
/**
* 查询图文咨询-聊天记录
@ -76,6 +85,7 @@ public class ChatRecordServiceImpl implements IChatRecordService {
chatRecord.setCreateTime(DateUtils.getNowDate());
ChatRecord record = new ChatRecord();
BeanUtils.copyBeanProp(record, chatRecord);
record.setMessageNo(IdUtils.fastSimpleUUID());
return chatRecordMapper.insertChatRecord(record);
}
@ -209,4 +219,59 @@ public class ChatRecordServiceImpl implements IChatRecordService {
return messageCenterVos;
}
/**
* @Author mengkuiliang
* @Description 查询健康知识推送列表
* @Date 2023-10-25 025 11:24
* @Param [messageDto]
* @return com.github.pagehelper.PageInfo<com.xinelu.applet.vo.chatrecord.MessageVo>
**/
@Override
public PageInfo<MessageVo> getNoticList(MessageSearchDto messageDto) {
// 根据发送人编号查询家医用户信息
HospitalPersonInfo hospitalPersonInfo = hospitalPersonInfoService.getByPersonCode(messageDto.getSenderNo(), null);
if(hospitalPersonInfo == null) {
throw new ServiceException("未查询到医生信息");
}
messageDto.setSenderId(hospitalPersonInfo.getId());
PageHelper.startPage(messageDto.getPageNum(), messageDto.getPageSize());
return PageInfo.of(chatRecordMapper.getNoticList(messageDto));
}
/**
* @return com.xinelu.mp.message.pojo.vo.MessageVo
* @Author mengkuiliang
* @Description 查询消息详情
* @Date 2023-02-18 14:58
* @Param [messageNo]
**/
@Override
public MessageVo getNoticDetail(String messageNo) {
return chatRecordMapper.getByNo(messageNo);
}
/**
* @Author mengkuiliang
* @Description 删除通知
* @Date 2023-10-25 025 13:15
* @Param [messageNo]
* @return void
**/
@Override
public void del(String messageNo) {
chatRecordMapper.del(messageNo);
}
/**
* @Author mengkuiliang
* @Description 更新通知
* @Date 2023-10-25 025 14:05
* @Param [entity]
* @return void
**/
@Override
public void updateChatRecordOfNo(ChatRecord entity) {
chatRecordMapper.updateChatRecordOfNo(entity);
}
}

View File

@ -30,6 +30,9 @@ public class MessageVo {
@ApiModelProperty("发送人编号")
private Long senderId;
@ApiModelProperty("发送人编号(家医医生编号)")
private String senderNo;
@ApiModelProperty("发送人姓名")
private String senderName;

View File

@ -34,6 +34,8 @@
message_no,
message_category,
consultation_id,
crowds,
crowds_name,
sender_id,
sender_name,
send_time,
@ -55,7 +57,7 @@
<sql id="Message_Vo_List">
message_no
,message_category,crowds,crowds_name,sender_id,
,message_category,crowds,crowds_name,sender_id,crowds,crowds_name,
sender_name,send_time,recipient_id,
recipient_name,message_type,title,content,content_id,
read_status
@ -117,12 +119,71 @@
where id = #{id}
</select>
<!-- 查询健康知识推送列表 -->
<select id="getNoticList" resultType="com.xinelu.applet.vo.chatrecord.MessageVo">
<include refid="selectChatRecordVo"></include>
where del_flag = '0' and sender_id = #{senderId}
<choose>
<when test="messageCategory != null and messageCategory != ''">
and message_category = #{messageCategory}
</when>
<otherwise>
and message_category in ('1', '2')
</otherwise>
</choose>
<if test="startDate != null">
and send_time &gt;= #{startDate}
</if>
<if test="endDate != null">
and send_time &lt;= #{endDate}
</if>
<if test="crowdNoList != null and crowdNoList.size() > 0">
and (
<foreach collection="crowdNoList" item="no" open="(" separator="or" close=")">
FIND_IN_SET(#{no},crowds)
</foreach>)
</if>
order by send_time desc
</select>
<!-- 查询消息详情 -->
<select id="getByNo" resultType="com.xinelu.applet.vo.chatrecord.MessageVo">
select cr.id,
cr.message_no,
cr.message_category,
cr.consultation_id,
cr.crowds,
cr.crowds_name,
cr.sender_id,
cr.sender_name,
cr.send_time,
cr.recipient_id,
cr.recipient_name,
cr.message_type,
cr.title,
cr.content,
cr.content_id,
cr.read_status,
cr.read_time,
cr.del_flag,
cr.create_by,
cr.create_time,
cr.update_by,
cr.update_time,
p.person_code sender_no
from chat_record cr
left join hospital_person_info p on p.id = cr.sender_id
where cr.message_no = #{messageNo}
</select>
<insert id="insertChatRecord" parameterType="ChatRecord" useGeneratedKeys="true"
keyProperty="id">
insert into chat_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="messageCategory != null">message_category,
</if>
<if test="messageNo != null">message_no,
</if>
<if test="consultationId != null">consultation_id,
</if>
<if test="crowds != null">crowds,
@ -165,6 +226,8 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="messageCategory != null">#{messageCategory},
</if>
<if test="messageNo != null">#{messageNo},
</if>
<if test="consultationId != null">#{consultationId},
</if>
<if test="crowds != null">#{crowds},
@ -286,6 +349,32 @@
where del_flag = '0' and read_status = '0' and recipient_id = #{recipientId}
</update>
<!-- 更新通知 -->
<update id="updateChatRecordOfNo">
update chat_record
<set>
<if test="messageCategory != null">message_category = #{messageCategory},</if>
<if test="consultationId != null">consultation_id = #{consultationId},</if>
<if test="crowds != null">crowds = #{crowds},</if>
<if test="crowdsName != null">crowds_name = #{crowdsName},</if>
<if test="senderId != null">sender_id = #{senderId},</if>
<if test="senderName != null and senderName != ''">sender_name = #{senderName},</if>
<if test="sendTime != null">send_time = #{sendTime},</if>
<if test="recipientId != null">recipient_id = #{recipientId},</if>
<if test="recipientName != null and recipientName != ''">recipient_name = #{recipientName},</if>
<if test="messageType != null">message_type = #{messageType},</if>
<if test="title != null">title = #{title},</if>
<if test="content != null">content = #{content},</if>
<if test="contentId != null">content_id = #{contentId},</if>
<if test="readStatus != null">read_status = #{readStatus},</if>
<if test="readTime != null">read_time = #{readTime},</if>
<if test="delFlag != null">del_flag =#{delFlag},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</set>
where message_no = #{messageNo}
</update>
<delete id="deleteChatRecordById" parameterType="Long">
delete
from chat_record
@ -298,4 +387,9 @@
#{id}
</foreach>
</delete>
<!-- 删除通知 -->
<delete id="del">
delete from chat_record where message_no = #{messageNo}
</delete>
</mapper>

View File

@ -34,6 +34,11 @@ public class ChatRecord extends BaseEntity implements Serializable {
*/
private Long id;
/**
* 消息业务主键
*/
private String messageNo;
/**
* 消息类别 1通知公告2健康推送3在线咨询 4消息通知
*/