| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public PatUpInfoVO fileHandle(String username, MultipartFile file) { |
| | | public PatUpInfoVO importFilehandle(String username, MultipartFile file) { |
| | | PatUpInfoVO patUpInfoVO = new PatUpInfoVO(); |
| | | Integer successNum = 0; |
| | | Integer failNum = 0; |
| | |
| | | continue; |
| | | } |
| | | PatArchive patArchive = new PatArchive(); |
| | | if (ObjectUtils.isEmpty(row.getCell(3))) { |
| | | patArchive.setRemark("身份证号为空"); |
| | | if (ObjectUtils.isEmpty(row.getCell(3)) || StringUtils.isEmpty(row.getCell(3).toString())) { |
| | | addRemark("身份证号为空", patArchive); |
| | | } else { |
| | | patArchive.setIccardno(row.getCell(3).toString()); |
| | | //根据身份证,先去患者管理表里看看有没有这个人,如果有这个人,也不需要插入患者表 |
| | |
| | | } |
| | | |
| | | //判断姓名是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(0))) { |
| | | patArchive.setRemark(patArchive.getRemark() + "," + "姓名为空"); |
| | | errorpatArchiveList.add(patArchive); |
| | | if (Objects.isNull(row.getCell(0)) || StringUtils.isEmpty(row.getCell(0).toString())) { |
| | | addRemark("姓名为空", patArchive); |
| | | } else { |
| | | patArchive.setName(row.getCell(0).toString()); |
| | | } |
| | | |
| | | //判断性别是否为空 |
| | | |
| | | if (ObjectUtils.isEmpty(row.getCell(1))) { |
| | | patArchive.setRemark(patArchive.getRemark() + "," + "性别为空"); |
| | | if (ObjectUtils.isEmpty(row.getCell(1)) || StringUtils.isEmpty(row.getCell(1).toString())) { |
| | | addRemark("性别为空", patArchive); |
| | | } else { |
| | | patArchive.setSex(row.getCell(1).toString().equals("男") ? 1L : 2L); |
| | | } |
| | | |
| | | //判断证件类型是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(2))) { |
| | | patArchive.setRemark("证件类型为空"); |
| | | if (ObjectUtils.isEmpty(row.getCell(2)) || StringUtils.isEmpty(row.getCell(2).toString())) { |
| | | addRemark("证件类型为空", patArchive); |
| | | } else { |
| | | patArchive.setIccardtype(row.getCell(2).toString()); |
| | | } |
| | | |
| | | //判断出生日期是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(4))) { |
| | | patArchive.setRemark("出生日期为空"); |
| | | if (ObjectUtils.isEmpty(row.getCell(4)) || StringUtils.isEmpty(row.getCell(4).toString())) { |
| | | addRemark("出生日期为空", patArchive); |
| | | } else { |
| | | //格式转换,转成日期 |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
| | |
| | | } |
| | | |
| | | //判断本人联系是否为空,和长度是否正确 |
| | | if (ObjectUtils.isEmpty(row.getCell(5))) { |
| | | patArchive.setRemark("本人联系电话为空"); |
| | | if (ObjectUtils.isEmpty(row.getCell(5)) || StringUtils.isEmpty(row.getCell(5).toString())) { |
| | | addRemark("本人联系电话为空", patArchive); |
| | | } else { |
| | | //格式转换,转成文本 |
| | | if (row.getCell(5).getCellType().toString().equals("NUMERIC")) { |
| | |
| | | } |
| | | |
| | | //判断亲属联系方式是否为空,长度是否正确 |
| | | if (ObjectUtils.isEmpty(row.getCell(6))) { |
| | | patArchive.setRemark("本人联系电话为空"); |
| | | if (ObjectUtils.isEmpty(row.getCell(6)) || StringUtils.isEmpty(row.getCell(6).toString())) { |
| | | addRemark("亲属联系方式为空", patArchive); |
| | | } else { |
| | | //格式转换,转成文本 |
| | | if (row.getCell(6).getCellType().toString().equals("NUMERIC")) { |
| | |
| | | |
| | | //患都标签是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(7))) { |
| | | patArchive.setRemark("患者标签为空"); |
| | | addRemark("患者标签为空", patArchive); |
| | | } else { |
| | | patArchive.setTag(row.getCell(7).toString()); |
| | | } |
| | | |
| | | //判断备注是否为空 |
| | |
| | | patArchiveMapper.insertPatArchive(patArchive); |
| | | |
| | | //根据标签名查询出标签信息 |
| | | BaseTag baseTag = new BaseTag(); |
| | | baseTag.setTagname(row.getCell(7).toString()); |
| | | List<BaseTag> baseTags = baseTagMapper.selectBaseTagList(baseTag); |
| | | BaseTag baseTag1 = baseTags.get(0); |
| | | String s = row.getCell(7).toString(); |
| | | String[] split = s.split(","); |
| | | for (String tagName : split) { |
| | | BaseTag baseTag = new BaseTag(); |
| | | baseTag.setTagname(tagName); |
| | | List<BaseTag> baseTags = baseTagMapper.selectBaseTagList(baseTag); |
| | | BaseTag baseTag1 = baseTags.get(0); |
| | | |
| | | // 新增患者档案标签 |
| | | PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag1, PatArchivetag.class); |
| | | patArchivetag.setUpdateBy(username); |
| | | patArchivetag.setCreateTime(new Date()); |
| | | patArchivetag.setPatid(patArchive.getPatid()); |
| | | patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | // 新增患者档案标签 |
| | | PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag1, PatArchivetag.class); |
| | | patArchivetag.setUpdateBy(username); |
| | | patArchivetag.setCreateTime(new Date()); |
| | | patArchivetag.setPatid(patArchive.getPatid()); |
| | | patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | } |
| | | successNum = successNum + 1; |
| | | } |
| | | |
| | |
| | | return patUpInfoVO; |
| | | } |
| | | |
| | | @Override |
| | | public String exportErrPatInfo(List<PatArchive> patArchiveList) { |
| | | // 创建工作簿和工作表 |
| | | Workbook workbook = new XSSFWorkbook(); |
| | | Sheet sheet = workbook.createSheet("Sheet1"); |
| | | // 创建行和单元格,并设置单元格的值 |
| | | Row row = sheet.createRow(0); |
| | | getdata(row, null, true); |
| | | |
| | | for (int i = 0; i < patArchiveList.size(); i++) { |
| | | row = sheet.createRow(i + 1); |
| | | getdata(row, patArchiveList.get(i), false); |
| | | } |
| | | // 保存工作簿到文件 |
| | | FileOutputStream outputStream = null; |
| | | try { |
| | | outputStream = new FileOutputStream("患者错误信息.xlsx"); |
| | | workbook.write(outputStream); |
| | | outputStream.close(); |
| | | workbook.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return "导出失败"; |
| | | } |
| | | return "导出成功"; |
| | | } |
| | | |
| | | private void getdata(Row row, PatArchive patArchive, Boolean head) { |
| | | if (head) { |
| | | row.createCell(0).setCellValue("姓名"); |
| | | row.createCell(1).setCellValue("性别"); |
| | | row.createCell(2).setCellValue("证件类型"); |
| | | row.createCell(3).setCellValue("证件号码"); |
| | | row.createCell(4).setCellValue("出生日期"); |
| | | row.createCell(5).setCellValue("本人联系方式"); |
| | | row.createCell(6).setCellValue("亲属联系方式"); |
| | | row.createCell(7).setCellValue("患者标签"); |
| | | row.createCell(8).setCellValue("错误原因"); |
| | | } else { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
| | | row.createCell(0).setCellValue(patArchive.getName()); |
| | | row.createCell(1).setCellValue(patArchive.getSex() == 1 ? "男" : "女"); |
| | | row.createCell(2).setCellValue(patArchive.getIccardtype()); |
| | | row.createCell(3).setCellValue(patArchive.getIccardno()); |
| | | if (ObjectUtils.isNotEmpty(patArchive.getBirthdate())) { |
| | | row.createCell(4).setCellValue(simpleDateFormat.format(patArchive.getBirthdate()).toString()); |
| | | } |
| | | row.createCell(5).setCellValue(patArchive.getTelcode()); |
| | | row.createCell(6).setCellValue(patArchive.getRelativetelcode()); |
| | | row.createCell(7).setCellValue(patArchive.getTag()); |
| | | row.createCell(8).setCellValue(patArchive.getRemark()); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | public void addRemark(String info, PatArchive patArchive) { |
| | | if (StringUtils.isNotEmpty(patArchive.getRemark()) == true) { |
| | | patArchive.setRemark(patArchive.getRemark() + "," + info); |
| | | } else { |
| | | patArchive.setRemark(info); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |