增加体检报告生成接口
This commit is contained in:
parent
34593a58b3
commit
5e3ee9e4c8
@ -75,6 +75,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectapplylog.InspectApplylogService;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
@Tag(name = "管理后台 - 患者信息")
|
||||
@RestController
|
||||
@RequestMapping("/inspect/patient")
|
||||
@ -475,14 +477,11 @@ public class InspectPatientController {
|
||||
applylogService.createApplylog(logVO);
|
||||
|
||||
//获取配置项地址
|
||||
//ConfigDO config = configService.getConfigByKey("url.applytj");
|
||||
ConfigDO config = configService.getConfigByKey("url.applytj");
|
||||
// 发送 POST 请求
|
||||
//String url = config.getValue();
|
||||
//获取头像地址
|
||||
//ConfigDO headconfig = configService.getConfigByKey("url.head");
|
||||
//String headurl = headconfig.getValue();
|
||||
String url = config.getValue();
|
||||
|
||||
//String response = HttpUtils.postJson(url, jsonRequestBody);
|
||||
String response = HttpUtils.postJson(url, jsonRequestBody);
|
||||
|
||||
// 记录接口返回值
|
||||
InspectApplylogSaveReqVO responseLogVO = new InspectApplylogSaveReqVO();
|
||||
@ -1230,4 +1229,108 @@ public class InspectPatientController {
|
||||
patientService.isprintupdate(medicalSn, printtime);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/generateReport")
|
||||
@Operation(summary = "生成体检报告")
|
||||
public CommonResult<String> generateReport(@RequestParam("medicalSn") String medicalSn) {
|
||||
try {
|
||||
// 先获取患者信息,检查status
|
||||
InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO == null) {
|
||||
return success("未找到该患者信息");
|
||||
}
|
||||
|
||||
// 检查患者的检查状态
|
||||
if (patientDO.getStatus() == null || patientDO.getStatus() != 1) {
|
||||
return success("患者未完成检查,无法生成报告");
|
||||
}
|
||||
|
||||
// 构建请求JSON
|
||||
Map<String, String> requestBody = new HashMap<>();
|
||||
requestBody.put("medicalSn", medicalSn);
|
||||
|
||||
// 将Map转换为JSON字符串
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonRequestBody = objectMapper.writeValueAsString(requestBody);
|
||||
|
||||
// 发送POST请求
|
||||
String url = "http://114.55.171.231:48085/api/report/generate";
|
||||
String response = HttpUtils.postJson(url, jsonRequestBody);
|
||||
if(response!=null) {
|
||||
// 解析响应,如果成功则保存PDF URL
|
||||
try {
|
||||
Map<String, Object> responseMap = objectMapper.readValue(response, Map.class);
|
||||
if (responseMap != null && responseMap.containsKey("success") && responseMap.get("success").equals(true)) {
|
||||
// 构建PDF URL
|
||||
String pdfUrl = "https://114.55.171.231:48082/reportpdfs/" + medicalSn + "-" + patientDO.getPName() + ".pdf";
|
||||
|
||||
// 更新pdfurl字段
|
||||
InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO();
|
||||
updateReqVO.setMedicalSn(medicalSn);
|
||||
updateReqVO.setPdfurl(pdfUrl);
|
||||
|
||||
// 调用服务更新数据
|
||||
patientService.updatePatientPdfUrl(updateReqVO);
|
||||
|
||||
return success("报告生成成功,URL已保存: " + pdfUrl);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// 如果解析响应失败,仅记录日志但不中断流程
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return success(response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return success("生成报告失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/updateReportUrl")
|
||||
@Operation(summary = "更新患者体检报告URL")
|
||||
public CommonResult<Boolean> updateReportUrl(@RequestParam("medicalSn") String medicalSn,
|
||||
@RequestParam("pdfUrl") String pdfUrl) {
|
||||
try {
|
||||
// 获取患者信息
|
||||
InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO == null) {
|
||||
return success(false, "未找到该患者信息");
|
||||
}
|
||||
|
||||
// 更新pdfurl字段
|
||||
InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO();
|
||||
updateReqVO.setMedicalSn(medicalSn);
|
||||
updateReqVO.setPdfurl(pdfUrl);
|
||||
|
||||
// 调用服务更新数据
|
||||
patientService.updatePatientPdfUrl(updateReqVO);
|
||||
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return success(false, "更新报告URL失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
@GetMapping("/getReportUrl")
|
||||
@Operation(summary = "获取患者体检报告URL")
|
||||
public CommonResult<String> getReportUrl(@RequestParam("cardId") String cardId) {
|
||||
try {
|
||||
// 根据身份证查询患者信息
|
||||
InspectPatientDO patientDO = patientService.getPatientByCardId(cardId);
|
||||
|
||||
// 如果找不到患者记录或者pdfurl为空,返回暂无报告
|
||||
if (patientDO == null || patientDO.getPdfurl() == null || patientDO.getPdfurl().trim().isEmpty()) {
|
||||
// 返回null作为data,并设置msg为"暂无报告"
|
||||
return success(null, "暂无报告");
|
||||
}
|
||||
|
||||
// 返回PDF报告URL到data字段
|
||||
return success(patientDO.getPdfurl(), "成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return success(null, "查询异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,9 +132,12 @@ public class InspectPatientPageReqVO extends PageParam {
|
||||
private LocalDateTime[] printTimeRange;
|
||||
|
||||
@Schema(description = "总检医生id")
|
||||
private Integer chiefinspectorid;
|
||||
private String chiefinspectorid;
|
||||
|
||||
@Schema(description = "总检医生")
|
||||
private String chiefinspector;
|
||||
|
||||
@Schema(description = "报告地址")
|
||||
private String pdfurl;
|
||||
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class InspectPatientRespVO {
|
||||
private LocalDateTime printtime;
|
||||
|
||||
@Schema(description = "总检医生id")
|
||||
private Integer chiefinspectorid;
|
||||
private String chiefinspectorid;
|
||||
|
||||
@Schema(description = "总检医生")
|
||||
private String chiefinspector;
|
||||
|
||||
@ -118,8 +118,11 @@ public class InspectPatientSaveReqVO {
|
||||
private LocalDateTime printtime;
|
||||
|
||||
@Schema(description = "总检医生id")
|
||||
private Integer chiefinspectorid;
|
||||
private String chiefinspectorid;
|
||||
|
||||
@Schema(description = "总检医生")
|
||||
private String chiefinspector;
|
||||
|
||||
@Schema(description = "报告地址")
|
||||
private String pdfurl;
|
||||
}
|
||||
@ -207,5 +207,11 @@ public class InspectPatientDO {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime printtime;
|
||||
|
||||
/**
|
||||
* 报告地址
|
||||
*/
|
||||
@TableField("pdfurl")
|
||||
private String pdfurl;
|
||||
|
||||
|
||||
}
|
||||
@ -76,6 +76,11 @@ public interface InspectPatientService {
|
||||
* */
|
||||
InspectPatientDO getPatientInfo(String medicalSn);
|
||||
|
||||
/*
|
||||
* 根据体检编号更新PDF报告URL
|
||||
* */
|
||||
void updatePatientPdfUrl(@Valid InspectPatientSaveReqVO updateReqVO);
|
||||
|
||||
/*
|
||||
* 根据体检编号更新数据
|
||||
* */
|
||||
@ -115,4 +120,7 @@ public interface InspectPatientService {
|
||||
* 获取患者体检报告单
|
||||
*/
|
||||
Map<String, Object> getPatientInspectDataReport(String medicalSn);
|
||||
|
||||
//根据身份证号获取患者信息
|
||||
InspectPatientDO getPatientByCardId(String cardId);
|
||||
}
|
||||
@ -184,8 +184,13 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updatePatientPdfUrl(InspectPatientSaveReqVO updateReqVO) {
|
||||
LambdaUpdateWrapper<InspectPatientDO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(InspectPatientDO::getMedicalSn, updateReqVO.getMedicalSn());
|
||||
updateWrapper.set(InspectPatientDO::getPdfurl, updateReqVO.getPdfurl());
|
||||
patientMapper.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<InspectPatientDO> getPatientPage(InspectPatientPageReqVO pageReqVO) {
|
||||
@ -701,4 +706,11 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
public Map<String, Object> getPatientInspectDataReport(String medicalSn) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectPatientDO getPatientByCardId(String cardId) {
|
||||
LambdaQueryWrapper<InspectPatientDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(InspectPatientDO::getCardId, cardId);
|
||||
return patientMapper.selectOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user