补偿文件job
parent
1ff10c7052
commit
eb95e70a36
@ -0,0 +1,79 @@
|
|||||||
|
package com.docus.server.report.job;
|
||||||
|
|
||||||
|
import com.docus.core.util.Func;
|
||||||
|
import com.docus.server.collection.mapper.TBasicMapper;
|
||||||
|
import com.docus.server.report.entity.AfReportRecord;
|
||||||
|
import com.docus.server.report.mapper.AfReportRecordMapper;
|
||||||
|
import com.docus.server.report.service.ReportService;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告相关xxl-Job
|
||||||
|
*
|
||||||
|
* @author jiashi
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ReportJob {
|
||||||
|
@Resource
|
||||||
|
private ReportService reportService;
|
||||||
|
@Resource
|
||||||
|
private AfReportRecordMapper afReportRecordMapper;
|
||||||
|
@Resource
|
||||||
|
private TBasicMapper tBasicMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补偿异常的报告
|
||||||
|
*/
|
||||||
|
@XxlJob("MakeupExceptionReportJob")
|
||||||
|
public void makeupExceptionReport() {
|
||||||
|
log.info("补偿异常的报告 任务开始了");
|
||||||
|
int makeupSize = 0;
|
||||||
|
final int pageSize = 1000;
|
||||||
|
int page = 1;
|
||||||
|
boolean loopCondition = true;
|
||||||
|
try {
|
||||||
|
do {
|
||||||
|
|
||||||
|
List<AfReportRecord> reportRecords = afReportRecordMapper.getStartStateReportRecord(page, pageSize);
|
||||||
|
if (reportRecords == null || reportRecords.size() < pageSize) {
|
||||||
|
// 结束循环
|
||||||
|
loopCondition = false;
|
||||||
|
}
|
||||||
|
if (reportRecords != null) {
|
||||||
|
updateReportRecordPatientId(reportRecords);
|
||||||
|
List<Long> taskIds = reportRecords.stream().map(AfReportRecord::getTaskId).collect(Collectors.toList());
|
||||||
|
reportService.makeupReportByTaskIds(taskIds);
|
||||||
|
}
|
||||||
|
page++;
|
||||||
|
} while (loopCondition);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("补偿异常的报告出错啦!" + ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
log.info("补偿异常的报告 任务结束了,本次补偿报告 {} 条", makeupSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateReportRecordPatientId(List<AfReportRecord> reportRecords) {
|
||||||
|
if (reportRecords == null || reportRecords.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (AfReportRecord reportRecord : reportRecords) {
|
||||||
|
if (Func.isNotBlank(reportRecord.getPatientId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 如果出现多条出错的情况,还是得保存收到的信息,人工干预处理
|
||||||
|
String patientId = tBasicMapper.getPatientIdByInpatientNoAndAdminssTimes(reportRecord.getInpatientNo(), reportRecord.getAdmissTimes());
|
||||||
|
afReportRecordMapper.updateReportRecordPatientId(patientId, reportRecord.getTaskId());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("查询病案主键出错了", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue