Compare commits
No commits in common. "master" and "6262807fdef12ea8fb1178f09c609d94de77974b" have entirely different histories.
master
...
6262807fde
|
@ -1,7 +1,7 @@
|
|||
# Default ignored files
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ADDITIONAL_TAGS" value="Dis" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
|
@ -1,9 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="lombok.Data" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
|
@ -12,11 +8,5 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="PWA">
|
||||
<option name="enabled" value="true" />
|
||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17 (2)" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -17,11 +17,9 @@
|
|||
<artifactId>health-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-common-security</artifactId>
|
||||
<version>3.6.6</version>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
@ -31,7 +29,6 @@
|
|||
<url>http://10.100.1.7:8081/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>dragon-release</id>
|
||||
|
@ -40,4 +37,5 @@
|
|||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package com.health.consultation.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 聊天记录表
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class Chatrecord {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 历史聊天记录ID
|
||||
*/
|
||||
private String historyChatRecordId;
|
||||
|
||||
/**
|
||||
* 医生聊天时间戳
|
||||
*/
|
||||
private String doctorChatTimestamp;
|
||||
|
||||
/**
|
||||
* 医生文本
|
||||
*/
|
||||
private String doctorText;
|
||||
|
||||
/**
|
||||
* 患者聊天时间戳
|
||||
*/
|
||||
private String patientChatTimestamp;
|
||||
|
||||
/**
|
||||
* 患者文本
|
||||
*/
|
||||
private String patientText;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package com.health.consultation.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : [Administrator]
|
||||
* @version : [v1.0]
|
||||
* @description : [问诊记录]
|
||||
* @createTime : [2023/10/26 15:58]
|
||||
* @updateUser : [Administrator]
|
||||
* @updateTime : [2023/10/26 15:58]
|
||||
* @updateRemark : [新增问诊记录实体类]
|
||||
*/
|
||||
@Data
|
||||
public class Inquiry {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 医生ID
|
||||
*/
|
||||
private String doctorId;
|
||||
|
||||
/**
|
||||
* 患者ID
|
||||
*/
|
||||
private String patientId;
|
||||
|
||||
/**
|
||||
* 患者头像
|
||||
*/
|
||||
private String patientAvatar;
|
||||
|
||||
/**
|
||||
* 最后咨询时间
|
||||
*/
|
||||
private String lastConsultationTime;
|
||||
|
||||
/**
|
||||
* 最后聊天记录
|
||||
*/
|
||||
private String lastChatRecord;
|
||||
|
||||
/**
|
||||
* 历史聊天记录ID
|
||||
*/
|
||||
private String historyChatRecordId;
|
||||
|
||||
/**
|
||||
* 问诊状态
|
||||
*/
|
||||
private String inquiryStatus;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.health.consultation.common.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ReqDoctorMsg {
|
||||
private String id;
|
||||
private String msg;
|
||||
/**
|
||||
* 患者id
|
||||
*/
|
||||
private String hid;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package com.health.consultation.common.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class RequestDoctor {
|
||||
private String id;
|
||||
/**
|
||||
* 医生姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 医生职位
|
||||
*/
|
||||
private String JobsId;
|
||||
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.health.consultation.common.domain.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 咨询列表
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class Consultation {
|
||||
private String role;
|
||||
private String text;
|
||||
private String historyChatRecordId;
|
||||
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package com.health.consultation.common.domain.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 问诊聊天记录
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class HistoryDoctor {
|
||||
private String id;//聊天记录ID,唯一标识符
|
||||
private String sessionId;//聊天会话ID
|
||||
private String senderId;//发送者ID
|
||||
private String receiverId;//接收者ID
|
||||
private String message;//聊天消息内容
|
||||
private String timestamp;//消息发送时间戳
|
||||
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.health.consultation.common.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @author : [Administrator]
|
||||
* @version : [v1.0]
|
||||
* @description : [用来各种格式转换]
|
||||
* @createTime : [2023/10/26 20:37]
|
||||
* @updateUser : [Administrator]
|
||||
* @updateTime : [2023/10/26 20:37]
|
||||
* @updateRemark : [说明本次修改内容]
|
||||
*/
|
||||
|
||||
public class FormatConversionUtils {
|
||||
|
||||
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern ("yyyyMMddHHmmss");
|
||||
|
||||
public static String formatDateTimeToString (LocalDate datetime) {
|
||||
return datetime.format (FORMATTER);
|
||||
}
|
||||
|
||||
public static LocalDate timeDateFormatter (String dateString) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern ("yyyyMMddHHmmss");
|
||||
LocalDate date = LocalDate.parse (dateString, formatter);
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.health.consultation.domain.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class Department {
|
||||
private String id;
|
||||
|
||||
|
||||
}
|
|
@ -32,82 +32,17 @@
|
|||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-consultation-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.20</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>base-system-common</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-common-datascope</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.taobao.arthas</groupId>
|
||||
<artifactId>arthas-client</artifactId>
|
||||
<version>3.6.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.health.consultation;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class ConMain {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConMain.class,args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.health.consultation.config;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
|
||||
public class Callback implements MqttCallbackExtended {
|
||||
/**
|
||||
* 连接完成
|
||||
* @param b
|
||||
* @param s
|
||||
*/
|
||||
@Override
|
||||
public void connectComplete(boolean b, String s) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接丢失
|
||||
* @param throwable 抛出
|
||||
*/
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息已到达
|
||||
* @param s
|
||||
* @param mqttMessage mqtt消息
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 交货完成
|
||||
* @param iMqttDeliveryToken
|
||||
*/
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.health.consultation.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* mqtt配置类
|
||||
* @author Administrator
|
||||
*/
|
||||
@Configuration
|
||||
@Data
|
||||
public class MQTTConnect {
|
||||
|
||||
private String broker;
|
||||
private String username;
|
||||
private String password;
|
||||
private MqttClient client;
|
||||
|
||||
public void setBroker(String broker) {
|
||||
this.broker = broker;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public MqttClient connect() throws MqttException {
|
||||
client = new MqttClient(broker, MqttClient.generateClientId(), new MemoryPersistence());
|
||||
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
options.setUserName(username);
|
||||
options.setPassword(password.toCharArray());
|
||||
options.setConnectionTimeout(60);
|
||||
options.setKeepAliveInterval(60);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
public void disconnect() throws MqttException {
|
||||
if (client != null && client.isConnected()) {
|
||||
client.disconnect();
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void publishMessage(String topic, String content, int qos) throws MqttException {
|
||||
MqttMessage message = new MqttMessage(content.getBytes());
|
||||
message.setQos(qos);
|
||||
client.publish(topic, message);
|
||||
}
|
||||
|
||||
public void subscribeTopic(String topic, IMqttMessageListener listener) throws MqttException {
|
||||
client.subscribe(topic, listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.health.consultation.controller;
|
||||
|
||||
import com.health.common.core.domain.Result;
|
||||
import com.health.consultation.domain.resp.Department;
|
||||
import com.health.consultation.service.ConService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/consultation")
|
||||
public class ConController {
|
||||
@Autowired
|
||||
ConService conService;
|
||||
|
||||
/**获取科室列表接口:getDepartmentList()
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Result getDepartmentList(){
|
||||
List<Department> departmentList = conService.getDepartmentList();
|
||||
return Result.success(departmentList);
|
||||
}
|
||||
|
||||
|
||||
//获取医生列表接口:getDoctorListByDepartment(String departmentId, String sortType)
|
||||
|
||||
|
||||
//获取医生详情接口:getDoctorDetails(String doctorId)
|
||||
|
||||
|
||||
//获取医生评价接口:getDoctorReviews(String doctorId)
|
||||
|
||||
|
||||
//获取医生关注状态接口:getDoctorFollowStatus(String userId, String doctorId)
|
||||
|
||||
|
||||
//关注医生接口:followDoctor(String userId, String doctorId)
|
||||
|
||||
|
||||
//取消关注医生接口:unfollowDoctor(String userId, String doctorId)
|
||||
|
||||
|
||||
//发送礼物接口:sendGift(String userId, String doctorId, String giftType)
|
||||
|
||||
|
||||
//获取用户咨询状态接口:getUserConsultationStatus(String userId)
|
||||
|
||||
|
||||
//发起咨询接口:startConsultation(String userId, String doctorId)
|
||||
|
||||
|
||||
//结束咨询接口:endConsultation(String userId)
|
||||
|
||||
|
||||
//获取聊天记录接口:getChatRecords(String userId, String doctorId)
|
||||
|
||||
|
||||
//发送聊天消息接口:sendChatMessage(String userId, String doctorId, Message message)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.health.consultation.layer;
|
||||
|
||||
|
||||
|
||||
import com.health.consultation.config.MQTTConnect;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
public class MqttListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
private MQTTConnect server;
|
||||
|
||||
@Autowired
|
||||
public void MQTTListener(MQTTConnect server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public MqttListener(MQTTConnect server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.health.consultation.mapper;
|
||||
|
||||
import com.health.consultation.domain.resp.Department;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ConMapper {
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
List<Department> getDepartmentList();
|
||||
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.health.consultation.server;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
public class ConsultationsMain {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run (ConsultationsMain.class, args);
|
||||
System.out.println ("模块启动成功" +
|
||||
"1" +
|
||||
"2" +
|
||||
"3" +
|
||||
"4" +
|
||||
"5" +
|
||||
"6" +
|
||||
"7" +
|
||||
"8" +
|
||||
"9" +
|
||||
"0" +
|
||||
"-" +
|
||||
"=");
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.health.consultation.server.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter () {
|
||||
|
||||
return new ServerEndpointExporter ();
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package com.health.consultation.server.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.health.common.core.domain.Result;
|
||||
import com.health.consultation.common.domain.req.ReqDoctorMsg;
|
||||
import com.health.consultation.common.domain.resp.Consultation;
|
||||
import com.health.consultation.common.domain.resp.HistoryDoctor;
|
||||
import com.health.consultation.server.service.InquiryService;
|
||||
import com.health.consultation.server.service.WebSocketServer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @Dis 查询历史列表
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping ("/iQL")
|
||||
public class InquiryController {
|
||||
@Autowired
|
||||
InquiryService inquiryService;
|
||||
@Autowired
|
||||
WebSocketServer webSocketServer;
|
||||
|
||||
/**
|
||||
* 获取问诊列表 doctor的信息从请求取
|
||||
*
|
||||
* @return Consultation
|
||||
*/
|
||||
@PostMapping ("/inquiries")
|
||||
public Result<List<Consultation>> getDoctorInquiries () {
|
||||
List<Consultation> list = inquiryService.getDoctorInquiries ();
|
||||
return Result.success (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userId
|
||||
*
|
||||
* @return com.health.common.core.domain.Result<java.util.List < com.health.consultation.common.domain.resp.HistoryDoctor>>
|
||||
*
|
||||
* @author zhn
|
||||
* @description //患者咨询医生
|
||||
* @createTime ${Date} ${Time}
|
||||
**/
|
||||
|
||||
@PostMapping ("/setUpConsultation")
|
||||
public Result<List<HistoryDoctor>> setUpConsultation (String userId) {
|
||||
return inquiryService.setUpConsultation (userId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping ("/chat")
|
||||
public Result setMsgDoctor (@RequestBody ReqDoctorMsg reqDoctorMsg) {
|
||||
try {
|
||||
|
||||
webSocketServer.sendMessage (JSONObject.toJSONString (reqDoctorMsg.getMsg ()), Long.valueOf (reqDoctorMsg.getHid ()));
|
||||
return inquiryService.setMsgDoctor (reqDoctorMsg);
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace ();
|
||||
return Result.error ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors (chain = true)
|
||||
public static class WebsocketResponse {
|
||||
private String userId;
|
||||
private String userName;
|
||||
private int age;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.health.consultation.server.mapper;
|
||||
|
||||
import com.health.consultation.common.domain.Chatrecord;
|
||||
import com.health.consultation.common.domain.resp.Consultation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : [Administrator]
|
||||
* @version : [v1.0]
|
||||
* @description : [一句话描述该类的功能]
|
||||
* @createTime : [2023/10/26 16:26]
|
||||
* @updateUser : [Administrator]
|
||||
* @updateTime : [2023/10/26 16:26]
|
||||
* @updateRemark : [说明本次修改内容]
|
||||
*/
|
||||
@Mapper
|
||||
public interface InquiryMapper {
|
||||
/**
|
||||
* @param doctorId
|
||||
*
|
||||
* @return java.util.List<com.health.consultation.common.domain.resp.Consultation>
|
||||
*
|
||||
* @author zhn
|
||||
* @description //TODO
|
||||
* @createTime ${Date} ${Time}
|
||||
**/
|
||||
|
||||
List<Consultation> getDoctorInquiries (@Param ("doctorId") String doctorId);
|
||||
|
||||
|
||||
int setUpConsultation (@Param ("doctorId") String doctorId, @Param ("userId") String userId);
|
||||
|
||||
|
||||
List<Chatrecord> viewTheChatLog (@Param ("userId") String userId);
|
||||
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.health.consultation.server.service;
|
||||
|
||||
import com.health.common.core.domain.Result;
|
||||
import com.health.consultation.common.domain.req.ReqDoctorMsg;
|
||||
import com.health.consultation.common.domain.resp.Consultation;
|
||||
import com.health.consultation.common.domain.resp.HistoryDoctor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
public interface InquiryService {
|
||||
/**
|
||||
* 医生问诊列表
|
||||
*
|
||||
* @return List<Consultation> 问诊列表
|
||||
*/
|
||||
List<Consultation> getDoctorInquiries ();
|
||||
|
||||
|
||||
/**
|
||||
* 添加患者id到咨询list
|
||||
*
|
||||
* @param userId
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Result<List<HistoryDoctor>> setUpConsultation (String userId);
|
||||
|
||||
/**
|
||||
* 把医生的消息存表
|
||||
*
|
||||
* @param reqDoctorMsg
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Result setMsgDoctor (ReqDoctorMsg reqDoctorMsg);
|
||||
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
package com.health.consultation.server.service;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
@ServerEndpoint ("/webSocket/1")
|
||||
public class WebSocketServer {
|
||||
/**
|
||||
* 为了保存在线用户信息,在方法中新建一个list存储一下【实际项目依据复杂度,可以存储到数据库或者缓存】
|
||||
*/
|
||||
private final static List<Session> SESSIONS = Collections.synchronizedList (new ArrayList<> ());
|
||||
private static int onlineCount = 0;
|
||||
private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<> ();
|
||||
/**
|
||||
* concurrent包的线程安全set,用来存放每个客户端对应的MyWebSocket对象
|
||||
*/
|
||||
private static ConcurrentHashMap<String, WebSocketServer> webSocketMap = new ConcurrentHashMap ();
|
||||
private Session session;
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 获取当前连接数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static synchronized int getOnlineCount () {
|
||||
return onlineCount;
|
||||
}
|
||||
|
||||
@OnOpen
|
||||
public void onOpen (Session session, @PathParam ("userId") String userId) {
|
||||
this.session = session;
|
||||
this.userId = userId;
|
||||
SESSIONS.add (session);
|
||||
if (webSocketMap.containsKey (userId)) {
|
||||
webSocketMap.remove (userId);
|
||||
webSocketMap.put (userId, this);
|
||||
}
|
||||
else {
|
||||
webSocketMap.put (userId, this);
|
||||
addOnlineCount ();
|
||||
}
|
||||
// log.info("【websocket消息】有新的连接, 总数:{}", webSocketSet.size());
|
||||
log.info ("[连接ID:{}] 建立连接, 当前连接数:{}", this.userId, webSocketMap.size ());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前连接数加一
|
||||
*/
|
||||
public static synchronized void addOnlineCount () {
|
||||
WebSocketServer.onlineCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开连接
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose () {
|
||||
webSocketSet.remove (this);
|
||||
if (webSocketMap.containsKey (userId)) {
|
||||
webSocketMap.remove (userId);
|
||||
subOnlineCount ();
|
||||
}
|
||||
// log.info("【websocket消息】连接断开, 总数:{}", webSocketSet.size());
|
||||
log.info ("[连接ID:{}] 断开连接, 当前连接数:{}", userId, webSocketMap.size ());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前连接数减一
|
||||
*/
|
||||
public static synchronized void subOnlineCount () {
|
||||
WebSocketServer.onlineCount--;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送错误
|
||||
*
|
||||
* @param session
|
||||
* @param error
|
||||
*/
|
||||
@OnError
|
||||
public void onError (Session session, Throwable error) {
|
||||
log.info ("[连接ID:{}] 错误原因:{}", this.userId, error.getMessage ());
|
||||
error.printStackTrace ();
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到消息
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
@OnMessage
|
||||
public void onMessage (String message) {
|
||||
// log.info("【websocket消息】收到客户端发来的消息:{}", message);
|
||||
log.info ("[连接ID:{}] 收到消息:{}", this.userId, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param message
|
||||
* @param userId
|
||||
*/
|
||||
public void sendMessage (String message, Long userId) {
|
||||
WebSocketServer webSocketServer = webSocketMap.get (String.valueOf (userId));
|
||||
if (webSocketServer != null) {
|
||||
log.info ("【websocket消息】推送消息, message={}", message);
|
||||
try {
|
||||
webSocketServer.session.getBasicRemote ().sendText (message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace ();
|
||||
log.error ("[连接ID:{}] 发送消息失败, 消息:{}", this.userId, message, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 群发消息
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void sendMassMessage (String message) {
|
||||
try {
|
||||
for (Session session : SESSIONS) {
|
||||
if (session.isOpen ()) {
|
||||
session.getBasicRemote ().sendText (message);
|
||||
log.info ("[连接ID:{}] 发送消息:{}", session.getRequestParameterMap ().get ("userId"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package com.health.consultation.server.service.impl;
|
||||
|
||||
|
||||
import com.health.common.core.domain.Result;
|
||||
import com.health.common.redis.service.RedisService;
|
||||
import com.health.consultation.common.domain.Chatrecord;
|
||||
import com.health.consultation.common.domain.req.ReqDoctorMsg;
|
||||
import com.health.consultation.common.domain.resp.Consultation;
|
||||
import com.health.consultation.common.domain.resp.HistoryDoctor;
|
||||
import com.health.consultation.server.mapper.InquiryMapper;
|
||||
import com.health.consultation.server.service.InquiryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Service
|
||||
public class InquiryServiceImpl implements InquiryService {
|
||||
@Autowired
|
||||
InquiryMapper inquiryMapper;
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
|
||||
/**
|
||||
* 医生问诊列表
|
||||
*
|
||||
* @return List<Consultation> 问诊列表
|
||||
*/
|
||||
@Override
|
||||
public List<Consultation> getDoctorInquiries () {
|
||||
//获取请求的医生信息(携带科室+个人信息+权限信息)
|
||||
List<Consultation> cacheList = redisService.getCacheList ("1chat");
|
||||
for (Consultation consultation : cacheList) {
|
||||
|
||||
}
|
||||
String doctorId = "";
|
||||
|
||||
if (cacheList.isEmpty ()) {
|
||||
List<Consultation> list = inquiryMapper.getDoctorInquiries (doctorId);
|
||||
redisService.setCacheList ("1chat", list);
|
||||
return list;
|
||||
}
|
||||
return cacheList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加患者id到咨询list
|
||||
*
|
||||
* @param userId
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<List<HistoryDoctor>> setUpConsultation (String userId) {
|
||||
//对医生角色权限判断,没权限直接返回提示入驻
|
||||
String doctorId = "1";
|
||||
//查看咨询列表是否有这个患者(redis查询)
|
||||
List<Chatrecord> list = inquiryMapper.viewTheChatLog (userId);
|
||||
if (list.isEmpty ()) {
|
||||
//没有就添加到咨询列表(mysql=>redis添加redis的key:医生名+患者id+患者名)
|
||||
int i = inquiryMapper.setUpConsultation (doctorId, userId);
|
||||
}
|
||||
|
||||
|
||||
//有就返回最后聊天的记录+结束时间(redis取值)
|
||||
// Todo 扣除患者h币+
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把医生的消息存表
|
||||
*
|
||||
* @param reqDoctorMsg
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result setMsgDoctor (ReqDoctorMsg reqDoctorMsg) {
|
||||
|
||||
// TODO 聊天记录存到mysql=>到redis
|
||||
|
||||
|
||||
return Result.success ();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.health.consultation.service;
|
||||
|
||||
import com.health.consultation.domain.resp.Department;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
public interface ConService {
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取科室列表接口:getDepartmentList()
|
||||
* @return List<Department>
|
||||
*/
|
||||
List<Department> getDepartmentList();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.health.consultation.service.impl;
|
||||
|
||||
import com.health.consultation.domain.resp.Department;
|
||||
import com.health.consultation.mapper.ConMapper;
|
||||
import com.health.consultation.service.ConService;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 咨询问诊业务逻辑层
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Service
|
||||
public class ConServiceImpl implements ConService {
|
||||
@Autowired
|
||||
ConMapper conMapper;
|
||||
@Autowired
|
||||
MqttClient mqttClient;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取科室列表接口:getDepartmentList()
|
||||
*
|
||||
* @return List<Department>
|
||||
*/
|
||||
@Override
|
||||
public List<Department> getDepartmentList() {
|
||||
List<Department> list= conMapper.getDepartmentList();
|
||||
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -1,5 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
</profile>
|
||||
</component>
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="FormatOnSaveOptions">
|
||||
<option name="myRunOnSave" value="true" />
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="OptimizeOnSaveOptions">
|
||||
<option name="myRunOnSave" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/resources.iml" filepath="$PROJECT_DIR$/.idea/resources.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,29 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 8083
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: health-consultation-server
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.100.1.5:8848
|
||||
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.100.1.5:8848
|
||||
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.health.consultation.server.mapper.InquiryMapper">
|
||||
<sql id="doctor">
|
||||
select *
|
||||
from inquiry
|
||||
</sql>
|
||||
<update id="setUpConsultation">
|
||||
INSERT INTO `health-consultation`.`inquiry` (`doctor_id`, `patient_id`)
|
||||
VALUES (#{doctorId}, #{userId});
|
||||
|
||||
</update>
|
||||
<update id="viewTheChatLog">
|
||||
|
||||
</update>
|
||||
|
||||
<select id="getDoctorInquiries" resultType="com.health.consultation.common.domain.resp.Consultation">
|
||||
SELECT c.role,
|
||||
c.text,
|
||||
c.history_chat_record_id
|
||||
FROM inquiry i
|
||||
LEFT JOIN ChatRecord c ON i.history_chat_record_id = c.history_chat_record_id
|
||||
WHERE c.role IS NOT NULL
|
||||
AND c.role <> ''
|
||||
AND i.doctor_id = '1'
|
||||
</select>
|
||||
</mapper>
|
5
pom.xml
5
pom.xml
|
@ -4,6 +4,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-consultation-service</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<packaging>pom</packaging>
|
||||
|
@ -17,13 +18,11 @@
|
|||
<artifactId>health-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dragon-public</id>
|
||||
|
@ -31,7 +30,6 @@
|
|||
<url>http://10.100.1.7:8081/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>dragon-release</id>
|
||||
|
@ -39,5 +37,4 @@
|
|||
<url>http://10.100.1.7:8081/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue