From 78b0e909aa6ece787091e5d81450c8927ef2599e Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 15 十二月 2023 17:03:12 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java |  501 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 340 insertions(+), 161 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 55eb072..15fb59d 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,32 @@
 package com.smartor.service.impl;
 
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 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.*;
 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.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.service.IPatArchiveService;
@@ -33,6 +39,7 @@
  * @author smartor
  * @date 2023-03-04
  */
+@Slf4j
 @Service
 public class PatArchiveServiceImpl implements IPatArchiveService {
     @Autowired
@@ -43,6 +50,18 @@
 
     @Autowired
     private PatArchivetagMapper patArchivetagMapper;
+
+    @Autowired
+    private IPatMedInhospService patMedInhospService;
+
+    @Autowired
+    private IPatMedOuthospService patMedOuthospService;
+
+    @Autowired
+    private IPatMedPhysicalService patMedPhysicalService;
+
+    @Autowired
+    private RedisCache redisCache;
 
 
     /**
@@ -67,6 +86,7 @@
         return patArchiveMapper.selectPatArchiveList(patArchive);
     }
 
+
     /**
      * 鏂板鎮h�呮。妗�
      *
@@ -76,7 +96,9 @@
     @Override
     public int insertPatArchive(PatArchive patArchive) {
         patArchive.setCreateTime(DateUtils.getNowDate());
-        return patArchiveMapper.insertPatArchive(patArchive);
+        List<PatArchive> patArchives = new ArrayList<>();
+        patArchives.add(patArchive);
+        return patArchiveMapper.insertPatArchive(patArchives);
     }
 
     /**
@@ -85,10 +107,51 @@
      * @param patArchive 鎮h�呮。妗�
      * @return 缁撴灉
      */
+    @Transactional(rollbackFor = Exception.class)
     @Override
-    public int updatePatArchive(PatArchive patArchive) {
+    public Boolean updatePatArchive(PatArchive patArchive) {
         patArchive.setUpdateTime(DateUtils.getNowDate());
-        return patArchiveMapper.updatePatArchive(patArchive);
+
+        for (String tagName : patArchive.getTagList()) {
+            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(null);
+                baseTag.setDelFlag("0");
+                baseTag.setCreateBy(null);
+                baseTag.setCreateTime(new Date());
+                baseTag.setCreateBy(null);
+                baseTag.setCreateTime(new Date());
+                baseTagMapper.insertBaseTag(baseTag);
+                //鐒跺悗鍐嶅線pat_archivetag琛ㄤ腑鏂板
+            } else {
+                //濡傛灉鍦╞asetag涓瓨鍦�,鍒欐牴鎹畉agid鍜宲atid鍘籶at_archivetag琛ㄤ腑鏌ヨ鏄惁瀛樺湪
+                baseTag = baseTags.get(0);
+                PatArchivetag patArchivetag = new PatArchivetag();
+                patArchivetag.setPatid(patArchive.getPatid());
+                patArchivetag.setTagid(baseTag.getTagid());
+                List<PatArchivetag> patArchivetags = patArchivetagMapper.selectPatArchivetagAndBaseTagList(patArchivetag);
+                if (CollectionUtils.isNotEmpty(patArchivetags)) {
+                    //濡傛灉瀛樺湪锛宑ontinue;
+                    continue;
+                } else {
+                    //濡傛灉涓嶅瓨鍦紝鍒欏垯pat_archivetag涓柊澧�
+                    // 鏂板鎮h�呮。妗堟爣绛�
+                }
+            }
+            PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag, PatArchivetag.class);
+            patArchivetag.setUpdateBy(null);
+            patArchivetag.setCreateTime(new Date());
+            patArchivetag.setPatid(patArchive.getPatid());
+            patArchivetagMapper.insertPatArchivetag(patArchivetag);
+        }
+        patArchiveMapper.updatePatArchive(patArchive);
+        return true;
     }
 
     /**
@@ -116,168 +179,240 @@
     @Override
     @Transactional
     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)) || 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());
-                    }
-                }
-
-                //鍒ゆ柇澶囨敞鏄惁涓虹┖
-                if (!StringUtils.isEmpty(patArchive.getRemark())) {
-                    //濡傛灉澶囨敞瀛楁涓嶄负绌猴紝璇存湁璇ユ偅鑰呭~鍐欐湁闂
-                    errorpatArchiveList.add(patArchive);
-                    failNum = failNum + 1;
-                    continue;
-                }
-
-                //寰�鎮h�呰〃閲屾柊澧�,骞惰幏鍙栧埌鏂板ID
-                patArchiveMapper.insertPatArchive(patArchive);
-
-                //鏍规嵁鏍囩鍚嶆煡璇㈠嚭鏍囩淇℃伅
-                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);
-                }
-                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;
     }
@@ -314,14 +449,44 @@
         List<PatArchive> patArchives = new ArrayList<>();
 
         //鏍规嵁鏉′欢鑾峰彇鎮h�呬俊鎭�
-        List<PatArchive> patArchiveList = patArchiveMapper.patInfoByContion(patArchive);
+//        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::getPatid));
 
         //瀵规暟鎹繘琛屽皝瑁�
         for (List<PatArchive> list : listMap.values()) {
             PatArchive patArchive1 = new PatArchive();
-            List<String> stringList = new ArrayList<>();
+            Set<String> stringList = new HashSet<>();
             for (int i = 0; i < list.size(); i++) {
                 if (i == 0) {
                     patArchive1 = DtoConversionUtils.sourceToTarget(list.get(0), PatArchive.class);
@@ -331,7 +496,7 @@
                 //灏嗘煡鍑虹殑tag锛屾斁鍒皃atArchive1閲岀殑TagList涓�
                 stringList.add(list.get(i).getTag());
             }
-            patArchive1.setTagList(stringList);
+            patArchive1.setTagList(stringList.stream().collect(Collectors.toList()));
             patArchives.add(patArchive1);
         }
 
@@ -378,7 +543,21 @@
     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;
@@ -399,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