修改BUG
This commit is contained in:
parent
b752be334f
commit
2bbc52f365
@ -24,6 +24,7 @@ import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
@ -119,8 +120,8 @@ public class InspectPatientController {
|
||||
try (InputStream inputStream = file.getInputStream();
|
||||
Workbook workbook = new XSSFWorkbook(inputStream)) {
|
||||
|
||||
// 获取第一个Sheet
|
||||
Sheet sheet = (Sheet) workbook.getSheetAt(0);
|
||||
// +获取第一个Sheet
|
||||
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0);
|
||||
if (sheet == null) {
|
||||
return success("Sheet为空");
|
||||
}
|
||||
@ -161,8 +162,7 @@ public class InspectPatientController {
|
||||
String MedicalSn= Long.toString(timestamp);
|
||||
//患者信息
|
||||
InspectPatientSaveReqVO rowData = new InspectPatientSaveReqVO();
|
||||
//套餐信息
|
||||
InspectPatientitemsSaveReqVO rowData2 = new InspectPatientitemsSaveReqVO();
|
||||
|
||||
rowData.setMedicalSn(MedicalSn);
|
||||
//填充患者信息
|
||||
for (int i = 0; i < row.getLastCellNum(); i++) {
|
||||
@ -177,7 +177,10 @@ public class InspectPatientController {
|
||||
rowData.setCardId(getCellValue(cell));
|
||||
break;
|
||||
case "出生日期":
|
||||
rowData.setBirthday(LocalDate.parse(getCellValue(cell)));
|
||||
String dateStr = getCellValue(cell);
|
||||
Date date = DateUtil.getJavaDate(cell.getNumericCellValue());
|
||||
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
rowData.setBirthday(localDate);
|
||||
break;
|
||||
case "性别":
|
||||
rowData.setGender(getCellValue(cell));
|
||||
@ -197,6 +200,8 @@ public class InspectPatientController {
|
||||
//填写项目信息
|
||||
for (InspectitemsDO inspectitemsDO:doList)
|
||||
{
|
||||
//套餐信息
|
||||
InspectPatientitemsSaveReqVO rowData2 = new InspectPatientitemsSaveReqVO();
|
||||
rowData2.setMedicalSn(MedicalSn);
|
||||
rowData2.setItemCode(inspectitemsDO.getItemCode());
|
||||
rowData2.setItemName(inspectitemsDO.getItemName());
|
||||
@ -212,8 +217,10 @@ public class InspectPatientController {
|
||||
dataList2.add(rowData2);
|
||||
}
|
||||
}
|
||||
patientService.createPatientList(dataList);
|
||||
patientitemsService.createPatientListitems(dataList2);
|
||||
// 分批插入患者信息
|
||||
batchInsertPatients(dataList);
|
||||
// 分批插入患者项目信息
|
||||
batchInsertPatientItems(dataList2);
|
||||
|
||||
return success("上传成功");
|
||||
|
||||
@ -230,7 +237,8 @@ public class InspectPatientController {
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue().toString();
|
||||
} else {
|
||||
return String.valueOf(cell.getNumericCellValue());
|
||||
// 将数值格式化为字符串
|
||||
return String.format("%.0f", cell.getNumericCellValue());
|
||||
}
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
@ -240,6 +248,26 @@ public class InspectPatientController {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void batchInsertPatients(List<InspectPatientSaveReqVO> dataList) {
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < dataList.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, dataList.size());
|
||||
List<InspectPatientSaveReqVO> batch = dataList.subList(i, end);
|
||||
patientService.createPatientList(batch);
|
||||
}
|
||||
}
|
||||
|
||||
private void batchInsertPatientItems(List<InspectPatientitemsSaveReqVO> dataList2) {
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < dataList2.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, dataList2.size());
|
||||
List<InspectPatientitemsSaveReqVO> batch = dataList2.subList(i, end);
|
||||
patientitemsService.createPatientListitems(batch);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新患者信息")
|
||||
public CommonResult<Boolean> updatePatient(@Valid @RequestBody InspectPatientSaveReqVO updateReqVO) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user