From e53334611e8d51fb67e769cba898743f11dcf627 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 16 六月 2023 17:45:23 +0800
Subject: [PATCH] 患者管理相关接口,提交
---
smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java | 241 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 206 insertions(+), 35 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
index 714d832..55eb072 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
@@ -1,26 +1,28 @@
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.*;
+import java.util.stream.Collectors;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DtoConversionUtils;
import com.ruoyi.common.utils.StringUtils;
-import com.smartor.domain.BaseTag;
-import com.smartor.domain.PatArchivetag;
-import com.smartor.domain.PatUpInfoVO;
+import com.smartor.domain.*;
import com.smartor.mapper.BaseTagMapper;
import com.smartor.mapper.PatArchivetagMapper;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.formula.functions.Now;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import com.smartor.mapper.PatArchiveMapper;
-import com.smartor.domain.PatArchive;
import com.smartor.service.IPatArchiveService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -113,7 +115,7 @@
@Override
@Transactional
- public PatUpInfoVO fileHandle(String username, MultipartFile file) {
+ public PatUpInfoVO importFilehandle(SysUser user, String tags, MultipartFile file) {
PatUpInfoVO patUpInfoVO = new PatUpInfoVO();
Integer successNum = 0;
Integer failNum = 0;
@@ -130,8 +132,8 @@
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());
//鏍规嵁韬唤璇侊紝鍏堝幓鎮h�呯鐞嗚〃閲岀湅鐪嬫湁娌℃湁杩欎釜浜�,濡傛灉鏈夎繖涓汉锛屼篃涓嶉渶瑕佹彃鍏ユ偅鑰呰〃
@@ -142,31 +144,30 @@
}
//鍒ゆ柇濮撳悕鏄惁涓虹┖
- 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");
@@ -181,8 +182,8 @@
}
//鍒ゆ柇鏈汉鑱旂郴鏄惁涓虹┖锛屽拰闀垮害鏄惁姝g‘
- 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")) {
@@ -196,8 +197,8 @@
}
//鍒ゆ柇浜插睘鑱旂郴鏂瑰紡鏄惁涓虹┖锛岄暱搴︽槸鍚︽纭�
- 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")) {
@@ -211,8 +212,19 @@
}
//鎮i兘鏍囩鏄惁涓虹┖
- if (ObjectUtils.isEmpty(row.getCell(7))) {
- patArchive.setRemark("鎮h�呮爣绛句负绌�");
+ if (ObjectUtils.isEmpty(row.getCell(7)) || StringUtils.isEmpty(row.getCell(7).toString())) {
+ if (StringUtils.isEmpty(tags)) {
+ addRemark("鎮h�呮爣绛句负绌�", patArchive);
+ } else {
+ patArchive.setTag(tags);
+
+ }
+ } else {
+ if (StringUtils.isNotEmpty(tags)) {
+ patArchive.setTag(row.getCell(7).toString() + "," + tags);
+ } else {
+ patArchive.setTag(row.getCell(7).toString());
+ }
}
//鍒ゆ柇澶囨敞鏄惁涓虹┖
@@ -227,17 +239,36 @@
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 = patArchive.getTag();
+ String[] split = s.split(",");
+ for (String tagName : split) {
+ BaseTag baseTag = new BaseTag();
+ baseTag.setTagname(tagName);
+ List<BaseTag> baseTags = baseTagMapper.selectBaseTagList(baseTag);
- // 鏂板鎮h�呮。妗堟爣绛�
- PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag1, PatArchivetag.class);
- patArchivetag.setUpdateBy(username);
- patArchivetag.setCreateTime(new Date());
- patArchivetag.setPatid(patArchive.getPatid());
- patArchivetagMapper.insertPatArchivetag(patArchivetag);
+ //濡傛灉璇ユ爣绛句负绌猴紝鐜版爣绛剧鐞嗘病鏈夊嚭鐜拌繃鐨勬柊鏍囩鏃讹紝鑷姩灏嗘爣绛炬坊鍔犲埌"鏍囩绠$悊"鏈垎绫烩�滀腑銆傜紪杈戜汉涓哄鍏ヨ处鍙�
+ if (CollectionUtils.isEmpty(baseTags)) {
+ baseTag = new BaseTag();
+ baseTag.setTagcategoryid(1L);
+ baseTag.setTagname(tagName);
+ baseTag.setOrgid(user.getDeptId().toString());
+ baseTag.setDelFlag("0");
+ baseTag.setCreateBy(user.getUserName());
+ baseTag.setCreateTime(new Date());
+ baseTag.setCreateBy(user.getUserName());
+ baseTag.setCreateTime(new Date());
+ baseTagMapper.insertBaseTag(baseTag);
+ } else {
+ baseTag = baseTags.get(0);
+ }
+
+ // 鏂板鎮h�呮。妗堟爣绛�
+ PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag, PatArchivetag.class);
+ patArchivetag.setUpdateBy(user.getUserName());
+ patArchivetag.setCreateTime(new Date());
+ patArchivetag.setPatid(patArchive.getPatid());
+ patArchivetagMapper.insertPatArchivetag(patArchivetag);
+ }
successNum = successNum + 1;
}
@@ -251,5 +282,145 @@
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("鎮h�呴敊璇俊鎭�.xlsx");
+ workbook.write(outputStream);
+ outputStream.close();
+ workbook.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "瀵煎嚭澶辫触";
+ }
+ return "瀵煎嚭鎴愬姛";
+ }
+
+ @Override
+ public List<PatArchive> patInfoByContion(PatArchiveReq patArchive) {
+ List<PatArchive> patArchives = new ArrayList<>();
+
+ //鏍规嵁鏉′欢鑾峰彇鎮h�呬俊鎭�
+ List<PatArchive> patArchiveList = patArchiveMapper.patInfoByContion(patArchive);
+ //鏍规嵁鎮h�匢D杩涜鍒嗙粍
+ Map<Long, List<PatArchive>> listMap = patArchiveList.stream().collect(Collectors.groupingBy(PatArchive::getPatid));
+
+ //瀵规暟鎹繘琛屽皝瑁�
+ for (List<PatArchive> list : listMap.values()) {
+ PatArchive patArchive1 = new PatArchive();
+ List<String> stringList = new ArrayList<>();
+ for (int i = 0; i < list.size(); i++) {
+ if (i == 0) {
+ patArchive1 = DtoConversionUtils.sourceToTarget(list.get(0), PatArchive.class);
+ //灏嗘爣绛剧疆绌�,涓嶇┖涔熸病鏈夐棶棰�
+ patArchive1.setTag("");
+ }
+ //灏嗘煡鍑虹殑tag锛屾斁鍒皃atArchive1閲岀殑TagList涓�
+ stringList.add(list.get(i).getTag());
+ }
+ patArchive1.setTagList(stringList);
+ patArchives.add(patArchive1);
+ }
+
+ return patArchives;
+ }
+
+ @Override
+ public List<PatArchivetagAndPatientInfo> patTagByContion(List<Long> tagids) {
+ List<PatArchivetagAndPatientInfo> patArchivetagAndPatientInfos = new ArrayList<>();
+ if (tagids.size() > 0) {
+ for (int i = 0; i < tagids.size(); i++) {
+ PatArchivetag patArchivetag = new PatArchivetag();
+ patArchivetag.setTagid(tagids.get(i));
+ //鑾峰彇鎮h�卲atid
+ List<PatArchivetag> patArchivetags1 = patArchivetagMapper.selectPatArchivetagAndBaseTagList(patArchivetag);
+ for (int j = 0; j < patArchivetags1.size(); j++) {
+ PatArchivetagAndPatientInfo patArchivetagAndPatientInfo = DtoConversionUtils.sourceToTarget(patArchivetags1.get(j), PatArchivetagAndPatientInfo.class);
+ PatArchive patArchive = new PatArchive();
+ patArchive.setPatid(patArchivetagAndPatientInfo.getPatid());
+ List<PatArchive> patArchiveList = patArchiveMapper.selectPatArchiveList(patArchive);
+ patArchivetagAndPatientInfo.setPatNum(patArchiveList.size());
+ // patArchivetagAndPatientInfo.setPatArchives(patArchiveList);
+ patArchivetagAndPatientInfos.add(patArchivetagAndPatientInfo);
+ }
+ }
+ } else {
+ PatArchivetag patArchivetag = new PatArchivetag();
+ //鑾峰彇鎮h�卲atid
+ List<PatArchivetag> patArchivetags1 = patArchivetagMapper.selectPatArchivetagAndBaseTagList(patArchivetag);
+ for (int j = 0; j < patArchivetags1.size(); j++) {
+ PatArchivetagAndPatientInfo patArchivetagAndPatientInfo = DtoConversionUtils.sourceToTarget(patArchivetags1.get(j), PatArchivetagAndPatientInfo.class);
+ PatArchive patArchive = new PatArchive();
+ patArchive.setPatid(patArchivetagAndPatientInfo.getPatid());
+ List<PatArchive> patArchiveList = patArchiveMapper.selectPatArchiveList(patArchive);
+ // patArchivetagAndPatientInfo.setPatArchives(patArchiveList);
+ patArchivetagAndPatientInfo.setPatNum(patArchiveList.size());
+ patArchivetagAndPatientInfos.add(patArchivetagAndPatientInfo);
+ }
+ }
+ return patArchivetagAndPatientInfos;
+ }
+
+ @Override
+ public List<PatArchivetagAndPatientInfo> patInfoByTag(List<Long> tagids) {
+
+
+
+
+
+ return null;
+ }
+
+ 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("鎮h�呮爣绛�");
+ 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);
+ }
+ }
+
}
--
Gitblit v1.9.3