|
|
|
@ -4,14 +4,16 @@ import com.docus.core.util.Func;
|
|
|
|
|
import com.docus.infrastructure.web.api.CommonResult;
|
|
|
|
|
import com.docus.server.collect.dto.PatientScanConditionDTO;
|
|
|
|
|
import com.docus.server.collect.entity.PatientScan;
|
|
|
|
|
import com.docus.server.collect.service.PatientScanSynchronizer;
|
|
|
|
|
import com.docus.server.collect.service.PatientScanService;
|
|
|
|
|
import com.docus.server.collect.service.PatientScanSynchronizer;
|
|
|
|
|
import com.docus.server.collect.service.dto.PatScanSyncResult;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -22,6 +24,7 @@ import java.util.List;
|
|
|
|
|
@Api("患者扫描控制")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/gdszy/patscan")
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class PatientScanController {
|
|
|
|
|
@Resource
|
|
|
|
|
private PatientScanService patientScanService;
|
|
|
|
@ -42,10 +45,36 @@ public class PatientScanController {
|
|
|
|
|
@PostMapping("/collect/collectByDisDate")
|
|
|
|
|
@ApiOperation("根据出院日期区间同步扫描患者数据 yyyy-MM-dd")
|
|
|
|
|
public CommonResult<PatScanSyncResult> collectByInpatientNoAndTimes(@RequestParam String disDateStart, @RequestParam String disDateEnd) {
|
|
|
|
|
List<PatientScanConditionDTO> patientScanConditionDTOList = patientScanService.getInpatientNoAndTimesByDisDate(disDateStart + " 00:00:00", disDateEnd + " 23:59:59");
|
|
|
|
|
if (Func.isEmpty(patientScanConditionDTOList)) {
|
|
|
|
|
return CommonResult.failed(disDateStart + " —— " + disDateEnd + " 没有可采集的视图数据!");
|
|
|
|
|
log.info("根据出院日期区间 {} —— {} 同步扫描患者数据接口。", disDateStart, disDateEnd);
|
|
|
|
|
LocalDate disDateStartDate = LocalDate.parse(disDateStart);
|
|
|
|
|
LocalDate disDateEndDate = LocalDate.parse(disDateEnd);
|
|
|
|
|
|
|
|
|
|
StringBuilder syncMsgStringBuilder = new StringBuilder();
|
|
|
|
|
int patientTotalCount = 0;
|
|
|
|
|
int successPatientCount = 0;
|
|
|
|
|
int fileCount = 0;
|
|
|
|
|
|
|
|
|
|
// 从开始时间一天一天的查询,直到超过了结束时间停止
|
|
|
|
|
while (!disDateStartDate.isAfter(disDateEndDate)) {
|
|
|
|
|
List<PatientScanConditionDTO> patientScanConditionDTOList = patientScanService.getInpatientNoAndTimesByDisDate(disDateStartDate + " 00:00:00", disDateStartDate + " 23:59:59");
|
|
|
|
|
if (Func.isEmpty(patientScanConditionDTOList)) {
|
|
|
|
|
log.warn("出院时间:{} —— {} 没有可同步的扫描数据!", disDateStartDate + " 00:00:00", disDateStartDate + " 23:59:59");
|
|
|
|
|
disDateStartDate = disDateStartDate.plusDays(1);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
PatScanSyncResult scanSyncResult = synchronizer.sync("根据出院日期区间同步扫描患者数据接口", patientScanConditionDTOList);
|
|
|
|
|
patientTotalCount += scanSyncResult.getPatientTotalCount();
|
|
|
|
|
successPatientCount += scanSyncResult.getSuccessPatientCount();
|
|
|
|
|
fileCount += scanSyncResult.getFileCount();
|
|
|
|
|
syncMsgStringBuilder.append(scanSyncResult.getMsg());
|
|
|
|
|
disDateStartDate = disDateStartDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
return CommonResult.success(synchronizer.sync("根据出院日期区间同步扫描患者数据接口",patientScanConditionDTOList));
|
|
|
|
|
|
|
|
|
|
PatScanSyncResult result = new PatScanSyncResult();
|
|
|
|
|
result.setPatientTotalCount(patientTotalCount);
|
|
|
|
|
result.setSuccessPatientCount(successPatientCount);
|
|
|
|
|
result.setFileCount(fileCount);
|
|
|
|
|
result.setMsg(syncMsgStringBuilder.toString());
|
|
|
|
|
return CommonResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|