| | |
| | | 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.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | public List<PatArchiveImport> importPatInfo(MultipartFile multipartFile) { |
| | | //用于返回 |
| | | List<PatArchiveImport> patArchiveImports = new ArrayList<>(); |
| | | |
| | | //去重 |
| | | List<String> qc = new ArrayList<>(); |
| | | try { |
| | | Workbook workbook = new XSSFWorkbook(multipartFile.getInputStream()); |
| | | Sheet sheet = workbook.getSheetAt(0); |
| | | |
| | | for (int i = sheet.getFirstRowNum() + 1; i < sheet.getLastRowNum(); i++) { |
| | | for (int i = sheet.getFirstRowNum() + 1; i <= sheet.getLastRowNum(); i++) { |
| | | //导入患者对象 |
| | | PatArchiveImport patArchiveImport = new PatArchiveImport(); |
| | | Row row = sheet.getRow(i); |
| | |
| | | } |
| | | if (ObjectUtils.isNotEmpty(row.getCell(1))) { |
| | | patArchiveImport.setIdcardno(row.getCell(1).toString()); |
| | | boolean contains = qc.contains(row.getCell(1).toString()); |
| | | if (contains) continue; |
| | | } |
| | | |
| | | if (ObjectUtils.isNotEmpty(row.getCell(2))) { |
| | | patArchiveImport.setTelcode(row.getCell(2).toString()); |
| | | Cell cell = row.getCell(2); |
| | | double numericCellValue = cell.getNumericCellValue(); |
| | | DecimalFormat decimalFormat = new DecimalFormat("#"); |
| | | String formattedValue = decimalFormat.format(numericCellValue); |
| | | patArchiveImport.setTelcode(formattedValue); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(row.getCell(3))) { |
| | | patArchiveImport.setBatchName(row.getCell(3).toString()); |
| | |
| | | patArchiveImport.setAge(Long.valueOf(row.getCell(7).toString())); |
| | | } |
| | | |
| | | patArchiveImports.add(patArchiveImport); |
| | | |
| | | patArchiveImport.setCreateTime(new Date()); |
| | | patArchiveImport.setUpdateTime(new Date()); |
| | | //批量号(当前时间) |
| | | patArchiveImport.setBatchNo(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); |
| | | insertPatArchiveImport(patArchiveImport); |
| | | |
| | | patArchiveImports.add(patArchiveImport); |
| | | } |
| | | |
| | | } catch (Exception e) { |