补偿文件job

3.2.4.44
wyb 2 years ago
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);
}
}
}
}

@ -49,4 +49,20 @@ public interface AfReportRecordMapper {
* @return patientIdid
*/
List<Long> getHasPatientIdTaskIdsByTaskIds(@Param("taskIds") List<Long> taskIds);
/**
*
* @param page
* @param pageSize
* @return
*/
List<AfReportRecord> getStartStateReportRecord(@Param("page") int page,@Param("pageSize") int pageSize);
/**
* id
* @param patientId
* @param taskId id
* @return
*/
int updateReportRecordPatientId(@Param("patientId") String patientId,@Param("taskId") Long taskId);
}

@ -91,6 +91,9 @@ public class ReportServiceImpl implements ReportService {
@Override
public void makeupReportByTaskIds(List<Long> taskIds) throws Exception {
if (taskIds == null || taskIds.isEmpty()) {
return;
}
// 定义一批200查询分批次
final int oneBatchCount = 200;
int startIndex = 0;

@ -29,6 +29,11 @@
`update_time`=now()
where `task_id` = #{taskId}
</update>
<update id="updateReportRecordPatientId">
update `docus_archivefile`.`af_report_record`
set `patient_id`= #{patientId}
where `task_id` = #{taskId}
</update>
<select id="getRecordBySerialnumAndInpatientNoAndSysFlag"
resultType="com.docus.server.report.entity.AfReportRecord">
select *
@ -53,4 +58,11 @@
#{taskId}
</foreach>
</select>
<select id="getStartStateReportRecord" resultType="com.docus.server.report.entity.AfReportRecord">
SELECT `task_id`, `inpatient_no`, `admiss_times`, `patient_id`
FROM `docus_archivefile`.`af_report_record`
WHERE `state` = 0
LIMIT ${(page-1)*pageSize}
, ${pageSize}
</select>
</mapper>

Loading…
Cancel
Save