|
|
|
@ -0,0 +1,130 @@
|
|
|
|
|
package com.docus.server.mzzyy.job;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.docus.core.util.Func;
|
|
|
|
|
import com.docus.infrastructure.web.api.CommonResult;
|
|
|
|
|
import com.docus.infrastructure.web.api.ResultCode;
|
|
|
|
|
import com.docus.server.rpc.DownPlatformService;
|
|
|
|
|
import com.docus.server.rpc.MzZyyLisService;
|
|
|
|
|
import com.docus.server.rpc.TaskDistributeService;
|
|
|
|
|
import com.docus.server.rpc.dto.MzZyyLisExportDto;
|
|
|
|
|
import com.docus.server.rpc.dto.MzZyyTestDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportDownDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportDownPatientDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportDownScanFileDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportDownTwoDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportHospitalTwoDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportPatientTwoDto;
|
|
|
|
|
import com.docus.server.rpc.dto.ReportTaskTwoDto;
|
|
|
|
|
import com.docus.server.rpc.enums.MzZyyLisType;
|
|
|
|
|
import com.docus.server.util.StaticResourceMapping;
|
|
|
|
|
import com.docus.server.util.TableJsonRead;
|
|
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Base64;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author YongBin Wen
|
|
|
|
|
* @date 2025/3/18 9:18
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class MzZyyLisCollectJob {
|
|
|
|
|
@Autowired
|
|
|
|
|
private DownPlatformService downPlatformService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TaskDistributeService taskDistributeService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MzZyyLisService mzZyyLisService;
|
|
|
|
|
|
|
|
|
|
@XxlJob("MzZyyLisCollectJob")
|
|
|
|
|
public void lisCollectJob() {
|
|
|
|
|
String configPath = "data-config";
|
|
|
|
|
String configName = "mzzyy-ws-config";
|
|
|
|
|
TableJsonRead jsonReader = new TableJsonRead();
|
|
|
|
|
JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class);
|
|
|
|
|
JSONObject lisWsConfig = configOjb.getJSONObject("lis");
|
|
|
|
|
String collectorId = lisWsConfig.getString("collectorId");
|
|
|
|
|
String assortId = lisWsConfig.getString("assortId");
|
|
|
|
|
|
|
|
|
|
CommonResult<ReportDownTwoDto> commonResult = taskDistributeService.getNoViewTaskByCollectorId(collectorId);
|
|
|
|
|
if (!ResultCode.SUCCESS.getCode().equals(commonResult.getCode())
|
|
|
|
|
|| commonResult.getData() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final String fileTitle = "Lis检查报告单";
|
|
|
|
|
|
|
|
|
|
ReportDownTwoDto downTwoDto = commonResult.getData();
|
|
|
|
|
ReportTaskTwoDto task = downTwoDto.getTasks().get(0);
|
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>> 梅州中医院Lis采集任务,获取了任务:{}", Func.toJson(task));
|
|
|
|
|
|
|
|
|
|
ReportHospitalTwoDto hospitalTwoDto = downTwoDto.getHospitals().get(0);
|
|
|
|
|
ReportPatientTwoDto reportPatientTwoDto = downTwoDto.getPatient();
|
|
|
|
|
String jzh = downTwoDto.getJzh();
|
|
|
|
|
String patientId = downTwoDto.getPatientId();
|
|
|
|
|
String inpatientNo = reportPatientTwoDto.getInpatientNo();
|
|
|
|
|
String patientType = "住院";
|
|
|
|
|
List<MzZyyTestDto> testFormPdfs = mzZyyLisService.getTestFormPdf(jzh, inpatientNo, patientType);
|
|
|
|
|
if (Func.isEmpty(testFormPdfs)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String formatDate = Func.formatDate(new Date());
|
|
|
|
|
String fileDirPath = TableJsonRead.currentPath(StaticResourceMapping.STATIC_RESOURCE_PREFIX + File.separator + StaticResourceMapping.LIS)
|
|
|
|
|
+ File.separator + formatDate
|
|
|
|
|
+ File.separator + patientId;
|
|
|
|
|
List<String> httpUrls = new ArrayList<>();
|
|
|
|
|
int i = 1;
|
|
|
|
|
for (MzZyyTestDto testFormPdf : testFormPdfs) {
|
|
|
|
|
MzZyyLisType lisType = MzZyyLisType.getLisType(testFormPdf.getType());
|
|
|
|
|
List<MzZyyLisExportDto> base64Files = mzZyyLisService.exportTestFormPdf(lisType, testFormPdf.getMachineId(), testFormPdf.getSampleId(), testFormPdf.getTestDate());
|
|
|
|
|
for (MzZyyLisExportDto base64File : base64Files) {
|
|
|
|
|
String filePath = fileDirPath + File.separator + i + "." + base64File.getType().toLowerCase(Locale.ROOT);
|
|
|
|
|
String httpUrl = "http://127.0.0.1:9010/lis/" + formatDate + "/" + patientId + "/" + i + "." + base64File.getType().toLowerCase(Locale.ROOT);
|
|
|
|
|
String base64 = base64File.getBase64();
|
|
|
|
|
byte[] decode = Base64.getDecoder().decode(base64);
|
|
|
|
|
FileUtil.writeBytes(decode, filePath);
|
|
|
|
|
httpUrls.add(httpUrl);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("住院号:{},住院流水号:{},采集了 {} 份文件。", inpatientNo, jzh, httpUrls.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String urls = String.join("|", httpUrls);
|
|
|
|
|
|
|
|
|
|
ReportDownPatientDto patient = new ReportDownPatientDto();
|
|
|
|
|
patient.setPatientid(patientId);
|
|
|
|
|
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorId);
|
|
|
|
|
reportDownDto.setIp("java-lis-job");
|
|
|
|
|
reportDownDto.setPatient(patient);
|
|
|
|
|
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setFiletype(1);
|
|
|
|
|
reportDownScanFileDto.setDownurl(urls);
|
|
|
|
|
reportDownScanFileDto.setFiletitle(fileTitle);
|
|
|
|
|
reportDownScanFileDto.setSerialnum("lis_" + patientId);
|
|
|
|
|
reportDownScanFileDto.setFilesource(1);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(1);
|
|
|
|
|
reportDownScanFileDto.setTaskid(task.getTaskId());
|
|
|
|
|
reportDownScanFileDto.setSort(0);
|
|
|
|
|
List<ReportDownScanFileDto> scanFiles = Collections.singletonList(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setAssortid(assortId);
|
|
|
|
|
reportDownDto.setScanfiles(scanFiles);
|
|
|
|
|
downPlatformService.report(reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|