|
@@ -21,12 +21,14 @@ import thyyxxk.webserver.entity.examinations.inspections.request.PatType;
|
|
|
import thyyxxk.webserver.entity.examinations.inspections.request.ReportIndexInquiry;
|
|
|
import thyyxxk.webserver.factory.examreport.ExamReportService;
|
|
|
import thyyxxk.webserver.factory.examreport.model.*;
|
|
|
+import thyyxxk.webserver.service.externalhttp.WebSocketService;
|
|
|
import thyyxxk.webserver.utils.DateUtil;
|
|
|
import thyyxxk.webserver.utils.StringUtil;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
@RestController
|
|
@@ -38,10 +40,12 @@ public class DpccController {
|
|
|
private static final String DRUG_URL = "https://manage.national-dpcc.com/api/sino-common/access-client/uploadHisDrugData";
|
|
|
|
|
|
private final DpccDao dao;
|
|
|
+ private final WebSocketService socketService;
|
|
|
|
|
|
@Autowired
|
|
|
- public DpccController(DpccDao dao) {
|
|
|
+ public DpccController(DpccDao dao, WebSocketService socketService) {
|
|
|
this.dao = dao;
|
|
|
+ this.socketService = socketService;
|
|
|
}
|
|
|
|
|
|
@PassToken
|
|
@@ -93,15 +97,37 @@ public class DpccController {
|
|
|
}
|
|
|
|
|
|
@PassToken
|
|
|
- @GetMapping("/uploadMzYp")
|
|
|
- public String uploadMzYp(@RequestParam("token") String token,
|
|
|
+ @GetMapping("/uploadMzDpcc")
|
|
|
+ public String uploadMzYp(@RequestParam("pat") String pat,
|
|
|
@RequestParam("day") Integer day) throws Exception {
|
|
|
- log.info("DPCC上传请求:{}", day);
|
|
|
- day = null == day ? 0 : day;
|
|
|
- List<PatientInfo> outpatientList = dao.getOutpatientList2(day);
|
|
|
+ String token = socketService.getDpccToken();
|
|
|
+ ReportIndexInquiry inquiry = getReportIndexInquiry();
|
|
|
+ log.info("DPCC上传请求:{}, {}", pat, day);
|
|
|
+ List<PatientInfo> outpatientList;
|
|
|
+ if (pat.contains("_")) {
|
|
|
+ String[] patinfo = pat.split("_");
|
|
|
+ String patientId = patinfo[0];
|
|
|
+ int times = Integer.parseInt(patinfo[1]);
|
|
|
+ String socialNo = dao.getSocialNo(patientId);
|
|
|
+ PatientInfo pi = new PatientInfo();
|
|
|
+ pi.setPatNo(patientId);
|
|
|
+ pi.setTimes(times);
|
|
|
+ pi.setSource("1");
|
|
|
+ pi.setIdCard(socialNo);
|
|
|
+ outpatientList = new ArrayList<>();
|
|
|
+ outpatientList.add(pi);
|
|
|
+ Map<String, String> map = dao.getStartAndEndDate(patientId, times);
|
|
|
+ if (null != map) {
|
|
|
+ inquiry.setReqStartTime(map.get("start"));
|
|
|
+ inquiry.setReqEndTime(map.get("endd"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ outpatientList = dao.getOutpatientList2(day);
|
|
|
+ }
|
|
|
if (outpatientList.isEmpty()) {
|
|
|
return "没有需要上传的数据。";
|
|
|
}
|
|
|
+ uploadOutpatientCheck(outpatientList,inquiry,token);
|
|
|
uploadOutpatientDrug(outpatientList, token);
|
|
|
return "OK";
|
|
|
}
|
|
@@ -151,7 +177,7 @@ public class DpccController {
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
long diff = now.getTime() - auditTime.getTime();
|
|
|
- return diff / 1000 / 60 <= 600;
|
|
|
+ return diff / 1000 / 60 / 60 <= 72;
|
|
|
}
|
|
|
|
|
|
private void queryCheckAndUpload(ReportIndexInquiry inquiry, PatientInfo patient, String token) throws Exception {
|
|
@@ -175,13 +201,13 @@ public class DpccController {
|
|
|
}
|
|
|
checkResultBatches.add(getMedicalCheckResult(patient, item));
|
|
|
if (checkResultBatches.size() == 100) {
|
|
|
- executeUploadChecks(checkResultBatches, token);
|
|
|
+ executeUploadChecks(checkResultBatches, token, patient.getPatNo(), patient.getTimes());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (!checkResultBatches.isEmpty()) {
|
|
|
- executeUploadChecks(checkResultBatches, token);
|
|
|
+ executeUploadChecks(checkResultBatches, token, patient.getPatNo(), patient.getTimes());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -242,9 +268,10 @@ public class DpccController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void executeUploadChecks(List<MedicalCheckResult> checkBatches, String token) throws Exception {
|
|
|
+ private void executeUploadChecks(List<MedicalCheckResult> checkBatches,
|
|
|
+ String token, String patNo, int times) throws Exception {
|
|
|
String json = JSON.toJSONString(checkBatches);
|
|
|
- log.info("DPCC上传检验明文:{}", json);
|
|
|
+ log.info("DPCC上传检验:{}, {}", patNo, times);
|
|
|
uploadToSino(DpccEncryptUtil.encrypt(json), Type.CHECK, token);
|
|
|
}
|
|
|
|