Merge remote-tracking branch 'origin/jihan_0920_护理服务、商城、积分兑换、在线问诊功能分支' into jihan_0920_护理服务、商城、积分兑换、在线问诊功能分支

This commit is contained in:
赵旭 2023-10-24 16:33:22 +08:00
commit b285e99460
9 changed files with 79 additions and 19 deletions

View File

@ -40,6 +40,11 @@ public class MessageTemplate {
*/ */
private String msgType; private String msgType;
/**
* 消息类型(文字/图片)
*/
private String messageType;
/** /**
* 发送时间 * 发送时间
* */ * */

View File

@ -12,12 +12,14 @@ import com.xinelu.common.core.domain.R;
import com.xinelu.common.enums.BusinessType; import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.socket.WebSocketUtils; import com.xinelu.common.socket.WebSocketUtils;
import com.xinelu.manage.domain.chatRecord.ChatRecord; import com.xinelu.manage.domain.chatRecord.ChatRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -33,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
* @author wanghao * @author wanghao
* @create 2023/9/26 0026 * @create 2023/9/26 0026
*/ */
@Api(tags = "消息控制器")
@RestController @RestController
@RequestMapping("/nurseApplet/chatRecord") @RequestMapping("/nurseApplet/chatRecord")
public class ChatRecordController extends BaseController { public class ChatRecordController extends BaseController {
@ -62,7 +65,8 @@ public class ChatRecordController extends BaseController {
@PostMapping("/sendMessage") @PostMapping("/sendMessage")
@Transactional @Transactional
public AjaxResult sendMessage(@RequestBody ChatRecordDTO chatRecordDTO) { public AjaxResult sendMessage(@RequestBody ChatRecordDTO chatRecordDTO) {
if (chatRecordService.insertChatRecord(chatRecordDTO) > 0) { chatRecordDTO.setMessageCategory("3");
if (chatRecordService.insertChatRecord(chatRecordDTO) > 0) {
// 判断接收人是否在线 // 判断接收人是否在线
if (WebSocketUtils.clients.get(chatRecordDTO.getRecipientId().toString()) == null) { if (WebSocketUtils.clients.get(chatRecordDTO.getRecipientId().toString()) == null) {
return AjaxResult.success(); return AjaxResult.success();
@ -96,4 +100,13 @@ public class ChatRecordController extends BaseController {
} }
return R.ok(chatRecordService.getMegVoList(messageDto)); return R.ok(chatRecordService.getMegVoList(messageDto));
} }
@ApiOperation("删除消息")
@GetMapping("/deleteMegs")
public R<String> deleteMegs(@RequestBody List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return R.fail("请选择要删除的消息!");
}
return chatRecordService.deleteMegs(ids) > 0 ? R.ok("删除成功") : R.fail("删除失败");
}
} }

View File

@ -2,6 +2,7 @@ package com.xinelu.applet.dto.chatrecord;
import com.xinelu.common.core.domain.BaseEntity; import com.xinelu.common.core.domain.BaseEntity;
import com.xinelu.common.custominterface.Insert; import com.xinelu.common.custominterface.Insert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import net.sf.jsqlparser.statement.update.Update; import net.sf.jsqlparser.statement.update.Update;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
@ -21,6 +22,9 @@ public class ChatRecordDTO extends BaseEntity implements Serializable {
private static final long serialVersionUID = -3911806583514536587L; private static final long serialVersionUID = -3911806583514536587L;
@ApiModelProperty("消息类别 1通知公告2健康推送3在线咨询 4消息通知")
private String messageCategory;
/** /**
* 聊天记录业务主键(问诊表id) * 聊天记录业务主键(问诊表id)
*/ */

View File

@ -25,7 +25,7 @@ public interface ChatRecordMapper {
* @param id 图文咨询-聊天记录主键 * @param id 图文咨询-聊天记录主键
* @return 图文咨询-聊天记录 * @return 图文咨询-聊天记录
*/ */
public ChatRecord selectChatRecordById(Long id); ChatRecord selectChatRecordById(Long id);
/** /**
* 查询图文咨询-聊天记录列表 * 查询图文咨询-聊天记录列表
@ -33,7 +33,7 @@ public interface ChatRecordMapper {
* @param chatRecord 图文咨询-聊天记录 * @param chatRecord 图文咨询-聊天记录
* @return 图文咨询-聊天记录集合 * @return 图文咨询-聊天记录集合
*/ */
public List<ChatRecord> selectChatRecordList(ChatRecord chatRecord); List<ChatRecord> selectChatRecordList(ChatRecord chatRecord);
/** /**
* 新增图文咨询-聊天记录 * 新增图文咨询-聊天记录
@ -41,7 +41,7 @@ public interface ChatRecordMapper {
* @param chatRecord 图文咨询-聊天记录 * @param chatRecord 图文咨询-聊天记录
* @return 结果 * @return 结果
*/ */
public int insertChatRecord(ChatRecord chatRecord); int insertChatRecord(ChatRecord chatRecord);
/** /**
* 修改图文咨询-聊天记录 * 修改图文咨询-聊天记录
@ -49,7 +49,7 @@ public interface ChatRecordMapper {
* @param chatRecord 图文咨询-聊天记录 * @param chatRecord 图文咨询-聊天记录
* @return 结果 * @return 结果
*/ */
public int updateChatRecord(ChatRecord chatRecord); int updateChatRecord(ChatRecord chatRecord);
/** /**
* 删除图文咨询-聊天记录 * 删除图文咨询-聊天记录
@ -57,7 +57,7 @@ public interface ChatRecordMapper {
* @param id 图文咨询-聊天记录主键 * @param id 图文咨询-聊天记录主键
* @return 结果 * @return 结果
*/ */
public int deleteChatRecordById(Long id); int deleteChatRecordById(Long id);
/** /**
* 批量删除图文咨询-聊天记录 * 批量删除图文咨询-聊天记录
@ -65,7 +65,9 @@ public interface ChatRecordMapper {
* @param ids 需要删除的数据主键集合 * @param ids 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteChatRecordByIds(Long[] ids); int deleteChatRecordByIds(Long[] ids);
Integer updateReadStatus(MarkReadDto markReadDto); Integer updateReadStatus(MarkReadDto markReadDto);
int deleteMegs(@Param("ids") List<Long> ids);
} }

View File

@ -24,7 +24,7 @@ public interface IChatRecordService {
* @param id 图文咨询-聊天记录主键 * @param id 图文咨询-聊天记录主键
* @return 图文咨询-聊天记录 * @return 图文咨询-聊天记录
*/ */
public ChatRecord selectChatRecordById(Long id); ChatRecord selectChatRecordById(Long id);
/** /**
* 查询图文咨询-聊天记录列表 * 查询图文咨询-聊天记录列表
@ -32,7 +32,7 @@ public interface IChatRecordService {
* @param chatRecord 图文咨询-聊天记录 * @param chatRecord 图文咨询-聊天记录
* @return 图文咨询-聊天记录集合 * @return 图文咨询-聊天记录集合
*/ */
public List<ChatRecord> selectChatRecordList(ChatRecord chatRecord); List<ChatRecord> selectChatRecordList(ChatRecord chatRecord);
/** /**
* 新增图文咨询-聊天记录 * 新增图文咨询-聊天记录
@ -40,7 +40,7 @@ public interface IChatRecordService {
* @param chatRecordDTO 图文咨询-聊天记录 * @param chatRecordDTO 图文咨询-聊天记录
* @return 结果 * @return 结果
*/ */
public int insertChatRecord(ChatRecordDTO chatRecordDTO); int insertChatRecord(ChatRecordDTO chatRecordDTO);
Boolean sendMessage(ChatRecordDTO chatRecordDTO); Boolean sendMessage(ChatRecordDTO chatRecordDTO);
@ -50,7 +50,7 @@ public interface IChatRecordService {
* @param chatRecord 图文咨询-聊天记录 * @param chatRecord 图文咨询-聊天记录
* @return 结果 * @return 结果
*/ */
public int updateChatRecord(ChatRecord chatRecord); int updateChatRecord(ChatRecord chatRecord);
/** /**
* 批量删除图文咨询-聊天记录 * 批量删除图文咨询-聊天记录
@ -58,7 +58,7 @@ public interface IChatRecordService {
* @param ids 需要删除的图文咨询-聊天记录主键集合 * @param ids 需要删除的图文咨询-聊天记录主键集合
* @return 结果 * @return 结果
*/ */
public int deleteChatRecordByIds(Long[] ids); int deleteChatRecordByIds(Long[] ids);
/** /**
* 删除图文咨询-聊天记录信息 * 删除图文咨询-聊天记录信息
@ -66,7 +66,7 @@ public interface IChatRecordService {
* @param id 图文咨询-聊天记录主键 * @param id 图文咨询-聊天记录主键
* @return 结果 * @return 结果
*/ */
public int deleteChatRecordById(Long id); int deleteChatRecordById(Long id);
/** /**
@ -75,7 +75,9 @@ public interface IChatRecordService {
* @param multipartFile,consultationId 文件,问诊id * @param multipartFile,consultationId 文件,问诊id
* @return 结果 * @return 结果
*/ */
public AjaxResult uploadChatRecordFile(MultipartFile multipartFile, Long consultationId) throws IOException, InvalidExtensionException; AjaxResult uploadChatRecordFile(MultipartFile multipartFile, Long consultationId) throws IOException, InvalidExtensionException;
List<MessageCenterVo> getMegVoList(MessageSearchDto messageDto); List<MessageCenterVo> getMegVoList(MessageSearchDto messageDto);
Integer deleteMegs(List<Long> ids);
} }

View File

@ -20,6 +20,7 @@ import com.xinelu.common.utils.file.MimeTypeUtils;
import com.xinelu.manage.domain.chatRecord.ChatRecord; import com.xinelu.manage.domain.chatRecord.ChatRecord;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -76,6 +77,9 @@ public class ChatRecordServiceImpl implements IChatRecordService {
chatRecord.setCreateTime(DateUtils.getNowDate()); chatRecord.setCreateTime(DateUtils.getNowDate());
ChatRecord record = new ChatRecord(); ChatRecord record = new ChatRecord();
BeanUtils.copyBeanProp(record, chatRecord); BeanUtils.copyBeanProp(record, chatRecord);
record.setReadStatus("0");
record.setSendTime(new Date());
record.setDelFlag(0);
return chatRecordMapper.insertChatRecord(record); return chatRecordMapper.insertChatRecord(record);
} }
@ -87,6 +91,7 @@ public class ChatRecordServiceImpl implements IChatRecordService {
msg.setFromKey(chatRecord.getSenderId().toString()); msg.setFromKey(chatRecord.getSenderId().toString());
msg.setToKey(chatRecord.getRecipientId().toString()); msg.setToKey(chatRecord.getRecipientId().toString());
msg.setMsgType(MessageContentType.CHAT.name()); msg.setMsgType(MessageContentType.CHAT.name());
msg.setMessageType(chatRecord.getMessageType());
msg.setSendTime(chatRecord.getSendTime()); msg.setSendTime(chatRecord.getSendTime());
return WebSocketUtils.sendMessage(chatRecord.getRecipientId().toString(), msg); return WebSocketUtils.sendMessage(chatRecord.getRecipientId().toString(), msg);
} }
@ -209,4 +214,8 @@ public class ChatRecordServiceImpl implements IChatRecordService {
return messageCenterVos; return messageCenterVos;
} }
@Override public Integer deleteMegs(List<Long> ids) {
return chatRecordMapper.deleteMegs(ids);
}
} }

View File

@ -66,7 +66,7 @@
select select
<include refid="Message_Vo_List"/> <include refid="Message_Vo_List"/>
from chat_record from chat_record
where del_flag = '0' and (recipient_id = #{recipientId} or sender_id = #{recipientId}) where del_flag = 0 and (recipient_id = #{recipientId} or sender_id = #{recipientId})
<if test="messageCategory != null"> <if test="messageCategory != null">
and message_category = #{messageCategory} and message_category = #{messageCategory}
</if> </if>
@ -89,7 +89,7 @@
recipient_id, recipient_id,
recipient_name recipient_name
from chat_record from chat_record
where del_flag = '0' where del_flag = 0
and message_category = '3' and message_category = '3'
and ((sender_id = #{bindingNo} and recipient_id = #{doctorNo}) and ((sender_id = #{bindingNo} and recipient_id = #{doctorNo})
or (sender_id = #{doctorNo} and recipient_id = #{bindingNo})) or (sender_id = #{doctorNo} and recipient_id = #{bindingNo}))
@ -98,7 +98,7 @@
<select id="selectChatRecordList" parameterType="ChatRecord" resultMap="ChatRecordResult"> <select id="selectChatRecordList" parameterType="ChatRecord" resultMap="ChatRecordResult">
<include refid="selectChatRecordVo"/> <include refid="selectChatRecordVo"/>
where del_flag = '0' where del_flag = 0
and consultation_id = #{consultationId} and consultation_id = #{consultationId}
and ( and (
(sender_id = #{senderId} and recipient_id = #{recipientId}) (sender_id = #{senderId} and recipient_id = #{recipientId})
@ -218,7 +218,7 @@
<if test="crowds != null">crowds = <if test="crowds != null">crowds =
#{crowds}, #{crowds},
</if> </if>
<if test="crowdsName != null">crowds_name <if test="crowdsName != null">crowds_name =
#{crowdsName}, #{crowdsName},
</if> </if>
<if test="senderId != null">sender_id = <if test="senderId != null">sender_id =
@ -283,7 +283,7 @@
read_time = #{readTime}, read_time = #{readTime},
</if> </if>
</trim> </trim>
where del_flag = '0' and read_status = '0' and recipient_id = #{recipientId} where del_flag = 0 and read_status = '0' and recipient_id = #{recipientId}
</update> </update>
<delete id="deleteChatRecordById" parameterType="Long"> <delete id="deleteChatRecordById" parameterType="Long">
@ -298,4 +298,16 @@
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<update id="deleteMegs">
update chat_record set del_flag = 1
<where>
<if test="ids != null">
id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</update>
</mapper> </mapper>

View File

@ -69,6 +69,8 @@
ci.doctor_name, ci.doctor_name,
ci.problem_description, ci.problem_description,
ci.create_time, ci.create_time,
(SELECT content FROM chat_record cr WHERE cr.consultation_id = ci.id ORDER BY create_time DESC LIMIT 1) as content,
(SELECT message_type FROM chat_record cr WHERE cr.consultation_id = ci.id ORDER BY create_time DESC LIMIT 1) as messageType,
(SELECT COUNT(cr.id) FROM chat_record cr WHERE cr.consultation_id = ci.id AND read_status = '0' (SELECT COUNT(cr.id) FROM chat_record cr WHERE cr.consultation_id = ci.id AND read_status = '0'
<if test="patientId != null "> <if test="patientId != null ">
and sender_id= ci.doctor_id and sender_id= ci.doctor_id

View File

@ -118,6 +118,15 @@ public class ConsultationInfoVO extends BaseEntity implements Serializable {
*/ */
private String medicalRecord; private String medicalRecord;
/**
* 最近一次内容
*/
private String content;
/**
* 内容类型
*/
private String messageType;
/** /**
* 是否删除标识01 * 是否删除标识01
*/ */
@ -152,6 +161,8 @@ public class ConsultationInfoVO extends BaseEntity implements Serializable {
.append("medicalRecord", getMedicalRecord()) .append("medicalRecord", getMedicalRecord())
.append("delFlag", getDelFlag()) .append("delFlag", getDelFlag())
.append("messageCount", getMessageCount()) .append("messageCount", getMessageCount())
.append("content", getContent())
.append("messageType", getMessageType())
.toString(); .toString();
} }
} }