From ad82e755b335e38e29a5d722f7e8abe67b35a4c8 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期六, 20 七月 2024 16:40:15 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java | 567 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 422 insertions(+), 145 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 39b4483..0ce2b89 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
@@ -1,21 +1,27 @@
package com.smartor.service.impl;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.exception.base.BaseException;
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 com.smartor.service.IPatMedInhospService;
+import com.smartor.service.IPatMedOuthospService;
+import com.smartor.service.IPatMedPhysicalService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.*;
@@ -23,7 +29,6 @@
import org.springframework.beans.factory.annotation.Autowired;
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;
@@ -34,6 +39,7 @@
* @author smartor
* @date 2023-03-04
*/
+@Slf4j
@Service
public class PatArchiveServiceImpl implements IPatArchiveService {
@Autowired
@@ -44,6 +50,18 @@
@Autowired
private PatArchivetagMapper patArchivetagMapper;
+
+ @Autowired
+ private IPatMedInhospService patMedInhospService;
+
+ @Autowired
+ private IPatMedOuthospService patMedOuthospService;
+
+ @Autowired
+ private IPatMedPhysicalService patMedPhysicalService;
+
+ @Autowired
+ private RedisCache redisCache;
/**
@@ -68,6 +86,7 @@
return patArchiveMapper.selectPatArchiveList(patArchive);
}
+
/**
* 鏂板鎮h�呮。妗�
*
@@ -75,21 +94,61 @@
* @return 缁撴灉
*/
@Override
- public int insertPatArchive(PatArchive patArchive) {
+ public Integer insertPatArchive(PatArchive patArchive) {
patArchive.setCreateTime(DateUtils.getNowDate());
- return patArchiveMapper.insertPatArchive(patArchive);
+ List<PatArchive> patArchives = new ArrayList<>();
+ patArchives.add(patArchive);
+ patArchiveMapper.insertPatArchive(patArchives);
+ if (CollectionUtils.isNotEmpty(patArchives)) {
+ patArchives.get(0).getId();
+ log.info("鎮h�卛d涓�: {}", patArchives.get(0).getId());
+ return patArchives.get(0).getId().intValue();
+ }
+ return null;
}
/**
- * 淇敼鎮h�呮。妗�
+ * 鏂板鎴栦慨鏀规偅鑰呮。淇℃伅
*
- * @param patArchive 鎮h�呮。妗�
+ * @param patArchiveVO 鏂板鎴栦慨鏀规偅鑰呮。淇℃伅
* @return 缁撴灉
*/
+ @Transactional(rollbackFor = Exception.class)
@Override
- public int updatePatArchive(PatArchive patArchive) {
- patArchive.setUpdateTime(DateUtils.getNowDate());
- return patArchiveMapper.updatePatArchive(patArchive);
+ public Boolean saveOrUpdatePatInfo(PatArchiveVO patArchiveVO) {
+ //閫氳繃isoperation鏉ュ垽鏂槸鍚︽柊澧�
+ PatArchive patArchive = DtoConversionUtils.sourceToTarget(patArchiveVO, PatArchive.class);
+ if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 1 || patArchiveVO.getPatid() == null) {
+ //鏂板
+ List<PatArchive> patArchives = new ArrayList<>();
+ patArchive.setUpdateTime(DateUtils.getNowDate());
+ patArchives.add(patArchive);
+ patArchiveMapper.insertPatArchive(patArchives);
+ } else if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 2 || patArchiveVO.getPatid() != null) {
+ //淇敼
+ patArchiveVO.setIsoperation(2);
+ patArchiveMapper.updatePatArchive(patArchive);
+ }
+
+ if (CollectionUtils.isNotEmpty(patArchiveVO.getTagList())) {
+ //澶勭悊鏍囩锛堟柊澧炪�佸垹闄わ級
+ for (PatArchivetag patArchivetag : patArchiveVO.getTagList()) {
+ if (patArchivetag.getIsoperation() != null && patArchivetag.getIsoperation() == 1 || patArchivetag.getIsoperation() == null && patArchiveVO.getIsoperation() == 1) {
+ //鏂板
+ patArchivetag.setUpdateBy(null);
+ patArchivetag.setCreateTime(new Date());
+ patArchivetag.setPatid(patArchive.getId());
+ patArchivetagMapper.insertPatArchivetag(patArchivetag);
+ } else if (patArchivetag.getIsoperation() != null && patArchivetag.getIsoperation() == 3 || patArchivetag.getIsoperation() == null && patArchiveVO.getIsoperation() == 3) {
+ patArchivetag.setDelFlag("1");
+ //鍒犻櫎
+ log.info("鏍囩鐨刬d涓猴細{}", patArchivetag.getTagid());
+ patArchivetagMapper.deletePatArchivetagById(patArchivetag);
+ }
+ }
+
+ }
+ return true;
}
/**
@@ -116,145 +175,241 @@
@Override
@Transactional
- public PatUpInfoVO importFilehandle(String username, MultipartFile file) {
+ public PatUpInfoVO importFilehandle(SysUser user, String tags, MultipartFile file) {
+ System.out.println("start : " + System.currentTimeMillis() / 1000);
PatUpInfoVO patUpInfoVO = new PatUpInfoVO();
- Integer successNum = 0;
- Integer failNum = 0;
+ //闇�瑕佸鐞嗙殑鎬昏鏁�
+ int lastRowNum = 0;
- List<PatArchive> errorpatArchiveList = new ArrayList<>();
+ final List<PatArchive> errorpatArchiveList = new ArrayList<>();
+ //鍒涘缓绾跨▼姹�
+ ExecutorService pool = Executors.newFixedThreadPool(10);
try {
Workbook workbook = new XSSFWorkbook(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0);
- for (int i = sheet.getFirstRowNum() + 1; i < sheet.getLastRowNum(); i++) {
- Row row = sheet.getRow(i);
- //濡傛灉琛屼负绌猴紝杩涜涓嬩竴娆″惊鐜�
- if (ObjectUtils.isEmpty(row)) {
- continue;
- }
- PatArchive patArchive = new PatArchive();
- if (ObjectUtils.isEmpty(row.getCell(3)) || StringUtils.isEmpty(row.getCell(3).toString())) {
- addRemark("韬唤璇佸彿涓虹┖", patArchive);
- } else {
- patArchive.setIccardno(row.getCell(3).toString());
- //鏍规嵁韬唤璇侊紝鍏堝幓鎮h�呯鐞嗚〃閲岀湅鐪嬫湁娌℃湁杩欎釜浜�,濡傛灉鏈夎繖涓汉锛屼篃涓嶉渶瑕佹彃鍏ユ偅鑰呰〃
- List<PatArchive> patArchiveList1 = patArchiveMapper.selectPatArchiveList(patArchive);
- if (patArchiveList1.size() > 0) {
- patArchive.setRemark("璇ユ偅鑰呭凡瀛樺湪");
+ //鑾峰彇鏂囦欢閲岀殑鎬昏鏁�
+ lastRowNum = sheet.getLastRowNum();
+ //灏嗘枃浠堕噷鐨勬暟鎹垎鎴�10浠�
+ int partsize = lastRowNum / 10;
+ for (int i = 0; i < 10; i++) {
+ int start = i * partsize + 1;
+ int end = (i + 1) * partsize;
+
+ pool.execute(new Runnable() {
+ @Override
+ public void run() {
+ for (int j = start; j <= end; j++) {
+ List<PatArchive> patArchives = new ArrayList<>();
+ String name = Thread.currentThread().getName();
+ Row row = sheet.getRow(j);
+ //濡傛灉琛屼负绌猴紝杩涜涓嬩竴娆″惊鐜�
+ if (ObjectUtils.isEmpty(row)) {
+ continue;
+ }
+ PatArchive patArchive = new PatArchive();
+ if (ObjectUtils.isEmpty(row.getCell(6)) || StringUtils.isEmpty(row.getCell(6).toString())) {
+ addRemark("璇佷欢鍙风爜涓虹┖", patArchive);
+ } else {
+ patArchive.setIdcardno(row.getCell(6).toString());
+ //鏍规嵁韬唤璇侊紝鍏堝幓鎮h�呯鐞嗚〃閲岀湅鐪嬫湁娌℃湁杩欎釜浜�,濡傛灉鏈夎繖涓汉锛屼篃涓嶉渶瑕佹彃鍏ユ偅鑰呰〃
+ // (杩欎竴鍧楁煡璇細褰卞搷鏁翠綋鐨勯�熷害,闇�瑕佷紭鍖�)
+ List<PatArchive> patArchiveList1 = patArchiveMapper.selectPatArchiveList(patArchive);
+ if (patArchiveList1.size() > 0) {
+ patArchive.setRemark("璇ユ偅鑰呭凡瀛樺湪");
+ }
+ }
+
+ //鍒ゆ柇濮撳悕鏄惁涓虹┖
+ 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)) || StringUtils.isEmpty(row.getCell(1).toString())) {
+ addRemark("鎬у埆涓虹┖", patArchive);
+ } else {
+ patArchive.setSex(row.getCell(1).toString().equals("鐢�") ? 1L : 2L);
+ }
+
+ //鍒ゆ柇璇佷欢绫诲瀷鏄惁涓虹┖
+ if (ObjectUtils.isEmpty(row.getCell(2)) || StringUtils.isEmpty(row.getCell(2).toString())) {
+ addRemark("璇佷欢绫诲瀷涓虹┖", patArchive);
+ } else {
+ patArchive.setIdcardtype(row.getCell(2).toString());
+ }
+
+ //鍒ゆ柇绫嶈疮鏄惁涓虹┖
+ if (ObjectUtils.isEmpty(row.getCell(3)) || StringUtils.isEmpty(row.getCell(3).toString())) {
+ patArchive.setNativePlace(null);
+ } else {
+ patArchive.setNativePlace(row.getCell(3).toString());
+ }
+
+ //鍒ゆ柇灞呬綇鍦版槸鍚︿负绌�
+ if (ObjectUtils.isEmpty(row.getCell(4)) || StringUtils.isEmpty(row.getCell(4).toString())) {
+ patArchive.setPlaceOfResidence(null);
+ } else {
+ patArchive.setPlaceOfResidence(row.getCell(4).toString());
+ }
+
+ //鍒ゆ柇灞呬綇鍦版槸鍚︿负绌�
+ if (ObjectUtils.isEmpty(row.getCell(5)) || StringUtils.isEmpty(row.getCell(5).toString())) {
+ patArchive.setBirthplace(null);
+ } else {
+ patArchive.setBirthplace(row.getCell(5).toString());
+ }
+
+ //鍒ゆ柇鍑虹敓鏃ユ湡鏄惁涓虹┖
+ if (ObjectUtils.isEmpty(row.getCell(7)) || StringUtils.isEmpty(row.getCell(7).toString())) {
+// addRemark("鍑虹敓鏃ユ湡涓虹┖", patArchive);
+ patArchive.setBirthdate(null);
+ } else {
+ //鏍煎紡杞崲锛岃浆鎴愭棩鏈�
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ Date javaDate = new Date();
+ if (row.getCell(7).getCellType().toString().equals("NUMERIC")) {
+ javaDate = HSSFDateUtil.getJavaDate(row.getCell(7).getNumericCellValue());
+ } else {
+ try {
+ javaDate = dateFormat.parse(row.getCell(7).toString());
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+ dateFormat.format(javaDate);
+ patArchive.setBirthdate(javaDate);
+ }
+
+ //鍒ゆ柇骞撮緞鏄惁涓虹┖
+ if (ObjectUtils.isEmpty(row.getCell(8)) || StringUtils.isEmpty(row.getCell(8).toString())) {
+ patArchive.setAge(null);
+ } else {
+ patArchive.setAge(Long.valueOf(row.getCell(8).toString()));
+ }
+
+ //鍒ゆ柇鏈汉鑱旂郴鏄惁涓虹┖锛屽拰闀垮害鏄惁姝g‘
+ if (ObjectUtils.isEmpty(row.getCell(12)) || StringUtils.isEmpty(row.getCell(12).toString())) {
+ addRemark("鏈汉鑱旂郴鐢佃瘽涓虹┖", patArchive);
+ } else {
+ //鏍煎紡杞崲锛岃浆鎴愭枃鏈�
+ if (row.getCell(12).getCellType().toString().equals("NUMERIC")) {
+ String cellData = String.valueOf((long) row.getCell(12).getNumericCellValue());
+ patArchive.setTelcode(cellData);
+ } else {
+ DataFormatter dataFormatter = new DataFormatter();
+ String cellValue = dataFormatter.formatCellValue(row.getCell(12));
+ patArchive.setTelcode(cellValue);
+ }
+ }
+
+ //鍒ゆ柇浜插睘鑱旂郴鏂瑰紡鏄惁涓虹┖锛岄暱搴︽槸鍚︽纭�
+ if (ObjectUtils.isEmpty(row.getCell(13)) || StringUtils.isEmpty(row.getCell(13).toString())) {
+// addRemark("浜插睘鑱旂郴鏂瑰紡涓虹┖", patArchive);
+ patArchive.setRelativetelcode(null);
+ } else {
+ //鏍煎紡杞崲锛岃浆鎴愭枃鏈�
+ if (row.getCell(13).getCellType().toString().equals("NUMERIC")) {
+ String cellData = String.valueOf((long) row.getCell(13).getNumericCellValue());
+ patArchive.setRelativetelcode(cellData);
+ } else {
+ DataFormatter dataFormatter = new DataFormatter();
+ String cellValue = dataFormatter.formatCellValue(row.getCell(13));
+ patArchive.setRelativetelcode(cellValue);
+ }
+ }
+ //鍒ゆ柇姘戞棌鏄惁涓虹┖
+ if (ObjectUtils.isEmpty(row.getCell(14)) || StringUtils.isEmpty(row.getCell(14).toString())) {
+ patArchive.setNation(null);
+ } else {
+ patArchive.setNation(row.getCell(14).toString());
+ }
+
+ //鎮i兘鏍囩鏄惁涓虹┖
+ if (ObjectUtils.isEmpty(row.getCell(17)) || StringUtils.isEmpty(row.getCell(17).toString())) {
+ patArchive.setTag(tags);
+ } else {
+ if (StringUtils.isNotEmpty(tags)) {
+ patArchive.setTag(row.getCell(17).toString() + "," + tags);
+ } else {
+ patArchive.setTag(row.getCell(17).toString());
+ }
+ }
+
+ //鍒ゆ柇澶囨敞鏄惁涓虹┖
+ if (!StringUtils.isEmpty(patArchive.getRemark())) {
+ //濡傛灉澶囨敞瀛楁涓嶄负绌猴紝璇存湁璇ユ偅鑰呭~鍐欐湁闂
+ errorpatArchiveList.add(patArchive);
+ continue;
+ }
+
+ patArchive.setUploadTime(new Date());
+ patArchive.setIsupload(0L);
+ //寰�鎮h�呰〃閲屾柊澧�,骞惰幏鍙栧埌鏂板ID
+ patArchives.add(patArchive);
+ int i1 = patArchiveMapper.insertPatArchive(patArchives);
+
+// // 鏍规嵁鏍囩鍚嶆煡璇㈠嚭鏍囩淇℃伅
+// 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);
+//
+// //濡傛灉璇ユ爣绛句负绌猴紝鐜版爣绛剧鐞嗘病鏈夊嚭鐜拌繃鐨勬柊鏍囩鏃讹紝鑷姩灏嗘爣绛炬坊鍔犲埌"鏍囩绠$悊"鏈垎绫烩�滀腑銆傜紪杈戜汉涓哄鍏ヨ处鍙�
+// 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);
+// }
+
+ patArchives.clear();
+ }
}
- }
-
- //鍒ゆ柇濮撳悕鏄惁涓虹┖
- 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)) || StringUtils.isEmpty(row.getCell(1).toString())) {
- addRemark("鎬у埆涓虹┖", patArchive);
- } else {
- patArchive.setSex(row.getCell(1).toString().equals("鐢�") ? 1L : 2L);
- }
-
- //鍒ゆ柇璇佷欢绫诲瀷鏄惁涓虹┖
- 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)) || StringUtils.isEmpty(row.getCell(4).toString())) {
- addRemark("鍑虹敓鏃ユ湡涓虹┖", patArchive);
- } else {
- //鏍煎紡杞崲锛岃浆鎴愭棩鏈�
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
- Date javaDate = new Date();
- if (row.getCell(4).getCellType().toString().equals("NUMERIC")) {
- javaDate = HSSFDateUtil.getJavaDate(row.getCell(4).getNumericCellValue());
- } else {
- javaDate = new Date(row.getCell(4).toString());
- }
- dateFormat.format(javaDate);
- patArchive.setBirthdate(javaDate);
- }
-
- //鍒ゆ柇鏈汉鑱旂郴鏄惁涓虹┖锛屽拰闀垮害鏄惁姝g‘
- if (ObjectUtils.isEmpty(row.getCell(5)) || StringUtils.isEmpty(row.getCell(5).toString())) {
- addRemark("鏈汉鑱旂郴鐢佃瘽涓虹┖", patArchive);
- } else {
- //鏍煎紡杞崲锛岃浆鎴愭枃鏈�
- if (row.getCell(5).getCellType().toString().equals("NUMERIC")) {
- String cellData = String.valueOf((long) row.getCell(5).getNumericCellValue());
- patArchive.setTelcode(cellData);
- } else {
- DataFormatter dataFormatter = new DataFormatter();
- String cellValue = dataFormatter.formatCellValue(row.getCell(5));
- patArchive.setTelcode(cellValue);
- }
- }
-
- //鍒ゆ柇浜插睘鑱旂郴鏂瑰紡鏄惁涓虹┖锛岄暱搴︽槸鍚︽纭�
- if (ObjectUtils.isEmpty(row.getCell(6)) || StringUtils.isEmpty(row.getCell(6).toString())) {
- addRemark("浜插睘鑱旂郴鏂瑰紡涓虹┖", patArchive);
- } else {
- //鏍煎紡杞崲锛岃浆鎴愭枃鏈�
- if (row.getCell(6).getCellType().toString().equals("NUMERIC")) {
- String cellData = String.valueOf((long) row.getCell(6).getNumericCellValue());
- patArchive.setRelativetelcode(cellData);
- } else {
- DataFormatter dataFormatter = new DataFormatter();
- String cellValue = dataFormatter.formatCellValue(row.getCell(6));
- patArchive.setRelativetelcode(cellValue);
- }
- }
-
- //鎮i兘鏍囩鏄惁涓虹┖
- if (ObjectUtils.isEmpty(row.getCell(7))) {
- addRemark("鎮h�呮爣绛句负绌�", patArchive);
- } else {
- patArchive.setTag(row.getCell(7).toString());
- }
-
- //鍒ゆ柇澶囨敞鏄惁涓虹┖
- if (!StringUtils.isEmpty(patArchive.getRemark())) {
- //濡傛灉澶囨敞瀛楁涓嶄负绌猴紝璇存湁璇ユ偅鑰呭~鍐欐湁闂
- errorpatArchiveList.add(patArchive);
- failNum = failNum + 1;
- continue;
- }
-
- //寰�鎮h�呰〃閲屾柊澧�,骞惰幏鍙栧埌鏂板ID
- patArchiveMapper.insertPatArchive(patArchive);
-
- //鏍规嵁鏍囩鍚嶆煡璇㈠嚭鏍囩淇℃伅
- 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);
-
- // 鏂板鎮h�呮。妗堟爣绛�
- PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag1, PatArchivetag.class);
- patArchivetag.setUpdateBy(username);
- patArchivetag.setCreateTime(new Date());
- patArchivetag.setPatid(patArchive.getPatid());
- patArchivetagMapper.insertPatArchivetag(patArchivetag);
- }
- successNum = successNum + 1;
+ });
}
-
} catch (Exception e) {
e.printStackTrace();
}
- patUpInfoVO.setFailNum(failNum);
- patUpInfoVO.setSuccessNum(successNum);
+ pool.shutdown();
+ Boolean aa = true;
+ d:
+ while (aa) {
+ boolean terminated = pool.isTerminated();
+ if (terminated) {
+ aa = false;
+ continue d;
+ }
+ }
+
+ if (errorpatArchiveList.size() != 0) {
+ patUpInfoVO.setSuccessNum(lastRowNum - errorpatArchiveList.size());
+ patUpInfoVO.setFailNum(errorpatArchiveList.size());
+ } else {
+ patUpInfoVO.setSuccessNum(lastRowNum == 0 ? 0 : lastRowNum);
+ patUpInfoVO.setFailNum(0);
+ }
patUpInfoVO.setPatArchiveList(errorpatArchiveList);
return patUpInfoVO;
}
@@ -286,6 +441,128 @@
return "瀵煎嚭鎴愬姛";
}
+ @Override
+ public List<PatArchive> patInfoByContion(PatArchiveReq patArchive) {
+ List<PatArchive> patArchives = new ArrayList<>();
+
+ //鏍规嵁鏉′欢鑾峰彇鎮h�呬俊鎭�
+// List<PatArchive> patArchiveList = patArchiveMapper.patInfoByContion(patArchive);
+ List<PatArchive> patArchiveList = new ArrayList<>();
+
+ if (patArchive.getEndtime() != null) {
+ //鍑洪櫌鏃堕棿鍙湁浣忛櫌鎵嶆湁
+ patArchive.setAllhosp(1L);
+ }
+
+ if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 0) {
+ List<PatArchive> patArchives0 = patArchiveMapper.selectPatArchiveInfoByAllhosp(patArchive);
+ if (CollectionUtils.isNotEmpty(patArchives0)) {
+ patArchiveList.addAll(patArchives0);
+ }
+ } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 1) {
+ List<PatArchive> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhosp(patArchive);
+ if (CollectionUtils.isNotEmpty(patArchives1)) {
+ patArchiveList.addAll(patArchives1);
+ }
+ } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 2) {
+ List<PatArchive> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchive);
+ if (CollectionUtils.isNotEmpty(patArchives2)) {
+ patArchiveList.addAll(patArchives2);
+ }
+ } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 3) {
+ List<PatArchive> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchive);
+ if (CollectionUtils.isNotEmpty(patArchives3)) {
+ patArchiveList.addAll(patArchives3);
+ }
+ }
+
+
+ //鏍规嵁鎮h�匢D杩涜鍒嗙粍
+ Map<Long, List<PatArchive>> listMap = patArchiveList.stream().collect(Collectors.groupingBy(PatArchive::getId));
+
+ //瀵规暟鎹繘琛屽皝瑁�
+ for (List<PatArchive> list : listMap.values()) {
+ PatArchive patArchive1 = new PatArchive();
+ Set<PatArchivetag> stringList = new HashSet<>();
+ for (int i = 0; i < list.size(); i++) {
+ if (i == 0) {
+ patArchive1 = DtoConversionUtils.sourceToTarget(list.get(0), PatArchive.class);
+ //灏嗘爣绛剧疆绌�,涓嶇┖涔熸病鏈夐棶棰�
+ patArchive1.setTag("");
+ }
+ //灏嗘煡鍑虹殑tag锛屾斁鍒皃atArchive1閲岀殑TagList涓�
+ PatArchivetag patArchivetag = new PatArchivetag();
+ patArchivetag.setTagname(list.get(i).getTag());
+ patArchivetag.setTagid(list.get(i).getTagid());
+ stringList.add(patArchivetag);
+ }
+ patArchive1.setTagList(stringList.stream().collect(Collectors.toList()));
+ 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.setId(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.setId(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;
+ }
+
+ @Override
+ public List<Object> getUserTreatmentInfo(String pid, String type) {
+ if (StringUtils.isEmpty(pid) || StringUtils.isEmpty(type)) {
+ throw new BaseException("鍏ュ弬涓虹┖锛岃妫�鏌ュ叆鍙�");
+ }
+ List<Object> objectList = new ArrayList<>();
+
+ //閫氳繃鎮h�呰幏鍙栭棬璇婁俊鎭�
+ PatMedInhosp patMedInhosp = new PatMedInhosp();
+ patMedInhosp.setInhospno(pid);
+ List<PatMedInhosp> patMedInhosps = patMedInhospService.selectPatMedInhospList(patMedInhosp);
+ objectList.addAll(patMedInhosps);
+
+
+ return null;
+ }
+
private void getdata(Row row, PatArchive patArchive, Boolean head) {
if (head) {
row.createCell(0).setCellValue("濮撳悕");
@@ -301,8 +578,8 @@
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());
+ row.createCell(2).setCellValue(patArchive.getIdcardtype());
+ row.createCell(3).setCellValue(patArchive.getIdcardno());
if (ObjectUtils.isNotEmpty(patArchive.getBirthdate())) {
row.createCell(4).setCellValue(simpleDateFormat.format(patArchive.getBirthdate()).toString());
}
--
Gitblit v1.9.3