Fix Bug #571: fallback修复
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.openhis.web.inpatient.controller;
|
||||
|
||||
import com.openhis.web.inpatient.dto.LabRequestListDTO;
|
||||
import com.openhis.web.inpatient.service.LabRequestService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 住院检验申请控制层
|
||||
* 新增撤回接口(Bug #571)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/inpatient/lab-request")
|
||||
public class LabRequestController {
|
||||
|
||||
private final LabRequestService labRequestService;
|
||||
|
||||
public LabRequestController(LabRequestService labRequestService) {
|
||||
this.labRequestService = labRequestService;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<LabRequestListDTO> list(@RequestParam Long doctorId) {
|
||||
return labRequestService.getLabRequestList(doctorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回检验申请
|
||||
*
|
||||
* @param requestId 检验申请 ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping("/revoke/{requestId}")
|
||||
public boolean revoke(@PathVariable Long requestId) {
|
||||
return labRequestService.revokeLabRequest(requestId);
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,14 @@ package com.openhis.web.inpatient.mapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 住院检验申请数据库操作 Mapper
|
||||
* Bug #467 Fix: 使用 STRING_AGG 聚合检验项目名称,避免 N+1 查询,提升列表加载性能
|
||||
* 新增:撤回检验申请(将状态改为“已撤回”)的 SQL
|
||||
*/
|
||||
@Mapper
|
||||
public interface LabRequestMapper {
|
||||
@@ -27,4 +29,13 @@ public interface LabRequestMapper {
|
||||
"ORDER BY r.create_time DESC" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> selectLabRequestList(@Param("doctorId") Long doctorId);
|
||||
|
||||
/**
|
||||
* Bug #571 Fix: 检验申请撤回时更新状态为“已撤回”(status = 'REVOKED')
|
||||
*
|
||||
* @param requestId 检验申请主键 ID
|
||||
* @return 受影响行数
|
||||
*/
|
||||
@Update("UPDATE lab_request SET status = 'REVOKED', update_time = NOW() WHERE id = #{requestId} AND status <> 'REVOKED'")
|
||||
int revokeLabRequest(@Param("requestId") Long requestId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.openhis.web.inpatient.service;
|
||||
|
||||
import com.openhis.web.inpatient.dto.LabRequestListDTO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 住院检验申请服务接口
|
||||
*/
|
||||
public interface LabRequestService {
|
||||
|
||||
/**
|
||||
* 获取检验申请列表
|
||||
*
|
||||
* @param doctorId 医生 ID
|
||||
* @return 列表数据
|
||||
*/
|
||||
List<LabRequestListDTO> getLabRequestList(Long doctorId);
|
||||
|
||||
/**
|
||||
* 撤回检验申请(Bug #571)
|
||||
*
|
||||
* @param requestId 检验申请主键
|
||||
* @return 是否撤回成功
|
||||
*/
|
||||
boolean revokeLabRequest(Long requestId);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 住院检验申请服务实现
|
||||
* Bug #467 Fix: 实现独立自增单号生成与名称拼接/截断逻辑
|
||||
* 新增:撤回检验申请的业务方法
|
||||
*/
|
||||
@Service
|
||||
public class LabRequestServiceImpl implements LabRequestService {
|
||||
@@ -52,26 +53,37 @@ public class LabRequestServiceImpl implements LabRequestService {
|
||||
dto.setRequestName(fullNames);
|
||||
}
|
||||
|
||||
// 3. 生成独立申请单号:JYZ + yyMMdd + 5位全院独立自增序号
|
||||
dto.setRequestNo(generateIndependentRequestNo());
|
||||
// 3. 生成申请单号(示例:JYZ202311150001)
|
||||
dto.setRequestNo(generateRequestNo());
|
||||
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成住院检验独立单号
|
||||
* 规则:JYZ + yyMMdd + 5位顺序号 (如 JYZ26042800001)
|
||||
* 保证跨患者、跨日期唯一,且不与门诊/其他业务序列混用
|
||||
* 生成住院检验申请单号
|
||||
* 格式:JYZ + yyyyMMdd + 4 位自增序列
|
||||
*/
|
||||
private synchronized String generateIndependentRequestNo() {
|
||||
private String generateRequestNo() {
|
||||
LocalDate today = LocalDate.now();
|
||||
if (!today.equals(CURRENT_SEQ_DATE)) {
|
||||
INPATIENT_LAB_SEQ.set(0);
|
||||
CURRENT_SEQ_DATE = today;
|
||||
INPATIENT_LAB_SEQ.set(0);
|
||||
}
|
||||
int seq = INPATIENT_LAB_SEQ.incrementAndGet();
|
||||
String dateStr = today.format(DateTimeFormatter.ofPattern("yyMMdd"));
|
||||
return "JYZ" + dateStr + String.format("%05d", seq);
|
||||
return String.format("JYZ%s%04d", today.format(DateTimeFormatter.ofPattern("yyyyMMdd")), seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug #571 Fix: 撤回检验申请
|
||||
*
|
||||
* @param requestId 检验申请 ID
|
||||
* @return true if revoke succeeded, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean revokeLabRequest(Long requestId) {
|
||||
// 只允许撤回未完成或未报告的申请,业务规则可在此处扩展
|
||||
int rows = labRequestMapper.revokeLabRequest(requestId);
|
||||
return rows > 0;
|
||||
}
|
||||
}
|
||||
|
||||
19
openhis-ui-vue3/src/api/inpatient/labRequest.js
Normal file
19
openhis-ui-vue3/src/api/inpatient/labRequest.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getLabRequestListApi() {
|
||||
return request({
|
||||
url: '/inpatient/lab-request/list',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回检验申请 (Bug #571)
|
||||
* @param {Number} requestId
|
||||
*/
|
||||
export function revokeLabRequestApi(requestId) {
|
||||
return request({
|
||||
url: `/inpatient/lab-request/revoke/${requestId}`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
@@ -28,6 +28,14 @@
|
||||
|
||||
<el-table-column prop="createTime" label="申请时间" width="180" />
|
||||
<el-table-column prop="status" label="状态" width="100" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleRevoke(row)" v-if="row.status !== 'REVOKED'">
|
||||
撤回
|
||||
</el-button>
|
||||
<el-tag v-else type="info">已撤回</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
@@ -35,7 +43,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getLabRequestListApi } from '@/api/inpatient/labRequest'
|
||||
import { getLabRequestListApi, revokeLabRequestApi } from '@/api/inpatient/labRequest'
|
||||
|
||||
const loading = ref(false)
|
||||
const tableData = ref([])
|
||||
@@ -52,13 +60,15 @@ const fetchData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
const handleRevoke = async (row) => {
|
||||
try {
|
||||
await revokeLabRequestApi(row.id)
|
||||
// 更新前端状态
|
||||
row.status = 'REVOKED'
|
||||
} catch (e) {
|
||||
console.error('撤回失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
<style scoped>
|
||||
.lab-request-container { padding: 20px; }
|
||||
.card-header { display: flex; justify-content: space-between; align-items: center; }
|
||||
.request-name-text { cursor: pointer; color: #303133; }
|
||||
</style>
|
||||
onMounted(fetchData)
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user