疾病报告管理-》报告卡管理:查看报卡详情页缺失“历史审核记录”展示
This commit is contained in:
@@ -20,12 +20,12 @@ public interface InfectiousAuditMapper extends BaseMapper<InfectiousAudit> {
|
||||
/**
|
||||
* 根据报卡编号查询审核记录
|
||||
*/
|
||||
@Select("SELECT * FROM infectious_audit WHERE card_id = #{cardId} ORDER BY audit_time DESC")
|
||||
@Select("SELECT * FROM infectious_audit WHERE card_id::text = #{cardId} ORDER BY audit_time DESC")
|
||||
List<InfectiousAudit> selectByCardId(@Param("cardId") String cardId);
|
||||
|
||||
/**
|
||||
* 获取下一个审核序号
|
||||
*/
|
||||
@Select("SELECT COALESCE(MAX(audit_seq), 0) + 1 FROM infectious_audit WHERE card_id = #{cardId}")
|
||||
@Select("SELECT COALESCE(MAX(audit_seq), 0) + 1 FROM infectious_audit WHERE card_id::text = #{cardId}")
|
||||
Integer getNextAuditSeq(@Param("cardId") String cardId);
|
||||
}
|
||||
|
||||
@@ -104,4 +104,12 @@ public interface IInfectiousCardAppService {
|
||||
R<?> revokeAudit(String cardNo, String status);
|
||||
R<?> getDeptTree();
|
||||
|
||||
/**
|
||||
* 查询报卡审核记录(留痕追溯)
|
||||
*
|
||||
* @param cardNo 报卡编号
|
||||
* @return 审核记录列表
|
||||
*/
|
||||
R<?> getAuditRecords(String cardNo);
|
||||
|
||||
}
|
||||
@@ -4,20 +4,25 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.administration.domain.Organization;
|
||||
import com.openhis.administration.service.IOrganizationService;
|
||||
import com.openhis.infectious.domain.InfectiousAudit;
|
||||
import com.openhis.web.reportManagement.appservice.IInfectiousCardAppService;
|
||||
import com.openhis.web.reportManagement.dto.InfectiousCardDto;
|
||||
import com.openhis.web.reportManagement.dto.InfectiousCardParam;
|
||||
import com.openhis.web.cardmanagement.mapper.InfectiousAuditMapper;
|
||||
import com.openhis.web.reportManagement.mapper.ReportManageCardMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 传染病报卡 AppService 实现
|
||||
@@ -35,6 +40,41 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
@Autowired
|
||||
private IOrganizationService organizationService;
|
||||
|
||||
@Autowired
|
||||
private InfectiousAuditMapper infectiousAuditMapper;
|
||||
|
||||
private void createAuditRecord(String cardNo, Integer statusFrom, Integer statusTo, String auditType,
|
||||
String auditOpinion, String reasonForReturn, boolean isBatch, Integer batchSize) {
|
||||
String safeCardNo = cardNo == null ? null : cardNo.trim();
|
||||
Integer nextSeq = infectiousAuditMapper.getNextAuditSeq(safeCardNo);
|
||||
InfectiousAudit audit = new InfectiousAudit();
|
||||
// infectious_audit.card_id 设计上应存报卡 card_no(字符串)
|
||||
audit.setCardId(safeCardNo);
|
||||
audit.setAuditSeq(nextSeq);
|
||||
audit.setAuditType(auditType);
|
||||
audit.setAuditStatusFrom(statusFrom == null ? null : String.valueOf(statusFrom));
|
||||
audit.setAuditStatusTo(statusTo == null ? null : String.valueOf(statusTo));
|
||||
audit.setAuditTime(LocalDateTime.now());
|
||||
audit.setAuditorId(SecurityUtils.getUserId() != null ? SecurityUtils.getUserId().toString() : null);
|
||||
audit.setAuditorName(SecurityUtils.getUsername());
|
||||
audit.setAuditOpinion(auditOpinion);
|
||||
audit.setReasonForReturn(reasonForReturn);
|
||||
audit.setIsBatch(isBatch);
|
||||
audit.setBatchSize(batchSize);
|
||||
// 通用审计字段(数据库字段建议为 create_time/update_time,与 HisBaseEntity 保持一致)
|
||||
audit.setCreateBy(SecurityUtils.getUsernameSafe());
|
||||
audit.setUpdateBy(SecurityUtils.getUsernameSafe());
|
||||
audit.setCreateTime(new java.util.Date());
|
||||
audit.setUpdateTime(new java.util.Date());
|
||||
audit.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
||||
audit.setDeleteFlag("0");
|
||||
|
||||
int inserted = infectiousAuditMapper.insert(audit);
|
||||
if (inserted <= 0) {
|
||||
throw new RuntimeException("写入审核记录失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询传染病报卡列表
|
||||
* @param param 查询参数
|
||||
@@ -106,15 +146,21 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 审核结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> audit(String cardNo, String auditOpinion, String status) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
String safeCardNo = cardNo == null ? null : cardNo.trim();
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(safeCardNo);
|
||||
if (dto == null) {
|
||||
return R.fail("报卡不存在");
|
||||
}
|
||||
|
||||
int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status));
|
||||
Integer fromStatus = dto.getStatus();
|
||||
Integer toStatus = Integer.parseInt(status);
|
||||
int rows = reportManageCardMapper.auditCard(safeCardNo, Integer.parseInt(status));
|
||||
if (rows > 0) {
|
||||
// 单审核通过:auditType=2
|
||||
createAuditRecord(safeCardNo, fromStatus, toStatus, "2", auditOpinion, null, false, 1);
|
||||
return R.ok("审核成功");
|
||||
} else {
|
||||
return R.fail("审核失败:未更新任何记录");
|
||||
@@ -133,15 +179,21 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 退回结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> returnCard(String cardNo, String returnReason, String status) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
String safeCardNo = cardNo == null ? null : cardNo.trim();
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(safeCardNo);
|
||||
if (dto == null) {
|
||||
return R.fail("报卡不存在");
|
||||
}
|
||||
|
||||
int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason);
|
||||
Integer fromStatus = dto.getStatus();
|
||||
Integer toStatus = Integer.parseInt(status);
|
||||
int rows = reportManageCardMapper.returnCard(safeCardNo, Integer.parseInt(status), returnReason);
|
||||
if (rows > 0) {
|
||||
// 单退回:auditType=4
|
||||
createAuditRecord(safeCardNo, fromStatus, toStatus, "4", null, returnReason, false, 1);
|
||||
return R.ok("退回成功");
|
||||
} else {
|
||||
return R.fail("退回失败:未更新任何记录");
|
||||
@@ -160,14 +212,27 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 批量审核结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> batchAudit(List<String> cardNos, String auditOpinion, String status) {
|
||||
try {
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
for (String cardNo : cardNos) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status));
|
||||
if (rows > 0) {
|
||||
// 批量审核:auditType=1
|
||||
createAuditRecord(
|
||||
cardNo,
|
||||
dto != null ? dto.getStatus() : null,
|
||||
Integer.parseInt(status),
|
||||
"1",
|
||||
auditOpinion,
|
||||
null,
|
||||
true,
|
||||
cardNos.size()
|
||||
);
|
||||
successCount++;
|
||||
} else {
|
||||
failCount++;
|
||||
@@ -192,14 +257,27 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 批量退回结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> batchReturn(List<String> cardNos, String returnReason, String status) {
|
||||
try {
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
for (String cardNo : cardNos) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason);
|
||||
if (rows > 0) {
|
||||
// 批量退回:auditType=3
|
||||
createAuditRecord(
|
||||
cardNo,
|
||||
dto != null ? dto.getStatus() : null,
|
||||
Integer.parseInt(status),
|
||||
"3",
|
||||
null,
|
||||
returnReason,
|
||||
true,
|
||||
cardNos.size()
|
||||
);
|
||||
successCount++;
|
||||
} else {
|
||||
failCount++;
|
||||
@@ -284,20 +362,28 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> revokeAudit(String cardNo, String status) {
|
||||
try {
|
||||
// 验证参数
|
||||
if (cardNo == null || cardNo.trim().isEmpty()) {
|
||||
return R.fail("报卡编号不能为空");
|
||||
}
|
||||
String safeCardNo = cardNo.trim();
|
||||
if (status == null || status.trim().isEmpty()) {
|
||||
return R.fail("撤销后的状态不能为空");
|
||||
}
|
||||
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(safeCardNo);
|
||||
Integer fromStatus = dto != null ? dto.getStatus() : null;
|
||||
Integer toStatus = Integer.parseInt(status);
|
||||
|
||||
// 执行撤销审核操作
|
||||
int rows = reportManageCardMapper.revokeAuditCard(cardNo, Integer.parseInt(status));
|
||||
int rows = reportManageCardMapper.revokeAuditCard(safeCardNo, Integer.parseInt(status));
|
||||
|
||||
if (rows > 0) {
|
||||
// 撤销审核:auditType=5(其他)
|
||||
createAuditRecord(safeCardNo, fromStatus, toStatus, "5", "撤销审核", null, false, 1);
|
||||
return R.ok("撤销审核成功");
|
||||
} else {
|
||||
return R.fail("撤销审核失败:未找到对应的报卡");
|
||||
@@ -411,6 +497,20 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getAuditRecords(String cardNo) {
|
||||
try {
|
||||
if (cardNo == null || cardNo.trim().isEmpty()) {
|
||||
return R.fail("报卡编号不能为空");
|
||||
}
|
||||
List<InfectiousAudit> records = infectiousAuditMapper.selectByCardId(cardNo);
|
||||
return R.ok(records);
|
||||
} catch (Exception e) {
|
||||
log.error("查询审核记录失败, cardNo={}", cardNo, e);
|
||||
return R.fail("查询审核记录失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树形结构
|
||||
*/
|
||||
|
||||
@@ -55,6 +55,14 @@ public class reportManagementController {
|
||||
return infectiousCardAppService.getByCardNo(cardNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询报卡审核记录(留痕追溯)
|
||||
*/
|
||||
@GetMapping("/auditRecords/{cardNo}")
|
||||
public R<?> getAuditRecords(@PathVariable String cardNo) {
|
||||
return infectiousCardAppService.getAuditRecords(cardNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核传染病报卡
|
||||
*/
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
WHERE t1.delete_flag = '0' AND t1.card_no = #{cardNo}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 审核传染病报卡 -->
|
||||
<update id="auditCard">
|
||||
UPDATE infectious_card
|
||||
|
||||
@@ -518,13 +518,16 @@
|
||||
@close="handleDrawerClose"
|
||||
>
|
||||
<template #append>
|
||||
<!-- 审核记录 -->
|
||||
<div class="audit-records-section" v-if="auditRecords.length > 0">
|
||||
<!-- 审核记录:查看/审核都展示,保证留痕可追溯 -->
|
||||
<div
|
||||
class="audit-records-section"
|
||||
v-if="drawerMode === 'view' || (drawerMode === 'audit' && auditRecords.length > 0)"
|
||||
>
|
||||
<h3 class="section-title">审核记录</h3>
|
||||
<el-timeline>
|
||||
<el-timeline v-if="auditRecords.length > 0">
|
||||
<el-timeline-item
|
||||
v-for="record in auditRecords"
|
||||
:key="record.auditId"
|
||||
v-for="(record, idx) in auditRecords"
|
||||
:key="record.auditId || idx"
|
||||
:timestamp="record.auditTime"
|
||||
placement="top"
|
||||
:type="getAuditType(record.auditStatusTo)"
|
||||
@@ -538,8 +541,8 @@
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="record-detail">
|
||||
<span v-if="record.auditOpinion">审核意见:{{ record.auditOpinion }}</span>
|
||||
<span v-if="record.reasonForReturn">退回原因:{{ record.reasonForReturn }}</span>
|
||||
<div v-if="record.auditOpinion">审核意见:{{ record.auditOpinion }}</div>
|
||||
<div v-if="record.reasonForReturn">退回原因:{{ record.reasonForReturn }}</div>
|
||||
</div>
|
||||
<div class="record-status">
|
||||
{{ getStatusName(record.auditStatusFrom) }} → {{ getStatusName(record.auditStatusTo) }}
|
||||
@@ -548,6 +551,7 @@
|
||||
</el-card>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-empty v-else description="暂无审核记录" />
|
||||
</div>
|
||||
|
||||
<!-- 审核操作区域 -->
|
||||
@@ -652,6 +656,7 @@ import InfectiousDiseaseReportDialog from '@/views/doctorstation/components/diag
|
||||
import {
|
||||
listInfectiousCards,
|
||||
getInfectiousCard,
|
||||
getAuditRecords,
|
||||
auditInfectiousCard,
|
||||
returnInfectiousCard,
|
||||
revokeAuditCard,
|
||||
@@ -706,6 +711,8 @@ const drawerMode = ref('view'); // view | audit
|
||||
const drawerLoading = ref(false);
|
||||
const reportDialogRef = ref(null);
|
||||
const currentCard = ref({});
|
||||
// 锁定当前打开的卡号,防止异步/串单导致写错审核记录
|
||||
const activeCardNo = ref('');
|
||||
const auditRecords = ref([]);
|
||||
const auditForm = ref({
|
||||
auditOpinion: '',
|
||||
@@ -950,6 +957,8 @@ async function handleRevokeAudit(row) {
|
||||
async function loadCardDetail(cardNo) {
|
||||
drawerLoading.value = true;
|
||||
try {
|
||||
activeCardNo.value = String(cardNo || '').trim();
|
||||
auditRecords.value = [];
|
||||
// 使用详情 API 获取卡片详细信息
|
||||
const res = await getInfectiousCard(cardNo);
|
||||
if (res.code === 200 && res.data) {
|
||||
@@ -962,8 +971,36 @@ async function loadCardDetail(cardNo) {
|
||||
deptName: res.data.deptName || res.data.createDeptName,
|
||||
diseaseName: res.data.diseaseName || getDiseaseName(res.data.diseaseCode),
|
||||
};
|
||||
// 如果没有单独的审核记录 API,尝试从详情数据中获取
|
||||
auditRecords.value = res.data.auditRecords || res.auditRecords || [];
|
||||
|
||||
const normalizeAuditRecords = (payload) => {
|
||||
if (!payload) return [];
|
||||
if (Array.isArray(payload)) return payload;
|
||||
// 兼容:data 里再包一层
|
||||
if (Array.isArray(payload.data)) return payload.data;
|
||||
// 兼容:分页/列表常见字段
|
||||
if (Array.isArray(payload.records)) return payload.records;
|
||||
if (Array.isArray(payload.rows)) return payload.rows;
|
||||
if (Array.isArray(payload.list)) return payload.list;
|
||||
return [];
|
||||
};
|
||||
|
||||
// 优先使用审核记录 API,确保能看到完整历史;失败再回退到详情内嵌字段
|
||||
try {
|
||||
const recordRes = await getAuditRecords(String(cardNo || '').trim());
|
||||
if (recordRes?.code === 200) {
|
||||
auditRecords.value = normalizeAuditRecords(recordRes.data);
|
||||
} else {
|
||||
auditRecords.value = normalizeAuditRecords(res.data.auditRecords || res.auditRecords);
|
||||
if (auditRecords.value.length === 0) {
|
||||
ElMessage.warning(recordRes?.msg || '获取审核记录失败');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
auditRecords.value = normalizeAuditRecords(res.data.auditRecords || res.auditRecords);
|
||||
if (auditRecords.value.length === 0) {
|
||||
ElMessage.warning('获取审核记录失败');
|
||||
}
|
||||
}
|
||||
reportDialogRef.value?.showReport(currentCard.value);
|
||||
} else {
|
||||
ElMessage.error('获取卡片详情失败');
|
||||
@@ -993,8 +1030,18 @@ async function handlePassCard() {
|
||||
}
|
||||
|
||||
try {
|
||||
const cardNo = String(activeCardNo.value || currentCard.value.cardNo || '').trim();
|
||||
if (!cardNo) {
|
||||
ElMessage.error('未获取到报卡编号,请重新打开后再试');
|
||||
return;
|
||||
}
|
||||
// 防止串单:展示的 currentCard 与锁定卡号不一致时禁止提交
|
||||
if (currentCard.value?.cardNo && String(currentCard.value.cardNo).trim() !== cardNo) {
|
||||
ElMessage.error('报卡编号发生变化,请重新打开报卡后再审核');
|
||||
return;
|
||||
}
|
||||
const res = await auditInfectiousCard({
|
||||
cardNo: currentCard.value.cardNo,
|
||||
cardNo,
|
||||
auditOpinion: auditForm.value.auditOpinion,
|
||||
status: '2'
|
||||
});
|
||||
@@ -1027,8 +1074,17 @@ async function handleReturnCard() {
|
||||
}
|
||||
|
||||
try {
|
||||
const cardNo = String(activeCardNo.value || currentCard.value.cardNo || '').trim();
|
||||
if (!cardNo) {
|
||||
ElMessage.error('未获取到报卡编号,请重新打开后再试');
|
||||
return;
|
||||
}
|
||||
if (currentCard.value?.cardNo && String(currentCard.value.cardNo).trim() !== cardNo) {
|
||||
ElMessage.error('报卡编号发生变化,请重新打开报卡后再退回');
|
||||
return;
|
||||
}
|
||||
const res = await returnInfectiousCard({
|
||||
cardNo: currentCard.value.cardNo,
|
||||
cardNo,
|
||||
returnReason: auditForm.value.returnReason,
|
||||
status: '5'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user