需求102 门诊医生站-》诊断TAB页:增加报卡弹框登记界面;
1.建立对应数据库表infectious_card 2.实现前端表单样式 3.完成相关表单数据查询以及数据传递与保存
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.openhis.clinical.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.clinical.domain.InfectiousCard;
|
||||
|
||||
/**
|
||||
* 传染病报卡表 Service接口
|
||||
*/
|
||||
public interface IInfectiousCardService extends IService<InfectiousCard> {
|
||||
|
||||
/**
|
||||
* 保存传染病报告卡
|
||||
* @param infectiousCard 传染病报告卡对象
|
||||
* @return 保存结果
|
||||
*/
|
||||
boolean saveInfectiousCard(InfectiousCard infectiousCard);
|
||||
|
||||
/**
|
||||
* 生成下一个卡片编号
|
||||
* @param orgCode 医疗机构编码
|
||||
* @return 下一个卡片编号(机构编码+YYYYMMDD+4位流水号)
|
||||
*/
|
||||
String generateNextCardNo(String orgCode);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.openhis.clinical.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.clinical.domain.InfectiousCard;
|
||||
import com.openhis.clinical.mapper.InfectiousCardMapper;
|
||||
import com.openhis.clinical.service.IInfectiousCardService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 传染病报卡表 Service实现
|
||||
*/
|
||||
@Service
|
||||
public class InfectiousCardServiceImpl extends ServiceImpl<InfectiousCardMapper, InfectiousCard> implements IInfectiousCardService {
|
||||
|
||||
@Override
|
||||
public String generateNextCardNo(String orgCode) {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
String prefix = orgCode + dateStr;
|
||||
|
||||
// --- MyBatis-Plus Lambda 重构部分开始 ---
|
||||
InfectiousCard maxCardEntity = this.lambdaQuery()
|
||||
.select(InfectiousCard::getCardNo) // 只查询编号列
|
||||
.likeRight(InfectiousCard::getCardNo, prefix) // 匹配前缀 (prefix%)
|
||||
.orderByDesc(InfectiousCard::getCardNo) // 按编号降序
|
||||
.last("LIMIT 1") // 取最大的一条
|
||||
.one(); // 获取单条实体
|
||||
|
||||
String maxCardNo = (maxCardEntity != null) ? maxCardEntity.getCardNo() : null;
|
||||
// --- 重构部分结束 ---
|
||||
|
||||
int nextSerial = 1;
|
||||
if (maxCardNo != null && maxCardNo.length() >= 4) {
|
||||
String lastFour = maxCardNo.substring(maxCardNo.length() - 4);
|
||||
try {
|
||||
nextSerial = Integer.parseInt(lastFour) + 1;
|
||||
} catch (NumberFormatException e) {
|
||||
// 流水号解析失败,使用默认值1
|
||||
}
|
||||
}
|
||||
return prefix + String.format("%04d", nextSerial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveInfectiousCard(InfectiousCard infectiousCard) {
|
||||
// 设置默认值
|
||||
if (infectiousCard.getStatus() == null) {
|
||||
infectiousCard.setStatus(0);
|
||||
}
|
||||
|
||||
if (infectiousCard.getReportDate() == null) {
|
||||
infectiousCard.setReportDate(LocalDate.now());
|
||||
}
|
||||
|
||||
if (infectiousCard.getCreateTime() == null) {
|
||||
infectiousCard.setCreateTime(LocalDateTime.now());
|
||||
} else {
|
||||
infectiousCard.setUpdateTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
return this.saveOrUpdate(infectiousCard);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user