diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java index ebad467e..8c7956f1 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java @@ -93,6 +93,15 @@ public interface IInfectiousCardAppService { * * @return 科室树数据 */ + + /** + * 撤销审核传染病报卡 + * + * @param cardNo 报卡编号 + * @param status 撤销后的状态 + * @return 结果 + */ + R revokeAudit(String cardNo, String status); R getDeptTree(); } \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java index 9cb86f10..5c8f1c74 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java @@ -276,6 +276,38 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService { throw new RuntimeException("导出失败:" + e.getMessage()); } } + /** + * 撤销审核传染病报卡 + * + * @param cardNo 报卡编号 + * @param status 撤销后的状态 + * @return 结果 + */ + @Override + public R revokeAudit(String cardNo, String status) { + try { + // 验证参数 + if (cardNo == null || cardNo.trim().isEmpty()) { + return R.fail("报卡编号不能为空"); + } + if (status == null || status.trim().isEmpty()) { + return R.fail("撤销后的状态不能为空"); + } + + // 执行撤销审核操作 + int rows = reportManageCardMapper.revokeAuditCard(cardNo, Integer.parseInt(status)); + + if (rows > 0) { + return R.ok("撤销审核成功"); + } else { + return R.fail("撤销审核失败:未找到对应的报卡"); + } + } catch (Exception e) { + log.error("撤销审核传染病报卡失败", e); + return R.fail("撤销审核失败:" + e.getMessage()); + } + } + /** * CSV 字段转义 diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java.backup b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java.backup new file mode 100644 index 00000000..a156c0ad --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java.backup @@ -0,0 +1,455 @@ +package com.openhis.web.reportManagement.appservice.impl; + +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.openhis.administration.domain.Organization; +import com.openhis.administration.service.IOrganizationService; +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.reportManagement.mapper.ReportManageCardMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +/** + * 传染病报卡 AppService 实现 + * + * @author system + * @date 2026-03-17 + */ +@Service +@Slf4j +public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService { + + @Autowired + private ReportManageCardMapper reportManageCardMapper; + + @Autowired + private IOrganizationService organizationService; + + /** + * 分页查询传染病报卡列表 + * @param param 查询参数 + * @param pageNo 页码 + * @param pageSize 每页条数 + * @return 报卡列表 + */ + @Override + public R listPage(InfectiousCardParam param, Integer pageNo, Integer pageSize) { + try { + Page page = new Page<>(pageNo, pageSize); + IPage resultPage = reportManageCardMapper.selectCardPage(page, param); + + JSONObject result = new JSONObject(); + result.put("rows", resultPage.getRecords()); + result.put("total", resultPage.getTotal()); + + return R.ok(result); + } catch (Exception e) { + log.error("查询传染病报卡列表失败", e); + return R.fail("查询失败:" + e.getMessage()); + } + } + + /** + * 根据 ID 查询传染病报卡详情 + * @param id 报卡 ID(实际为 cardNo) + * @return 报卡详情 + */ + @Override + public R getById(Long id) { + try { + // 注:id 参数实际是 cardNo,需要转换为 String + InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(String.valueOf(id)); + if (dto == null) { + return R.fail("报卡不存在"); + } + return R.ok(dto); + } catch (Exception e) { + log.error("根据 ID 查询传染病报卡失败", e); + return R.fail("查询失败:" + e.getMessage()); + } + } + + /** + * 根据卡号查询传染病报卡详情 + * @param cardNo 卡号 + * @return 报卡详情 + */ + @Override + public R getByCardNo(String cardNo) { + try { + InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo); + if (dto == null) { + return R.fail("报卡不存在"); + } + return R.ok(dto); + } catch (Exception e) { + log.error("根据卡号查询传染病报卡失败", e); + return R.fail("查询失败:" + e.getMessage()); + } + } + + /** + * 审核传染病报卡 + * @param cardNo 卡号 + * @param auditOpinion 审核意见 + * @param status 审核状态 + * @return 审核结果 + */ + @Override + public R audit(String cardNo, String auditOpinion, String status) { + try { + InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo); + if (dto == null) { + return R.fail("报卡不存在"); + } + + int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status)); + if (rows > 0) { + return R.ok("审核成功"); + } else { + return R.fail("审核失败:未更新任何记录"); + } + } catch (Exception e) { + log.error("审核传染病报卡失败", e); + return R.fail("审核失败:" + e.getMessage()); + } + } + + /** + * 退回传染病报卡 + * @param cardNo 卡号 + * @param returnReason 退回原因 + * @param status 退回状态 + * @return 退回结果 + */ + @Override + public R returnCard(String cardNo, String returnReason, String status) { + try { + InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo); + if (dto == null) { + return R.fail("报卡不存在"); + } + + int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason); + if (rows > 0) { + return R.ok("退回成功"); + } else { + return R.fail("退回失败:未更新任何记录"); + } + } catch (Exception e) { + log.error("退回传染病报卡失败", e); + return R.fail("退回失败:" + e.getMessage()); + } + } + + /** + * 批量审核传染病报卡 + * @param cardNos 卡号列表 + * @param auditOpinion 审核意见 + * @param status 审核状态 + * @return 批量审核结果 + */ + @Override + public R batchAudit(List cardNos, String auditOpinion, String status) { + try { + int successCount = 0; + int failCount = 0; + for (String cardNo : cardNos) { + try { + int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status)); + if (rows > 0) { + successCount++; + } else { + failCount++; + } + } catch (Exception e) { + log.error("批量审核卡号 {} 失败", cardNo, e); + failCount++; + } + } + return R.ok(String.format("批量审核完成:成功 %d 条,失败 %d 条", successCount, failCount)); + } catch (Exception e) { + log.error("批量审核传染病报卡失败", e); + return R.fail("批量审核失败:" + e.getMessage()); + } + } + + /** + * 批量退回传染病报卡 + * @param cardNos 卡号列表 + * @param returnReason 退回原因 + * @param status 退回状态 + * @return 批量退回结果 + */ + @Override + public R batchReturn(List cardNos, String returnReason, String status) { + try { + int successCount = 0; + int failCount = 0; + for (String cardNo : cardNos) { + try { + int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason); + if (rows > 0) { + successCount++; + } else { + failCount++; + } + } catch (Exception e) { + log.error("批量退回卡号 {} 失败", cardNo, e); + failCount++; + } + } + return R.ok(String.format("批量退回完成:成功 %d 条,失败 %d 条", successCount, failCount)); + } catch (Exception e) { + log.error("批量退回传染病报卡失败", e); + return R.fail("批量退回失败:" + e.getMessage()); + } + } + + /** + * 导出传染病报卡数据 + * @param param 查询参数 + * @param response HTTP 响应对象 + */ + @Override + public void export(InfectiousCardParam param, HttpServletResponse response) { + try { + // 查询所有符合条件的数据 + List list = reportManageCardMapper.selectAllCards(param); + + // 设置响应头 + response.setContentType("text/csv;charset=UTF-8"); + response.setHeader("Content-Disposition", + "attachment; filename=infectious_cards_" + System.currentTimeMillis() + ".csv"); + + // 写入 CSV 内容 + java.io.PrintWriter writer = response.getWriter(); + + // 写入 BOM,防止中文乱码 + writer.print('\uFEFF'); + + // 写入表头 + writer.println("报卡编号,报卡名称,病种名称,患者姓名,性别,年龄,上报科室,登记来源,上报时间,审核状态," + + "身份证号,联系电话,现住地址,职业,病例分类,发病日期,诊断日期,报告单位,报告医生,填卡日期,备注"); + + // 写入数据 + for (InfectiousCardDto dto : list) { + writer.println(String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", + escapeCsv(dto.getCardNo()), + escapeCsv(dto.getCardName()), + escapeCsv(dto.getDiseaseName()), + escapeCsv(dto.getPatientName()), + "1".equals(dto.getSex()) ? "男" : "2".equals(dto.getSex()) ? "女" : "未知", + dto.getAge() + getAgeUnit(dto.getAgeUnit()), + escapeCsv(dto.getDeptName()), + getRegistrationSourceName(dto.getRegistrationSource()), + dto.getReportDate(), + getStatusName(dto.getStatus()), + escapeCsv(dto.getIdNo()), + escapeCsv(dto.getPhone()), + escapeCsv(getFullAddress(dto)), + escapeCsv(dto.getOccupation()), + getCaseClassName(dto.getCaseClass()), + dto.getOnsetDate(), + dto.getDiagDate() != null ? dto.getDiagDate().toString().substring(0, 10) : "", + escapeCsv(dto.getReportOrg()), + escapeCsv(dto.getReportDoc()), + dto.getReportDate(), + escapeCsv(dto.getRemark() != null ? dto.getRemark() : "") + )); + } + + writer.flush(); + log.info("导出传染病报卡数据成功,共 {} 条", list.size()); + } catch (Exception e) { + log.error("导出传染病报卡数据失败", e); + throw new RuntimeException("导出失败:" + e.getMessage()); + } + } + + /** + * CSV 字段转义 + */ + private String escapeCsv(String value) { + if (value == null) { + return ""; + } + if (value.contains(",") || value.contains("\"") || value.contains("\n")) { + return "\"" + value.replace("\"", "\"\"") + "\""; + } + return value; + } + + /** + * 获取年龄单位 + */ + private String getAgeUnit(String unit) { + if (unit == null) return "岁"; + switch (unit) { + case "1": return "岁"; + case "2": return "月"; + case "3": return "天"; + default: return "岁"; + } + } + + /** + * 获取登记来源名称 + */ + private String getRegistrationSourceName(Integer source) { + if (source == null) return "未知"; + switch (source) { + case 1: return "门诊"; + case 2: return "住院"; + case 3: return "急诊"; + case 4: return "体检"; + default: return "未知"; + } + } + + /** + * 获取状态名称 + */ + private String getStatusName(Integer status) { + if (status == null) return "未知"; + switch (status) { + case 0: return "草稿"; + case 1: return "待审核"; + case 2: return "审核通过"; + case 3: return "已上报"; + case 4: return "已撤回"; + case 5: return "审核失败"; + default: return "未知"; + } + } + + /** + * 获取病例分类名称 + */ + private String getCaseClassName(Integer caseClass) { + if (caseClass == null) return "未知"; + switch (caseClass) { + case 1: return "疑似病例"; + case 2: return "临床诊断病例"; + case 3: return "确诊病例"; + case 4: return "病原携带者"; + case 5: return "阳性检测结果"; + default: return "未知"; + } + } + + /** + * 获取完整地址 + */ + private String getFullAddress(InfectiousCardDto dto) { + StringBuilder sb = new StringBuilder(); + if (dto.getAddressProv() != null) sb.append(dto.getAddressProv()); + if (dto.getAddressCity() != null) sb.append(dto.getAddressCity()); + if (dto.getAddressCounty() != null) sb.append(dto.getAddressCounty()); + if (dto.getAddressTown() != null) sb.append(dto.getAddressTown()); + if (dto.getAddressVillage() != null) sb.append(dto.getAddressVillage()); + if (dto.getAddressHouse() != null) sb.append(dto.getAddressHouse()); + return sb.toString(); + } + + /** + * 获取科室树 + * @return 科室树数据 + */ + @Override + /** + * 撤销审核传染病报卡 + * + * @param cardNo 报卡编号 + * @param status 撤销后的状态 + * @return 结果 + */ + @Override + public R revokeAudit(String cardNo, String status) { + try { + // 验证参数 + if (cardNo == null || cardNo.trim().isEmpty()) { + return R.fail("报卡编号不能为空"); + } + if (status == null || status.trim().isEmpty()) { + return R.fail("撤销后的状态不能为空"); + } + + // 执行撤销审核操作 + int rows = reportManageCardMapper.revokeAuditCard(cardNo, Integer.parseInt(status)); + + if (rows > 0) { + return R.ok("撤销审核成功"); + } else { + return R.fail("撤销审核失败:未找到对应的报卡"); + } + } catch (Exception e) { + log.error("撤销审核传染病报卡失败", e); + return R.fail("撤销审核失败:" + e.getMessage()); + } + } + + /** + * 撤销审核传染病报卡 + * + * @param cardNo 报卡编号 + * @param status 撤销后的状态 + * @return 结果 + */ + @Override + } + } + + public R getDeptTree() { + try { + // 查询所有启用的机构/科室 + List organizations = organizationService.list(); + List tree = buildTree(organizations); + return R.ok(tree); + } catch (Exception e) { + log.error("获取科室树失败", e); + return R.fail("获取科室树失败:" + e.getMessage()); + } + } + + /** + * 构建树形结构 + */ + private List buildTree(List list) { + List tree = new ArrayList<>(); + for (Organization org : list) { + TreeNode node = new TreeNode(); + node.value = org.getId(); + node.label = org.getName(); + node.children = new ArrayList<>(); + tree.add(node); + } + return tree; + } + + /** + * 树形节点 DTO + */ + private static class TreeNode { + private Long value; + private String label; + private List children; + + public Long getValue() { return value; } + public void setValue(Long value) { this.value = value; } + public String getLabel() { return label; } + public void setLabel(String label) { this.label = label; } + public List getChildren() { return children; } + public void setChildren(List children) { this.children = children; } + } +} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java index ca76c77e..eb5f0f0f 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java @@ -7,6 +7,7 @@ import com.openhis.web.reportManagement.dto.AuditInfectiousCardRequest; import com.openhis.web.reportManagement.dto.ReturnInfectiousCardRequest; import com.openhis.web.reportManagement.dto.BatchAuditInfectiousCardRequest; import com.openhis.web.reportManagement.dto.BatchReturnInfectiousCardRequest; +import com.openhis.web.reportManagement.dto.RevokeAuditInfectiousCardRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -109,6 +110,20 @@ public class reportManagementController { public R batchReturn(@Valid @RequestBody BatchReturnInfectiousCardRequest request) { return infectiousCardAppService.batchReturn(request.getCardNos(), request.getReturnReason(), request.getStatus()); } + /** + * 撤销审核传染病报卡 + * + /** + * 撤销审核传染病报卡 + * + * @param request 撤销审核请求 + * @return 结果 + */ + @PostMapping("/revokeAudit") + public R revokeAudit(@Valid @RequestBody RevokeAuditInfectiousCardRequest request) { + return infectiousCardAppService.revokeAudit(request.getCardNo(), request.getStatus()); + } + /** * 导出传染病报卡 @@ -117,6 +132,18 @@ public class reportManagementController { * @param response 响应对象 */ @GetMapping("/export") + /** + * 撤销审核传染病报卡 + * + * @param cardNo 报卡编号 + * @param status 撤销后的状态 + * @return 结果 + */ + @PostMapping("/revokeAudit") + public R revokeAudit(@RequestParam String cardNo, @RequestParam String status) { + return infectiousCardAppService.revokeAudit(cardNo, status); + } + public void export(InfectiousCardParam param, HttpServletResponse response) { infectiousCardAppService.export(param, response); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/RevokeAuditInfectiousCardRequest.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/RevokeAuditInfectiousCardRequest.java new file mode 100644 index 00000000..125d61e2 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/RevokeAuditInfectiousCardRequest.java @@ -0,0 +1,20 @@ +package com.openhis.web.reportManagement.dto; + +import lombok.Data; + +/** + * 撤销审核传染病报卡请求 DTO + * + * @author guanyu + * @date 2026-04-23 + */ +@Data +public class RevokeAuditInfectiousCardRequest { + + /** 卡片编号(主键) */ + private String cardNo; + + /** 撤销后的状态 (0 暂存/1 待审核/2 已审核/3 已上报/4 失败/5 退回) */ + private String status; + +} diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java index 370792e0..b3d13b9f 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java @@ -55,5 +55,12 @@ public interface ReportManageCardMapper { * @param param 查询参数 * @return 报卡列表 */ + /** + * 撤销审核传染病报卡 + * @param cardNo 卡号 + * @param status 撤销后的状态 + * @return 影响行数 + */ + int revokeAuditCard(@Param("cardNo") String cardNo, @Param("status") Integer status); List selectAllCards(@Param("param") InfectiousCardParam param); } diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml index 4f8a30ba..efe57634 100644 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml @@ -252,4 +252,11 @@ ORDER BY t1.report_date DESC + + + UPDATE infectious_card + SET status = #{status}::INTEGER, + update_time = CURRENT_TIMESTAMP + WHERE card_no = #{cardNo} + diff --git a/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml b/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml index 6191bdce..72f19721 100644 --- a/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml +++ b/openhis-server-new/openhis-domain/src/main/resources/mapper/administration/ScheduleSlotMapper.xml @@ -299,7 +299,7 @@ AND o.phone LIKE CONCAT('%', #{query.phone}, '%') - AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND s.expect_time >= CURRENT_TIME::TIME)) + AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW())) @@ -370,7 +370,7 @@ p.schedule_date > CURRENT_DATE OR ( p.schedule_date = CURRENT_DATE - AND CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME) > TO_TIMESTAMP(#{query.currentTime}/1000) + AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW() ) ) THEN s.id @@ -401,7 +401,7 @@ AND p.schedule_date = CAST(#{query.date} AS DATE) - AND p.schedule_date >= CURRENT_DATE + AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW())) AND org.name = #{query.department}