提交 449e6a53 authored 作者: 杨凯's avatar 杨凯

feat:家庭医生初始化

上级 812cc55c
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>byh-family-doctor</artifactId>
<groupId>com.ebaiyihui</groupId>
<relativePath>../pom.xml</relativePath>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.ebaiyihui</groupId>
<artifactId>family-doctor-client</artifactId>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
<packaging>jar</packaging>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>byh-family-doctor</artifactId>
<groupId>com.ebaiyihui</groupId>
<relativePath>../pom.xml</relativePath>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.ebaiyihui</groupId>
<artifactId>family-doctor-common</artifactId>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.ebaiyihui.imforward</groupId>
<artifactId>byh-im-forward-client</artifactId>
<version>${byh-im-forward.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</exclusion>
<exclusion>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclusion>
<exclusion>
<artifactId>spring-cloud-openfeign-core</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.ebaiyihui.family.doctor.common.bo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: DoctorInfo
* @Author:yanliang
* @Date:2024/3/14 16:42
* @Description
*/
@Data
public class DoctorInfo {
private String doctorId;
private String doctorName;
private String deptId;
private String deptName;
@ApiModelProperty("医生头像")
private String doctorPortrait;
@ApiModelProperty("医生职称")
private String doctorProfession;
}
package com.ebaiyihui.family.doctor.common.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @ClassName: ImAccountCreateReq
* @Author:yanliang
* @Date:2024/3/13 11:33
* @Description
*/
@Data
@AllArgsConstructor
public class ImAccountCreateReq {
/**
* 就诊记录ID
*/
private String admId;
/**
* 医生ID
*/
private String docId;
/**
* 就诊人ID
*/
private String patientId;
/**
* 医生userId
*/
private String doctorUserId;
/**
* 患者userID
*/
private String patientUserId;
private String appCode;
}
package com.ebaiyihui.family.doctor.common.bo;
/**
* @ClassName: MemberInfo
* @Author:yanliang
* @Date:2024/3/14 15:34
* @Description
*/
public class MemberInfo {
/**
* 医生id
*/
private String doctorId;
/**
* 医生名字
*/
private String name;
/**
* 医生账号
*/
private String account;
public String getDoctorId() {
return doctorId;
}
public void setDoctorId(String doctorId) {
this.doctorId = doctorId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
}
package com.ebaiyihui.family.doctor.common.bo;
import lombok.Data;
import lombok.ToString;
/**
* @ClassName: Message
* @Author:yanliang
* @Date:2024/3/14 15:21
* @Description
*/
@Data
@ToString
public class Message<T> {
/**
* 消息类型 1:不可跳转 2:可以跳转
*/
private Integer messageType;
/**
* 业务编码 arc 医嘱,bookin 入院 ,order 订单详情(病例)
* 如果是不可跳转的消息此处为空
*/
private String businessCode;
/**
* 就诊id
*/
private String admissionId;
private String applicationCode;
/**
* 是否刷新:0 不刷新 1 刷新
*/
private Integer isRefresh;
/**
* 转诊id
*/
private String admId;
/**
* 服务类型
*/
private Integer servType;
/**
* 是否团队:1.个人 2.团队
*/
private String teamFlag;
/**
* 团队消息Id
*/
private String msgId;
/**
* 消息数据
*/
private T data;
private String medicalOpinion;
/**
* user=指定用户发送消息,system=发送系统消息
*/
private String actionType;
public Integer getMessageType() {
return messageType;
}
public void setMessageType(Integer messageType) {
this.messageType = messageType;
}
public String getBusinessCode() {
return businessCode;
}
public void setBusinessCode(String businessCode) {
this.businessCode = businessCode;
}
public String getAdmissionId() {
return admissionId;
}
public void setAdmissionId(String admissionId) {
this.admissionId = admissionId;
}
public String getApplicationCode() {
return applicationCode;
}
public void setApplicationCode(String applicationCode) {
this.applicationCode = applicationCode;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Integer getIsRefresh() {
return isRefresh;
}
public void setIsRefresh(Integer isRefresh) {
this.isRefresh = isRefresh;
}
public String getAdmId() {
return admId;
}
public void setAdmId(String admId) {
this.admId = admId;
}
public Integer getServType() {
return servType;
}
public void setServType(Integer servType) {
this.servType = servType;
}
public String getMedicalOpinion() {
return medicalOpinion;
}
public void setMedicalOpinion(String medicalOpinion) {
this.medicalOpinion = medicalOpinion;
}
public String getTeamFlag() {
return teamFlag;
}
public void setTeamFlag(String teamFlag) {
this.teamFlag = teamFlag;
}
public String getMsgId() {
return msgId;
}
public void setMsgId(String msgId) {
this.msgId = msgId;
}
public String getActionType() {
return actionType;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
}
package com.ebaiyihui.family.doctor.common.bo;
import com.ebaiyihui.imforward.client.vo.AccountVO;
import java.util.List;
/**
* @ClassName: MessageInfo
* @Author:yanliang
* @Date:2024/3/14 15:19
* @Description
*/
public class MessageInfo {
/**
* 接收账号(团队)
*/
private List<AccountVO> receiveAccounts;
/**
* 接收账号(个人)
*/
private AccountVO singleAccount;
/**
* 发送账号(个人)
*/
private AccountVO selfAccount;
/**
* 消息内容对象
*/
private Message message;
/**
* 延迟毫秒数
*/
private Long syncFlag;
/**
* user=指定用户发送消息,system=发送系统消息
*/
private String actionType;
public List<AccountVO> getReceiveAccounts() {
return receiveAccounts;
}
public void setReceiveAccounts(List<AccountVO> receiveAccounts) {
this.receiveAccounts = receiveAccounts;
}
public AccountVO getSingleAccount() {
return singleAccount;
}
public void setSingleAccount(AccountVO singleAccount) {
this.singleAccount = singleAccount;
}
public AccountVO getSelfAccount() {
return selfAccount;
}
public void setSelfAccount(AccountVO selfAccount) {
this.selfAccount = selfAccount;
}
public Message getMessage() {
return message;
}
public void setMessage(Message message) {
this.message = message;
}
public Long getSyncFlag() {
return syncFlag;
}
public void setSyncFlag(Long syncFlag) {
this.syncFlag = syncFlag;
}
public String getActionType() {
return actionType;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
@Override
public String toString() {
return "MessageInfo{" +
"receiveAccounts=" + receiveAccounts +
", singleAccount=" + singleAccount +
", selfAccount=" + selfAccount +
", message=" + message +
", syncFlag=" + syncFlag +
", actionType='" + actionType + '\'' +
'}';
}
}
package com.ebaiyihui.family.doctor.common.bo;
import lombok.Data;
import java.util.List;
/**
* @ClassName: patientSignInfo
* @Author:yanliang
* @Date:2024/3/14 15:34
* @Description
*/
@Data
public class PatientSignInfo {
/**
* 就诊id
*/
private String admId;
/**
* 平台code
*/
private String appCode;
/**
* 机构code
*/
private Long organId;
/**
* 业务类型
*/
private Integer serviceType;
/**
* 患者用户ID
*/
private String patientUserId;
/**
* 患者名字
*/
private String patientName;
/**
* 团队当前处理人doctorId(个人这个值为null)
*/
private String doctorId;
private String doctorName;
/**
* 医生用户ID(团队这个值为null)
*/
private String doctorUserId;
/**
* 团队成员信息(个人这个值为null)
*/
private List<MemberInfo> memberInfos;
}
package com.ebaiyihui.family.doctor.common.bo;
import java.util.List;
/**
* @ClassName: PersonImInformReq
* @Author:yanliang
* @Date:2024/3/14 15:56
* @Description
*/
public class PersonImInformReq {
/**
* 就诊id
*/
private String admissionId;
/**
* 业务编码
*/
private String busiCode;
/**
* 推送消息参数
*/
private List<MessageInfo> messageInfos;
public String getAdmissionId() {
return admissionId;
}
public void setAdmissionId(String admissionId) {
this.admissionId = admissionId;
}
public List<MessageInfo> getMessageInfos() {
return messageInfos;
}
public void setMessageInfos(List<MessageInfo> messageInfos) {
this.messageInfos = messageInfos;
}
public String getBusiCode() {
return busiCode;
}
public void setBusiCode(String busiCode) {
this.busiCode = busiCode;
}
}
package com.ebaiyihui.family.doctor.common.dto;
/**
* @ClassName: DoctorIdDTO
* @Author:yanliang
* @Date:2024/3/13 11:25
* @Description
*/
public class DoctorIdDTO {
/**
* 医生Id
*/
private String doctorId;
/**
* Getter method for property <tt>doctorId</tt>.
*
* @return property value of doctorId
*/
public String getDoctorId() {
return doctorId;
}
/**
* Setter method for property <tt>doctorId</tt>.
*
* @param doctorId value to be assigned to property doctorId
*/
public void setDoctorId(String doctorId) {
this.doctorId = doctorId;
}
/**
* @see Object#toString()
*/
@Override
public String toString() {
return "DoctorIdQueryDTO [doctorId=" + doctorId + "]";
}
}
package com.ebaiyihui.family.doctor.common.dto;
import lombok.Data;
/**
* @ClassName: DoctorInfoForScheduleDTO
* @Author:yanliang
* @Date:2024/3/14 16:24
* @Description
*/
@Data
public class DoctorInfoForScheduleDTO {
private String doctorId;
private String doctorName;
private String deptId;
private String deptName;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @ClassName: ImInfoDetailDocReqDTO
* @Author:yanliang
* @Date:2024/3/13 18:16
* @Description
*/
@Data
public class ImInfoDetailDocReqDTO {
@NotNull(message = "就诊记录Id不能为空")
@ApiModelProperty("就诊id")
private String admissionId;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: ImInfoListDocReqDTO
* @Author:yanliang
* @Date:2024/3/13 17:22
* @Description
*/
@Data
public class ImInfoListDocReqDTO extends PageDTO {
@ApiModelProperty("医生id")
private String doctorId;
@ApiModelProperty("搜索参数")
private String keyWord;
@ApiModelProperty("医院code")
private String appCode;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* @ClassName: InsertScheduleRecordReqDTO
* @Author:yanliang
* @Date:2024/3/14 16:22
* @Description
*/
@Data
public class InsertScheduleRecordReqDTO {
@ApiModelProperty(value = "医院id")
@NotBlank(message = "医院id")
private String hospitalId;
@ApiModelProperty(value = "医院名称")
@NotBlank(message = "医院名称")
private String hospitalName;
@ApiModelProperty(value = "医院名称")
@NotBlank(message = "医院名称")
private String organCode;
@ApiModelProperty("业务类型")
private Integer servType;
@ApiModelProperty(value = "排班开始日期")
@NotBlank(message = "排班开始日期")
private String scheduleDate;
@ApiModelProperty(value = "排班结束日期")
@NotBlank(message = "排班结束日期")
private String scheduleDateEnd;
private List<ScheduleRangeAndTimeDTO> scheduleRangeAndTime;
private List<DoctorInfoForScheduleDTO> doctorInfoForSchedule;
@ApiModelProperty(value = "是否开通循环排班 1开通 -1未开通")
private Integer isCycleSchedule;
}
package com.ebaiyihui.family.doctor.common.dto;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @ClassName: PageDTO
* @Author:yanliang
* @Date:2024/3/13 15:20
* @Description
*/
@Data
public class PageDTO {
@NotNull(message = "当前页不能为空")
@Min(value = 1, message = "当前页不能小于1")
private Integer pageNum = 1;
private Integer pageSize = 20;
}
package com.ebaiyihui.family.doctor.common.dto;
import lombok.Data;
import java.util.List;
/**
* @ClassName: QueryDoctorsDTO
* @Author:yanliang
* @Date:2024/3/11 09:46
* @Description
*/
@Data
public class QueryDoctorsDTO extends QueryFamousDTO {
/**
* 新冠门诊多科室
*/
private List<Long> depts;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: QueryFamousDotDTO
* @Author:yanliang
* @Date:2024/3/11 09:46
* @Description
*/
@Data
public class QueryFamousDTO {
private String userId;
@ApiModelProperty("医疗平台编号")
private String appCode;
@ApiModelProperty("医院id")
private Long organId;
@ApiModelProperty("医院科室id")
private Long organDeptId;
@ApiModelProperty("搜索入参")
private String searchParam;
@ApiModelProperty(
value = "业务code字符串集合",
required = true
)
private String serviceCodes;
@ApiModelProperty("标准二级科室id")
private Long stdDeptId;
@ApiModelProperty("排序标识")
private Integer seq;
@ApiModelProperty(
value = "起始页码",
required = true
)
private Integer pageNum;
@ApiModelProperty(
value = "每页条数",
required = true
)
private Integer pageSize;
@ApiModelProperty(
value = "医生状态",
hidden = true
)
private Integer status;
@ApiModelProperty(value = "服务类型:在线咨询:2,在线复诊:3")
private Integer type;
@ApiModelProperty("预约时间")
private String reserveTime;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: RequestGetDoctorOfficeStatusDTO
* @Author:yanliang
* @Date:2024/3/14 09:56
* @Description
*/
@Data
public class RequestGetDoctorOfficeStatusDTO {
@ApiModelProperty("医生id")
private String doctorId;
@ApiModelProperty("医院id")
private String hospitalId;
@ApiModelProperty("科室id")
private String deptId;
@ApiModelProperty("AppCode")
private String appCode;
@ApiModelProperty("上下线状态:1上线,-1下线")
private Integer officeStatus;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: RequestGetScheduleForWeekDTO
* @Author:yanliang
* @Date:2024/3/14 16:25
* @Description
*/
@Data
public class RequestGetScheduleForWeekDTO {
private Long hospitalId;
private Long deptId;
private Integer week;
private String doctorName;
@ApiModelProperty("业务类型")
private Integer servType;
@ApiModelProperty("当前排班日期")
private Date scheduleDate;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: RequestServiceConfigDTO
* @Author:yanliang
* @Date:2024/3/14 13:50
* @Description
*/
@Data
public class RequestServiceConfigDTO {
@ApiModelProperty("医生Id")
private String doctorId;
private String organId;
@ApiModelProperty("状态")
private Integer status;
private String appCode;
private String serviceCode;
private Long deptId;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: ScheduleForWeekReqDTO
* @Author:yanliang
* @Date:2024/3/14 16:29
* @Description
*/
@Data
public class ScheduleForWeekReqDTO {
private Long hospitalId;
private Integer week;
@ApiModelProperty("用于管理端搜索医生排班")
private String doctorName;
@ApiModelProperty("业务类型")
private Integer servType;
private Integer pageNum;
private Integer pageSize;
}
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @ClassName: ScheduleRangeAndTimeDTO
* @Author:yanliang
* @Date:2024/3/14 16:23
* @Description
*/
@Data
public class ScheduleRangeAndTimeDTO {
@ApiModelProperty(value = "排班类型0 全天 1 上午 2下午 3夜间门诊")
private Integer scheduleRange;
@ApiModelProperty(value = "总号源数")
@NotBlank(message = "总号源数")
private Integer totalCount;
@ApiModelProperty("排班开始时间")
private String startTime;
@ApiModelProperty("排班结束时间")
private String endTime;
}
package com.ebaiyihui.family.doctor.common.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @ClassName: patientSignDoctorDTO
* @Author:yanliang
* @Date:2024/3/13 09:48
* @Description
*/
@Data
public class SignedDoctorDTO {
private String name;
private String idCard;
private String phone;
@NotNull(message = "医生ID不能为空")
private Long doctorId;
private String doctorName;
private Long deptId;
private String deptName;
private String patientId;
private String admId;
private Integer signStatus;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: DoctorListVo
* @Author:yanliang
* @Date:2024/3/11 09:39
* @Description
*/
@Data
public class DoctorListVo {
private String doctorId;
private String doctorName;
private String doctorCode;
private Long titleId;
private String title;
private Integer organId;
private String organName;
private Integer deptId;
private String deptName;
private Long stdSecondDeptId;
private String phoneNum;
private String portrait;
private Integer gender;
private String profession;
private String introduction;
private String servConfig;
private Integer organCode;
/**
* 上次选择
*/
@ApiModelProperty(value = "是否是上次签名 1是,0不是")
private Integer lastSign;
/**
* 服务金额ServiceConfigData
*/
// private ServiceConfigVo serviceConfigData;
private String doctorLabelName;
@ApiModelProperty(value = "医生是否在线 1在线 -1下线")
private Integer officeStatus;
}
package com.ebaiyihui.family.doctor.common.vo;
import lombok.Data;
/**
* @ClassName: IMMsgResultVo
* @Author:yanliang
* @Date:2024/3/13 14:27
* @Description
*/
@Data
public class IMMsgResultVo {
private String appointmentId;
private String sender;
private String receiver;
private String sendTime;
private String msgType;
private String msgContent;
private String fileName;
private String fileUrl;
private String thirdSdkAccount;
private String msgId;
private Integer duration;
private String groupId;
private Long timeStamp;
private String fromNick;
private String businessCode;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: ImInfoDetailDocResVo
* @Author:yanliang
* @Date:2024/3/13 18:17
* @Description
*/
@Data
public class ImInfoDetailDocResVo {
@ApiModelProperty("医生id")
private String doctorId;
@ApiModelProperty("医生姓名")
private String doctorName;
@ApiModelProperty("医生头像")
private String doctorPortrait;
@ApiModelProperty("患者头像")
private String patientImageUrl;
@ApiModelProperty("患者信息")
private PatientInfoVo patientInfo;
@ApiModelProperty("就诊id")
private String admId;
@ApiModelProperty("订单状态 2.进行中 3.已完成")
private Integer status;
@ApiModelProperty("科室id")
private String deptId;
@ApiModelProperty("科室名称")
private String deptName;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @ClassName: ImInfoListResVo
* @Author:yanliang
* @Date:2024/3/13 17:20
* @Description
*/
@Data
public class ImInfoListResVo {
@ApiModelProperty("就诊id")
private String admId;
@ApiModelProperty("就诊id集合")
private List<String> admIds;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("订单状态")
private Integer status;
@ApiModelProperty("订单状态描述")
private String statusDesc;
@ApiModelProperty("患者姓名")
private String patientName;
@ApiModelProperty("患者性别")
private Integer gender;
@ApiModelProperty("患者年龄")
private Integer age;
@ApiModelProperty("身份证")
private String idCard;
@ApiModelProperty("身份证")
private String patientId;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.util.List;
/**
* @ClassName: ZKfbImInfoResVo
* @Author:yanliang
* @Date:2024/3/13 14:26
* @Description
*/
@Data
@Builder
public class ImInfoResVo {
@ApiModelProperty("医生IM账号")
private String docImAccount;
@ApiModelProperty("患者IM账号")
private String patImAccount;
@ApiModelProperty("房间号")
private Long roomNum;
private String sig;
@ApiModelProperty("医生头像")
private String doctorPortrait;
@ApiModelProperty("医生姓名")
private String doctorName;
@ApiModelProperty("IM历史消息")
private List<IMMsgResultVo> iMMsgVo;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: PatientInfoVo
* @Author:yanliang
* @Date:2024/3/13 18:19
* @Description
*/
@Data
public class PatientInfoVo {
@ApiModelProperty("患者姓名")
private String patientName;
@ApiModelProperty("患者id")
private String patientId;
@ApiModelProperty("患者性别 1.男 2.女")
private Integer gender;
@ApiModelProperty("患者年龄")
private Integer age;
@ApiModelProperty("患者身份证")
private String idCard;
@ApiModelProperty("患者头像")
private String portrait;
@ApiModelProperty("患者用户id")
private String patientUserId;
@ApiModelProperty("身份证号码")
private String credNo;
@ApiModelProperty("证件类型")
private String credTypeCode;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: RequestOnlineOrOfflineVo
* @Author:yanliang
* @Date:2024/3/11 18:31
* @Description
*/
@Data
public class RequestOnlineOrOfflineVo {
@ApiModelProperty("医生id")
private String doctorId;
@ApiModelProperty("医院id")
private String hospitalId;
@ApiModelProperty("科室id")
private String deptId;
@ApiModelProperty("AppCode")
private String appCode;
@ApiModelProperty("上下线状态:1上线,-1下线")
private Integer officeStatus;
}
package com.ebaiyihui.family.doctor.common.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @ClassName: ResponseGetScheduleForWeekVo
* @Author:yanliang
* @Date:2024/3/14 16:26
* @Description
*/
@Data
public class ResponseGetScheduleForWeekVo {
@JsonFormat(pattern = "yyyy-MM-dd" ,timezone = "GMT+8")
private Date scheduleDate;
private List<ScheduleOfDayVo> scheduleOfDayVoList;
}
package com.ebaiyihui.family.doctor.common.vo;
import lombok.Data;
import java.util.List;
/**
* @ClassName: ScheduleForWeekResVo
* @Author:yanliang
* @Date:2024/3/14 16:30
* @Description
*/
@Data
public class ScheduleForWeekResVo {
private String scheduleTime;
private List<ScheduleInfoVo> scheduleInfos;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @ClassName: ScheduleInfoVo
* @Author:yanliang
* @Date:2024/3/14 16:31
* @Description
*/
@Data
public class ScheduleInfoVo {
private String doctorId;
private String doctorName;
private String deptId;
private String deptName;
@ApiModelProperty("医生头像")
private String doctorPortrait;
@ApiModelProperty("医生职称")
private String doctorProfession;
private List<ScheduleRangeAndCountVo> scheduleRangeAndCountList;
@ApiModelProperty("某医生某科室某时段创建的最早时间")
private Date createEarliestTime;
}
package com.ebaiyihui.family.doctor.common.vo;
import lombok.Data;
import java.util.List;
/**
* @ClassName: ScheduleOfDayVo
* @Author:yanliang
* @Date:2024/3/14 16:27
* @Description
*/
@Data
public class ScheduleOfDayVo {
private ScheduleTimeSaveListVo scheduleTimeSaveListVo;
private List<ScheduleRecordVo> recordVoList;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: ScheduleRangeAndCountVo
* @Author:yanliang
* @Date:2024/3/14 16:31
* @Description
*/
@Data
public class ScheduleRangeAndCountVo {
@ApiModelProperty(value = "排班id")
private Long id;
@ApiModelProperty(value = "可用号源数")
private Integer availableCount;
@ApiModelProperty(value = "总号源数")
private Integer totalCount;
@ApiModelProperty(value = "排班类型 1 上午 2下午 3夜间门诊")
private Integer scheduleRange;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "前十分钟不可预约 结束时间 1 可预约 -1 不可预约")
private Integer tenMinute;
@ApiModelProperty(value = "是否开通循环排班 1 开通 -1不开通")
private Integer isCycleSchedule;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @ClassName: ScheduleRecordVo
* @Author:yanliang
* @Date:2024/3/14 16:28
* @Description
*/
@Data
public class ScheduleRecordVo {
private Long id;
@ApiModelProperty(value = "医生ID")
private String doctorId;
@ApiModelProperty(value = "医生名称")
private String doctorName;
@ApiModelProperty(value = "总号源数")
private Integer totalCount;
@ApiModelProperty(value = "可用号源数")
private Integer availableCount;
@ApiModelProperty(value = "状态:停诊/复诊")
private Integer status;
@ApiModelProperty(value = "价格")
private BigDecimal price;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: ScheduleTimeSaveListVo
* @Author:yanliang
* @Date:2024/3/14 16:27
* @Description
*/
@Data
public class ScheduleTimeSaveListVo {
private Long id;
@ApiModelProperty("排班时段类型:1上午 2下午 3夜间")
private Integer scheduleRange;
@ApiModelProperty("排班时段开始时间")
private String startTime;
@ApiModelProperty("排班时段结束时间")
private String endTime;
}
package com.ebaiyihui.family.doctor.common.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName: ServiceConfigVo
* @Author:yanliang
* @Date:2024/3/11 09:41
* @Description
*/
@Data
public class ServiceConfigVo {
/**
* 价格
*/
private BigDecimal price;
/**
* 服务有效时间
*/
private Integer servTime;
/**
* 每日限制人数
*/
private Integer dailyLimit;
/**
* 医生回复条数限制
*/
private Integer numLimit;
/**
* 公告
*/
private String notice;
private String serviceId;
/**
* 0 全天 1 上午 2下午 3夜间门诊
*/
@ApiModelProperty(value="排班类型")
private Date scheduleDate;
/**
* 排班时间
*/
@ApiModelProperty(value="排班时间")
private Integer scheduleRange;
@ApiModelProperty("服务有效时间单位:1分钟,2小时")
private Integer timeUnit;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>byh-family-doctor</artifactId>
<groupId>com.ebaiyihui</groupId>
<relativePath>../pom.xml</relativePath>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.ebaiyihui</groupId>
<artifactId>family-doctor-server</artifactId>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.ebaiyihui</groupId>
<artifactId>family-doctor-common</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
<!--easypoi -->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.ebaiyihui</groupId>-->
<!-- <artifactId>byh-framework-service</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--swagger接口文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.github.swagger2markup</groupId>-->
<!-- <artifactId>swagger2markup</artifactId>-->
<!-- <version>1.3.3</version>-->
<!-- </dependency>-->
<!--数据库连接-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<!--fastjson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.24</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
<dependency>
<groupId>com.ning</groupId>
<artifactId>async-http-client</artifactId>
<version>1.9.40</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>com.ihospital</groupId>
<artifactId>doctoruser-service-api</artifactId>
<version>${doctoruser-api.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</exclusion>
<exclusion>
<groupId>com.hxgy.ehospital</groupId>
<artifactId>hxgy-commons-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.ebaiyihui</groupId>
<artifactId>byh-framework-service</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ebaiyihui.imforward</groupId>
<artifactId>byh-im-forward-client</artifactId>
<version>${byh-im-forward.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</exclusion>
<exclusion>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclusion>
<exclusion>
<artifactId>spring-cloud-openfeign-core</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.ihospital</groupId>
<artifactId>doctor-basedata-api</artifactId>
<version>2.0.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.ebaiyihui</groupId>-->
<!-- <artifactId>node-user-center-client</artifactId>-->
<!-- <version>${node-user-center.version}</version>-->
<!-- <exclusions>-->
<!-- <exclusion> &lt;!&ndash; declare the exclusion here &ndash;&gt;-->
<!-- <groupId>com.ebaiyihui</groupId>-->
<!-- <artifactId>byh-common-redis</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion> &lt;!&ndash; declare the exclusion here &ndash;&gt;-->
<!-- <groupId>com.hxgy.ehospital</groupId>-->
<!-- <artifactId>hxgy-ehospital-im</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!--redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--Excel文件导出-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>easyexcel</artifactId>-->
<!-- <version>2.1.3</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
<dockerDirectory>${project.basedir}/src/main/${dockerfile.dic}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
FROM byh-registry-pro:5000/byh-base:s1.3.2
VOLUME /tmp
ADD family-doctor-server-*.jar app.jar
ADD startup.sh startup.sh
RUN sh -c 'touch /app.jar'
RUN echo "Asia/Shanghai" > /etc/localtime > /etc/timezone \
&& chmod +x /startup.sh
ENTRYPOINT ["/startup.sh" ]
\ No newline at end of file
#!/bin/sh
java -Duser.timezone=GMT+08 -Dfile.encoding=UTF-8 \
-javaagent:/agent/skywalking-agent.jar \
-Dskywalking.agent.service_name=${sw_service_name} \
-Dskywalking.collector.backend_service=${sw_service_url} \
-Dskywalking.trace.ignore_path=/eureka/** \
-Djava.security.egd=file:/dev/./urandom \
-jar \
/app.jar
\ No newline at end of file
FROM byh-registry:5000/oraclejdk8:v1
VOLUME /tmp
ADD family-doctor-server-*.jar app.jar
RUN sh -c 'touch /app.jar'
RUN echo "Asia/Shanghai" > /etc/timezone
ENV JAVA_OPTS="-Duser.timezone=GMT+08 -Dfile.encoding=UTF-8"
ENTRYPOINT ["sh","-c","java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
\ No newline at end of file
package com.ebaiyihui;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @ClassName: ByhFamilyDoctorApplcation
* @Author:yanliang
* @Date:2024/3/8 14:46
* @Description
*/
@EnableDiscoveryClient
@SpringBootApplication
@EnableTransactionManagement
@EnableEurekaClient
@EnableFeignClients
@EnableCircuitBreaker
@EnableAsync
@MapperScan("com.ebaiyihui.family.doctor.server.mapper")
public class ByhFamilyDoctorApplication {
public static void main(String[] args) {
SpringApplication.run(ByhFamilyDoctorApplication.class, args);
}
}
package com.ebaiyihui.family.doctor.server.aspect;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* @program chenmt-rides
* @description:
* @author: chenmet
* @create: 2019/08/09 10:58
*/
@Slf4j
@Aspect //表明是一个切面类
@Component //将当前类注入到Spring容器内
public class LogAspect {
//xyz.chenmt.www.chenmtrides.controller包下的所有类中的所有方法,".."表示所有方法中的参数不限个数;
//切入点,其中execution用于使用切面的连接点。使用方法:execution(方法修饰符(可选)
// 返回类型 方法名 参数 异常模式(可选)) ,可以使用通配符匹配字符,*可以匹配任意字符。
@Pointcut("execution(public * com.ebaiyihui.family.doctor.server.controller.*.*(..))")
public void LogAspect(){}
//环绕通知,就是可以在执行前后都使用,这个方法参数必须为ProceedingJoinPoint,proceed()方法就是被切面的方法,
// 上面四个方法可以使用JoinPoint,JoinPoint包含了类名,被切面的方法名,参数等信息。
@Around("LogAspect()")
public Object deAround(ProceedingJoinPoint pjp) throws Throwable{
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
HttpServletRequest request = sra.getRequest();
//ip地址
String ipaddress;
if (request.getHeader("x-forwarded-for") == null) {
ipaddress = request.getRemoteAddr();
} else {
ipaddress = request.getHeader("x-forwarded-for");
}
String url = request.getRequestURL().toString();
String method = request.getMethod();
String queryString = request.getQueryString();
Object[] args = pjp.getArgs();
String params = "";
//获取请求参数集合并进行遍历拼接
if(args.length>0){
if("POST".equals(method)){
Object object = args[0];
Map map = getKeyAndValue(object);
params = JSON.toJSONString(map);
;
}else if("GET".equals(method)){
params = queryString;
}
}
Signature signature = pjp.getSignature();
MethodSignature methodSignature = (MethodSignature)signature;
Method targetMethod = methodSignature.getMethod();
Method realMethod = pjp.getTarget().getClass().getDeclaredMethod(signature.getName(), targetMethod.getParameterTypes());
ApiOperation operation=realMethod.getAnnotation(ApiOperation.class);
if(null!=operation){
log.info("请求开始===方法描述:{},请求方法:{},请求地址:{},请求ip:{},请求类型:{},请求参数:{}",operation.value(),realMethod.getName(),url,ipaddress,method,params);
}else{
log.info("请求开始===请求方法:{},请求地址:{},请求ip:{},请求类型:{},请求参数:{}",realMethod.getName(),url,ipaddress,method,params);
}
// result的值就是被拦截方法的返回值
// Object result = pjp.proceed();
// log.info("请求结束===返回值{}",JSONObject.toJSON(result));
return pjp.proceed();
}
public static Map<String, Object> getKeyAndValue(Object obj) {
Map<String, Object> map = new HashMap<String, Object>();
// 得到类对象
Class userCla = (Class) obj.getClass();
/* 得到类中的所有属性集合 */
Field[] fs = userCla.getDeclaredFields();
for (int i = 0; i < fs.length; i++) {
Field f = fs[i];
f.setAccessible(true); // 设置些属性是可以访问的
Object val;
try {
val = f.get(obj);
// 得到此属性的值
map.put(f.getName(), val);// 设置键值
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return map;
}
}
package com.ebaiyihui.family.doctor.server.common.constants;
/**
* @ClassName: CommonConstants
* @Author:yanliang
* @Date:2024/3/13 10:19
* @Description
*/
public class CommonConstants {
/**
* 性别男 - 数据库值
*/
public static final Integer GENDER_MALE_KEY = 1;
/**
* 性别男 - 页面显示值
*/
public static final String GENDER_MALE_DESC = "男";
/**
* 性别女 - 数据库值
*/
public static final Integer GENDER_FAMALE_KEY = 2;
/**
* 性别女 - 页面显示值
*/
public static final String GENDER_FAMALE_DESC = "女";
/**
* 性别未知 - 页面显示值
*/
public static final String GENDER_UNKNOWN_DESC = "未知";
/**
* 0 - 数据无效
*/
public static final Integer STATUS_INVALID = 0;
/**
* 1 - 数据有效
*/
public static final Integer STATUS_VALID = 1;
/**
* 分页显示,单页最大显示条数
*/
public static final Integer PAGE_SIZE = 10;
/**
* 支付系统业务调用成功f返回码
*/
public static final Integer PAY_SYSTEM_SUCCESS_CODE = 200;
/**
* 医生类型 - 个人
*/
public static final String DOCTOR_TYPE_PERSONAL= "个人";
public static final Integer DOCTOR_TYPE= 1;
public static final Integer PATIENT_TYPE= 1;
/**
* 默认评分
*/
public static final double SATISFACTION = 5;
public static final int INQUIRY_END_PRE = 3;
/**
* 3分钟秒数
*/
public static final int INQUIRY_END_TIME = 180;
public static final int TENMINT_TIME = 600;
/**
* im聊天条数
*/
public static final int IM_CURRENT_NUM = 3 ;
/**
* 医生超时未接待,推送给患者端APP title
*/
public static final String PATIENT_DOCTOR_OVERTIME_TITLE = "医生超时未接待";
/**
* 候诊提醒,推送给患者端APP title
*/
public static final String PATIENT_WAITE_REMIND_TITLE = "候诊提醒";
/**
* 医生向患者发起视频,推送给患者端APP title
*/
public static final String PATIENT_VIDEO_INQUIRY_TITLE = "医生邀请您视频问诊";
/**
* 医生拒绝问诊,推送给患者端APP title
*/
public static final String PATIENT_DOCTOR_REFUSE_TITLE = "医生拒绝问诊";
public static final String HOS_NAME = "hos_name";
public static final String DATA = "data";
public static final String ASC = "1";
public static final String DESC = "2";
public static final String DAY_TYPE = "1";
public static final String WEEK_TYPE = "2";
public static final String MONTH_TYPE = "3";
/**
* -1 - 数据非法
*/
public static final Integer STATUS_NOTVALID = -1;
public static final String APP_CODE = "NCZK";
public static final String ORGAN_NAME = "南昌众康医院";
public static final Long ORGAN_CODE = 130188L;
}
package com.ebaiyihui.family.doctor.server.common.constants;
/**
* @ClassName: IMInformConstants
* @Author:yanliang
* @Date:2024/3/14 15:23
* @Description
*/
public class IMInformConstants {
/**
* 推送im消息类型-系统消息
*/
public static final String INFORM_SYSTEM_MESSAGE_TYPE = "system";
/**
* 推送im消息类型-用户消息
*/
public static final String INFORM_USER_MESSAGE_TYPE = "user";
/**
* im系统调用成功
*/
public static final Integer IM_SYSTEM_SUCCESS_STATUS = 1;
/**
* 不可以跳转消息类型
*/
public static final Integer SERVICE_SYSTEM_FIXATION_TYPE = 1;
/**
* 可跳转消息类型
*/
public static final Integer SERVICE_SYSTEM_FREE_TYPE = 2;
/**
* im推送群聊消息地址
*/
public static final String PUSH_GROUP_MESSAGE_PATH = "sendMsg/pushGroupMsg";
/**
* im推送单聊消息地址
*/
public static final String PUSH_SINGLE_MESSAGE_PATH = "sendMsg/pushSingleMsg";
/**
* 医生appCode
*/
public static final String DOCTOR_APPLICATION_CODE = "EHOS_DOCTOR";
/**
* 大众appCode
*/
public static final String PATIENT_APPLICATION_CODE = "EHOS_PATIENT";
/**
* 自定义消息-病历类型
*/
public static final String CASE_HISTORY_CUSTOM_TYPE = "order";
public static final String CASE_HISTORY_CARD_TYPE = "card";
public static final String CASE_HISTORY_DOCTOR_CARD_TYPE = "doctorCard";
/**
* 自定义消息-诊疗意见
*/
public static final String MEDICAL_ADVICE_TYPE = "advice";
/**
* 自定义消息-评论类型
*/
public static final String REVIEW_TYPE = "review";
/**
* 自定义消息-检查检验医嘱类型
*/
public static final String CASE_ARC_TYPE = "arc";
/**
* 自定义消息-药品医嘱类型
*/
public static final String CASE_DRUG_TYPE = "drug";
/**
* 自定义消息-入院证类型
*/
public static final String CASE_BOOKIN_TYPE = "bookin";
/**
* im系统在线门诊(咨询)业务区分code
*/
public static final String IM_SYSTEM_BUSINESS_CODE = "zxzx";
public static final String REFERRAL_CARD = "referralCard";
/**
* 统一延迟毫秒数
*/
public static final Long COMMON_DELAY_TIME = 1000L;
public static final String TIME = "time";
public static final String REFERRAL_TIME = "referralTime";
public static final Integer REFRESH = 1;
public static final Integer NOT_REFRESH = 0;
public static final String CASE_DOCTOR_TYPE = "treatmentCard";
public static final String REFERRAL_COPY = "referralCopy";
public static final String RECOMM_SERVICE = "recommService";
public static final String BG_RECORD_DRUG = "bgRecordAndDrug";
}
package com.ebaiyihui.family.doctor.server.common.constants;
/**
* @ClassName: ImConstants
* @Author:yanliang
* @Date:2024/3/13 11:45
* @Description
*/
public class ImConstants {
/**
* im服务中查询在线咨询内容需要的code
*/
public static final String IM_QUERY_ACCOUNT_CODE = "zxzx";
/**
* 区分imaccount-医生
*/
public static final String IM_DOC_ACCOUNT_NUM = "EHOS_DOCTOR";
/**
* 区分imaccount-病人(大众)
*/
public static final String IM_PAT_ACCOUNT_NUM = "EHOS_PATIENT";
/**
* 1容联云类型
*/
public static final short IM_QUERY_TYPE_CLOOPEN = (short) 1;
/**
* 2腾讯云类型
*/
public static final short IM_QUERY_TYPE_TENCENT = (short) 2;
/**
* 推送中心成功code
*/
public static final String PUSH_CENTER_SUCCESS_CODE = "1";
/**
* 推送中大众端type
*/
public static final Short PUSH_CENTER_DZ_CODE = 0;
/**
* 推送中医生端type
*/
public static final Short PUSH_CENTER_YS_CODE = 1;
/**
* 服务提供者为个人-不是团队
*/
public static final boolean INFORM_SERVER_OF_PERSON = false;
}
package com.ebaiyihui.family.doctor.server.common.enums;
import org.apache.commons.lang.StringUtils;
/**
* @ClassName: GenderEnum
* @Author:yanliang
* @Date:2024/3/13 16:41
* @Description
*/
public enum GenderEnum {
/**
* 性别 - 男
*/
MALE("男", 1),
/**
* 性别 - 女
*/
FEMALE("女", 2);
private String desc;
private Integer value;
private GenderEnum(String desc, Integer value) {
this.desc = desc;
this.value = value;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public static String getDesc(Integer value) {
if (value == null || value < 0) {
return null;
}
for (GenderEnum genderEnum : GenderEnum.values()) {
if (genderEnum.getValue().equals(value)) {
return genderEnum.getDesc();
}
}
return null;
}
public static GenderEnum getEnum(Integer value) {
if (value == null || value < 0) {
return null;
}
for (GenderEnum genderEnum : GenderEnum.values()) {
if (genderEnum.getValue().equals(value)) {
return genderEnum;
}
}
return null;
}
public static Integer getValue(String desc) {
if (StringUtils.isBlank(desc)) {
return null;
}
for (GenderEnum genderEnum : GenderEnum.values()) {
if (genderEnum.getDesc().equals(desc)) {
return genderEnum.getValue();
}
}
return null;
}
}
package com.ebaiyihui.family.doctor.server.common.enums;
/**
* @ClassName: ScheduleRecordEnum
* @Author:yanliang
* @Date:2024/3/11 17:19
* @Description
*/
public enum ScheduleRecordEnum {
/**
*全天
*/
DAY("全天", 0),
/**
* 上午
*/
MORNING("上午", 1),
/**
* 下午
*/
AFTERNOON("下午", 2),
/**
* 晚上
*/
EVENING("晚上", 3),
//==============排班状态
/**
* 正常
*/
NORMAL("正常", 1),
/**
* 停诊
*/
TINGZHEN("停诊", 2),
/**
* 复诊
*/
VISIT("复诊", 3);
private String desc;
private Integer value;
private ScheduleRecordEnum(String desc, Integer value) {
this.desc = desc;
this.value = value;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public static String getDesc(Integer value) {
if (value == null || value < 0) {
return null;
}
for (ScheduleRecordEnum scheduleRecordEnum : ScheduleRecordEnum.values()) {
if (value.equals(scheduleRecordEnum.getValue())) {
return scheduleRecordEnum.getDesc();
}
}
return null;
}
public static ScheduleRecordEnum getEnum(Integer value) {
if (value == null || value < 0) {
return null;
}
for (ScheduleRecordEnum scheduleRecordEnum : ScheduleRecordEnum.values()) {
if (value.equals(scheduleRecordEnum.getValue())) {
return scheduleRecordEnum;
}
}
return null;
}
}
package com.ebaiyihui.family.doctor.server.common.enums;
/**
* @ClassName: StatusEnum
* @Author:yanliang
* @Date:2024/3/13 15:40
* @Description
*/
public enum StatusEnum {
IN_CONSULTATION("进行中", 2),
FINISH_APPLY("已完成", 3),
EXPIRED("已过期", 4);
private String desc;
private Integer value;
/**
* @param desc
*/
private StatusEnum(String desc, Integer value) {
this.desc = desc;
this.value = value;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public static String getDesc(Integer value) {
if (value == null || value < 0) {
return null;
}
for (StatusEnum statusEnum : StatusEnum.values()) {
if (value.equals(statusEnum.getValue())) {
return statusEnum.getDesc();
}
}
return null;
}
public static StatusEnum getEnum(Integer value) {
if (value == null || value < 0) {
return null;
}
for (StatusEnum statusEnum : StatusEnum.values()) {
if (value.equals(statusEnum.getValue())) {
return statusEnum;
}
}
return null;
}
}
package com.ebaiyihui.family.doctor.server.common.enums;
import org.apache.commons.lang.StringUtils;
/**
* @ClassName: WhetherEnum
* @Author:yanliang
* @Date:2024/3/11 17:17
* @Description
*/
public enum WhetherEnum {
/**
* 允许
*/
ALLOW("允许", 1),
/**
* 患者
*/
FORBID("禁止", -1),
EQU("相等", 0);
private String desc;
private Integer value;
private WhetherEnum(String desc, Integer value) {
this.desc = desc;
this.value = value;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public static String getDesc(Integer value) {
if (value == null || value < 0) {
return null;
}
for (WhetherEnum whetherEnum : WhetherEnum.values()) {
if (whetherEnum.getValue().equals(value)) {
return whetherEnum.getDesc();
}
}
return null;
}
public static WhetherEnum whetherEnum(Integer value) {
if (value == null || value < 0) {
return null;
}
for (WhetherEnum whetherEnum : WhetherEnum.values()) {
if (whetherEnum.getValue().equals(value)) {
return whetherEnum;
}
}
return null;
}
public static Integer getValue(String desc) {
if (StringUtils.isBlank(desc)) {
return null;
}
for (WhetherEnum whetherEnum : WhetherEnum.values()) {
if (whetherEnum.getDesc().equals(desc)) {
return whetherEnum.getValue();
}
}
return null;
}
}
package com.ebaiyihui.family.doctor.server.config;
/**
* @ClassName: Swagger2
* @Author:yanliang
* @Date:2024/3/11 09:31
* @Description
*/
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Author:yanliang
* @Date:2019/6/12 16:00
* @Description swagger配置类
*/
@EnableSwagger2
@Configuration
public class Swagger2 {
/**
* 是否开启swagger,正式环境一般是需要关闭的,可根据springboot的多环境配置进行设置
*/
@Value(value = "${swagger.enabled}")
Boolean swaggerEnabled;
/**
* swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等
*/
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
// 是否开启
.enable(swaggerEnabled).select()
//为当前包路径
.apis(RequestHandlerSelectors.basePackage("com.ebaiyihui.family.doctor.server.controller"))
.paths(PathSelectors.any())
.build().pathMapping("/");
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("家庭医生APIs")
//描述
.description("家庭医生api")
//创建人
.contact(new Contact("", "", ""))
//版本号
.version("1.0")
//描述
.build();
}
}
package com.ebaiyihui.family.doctor.server.controller;
import com.ebaiyihui.family.doctor.common.dto.QueryDoctorsDTO;
import com.ebaiyihui.family.doctor.common.vo.DoctorListVo;
import com.ebaiyihui.family.doctor.server.service.DoctorService;
import com.ebaiyihui.framework.page.PageResult;
import com.ebaiyihui.framework.response.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName: DoctorController
* @Author:yanliang
* @Date:2024/3/11 09:38
* @Description
*/
@RestController
@RequestMapping("/doctor")
@Api(tags = "医生API")
@Slf4j
public class DoctorController {
@Autowired
private DoctorService doctorService;
@ApiOperation(value = "获取医生列表和服务次数信息", notes = "医生服务feign调用")
@RequestMapping(value = "/getDoctorList", method = RequestMethod.POST)
public BaseResponse<PageResult<DoctorListVo>> getDoctorList(@RequestBody QueryDoctorsDTO reqVo,
BindingResult bindingResult) {
BaseResponse<PageResult<DoctorListVo>> doctorListVo = null;
try {
doctorListVo = doctorService.getDoctorList(reqVo);
} catch (Exception e) {
return BaseResponse.error(e.getMessage());
}
return doctorListVo;
}
}
package com.ebaiyihui.family.doctor.server.controller;
import com.ebaiyihui.family.doctor.common.dto.SignedDoctorDTO;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.service.PatientService;
import com.ebaiyihui.framework.response.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName: PatientController
* @Author:yanliang
* @Date:2024/3/13 09:49
* @Description
*/
@RestController
@RequestMapping("/patient")
@Api(tags = "患者API")
@Slf4j
public class PatientController {
@Autowired
private PatientService patientService;
@ApiOperation(value = "签约医生", notes = "医生服务feign调用")
@RequestMapping(value = "/signedDoctor", method = RequestMethod.POST)
public BaseResponse<String> signedDoctor(@RequestBody SignedDoctorDTO reqVo,
BindingResult bindingResult) {
BaseResponse<String> response = null;
try {
response = patientService.signedDoctor(reqVo);
} catch (Exception e) {
return BaseResponse.error(e.getMessage());
}
return response;
}
@ApiOperation(value = "签约医生", notes = "医生服务feign调用")
@RequestMapping(value = "/getSignedDoctor", method = RequestMethod.POST)
public BaseResponse<PatientSignEntity> getSignedDoctor(@RequestBody SignedDoctorDTO reqVo,
BindingResult bindingResult) {
BaseResponse<PatientSignEntity> response = null;
try {
response = patientService.getSignedDoctor(reqVo);
} catch (Exception e) {
return BaseResponse.error(e.getMessage());
}
return response;
}
}
package com.ebaiyihui.family.doctor.server.controller;
import com.ebaiyihui.family.doctor.common.dto.ImInfoDetailDocReqDTO;
import com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO;
import com.ebaiyihui.family.doctor.common.dto.RequestGetDoctorOfficeStatusDTO;
import com.ebaiyihui.family.doctor.common.dto.RequestServiceConfigDTO;
import com.ebaiyihui.family.doctor.common.vo.ImInfoDetailDocResVo;
import com.ebaiyihui.family.doctor.common.vo.ImInfoListResVo;
import com.ebaiyihui.family.doctor.common.vo.RequestOnlineOrOfflineVo;
import com.ebaiyihui.family.doctor.common.vo.ImInfoResVo;
import com.ebaiyihui.family.doctor.server.service.PatientSignService;
import com.ebaiyihui.family.doctor.server.service.ServiceConfigService;
import com.ebaiyihui.family.doctor.server.util.PageUtil;
import com.ebaiyihui.framework.response.BaseResponse;
import com.ebaiyihui.imforward.client.vo.IMQueryMsgReqVO;
import com.ebaiyihui.imforward.client.vo.IMSingleMsgResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @ClassName: PatientSignController
* @Author:yanliang
* @Date:2024/3/13 14:12
* @Description
*/
@RestController
@RequestMapping("/patientSign")
@Api(tags = "患者签名API")
@Slf4j
public class PatientSignController {
@Autowired
private PatientSignService patientSignService;
@Autowired
private ServiceConfigService serviceConfigService;
@ApiOperation(value = "查询im聊天消息记录", httpMethod = "POST", notes = "查询im消息记录")
@RequestMapping(value = "/getMsg", method = RequestMethod.POST)
public BaseResponse<List<IMSingleMsgResultVO>> getAllMsgContent(@RequestBody IMQueryMsgReqVO reqVO) {
return patientSignService.getAllMsgContent(reqVO);
}
@ApiOperation("查询IM相关信息")
@GetMapping("/v1/queryImInfo")
public BaseResponse<ImInfoResVo> queryImInfo(@RequestParam("admId") String admId) {
return patientSignService.queryImInfo(admId);
}
@ApiOperation("医生AppIM列表")
@PostMapping("/v1/queryImInfoList")
public BaseResponse<PageUtil<ImInfoListResVo>> queryImInfoList(@RequestBody ImInfoListDocReqDTO param) {
return patientSignService.queryImInfoList(param);
}
@ApiOperation("医生IM详情")
@PostMapping("/v1/queryImInfoDetail")
public BaseResponse<ImInfoDetailDocResVo> queryImInfoDetail(@RequestBody ImInfoDetailDocReqDTO param) {
return patientSignService.queryImInfoDetail(param);
}
@ApiOperation(value = "查询医生上下线状态", notes = "查询医生上下线状态")
@RequestMapping(value = "/v1/getDoctorOfficeStatus", method = RequestMethod.POST)
public BaseResponse<RequestOnlineOrOfflineVo> getDoctorOfficeStatus(@RequestBody RequestGetDoctorOfficeStatusDTO requestGetDoctorOfficeStatusDTO) {
RequestOnlineOrOfflineVo onlineOrOfflineVo = new RequestOnlineOrOfflineVo();
try {
onlineOrOfflineVo = serviceConfigService.getDoctorOfficeStatus(requestGetDoctorOfficeStatusDTO);
} catch (Exception e) {
return BaseResponse.error(e.getMessage());
}
return BaseResponse.success(onlineOrOfflineVo);
}
@ApiOperation(value = "医生上下线", notes = "医生上线下线操作")
@RequestMapping(value = "/v2/officeOnlineOrOffline", method = RequestMethod.POST)
public BaseResponse<RequestOnlineOrOfflineVo> officeOnlineOrOffline(@RequestBody RequestOnlineOrOfflineVo requestOnlineOrOfflineVo) {
RequestOnlineOrOfflineVo onlineOrOfflineVo = new RequestOnlineOrOfflineVo();
try {
onlineOrOfflineVo = serviceConfigService.officeOnlineOrOffline(requestOnlineOrOfflineVo);
} catch (Exception e) {
return BaseResponse.error(e.getMessage());
}
return BaseResponse.success(onlineOrOfflineVo);
}
@ApiOperation("添加/修改医生服务信息")
@RequestMapping(value = "/saveServiceInfo", method = RequestMethod.POST)
//@Log(value = "在线问诊",enable = true,type = LogActionType.ADD)
public BaseResponse<Object> saveServiceInfo(@RequestBody @Validated RequestServiceConfigDTO serviceConfigDTO,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return BaseResponse.error(bindingResult.getFieldError().getDefaultMessage());
}
return serviceConfigService.saveServiceInfo(serviceConfigDTO);
}
}
package com.ebaiyihui.family.doctor.server.controller;
import com.ebaiyihui.family.doctor.common.dto.InsertScheduleRecordReqDTO;
import com.ebaiyihui.family.doctor.common.dto.RequestGetScheduleForWeekDTO;
import com.ebaiyihui.family.doctor.common.dto.ScheduleForWeekReqDTO;
import com.ebaiyihui.family.doctor.common.vo.ResponseGetScheduleForWeekVo;
import com.ebaiyihui.family.doctor.common.vo.ScheduleForWeekResVo;
import com.ebaiyihui.family.doctor.server.service.ScheduleRecordService;
import com.ebaiyihui.framework.response.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**
* @ClassName: ScheduleRecordController
* @Author:yanliang
* @Date:2024/3/14 16:19
* @Description
*/
@Slf4j
@RestController
@RequestMapping(value = "/schedulerecord")
@Api(tags = "排班API")
public class ScheduleRecordController {
@Autowired
private ScheduleRecordService scheduleRecordService;
@RequestMapping(value = "/insert", method = RequestMethod.POST)
@ApiOperation(value = "增加排班")
public BaseResponse<String> insert(@RequestBody @Valid InsertScheduleRecordReqDTO record) {
return scheduleRecordService.insert(record);
}
@RequestMapping(value = "/getscheduleforweek", method = RequestMethod.POST)
@ApiOperation("获取医生一周的排班")
public BaseResponse<List<ResponseGetScheduleForWeekVo>> getScheduleForWeek(@RequestBody RequestGetScheduleForWeekDTO requestGetScheduleForWeekDTO) {
return scheduleRecordService.getScheduleForWeek(requestGetScheduleForWeekDTO);
}
@RequestMapping(value = "/scheduleForWeekNew", method = RequestMethod.POST)
@ApiOperation("管理端排班列表")
public BaseResponse<List<ScheduleForWeekResVo>> scheduleForWeekNew(@RequestBody ScheduleForWeekReqDTO scheduleForWeekReqDTO) {
return scheduleRecordService.scheduleForWeekNew(scheduleForWeekReqDTO);
}
}
package com.ebaiyihui.family.doctor.server.entity;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: PatientEntity
* @Author:yanliang
* @Date:2024/3/13 16:25
* @Description
*/
@Data
public class PatientEntity {
private String id;
private Date createTime;
private Date updateTime;
private String patientName;
private String credNo;
private String phone;
private String birthDates;
private Integer gender;
private Integer patientType;
private String userId;
}
package com.ebaiyihui.family.doctor.server.entity;
import lombok.Data;
import java.util.Date;
/**
* @ClassName: PatientSign
* @Author:yanliang
* @Date:2024/3/11 13:54
* @Description
*/
@Data
public class PatientSignEntity {
private Long id;
private String admId;
private Date createTime;
private Date updateTime;
private String appCode;
private Long organId;
private String organName;
private String patientId;
private String patientUserId;
private String patientName;
private String patientPhone;
private String credNo;
private Long doctorId;
private String doctorName;
private Long deptId;
private String deptName;
private Integer signStatus;
private Integer subStatus;
private Integer status;
}
package com.ebaiyihui.family.doctor.server.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* @ClassName: ScheduleRecord
* @Author:yanliang
* @Date:2024/3/11 13:55
* @Description
*/
@Data
//@TableName("schedule_record")
public class ScheduleRecordEntity {
// @TableId
private Long id;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
@ApiModelProperty(value = "医院id")
@NotBlank(message = "医院id")
private String hospitalId;
@ApiModelProperty(value = "医院名称")
@NotBlank(message = "医院名称")
private String hospitalName;
@ApiModelProperty(value = "医生ID")
@NotBlank(message = "医生ID")
private String doctorId;
@ApiModelProperty(value = "医生名称")
@NotBlank(message = "医生名称")
private String doctorName;
@ApiModelProperty(value = "二级科室编码")
@NotBlank(message = "二级科室编码")
private String deptId;
@ApiModelProperty(value = "二级科室名称")
@NotBlank(message = "二级科室名称")
private String deptName;
@ApiModelProperty(value = "总号源数")
@NotBlank(message = "总号源数")
private Integer totalCount;
@ApiModelProperty(value = "可用号源数")
@NotBlank(message = "可用号源数")
private Integer availableCount;
@ApiModelProperty(value = "号源日期")
@NotBlank(message = "号源日期")
@JsonFormat(pattern = "yyyy-MM-dd" ,timezone = "GMT+8")
private Date scheduleDate;
@ApiModelProperty(value = "排班类型0 全天 1 上午 2下午 3夜间门诊")
private Integer scheduleRange;
@ApiModelProperty(value = "排班状态")
private Integer status;
private String organCode;
@ApiModelProperty("业务类型")
private Integer servType;
@ApiModelProperty("排班开始时间")
private String startTime;
@ApiModelProperty("排班结束时间")
private String endTime;
@ApiModelProperty("是否开启循环排班 1开启 -1关闭")
private Integer isCycleSchedule;
}
package com.ebaiyihui.family.doctor.server.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* @ClassName: InquiryServiceConfig
* @Author:yanliang
* @Date:2024/3/11 13:55
* @Description
*/
@Data
public class ServiceConfigEntity {
private String id;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 医生/团队id
*/
@ApiModelProperty("医生Id")
@NotBlank(message = "医生id不能为空")
private String doctorId;
private String organId;
@ApiModelProperty("状态")
private Integer status;
private String appCode;
@ApiModelProperty("是否有排班1/-1")
private Integer isSchedule;
@ApiModelProperty("上下线状态")
private Integer officeStatus;
private String serviceCode;
private Long deptId;
@ApiModelProperty("医生头像")
private String doctorPortrait;
@ApiModelProperty("医生职称")
private String doctorProfession;
}
package com.ebaiyihui.family.doctor.server.exception;
/**
* @ClassName: BusinessException
* @Author:yanliang
* @Date:2024/3/13 13:47
* @Description
*/
public class BusinessException extends RuntimeException {
/**
* 错误码
*/
private String errorCode;
public BusinessException(String errorMsg) {
super(errorMsg);
}
public BusinessException(String errorCode, String errorMsg) {
super(errorMsg);
this.errorCode = errorCode;
}
public BusinessException(String errorCode, Throwable error) {
super(error);
this.errorCode = errorCode;
}
public BusinessException(String errorCode, String errorMsg, Throwable error) {
super(errorMsg, error);
this.errorCode = errorCode;
}
public String getErrorCode() {
return errorCode;
}
}
//package com.ebaiyihui.family.doctor.server.exception;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//
///**
// * @ClassName: ExceptionHandle
// * @Author:yanliang
// * @Date:2024/3/13 13:48
// * @Description
// */
//@ControllerAdvice
//public class ExceptionHandle {
//
// private Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
//
// /**
// * 异常处理
// *
// * @param e 异常
// * @return 统一错误响应
// */
// @ExceptionHandler(value = Exception.class)
// @ResponseBody
// public ResultData<?> handle(Exception e) {
// logger.error(e.getMessage(), e);
//
// // 业务异常
// if (e instanceof BusinessException) {
// BusinessException businessException = (BusinessException) e;
// return new ResultData<>().error(businessException.getMessage());
// }
// return new ResultData<>().error("未知错误");
// }
//}
package com.ebaiyihui.family.doctor.server.feign;
import com.doctoruser.api.DoctorInfoApi;
import org.springframework.cloud.openfeign.FeignClient;
/**
* @ClassName: DoctorInfofeignClient
* @Author:yanliang
* @Date:2024/3/13 14:48
* @Description
*/
@FeignClient(name = "doctoruser-service-api",url ="${cloudDoctorUrl}")
public interface DoctorInfofeignClient extends DoctorInfoApi {
}
package com.ebaiyihui.family.doctor.server.feign;
import com.doctor.basedata.api.DoctorWorkingServiceApi;
import org.springframework.cloud.openfeign.FeignClient;
/**
* @ClassName: DoctorWorkingServiceClient
* @Author:yanliang
* @Date:2024/3/11 17:26
* @Description
*/
@FeignClient(name = "doctoruser-service-api",url ="${cloudDoctorUrl}")
public interface DoctorWorkingServiceClient extends DoctorWorkingServiceApi {
}
package com.ebaiyihui.family.doctor.server.feign;
import com.ebaiyihui.imforward.client.interfaces.IMPushMsgApi;
import org.springframework.cloud.openfeign.FeignClient;
/**
* @ClassName: IMPushMsgFeignClient
* @Author:yanliang
* @Date:2024/3/14 15:58
* @Description
*/
@FeignClient(name = "IMSYS-FORWARD")
public interface IMPushMsgFeignClient extends IMPushMsgApi {
}
package com.ebaiyihui.family.doctor.server.feign;
import com.ebaiyihui.imforward.client.interfaces.IMSyncMsgApi;
import org.springframework.cloud.openfeign.FeignClient;
/**
* @ClassName: IMSyncMsgClient
* @Author:yanliang
* @Date:2024/3/13 14:16
* @Description
*/
@FeignClient(name = "IMSYS-FORWARD")
public interface IMSyncMsgClient extends IMSyncMsgApi {
}
package com.ebaiyihui.family.doctor.server.feign;
import com.ebaiyihui.imforward.client.interfaces.IMClientApi;
import org.springframework.cloud.openfeign.FeignClient;
/**
* @ClassName: ImApiFeignClient
* @Author:yanliang
* @Date:2024/3/13 11:48
* @Description
*/
@FeignClient(name = "IMSYS-FORWARD")
public interface ImApiFeignClient extends IMClientApi {
}
package com.ebaiyihui.family.doctor.server.feign;
import com.doctoruser.api.UserApi;
import org.springframework.cloud.openfeign.FeignClient;
/**
* @ClassName: UserApiFeignClient
* @Author:yanliang
* @Date:2024/3/13 11:21
* @Description
*/
@FeignClient(name = "doctoruser-service-api",url ="${cloudDoctorUserUrl}")
public interface UserApiFeignClient extends UserApi {
}
package com.ebaiyihui.family.doctor.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ebaiyihui.family.doctor.server.entity.PatientEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName: PatientMapper
* @Author:yanliang
* @Date:2024/3/13 16:29
* @Description
*/
@Mapper
public interface PatientMapper extends BaseMapper<PatientEntity> {
}
package com.ebaiyihui.family.doctor.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO;
import com.ebaiyihui.family.doctor.common.vo.ImInfoListResVo;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @ClassName: PatientSignMapper
* @Author:yanliang
* @Date:2024/3/11 14:02
* @Description
*/
@Mapper
public interface PatientSignMapper extends BaseMapper<PatientSignEntity> {
List<ImInfoListResVo> queryImInfoList(ImInfoListDocReqDTO param);
}
package com.ebaiyihui.family.doctor.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ebaiyihui.family.doctor.server.entity.ScheduleRecordEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName: ScheduleRecordMapper
* @Author:yanliang
* @Date:2024/3/11 14:18
* @Description
*/
@Mapper
public interface ScheduleRecordMapper extends BaseMapper<ScheduleRecordEntity> {
}
package com.ebaiyihui.family.doctor.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ebaiyihui.family.doctor.server.entity.ServiceConfigEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName: ServiceConfigMapper
* @Author:yanliang
* @Date:2024/3/14 10:06
* @Description
*/
@Mapper
public interface ServiceConfigMapper extends BaseMapper<ServiceConfigEntity> {
}
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.common.dto.QueryDoctorsDTO;
import com.ebaiyihui.family.doctor.common.vo.DoctorListVo;
import com.ebaiyihui.framework.page.PageResult;
import com.ebaiyihui.framework.response.BaseResponse;
/**
* @ClassName: DoctorService
* @Author:yanliang
* @Date:2024/3/11 09:48
* @Description
*/
public interface DoctorService {
BaseResponse<PageResult<DoctorListVo>> getDoctorList(QueryDoctorsDTO reqVo);
}
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.framework.response.BaseResponse;
import com.ebaiyihui.imforward.client.vo.IMQueryTargetSdkAccountRspVO;
/**
* @ClassName: ImChatTemplate
* @Author:yanliang
* @Date:2024/3/13 11:15
* @Description
*/
public interface ImChatTemplate {
BaseResponse createImSession(PatientSignEntity patientSignEntity);
/**
* 通过admId获取Im账号
*
* @param admId 就诊ID
* @param imAppCode IM设备类型
* @return IM账号
*/
IMQueryTargetSdkAccountRspVO queryImAccount(String admId, String imAppCode, String doctorId);
void doctorPrompted(String admId);
}
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.common.dto.SignedDoctorDTO;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.framework.response.BaseResponse;
/**
* @ClassName: PatientService
* @Author:yanliang
* @Date:2024/3/13 09:51
* @Description
*/
public interface PatientService {
BaseResponse<String> signedDoctor(SignedDoctorDTO reqVo);
BaseResponse<PatientSignEntity> getSignedDoctor(SignedDoctorDTO reqVo);
}
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.common.dto.ImInfoDetailDocReqDTO;
import com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO;
import com.ebaiyihui.family.doctor.common.vo.ImInfoDetailDocResVo;
import com.ebaiyihui.family.doctor.common.vo.ImInfoListResVo;
import com.ebaiyihui.family.doctor.common.vo.ImInfoResVo;
import com.ebaiyihui.family.doctor.server.util.PageUtil;
import com.ebaiyihui.framework.response.BaseResponse;
import com.ebaiyihui.imforward.client.vo.IMQueryMsgReqVO;
import com.ebaiyihui.imforward.client.vo.IMSingleMsgResultVO;
import java.util.List;
/**
* @ClassName: PatientSignService
* @Author:yanliang
* @Date:2024/3/13 14:14
* @Description
*/
public interface PatientSignService {
/**
* 同步会话消息
*
* @param reqVO
* @return
*/
BaseResponse<List<IMSingleMsgResultVO>> getAllMsgContent(IMQueryMsgReqVO reqVO);
BaseResponse<ImInfoResVo> queryImInfo(String admId);
BaseResponse<PageUtil<ImInfoListResVo>> queryImInfoList(ImInfoListDocReqDTO param);
BaseResponse<ImInfoDetailDocResVo> queryImInfoDetail(ImInfoDetailDocReqDTO param);
}
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.common.dto.InsertScheduleRecordReqDTO;
import com.ebaiyihui.family.doctor.common.dto.RequestGetScheduleForWeekDTO;
import com.ebaiyihui.family.doctor.common.dto.ScheduleForWeekReqDTO;
import com.ebaiyihui.family.doctor.common.vo.ResponseGetScheduleForWeekVo;
import com.ebaiyihui.family.doctor.common.vo.ScheduleForWeekResVo;
import com.ebaiyihui.framework.response.BaseResponse;
import java.util.List;
/**
* @ClassName: ScheduleRecordService
* @Author:yanliang
* @Date:2024/3/14 16:21
* @Description
*/
public interface ScheduleRecordService {
BaseResponse<String> insert(InsertScheduleRecordReqDTO record);
BaseResponse<List<ResponseGetScheduleForWeekVo>> getScheduleForWeek(RequestGetScheduleForWeekDTO requestGetScheduleForWeekDTO);
BaseResponse<List<ScheduleForWeekResVo>> scheduleForWeekNew(ScheduleForWeekReqDTO scheduleForWeekReqDTO);
}
package com.ebaiyihui.family.doctor.server.service;
import com.ebaiyihui.family.doctor.common.dto.RequestGetDoctorOfficeStatusDTO;
import com.ebaiyihui.family.doctor.common.dto.RequestServiceConfigDTO;
import com.ebaiyihui.family.doctor.common.vo.RequestOnlineOrOfflineVo;
import com.ebaiyihui.framework.response.BaseResponse;
/**
* @ClassName: InquiryServiceConfigService
* @Author:yanliang
* @Date:2024/3/12 09:40
* @Description
*/
public interface ServiceConfigService {
RequestOnlineOrOfflineVo getDoctorOfficeStatus(RequestGetDoctorOfficeStatusDTO requestGetDoctorOfficeStatusDTO);
RequestOnlineOrOfflineVo officeOnlineOrOffline(RequestOnlineOrOfflineVo requestOnlineOrOfflineVo);
BaseResponse<Object> saveServiceInfo(RequestServiceConfigDTO serviceConfigDTO);
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doctor.basedata.api.vo.BusinessDoctorPageReqVo;
import com.doctor.basedata.api.vo.DoctorBasicRespVO;
import com.ebaiyihui.family.doctor.common.dto.QueryDoctorsDTO;
import com.ebaiyihui.family.doctor.common.vo.DoctorListVo;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.feign.DoctorWorkingServiceClient;
import com.ebaiyihui.family.doctor.server.mapper.PatientSignMapper;
import com.ebaiyihui.family.doctor.server.mapper.ScheduleRecordMapper;
import com.ebaiyihui.family.doctor.server.service.DoctorService;
import com.ebaiyihui.family.doctor.server.service.ServiceConfigService;
import com.ebaiyihui.framework.page.PageResult;
import com.ebaiyihui.framework.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @ClassName: DoctorServiceImpl
* @Author:yanliang
* @Date:2024/3/11 09:49
* @Description
*/
@Service
@Slf4j
public class DoctorServiceImpl implements DoctorService {
@Autowired
private PatientSignMapper patientSignMapper;
@Autowired
private ScheduleRecordMapper scheduleRecordMapper;
@Autowired
private ServiceConfigService serviceConfigService;
@Autowired
private DoctorWorkingServiceClient doctorWorkingServiceClient;
@Override
public BaseResponse<PageResult<DoctorListVo>> getDoctorList(QueryDoctorsDTO reqVo) {
log.info("查询医生入参:" + JSONObject.toJSONString(reqVo));
// if (StringUtils.isNotEmpty(reqVo.getSearchParam()) && StringUtils.isNotEmpty(reqVo.getUserId())) {
// redisHistory(reqVo);
// }
//执业机构
String wOrganId = reqVo.getOrganId().toString();
//2。查询上次选择医生
QueryWrapper<PatientSignEntity> wrapper = new QueryWrapper<>();
PatientSignEntity patientSignEntity = new PatientSignEntity();
patientSignEntity.setPatientUserId(reqVo.getUserId());
patientSignEntity.setOrganId(reqVo.getOrganId());
patientSignEntity.setSignStatus(1);
wrapper.setEntity(patientSignEntity);
PatientSignEntity entity = patientSignMapper.selectOne(wrapper);
boolean LastSignFlag = false;
log.info("患者上次绑定-用来处理上次选择的医生:entity{}", JSON.toJSONString(entity));
PageResult pageResult = new PageResult();
//先开服务 再看排班 前面为准
List<DoctorBasicRespVO> docBaseList = getDoctors(reqVo);
if (CollectionUtils.isEmpty(docBaseList)) {
pageResult.setContent(new ArrayList());
pageResult.setPageNum(reqVo.getPageNum());
pageResult.setPageSize(reqVo.getPageSize());
return BaseResponse.success(pageResult);
}
log.info("用于循环的集合{}", JSON.toJSONString(docBaseList));
List<DoctorListVo> doctorListVos = new ArrayList<>();
for (DoctorBasicRespVO dto : docBaseList) {
Integer doctorId = dto.getXId().intValue();
DoctorListVo doctorListVo = new DoctorListVo();
//评分
BeanUtils.copyProperties(dto, doctorListVo);
doctorListVo.setTitle(dto.getStandardTitle());
doctorListVo.setDoctorId(doctorId.toString());
doctorListVo.setOrganId(Integer.valueOf(wOrganId));
doctorListVo.setDeptId(dto.getDeptId().intValue());
doctorListVo.setPhoneNum(dto.getTelephone());
doctorListVo.setLastSign(new Integer("0"));
//上下线
// getDoctorOfficeStatusAndDoctorLabel(reqVo, dto.getDeptId(), dto.getOrganId(), doctorId, doctorListVo);
//如果有模糊搜索医生姓名时, 不置顶上次选择的医生,有科室帅选 的时候 不置顶上次选择的 医生
//去除掉上次选择的医生数据
if (null != entity
&& entity.getDoctorId().equals(dto.getXId().toString())
&& StringUtils.isEmpty(reqVo.getSearchParam())
&& null == (reqVo.getOrganDeptId())) {
log.info("去除掉上次选择的医生======" + JSON.toJSONString(dto));
LastSignFlag = true;
continue;
}
//处理 有搜索参数时,并且是上次选择 的医生
if (null != entity && entity.getDoctorId().equals(dto.getXId().toString())) {
if (StringUtils.isNotEmpty(reqVo.getSearchParam()) || null != (reqVo.getOrganDeptId())) {
doctorListVo.setLastSign(new Integer("1"));
doctorListVos.add(0, doctorListVo);
continue;
}
}
doctorListVos.add(doctorListVo);
}
//针对上次选择的医生进行处理
//如果有模糊搜索医生姓名时, 不置顶上次选择的医生,有科室帅选 的时候 不置顶上次选择的 医生
// if (LastSignFlag) {
// isLastSign(reqVo, doctorListVos, wOrganId, entity, doctorZxwzService);
// }
pageResult.setPageNum(reqVo.getPageNum());
pageResult.setPageSize(doctorListVos.size());
// pageResult.setPageSize(reqVo.getPageSize());
// pageResult.setTotalPages(businessDoctorPage.getData().getTotalPages());
// pageResult.setTotal(businessDoctorPage.getData().getTotal());
pageResult.setContent(doctorListVos);
return BaseResponse.success(pageResult);
}
// private void redisHistory(QueryFamousDotDTO reqVo) {
//
// //把搜索的数据存在map中
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
// String value = simpleDateFormat.format(new Date());
// log.info("===========value===========:" + value);
// //先判断redis中的map是否有值
// String redisValue = redisUtil.get(reqVo.getUserId());
// //如果redis中没有map,则新建map,存入redis
// if (null == redisValue) {
// Map map = new LinkedHashMap<String, String>();
// map.put(reqVo.getSearchParam(), value);
// log.info("map的大小为:" + map.size());
// //存在map中,将map存入redis
// String jsonString = JSON.toJSONString(map);
// redisUtil.set(reqVo.getUserId(), jsonString);
// //如果redis里面有map,直接拿出来,存入数据,在放入redis
// } else {
// Map<String, String> redisMap = JSONObject.parseObject(redisValue, Map.class);
// //如果大小比5小,直接数据放入map中
// if (redisMap.size() < 5) {
// //查看map中是否有插入的key
// boolean flag = redisMap.containsKey(reqVo.getSearchParam());
// //则表示map中不包含,可以直接插入
// if (!flag) {
// redisMap.put(reqVo.getSearchParam(), value);
// } else {
// //如果map中包含,则先删除原有的,在重新放入
// redisMap.remove(reqVo.getSearchParam());
// redisMap.put(reqVo.getSearchParam(), value);
// }
// redisMap.put(reqVo.getSearchParam(), value);
// String jsonString = JSON.toJSONString(redisMap);
// redisUtil.set(reqVo.getUserId(), jsonString);
// log.info("redis中size<5的map的大小为:" + redisMap.size());
// } else {
// //讲map按照value降序,时间最早的就是最后一个
// Map<String, String> mapResult = sortByValue(redisMap, true);
// log.info("排序后的map有序map为:" + mapResult);
//
// boolean flag = mapResult.containsKey(reqVo.getSearchParam());
// //则表示map中不包含,可以直接插入
// if (!flag) {
// //获取redis的最后一个元素
// Field tail = null;
// try {
// tail = mapResult.getClass().getDeclaredField("tail");
// } catch (NoSuchFieldException e) {
// e.printStackTrace();
// }
// tail.setAccessible(true);
// Map.Entry<String, String> entry = null;
// try {
// entry = (Map.Entry<String, String>) tail.get(mapResult);
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// String key = entry.getKey();
// log.info("删除的最早的一条记录的key是:" + key);
// mapResult.remove(key);
// log.info("删除一条记录的map为" + mapResult);
//
// mapResult.put(reqVo.getSearchParam(), value);
// } else {
// //如果map中包含,则先删除原有的,在重新放入
// mapResult.remove(reqVo.getSearchParam());
// mapResult.put(reqVo.getSearchParam(), value);
// }
//
// log.info("重新放入一条记录的map为" + mapResult);
//
// String jsonString = JSON.toJSONString(mapResult);
// redisUtil.set(reqVo.getUserId(), jsonString);
// log.info("redis中map的大小为:" + redisMap.size());
// }
// }
// }
private List<DoctorBasicRespVO> getDoctors(QueryDoctorsDTO reqVo) {
List<DoctorBasicRespVO> docBaseList = new ArrayList<>();
List<DoctorBasicRespVO> resultData = new ArrayList<>();
List<Long> depts = reqVo.getDepts();
if (!CollectionUtils.isEmpty(depts)) {
log.info("多科室显示");
depts.stream().forEach(i -> {
BusinessDoctorPageReqVo businessDoctorPageReqVo = new BusinessDoctorPageReqVo();
reqVo.setSeq(1);
reqVo.setStatus(1);
BeanUtils.copyProperties(reqVo, businessDoctorPageReqVo);
businessDoctorPageReqVo.setOrganDeptId(i);
businessDoctorPageReqVo.setServiceCode(reqVo.getServiceCodes());
BaseResponse<PageResult<DoctorBasicRespVO>> doctors = doctorWorkingServiceClient.getBusinessDoctorBaseInfoPage(businessDoctorPageReqVo);
if (!CollectionUtils.isEmpty(doctors.getData().getContent())) {
List<DoctorBasicRespVO> vos = doctors.getData().getContent();
resultData.addAll(vos);
}
});
} else {
BusinessDoctorPageReqVo businessDoctorPageReqVo = new BusinessDoctorPageReqVo();
reqVo.setSeq(1);
reqVo.setStatus(1);
BeanUtils.copyProperties(reqVo, businessDoctorPageReqVo);
businessDoctorPageReqVo.setServiceCode(reqVo.getServiceCodes());
log.info("医生数据入参" + JSON.toJSONString(businessDoctorPageReqVo));
BaseResponse<PageResult<DoctorBasicRespVO>> businessDoctorPage =
doctorWorkingServiceClient.getBusinessDoctorBaseInfoPage(businessDoctorPageReqVo);
log.info("医生数据出参" + JSON.toJSONString(businessDoctorPage.getData()));
if (null == businessDoctorPage.getData()) {
return new ArrayList<>();
}
resultData.addAll(businessDoctorPage.getData().getContent());
if (CollectionUtils.isEmpty(resultData)) {
return new ArrayList<>();
}
//List<DoctorBasicRespVO> content = businessDoctorPage.getData().getContent();
List<DoctorBasicRespVO> collect = resultData.stream().filter(vo -> ("5").equals(vo.getAduitStatus())).collect(Collectors.toList());
docBaseList.addAll(collect);
}
return docBaseList;
}
// private void getDoctorOfficeStatusAndDoctorLabel(QueryFamousDotDTO reqVo, Long deptId, Long organId, Integer doctorId, DoctorListVo doctorListVo) {
// //3.查询医生上下线状态
// RequestGetDoctorOfficeStatusVo requestGetDoctorOfficeStatus = new RequestGetDoctorOfficeStatusVo();
// requestGetDoctorOfficeStatus.setAppCode(reqVo.getAppCode());
// requestGetDoctorOfficeStatus.setDoctorId(doctorId.toString());
// requestGetDoctorOfficeStatus.setHospitalId(reqVo.getOrganId().toString());
// RequestOnlineOrOfflineVo requestOnlineOrOfflineVo = inquiryServiceConfigService.getDoctorOfficeStatus(requestGetDoctorOfficeStatus);
// if (null != requestOnlineOrOfflineVo) {
// doctorListVo.setOfficeStatus(requestOnlineOrOfflineVo.getOfficeStatus());
// log.info("医生是否在线:" + requestOnlineOrOfflineVo.getOfficeStatus());
// }
// }
// private void isLastSign(QueryFamousDotDTO reqVo, List<DoctorListVo> doctorListVos, String wOrganId, PatientSignEntity patientSignEntity, ZXWZServiceBo doctorZxwzService) {
// // 查询医生的服务是否可购买 新版更新为从数据库获取
// QueryWrapper<InquiryServiceConfigEntity> queryWrapper = new QueryWrapper<>();
// InquiryServiceConfigEntity wrapperEntity = new InquiryServiceConfigEntity();
// wrapperEntity.setDoctorId(orderEntity.getDoctorId());
// wrapperEntity.setOrganId(orderEntity.getHospitalId());
// wrapperEntity.setStatus(CommonConstants.STATUS_VALID.intValue());
// wrapperEntity.setServiceCode(reqVo.getServiceCodes());
// wrapperEntity.setDeptId(orderEntity.getDeptId());
// log.info("wrapperEntity:{}" + JSON.toJSONString(wrapperEntity));
// queryWrapper.setEntity(wrapperEntity);
// queryWrapper.last("limit 1");
// if (StringUtils.isNotEmpty(reqVo.getReserveTime()) && !"1".equals(reqVo.getReserveTime())) {
// queryWrapper.in("is_schedule", 2, 3);
// }
// InquiryServiceConfigEntity inquiryServiceConfigEntity = inquiryServiceConfigService.getOne(queryWrapper);
//
// if (null != inquiryServiceConfigEntity) {
// log.info("inquiryServiceConfigEntity:{}" + inquiryServiceConfigEntity.toString());
// //查询上次选择的医生数据
// //查询医生数据
// // 封装 获取医生信息的请求类
// QueryPersonnelInfoReq queryPersonnelInfoReq = new QueryPersonnelInfoReq();
// queryPersonnelInfoReq.setDoctorId(orderEntity.getDoctorId());
//
// // Feign请求获取医生信息
// BaseResponse<PersonnelInfo> personnelInfoBaseResponse =
// doctorCilent.queryPersonnelInfo(queryPersonnelInfoReq);
// log.info("req :{}", JSON.toJSONString(personnelInfoBaseResponse));
//
// //查询医生评分
// DoctorListVo doctorListVo = new DoctorListVo();
//
// //判断团队服务
// BaseResponse<Boolean> docIsLearder = doctorTemInfomService.getDocIsLearder(orderEntity.getDoctorId(), wOrganId);
// List<GetPersonTeamDetialResVo> personTeamNew = doctorTemInfomService.getPersonTeamNew(orderEntity.getDoctorId());
// if (docIsLearder.isSuccess() && docIsLearder.getData() && personTeamNew != null) {
// doctorListVo.setDoctorType(DoctorTypeEnum.TEAM.getValue());
// } else {
// doctorListVo.setDoctorType(DoctorTypeEnum.PERSONAL.getValue());
// }
//
// //装填doctorListVo
// PersonnelInfo baseResponseData = personnelInfoBaseResponse.getData();
// BeanUtils.copyProperties(baseResponseData, doctorListVo);
//
// ServiceConfigVo serviceConfigVo = new ServiceConfigVo();
// serviceConfigVo.setPrice(doctorZxwzService.getServicePrice());
// serviceConfigVo.setDailyLimit(doctorZxwzService.getNumLimit());
// serviceConfigVo.setNumLimit(doctorZxwzService.getReplyLimit());
// serviceConfigVo.setServTime(doctorZxwzService.getEffectiveTime());
// doctorListVo.setServiceConfigData(serviceConfigVo);
//
// doctorListVo.setOrganId(Integer.valueOf(wOrganId));
// doctorListVo.setLastSelect(new Integer("1"));
// doctorListVo.setDoctorId(baseResponseData.getDoctorId());
// String doctorScorel = "5.0";
// BaseResponse<String> doctorAverageScorel =
// doctorUserEvaluationFeignClient.getDoctorAverageScore(doctorListVo.getDoctorId());
// if (null != doctorAverageScorel && null != doctorAverageScorel.getData()) {
// doctorScorel = "0.0".equals(doctorAverageScorel.getData()) ? "5.0" : doctorAverageScorel.getData();
// }
// doctorListVo.setSatisfaction(doctorScorel);
// doctorListVo.setServTimes(getDoctorServTimes(orderEntity.getDoctorId(), orderEntity.getOrganId(),
// orderEntity.getServType()));
// QueryWrapper query = new QueryWrapper();
// AdmissionEntity wrapper = new AdmissionEntity();
// wrapper.setDoctorId(baseResponseData.getDoctorId());
// List list = new ArrayList();
// list.add(1);
// list.add(2);
// wrapper.setServType(orderEntity.getServType());
// query.setEntity(wrapper);
// query.in("status", list);
// int inService = baseInquiryAdmissionService.count(query);
// Long deptId = baseResponseData.getDeptId().longValue();
// Long organId = baseResponseData.getOrganId().longValue();
// Integer doctorId = Integer.parseInt(baseResponseData.getDoctorId());
// getDoctorOfficeStatusAndDoctorLabel(reqVo, deptId, organId, doctorId, doctorListVo);
// doctorListVo.setInService(inService);
// //把数据放到医生列表第一列
// doctorListVos.add(0, doctorListVo);
// }
// }
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doctoruser.api.pojo.base.dto.doctor.QueryPersonnelInfoReq;
import com.doctoruser.api.pojo.base.vo.doctor.PersonnelInfo;
import com.doctoruser.api.pojo.vo.UserInfoByDoctorIdRespVO;
import com.doctoruser.api.pojo.vo.UserInfoByUserIdRespVO;
import com.ebaiyihui.family.doctor.common.bo.*;
import com.ebaiyihui.family.doctor.common.dto.DoctorIdDTO;
import com.ebaiyihui.family.doctor.server.common.constants.CommonConstants;
import com.ebaiyihui.family.doctor.server.common.constants.IMInformConstants;
import com.ebaiyihui.family.doctor.server.common.constants.ImConstants;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.exception.BusinessException;
import com.ebaiyihui.family.doctor.server.feign.DoctorInfofeignClient;
import com.ebaiyihui.family.doctor.server.feign.IMPushMsgFeignClient;
import com.ebaiyihui.family.doctor.server.feign.ImApiFeignClient;
import com.ebaiyihui.family.doctor.server.feign.UserApiFeignClient;
import com.ebaiyihui.family.doctor.server.mapper.PatientSignMapper;
import com.ebaiyihui.family.doctor.server.service.ImChatTemplate;
import com.ebaiyihui.family.doctor.server.util.JsonUtil;
import com.ebaiyihui.framework.response.BaseResponse;
import com.ebaiyihui.imforward.client.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @ClassName: ImChatTemplateImpl
* @Author:yanliang
* @Date:2024/3/13 11:15
* @Description
*/
@Service
@Slf4j
public class ImChatTemplateImpl implements ImChatTemplate {
@Autowired
private UserApiFeignClient userApiFeignClient;
@Autowired
private DoctorInfofeignClient doctorInfofeignClient;
@Autowired
private ImApiFeignClient imApiFeignClient;
@Autowired
private IMPushMsgFeignClient imPushMsgFeignClient;
@Autowired
private PatientSignMapper patientSignMapper;
@Override
public BaseResponse createImSession(PatientSignEntity patientSignEntity) {
//创建 IM Session
log.info("=======创建会话开始=====");
log.info("创建会话开始时间:{}" + System.currentTimeMillis());
log.info("patientSignEntity :{}", patientSignEntity);
BaseResponse response = createPersonalImSession(patientSignEntity);
log.info("创建会话返回:{}" + JSON.toJSONString(response));
log.info("=======创建会话结束=====");
log.info("创建会话结束时间:{}" + System.currentTimeMillis());
return response;
}
@Override
public IMQueryTargetSdkAccountRspVO queryImAccount(String admId, String imAppCode, String doctorId) {
log.info("admId:" + admId);
log.info("imAppCode:" + imAppCode);
if (StringUtils.isEmpty(admId)) {
return null;
}
QueryWrapper<PatientSignEntity> wrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(admId);
wrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(wrapper);
if (patientSignEntity == null) {
return null;
}
log.info("patientSignEntity:" + patientSignEntity.toString());
IMQueryTargetSdkAccountReqVO imQueryTargetSdkAccountReqVO = new IMQueryTargetSdkAccountReqVO();
if (ImConstants.IM_DOC_ACCOUNT_NUM.equals(imAppCode)) {
// 查询医生账号
BaseResponse<UserInfoByDoctorIdRespVO> response = userApiFeignClient.getUserInfoByDoctorId(doctorId);
log.info("response:{}", JsonUtil.convertObject(response));
if (response.isSuccess()) {
UserInfoByDoctorIdRespVO userInfoByDoctorIdRespVO = response.getData();
log.info("userInfoByDoctorIdRespVO:{}" + JSONObject.toJSONString(userInfoByDoctorIdRespVO));
imQueryTargetSdkAccountReqVO.setUserId(userInfoByDoctorIdRespVO.getUserId());
}
} else if (ImConstants.IM_PAT_ACCOUNT_NUM.equals(imAppCode)) {
// 查询患者账号
imQueryTargetSdkAccountReqVO.setUserId(patientSignEntity.getPatientUserId());
}
imQueryTargetSdkAccountReqVO.setBusiCode(ImConstants.IM_QUERY_ACCOUNT_CODE);
imQueryTargetSdkAccountReqVO.setAppCode(imAppCode);
imQueryTargetSdkAccountReqVO.setTreatmentId(admId);
log.info("imQueryTargetSdkAccountReqVO:{}" + JSONObject.toJSONString(imQueryTargetSdkAccountReqVO));
BaseResponse<IMQueryTargetSdkAccountRspVO> response = imApiFeignClient
.qeuryTagetSdkAccount(imQueryTargetSdkAccountReqVO);
log.info("imApiFeignClient-response{}", JSON.toJSONString(response));
if (response.isSuccess()) {
return response.getData();
}
log.warn("IM账号查询 - 查询失败 - response:{}", JsonUtil.convertObject(response));
return null;
}
@Override
public void doctorPrompted(String admId) {
String content = "";
List<MessageInfo> messageInfos = new ArrayList<>();
PatientSignInfo patientSignInfo = getPatientSignInfo(admId);
messageInfos.add(getDoctorInformRefreshPatientParam(patientSignInfo, IMInformConstants.REFRESH));
PersonImInformReq parameter = new PersonImInformReq();
parameter.setMessageInfos(messageInfos);
parameter.setAdmissionId(admId);
parameter.setBusiCode(IMInformConstants.IM_SYSTEM_BUSINESS_CODE);
log.info("推送家庭医生提示语推送:{}" + JSON.toJSONString(parameter.getMessageInfos()));
if (personUserImInform(parameter, content, null)) {
log.info("推送家庭医生提示语推送成功,admissionId:{}", admId);
}
}
/**
* 获取im推送需要的信息
* 1.serviceType 2.0 病人账号 2.1 病人名字 3.3 医生生名字 账号 6.拒绝理由 7.订单号
* 团队的 1.groupId (注意状态,销毁了就不能发) 2.serviceType 3.0 病人用户账号 3.1 病人名字
* 4.团队的所有医生bean(id,账号,姓名) 5.团队名字 6 拒绝理由 7订单号
*
* @param admId
* @return
* @description 公共方法
*/
private PatientSignInfo getPatientSignInfo(String admId) {
QueryWrapper<PatientSignEntity> wrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(admId);
wrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(wrapper);
if (patientSignEntity == null) {
log.error("IM INFORM ERROR : 没有查询到就诊信息,admId:{}", admId);
return new PatientSignInfo();
}
PatientSignInfo patientSignInfo = new PatientSignInfo();
BeanUtils.copyProperties(patientSign, patientSignInfo);
// 获取医生基本信息
QueryPersonnelInfoReq queryPersonnelInfoReq = new QueryPersonnelInfoReq();
queryPersonnelInfoReq.setDoctorId(String.valueOf(patientSignEntity.getDoctorId()));
BaseResponse<PersonnelInfo> doctorInfo = doctorInfofeignClient.queryPersonnelInfo(queryPersonnelInfoReq);
// 调用用户系统查询医生userId
UserInfoByUserIdRespVO userInfoByUserIdRespVO = queryDocAccountInfo(String.valueOf(patientSignEntity.getDoctorId()));
if (userInfoByUserIdRespVO == null) {
log.error("IM INFORM ERROR : 获取医生信息失败 doctorId:{}", String.valueOf(patientSignEntity.getDoctorId()));
return new PatientSignInfo();
}
if (null == doctorInfo && !doctorInfo.isSuccess()) {
log.error("IM INFORM ERROR : 获取医生信息失败 doctorId:{}", String.valueOf(patientSignEntity.getDoctorId()));
return new PatientSignInfo();
}
patientSignInfo.setDoctorUserId(userInfoByUserIdRespVO.getUserId());
log.info("patientSignInfo:{}" + JSON.toJSONString(patientSignInfo));
return patientSignInfo;
}
private <T> MessageInfo getDoctorInformRefreshPatientParam(PatientSignInfo patientSignInfo, Integer isRefresh) {
String patientUserId = patientSignInfo.getPatientUserId();
if (org.apache.commons.lang3.StringUtils.isEmpty(patientUserId)) {
log.error("IM INFORM ERROR : 无法查询到接收人信息");
return new MessageInfo();
}
MessageInfo messageInfo = new MessageInfo();
Message<T> message = new Message<>();
// message.setData(content);
// messageInfo.setMessage(message);
message.setApplicationCode(IMInformConstants.IM_SYSTEM_BUSINESS_CODE);
messageInfo.setSingleAccount(newAccount(IMInformConstants.PATIENT_APPLICATION_CODE, patientUserId));
messageInfo.setSelfAccount(newAccount(IMInformConstants.DOCTOR_APPLICATION_CODE,
patientSignInfo.getDoctorUserId()));
messageInfo.setMessage(message);
return messageInfo;
}
private <T> MessageInfo getInformRefreshPatientParam(PatientSignInfo patientSignInfo, T content, Integer isRefresh) {
String patientUserId = patientSignInfo.getPatientUserId();
if (org.apache.commons.lang3.StringUtils.isEmpty(patientUserId)) {
log.error("IM INFORM ERROR : 无法查询到接收人信息");
return new MessageInfo();
}
MessageInfo messageInfo = new MessageInfo();
Message<T> message = new Message<>();
message.setMessageType(IMInformConstants.SERVICE_SYSTEM_FIXATION_TYPE);
message.setAdmissionId(patientSignInfo.getAdmId());
message.setApplicationCode(IMInformConstants.IM_SYSTEM_BUSINESS_CODE);
message.setIsRefresh(isRefresh);
message.setData(content);
messageInfo.setMessage(message);
message.setApplicationCode(IMInformConstants.IM_SYSTEM_BUSINESS_CODE);
messageInfo.setSingleAccount(newAccount(IMInformConstants.PATIENT_APPLICATION_CODE, patientUserId));
messageInfo.setSelfAccount(newAccount(IMInformConstants.DOCTOR_APPLICATION_CODE,
patientSignInfo.getDoctorUserId()));
messageInfo.setMessage(message);
return messageInfo;
}
private AccountVO newAccount(String appCode, String userId) {
AccountVO accountVO = new AccountVO();
accountVO.setAppCode(appCode);
accountVO.setUserId(userId);
return accountVO;
}
/**
* 推送医生消息
*
* @param param
* @return
*/
private boolean personUserImInform(PersonImInformReq param, String content, Long syncFlag) {
List<MessageInfo> messageInfos = param.getMessageInfos();
if (messageInfos == null || messageInfos.isEmpty()) {
log.error("IM INFORM ERROR : 没有可发送的消息");
return false;
}
List<PushSingleMsgDataVO> msgSingleDatas = new ArrayList<>();
messageInfos.forEach(e -> {
PushSingleMsgDataVO msgsingleData = new PushSingleMsgDataVO();
//医生发送消息
msgsingleData.setActionType(IMInformConstants.INFORM_USER_MESSAGE_TYPE);
msgsingleData.setFromAccount(e.getSelfAccount());
msgsingleData.setToAccount(e.getSingleAccount());
if (Objects.nonNull(syncFlag)) {
msgsingleData.setSyncFlag(syncFlag);
}
msgsingleData.setMessage(content);
msgSingleDatas.add(msgsingleData);
});
PushSingleMsgReqVO parameter = new PushSingleMsgReqVO();
parameter.setBusiCode(param.getBusiCode());
parameter.setUniqueId(param.getAdmissionId());
parameter.setMsgData(msgSingleDatas);
// 发送IM单人推送
log.info("推送入参:{}" + JSON.toJSONString(parameter));
boolean pushFlag = pushSingleIm(parameter);
if (pushFlag != true) {
log.info("IM INFORM ERROR : im 调用im系统推送失败");
return false;
}
return true;
}
/**
* @param reqVO 请求参数
* @return boolean 发送结果
* @description: 发送IM单人推送
* @author fangyueguo
* @date 2019年02月19日
*/
private boolean pushSingleIm(PushSingleMsgReqVO reqVO) {
log.info("调用IM第三方reqVO:{}" + JSON.toJSONString(reqVO));
BaseResponse<?> response = imPushMsgFeignClient.pushSingleMsg(reqVO);
log.info("发送IM单人推送:{}", response.toString());
return response.isSuccess();
}
private BaseResponse createPersonalImSession(PatientSignEntity patientSignEntity) {
BaseResponse baseResponse = new BaseResponse();
String doctorId = String.valueOf(patientSignEntity.getDoctorId());
log.info("DoctorId:{}" + doctorId);
UserInfoByUserIdRespVO docAccountInfo = queryDocAccountInfo(doctorId);
if (docAccountInfo == null) {
// throw new BusinessException("创建IMsession失败,调用查询医生userId失败,未查询到医生信息!");
}
log.info("开始创建单人im账号");
DoctorIdDTO doctorIdVo = new DoctorIdDTO();
doctorIdVo.setDoctorId(doctorId);
ImAccountCreateReq imAccountCreateReq = new ImAccountCreateReq(patientSignEntity.getAdmId(),
doctorId, patientSignEntity.getPatientId(),
docAccountInfo.getUserId(), patientSignEntity.getPatientUserId(), patientSignEntity.getAppCode());
IMSaveSessionReqVO imSaveSessionReqVO = createImSessionParam(imAccountCreateReq);
log.info("创建im入参{}", JSONObject.toJSONString(imSaveSessionReqVO));
BaseResponse<?> imResponse = null;
if (null != imSaveSessionReqVO) {
log.info("创建im请求开始");
imResponse = imApiFeignClient.saveIMSession(imSaveSessionReqVO);
log.info("创建im请求结果:{}", JsonUtil.convertObject(imResponse));
} else {
throw new BusinessException("createImSession fail!");
}
return imResponse;
}
private UserInfoByUserIdRespVO queryDocAccountInfo(String doctorId) {
BaseResponse<UserInfoByDoctorIdRespVO> response = userApiFeignClient.getUserInfoByDoctorId(doctorId);
log.info("response:{}", JsonUtil.convertObject(response));
UserInfoByUserIdRespVO userInfoByUserIdRespVO = new UserInfoByUserIdRespVO();
if (response.isSuccess()) {
userInfoByUserIdRespVO.setUserId(response.getData().getUserId());
log.info("UserInfoByUserIdRespVO===>{}", JSON.toJSONString(userInfoByUserIdRespVO));
return userInfoByUserIdRespVO;
}
return null;
}
/**
* 创建IM Session参数
*
* @param req 传入数据
* @author Fu Chao
*/
private IMSaveSessionReqVO createImSessionParam(ImAccountCreateReq req) {
IMSaveSessionReqVO reqVO = new IMSaveSessionReqVO();
reqVO.setBusiCode(ImConstants.IM_QUERY_ACCOUNT_CODE);
reqVO.setSdkType(ImConstants.IM_QUERY_TYPE_TENCENT);
reqVO.setTreatmentId(req.getAdmId());
reqVO.setBusiNodeCode(req.getAppCode());
reqVO.setSaveType(true);
IMSessionMemberVO memberOfDoc = new IMSessionMemberVO();
List<IMSessionMemberVO> datas = new ArrayList<>();
memberOfDoc.setAppCode(ImConstants.IM_DOC_ACCOUNT_NUM);
memberOfDoc.setDoctorId(CommonConstants.DOCTOR_TYPE.toString());
memberOfDoc.setPatientId(CommonConstants.STATUS_INVALID.toString());
memberOfDoc.setUserId(req.getDoctorUserId());
datas.add(memberOfDoc);
IMSessionMemberVO memberOfPatient = new IMSessionMemberVO();
memberOfPatient.setAppCode(ImConstants.IM_PAT_ACCOUNT_NUM);
memberOfPatient.setDoctorId(CommonConstants.STATUS_INVALID.toString());
memberOfPatient.setPatientId(CommonConstants.PATIENT_TYPE.toString());
memberOfPatient.setUserId(req.getPatientUserId());
datas.add(memberOfPatient);
reqVO.setMemberList(datas);
return reqVO;
}
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ebaiyihui.family.doctor.common.dto.SignedDoctorDTO;
import com.ebaiyihui.family.doctor.server.common.constants.CommonConstants;
import com.ebaiyihui.family.doctor.server.common.enums.StatusEnum;
import com.ebaiyihui.family.doctor.server.entity.PatientEntity;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.exception.BusinessException;
import com.ebaiyihui.family.doctor.server.mapper.PatientMapper;
import com.ebaiyihui.family.doctor.server.mapper.PatientSignMapper;
import com.ebaiyihui.family.doctor.server.service.ImChatTemplate;
import com.ebaiyihui.family.doctor.server.service.PatientService;
import com.ebaiyihui.family.doctor.server.util.IDCardUtil;
import com.ebaiyihui.family.doctor.server.util.UUIDUtil;
import com.ebaiyihui.framework.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @ClassName: PatientServiceImpl
* @Author:yanliang
* @Date:2024/3/13 09:51
* @Description
*/
@Service
@Slf4j
public class PatientServiceImpl implements PatientService {
@Autowired
private PatientSignMapper patientSignMapper;
@Autowired
private PatientMapper patientMapper;
@Autowired
private ImChatTemplate imChatTemplate;
@Override
public BaseResponse<String> signedDoctor(SignedDoctorDTO reqVo) {
String orderId = UUIDUtil.generateViewId();
String admId = UUIDUtil.getUUID();
String patientId = "jtys_" + reqVo.getIdCard();
String patientUserId = orderId + "_jtys";
QueryWrapper<PatientEntity> wrapper = new QueryWrapper<>();
PatientEntity patient = new PatientEntity();
patient.setId(reqVo.getPatientId());
wrapper.setEntity(patient);
PatientEntity patientEntity = patientMapper.selectOne(wrapper);
if (Objects.isNull(patientEntity)) {
patientEntity = new PatientEntity();
patientEntity.setId(patientId);
patientEntity.setPatientName(reqVo.getName());
patientEntity.setPhone(reqVo.getPhone());
patientEntity.setPatientType(CommonConstants.PATIENT_TYPE);
patientEntity.setGender(Integer.valueOf(IDCardUtil.getGenderForInteger(reqVo.getIdCard())));
patientEntity.setBirthDates(IDCardUtil.getBirthByIdCard(reqVo.getIdCard()));
patientEntity.setCredNo(reqVo.getIdCard());
patientEntity.setUserId(patientUserId);
log.info("数据库不存在添加患者: {}", JSON.toJSONString(patientEntity));
patientMapper.insert(patientEntity);
} else {
patientId = patientEntity.getId();
patientUserId = patientEntity.getUserId();
}
// 处理换绑医生
if (Objects.nonNull(reqVo.getAdmId())) {
QueryWrapper<PatientSignEntity> psWrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(admId);
psWrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(psWrapper);
if (Objects.nonNull(patientSignEntity)) {
patientSignEntity.setStatus(StatusEnum.FINISH_APPLY.getValue());
patientSignEntity.setSignStatus(3);
patientSignEntity.setSubStatus(2);
patientSignMapper.updateById(patientSignEntity);
}
}
PatientSignEntity patientSignEntity = new PatientSignEntity();
patientSignEntity.setAdmId(admId);
patientSignEntity.setAppCode(CommonConstants.APP_CODE);
patientSignEntity.setOrganId(CommonConstants.ORGAN_CODE);
patientSignEntity.setOrganName(CommonConstants.ORGAN_NAME);
patientSignEntity.setDoctorId(reqVo.getDoctorId());
patientSignEntity.setDoctorName(reqVo.getDoctorName());
patientSignEntity.setDeptId(reqVo.getDeptId());
patientSignEntity.setDeptName(reqVo.getDeptName());
patientSignEntity.setSignStatus(reqVo.getSignStatus());
patientSignEntity.setPatientPhone(reqVo.getPhone());
patientSignEntity.setCredNo(reqVo.getIdCard());
patientSignEntity.setPatientId(patientId);
patientSignEntity.setPatientUserId(patientUserId);
patientSignMapper.insert(patientSignEntity);
//创建IM
BaseResponse createImResponse = imChatTemplate.createImSession(patientSignEntity);
if (!createImResponse.isSuccess()) {
log.info("创建IM失败:{}", createImResponse.getMsg());
throw new BusinessException("创建IM失败");
}
// if (2 == reqVo.getSignStatus()){
// imChatTemplate.doctorPrompted(admId);
// }
return BaseResponse.success(admId);
}
@Override
public BaseResponse<PatientSignEntity> getSignedDoctor(SignedDoctorDTO reqVo) {
QueryWrapper<PatientSignEntity> psWrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(reqVo.getAdmId());
psWrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(psWrapper);
if (null == patientSignEntity) {
throw new BusinessException("未查询到签约医生信息!");
}
return BaseResponse.success(patientSignEntity);
}
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doctoruser.api.pojo.base.dto.doctor.QueryPersonnelInfoReq;
import com.doctoruser.api.pojo.base.vo.doctor.PersonnelInfo;
import com.ebaiyihui.family.doctor.common.dto.ImInfoDetailDocReqDTO;
import com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO;
import com.ebaiyihui.family.doctor.common.vo.*;
import com.ebaiyihui.family.doctor.server.common.constants.ImConstants;
import com.ebaiyihui.family.doctor.server.common.enums.StatusEnum;
import com.ebaiyihui.family.doctor.server.entity.PatientEntity;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.feign.DoctorInfofeignClient;
import com.ebaiyihui.family.doctor.server.feign.IMSyncMsgClient;
import com.ebaiyihui.family.doctor.server.feign.ImApiFeignClient;
import com.ebaiyihui.family.doctor.server.mapper.PatientMapper;
import com.ebaiyihui.family.doctor.server.mapper.PatientSignMapper;
import com.ebaiyihui.family.doctor.server.service.ImChatTemplate;
import com.ebaiyihui.family.doctor.server.service.PatientSignService;
import com.ebaiyihui.family.doctor.server.util.IDCardUtil;
import com.ebaiyihui.family.doctor.server.util.PageUtil;
import com.ebaiyihui.framework.response.BaseResponse;
import com.ebaiyihui.imforward.client.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName: PatientSignServiceImpl
* @Author:yanliang
* @Date:2024/3/13 14:14
* @Description
*/
@Service
@Slf4j
public class PatientSignServiceImpl implements PatientSignService {
@Autowired
private IMSyncMsgClient imSyncMsgClient;
@Autowired
private ImApiFeignClient imApiFeignClient;
@Autowired
private DoctorInfofeignClient doctorCilent;
@Autowired
private PatientSignMapper patientSignMapper;
@Autowired
private PatientMapper patientMapper;
@Autowired
private ImChatTemplate imChatTemplate;
@Override
public BaseResponse<List<IMSingleMsgResultVO>> getAllMsgContent(IMQueryMsgReqVO reqVO) {
log.info("同步会话消息入参" + JSON.toJSONString(reqVO));
BaseResponse<List<IMSingleMsgResultVO>> listBaseResponse = imSyncMsgClient.queryImMsg(reqVO);
log.info("同步会话消息出参" + JSON.toJSONString(listBaseResponse));
if (!listBaseResponse.isSuccess()) {
log.info("imSyncMsgClient.queryImMsg: " + listBaseResponse.toString());
return BaseResponse.error(listBaseResponse.getMsg());
}
if (listBaseResponse.getData() == null) {
return BaseResponse.success(new ArrayList<>());
}
List<IMSingleMsgResultVO> imMsgResultVOList = listBaseResponse.getData();
for (IMSingleMsgResultVO imSingleMsgResultVO : imMsgResultVOList) {
try {
JSONObject jsonObject =
JSONObject.parseObject(imSingleMsgResultVO.getMsgContent());
if (jsonObject.get("msgId") != null && StringUtils.isNotEmpty(jsonObject.get("msgId").toString())) {
String msgId = jsonObject.get("msgId").toString();
imSingleMsgResultVO.setMsgId(msgId);
}
} catch (Exception e) {
continue;
}
}
log.info("查询到结果为:{}" + imMsgResultVOList.toString());
return BaseResponse.success(imMsgResultVOList);
}
@Override
public BaseResponse<ImInfoResVo> queryImInfo(String admId) {
QueryWrapper<PatientSignEntity> wrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(admId);
wrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(wrapper);
IMQueryTargetSdkAccountRspVO docImAccount = imChatTemplate.queryImAccount(admId, ImConstants.IM_DOC_ACCOUNT_NUM, String.valueOf(patientSignEntity.getDoctorId()));
IMQueryTargetSdkAccountRspVO patImAccount = imChatTemplate.queryImAccount(admId, ImConstants.IM_PAT_ACCOUNT_NUM, String.valueOf(patientSignEntity.getDoctorId()));
IMQueryUserLoginReqVO reqVO = new IMQueryUserLoginReqVO();
reqVO.setAppCode(ImConstants.IM_PAT_ACCOUNT_NUM);
reqVO.setUserId(patientSignEntity.getPatientUserId());
BaseResponse<IMQueryUserLoginRspVO> imSysResult = imApiFeignClient.queryUserLogin(reqVO);
log.info("获取IM登录信息:{}", imSysResult);
IMQueryMsgReqVO imQueryMsgReqVO = new IMQueryMsgReqVO();
imQueryMsgReqVO.setAppCode("EHOS_PATIENT");
imQueryMsgReqVO.setUserId(patientSignEntity.getPatientUserId());
imQueryMsgReqVO.setBusinessCode("zxzx");
imQueryMsgReqVO.setMsgType("1");
imQueryMsgReqVO.setPageSize(999);
imQueryMsgReqVO.setSortOrder("ASC");
ImInfoResVo resVo = ImInfoResVo.builder()
.docImAccount(docImAccount.getSdkAccount())
.patImAccount(patImAccount.getSdkAccount())
.roomNum(docImAccount.getRoomNum())
.sig(imSysResult.getData().getSig())
.doctorName(patientSignEntity.getDoctorName())
.build();
QueryPersonnelInfoReq queryPersonnelInfoReq = new QueryPersonnelInfoReq();
queryPersonnelInfoReq.setDoctorId(String.valueOf(patientSignEntity.getDoctorId()));
BaseResponse<PersonnelInfo> res = doctorCilent.queryPersonnelInfo(queryPersonnelInfoReq);
if (res.isSuccess()) {
resVo.setDoctorPortrait(res.getData().getPortrait());
}
List<String> appointmentId = new ArrayList<>();
appointmentId.add(admId);
imQueryMsgReqVO.setAppointmentId(appointmentId);
BaseResponse<List<IMSingleMsgResultVO>> allMsgContent = getAllMsgContent(imQueryMsgReqVO);
if (allMsgContent.isSuccess() && Objects.nonNull(allMsgContent.getData())) {
List<IMMsgResultVo> imMsgResultVos = new ArrayList<>();
List<IMSingleMsgResultVO> msgResultVOS = allMsgContent.getData();
msgResultVOS.forEach(
msgResultVO -> {
IMMsgResultVo imMsgResultVo = new IMMsgResultVo();
BeanUtils.copyProperties(msgResultVO, imMsgResultVo);
imMsgResultVos.add(imMsgResultVo);
}
);
resVo.setIMMsgVo(imMsgResultVos);
}
return BaseResponse.success(resVo);
}
@Override
public BaseResponse<PageUtil<ImInfoListResVo>> queryImInfoList(ImInfoListDocReqDTO param) {
param.setPageNum((param.getPageNum() - 1) * param.getPageSize());
List<ImInfoListResVo> records = patientSignMapper.queryImInfoList(param);
//根据患者id分组
Map<String, List<ImInfoListResVo>> collect =
records.stream().collect(Collectors.groupingBy(ImInfoListResVo::getPatientId));
List<ImInfoListResVo> resVo = new ArrayList<>();
for (String key : collect.keySet()) {
List<ImInfoListResVo> zkFbImInfoListResVos = collect.get(key);
List<String> admIds = zkFbImInfoListResVos.stream().map(ImInfoListResVo::getAdmId).collect(Collectors.toList());
ImInfoListResVo record = zkFbImInfoListResVos.get(0);
Integer age = IDCardUtil.getAge(record.getIdCard());
Integer gender = IDCardUtil.getGenderForInteger(record.getIdCard());
record.setAge(age);
record.setGender(gender);
String statusDesc = StatusEnum.getDesc(record.getStatus());
record.setStatusDesc(statusDesc);
record.setStatus(record.getStatus());
record.setAdmIds(admIds);
resVo.add(record);
}
resVo = resVo.stream().sorted(Comparator.comparing(ImInfoListResVo::getUpdateTime).reversed()).collect(Collectors.toList());
PageUtil pageUtil = new PageUtil();
pageUtil.setList(resVo);
// pageUtil.setTotal(total);
return BaseResponse.success(pageUtil);
}
@Override
public BaseResponse<ImInfoDetailDocResVo> queryImInfoDetail(ImInfoDetailDocReqDTO param) {
ImInfoDetailDocResVo resVo = new ImInfoDetailDocResVo();
//订单信息
QueryWrapper<PatientSignEntity> psWrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(param.getAdmissionId());
psWrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(psWrapper);
if (Objects.isNull(patientSignEntity) || Objects.isNull(patientSignEntity)) {
return BaseResponse.error("未查询到签约医生信息");
}
resVo.setDoctorId(String.valueOf(patientSignEntity.getDoctorId()));
resVo.setAdmId(patientSignEntity.getAdmId());
resVo.setStatus(patientSignEntity.getStatus());
resVo.setDeptId(patientSignEntity.getDeptId().toString());
resVo.setDeptName(patientSignEntity.getDeptName());
//患者信息
PatientEntity patientEntity = patientMapper.selectById(patientSign.getPatientId());
PatientInfoVo patientInfoVo = new PatientInfoVo();
patientInfoVo.setPatientName(patientEntity.getPatientName());
patientInfoVo.setPatientId(patientEntity.getId());
patientInfoVo.setGender(IDCardUtil.getGenderForInteger(patientEntity.getCredNo()));
patientInfoVo.setAge(IDCardUtil.getAge(patientEntity.getCredNo()));
patientInfoVo.setCredNo(patientEntity.getCredNo());
patientInfoVo.setPatientUserId(patientSignEntity.getPatientUserId());
patientInfoVo.setPortrait("");
resVo.setPatientInfo(patientInfoVo);
// 获取医生基本信息
QueryPersonnelInfoReq queryPersonnelInfoReq = new QueryPersonnelInfoReq();
queryPersonnelInfoReq.setDoctorId(String.valueOf(patientSignEntity.getDoctorId()));
BaseResponse<PersonnelInfo> res =
doctorCilent.queryPersonnelInfo(queryPersonnelInfoReq);
if (null != res && res.isSuccess()) {
resVo.setDoctorName(res.getData().getDoctorName());
resVo.setDoctorPortrait(res.getData().getPortrait());
}
return BaseResponse.success(resVo);
}
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doctoruser.api.pojo.base.dto.doctor.QueryPersonnelInfoReq;
import com.doctoruser.api.pojo.base.vo.doctor.PersonnelInfo;
import com.ebaiyihui.family.doctor.common.bo.DoctorInfo;
import com.ebaiyihui.family.doctor.common.dto.*;
import com.ebaiyihui.family.doctor.common.vo.*;
import com.ebaiyihui.family.doctor.server.common.enums.WhetherEnum;
import com.ebaiyihui.family.doctor.server.entity.ScheduleRecordEntity;
import com.ebaiyihui.family.doctor.server.entity.ServiceConfigEntity;
import com.ebaiyihui.family.doctor.server.feign.DoctorInfofeignClient;
import com.ebaiyihui.family.doctor.server.mapper.ScheduleRecordMapper;
import com.ebaiyihui.family.doctor.server.service.ScheduleRecordService;
import com.ebaiyihui.family.doctor.server.util.DateUtils;
import com.ebaiyihui.framework.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName: ScheduleRecordServiceImpl
* @Author:yanliang
* @Date:2024/3/14 16:22
* @Description
*/
@Service
@Slf4j
public class ScheduleRecordServiceImpl implements ScheduleRecordService {
@Autowired
private ScheduleRecordMapper scheduleRecordMapper;
@Autowired
private DoctorInfofeignClient doctorCilent;
@Override
public BaseResponse<String> insert(InsertScheduleRecordReqDTO record) {
String currentDate = DateUtils.getCurrentDateSimpleToString();
Date dateNow = null;
Date startRes = null;
Date endRes = null;
try {
dateNow = DateUtils.strToDate(currentDate, "yyyy-MM-dd");
startRes = DateUtils.strToDate(record.getScheduleDate(), "yyyy-MM-dd");
endRes = DateUtils.strToDate(record.getScheduleDateEnd(), "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
if (dateNow.after(startRes)) {
return BaseResponse.error("新增排班日期需大于等于当前日期");
}
List<DoctorInfoForScheduleDTO> doctorInfoForScheduleList = record.getDoctorInfoForSchedule();
List<ScheduleRangeAndTimeDTO> scheduleRangeTimeList = record.getScheduleRangeAndTime();
List<String> dates = new ArrayList<>();
List<String> dateReq = DateUtils.getDateRange(startRes, endRes);
log.info("dateReq{}", JSON.toJSONString(dateReq));
List<String> allDates = DateUtils.getOneDayNextWeek(dateReq, 3);
log.info("allDates{}", JSON.toJSONString(allDates));
if (WhetherEnum.ALLOW.getValue().equals(record.getIsCycleSchedule())) {
dates.addAll(allDates);
} else {
dates.addAll(dateReq);
}
log.info("dates{}", JSON.toJSONString(dates));
for (DoctorInfoForScheduleDTO doctorInfo : doctorInfoForScheduleList) {
//查出此科室此医生 此时段 所有排班日期
QueryWrapper<ScheduleRecordEntity> scheduleRecordWrapper = new QueryWrapper<>();
ScheduleRecordEntity scheduleRecordEntity = new ScheduleRecordEntity();
scheduleRecordEntity.setDoctorId(doctorInfo.getDoctorId());
scheduleRecordEntity.setHospitalId(record.getHospitalId());
scheduleRecordEntity.setDeptId(doctorInfo.getDeptId());
scheduleRecordEntity.setStatus(WhetherEnum.ALLOW.getValue());
scheduleRecordEntity.setServType(record.getServType());
for (String oneDay : dates) {
scheduleRecordEntity.setScheduleDate(DateUtils.strToDateNoTry(oneDay));
scheduleRecordWrapper.setEntity(scheduleRecordEntity);
log.info("医生某科室某天有排班的入参:" + scheduleRecordEntity);
List<ScheduleRecordEntity> list = scheduleRecordMapper.selectList(scheduleRecordWrapper);
if (CollectionUtils.isEmpty(list)) {
continue;
}
log.info("list{}", list.toString());
for (ScheduleRangeAndTimeDTO rangeReq : scheduleRangeTimeList) {
for (ScheduleRecordEntity rangeRes : list) {
Boolean aBoolean = DateUtils.rangeCompare(DateUtils.strToDateNoTryForMinute(rangeReq.getStartTime()),
DateUtils.strToDateNoTryForMinute(rangeReq.getEndTime()),
DateUtils.strToDateNoTryForMinute(rangeRes.getStartTime()),
DateUtils.strToDateNoTryForMinute(rangeRes.getEndTime()));
if (aBoolean) {
return BaseResponse.error("排班时段与已添加排班时间冲突,请重新设置");
}
}
}
}
}
for (DoctorInfoForScheduleDTO doctorInfo : doctorInfoForScheduleList) {
for (String oneDay : dates) {
scheduleRangeTimeList.stream().forEach(rangeVo -> {
getInsertSchedule(record, doctorInfo, rangeVo, oneDay);
});
}
}
return BaseResponse.success("新增排班成功");
}
@Override
public BaseResponse<List<ResponseGetScheduleForWeekVo>> getScheduleForWeek(RequestGetScheduleForWeekDTO requestGetScheduleForWeekDTO) {
Date intStartDate = DateUtils.dateToDateAsFormat(DateUtils.getBeginDayOfWeek());
Date intEndDate = DateUtils.dateToDateAsFormat(DateUtils.getEndDayOfWeek());
Integer week = requestGetScheduleForWeekDTO.getWeek();
Date startDate = null;
Date endDate = null;
startDate = DateUtils.getDateAfter(intStartDate, 7 * week);
endDate = DateUtils.getDateAfter(intEndDate, 7 * week);
QueryWrapper<ScheduleRecordEntity> wrapper = new QueryWrapper();
ScheduleRecordEntity entity = new ScheduleRecordEntity();
entity.setDeptId(JSON.toJSONString(requestGetScheduleForWeekDTO.getDeptId()));
entity.setHospitalId(JSON.toJSONString(requestGetScheduleForWeekDTO.getHospitalId()));
wrapper.setEntity(entity);
wrapper.between("schedule_date", startDate, endDate);
List<ScheduleRecordEntity> recordEntityList = scheduleRecordMapper.selectList(wrapper);
log.info("查询排班结果{}", recordEntityList.toString());
List<ResponseGetScheduleForWeekVo> list = new ArrayList<>();
for (int i = 0; i < 7; i++) {
ResponseGetScheduleForWeekVo scheduleForWeekVo = new ResponseGetScheduleForWeekVo();
Date weekDay = DateUtils.getDateAfter(startDate, i);
scheduleForWeekVo.setScheduleDate(weekDay);
List<ScheduleOfDayVo> scheduleOfDayVoList = new ArrayList<>();
for (int j = 1; j <= 3; j++) {
ScheduleOfDayVo scheduleOfDayVo = new ScheduleOfDayVo();
QueryWrapper<ScheduleRecordEntity> queryWrapper = new QueryWrapper<>();
ScheduleRecordEntity timeIntervalEntity = new ScheduleRecordEntity();
timeIntervalEntity.setHospitalId(String.valueOf(requestGetScheduleForWeekDTO.getHospitalId()));
timeIntervalEntity.setScheduleRange(j);
queryWrapper.setEntity(timeIntervalEntity);
ScheduleRecordEntity scheduleTimeIntervalEntity = scheduleRecordMapper.selectOne(queryWrapper);
ScheduleTimeSaveListVo saveListVo = new ScheduleTimeSaveListVo();
if (null != scheduleTimeIntervalEntity) {
BeanUtils.copyProperties(scheduleTimeIntervalEntity, saveListVo);
}
scheduleOfDayVo.setScheduleTimeSaveListVo(saveListVo);
List<ScheduleRecordVo> scheduleRecordVoList = new ArrayList<>();
if (!recordEntityList.isEmpty()) {
for (ScheduleRecordEntity scheduleRecordEntity : recordEntityList) {
if (DateUtils.dateToSimpleString(scheduleRecordEntity.getScheduleDate()).equals(DateUtils.dateToSimpleString(weekDay)) && scheduleRecordEntity.getScheduleRange().equals(j)) {
ScheduleRecordVo scheduleRecordVo = new ScheduleRecordVo();
BeanUtils.copyProperties(scheduleRecordEntity, scheduleRecordVo);
QueryWrapper configQuery = new QueryWrapper();
ServiceConfigEntity configEntity = new ServiceConfigEntity();
configEntity.setOrganId(String.valueOf(requestGetScheduleForWeekDTO.getHospitalId()));
configEntity.setDoctorId(scheduleRecordEntity.getDoctorId());
configEntity.setDeptId(Long.parseLong(scheduleRecordEntity.getDeptId()));
configQuery.setEntity(configEntity);
configQuery.last("limit 1");
scheduleRecordVoList.add(scheduleRecordVo);
}
}
}
scheduleOfDayVo.setRecordVoList(scheduleRecordVoList);
scheduleOfDayVoList.add(scheduleOfDayVo);
}
scheduleForWeekVo.setScheduleOfDayVoList(scheduleOfDayVoList);
list.add(scheduleForWeekVo);
}
return BaseResponse.success(list);
}
@Override
public BaseResponse<List<ScheduleForWeekResVo>> scheduleForWeekNew(ScheduleForWeekReqDTO scheduleForWeekReqDTO) {
//停诊的不展示
Date intStartDate = DateUtils.dateToDateAsFormat(DateUtils.getBeginDayOfWeek());
Date intEndDate = DateUtils.dateToDateAsFormat(DateUtils.getEndDayOfWeek());
Integer week = scheduleForWeekReqDTO.getWeek();
Date startDate;
Date endDate;
startDate = DateUtils.getDateAfter(intStartDate, 7 * week);
endDate = DateUtils.getDateAfter(intEndDate, 7 * week);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
ArrayList<ScheduleForWeekResVo> list = new ArrayList<>();
//根据医院 业务 找出 非停诊的 当前周的 医生排班列表 或加 医生姓名(用于管理端医生姓名搜索)
List<ScheduleRecordEntity> scheduleRecordEList = getScheduleRecordEntities(scheduleForWeekReqDTO);
if (CollectionUtils.isEmpty(scheduleRecordEList)) {
list = noScheduleRes(startDate);
return BaseResponse.success(list);
}
log.info("查询排班结果{}", scheduleRecordEList.size());
//过滤出 在排班日期范围内的 数据
ArrayList<ScheduleRecordEntity> recordEntityList = new ArrayList<>();
for (ScheduleRecordEntity scheduleRecord : scheduleRecordEList) {
boolean overlap = DateUtils.overlap(scheduleRecord.getScheduleDate(), scheduleRecord.getScheduleDate(), startDate, endDate);
if (overlap) {
recordEntityList.add(scheduleRecord);
}
}
if (CollectionUtils.isEmpty(recordEntityList)) {
log.info("此时段无排班");
list = noScheduleRes(startDate);
return BaseResponse.success(list);
}
log.info("scheduleRecordfilterList:" + recordEntityList.toString());
int i = 0;
for (i = 0; i < 7; i++) {
ScheduleForWeekResVo scheduleTimeRes = new ScheduleForWeekResVo();
Date dateAfter = DateUtils.getDateAfter(startDate, i);
String format = simpleDateFormat.format(dateAfter);
log.info("第几天:" + format);
scheduleTimeRes.setScheduleTime(format);
ArrayList<ScheduleRecordEntity> scheduleOneDayList = new ArrayList<>();
recordEntityList.stream().forEach(record -> {
boolean overlap = DateUtils.overlap(record.getScheduleDate(), record.getScheduleDate(), dateAfter, dateAfter);
if (overlap) {
scheduleOneDayList.add(record);
}
});
if (CollectionUtils.isEmpty(scheduleOneDayList)) {
scheduleTimeRes.setScheduleInfos(new ArrayList<>());
list.add(scheduleTimeRes);
continue;
}
log.info("某天的排班{}", scheduleOneDayList.toString());
//根据医生分组
Map<String, List<ScheduleRecordEntity>> collect =
scheduleOneDayList.stream().collect(Collectors.groupingBy(ScheduleRecordEntity::getDoctorId));
List<ScheduleInfoVo> scheduleInfos = new ArrayList<>();
for (String key : collect.keySet()) {
List<ScheduleRecordEntity> scheduleRecordEntities = collect.get(key);
//根据科室分组
Map<String, List<ScheduleRecordEntity>> collectDept =
scheduleRecordEntities.stream().collect(Collectors.groupingBy(ScheduleRecordEntity::getDeptId));
for (String keyDept : collectDept.keySet()) {
ScheduleInfoVo scheduleInfo = new ScheduleInfoVo();
List<ScheduleRecordEntity> scheduleRecord = collectDept.get(keyDept);
DoctorInfo doctorInfo = new DoctorInfo();
log.info("医生信息入参{}", JSON.toJSONString(scheduleRecord));
QueryPersonnelInfoReq queryPersonnelInfoReq = new QueryPersonnelInfoReq();
queryPersonnelInfoReq.setDoctorId(scheduleRecord.get(0).getDoctorId());
BaseResponse<PersonnelInfo> response = doctorCilent.queryPersonnelInfo(queryPersonnelInfoReq);
doctorInfo.setDeptId(keyDept);
doctorInfo.setDeptName(scheduleRecord.get(0).getDeptName());
doctorInfo.setDoctorId(scheduleRecord.get(0).getDoctorId());
doctorInfo.setDoctorName(scheduleRecord.get(0).getDoctorName());
doctorInfo.setDoctorProfession(response.getData().getTitle());
doctorInfo.setDoctorPortrait(response.getData().getPortrait());
ArrayList<ScheduleRangeAndCountVo> scheduleRangeAndCounts = new ArrayList<>();
List<ScheduleRecordEntity> scheduleRecordCountEntities = getScheduleRecordEntities(scheduleForWeekReqDTO, format, doctorInfo);
scheduleRecordCountEntities.sort(Comparator.comparing(ScheduleRecordEntity::getStartTime));
scheduleRecordCountEntities.stream().forEach(scheduleRecordCount -> {
ScheduleRangeAndCountVo scheduleRangeAndCount = new ScheduleRangeAndCountVo();
BeanUtils.copyProperties(scheduleRecordCount, scheduleRangeAndCount);
scheduleRangeAndCounts.add(scheduleRangeAndCount);
});
scheduleRecordCountEntities.sort(Comparator.comparing(ScheduleRecordEntity::getCreateTime));
BeanUtils.copyProperties(doctorInfo, scheduleInfo);
scheduleInfo.setCreateEarliestTime(scheduleRecordCountEntities.get(0).getCreateTime());
scheduleInfo.setScheduleRangeAndCountList(scheduleRangeAndCounts);
scheduleInfos.add(scheduleInfo);
scheduleInfos.sort(Comparator.comparing(ScheduleInfoVo::getCreateEarliestTime).reversed());
scheduleTimeRes.setScheduleInfos(scheduleInfos);
}
}
list.add(scheduleTimeRes);
log.info("list{}", list.toString());
}
return BaseResponse.success(list);
}
private void getInsertSchedule(InsertScheduleRecordReqDTO record, DoctorInfoForScheduleDTO doctorInfo, ScheduleRangeAndTimeDTO rangeRes, String s) {
ScheduleRecordEntity schedule = new ScheduleRecordEntity();
BeanUtils.copyProperties(record, schedule);
BeanUtils.copyProperties(doctorInfo, schedule);
BeanUtils.copyProperties(rangeRes, schedule);
schedule.setAvailableCount(rangeRes.getTotalCount());
Date date = null;
try {
date = DateUtils.strToDate(s, "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
schedule.setScheduleDate(date);
log.info("排班新增入参:" + schedule.toString());
scheduleRecordMapper.insert(schedule);
}
private ArrayList<ScheduleForWeekResVo> noScheduleRes(Date startDate) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
ArrayList<ScheduleForWeekResVo> list = new ArrayList<>();
int i;
for (i = 0; i < 7; i++) {
ScheduleForWeekResVo scheduleTimeRes = new ScheduleForWeekResVo();
Date dateAfter = DateUtils.getDateAfter(startDate, i);
String format = simpleDateFormat.format(dateAfter);
log.info("第几天:" + format);
scheduleTimeRes.setScheduleTime(format);
scheduleTimeRes.setScheduleInfos(new ArrayList<>());
list.add(scheduleTimeRes);
}
return list;
}
private List<ScheduleRecordEntity> getScheduleRecordEntities(ScheduleForWeekReqDTO scheduleForWeekReqDTO, String format, DoctorInfo doctorInfo) {
QueryWrapper<ScheduleRecordEntity> queryWrapper = new QueryWrapper<>();
ScheduleRecordEntity scheduleRecordCountEntity = new ScheduleRecordEntity();
scheduleRecordCountEntity.setHospitalId(scheduleForWeekReqDTO.getHospitalId().toString());
scheduleRecordCountEntity.setDeptId(doctorInfo.getDeptId());
scheduleRecordCountEntity.setDoctorId(doctorInfo.getDoctorId());
try {
scheduleRecordCountEntity.setScheduleDate(DateUtils.strToDate(format, "yyyy-MM-dd"));
} catch (ParseException e) {
e.printStackTrace();
}
scheduleRecordCountEntity.setStatus(WhetherEnum.ALLOW.getValue());
scheduleRecordCountEntity.setServType(scheduleForWeekReqDTO.getServType());
queryWrapper.setEntity(scheduleRecordCountEntity);
return scheduleRecordMapper.selectList(queryWrapper);
}
private List<ScheduleRecordEntity> getScheduleRecordEntities(ScheduleForWeekReqDTO scheduleForWeekReqDTO) {
QueryWrapper<ScheduleRecordEntity> wrapper = new QueryWrapper();
ScheduleRecordEntity entity = new ScheduleRecordEntity();
entity.setHospitalId(JSON.toJSONString(scheduleForWeekReqDTO.getHospitalId()));
entity.setServType(scheduleForWeekReqDTO.getServType());
entity.setStatus(WhetherEnum.ALLOW.getValue());
wrapper.setEntity(entity);
wrapper.like(StringUtils.isNotEmpty(scheduleForWeekReqDTO.getDoctorName()), "doctor_name", scheduleForWeekReqDTO.getDoctorName());
log.info("查询入参:" + entity.toString());
return scheduleRecordMapper.selectList(wrapper);
}
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ebaiyihui.family.doctor.common.dto.RequestGetDoctorOfficeStatusDTO;
import com.ebaiyihui.family.doctor.common.dto.RequestServiceConfigDTO;
import com.ebaiyihui.family.doctor.common.vo.RequestOnlineOrOfflineVo;
import com.ebaiyihui.family.doctor.server.entity.ServiceConfigEntity;
import com.ebaiyihui.family.doctor.server.exception.BusinessException;
import com.ebaiyihui.family.doctor.server.mapper.ServiceConfigMapper;
import com.ebaiyihui.family.doctor.server.service.ServiceConfigService;
import com.ebaiyihui.framework.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @ClassName: ServiceConfigServiceImpl
* @Author:yanliang
* @Date:2024/3/12 09:41
* @Description
*/
@Service
@Slf4j
public class ServiceConfigServiceImpl implements ServiceConfigService {
@Autowired
private ServiceConfigMapper serviceConfigMapper;
@Override
public RequestOnlineOrOfflineVo getDoctorOfficeStatus(RequestGetDoctorOfficeStatusDTO requestGetDoctorOfficeStatusDTO) {
QueryWrapper<ServiceConfigEntity> queryWrapper = new QueryWrapper<>();
ServiceConfigEntity wrapperEntity = new ServiceConfigEntity();
wrapperEntity.setOrganId(requestGetDoctorOfficeStatusDTO.getHospitalId());
wrapperEntity.setAppCode(requestGetDoctorOfficeStatusDTO.getAppCode());
wrapperEntity.setDoctorId(requestGetDoctorOfficeStatusDTO.getDoctorId());
wrapperEntity.setStatus(1);
queryWrapper.setEntity(wrapperEntity);
queryWrapper.last("limit 1");
ServiceConfigEntity serviceConfigEntity = serviceConfigMapper.selectOne(queryWrapper);
if (null == serviceConfigEntity) {
throw new BusinessException("当前医生未开通家庭医生服务或数据不同步!");
}
RequestOnlineOrOfflineVo requestOnlineOrOfflineVo = new RequestOnlineOrOfflineVo();
requestOnlineOrOfflineVo.setAppCode(serviceConfigEntity.getAppCode());
requestOnlineOrOfflineVo.setDoctorId(serviceConfigEntity.getDoctorId());
requestOnlineOrOfflineVo.setHospitalId(serviceConfigEntity.getOrganId());
requestOnlineOrOfflineVo.setOfficeStatus(serviceConfigEntity.getOfficeStatus());
return requestOnlineOrOfflineVo;
}
@Override
public RequestOnlineOrOfflineVo officeOnlineOrOffline(RequestOnlineOrOfflineVo requestOnlineOrOfflineVo) {
QueryWrapper<ServiceConfigEntity> queryWrapper = new QueryWrapper<>();
ServiceConfigEntity wrapperEntity = new ServiceConfigEntity();
wrapperEntity.setOrganId(requestOnlineOrOfflineVo.getHospitalId());
wrapperEntity.setAppCode(requestOnlineOrOfflineVo.getAppCode());
wrapperEntity.setDoctorId(requestOnlineOrOfflineVo.getDoctorId());
queryWrapper.setEntity(wrapperEntity);
queryWrapper.last("limit 1");
ServiceConfigEntity serviceConfigEntity = serviceConfigMapper.selectOne(queryWrapper);
if (null == serviceConfigEntity) {
throw new BusinessException("未查询到该医生上下线配置信息!");
}
serviceConfigEntity.setOfficeStatus(requestOnlineOrOfflineVo.getOfficeStatus());
int flag = serviceConfigMapper.updateById(serviceConfigEntity);
if (flag > 0) {
if (requestOnlineOrOfflineVo.getOfficeStatus().equals(1)) {
throw new BusinessException("上线失败");
} else {
throw new BusinessException("上线失败");
}
}
return requestOnlineOrOfflineVo;
}
@Override
public BaseResponse<Object> saveServiceInfo(RequestServiceConfigDTO serviceConfigDTO) {
QueryWrapper<ServiceConfigEntity> queryWrapper = new QueryWrapper<>();
ServiceConfigEntity wrapperEntity = new ServiceConfigEntity();
wrapperEntity.setOrganId(serviceConfigDTO.getOrganId());
wrapperEntity.setAppCode(serviceConfigDTO.getAppCode());
wrapperEntity.setDeptId(serviceConfigDTO.getDeptId());
wrapperEntity.setDoctorId(serviceConfigDTO.getDoctorId());
wrapperEntity.setServiceCode(serviceConfigDTO.getServiceCode());
queryWrapper.setEntity(wrapperEntity);
queryWrapper.last("limit 1");
ServiceConfigEntity serviceConfigEntity = serviceConfigMapper.selectOne(queryWrapper);
ServiceConfigEntity entity = new ServiceConfigEntity();
//没有找到具体的医生信息,新增
if (null == serviceConfigEntity) {
BeanUtils.copyProperties(serviceConfigDTO, entity);
entity.setOfficeStatus(1);
log.info("添加家庭医生服务信息entity: {}", entity);
serviceConfigMapper.insert(entity);
return BaseResponse.success("新增家庭医生服务信息成功");
}
//找到了医生信息,修改
BeanUtils.copyProperties(serviceConfigDTO, entity);
log.info("查询到服务信息id:" + serviceConfigEntity.getId());
entity.setId(serviceConfigEntity.getId());
entity.setStatus(serviceConfigDTO.getStatus());
log.info("修改家庭医生服务信息entity: {}", entity);
serviceConfigMapper.updateById(entity);
return BaseResponse.success("修改家庭医生服务信息成功");
}
}
package com.ebaiyihui.family.doctor.server.util;
import com.ebaiyihui.family.doctor.server.common.enums.ScheduleRecordEnum;
import com.ebaiyihui.family.doctor.server.common.enums.WhetherEnum;
import org.apache.commons.lang.StringUtils;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* @ClassName: DateUtils
* @Author:yanliang
* @Date:2024/3/11 17:15
* @Description 日期处理类
*/
public class DateUtils {
public final static String FULL_FORMAT = "yyyy-MM-dd HH:mm:ss";
public final static String SIMPLE_FORMAT = "yyyy-MM-dd";
public final static String FORMAT = "yyyyMMddHHmmss";
public final static String SIMPLE_NOSPE_FORMAT = "yyyyMMdd";
public final static String SIMPLE_TIME_FORMAT = "HH:mm:ss";
public final static String SIMPLE_TIME_FORMAT_MINUTE = "mm:ss";
/**
* 分钟 转 天时分
**/
public static String toDayHourMinuteString(int minute) {
if (0 == minute) {
return 24 + "小时";
}
if (0 < minute && minute < 60) {
return minute + "分钟";
}
if (60 <= minute && minute < 1440) {
if (minute % 60 == 0) {
int h = minute / 60;
return h + "小时";
} else {
int h = minute / 60;
int m = minute % 60;
return h + "小时" + m + "分钟";
}
}
if (minute >= 1440) {
int d = minute / 60 / 24;
int h = minute / 60 % 24;
int m = minute % 60;
String s1 = null;
if (d > 0) {
s1 = d + "天";
}
if (h >= 1) {
s1 += h + "小时";
}
if (m > 0) {
s1 += m + "分钟";
}
return s1;
}
return null;
}
/**
* 2020-3-1 2020-03-01
*/
public static String getDate(String date) {
String[] s1 = date.split(" ");
String dateStr = s1[0];
String dateFormart = SIMPLE_FORMAT;
SimpleDateFormat format = new SimpleDateFormat(SIMPLE_FORMAT);
String newDateStr = null;
try {
newDateStr = format.format(format.parse(dateStr));
} catch (ParseException e) {
e.printStackTrace();
}
return newDateStr;
}
/**
* @param second
* @param
* @return java.lang.String
**/
public static String secondToDateTime(long second) {
Calendar calendar = Calendar.getInstance();
//转换为毫秒
calendar.setTimeInMillis(second * 1000);
Date date = calendar.getTime();
SimpleDateFormat format = new SimpleDateFormat(FULL_FORMAT);
String dateString = format.format(date);
return dateString;
}
/**
* 秒 转 时分秒
* 280秒 转 10:00:00
**/
public static String tosecondString(String str) {
Integer second = Integer.valueOf(str);
String h1 = null;
String m1 = null;
String s1 = null;
if (second < 60) {
return "00" + ":" + "00" + ":" + str;
}
if (60 <= second && second < 3600) {
Integer m = second / 60;
if (0 <= m && m < 10) {
m1 = "0" + m;
} else {
m1 = m.toString();
}
Integer s = second % 60;
if (0 <= s && s < 10) {
s1 = "0" + s;
} else {
s1 = s.toString();
}
return "00" + ":" + m1 + ":" + s1;
}
if (second >= 3600) {
Integer h = second / 3600;
if (0 <= h && h < 10) {
h1 = "0" + h;
} else {
h1 = h.toString();
}
Integer m = (second % 3600) / 60;
if (0 <= m && m < 10) {
m1 = "0" + m;
} else {
m1 = m.toString();
}
Integer s = (second % 3600) % 60;
if (0 <= s && s < 10) {
s1 = "0" + s;
} else {
s1 = s.toString();
}
return h1 + ":" + m1 + ":" + s1;
}
return null;
}
/**
* 获得当前 时:分:秒
*
* @return
*/
public static String getCurrentTime() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_TIME_FORMAT);
return df.format(calendar.getTime());
}
/**
* 得到几天前的时间
*
* @param d
* @param day
* @return
*/
public static Date getDateBefore(Date d, int day) {
Calendar now = Calendar.getInstance();
now.setTime(d);
now.set(Calendar.DATE, now.get(Calendar.DATE) - day);
return now.getTime();
}
/**
* 得到几天后的时间
*
* @param d
* @param day
* @return
*/
public static Date getDateAfter(Date d, int day) {
Calendar now = Calendar.getInstance();
now.setTime(d);
now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
return now.getTime();
}
/**
* 得到 (Date类型的日期+N个月) 的日期Date类型 加法
*
* @param date
* @param month
* @return
*/
public static Date getAddMonth(Date date, int month) {
Calendar now = Calendar.getInstance();
now.setTime(date);
now.add(Calendar.MONTH, month);
return now.getTime();
}
/**
* 得到 (Date类型的日期-N个月) 的日期字符串 减法
*
* @param date
* @param month
* @return
*/
public static Date getSubtractMonth(Date date, int month) {
Calendar now = Calendar.getInstance();
now.setTime(date);
now.add(Calendar.MONTH, -month);
return now.getTime();
}
/**
* 得到 (Date类型的日期+N年) 的日期Date类型 加法
*
* @param date
* @param month
* @return
*/
public static Date getAddYear(Date date, int year) {
Calendar now = Calendar.getInstance();
now.setTime(date);
now.add(Calendar.YEAR, year);
return now.getTime();
}
/**
* 得到 (Date类型的日期-N个月) 的日期字符串 减法
*
* @param date
* @param month
* @return
*/
public static Date getSubtractYear(Date date, int year) {
Calendar now = Calendar.getInstance();
now.setTime(date);
now.add(Calendar.YEAR, -year);
return now.getTime();
}
private static Calendar initCurrentDate() {
Date date = new Date(System.currentTimeMillis());
Calendar c = Calendar.getInstance();
c.setTime(date);
return c;
}
public static int getCurrentYear() {
Calendar c = initCurrentDate();
return c.get(Calendar.YEAR);
}
public static int getCurrentMonth() {
return initCurrentDate().get(Calendar.MONTH) + 1;
}
public static int getCurrentDay() {
return initCurrentDate().get(Calendar.DAY_OF_MONTH);
}
public static int getCurrentHour() {
return initCurrentDate().get(Calendar.HOUR_OF_DAY);
}
public static int getCurrentMinute() {
return initCurrentDate().get(Calendar.MINUTE);
}
public static int getCurrentSecond() {
return initCurrentDate().get(Calendar.SECOND);
}
public static String getCurrentDate(String format) {
SimpleDateFormat parse = new SimpleDateFormat(format);
return parse.format(new Date());
}
public static Date parseDate(String str, String parsePatterns) throws ParseException {
if (str == null || parsePatterns == null) {
throw new IllegalArgumentException("Date and Patterns must not be null");
}
SimpleDateFormat parser = null;
ParsePosition pos = new ParsePosition(0);
parser = new SimpleDateFormat(parsePatterns);
pos.setIndex(0);
Date date = parser.parse(str, pos);
if (date != null && pos.getIndex() == str.length()) {
return date;
}
throw new ParseException("Unable to parse the date: " + str, -1);
}
public static String dateToString(Date date, String par) {
if (date == null) {
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat(par);
return sdf.format(date);
}
/**
* 将日期字符串转换为长整型
*
* @param date 格式(yyyy-MM-dd)
* @return
*/
public static long strToDateLong(String date) {
long l = 0L;
try {
Calendar ca = Calendar.getInstance();
ca.setTime(java.sql.Date.valueOf(date));
l = ca.getTimeInMillis();
} catch (Exception e) {
new Exception("日期字符串转长整形错误", e);
}
return l;
}
public static String longToStrDate(String format, long time) {
DateFormat df = new SimpleDateFormat(format);
return df.format(new Date(time));
}
public static Date strToDate(String str, String parsePatterns) throws ParseException {
return parseDate(str, parsePatterns);
}
/**
* 得到 n 天后的日期
*
* @param days
* @return
*/
public static Date getAfterCurrentDay(int days) {
Date result = null;
Calendar calendar = Calendar.getInstance();
try {
calendar.add(Calendar.DAY_OF_WEEK, +days);
result = calendar.getTime();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* 得到当前日期的指定格式
*
* @return
*/
public static String getFormatDateString(Date date, String format) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(format);
return df.format(date);
}
/**
* 得到当前日期的年月日时分秒
*
* @return
*/
public static String getCurrentDateTimeString() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(FORMAT);
return df.format(calendar.getTime());
}
/**
* 得到当前日期的年-月-日 时:分:秒
*
* @return
*/
public static String getCurrentDateToString() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(FULL_FORMAT);
return df.format(calendar.getTime());
}
/**
* 得到当前日期的年-月-日
*
* @return
*/
public static String getCurrentDateSimpleToString() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
return df.format(calendar.getTime());
}
/**
* 得到当前日期的yyyymmdd
*
* @return
*/
public static String getCurrentDateSimpleNoSpeToString() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_NOSPE_FORMAT);
return df.format(calendar.getTime());
}
/**
* 得到当前日期的年-月-日
*
* @return
*/
public static Date getCurrentDate() {
Calendar calendar = Calendar.getInstance();
return calendar.getTime();
}
/**
* 得到当前日期的年-月-日
*
* @return
*/
public static Timestamp getCurrentDateTimestamp() {
Calendar calendar = Calendar.getInstance();
return new Timestamp(calendar.getTime().getTime());
}
/**
* 得到当天到下周的日期
*
* @return
*/
public static String getNextWeekToString() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_WEEK, +6);
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
return df.format(calendar.getTime());
}
/**
* 得到明天的时间
*
* @return
*/
public static String getNextDayToString(String day) {
String result = "";
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
try {
calendar.setTime(df.parse(day));
calendar.add(Calendar.DAY_OF_WEEK, +1);
result = df.format(calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return result;
}
public static String getLastWeekToString() {
String result = "";
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
try {
// 周数减一,即上周
calendar.add(Calendar.WEEK_OF_MONTH, -1);
result = df.format(calendar.getTime());
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* 获取昨天日期
*
* @param day
* @return
*/
public static String getYestarDayToString(String day) {
String result = "";
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
try {
calendar.setTime(df.parse(day));
calendar.add(Calendar.DAY_OF_WEEK, -1);
result = df.format(calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return result;
}
/**
* 字符串日期转Date类型
*
* @param str
* @return
*/
public static Date stringToSimpleDate(String str) {
if (str == null || "".equals(str)) {
return null;
}
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
try {
return df.parse(str);
} catch (ParseException e) {
return null;
}
}
/**
* 字符串日期转Date类型
*
* @param str
* @return
*/
public static Date stringToFullDate(String str) {
if (str == null || "".equals(str)) {
return null;
}
SimpleDateFormat df = new SimpleDateFormat(FULL_FORMAT);
try {
return df.parse(str);
} catch (ParseException e) {
return null;
}
}
/**
* Date类型转字符串日期
*
* @param str
* @return
*/
public static String dateToSimpleString(Date date) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
return df.format(date);
}
/**
* Date类型转字符串日期
*
* @param str
* @return
*/
public static String dateToFullString(Date date) {
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat(FULL_FORMAT);
return df.format(date);
}
/**
* 根据日期得到星期几
*
* @param date
* @return
*/
public static String getWeekChinese(String date) {
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
Calendar cal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
try {
cal.setTime(df.parse(date));
} catch (ParseException e) {
e.printStackTrace();
}
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0) {
w = 0;
}
return weekDays[w];
}
public static String getForWeek(String date) {
String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
Calendar cal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
try {
cal.setTime(df.parse(date));
} catch (ParseException e) {
e.printStackTrace();
}
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0) {
w = 0;
}
return weekDays[w];
}
/**
* 判断两个时间的大小 是否后面那个大于前面那个 格式 yyyy-MM-dd
*
* @param startDate
* @param endDate
* @return true为是 false为否
*/
public static boolean judgeDate(String startStr, String endStr) {
Date startDate = stringToSimpleDate(startStr);
Date endDate = stringToSimpleDate(endStr);
if (startDate.before(endDate)) {
return true;
}
return false;
}
/**
* 判断两个时间的大小 是否后面那个大于或等于前面那个 格式 yyyy-MM-dd
*
* @param startDate
* @param endDate
* @return true为是 false为否
*/
public static boolean judgeDateEqual(String startStr, String endStr) {
Date startDate = stringToSimpleDate(startStr);
Date endDate = stringToSimpleDate(endStr);
if (startDate.before(endDate) || startDate.compareTo(endDate) == 0) {
return true;
}
return false;
}
/**
* 判断两个时间的大小 是否后面那个大于或等于前面那个 格式 yyyy-MM-dd hh:mm:ss
*
* @param startDate
* @param endDate
* @return true为是 false为否
*/
public static boolean judgeFullDateEqual(String startStr, String endStr) {
Date startDate = stringToSimpleDate(startStr);
Date endDate = stringToSimpleDate(endStr);
if (startDate.before(endDate) || startDate.compareTo(endDate) == 0) {
return true;
}
return false;
}
/**
* 得到多少天的日期 正数为加 负数为减
*
* @param str
* @param day
* @return
*/
public static String getNumAfterDate(String str, int day) {
Date startDate = stringToSimpleDate(str);
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(Calendar.DAY_OF_WEEK, day);
return dateToSimpleString(calendar.getTime());
}
/**
* 将UNIXTIME转为普通的时间
*
* @param unixTime
* @return
*/
public static String unixTimeToString(String unixTime) {
Calendar c = Calendar.getInstance();
c.setTimeInMillis(Long.parseLong(unixTime));
return dateToSimpleString(c.getTime());
}
/**
* 将普通的日间转为UNIXTIME
*
* @param date
* @return
*/
public static String stringToUnixTime(String date) {
Calendar c = Calendar.getInstance();
Date date2 = stringToSimpleDate(date);
c.setTime(date2);
return c.getTimeInMillis() + "";
}
/**
* 将时间字符串转化成Timestamp时间戳(String的类型必须形如: yyyy-mm-dd hh:mm:ss 这样的格式,否则报错)
*
* @param tsStr
* @return Timestamp
*/
public static Timestamp stringToTimestamp(String tsStr) {
Timestamp ts = new Timestamp(System.currentTimeMillis());
try {
ts = Timestamp.valueOf(tsStr);
} catch (Exception e) {
e.printStackTrace();
}
return ts;
}
/**
* 时间戳转字符串
*
* @param ccTime
* @return
*/
public static String getStrByTimestamp(Timestamp ccTime) {
SimpleDateFormat sdf = new SimpleDateFormat(FULL_FORMAT);
return sdf.format(ccTime);
}
@SuppressWarnings("static-access")
public static Time strToTime(String strDate) {
if ("".equals(strDate) || strDate == null) {
return null;
}
String str = strDate;
SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss");
Date d = null;
try {
d = format.parse(str);
} catch (Exception e) {
e.printStackTrace();
}
return Time.valueOf(str);
}
public static Time getTime() {
Date d = new Date();
// SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss");
Time time = new Time(d.getTime());
return time;
}
/**
* dateB - dateA 的日期天数
*
* @param dateA
* @param dateB
* @return
*/
public static int getBetweenDayNumber(Date dateA, Date dateB) {
long dayNumber = 0;
long day = 24L * 60L * 60L * 1000L;
try {
dayNumber = (dateB.getTime() - dateA.getTime()) / day;
} catch (Exception e) {
e.printStackTrace();
}
return (int) dayNumber;
}
/**
* 计算两个日期相差的天数 date2-date1
*
* @param date1
* @param date2
* @return
*/
public static int daysBetween(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(betweenDays));
}
/**
* 计算两个日期相差的秒数 date2-date1
*
* @param date1
* @param date2
* @return
*/
public static int secondsBetween(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / 1000;
return Integer.parseInt(String.valueOf(betweenDays));
}
/**
* 计算两个日期相差的秒数 date2-date1-1个小时
*
* @param date1
* @param date2
* @return
*/
public static Long secondsBetweenOneHour(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenSeconds = 0L;
betweenSeconds = time2 - time1;
if (betweenSeconds < (1000 * 3600)) {
betweenSeconds = 0;
} else {
betweenSeconds = betweenSeconds - (1000 * 3600);
}
return betweenSeconds;
}
/**
* 计算两个日期相差的小时 date2-date1
*
* @param date1
* @param date2
* @return
*/
public static int hoursBetween(Date date1, Date date2) {
if (date1.after(date2)) {
return 0;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / 1000 / 3600;
return Integer.parseInt(String.valueOf(betweenDays));
}
/**
* 计算两个日期相差的分钟 date2-date1
*
* @param date1
* @param date2
* @return
*/
public static int minuteBetween(Date date1, Date date2) {
if (date1.after(date2)) {
return 0;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / 1000 / 60;
return Integer.parseInt(String.valueOf(betweenDays));
}
/**
* 日期增加天数
*
* @param date
* @param addDays
* @return
*/
public static Date dateAddDays(Date date, int addDays) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, addDays);
return calendar.getTime();
}
/**
* 日期增加小时
*
* @param date
* @param addHours
* @return
*/
public static Date dateAddHours(Date date, int addHours) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.HOUR_OF_DAY, addHours);
return calendar.getTime();
}
/**
* 时间增加小时
*
* @param day
* @param hour
* @return
*/
public static Date addDateMinut(Date day, int hour) {
Calendar cal = Calendar.getInstance();
cal.setTime(day);
// 24小时制
cal.add(Calendar.HOUR, hour);
Date time = cal.getTime();
return time;
}
/**
* 日期增加分钟
*
* @param date
* @param addMinutes
* @return
*/
public static Date dateAddMinutes(Date date, int addMinutes) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MINUTE, addMinutes);
return calendar.getTime();
}
/**
* long类型转换为String类型
*
* @param currentTime 要转换的long类型的时间
* @param formatType 要转换的string类型的时间格式
* @return
* @throws ParseException
*/
public static String longToString(long currentTime, String formatType) throws ParseException {
// long类型转成Date类型
Date date = longToDate(currentTime, formatType);
// date类型转成String
String strTime = dateToString(date, formatType);
return strTime;
}
/**
* string 类型转为时间戳,格式为(yyyy-MM-dd HH:mm:ss)
*
* @param strDateTime
* @return
*/
public static long StringTolong(String strDateTime) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
long timeStamp = 0L;
try {
LocalDateTime localDateTime = LocalDateTime.parse(strDateTime, dtf);
timeStamp = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
} catch (Exception e) {
return timeStamp;
}
return timeStamp;
}
/**
* string类型转换为date类型
*
* @param strTime要转换的string类型的时间,formatType要转换的格式yyyy-MM-dd HH:mm:ss//yyyy年MM月dd日
* @param formatType
* @return
* @throws ParseException
*/
public static Date stringToDate(String strTime, String formatType) {
SimpleDateFormat formatter = new SimpleDateFormat(formatType);
Date date = null;
try {
date = formatter.parse(strTime);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* long转换为Date类型
*
* @param currentTime 要转换的long类型的时间
* @param formatType要转换的时间格式yyyy-MM-dd HH:mm:ss//yyyy年MM月dd日 HH时mm分ss秒
* @return
* @throws ParseException
*/
public static Date longToDate(long currentTime, String formatType) throws ParseException {
// 根据long类型的毫秒数生命一个date类型的时间
Date dateOld = new Date(currentTime);
// 把date类型的时间转换为string
String sDateTime = dateToString(dateOld, formatType);
// 把String类型转换为Date类型
Date date = stringToDate(sDateTime, formatType);
return date;
}
/**
* date类型转换为long类型
*
* @param date要转换的date类型的时间
* @return
*/
public static long dateToLong(Date date) {
return date.getTime();
}
/**
* 时 分 秒 置0
*
* @param d
* @param hour
* @param min
* @param second
* @return
*/
public static Date setPrecise(Date d, int hour, int min, int second) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(d);
calendar.set(GregorianCalendar.HOUR_OF_DAY, hour);
calendar.set(GregorianCalendar.MINUTE, min);
calendar.set(GregorianCalendar.SECOND, second);
calendar.set(GregorianCalendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取当前时间第二天的起始时间
*
* @return
* @author ZhangWei
*/
public static Date getNextDayStartTime() {
Date date = new Date();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
/**
* 获取本周的开始时间
*
* @return
*/
public static Date getBeginDayOfWeek() {
Date date = new Date();
if (date == null) {
return null;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
if (dayofweek == 1) {
dayofweek += 7;
}
cal.add(Calendar.DATE, 2 - dayofweek);
return getDayStartTime(cal.getTime());
}
/**
* 获取本周的结束时间
*
* @return
*/
public static Date getEndDayOfWeek() {
Calendar cal = Calendar.getInstance();
cal.setTime(getBeginDayOfWeek());
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
return getDayEndTime(weekEndSta);
}
/**
* 获取上周的开始时间
*
* @return
*/
public static Date getBeginDayOfLastWeek(Integer min) {
Date date = new Date();
if (date == null) {
return null;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
if (dayofweek == 1) {
dayofweek += 7;
}
cal.add(Calendar.DATE, 2 - dayofweek - min * 7);
return getDayStartTime(cal.getTime());
}
/**
* 获取上周的结束时间
*
* @return
*/
public static Date getEndDayOfLastWeek(Integer min) {
Calendar cal = Calendar.getInstance();
cal.setTime(getBeginDayOfLastWeek(min));
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
return getDayEndTime(weekEndSta);
}
/**
* 获取上上周的开始时间
*
* @return
*/
public static Date getBeginDayLastWeek() {
Date date = new Date();
if (date == null) {
return null;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
if (dayofweek == 1) {
dayofweek += 7;
}
cal.add(Calendar.DATE, 2 - dayofweek - 4 * 7);
return getDayStartTime(cal.getTime());
}
/**
* 获取上上周的结束时间
*
* @return
*/
public static Date getEndDayLastWeek() {
Calendar cal = Calendar.getInstance();
cal.setTime(getBeginDayLastWeek());
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
return getDayEndTime(weekEndSta);
}
/**
* 获取下周的开始时间
*
* @return
*/
public static Date getBeginDayOfNextWeek() {
Date date = new Date();
if (date == null) {
return null;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
if (dayofweek == 1) {
dayofweek += 7;
}
cal.add(Calendar.DATE, 2 - dayofweek + 7);
return getDayStartTime(cal.getTime());
}
/**
* 获取下周的结束时间
*
* @return
*/
public static Date getEndDayOfNextWeek() {
Calendar cal = Calendar.getInstance();
cal.setTime(getBeginDayOfNextWeek());
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
return getDayEndTime(weekEndSta);
}
/**
* 获取某个日期的开始时间
*
* @param d
* @return
*/
public static Timestamp getDayStartTime(Date d) {
Calendar calendar = Calendar.getInstance();
if (null != d) {
calendar.setTime(d);
}
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
return new Timestamp(calendar.getTimeInMillis());
}
/**
* 获取某个日期的结束时间
*
* @param d
* @return
*/
public static Timestamp getDayEndTime(Date d) {
Calendar calendar = Calendar.getInstance();
if (null != d) {
calendar.setTime(d);
}
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
calendar.set(Calendar.MILLISECOND, 999);
return new Timestamp(calendar.getTimeInMillis());
}
/**
* 获取当天后7天结束时间
*
* @return
*/
public static Date getWeek() {
Calendar cal = Calendar.getInstance();
cal.setTime(date());
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
return getDayEndTime(weekEndSta);
}
/**
* 获取当天的开始时间
*
* @return
*/
public static Date date() {
SimpleDateFormat deTime = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String format = deTime.format(date);
Date parse = null;
try {
parse = deTime.parse(format);
} catch (ParseException e) {
e.printStackTrace();
}
return parse;
}
/**
* 获取下周的开始时间
*
* @return
*/
public static Date getBegNextWeek(Integer min) {
Date date = new Date();
if (date == null) {
return null;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
if (dayofweek == 1) {
dayofweek += 7;
}
cal.add(Calendar.DATE, 2 - dayofweek + min * 7);
return getDayStartTime(cal.getTime());
}
/**
* 获取下周的结束时间
*
* @return
*/
public static Date getEndNextWeek(Integer min) {
Calendar cal = Calendar.getInstance();
cal.setTime(getBegNextWeek(min));
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
return getDayEndTime(weekEndSta);
}
public static Date updateDate(Date scheduleDate, Integer scheduleRange) {
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
String scheduledate = df.format(scheduleDate);
String moStartTime = null;
if (scheduleRange.equals(ScheduleRecordEnum.MORNING.getValue())) {
moStartTime = scheduledate + " 09:00:00";
}
if (scheduleRange.equals(ScheduleRecordEnum.AFTERNOON.getValue())) {
moStartTime = scheduledate + " 13:00:00";
}
if (scheduleRange.equals(ScheduleRecordEnum.EVENING.getValue())) {
moStartTime = scheduledate + " 18:00:00";
}
Date parse = null;
try {
SimpleDateFormat dfs = new SimpleDateFormat(FULL_FORMAT);
parse = dfs.parse(moStartTime);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(scheduleDate);
calendar.add(Calendar.DATE, -2);
return calendar.getTime();
}
public static Integer getExpirationTime(Date scheduleDate, Integer scheduleRange) {
SimpleDateFormat df = new SimpleDateFormat(SIMPLE_FORMAT);
String scheduledate = df.format(scheduleDate);
String moStartTime = null;
if (scheduleRange.equals(ScheduleRecordEnum.MORNING.getValue())) {
moStartTime = scheduledate + " 12:00:00";
}
if (scheduleRange.equals(ScheduleRecordEnum.AFTERNOON.getValue())) {
moStartTime = scheduledate + " 18:00:00";
}
if (scheduleRange.equals(ScheduleRecordEnum.EVENING.getValue())) {
moStartTime = scheduledate + " 21:00:00";
}
Date parse = null;
try {
SimpleDateFormat dfs = new SimpleDateFormat(FULL_FORMAT);
parse = dfs.parse(moStartTime);
} catch (ParseException e) {
e.printStackTrace();
}
Date date = new Date();
int after = parse.compareTo(date);
if (after != 1) {
return 1;
}
return 0;
}
public static Date dateToDateAsFormat(Date date) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String sDate = simpleDateFormat.format(date);
Date newDate = null;
try {
newDate = simpleDateFormat.parse(sDate);
} catch (ParseException e) {
e.printStackTrace();
}
return newDate;
}
public static Date stringToFullDateUtil(String str) {
if (str == null || "".equals(str)) {
return null;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try {
return df.parse(str);
} catch (ParseException e) {
return null;
}
}
public static Date stringToFullDateUtil1(String str) {
if (str == null || "".equals(str)) {
return null;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
return df.parse(str);
} catch (ParseException e) {
return null;
}
}
/**
* 三个时间的 时分秒 对比 倒叙
*
* @return
*/
public static Integer timeCompare(String t1, String t2, String t3) {
Date t4;
Date t5;
Date t6;
Integer a = 1;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
try {
t4 = simpleDateFormat.parse(t1);
t5 = simpleDateFormat.parse(t2);
t6 = simpleDateFormat.parse(t3);
if (t6.getTime() > t5.getTime() && t5.getTime() > t4.getTime()) {
a = 0;
}
} catch (ParseException e) {
e.printStackTrace();
}
return a;
}
/**
* Discreption:获取两个日期之间的所有日期
* 2020-07-02 ---- 2020-07-04 返回 [2020-07-02,2020-07-03,2020-07-04]
*/
public static List<String> getDateRange(Date date1, Date date2) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
int i = DateUtils.daysBetween(date1, date2);
System.out.println("i:" + i);
int j = 0;
ArrayList<String> scheduleDateList = new ArrayList<>();
for (j = 0; j <= i; j++) {
Date date = DateUtils.dateAddDays(date1, j);
String format = simpleDateFormat.format(date);
scheduleDateList.add(format);
}
System.out.println(scheduleDateList);
return scheduleDateList;
}
/**
* 判断日期范围是否有重叠(日期到天)
*/
// public static boolean overlapping(List<String> list) {
// if (list == null || list.size() <= 1) {
// return false;
// }
// for (int i = 0; i < list.size(); i++) {
// String date1[] = list.get(i).split(" ");
// Date beginDate1 = DateUtil.toShortDate(date1[0]);
// Date endDate1 = DateUtil.toShortDate(date1[1]);
// for (int j = i + 1; j < list.size(); j++) {
// String date2[] = list.get(j).split(" ");
// Date beginDate2 = DateUtil.toShortDate(date2[0]);
// Date endDate2 = DateUtil.toShortDate(date2[1]);
// if (!beginDate2.before(beginDate1)) {
// if (!beginDate2.after(endDate1)) {
// return true;
// }
// } else if (!endDate2.before(beginDate1)) {
// return true;
// }
// }
// }
// return false;
// }
/**
* 判断两个日期范围是否有重叠(日期到天)
*/
public static boolean overlap(Date beginDate1, Date endDate1, Date beginDate2, Date endDate2) {
if (!beginDate2.before(beginDate1)) {
if (!beginDate2.after(endDate1)) {
return true;
}
} else if (!endDate2.before(beginDate1)) {
return true;
}
System.out.println();
return false;
}
/**
* 获取当前时间的 时 和 分
*/
public static String getHourAndSecond() {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("HH:mm");
return df.format(calendar.getTime());
}
/**
* 当前时间是 上午 中午 晚上
*/
public static Integer getTimeRange() {
Date date = new Date();
SimpleDateFormat df = new SimpleDateFormat("HH");
String str = df.format(date);
int a = Integer.parseInt(str);
if (a >= 8 && a <= 12) {
return 1;
}
if (a >= 13 && a <= 17) {
return 2;
}
if (a >= 18 && a <= 22) {
return 3;
}
return 0;
}
/*
* Discreption:
*获取某天 所在周的 周一
*/
public static String getOneDayForWeekFirst(String oneDay) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
cal.setTime(sdf.parse(oneDay));
} catch (ParseException e) {
e.printStackTrace();
}
// 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
cal.setFirstDayOfWeek(Calendar.MONDAY);
// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
if (1 == dayWeek) {
cal.add(Calendar.DAY_OF_MONTH, -1);
}
// 获得当前日期是一个星期的第几天
int day = cal.get(Calendar.DAY_OF_WEEK);
// 获取该周第一天
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
String beginDate = sdf.format(cal.getTime());
// 获取该周最后一天
cal.add(Calendar.DATE, 6);
String endDate = sdf.format(cal.getTime());
System.out.println("beginDate:" + beginDate);
System.out.println("endDate:" + endDate);
return beginDate;
}
/*
* Discreption:
*获取某天 所在周的 周日
*/
public static String getOneDayForWeekLast(String oneDay) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
cal.setTime(sdf.parse(oneDay));
} catch (ParseException e) {
e.printStackTrace();
}
cal.setFirstDayOfWeek(Calendar.MONDAY);
int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
if (1 == dayWeek) {
cal.add(Calendar.DAY_OF_MONTH, -1);
}
int day = cal.get(Calendar.DAY_OF_WEEK);
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
String beginDate = sdf.format(cal.getTime());
cal.add(Calendar.DATE, 6);
String endDate = sdf.format(cal.getTime());
return endDate;
}
/*
* Discreption:
*获取某两天之间 间隔 几周 不包含这两天
*/
public static Long getWeekDayToDay(String start, String end) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
long l = 0;
try {
long from = df.parse(start).getTime();
long to = df.parse(end).getTime();
l = (to - from) / (1000 * 3600 * 24 * 7);
} catch (ParseException e) {
e.printStackTrace();
}
return l;
}
public static Integer getDifMonth(Date start, Date end) {
if (start.after(end)) {
Date t = start;
start = end;
end = t;
}
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(start);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(end);
Calendar temp = Calendar.getInstance();
temp.setTime(end);
temp.add(Calendar.DATE, 1);
int year = endCalendar.get(Calendar.YEAR) - startCalendar.get(Calendar.YEAR);
int month = endCalendar.get(Calendar.MONTH) - startCalendar.get(Calendar.MONTH);
if ((startCalendar.get(Calendar.DATE) == 1) && (temp.get(Calendar.DATE) == 1)) {
return year * 12 + month + 1;
} else if ((startCalendar.get(Calendar.DATE) != 1) && (temp.get(Calendar.DATE) == 1)) {
return year * 12 + month;
} else if ((startCalendar.get(Calendar.DATE) == 1) && (temp.get(Calendar.DATE) != 1)) {
return year * 12 + month;
} else {
return (year * 12 + month - 1) < 0 ? 0 : (year * 12 + month);
}
}
/*
* Discreption:
*获取某天 下几周的 周一
*/
public static String getNextWeekFirst(String date, Integer min) {
Date date1 = null;
try {
date1 = strToDate(date, "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
if (dayofweek == 1) {
dayofweek += 7;
}
cal.add(Calendar.DATE, 2 - dayofweek + min * 7);
String s = dateToSimpleString(getDayStartTime(cal.getTime()));
return s;
}
/*
* Discreption:
*获取某天 下几周的 周日
*/
public static String getNextWeekLast(String date, Integer min) {
Date date1 = null;
try {
date1 = strToDate(getNextWeekFirst(date, min), "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
cal.add(Calendar.DAY_OF_WEEK, 6);
Date weekEndSta = cal.getTime();
String s = dateToSimpleString(getDayEndTime(weekEndSta));
return s;
}
/*
* Discreption:
*两个日期间 相差的 月份
*/
public static List<Integer> getMonth(String startTime, String endTime) {
List<Integer> time = new ArrayList<>();
String start;
String end;
if (startTime.charAt(5) == 48) {
start = startTime.substring(6, 7);
} else {
start = startTime.substring(5, 7);
}
if (endTime.charAt(5) == 48) {
end = endTime.substring(6, 7);
} else {
end = endTime.substring(5, 7);
}
for (int i = Integer.valueOf(start); i <= Integer.valueOf(end); i++) {
time.add(i);
}
if (time.size() == 2) {
Integer i = time.get(0);
Integer k = time.get(1);
if (i.equals(k)) {
time.remove(1);
}
}
return time;
}
/*
* Discreption:
*某日期当前月的 最后一天
*/
public static String getLastDayOfMonth(String yearMonth) {
int year = Integer.parseInt(yearMonth.split("-")[0]);
int month = Integer.parseInt(yearMonth.split("-")[1]);
Calendar cal = Calendar.getInstance();
// 设置年份
cal.set(Calendar.YEAR, year);
// 设置月份
// cal.set(Calendar.MONTH, month - 1);
//设置当前月的上一个月
cal.set(Calendar.MONTH, month);
// 获取某月最大天数
//int lastDay = cal.getActualMaximum(Calendar.DATE);
//获取月份中的最小值,即第一天
int lastDay = cal.getMinimum(Calendar.DATE);
// 设置日历中月份的最大天数
//cal.set(Calendar.DAY_OF_MONTH, lastDay);
//上月的第一天减去1就是当月的最后一天
cal.set(Calendar.DAY_OF_MONTH, lastDay - 1);
// 格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(cal.getTime());
}
/*
* @Description:获取时间段中自然周
* @author:liyp String a = "2020-08-24";
String b = "2020-08-26";
[{week=2020-08-30, mon=2020-08-24}]
**/
public static List<Map<String, String>> getBetweenWeeks(String startDate, String endDate) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//定义起始日期
Date start = sdf.parse(startDate);
//定义结束日期
Date end = sdf.parse(endDate);
List<Map<String, String>> result = new ArrayList<Map<String, String>>();
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
while (tempStart.before(tempEnd) || tempStart.equals(tempEnd)) {
Map<String, String> map = new HashMap<String, String>(16);
int we = tempStart.get(Calendar.DAY_OF_WEEK);
if (we == 2) {
map.put("mon", sdf.format(tempStart.getTime()));
}
//检测map是否为空
if (map.isEmpty()) {
tempStart.add(Calendar.DAY_OF_YEAR, 1);
} else {
tempStart.add(Calendar.DAY_OF_YEAR, 6);
map.put("week", sdf.format(tempStart.getTime()));
result.add(map);
}
}
return result;
}
/*
* Discreption:str转date "yyyy-MM-dd"
*/
public static Date strToDateNoTry(String str) {
Date date = null;
try {
date = strToDate(str, SIMPLE_FORMAT);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static Date strToDateNoTryForMinute(String str) {
Date date = null;
try {
date = strToDate(str, SIMPLE_TIME_FORMAT_MINUTE);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/*
* Discreption:得到某天后几周的时间
*/
public static Date getNextWeek(String date, Integer min) {
Date date1 = null;
try {
date1 = DateUtils.strToDate(date, "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
cal.add(Calendar.DATE, min * 7);
Date week = cal.getTime();
String s = DateUtils.dateToSimpleString(week);
Date date2 = null;
try {
date2 = strToDate(s, "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
return date2;
}
/*
* Discreption:得到某天后几周的时间集合 包括入参时间
*/
public static List<String> getOneDayNextWeek(List<String> range, Integer min) {
List<String> dateRes = new ArrayList<>();
for (String str : range) {
int i = 0;
for (i = 1; i <= min; i++) {
Calendar cal = Calendar.getInstance();
cal.setTime(strToDateNoTry(str));
cal.add(Calendar.DATE, i * 7);
Date week = cal.getTime();
String s = DateUtils.dateToSimpleString(week);
dateRes.add(s);
}
}
dateRes.addAll(range);
return dateRes;
}
/*
* Discreption:得到某天后几周的时间集合 不包括入参时间
*/
public static List<String> getOneDayNextWeekTwo(List<String> range, Integer min) {
List<String> dateRes = new ArrayList<>();
for (String str : range) {
int i = 0;
for (i = 1; i <= min; i++) {
Calendar cal = Calendar.getInstance();
cal.setTime(strToDateNoTry(str));
cal.add(Calendar.DATE, i * 7);
Date week = cal.getTime();
String s = DateUtils.dateToSimpleString(week);
dateRes.add(s);
}
}
return dateRes;
}
/*
* Discreption: true 有重叠
*/
public static Boolean rangeCompare(Date date1, Date date2, Date date3, Date date4) {
Boolean flag = true;
int f1 = date1.compareTo(date3);
int f2 = date3.compareTo(date2);
int f3 = date2.compareTo(date4);
int f4 = date1.compareTo(date4);
//左跨
boolean b1 = WhetherEnum.FORBID.getValue().equals(f1);
boolean b = WhetherEnum.ALLOW.getValue().equals(f2) || WhetherEnum.EQU.getValue().equals(f2);
if (b1 && b) {
flag = false;
}
// if(WhetherEnum.FORBID.getValue().equals(f1) && (WhetherEnum.ALLOW.getValue().equals(f2) || WhetherEnum.EQU.getValue().equals(f2))){
// flag=false;
// }
//右跨
boolean b2 = WhetherEnum.EQU.getValue().equals(f4) || WhetherEnum.ALLOW.getValue().equals(f4);
if (WhetherEnum.ALLOW.getValue().equals(f3) && b2) {
flag = false;
}
// if(WhetherEnum.ALLOW.getValue().equals(f3) &&
// (WhetherEnum.EQU.getValue().equals(f4) || WhetherEnum.ALLOW.getValue().equals(f4))){
// flag=false;
// }
return flag;
}
/**
* 判断两个时间的大小 是否后面那个大于或等于前面那个 格式 yyyy-MM-dd hh:mm:ss
*
* @param startDate
* @param endDate
* @return true为是 false为否
*/
public static boolean dateCompare(String startStr, String endStr) {
Date startDate = null;
Date endDate = null;
try {
startDate = strToDate(startStr, FULL_FORMAT);
endDate = strToDate(endStr, FULL_FORMAT);
} catch (ParseException e) {
e.printStackTrace();
}
if (startDate.before(endDate) || startDate.compareTo(endDate) == 0) {
return true;
}
return false;
}
/**
* 分钟转小时
*/
public static String formatTime(int minuteStr) {
String resultStr = "";
if (!StringUtils.isEmpty(Integer.toString(minuteStr))) {
if (minuteStr != 0) {
if (minuteStr / 60 == 0) {
resultStr = minuteStr % 60 + "分";
} else {
if (minuteStr % 60 == 0) {
resultStr = minuteStr / 60 + "小时";
} else {
resultStr = (minuteStr / 60 + "小时" + minuteStr % 60 + "分");
}
}
} else {
resultStr = "0时0分";
}
} else {
resultStr = "0时0分";
}
return resultStr;
}
public static long secondsBetween1(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / 1000;
return betweenDays;
}
/**
* 计算两个日期相差的秒数 date2-date1
*
* @param date1
* @param date2
* @return
*/
public static int secondBetween(Date date1, Date date2) {
if (date1.after(date2)) {
return 0;
}
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / 1000;
return Integer.parseInt(String.valueOf(betweenDays));
}
/**
* 某日期当前月的 第一天
*
* @param yearMonth
* @return
*/
public static String getStartDayOfMonth(String yearMonth) {
int year = Integer.parseInt(yearMonth.split("-")[0]);
int month = Integer.parseInt(yearMonth.split("-")[1]);
Calendar cal = Calendar.getInstance();
// 设置年份
cal.set(Calendar.YEAR, year);
// 设置月份
// cal.set(Calendar.MONTH, month - 1);
//设置当前月的上一个月
cal.set(Calendar.MONTH, month - 1);
// 获取某月最大天数
//int lastDay = cal.getActualMaximum(Calendar.DATE);
//获取月份中的最小值,即第一天
int lastDay = cal.getMinimum(Calendar.DATE);
// 设置日历中月份的最大天数
//cal.set(Calendar.DAY_OF_MONTH, lastDay);
//上月的第一天减去1就是当月的最后一天
cal.set(Calendar.DAY_OF_MONTH, lastDay);
// 格式化日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(cal.getTime());
}
/**
* 计算一个月的月初日期和月末日期
*
* @param time
* @return
*/
public static List<String> getMonthBeginAndEnd(String time) {
String begin = "01";
String end1 = "28";
String end2 = "29";
String end3 = "30";
String end4 = "31";
//大月
Integer[] bigMonth = {1, 3, 5, 7, 8, 10, 12};
Integer[] smallMonth = {4, 6, 9, 11};
List<Integer> bigMonthList = new ArrayList<>();
bigMonthList.addAll(Arrays.asList(bigMonth));
List<Integer> smallMonthList = new ArrayList<>();
smallMonthList.addAll(Arrays.asList(smallMonth));
//获得当前年月信息
int year = Integer.parseInt(time.substring(0, 4));
int month = Integer.parseInt(time.substring(5, 7));
List<String> result = new ArrayList<>();
//判断是否为闰年
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
StringBuffer monthBegin = new StringBuffer();
StringBuffer monthEnd = new StringBuffer();
if ("2".equals(month) && month < 10) {
monthBegin.append(year).append("-").append(0).append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(0).append(month).append("-").append(end2);
} else {
monthBegin.append(year).append("-").append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(month).append("-").append(end2);
}
} else {
StringBuffer monthBegin = new StringBuffer();
StringBuffer monthEnd = new StringBuffer();
//非闰年
if ("2".equals(month) && month < 10) {
monthBegin.append(year).append("-").append(0).append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(0).append(month).append("-").append(end1);
}
if ("2".equals(month) && month >= 10) {
monthBegin.append(year).append("-").append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(month).append("-").append(end1);
}
if (bigMonthList.contains(month) && month < 10) {
monthBegin.append(year).append("-").append(0).append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(0).append(month).append("-").append(end4);
}
if (bigMonthList.contains(month) && month >= 10) {
monthBegin.append(year).append("-").append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(month).append("-").append(end4);
}
if (smallMonthList.contains(month) && month < 10) {
monthBegin.append(year).append("-").append(0).append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(0).append(month).append("-").append(end3);
}
if (bigMonthList.contains(month) && month >= 10) {
monthBegin.append(year).append("-").append(month).append("-").append(begin);
monthEnd.append(year).append("-").append(month).append("-").append(end3);
}
result.add(monthBegin.toString());
result.add(monthEnd.toString());
}
return result;
}
public static int getAgeByBirth(Date birthDay) throws ParseException {
int age = 0;
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算
throw new IllegalArgumentException(
"The birthDay is before Now.It's unbelievable!");
}
int yearNow = cal.get(Calendar.YEAR); //当前年份
int monthNow = cal.get(Calendar.MONTH); //当前月份
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); //当前日期
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
int monthBirth = cal.get(Calendar.MONTH);
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
age = yearNow - yearBirth; //计算整岁数
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth) {
age--;//当前日期在生日之前,年龄减一
}
} else {
age--;//当前月份在生日之前,年龄减一
}
}
return age;
}
}
package com.ebaiyihui.family.doctor.server.util;
import com.ebaiyihui.family.doctor.server.common.enums.GenderEnum;
import org.apache.commons.lang.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @ClassName: IDCardUtil
* @Author:yanliang
* @Date:2024/3/13 16:40
* @Description
*/
public class IDCardUtil {
/**
* 通过身份证号码获取年龄
*
* @param idcard
* @return
* @throws ParseException
* @author ZhangWei
*/
public static Integer getAge(String idcard) {
if (idcard == null) {
return null;
}
//身份证位数不足统一返回null
if (idcard.length() != 18) {
return null;
}
return getAgeByBirthDates(idcard.substring(6, 14), "yyyyMMdd");
}
public static Integer getAgeByBirthDates(String birthDateStr) {
return getAgeByBirthDates(birthDateStr, "yyyy-MM-dd");
}
public static Integer getAgeByBirthDates(String birthDateStr, String format) {
if (birthDateStr == null || format == null) {
return 0;
}
Date birthDate;
try {
birthDate = new SimpleDateFormat(format).parse(birthDateStr);
} catch (ParseException e) {
return 0;
}
// 判断出身日期的合法性
Calendar calendar = Calendar.getInstance();
if (calendar.before(birthDate)) {
return 0;
}
// 获取当前时间的 年 月 日
int yearNow = calendar.get(Calendar.YEAR);
int monthNow = calendar.get(Calendar.MONTH);
int dayOfMonthNow = calendar.get(Calendar.DAY_OF_MONTH);
// 获取出身日期的年月日
calendar.setTime(birthDate);
int yearBirth = calendar.get(Calendar.YEAR);
int monthBirth = calendar.get(Calendar.MONTH);
int dayOfMonthBirth = calendar.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth;
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth) {
age--;
}
} else {
age--;
}
}
return age;
}
public static String getGender(String idcard) {
if (StringUtils.isBlank(idcard)) {
return null;
}
String gender = null;
char[] number = idcard.toCharArray();
boolean flag = true;
int oldLength = 15;
int newLength = 18;
if (number.length == oldLength) {
for (int x = 0; x < number.length; x++) {
if (!flag) {
return null;
}
flag = Character.isDigit(number[x]);
}
} else if (number.length == newLength) {
for (int x = 0; x < number.length - 1; x++) {
if (!flag) {
return null;
}
flag = Character.isDigit(number[x]);
}
}
if (flag && idcard.length() == oldLength) {
gender = Integer.parseInt(idcard.substring(idcard.length() - 3, idcard.length()))
% 2 == 0 ? GenderEnum.FEMALE.getDesc() : GenderEnum.MALE.getDesc();
} else if (flag && idcard.length() == newLength) {
gender = Integer.parseInt(idcard.substring(idcard.length() - 4, idcard.length() - 1)) % 2 == 0
? GenderEnum.FEMALE.getDesc() : GenderEnum.MALE.getDesc();
}
return gender;
}
public static Integer getGenderForInteger(String idcard) {
if (StringUtils.isBlank(idcard)) {
return null;
}
Integer gender = null;
char[] number = idcard.toCharArray();
boolean flag = true;
int oldLength = 15;
int newLength = 18;
if (number.length == oldLength) {
for (int x = 0; x < number.length; x++) {
if (!flag) {
return null;
}
flag = Character.isDigit(number[x]);
}
} else if (number.length == newLength) {
for (int x = 0; x < number.length - 1; x++) {
if (!flag) {
return null;
}
flag = Character.isDigit(number[x]);
}
}
if (flag && idcard.length() == oldLength) {
gender = Integer.parseInt(idcard.substring(idcard.length() - 3, idcard.length()))
% 2 == 0 ? GenderEnum.FEMALE.getValue() : GenderEnum.MALE.getValue();
} else if (flag && idcard.length() == newLength) {
gender = Integer.parseInt(idcard.substring(idcard.length() - 4, idcard.length() - 1)) % 2 == 0
? GenderEnum.FEMALE.getValue() : GenderEnum.MALE.getValue();
}
return gender;
}
/**
* 通过身份证号码获取生日 格式 yyyy-MM-dd
*/
public static String getBirthByIdCard(String idCard) {
if (idCard == null) {
return null;
}
//身份证位数不足统一返回null
if (idCard.length() != 18) {
return null;
}
String year = idCard.substring(6, 10);
String month = idCard.substring(10, 12);
String day = idCard.substring(12, 14);
String birth = year + "-" + month + "-" + day;
return birth;
}
}
package com.ebaiyihui.family.doctor.server.util;
import com.alibaba.fastjson.JSONArray;
import com.ebaiyihui.family.doctor.common.vo.ImInfoListResVo;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName: JsonUtil
* @Author:yanliang
* @Date:2024/3/13 11:23
* @Description
*/
public class JsonUtil {
private static ObjectMapper mapper = new ObjectMapper();
@SuppressWarnings("rawtypes")
public static <T> List<T> convertCollection(String json, Class<? extends Collection> collection, Class<T> clazz) {
try {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
CollectionType javaType = mapper.getTypeFactory().constructCollectionType(collection, clazz);
return (List) mapper.readValue(json, javaType);
} catch (Exception var4) {
var4.printStackTrace();
return null;
}
}
public static <T> T convertObject(String json, Class<T> clazz) {
try {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.readValue(json, clazz);
} catch (Exception var3) {
var3.printStackTrace();
return null;
}
}
public static String convertObject(Object object) {
try {
return mapper.writeValueAsString(object);
} catch (Exception var2) {
var2.printStackTrace();
return null;
}
}
/**
* 对象转换为json字符串
*/
public static String toJson(Object bean) {
String json = null;
JsonGenerator gen = null;
StringWriter sw = new StringWriter();
try {
gen = new JsonFactory().createGenerator(sw);
mapper.writeValue(gen, bean);
json = sw.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
try {
if (gen != null) {
gen.close();
}
if (sw != null) {
sw.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return json;
}
/**
* json 转 List<T>
*/
public static <T> List<T> json2ListBean(String jsonString, Class<T> clazz) {
@SuppressWarnings("unchecked")
List<T> ts = (List<T>) JSONArray.parseArray(jsonString, clazz);
return ts;
}
/**
* string转list集合,使用,进行分隔
*
* @param strs
* @return
*/
public static List<String> stringToList(String strs) {
String[] str = strs.split(",");
return Arrays.asList(str);
}
public static void main(String[] args) {
List<ImInfoListResVo> records = new ArrayList<>();
ImInfoListResVo imInfoListResVo = new ImInfoListResVo();
imInfoListResVo.setPatientId("1111");
imInfoListResVo.setAdmId("22222");
records.add(imInfoListResVo);
ImInfoListResVo imInfoListResVo2 = new ImInfoListResVo();
imInfoListResVo2.setPatientId("1111");
imInfoListResVo2.setAdmId("33333");
records.add(imInfoListResVo2);
ImInfoListResVo imInfoListResVo3 = new ImInfoListResVo();
imInfoListResVo3.setPatientId("2222");
imInfoListResVo3.setAdmId("33333");
records.add(imInfoListResVo3);
Map<String, List<ImInfoListResVo>> collect =
records.stream().collect(Collectors.groupingBy(ImInfoListResVo::getPatientId));
System.out.println(collect);
}
}
package com.ebaiyihui.family.doctor.server.util;
import com.github.pagehelper.Page;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
/**
* @ClassName: PageUtil
* @Author:yanliang
* @Date:2024/3/13 15:31
* @Description
*/
public final class PageUtil<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总记录数
*/
private long total;
/**
* 结果集
*/
private List<T> list;
private Object object;
public PageUtil() {
super();
}
public PageUtil(List<T> list) {
if (list instanceof Page) {
Page page = (Page) list;
this.list = page;
this.total = page.getTotal();
} else if (list instanceof Collection) {
this.list = list;
this.total = list.size();
}
}
public static int getTotalPage(int total, int pageSize) {
int totalPage = (total + pageSize - 1) / pageSize;
return totalPage;
}
/**
* Getter method for property <tt>total</tt>.
*
* @return property value of total
*/
public long getTotal() {
return total;
}
/**
* Setter method for property <tt>total</tt>.
*
* @param total value to be assigned to property total
*/
public void setTotal(long total) {
this.total = total;
}
/**
* Getter method for property <tt>list</tt>.
*
* @return property value of list
*/
public List<T> getList() {
return list;
}
/**
* Setter method for property <tt>list</tt>.
*
* @param list value to be assigned to property list
*/
public void setList(List<T> list) {
this.list = list;
}
public Object getObject() {
return object;
}
public void setObject(Object object) {
this.object = object;
}
}
package com.ebaiyihui.family.doctor.server.util;
import java.util.Random;
import java.util.UUID;
/**
* @ClassName: UUIDUtil
* @Author:yanliang
* @Date:2024/3/13 09:57
* @Description
*/
public class UUIDUtil {
/**
* 得到UUID
*
* @return
*/
public static String getUUID() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
/**
* 生成返回给界面的唯一ID,防止数据库的自增ID被获取
*
* @return
*/
public static String generateViewId() {
Long timestamp = System.currentTimeMillis();
// 生成三位随机数
StringBuilder result = new StringBuilder();
Random random = new Random();
for (int i = 0; i < 6; i++) {
result.append(random.nextInt(10));
}
return String.valueOf(timestamp) + result.toString();
}
}
spring:
# redis:
# database: 0
# cluster:
# nodes: 39.105.23.253:6382,39.106.26.175:6381,101.200.127.120:6382
# timeout: 3600
# jedis:
# shutdown-timeout: 3600
# pool:
# max-wait: -1
# max-active: 300
# max-idle: 8
# min-idle: 2
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: Bykf@2020@..
url: jdbc:mysql://192.168.0.103:3310/byh-family-doctor?useUnicode=true&characterEncoding=utf8
cache:
cache-names: dataCache
type: REDIS
# rabbitmq:
# host: 123.57.93.190
# port: 5672
# username: byh
# password: byh2019@ZW..
jackson:
serialization:
WRITE_DATES_AS_TIMESTAMPS: true
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://discover:1111/eureka
feign:
hystrix:
enabled: true # 开启Feign熔断
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 50000
ribbon:
ReadTimeout: 50000
ConnectTimeout: 50000
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
logging:
config: classpath:logback-spring.xml
path: data/log
swagger:
enabled: true
cloudDoctorUrl: https://testapi.chinachdu.com/cloud/doctorbasedata/
cloudDoctorUserUrl: https://testapi.chinachdu.com/cloud/doctoruser/
\ No newline at end of file
spring:
# redis:
# database: 0
# cluster:
# nodes: 39.105.23.253:6382,39.106.26.175:6381,101.200.127.120:6382
# timeout: 3600
# jedis:
# shutdown-timeout: 3600
# pool:
# max-wait: -1
# max-active: 300
# max-idle: 8
# min-idle: 2
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: Bykf@2020@..
url: jdbc:mysql://192.168.0.108:3311/byh-family-doctor?useUnicode=true&characterEncoding=utf8
cache:
cache-names: dataCache
type: REDIS
# rabbitmq:
# host: 123.57.93.190
# port: 5672
# username: byh
# password: byh2019@ZW..
jackson:
serialization:
WRITE_DATES_AS_TIMESTAMPS: true
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://discover:1111/eureka
feign:
hystrix:
enabled: true # 开启Feign熔断
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 50000
ribbon:
ReadTimeout: 50000
ConnectTimeout: 50000
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
logging:
config: classpath:logback-spring.xml
path: data/log
swagger:
enabled: true
cloudDoctorUrl: https://testapi.chinachdu.com/cloud/doctorbasedata/
cloudDoctorUserUrl: https://testapi.chinachdu.com/cloud/doctoruser/
\ No newline at end of file
spring:
# redis:
# database: 0
# cluster:
# nodes: 39.105.23.253:6382,39.106.26.175:6381,101.200.127.120:6382
# timeout: 3600
# jedis:
# shutdown-timeout: 3600
# pool:
# max-wait: -1
# max-active: 300
# max-idle: 8
# min-idle: 2
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: Lyt#2021...
url: jdbc:mysql://192.168.0.103:3310/byh-family-doctor?useUnicode=true&characterEncoding=utf8
cache:
cache-names: dataCache
type: REDIS
# rabbitmq:
# host: 123.57.93.190
# port: 5672
# username: byh
# password: byh2019@ZW..
jackson:
serialization:
WRITE_DATES_AS_TIMESTAMPS: true
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://discover:1111/eureka
feign:
hystrix:
enabled: true # 开启Feign熔断
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 50000
ribbon:
ReadTimeout: 50000
ConnectTimeout: 50000
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
logging:
config: classpath:logback-spring.xml
path: data/log
swagger:
enabled: true
cloudDoctorUrl: https://testapi.chinachdu.com/cloud/doctorbasedata/
cloudDoctorUserUrl: https://testapi.chinachdu.com/cloud/doctoruser/
\ No newline at end of file
server:
port: 9888
spring:
application:
name: byh-family-doctor
# profiles:
# active: test
cloud:
config:
name: byh-family-doctor
profile: pro # 配置文件版本
label: zryh # 配置文件分支
discovery:
enabled: true #是从配置中心读取文件
service-id: byh-service-config
eureka:
client:
serviceUrl:
defaultZone: http://discover:1111/eureka/
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<springProperty scope="context" name="springAppName" source="spring.application.name" />
<springProperty name="LOG_PATH" source="logging.path" defaultValue="data/log/${springAppName}"/>
<property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss:SSS} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([${springAppName:-}]){yellow} %clr(${PID:- }){magenta} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr([%X{caller},%X{user},%X{method}]){green} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" />
<springProperty scope="context" name="FILE_PATTERN" source="log=back.pattern.file" defaultValue="%d{yyyy-MM-dd HH:mm:ss:SSS} ${LOG_LEVEL_PATTERN:-%5p} [${springAppName:-}] ${PID:- } [%15.15t] %-40.40logger{39} [%X{caller},%X{user},%X{method}] : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="flatfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<fileNamePattern>${LOG_PATH}/${springAppName}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>300MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>${FILE_PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="console" />
<appender-ref ref="flatfile" />
</root>
</configuration>
\ No newline at end of file
<?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.ebaiyihui.family.doctor.server.mapper.PatientSignMapper">
<select id="queryImInfoList" parameterType="com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO"
resultType="com.ebaiyihui.family.doctor.common.vo.ImInfoListResVo">
select ps.admission_id admId,
ps.create_time createTime,
ps.update_time updateTime,
ps.status status,
ps.patient_name patientName,
ps.idcard idCard,
ps.patient_id patientId,
from patient_sign ps
where ps.doctor_id=#{param.doctorId}
and ps.sign_status in(1,2)
<if test="param.keyWord!=null and param.keyWord!=''">
and ps.patient_name like concat('%',#{param.keyWord},'%')
</if>
<if test="param.appCode!=null and param.appCode!=''">
and ps.app_code=#{param.appCode}
</if>
order by ps.create_time asc
LIMIT #{param.pageNum}, #{param.pageSize}
</select>
<!-- <select id="getImInfoTotal" parameterType="com.ebaiyihui.onlineoutpatient.core.vo.nczk.vo.ZkFbImInfoListDocReqVo"-->
<!-- resultType="java.lang.Integer">-->
<!-- select count(*)-->
<!-- from medical_admission_ref r join inquiry_admission a on r.admission_id=a.x_id-->
<!-- join inquiry_order o on a.order_id=o.x_id-->
<!-- join inquiry_patient p on a.patient_id=p.x_id-->
<!-- join inquiry_patient_medical_record m on a.medical_record_id=m.x_id-->
<!-- where (o.keep_order = 1 OR o.keep_order = 3)-->
<!-- and o.doctor_id=#{param.doctorId}-->
<!-- <if test="param.queryType==1">-->
<!-- and r.pre_status = 1-->
<!-- </if>-->
<!-- <if test="param.queryType==2">-->
<!-- and r.pre_status = 5-->
<!-- </if>-->
<!-- <if test="param.keyWord!=null and param.keyWord!=''">-->
<!-- and p.patient_name like concat('%',#{param.keyWord},'%')-->
<!-- </if>-->
<!-- <if test="param.appCode!=null and param.appCode!=''">-->
<!-- and o.app_code=#{param.appCode}-->
<!-- </if>-->
<!-- </select>-->
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ebaiyihui</groupId>
<artifactId>byh-family-doctor</artifactId>
<version>0.0.3-SNAPSHOT</version>
<!-- <version>1.0.0</version>-->
<packaging>pom</packaging>
<name>byh-family-doctor</name>
<description>Demo project for Spring Boot</description>
<profiles>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment><!-- 节点名字environment是自己随意取的 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<java.version>1.8</java.version>
<common.version>0.0.3-SNAPSHOT</common.version>
<docker.image.prefix> byh-registry:5000</docker.image.prefix>
<docker.plugin.version>0.4.13</docker.plugin.version>
<dockerfile.dic>docker</dockerfile.dic>
<node-user-center.version>0.0.3-SNAPSHOT</node-user-center.version>
<card.version>0.0.2-SNAPSHOT</card.version>
<doctoruser-api.version>0.0.3-SNAPSHOT</doctoruser-api.version>
<byh-im-forward.version>0.0.3-SNAPSHOT</byh-im-forward.version>
</properties>
<activation>
<activeByDefault>true</activeByDefault><!-- 默认激活该profile节点-->
</activation>
</profile>
<profile>
<id>pro</id>
<properties>
<environment>pro</environment><!-- 节点名字environment是自己随意取的 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
<java.version>1.8</java.version>
<common.version>1.0.0</common.version>
<docker.image.prefix> byh-registry-pro:5000</docker.image.prefix>
<docker.plugin.version>0.4.13</docker.plugin.version>
<dockerfile.dic>docker-pro</dockerfile.dic>
<node-user-center.version>1.0.0</node-user-center.version>
<card.version>1.0.0</card.version>
<doctoruser-api.version>1.0.0</doctoruser-api.version>
<byh-im-forward.version>1.0.0</byh-im-forward.version>
</properties>
</profile>
</profiles>
<modules>
<module>family-doctor-client</module>
<module>family-doctor-common</module>
<module>family-doctor-server</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--swagger接口文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.ebaiyihui</groupId>
<artifactId>byh-framework-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>public</id>
<name>byhgroup</name>
<url>http://39.106.16.160:9001/nexus/content/groups/public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<url>http://39.106.16.160:9001/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<url>http://39.106.16.160:9001/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论