liusheng
2024-10-21 af396db5b1e6dcbb53879af52bd682b4a7e82664
smartor/src/main/java/com/smartor/service/impl/PatArchiveImportServiceImpl.java
@@ -6,10 +6,7 @@
import com.smartor.mapper.PatArchiveImportMapper;
import com.smartor.service.IPatArchiveImportService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -21,6 +18,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
/**
 * Excel导入患者档案Service业务层处理
@@ -123,11 +121,28 @@
                //判断数据是否有问题
                if (ObjectUtils.isNotEmpty(row.getCell(0).toString())) {
                if (ObjectUtils.isNotEmpty(row.getCell(0))) {
                    patArchiveImport.setName(row.getCell(0).toString());
                } else {
                    continue;
                }
                if (ObjectUtils.isNotEmpty(row.getCell(1))) {
                    patArchiveImport.setIdcardno(row.getCell(1).toString());
                    Cell cell = row.getCell(1);
                    if (row.getCell(1).toString().contains("X") || row.getCell(1).toString().contains("x")) {
                        patArchiveImport.setIdcardno(row.getCell(1).toString());
                    } else {
                        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
                        boolean matches = pattern.matcher(row.getCell(1).toString()).matches();
                        if (matches) {
                            patArchiveImport.setIdcardno(row.getCell(1).toString());
                        } else {
                            double numericCellValue = cell.getNumericCellValue();
                            DecimalFormat decimalFormat = new DecimalFormat("#");
                            String formattedValue = decimalFormat.format(numericCellValue);
                            patArchiveImport.setIdcardno(formattedValue);
                        }
                    }
                    boolean contains = qc.contains(row.getCell(1).toString());
                    if (contains) continue;
                }