diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java index 58d3fd830..701b95bfb 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java @@ -199,4 +199,21 @@ public class DateUtils { // 格式化日期 return sdf.format(date); } + + /** + * 时间戳转换日期 + * + */ + public static String formateddatetime(long timestamp) + { + + // 创建Date对象 + Date date = new Date(timestamp); + + // 创建SimpleDateFormat对象,并设置日期格式 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + // 格式化日期 + return sdf.format(date); + } } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java index 1ee02d420..d09e100cd 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java @@ -173,5 +173,46 @@ public class HttpUtils { } } } + /** + * 发送POST请求到指定的URL,并带有JSON类型的请求体。 + * + * @param url 请求的URL地址 + * @param json JSON格式的请求体 + * @return 响应的字符串 + * @throws IOException 如果发生I/O错误 + */ + public static String sendPost(String url, String json) throws IOException { + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + // 默认设置POST方法 + con.setRequestMethod("POST"); + con.setRequestProperty("Content-Type","application/json"); + + + // 发送POST请求必须设置如下两行 + con.setDoOutput(true); + + // 写入请求体 + try (OutputStream os = con.getOutputStream()) { + byte[] input = json.getBytes(StandardCharsets.UTF_8); + os.write(input, 0, input.length); + } + + // 读取响应 + StringBuilder response; + try (BufferedReader br = new BufferedReader( + new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8))) { + response = new StringBuilder(); + String responseLine; + while ((responseLine = br.readLine()) != null) { + response.append(responseLine.trim()); + } + } + + // 断开连接 + con.disconnect(); + + return response.toString(); + } } diff --git a/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java b/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java index b5008ef90..1ca202ea6 100644 --- a/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java +++ b/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/EcganalysisparasController.java @@ -1,11 +1,18 @@ package cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.framework.common.util.http.HttpUtils; +import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO; +import cn.iocoder.yudao.module.infra.service.config.ConfigService; import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO; import cn.iocoder.yudao.module.system.dal.dataobject.org.OrgUnitDO; import cn.iocoder.yudao.module.system.service.doctor.DoctorService; import cn.iocoder.yudao.module.system.service.org.OrgUnitService; +import cn.iocoder.yudao.module.tblist.dal.dataobject.patientexamlist.PatientexamlistDO; import cn.iocoder.yudao.module.tblist.dal.mysql.ecganalysisparas.EcganalysisparasMapper; +import cn.iocoder.yudao.module.tblist.dal.mysql.patientexamlist.PatientexamlistMapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.web.bind.annotation.*; @@ -47,6 +54,10 @@ import java.net.URLEncoder; @Validated public class EcganalysisparasController { + @Resource + private ConfigService configService; + @Resource + private PatientexamlistMapper patientexamlistMapper; @Resource private OrgUnitService orgService; @Resource @@ -91,7 +102,7 @@ public class EcganalysisparasController { @PutMapping("/SaveEcgPdf") @Operation(summary = "保存心电分析数据调用打印服务生成pdf") - public CommonResult SaveEcgPdf(@RequestBody EcganalysisparasSaveReqVO updateReqVO) throws JsonProcessingException { + public CommonResult SaveEcgPdf(@RequestBody EcganalysisparasSaveReqVO updateReqVO) throws IOException { EcgPrintPdf ecgPrintPdf=new EcgPrintPdf(); ecgPrintPdf.setExamid(updateReqVO.getExamId()); ecgPrintPdf.setName(updateReqVO.getName()); @@ -112,9 +123,9 @@ public class EcganalysisparasController { { ecgPrintPdf.setImage(doctorDO.getESignatureUrl()); } - ecgPrintPdf.setDoctorDiagTime(String.valueOf(updateReqVO.getDoctorDiagTime())); + ecgPrintPdf.setDepartName(doctorDO.getDepartmentName()); + ecgPrintPdf.setDoctorDiagTime(DateUtils.formateddatetime(Long.parseLong(updateReqVO.getDiagtime()))); ecgPrintPdf.setDiagContent(updateReqVO.getDoctorDiagResult()); - ecgPrintPdf.setDepartName(updateReqVO.getDepartName()); ecgPrintPdf.setDoctorName(updateReqVO.getDoctorName()); ecgPrintPdf.setType("2"); ecgPrintPdf.setFilepath(updateReqVO.getEcgJsonDataFilePath()); @@ -125,6 +136,24 @@ public class EcganalysisparasController { } ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(ecgPrintPdf); + if(!json.isEmpty()) + { + //获取配置项地址 + ConfigDO printurl = configService.getConfigByKey("url.printurl"); + String re= HttpUtils.sendPost(printurl.getValue(),json); + if(!re.isEmpty()) + { + //获取配置项地址 + ConfigDO config = configService.getConfigByKey("url.ftpurl"); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("examId",updateReqVO.getExamId()); + updateWrapper.eq("regId",updateReqVO.getRegId()); + updateWrapper.eq("orgId",updateReqVO.getOrgId()); + PatientexamlistDO patientexamlistDO = new PatientexamlistDO(); + patientexamlistDO.setPdfurl(config.getValue()+re); + patientexamlistMapper.update(patientexamlistDO,updateWrapper); + } + } return success(true); } diff --git a/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/vo/EcganalysisparasSaveReqVO.java b/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/vo/EcganalysisparasSaveReqVO.java index 97c520abf..606a6c34e 100644 --- a/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/vo/EcganalysisparasSaveReqVO.java +++ b/yudao-module-tblist/yudao-module-tblist-biz/src/main/java/cn/iocoder/yudao/module/tblist/controller/admin/ecganalysisparas/vo/EcganalysisparasSaveReqVO.java @@ -114,4 +114,6 @@ public class EcganalysisparasSaveReqVO { private String name; private String gender; private String age; + private String diagtime; + } \ No newline at end of file