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