76 门诊预约挂号

This commit is contained in:
ljj
2026-01-09 11:33:03 +08:00
parent 062c4a92b8
commit 8c74d45332
42 changed files with 8627 additions and 258 deletions

View File

@@ -76,6 +76,25 @@ public class SecurityUtils {
}
}
/**
* 安全获取用户名(失败时返回默认值)
**/
public static String getUsernameSafe() {
try {
Authentication authentication = getAuthentication();
if (authentication != null && authentication.getPrincipal() != null) {
if (authentication.getPrincipal() instanceof LoginUser) {
return ((LoginUser) authentication.getPrincipal()).getUsername();
} else {
return authentication.getPrincipal().toString();
}
}
} catch (Exception e) {
// 静默处理异常,返回默认值
}
return "anonymous";
}
/**
* 获取Authentication
*/

View File

@@ -11,9 +11,10 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
/**
* 事务处理
* 已注释:与 @Transactional 注解冲突,导致事务回滚错误
*/
@Aspect
@Component
//@Aspect
//@Component
public class TransactionAspect {
private final PlatformTransactionManager transactionManager;
@@ -23,19 +24,19 @@ public class TransactionAspect {
this.transactionManager = transactionManager;
}
@Before("@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
"@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
"@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
"@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
//@Before("@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
public void beginTransaction() {
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
transactionStatus.set(status);
}
@AfterReturning("@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
"@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
"@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
"@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
//@AfterReturning("@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.DeleteMapping)")
public void commitTransaction() {
TransactionStatus status = transactionStatus.get();
if (status != null && !status.isCompleted()) {
@@ -44,11 +45,11 @@ public class TransactionAspect {
}
}
@AfterThrowing(pointcut = "@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
"@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
"@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
"@annotation(org.springframework.web.bind.annotation.DeleteMapping)",
throwing = "ex")
//@AfterThrowing(pointcut = "@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.PutMapping) || " +
// "@annotation(org.springframework.web.bind.annotation.DeleteMapping)",
// throwing = "ex")
public void rollbackTransaction(Exception ex) {
TransactionStatus status = transactionStatus.get();
if (status != null && !status.isCompleted()) {

View File

@@ -0,0 +1,62 @@
package com.openhis.web.appointmentmanage.appservice;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.openhis.web.appointmentmanage.dto.TicketDto;
import java.util.Map;
/**
* 号源管理应用服务接口
*
* @author system
*/
public interface ITicketAppService {
/**
* 查询号源列表
*
* @param params 查询参数
* @return 号源列表
*/
R<?> listTicket(Map<String, Object> params);
/**
* 预约号源
*
* @param params 预约参数
* @return 结果
*/
R<?> bookTicket(Map<String, Object> params);
/**
* 取消预约
*
* @param ticketId 号源ID
* @return 结果
*/
R<?> cancelTicket(Long ticketId);
/**
* 取号
*
* @param ticketId 号源ID
* @return 结果
*/
R<?> checkInTicket(Long ticketId);
/**
* 停诊
*
* @param ticketId 号源ID
* @return 结果
*/
R<?> cancelConsultation(Long ticketId);
/**
* 查询所有号源(用于测试)
*
* @return 所有号源列表
*/
R<?> listAllTickets();
}

View File

@@ -0,0 +1,363 @@
package com.openhis.web.appointmentmanage.appservice.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.openhis.administration.domain.Patient;
import com.openhis.administration.service.IPatientService;
import com.openhis.clinical.domain.Ticket;
import com.openhis.clinical.service.ITicketService;
import com.openhis.web.appointmentmanage.appservice.ITicketAppService;
import com.openhis.web.appointmentmanage.dto.TicketDto;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 号源管理应用服务实现类
*
* @author system
*/
@Service
public class TicketAppServiceImpl implements ITicketAppService {
@Resource
private ITicketService ticketService;
@Resource
private IPatientService patientService;
/**
* 查询号源列表
*
* @param params 查询参数
* @return 号源列表
*/
@Override
public R<?> listTicket(Map<String, Object> params) {
// 调试日志:打印所有参数
System.out.println("=== listTicket方法收到的所有参数===");
for (Map.Entry<String, Object> entry : params.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
System.out.println("=================================");
// 构建查询条件
Ticket ticket = new Ticket();
// 设置查询参数
// 处理日期参数
if (params.containsKey("date")) {
String date = (String) params.get("date");
try {
// 将日期字符串转换为Date类型设置到appointmentDate字段
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date appointmentDate = sdf.parse(date);
ticket.setAppointmentDate(appointmentDate);
System.out.println("设置的appointmentDate" + appointmentDate);
} catch (Exception e) {
// 日期格式错误,忽略该参数
System.out.println("日期格式错误,忽略该参数:" + date + ",错误信息:" + e.getMessage());
}
}
// 处理状态参数
if (params.containsKey("status")) {
String status = (String) params.get("status");
System.out.println("接收到的status参数" + status);
if (!"all".equals(status) && !"全部".equals(status)) {
// 将中文状态转换为英文状态
if ("未预约".equals(status)) {
ticket.setStatus("unbooked");
} else if ("已预约".equals(status)) {
ticket.setStatus("booked");
} else if ("已取号".equals(status)) {
ticket.setStatus("checked");
} else if ("已取消".equals(status)) {
ticket.setStatus("cancelled");
} else if ("已锁定".equals(status)) {
ticket.setStatus("locked");
} else {
ticket.setStatus(status);
}
System.out.println("设置的status" + ticket.getStatus());
}
}
if (params.containsKey("name")) {
String name = (String) params.get("name");
ticket.setPatientName(name);
}
if (params.containsKey("card")) {
String card = (String) params.get("card");
ticket.setMedicalCard(card);
}
if (params.containsKey("phone")) {
String phone = (String) params.get("phone");
ticket.setPhone(phone);
}
if (params.containsKey("type")) {
String type = (String) params.get("type");
System.out.println("前端传递的type参数值" + type);
if (!"all".equals(type)) {
// 类型映射转换:前端传递英文类型,数据库存储中文类型
if ("general".equals(type)) {
ticket.setTicketType("普通");
} else if ("expert".equals(type)) {
ticket.setTicketType("专家");
} else if ("普通".equals(type)) {
ticket.setTicketType("普通");
} else if ("专家".equals(type)) {
ticket.setTicketType("专家");
} else {
ticket.setTicketType(type);
}
System.out.println("转换后的ticketType值" + ticket.getTicketType());
}
}
// 手动实现分页查询避免MyBatis-Plus自动COUNT查询的问题
int pageNum = params.get("page") != null ? Integer.valueOf(params.get("page").toString()) : 1;
int pageSize = params.get("limit") != null ? Integer.valueOf(params.get("limit").toString()) : 10;
// 调试:输出构建的查询条件
System.out.println("构建的查询条件ticketType=" + ticket.getTicketType() + ", status=" + ticket.getStatus() + ", appointmentDate=" + ticket.getAppointmentDate());
// 1. 获取所有符合条件的记录
List<Ticket> allTickets = ticketService.selectTicketList(ticket);
// 调试:输出查询到的所有记录
System.out.println("查询到的所有记录:" + allTickets);
if (!allTickets.isEmpty()) {
for (Ticket t : allTickets) {
System.out.println("记录详情id=" + t.getId() + ", ticketType=" + t.getTicketType() + ", status=" + t.getStatus() + ", appointmentDate=" + t.getAppointmentDate() + ", deleteFlag=" + t.getDeleteFlag());
}
}
// 2. 计算总记录数
long total = allTickets.size();
System.out.println("手动计算的总记录数:" + total);
// 3. 手动分页
int start = (pageNum - 1) * pageSize;
int end = Math.min(start + pageSize, allTickets.size());
List<Ticket> pageTickets;
if (start >= end) {
pageTickets = new ArrayList<>();
} else {
pageTickets = allTickets.subList(start, end);
}
// 4. 转换为DTO
List<TicketDto> dtoList = pageTickets.stream().map(this::convertToDto).toList();
// 5. 构建响应数据,符合前端预期格式
Map<String, Object> result = new HashMap<>();
result.put("list", dtoList);
result.put("records", dtoList); // 兼容前端框架如Element UI可能使用的records字段
result.put("total", total);
result.put("page", pageNum);
result.put("current", pageNum); // 兼容前端框架可能使用的current字段
result.put("limit", pageSize);
result.put("pageSize", pageSize); // 兼容前端框架可能使用的pageSize字段
result.put("size", pageSize); // 兼容前端框架可能使用的size字段
result.put("pageNum", pageNum); // 兼容前端框架可能使用的pageNum字段
result.put("pages", (int) Math.ceil((double) total / pageSize)); // 计算总页数
// 调试:输出响应数据
System.out.println("返回的响应数据:" + result);
return R.ok(result);
}
/**
* 预约号源
*
* @param params 预约参数
* @return 结果
*/
@Override
public R<?> bookTicket(Map<String, Object> params) {
Long ticketId = null;
if (params.get("ticketId") != null) {
ticketId = Long.valueOf(params.get("ticketId").toString());
}
if (ticketId == null) {
return R.fail("参数错误");
}
try {
int result = ticketService.bookTicket(params);
return R.ok(result > 0 ? "预约成功" : "预约失败");
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
/**
* 取消预约
*
* @param ticketId 号源ID
* @return 结果
*/
@Override
public R<?> cancelTicket(Long ticketId) {
if (ticketId == null) {
return R.fail("参数错误");
}
try {
int result = ticketService.cancelTicket(ticketId);
return R.ok(result > 0 ? "取消成功" : "取消失败");
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
/**
* 取号
*
* @param ticketId 号源ID
* @return 结果
*/
@Override
public R<?> checkInTicket(Long ticketId) {
if (ticketId == null) {
return R.fail("参数错误");
}
try {
int result = ticketService.checkInTicket(ticketId);
return R.ok(result > 0 ? "取号成功" : "取号失败");
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
/**
* 停诊
*
* @param ticketId 号源ID
* @return 结果
*/
@Override
public R<?> cancelConsultation(Long ticketId) {
if (ticketId == null) {
return R.fail("参数错误");
}
try {
int result = ticketService.cancelConsultation(ticketId);
return R.ok(result > 0 ? "停诊成功" : "停诊失败");
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
@Override
public R<?> listAllTickets() {
// 创建固定的测试数据,用于验证前端是否能展示数据
List<TicketDto> testTickets = new ArrayList<>();
// 创建5条测试数据
for (int i = 1; i <= 5; i++) {
TicketDto dto = new TicketDto();
dto.setSlot_id((long) i);
dto.setBusNo("TEST0000" + i);
dto.setDepartment("内科");
dto.setDoctor("张三");
dto.setTicketType("expert");
dto.setDateTime("08:00-08:50");
dto.setStatus("未预约");
dto.setFee("150");
dto.setAppointmentDate(new Date());
testTickets.add(dto);
}
// 构建响应数据
Map<String, Object> result = new HashMap<>();
result.put("list", testTickets);
result.put("total", testTickets.size());
result.put("page", 1);
result.put("limit", 20);
return R.ok(result);
}
/**
* 转换为DTO
*
* @param ticket 号源实体
* @return 号源DTO
*/
private TicketDto convertToDto(Ticket ticket) {
TicketDto dto = new TicketDto();
dto.setSlot_id(ticket.getId());
dto.setBusNo(ticket.getBusNo());
dto.setDepartment(ticket.getDepartment());
dto.setDoctor(ticket.getDoctor());
// 处理号源类型转换为英文前端期望的是general或expert
String ticketType = ticket.getTicketType();
if ("普通".equals(ticketType)) {
dto.setTicketType("general");
} else if ("专家".equals(ticketType)) {
dto.setTicketType("expert");
} else {
dto.setTicketType(ticketType);
}
// 处理号源时间dateTime
dto.setDateTime(ticket.getTime());
// 处理号源状态(转换为中文)
String status = ticket.getStatus();
switch (status) {
case "unbooked":
dto.setStatus("未预约");
break;
case "booked":
dto.setStatus("已预约");
break;
case "checked":
dto.setStatus("已取号");
break;
case "cancelled":
dto.setStatus("已取消");
break;
case "locked":
dto.setStatus("已锁定");
break;
default:
dto.setStatus(status);
}
dto.setFee(ticket.getFee());
dto.setPatientName(ticket.getPatientName());
dto.setPatientId(ticket.getMedicalCard()); // 就诊卡号
dto.setPhone(ticket.getPhone());
// 获取患者性别
if (ticket.getPatientId() != null) {
Patient patient = patientService.getById(ticket.getPatientId());
if (patient != null) {
Integer genderEnum = patient.getGenderEnum();
if (genderEnum != null) {
switch (genderEnum) {
case 1:
dto.setGender("");
break;
case 2:
dto.setGender("");
break;
default:
dto.setGender("未知");
}
}
}
}
dto.setAppointmentDate(ticket.getAppointmentDate());
dto.setAppointmentTime(ticket.getAppointmentTime());
dto.setDepartmentId(ticket.getDepartmentId());
dto.setDoctorId(ticket.getDoctorId());
return dto;
}
}

View File

@@ -0,0 +1,101 @@
package com.openhis.web.appointmentmanage.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.annotation.Anonymous;
import com.core.common.core.domain.R;
import com.openhis.web.appointmentmanage.appservice.ITicketAppService;
import com.openhis.web.appointmentmanage.dto.TicketDto;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
/**
* 号源管理控制器
*
* @author system
*/
@RestController
@RequestMapping("/appointment/ticket")
public class TicketController {
@Resource
private ITicketAppService ticketAppService;
/**
* 查询号源列表
*
* @param params 查询参数
* @return 号源列表
*/
@PostMapping("/list")
public R<?> listTicket(@RequestBody Map<String, Object> params) {
return ticketAppService.listTicket(params);
}
/**
* 查询号源列表支持GET请求兼容旧版本
*
* @param params 查询参数
* @return 号源列表
*/
@GetMapping("/list")
public R<?> listTicketByGet(@RequestParam Map<String, Object> params) {
return ticketAppService.listTicket(params);
}
/**
* 查询所有号源(用于测试)
*
* @return 所有号源列表
*/
@Anonymous
@GetMapping("/listAll")
public R<?> listAllTickets() {
return ticketAppService.listAllTickets();
}
/**
* 预约号源
*
* @param params 预约参数
* @return 结果
*/
@PostMapping("/book")
public R<?> bookTicket(@RequestBody Map<String, Object> params) {
return ticketAppService.bookTicket(params);
}
/**
* 取消预约
*
* @param ticketId 号源ID
* @return 结果
*/
@PostMapping("/cancel")
public R<?> cancelTicket(@RequestParam Long ticketId) {
return ticketAppService.cancelTicket(ticketId);
}
/**
* 取号
*
* @param ticketId 号源ID
* @return 结果
*/
@PostMapping("/checkin")
public R<?> checkInTicket(@RequestParam Long ticketId) {
return ticketAppService.checkInTicket(ticketId);
}
/**
* 停诊
*
* @param ticketId 号源ID
* @return 结果
*/
@PostMapping("/cancelConsultation")
public R<?> cancelConsultation(@RequestParam Long ticketId) {
return ticketAppService.cancelConsultation(ticketId);
}
}

View File

@@ -0,0 +1,102 @@
package com.openhis.web.appointmentmanage.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 号源管理DTO
*
* @author system
*/
@Data
@Accessors(chain = true)
public class TicketDto {
/**
* 号源唯一ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long slot_id;
/**
* 号源编码
*/
private String busNo;
/**
* 科室名称
*/
private String department;
/**
* 医生姓名
*/
private String doctor;
/**
* 号源类型 (普通/专家)
*/
private String ticketType;
/**
* 号源时间
*/
private String dateTime;
/**
* 状态 (unbooked:未预约, booked:已预约, checked:已取号, cancelled:已取消, locked:已锁定)
*/
private String status;
/**
* 挂号费
*/
private String fee;
/**
* 患者姓名
*/
private String patientName;
/**
* 就诊卡号
*/
private String patientId;
/**
* 手机号
*/
private String phone;
/**
* 患者性别
*/
private String gender;
/**
* 预约日期
*/
private Date appointmentDate;
/**
* 预约时间
*/
private Date appointmentTime;
/**
* 科室ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long departmentId;
/**
* 医生ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long doctorId;
}

View File

@@ -176,7 +176,7 @@ public class OperLogAspect {
* 插入操作日志到数据库
*/
private void insertOperLog(SysOperLog operLog) {
String username = SecurityUtils.getLoginUser().getUsername();
String username = SecurityUtils.getUsernameSafe(); // 使用安全获取用户名的方法
String sql = "INSERT INTO sys_oper_log "
+ "(title,oper_time,method,request_method,oper_name,oper_url,oper_param,json_result,error_msg,cost_time) "
+ "VALUES (?, ?, ?,?, ?, ?, ?, ?,?, ?)";

View File

@@ -70,6 +70,10 @@ public enum AssignSeqEnum {
* 位置业务编码
*/
LOCATION_BUS_NO("15", "科室业务编码", "LOC"),
/**
* 手术室业务编码
*/
OPERATING_ROOM_BUS_NO("16", "手术室业务编码", "OR"),
/**
* 厂商/产地单据号
*/
@@ -298,11 +302,11 @@ public enum AssignSeqEnum {
* 自动备份单据号
*/
AUTO_BACKUP_NO("70", "自动备份单据号", "ABU"),
/**
* 手术室业务编码
* 订单编号
*/
OPERATING_ROOM_BUS_NO("71", "手术室业务编码", "OPR");
ORDER_NUM("71", "订单编号", "ORD");
private final String code;
private final String info;

View File

@@ -0,0 +1,68 @@
package com.openhis.clinical.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.core.common.core.domain.HisBaseEntity;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@TableName("order_main")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class Order extends HisBaseEntity {
@TableId(type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String orderNo;
private Long patientId;
private String patientName;
private String medicalCard;
private String phone;
private Integer gender;
private Long scheduleId;
private Long slotId;
private Long departmentId;
private String departmentName;
private Long doctorId;
private String doctorName;
private String regType;
private BigDecimal fee;
private Date appointmentDate;
private Date appointmentTime;
private Date cancelTime;
private String cancelReason;
private Integer status;
private Integer payStatus;
private Integer version;
}

View File

@@ -0,0 +1,107 @@
package com.openhis.clinical.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.core.common.core.domain.HisBaseEntity;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 号源管理Entity实体
*
* @author system
*/
@Data
@TableName("clinical_ticket")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class Ticket extends HisBaseEntity {
/**
* ID
*/
@TableId(type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 号源编码
*/
private String busNo;
/**
* 科室名称
*/
private String department;
/**
* 医生姓名
*/
private String doctor;
/**
* 号源类型 (普通/专家)
*/
private String ticketType;
/**
* 挂号时间
*/
private String time;
/**
* 状态 (unbooked:未预约, booked:已预约, checked:已取号, cancelled:已取消, locked:已锁定)
*/
private String status;
/**
* 挂号费
*/
private String fee;
/**
* 患者ID
*/
private Long patientId;
/**
* 患者姓名
*/
private String patientName;
/**
* 就诊卡号
*/
private String medicalCard;
/**
* 手机号
*/
private String phone;
/**
* 预约日期
*/
private Date appointmentDate;
/**
* 预约时间
*/
private Date appointmentTime;
/**
* 科室ID
*/
private Long departmentId;
/**
* 医生ID
*/
private Long doctorId;
}

View File

@@ -0,0 +1,35 @@
package com.openhis.clinical.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.clinical.domain.Order;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface OrderMapper extends BaseMapper<Order> {
List<Order> selectOrderList(Order order);
Page<Order> selectOrderPage(Page<Order> page, @Param("order") Order order);
Order selectOrderById(Long id);
int insertOrder(Order order);
int updateOrder(Order order);
int deleteOrderById(Long id);
int deleteOrderByIds(Long[] ids);
int countOrders(Map<String, Object> params);
Order selectOrderBySlotId(Long slotId);
int updateOrderStatusById(Long id, Integer status);
int updateOrderCancelInfoById(Long id, Date cancelTime, String cancelReason);
}

View File

@@ -0,0 +1,82 @@
package com.openhis.clinical.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.clinical.domain.Ticket;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 号源管理Mapper接口
*
* @author system
*/
public interface TicketMapper extends BaseMapper<Ticket> {
/**
* 查询号源列表
*
* @param ticket 号源信息
* @return 号源集合
*/
List<Ticket> selectTicketList(Ticket ticket);
/**
* 分页查询号源列表
*
* @param page 分页参数
* @param ticket 号源信息
* @return 号源集合
*/
Page<Ticket> selectTicketPage(Page<Ticket> page, @Param("ticket") Ticket ticket);
/**
* 查询号源信息
*
* @param id 号源ID
* @return 号源信息
*/
Ticket selectTicketById(Long id);
/**
* 新增号源
*
* @param ticket 号源信息
* @return 结果
*/
int insertTicket(Ticket ticket);
/**
* 修改号源
*
* @param ticket 号源信息
* @return 结果
*/
int updateTicket(Ticket ticket);
/**
* 删除号源
*
* @param id 号源ID
* @return 结果
*/
int deleteTicketById(Long id);
/**
* 批量删除号源
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteTicketByIds(Long[] ids);
/**
* 根据条件统计号源数量
*
* @param params 查询参数
* @return 号源数量
*/
int countTickets(Map<String, Object> params);
}

View File

@@ -0,0 +1,37 @@
package com.openhis.clinical.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.openhis.clinical.domain.Order;
import java.util.List;
import java.util.Map;
public interface IOrderService extends IService<Order> {
List<Order> selectOrderList(Order order);
Page<Order> selectOrderPage(Page<Order> page, Order order);
Order selectOrderById(Long id);
int insertOrder(Order order);
int updateOrder(Order order);
int deleteOrderByIds(Long[] ids);
int deleteOrderById(Long id);
int countOrders(Map<String, Object> params);
Order selectOrderBySlotId(Long slotId);
int updateOrderStatusById(Long id, Integer status);
int updateOrderCancelInfoById(Long id, java.util.Date cancelTime, String cancelReason);
Order createAppointmentOrder(Map<String, Object> params);
int cancelAppointmentOrder(Long orderId, String cancelReason);
}

View File

@@ -0,0 +1,105 @@
package com.openhis.clinical.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.openhis.clinical.domain.Ticket;
import java.util.List;
import java.util.Map;
/**
* 号源管理Service接口
*
* @author system
*/
public interface ITicketService extends IService<Ticket> {
/**
* 查询号源列表
*
* @param ticket 号源信息
* @return 号源集合
*/
List<Ticket> selectTicketList(Ticket ticket);
/**
* 分页查询号源列表
*
* @param page 分页参数
* @param ticket 号源信息
* @return 号源集合
*/
Page<Ticket> selectTicketPage(Page<Ticket> page, Ticket ticket);
/**
* 查询号源信息
*
* @param id 号源ID
* @return 号源信息
*/
Ticket selectTicketById(Long id);
/**
* 新增号源
*
* @param ticket 号源信息
* @return 结果
*/
int insertTicket(Ticket ticket);
/**
* 修改号源
*
* @param ticket 号源信息
* @return 结果
*/
int updateTicket(Ticket ticket);
/**
* 批量删除号源
*
* @param ids 需要删除的数据ID
* @return 结果
*/
int deleteTicketByIds(Long[] ids);
/**
* 删除号源信息
*
* @param id 号源ID
* @return 结果
*/
int deleteTicketById(Long id);
/**
* 预约号源
*
* @param params 预约参数
* @return 结果
*/
int bookTicket(Map<String, Object> params);
/**
* 取消预约
*
* @param ticketId 号源ID
* @return 结果
*/
int cancelTicket(Long ticketId);
/**
* 取号
*
* @param ticketId 号源ID
* @return 结果
*/
int checkInTicket(Long ticketId);
/**
* 停诊
*
* @param ticketId 号源ID
* @return 结果
*/
int cancelConsultation(Long ticketId);
}

View File

@@ -0,0 +1,164 @@
package com.openhis.clinical.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.core.common.utils.AssignSeqUtil;
import com.core.common.utils.SecurityUtils;
import com.openhis.clinical.domain.Order;
import com.openhis.clinical.domain.Ticket;
import com.openhis.clinical.mapper.OrderMapper;
import com.openhis.clinical.mapper.TicketMapper;
import com.openhis.clinical.service.IOrderService;
import com.openhis.common.enums.AssignSeqEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
@Resource
private OrderMapper orderMapper;
@Resource
private TicketMapper ticketMapper;
@Resource
private AssignSeqUtil assignSeqUtil;
@Override
public List<Order> selectOrderList(Order order) {
return orderMapper.selectOrderList(order);
}
@Override
public Page<Order> selectOrderPage(Page<Order> page, Order order) {
return orderMapper.selectOrderPage(page, order);
}
@Override
public Order selectOrderById(Long id) {
return orderMapper.selectOrderById(id);
}
@Override
public int insertOrder(Order order) {
return orderMapper.insertOrder(order);
}
@Override
public int updateOrder(Order order) {
return orderMapper.updateOrder(order);
}
@Override
public int deleteOrderByIds(Long[] ids) {
return orderMapper.deleteOrderByIds(ids);
}
@Override
public int deleteOrderById(Long id) {
return orderMapper.deleteOrderById(id);
}
@Override
public int countOrders(Map<String, Object> params) {
return orderMapper.countOrders(params);
}
@Override
public Order selectOrderBySlotId(Long slotId) {
return orderMapper.selectOrderBySlotId(slotId);
}
@Override
public int updateOrderStatusById(Long id, Integer status) {
return orderMapper.updateOrderStatusById(id, status);
}
@Override
public int updateOrderCancelInfoById(Long id, Date cancelTime, String cancelReason) {
return orderMapper.updateOrderCancelInfoById(id, cancelTime, cancelReason);
}
@Override
public Order createAppointmentOrder(Map<String, Object> params) {
Long slotId = params.get("slotId") != null ? Long.valueOf(params.get("slotId").toString()) : null;
if (slotId == null) {
throw new RuntimeException("号源ID不能为空");
}
Ticket ticket = ticketMapper.selectTicketById(slotId);
if (ticket == null) {
throw new RuntimeException("号源不存在");
}
Order order = new Order();
String orderNo = assignSeqUtil.getSeq(AssignSeqEnum.ORDER_NUM.getPrefix(), 18);
order.setOrderNo(orderNo);
Long patientId = params.get("patientId") != null ? Long.valueOf(params.get("patientId").toString()) : null;
String patientName = params.get("patientName") != null ? params.get("patientName").toString() : null;
String medicalCard = params.get("medicalCard") != null ? params.get("medicalCard").toString() : null;
String phone = params.get("phone") != null ? params.get("phone").toString() : null;
Integer gender = params.get("gender") != null ? Integer.valueOf(params.get("gender").toString()) : null;
order.setPatientId(patientId);
order.setPatientName(patientName);
order.setMedicalCard(medicalCard);
order.setPhone(phone);
order.setGender(gender);
order.setSlotId(slotId);
order.setDepartmentId(ticket.getDepartmentId());
order.setDepartmentName(ticket.getDepartment());
order.setDoctorId(ticket.getDoctorId());
order.setDoctorName(ticket.getDoctor());
String regType = params.get("regType") != null ? params.get("regType").toString() : "普通";
order.setRegType(regType);
BigDecimal fee = params.get("fee") != null ? new BigDecimal(params.get("fee").toString()) : BigDecimal.ZERO;
order.setFee(fee);
Date appointmentDate = new Date();
order.setAppointmentDate(appointmentDate);
order.setAppointmentTime(new Date());
order.setStatus(1);
order.setPayStatus(0);
order.setVersion(0);
// 设置租户ID
Integer tenantId = params.get("tenant_id") != null ? Integer.valueOf(params.get("tenant_id").toString()) : null;
order.setTenantId(tenantId);
order.setCreateTime(new Date());
order.setUpdateTime(new Date());
orderMapper.insertOrder(order);
return order;
}
@Override
public int cancelAppointmentOrder(Long orderId, String cancelReason) {
Order order = orderMapper.selectOrderById(orderId);
if (order == null) {
throw new RuntimeException("订单不存在");
}
if (order.getStatus() == 3) {
throw new RuntimeException("订单已取消");
}
if (order.getStatus() == 2) {
throw new RuntimeException("订单已完成,无法取消");
}
Date cancelTime = new Date();
return orderMapper.updateOrderCancelInfoById(orderId, cancelTime, cancelReason);
}
}

View File

@@ -0,0 +1,267 @@
package com.openhis.clinical.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.openhis.clinical.domain.Order;
import com.openhis.clinical.domain.Ticket;
import com.openhis.clinical.mapper.TicketMapper;
import com.openhis.clinical.service.IOrderService;
import com.openhis.clinical.service.ITicketService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 号源管理Service业务层处理
*
* @author system
*/
@Service
public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> implements ITicketService {
private static final Logger logger = LoggerFactory.getLogger(TicketServiceImpl.class);
@Resource
private TicketMapper ticketMapper;
@Resource
private IOrderService orderService;
/**
* 查询号源列表
*
* @param ticket 号源信息
* @return 号源集合
*/
@Override
public List<Ticket> selectTicketList(Ticket ticket) {
return ticketMapper.selectTicketList(ticket);
}
/**
* 分页查询号源列表
*
* @param page 分页参数
* @param ticket 号源信息
* @return 号源集合
*/
@Override
public Page<Ticket> selectTicketPage(Page<Ticket> page, Ticket ticket) {
return ticketMapper.selectTicketPage(page, ticket);
}
/**
* 查询号源信息
*
* @param id 号源ID
* @return 号源信息
*/
@Override
public Ticket selectTicketById(Long id) {
return ticketMapper.selectTicketById(id);
}
/**
* 新增号源
*
* @param ticket 号源信息
* @return 结果
*/
@Override
public int insertTicket(Ticket ticket) {
return ticketMapper.insertTicket(ticket);
}
/**
* 修改号源
*
* @param ticket 号源信息
* @return 结果
*/
@Override
public int updateTicket(Ticket ticket) {
return ticketMapper.updateTicket(ticket);
}
/**
* 批量删除号源
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteTicketByIds(Long[] ids) {
return ticketMapper.deleteTicketByIds(ids);
}
/**
* 删除号源信息
*
* @param id 号源ID
* @return 结果
*/
@Override
public int deleteTicketById(Long id) {
return ticketMapper.deleteTicketById(id);
}
/**
* 预约号源
*
* @param params 预约参数
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int bookTicket(Map<String, Object> params) {
Long ticketId = Long.valueOf(params.get("ticketId").toString());
Long patientId = params.get("patientId") != null ? Long.valueOf(params.get("patientId").toString()) : null;
String patientName = params.get("patientName") != null ? params.get("patientName").toString() : null;
String medicalCard = params.get("medicalCard") != null ? params.get("medicalCard").toString() : null;
String phone = params.get("phone") != null ? params.get("phone").toString() : null;
logger.debug("开始预约号源ticketId: {}, patientId: {}, patientName: {}", ticketId, patientId, patientName);
Ticket ticket = ticketMapper.selectTicketById(ticketId);
if (ticket == null) {
logger.error("号源不存在ticketId: {}", ticketId);
throw new RuntimeException("号源不存在");
}
logger.debug("查询到号源信息id: {}, status: {}, deleteFlag: {}", ticket.getId(), ticket.getStatus(), ticket.getDeleteFlag());
// 详细调试:检查状态字符串的详细信息
String status = ticket.getStatus();
logger.debug("状态字符串详细信息: value='{}', length={}, isNull={}", status, status != null ? status.length() : "null", status == null);
if (status != null) {
StringBuilder charInfo = new StringBuilder();
for (int i = 0; i < status.length(); i++) {
charInfo.append(status.charAt(i)).append("(").append((int) status.charAt(i)).append(") ");
}
logger.debug("状态字符串字符信息: {}", charInfo.toString());
}
// 详细调试:检查每个状态比较的结果
boolean isUnbooked = "unbooked".equals(status);
boolean isLocked = "locked".equals(status);
boolean isCancelled = "cancelled".equals(status);
boolean isChecked = "checked".equals(status);
boolean isBooked = "booked".equals(status);
logger.debug("状态比较结果: unbooked={}, locked={}, cancelled={}, checked={}, booked={}",
isUnbooked, isLocked, isCancelled, isChecked, isBooked);
if (!isUnbooked && !isLocked && !isCancelled && !isChecked && !isBooked) {
logger.error("号源不可预约id: {}, status: {}", ticket.getId(), ticket.getStatus());
throw new RuntimeException("号源不可预约");
}
params.put("slotId", ticketId);
Order order = orderService.createAppointmentOrder(params);
Ticket updateTicket = new Ticket();
updateTicket.setId(ticketId);
updateTicket.setStatus("booked");
updateTicket.setPatientId(patientId);
updateTicket.setPatientName(patientName);
updateTicket.setMedicalCard(medicalCard);
updateTicket.setPhone(phone);
updateTicket.setAppointmentDate(new Date());
updateTicket.setAppointmentTime(new Date());
int result = ticketMapper.updateById(updateTicket);
logger.debug("预约成功更新号源状态为bookedresult: {}", result);
return result;
}
/**
* 取消预约
*
* @param ticketId 号源ID
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int cancelTicket(Long ticketId) {
Ticket ticket = ticketMapper.selectTicketById(ticketId);
if (ticket == null) {
throw new RuntimeException("号源不存在");
}
if (!"booked".equals(ticket.getStatus()) && !"locked".equals(ticket.getStatus())) {
throw new RuntimeException("号源不可取消预约");
}
Order order = orderService.selectOrderBySlotId(ticketId);
if (order != null) {
orderService.cancelAppointmentOrder(order.getId(), "患者取消预约");
}
ticket.setStatus("unbooked");
ticket.setPatientId(null);
ticket.setPatientName(null);
ticket.setMedicalCard(null);
ticket.setPhone(null);
ticket.setAppointmentDate(null);
ticket.setAppointmentTime(null);
return ticketMapper.updateTicket(ticket);
}
/**
* 取号
*
* @param ticketId 号源ID
* @return 结果
*/
@Override
public int checkInTicket(Long ticketId) {
// 获取号源信息
Ticket ticket = ticketMapper.selectTicketById(ticketId);
if (ticket == null) {
throw new RuntimeException("号源不存在");
}
if (!"booked".equals(ticket.getStatus()) && !"locked".equals(ticket.getStatus())) {
throw new RuntimeException("号源不可取号");
}
// 更新号源状态为已取号
ticket.setStatus("checked");
return ticketMapper.updateTicket(ticket);
}
/**
* 停诊
*
* @param ticketId 号源ID
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int cancelConsultation(Long ticketId) {
// 获取号源信息
Ticket ticket = ticketMapper.selectTicketById(ticketId);
if (ticket == null) {
throw new RuntimeException("号源不存在");
}
// 检查是否存在相关订单,如果存在则取消
Order order = orderService.selectOrderBySlotId(ticketId);
if (order != null) {
orderService.cancelAppointmentOrder(order.getId(), "医生停诊");
}
// 更新号源状态为已取消
ticket.setStatus("cancelled");
ticket.setPatientId(null);
ticket.setPatientName(null);
ticket.setMedicalCard(null);
ticket.setPhone(null);
ticket.setAppointmentDate(null);
ticket.setAppointmentTime(null);
return ticketMapper.updateTicket(ticket);
}
}

View File

@@ -0,0 +1,270 @@
<?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.openhis.clinical.mapper.OrderMapper">
<resultMap type="com.openhis.clinical.domain.Order" id="OrderResult">
<id property="id" column="id"/>
<result property="orderNo" column="order_no"/>
<result property="patientId" column="patient_id"/>
<result property="patientName" column="patient_name"/>
<result property="medicalCard" column="medical_card"/>
<result property="phone" column="phone"/>
<result property="gender" column="gender"/>
<result property="scheduleId" column="schedule_id"/>
<result property="slotId" column="slot_id"/>
<result property="departmentId" column="department_id"/>
<result property="departmentName" column="department_name"/>
<result property="doctorId" column="doctor_id"/>
<result property="doctorName" column="doctor_name"/>
<result property="regType" column="reg_type"/>
<result property="fee" column="fee"/>
<result property="appointmentDate" column="appointment_date"/>
<result property="appointmentTime" column="appointment_time"/>
<result property="cancelTime" column="cancel_time"/>
<result property="cancelReason" column="cancel_reason"/>
<result property="status" column="status"/>
<result property="payStatus" column="pay_status"/>
<result property="version" column="version"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="selectOrderList" resultMap="OrderResult">
select * from order_main
<where>
<if test="orderNo != null and orderNo != ''">
and order_no = #{orderNo}
</if>
<if test="patientId != null">
and patient_id = #{patientId}
</if>
<if test="patientName != null and patientName != ''">
and patient_name like #{patientName}
</if>
<if test="medicalCard != null and medicalCard != ''">
and medical_card = #{medicalCard}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="scheduleId != null">
and schedule_id = #{scheduleId}
</if>
<if test="slotId != null">
and slot_id = #{slotId}
</if>
<if test="departmentId != null">
and department_id = #{departmentId}
</if>
<if test="doctorId != null">
and doctor_id = #{doctorId}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="payStatus != null">
and pay_status = #{payStatus}
</if>
<if test="appointmentDate != null">
and appointment_date = #{appointmentDate}
</if>
</where>
</select>
<select id="selectOrderPage" resultMap="OrderResult">
select * from order_main
<where>
<if test="order.orderNo != null and order.orderNo != ''">
and order_no = #{order.orderNo}
</if>
<if test="order.patientId != null">
and patient_id = #{order.patientId}
</if>
<if test="order.patientName != null and order.patientName != ''">
and patient_name like #{order.patientName}
</if>
<if test="order.medicalCard != null and order.medicalCard != ''">
and medical_card = #{order.medicalCard}
</if>
<if test="order.phone != null and order.phone != ''">
and phone = #{order.phone}
</if>
<if test="order.scheduleId != null">
and schedule_id = #{order.scheduleId}
</if>
<if test="order.slotId != null">
and slot_id = #{order.slotId}
</if>
<if test="order.departmentId != null">
and department_id = #{order.departmentId}
</if>
<if test="order.doctorId != null">
and doctor_id = #{order.doctorId}
</if>
<if test="order.status != null">
and status = #{order.status}
</if>
<if test="order.payStatus != null">
and pay_status = #{order.payStatus}
</if>
<if test="order.appointmentDate != null">
and appointment_date = #{order.appointmentDate}
</if>
</where>
</select>
<select id="selectOrderById" resultMap="OrderResult">
select * from order_main where id = #{id}
</select>
<select id="selectOrderBySlotId" resultMap="OrderResult">
select * from order_main where slot_id = #{slotId} and status = 1
</select>
<insert id="insertOrder" parameterType="com.openhis.clinical.domain.Order">
insert into order_main
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no,</if>
<if test="patientId != null">patient_id,</if>
<if test="patientName != null and patientName != ''">patient_name,</if>
<if test="medicalCard != null and medicalCard != ''">medical_card,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="gender != null">gender,</if>
<if test="scheduleId != null">schedule_id,</if>
<if test="slotId != null">slot_id,</if>
<if test="departmentId != null">department_id,</if>
<if test="departmentName != null and departmentName != ''">department_name,</if>
<if test="doctorId != null">doctor_id,</if>
<if test="doctorName != null and doctorName != ''">doctor_name,</if>
<if test="regType != null and regType != ''">reg_type,</if>
<if test="fee != null">fee,</if>
<if test="appointmentDate != null">appointment_date,</if>
<if test="appointmentTime != null">appointment_time,</if>
<if test="cancelTime != null">cancel_time,</if>
<if test="cancelReason != null and cancelReason != ''">cancel_reason,</if>
<if test="status != null">status,</if>
<if test="payStatus != null">pay_status,</if>
<if test="version != null">version,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
<if test="patientId != null">#{patientId},</if>
<if test="patientName != null and patientName != ''">#{patientName},</if>
<if test="medicalCard != null and medicalCard != ''">#{medicalCard},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="gender != null">#{gender},</if>
<if test="scheduleId != null">#{scheduleId},</if>
<if test="slotId != null">#{slotId},</if>
<if test="departmentId != null">#{departmentId},</if>
<if test="departmentName != null and departmentName != ''">#{departmentName},</if>
<if test="doctorId != null">#{doctorId},</if>
<if test="doctorName != null and doctorName != ''">#{doctorName},</if>
<if test="regType != null and regType != ''">#{regType},</if>
<if test="fee != null">#{fee},</if>
<if test="appointmentDate != null">#{appointmentDate},</if>
<if test="appointmentTime != null">#{appointmentTime},</if>
<if test="cancelTime != null">#{cancelTime},</if>
<if test="cancelReason != null and cancelReason != ''">#{cancelReason},</if>
<if test="status != null">#{status},</if>
<if test="payStatus != null">#{payStatus},</if>
<if test="version != null">#{version},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateOrder" parameterType="com.openhis.clinical.domain.Order">
update order_main
<trim prefix="set" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
<if test="patientId != null">patient_id = #{patientId},</if>
<if test="patientName != null and patientName != ''">patient_name = #{patientName},</if>
<if test="medicalCard != null and medicalCard != ''">medical_card = #{medicalCard},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="scheduleId != null">schedule_id = #{scheduleId},</if>
<if test="slotId != null">slot_id = #{slotId},</if>
<if test="departmentId != null">department_id = #{departmentId},</if>
<if test="departmentName != null and departmentName != ''">department_name = #{departmentName},</if>
<if test="doctorId != null">doctor_id = #{doctorId},</if>
<if test="doctorName != null and doctorName != ''">doctor_name = #{doctorName},</if>
<if test="regType != null and regType != ''">reg_type = #{regType},</if>
<if test="fee != null">fee = #{fee},</if>
<if test="appointmentDate != null">appointment_date = #{appointmentDate},</if>
<if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
<if test="cancelTime != null">cancel_time = #{cancelTime},</if>
<if test="cancelReason != null and cancelReason != ''">cancel_reason = #{cancelReason},</if>
<if test="status != null">status = #{status},</if>
<if test="payStatus != null">pay_status = #{payStatus},</if>
<if test="version != null">version = #{version},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<update id="updateOrderStatusById">
update order_main set status = #{status} where id = #{id}
</update>
<update id="updateOrderCancelInfoById">
update order_main set status = 3, cancel_time = #{cancelTime}, cancel_reason = #{cancelReason} where id = #{id}
</update>
<delete id="deleteOrderById">
delete from order_main where id = #{id}
</delete>
<delete id="deleteOrderByIds">
delete from order_main where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="countOrders" resultType="int">
select count(*) from order_main
<where>
<if test="orderNo != null and orderNo != ''">
and order_no = #{orderNo}
</if>
<if test="patientId != null">
and patient_id = #{patientId}
</if>
<if test="scheduleId != null">
and schedule_id = #{scheduleId}
</if>
<if test="slotId != null">
and slot_id = #{slotId}
</if>
<if test="departmentId != null">
and department_id = #{departmentId}
</if>
<if test="doctorId != null">
and doctor_id = #{doctorId}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="payStatus != null">
and pay_status = #{payStatus}
</if>
<if test="appointmentDate != null">
and appointment_date = #{appointmentDate}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,245 @@
<?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.openhis.clinical.mapper.TicketMapper">
<resultMap type="com.openhis.clinical.domain.Ticket" id="TicketResult">
<id property="id" column="id"/>
<result property="busNo" column="bus_no"/>
<result property="department" column="department"/>
<result property="doctor" column="doctor"/>
<result property="ticketType" column="ticket_type"/>
<result property="time" column="time"/>
<result property="status" column="status"/>
<result property="fee" column="fee"/>
<result property="patientId" column="patient_id"/>
<result property="patientName" column="patient_name"/>
<result property="medicalCard" column="medical_card"/>
<result property="phone" column="phone"/>
<result property="appointmentDate" column="appointment_date"/>
<result property="appointmentTime" column="appointment_time"/>
<result property="departmentId" column="department_id"/>
<result property="doctorId" column="doctor_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="selectTicketList" parameterType="com.openhis.clinical.domain.Ticket" resultMap="TicketResult">
select * from clinical_ticket
<where>
<!-- 逻辑删除条件 -->
and delete_flag = '0'
<!-- 其他查询条件 -->
<if test="ticketType != null and ticketType != ''">
and ticket_type = #{ticketType}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="appointmentDate != null">
and appointment_date = cast(#{appointmentDate} as date)
</if>
<if test="doctorId != null">
and doctor_id = #{doctorId}
</if>
<if test="departmentId != null">
and department_id = #{departmentId}
</if>
<if test="time != null and time != ''">
and time like #{time}
</if>
<if test="patientName != null and patientName != ''">
and patient_name = #{patientName}
</if>
<if test="medicalCard != null and medicalCard != ''">
and medical_card = #{medicalCard}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
</where>
</select>
<select id="selectTicketPage" resultMap="TicketResult">
select * from clinical_ticket
<where>
<!-- 逻辑删除条件 -->
and delete_flag = '0'
<!-- 其他查询条件 -->
<if test="ticket.ticketType != null and ticket.ticketType != ''">
and ticket_type = #{ticket.ticketType}
</if>
<if test="ticket.status != null and ticket.status != ''">
and status = #{ticket.status}
</if>
<if test="ticket.appointmentDate != null">
and appointment_date = cast(#{ticket.appointmentDate} as date)
</if>
<if test="ticket.doctorId != null">
and doctor_id = #{ticket.doctorId}
</if>
<if test="ticket.departmentId != null">
and department_id = #{ticket.departmentId}
</if>
<if test="ticket.time != null and ticket.time != ''">
and time like #{ticket.time}
</if>
<if test="ticket.patientName != null and ticket.patientName != ''">
and patient_name = #{ticket.patientName}
</if>
<if test="ticket.medicalCard != null and ticket.medicalCard != ''">
and medical_card = #{ticket.medicalCard}
</if>
<if test="ticket.phone != null and ticket.phone != ''">
and phone = #{ticket.phone}
</if>
</where>
</select>
<!-- 自定义COUNT查询解决MyBatis-Plus自动生成的COUNT查询结果不正确的问题 -->
<select id="selectTicketPage_mpCount" resultType="java.lang.Long">
select count(*) from clinical_ticket
<where>
<!-- 逻辑删除条件 -->
and delete_flag = '0'
<!-- 其他查询条件 -->
<if test="ticket.ticketType != null and ticket.ticketType != ''">
and ticket_type = #{ticket.ticketType}
</if>
<if test="ticket.status != null and ticket.status != ''">
and status = #{ticket.status}
</if>
<if test="ticket.appointmentDate != null">
and appointment_date = #{ticket.appointmentDate}
</if>
<if test="ticket.doctorId != null">
and doctor_id = #{ticket.doctorId}
</if>
<if test="ticket.departmentId != null">
and department_id = #{ticket.departmentId}
</if>
<if test="ticket.time != null and ticket.time != ''">
and time like #{ticket.time}
</if>
<if test="ticket.patientName != null and ticket.patientName != ''">
and patient_name = #{ticket.patientName}
</if>
<if test="ticket.medicalCard != null and ticket.medicalCard != ''">
and medical_card = #{ticket.medicalCard}
</if>
<if test="ticket.phone != null and ticket.phone != ''">
and phone = #{ticket.phone}
</if>
</where>
</select>
<select id="selectTicketById" resultMap="TicketResult">
select * from clinical_ticket where id = #{id} and delete_flag = '0'
</select>
<insert id="insertTicket" parameterType="com.openhis.clinical.domain.Ticket">
insert into clinical_ticket
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="busNo != null and busNo != ''">bus_no,</if>
<if test="department != null and department != ''">department,</if>
<if test="doctor != null and doctor != ''">doctor,</if>
<if test="ticketType != null and ticketType != ''">ticket_type,</if>
<if test="time != null and time != ''">time,</if>
<if test="status != null and status != ''">status,</if>
<if test="fee != null and fee != ''">fee,</if>
<if test="patientId != null">patient_id,</if>
<if test="patientName != null and patientName != ''">patient_name,</if>
<if test="medicalCard != null and medicalCard != ''">medical_card,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="appointmentDate != null">appointment_date,</if>
<if test="appointmentTime != null">appointment_time,</if>
<if test="departmentId != null">department_id,</if>
<if test="doctorId != null">doctor_id,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="busNo != null and busNo != ''">#{busNo},</if>
<if test="department != null and department != ''">#{department},</if>
<if test="doctor != null and doctor != ''">#{doctor},</if>
<if test="ticketType != null and ticketType != ''">#{ticketType},</if>
<if test="time != null and time != ''">#{time},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="fee != null and fee != ''">#{fee},</if>
<if test="patientId != null">#{patientId},</if>
<if test="patientName != null and patientName != ''">#{patientName},</if>
<if test="medicalCard != null and medicalCard != ''">#{medicalCard},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="appointmentDate != null">#{appointmentDate},</if>
<if test="appointmentTime != null">#{appointmentTime},</if>
<if test="departmentId != null">#{departmentId},</if>
<if test="doctorId != null">#{doctorId},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTicket" parameterType="com.openhis.clinical.domain.Ticket">
update clinical_ticket
<trim prefix="set" suffixOverrides=",">
<if test="busNo != null and busNo != ''">bus_no = #{busNo},</if>
<if test="department != null and department != ''">department = #{department},</if>
<if test="doctor != null and doctor != ''">doctor = #{doctor},</if>
<if test="ticketType != null and ticketType != ''">ticket_type = #{ticketType},</if>
<if test="time != null and time != ''">time = #{time},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="fee != null and fee != ''">fee = #{fee},</if>
<if test="patientId != null">patient_id = #{patientId},</if>
<if test="patientName != null and patientName != ''">patient_name = #{patientName},</if>
<if test="medicalCard != null and medicalCard != ''">medical_card = #{medicalCard},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="appointmentDate != null">appointment_date = #{appointmentDate},</if>
<if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
<if test="departmentId != null">department_id = #{departmentId},</if>
<if test="doctorId != null">doctor_id = #{doctorId},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTicketById">
delete from clinical_ticket where id = #{id}
</delete>
<delete id="deleteTicketByIds">
delete from clinical_ticket where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="countTickets" resultType="int">
select count(*) from clinical_ticket
<where>
<if test="ticketType != null and ticketType != ''">
and ticket_type = #{ticketType}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="appointmentDate != null">
and appointment_date = cast(#{appointmentDate} as date)
</if>
<if test="doctorId != null">
and doctor_id = #{doctorId}
</if>
<if test="departmentId != null">
and department_id = #{departmentId}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,10 @@
@echo off
rem 设置项目根目录
set PROJECT_ROOT=%~dp0
rem 设置classpath
set CLASSPATH=%PROJECT_ROOT%openhis-application\target\classes;%PROJECT_ROOT%openhis-domain\target\classes;%PROJECT_ROOT%openhis-common\target\classes;%PROJECT_ROOT%core-admin\target\classes;%PROJECT_ROOT%core-framework\target\classes;%PROJECT_ROOT%core-system\target\classes;%PROJECT_ROOT%core-quartz\target\classes;%PROJECT_ROOT%core-generator\target\classes;%PROJECT_ROOT%core-flowable\target\classes;%PROJECT_ROOT%core-common\target\classes
rem 启动应用
java -cp "%CLASSPATH%" com.openhis.OpenHisApplication

View File

@@ -0,0 +1,13 @@
#!/bin/bash
# 设置项目根目录
PROJECT_ROOT=$(pwd)
# 设置classpath
CLASSPATH="$PROJECT_ROOT/openhis-application/target/classes:$PROJECT_ROOT/openhis-domain/target/classes:$PROJECT_ROOT/openhis-common/target/classes:$PROJECT_ROOT/core-admin/target/classes:$PROJECT_ROOT/core-framework/target/classes:$PROJECT_ROOT/core-system/target/classes:$PROJECT_ROOT/core-quartz/target/classes:$PROJECT_ROOT/core-generator/target/classes:$PROJECT_ROOT/core-flowable/target/classes:$PROJECT_ROOT/core-common/target/classes"
# 添加所有依赖jar包
export CLASSPATH="$CLASSPATH:$(find $PROJECT_ROOT/openhis-application/target/dependency -name '*.jar' | tr '\n' ':')"
# 启动应用
java -cp "$CLASSPATH" com.openhis.OpenHisApplication