From 907641e56c2085aaa81f267946dc3e3e9fca73e7 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 18 九月 2024 09:39:02 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java |  644 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 469 insertions(+), 175 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 9cad7d3..871e4d3 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
@@ -1,35 +1,40 @@
 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.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.PatArchiveMapper;
 import com.smartor.mapper.PatArchivetagMapper;
+import com.smartor.service.IPatArchiveService;
+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.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 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;
+
+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;
 
 /**
  * 鎮h�呮。妗圫ervice涓氬姟灞傚鐞�
@@ -37,6 +42,7 @@
  * @author smartor
  * @date 2023-03-04
  */
+@Slf4j
 @Service
 public class PatArchiveServiceImpl implements IPatArchiveService {
     @Autowired
@@ -47,6 +53,18 @@
 
     @Autowired
     private PatArchivetagMapper patArchivetagMapper;
+
+    @Autowired
+    private IPatMedInhospService patMedInhospService;
+
+    @Autowired
+    private IPatMedOuthospService patMedOuthospService;
+
+    @Autowired
+    private IPatMedPhysicalService patMedPhysicalService;
+
+    @Autowired
+    private RedisCache redisCache;
 
 
     /**
@@ -71,6 +89,7 @@
         return patArchiveMapper.selectPatArchiveList(patArchive);
     }
 
+
     /**
      * 鏂板鎮h�呮。妗�
      *
@@ -78,21 +97,63 @@
      * @return 缁撴灉
      */
     @Override
-    public int insertPatArchive(PatArchive patArchive) {
+    public Integer insertPatArchive(PatArchive patArchive) {
         patArchive.setCreateTime(DateUtils.getNowDate());
-        return patArchiveMapper.insertPatArchive(patArchive);
+        patArchiveMapper.insertPatArchiveSingle(patArchive);
+        return patArchive.getId().intValue();
+    }
+
+    @Override
+    public Boolean update(PatArchive patArchive) {
+        int i = patArchiveMapper.updatePatArchive(patArchive);
+        if (i != 1) {
+            return false;
+        }
+        return true;
     }
 
     /**
-     * 淇敼鎮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.getId() == 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.getId() != 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;
     }
 
     /**
@@ -117,171 +178,283 @@
         return patArchiveMapper.deletePatArchiveByPatid(patid);
     }
 
+    /**
+     * 鑾峰彇鎮h�呬俊鎭�
+     *
+     * @param patArchiveReq
+     * @return
+     */
+    @Override
+    public List<PatArchiveOthreInfo> getPatientInfo(PatArchiveReq patArchiveReq) {
+        if (CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) || patArchiveReq.getLeavehospitaldistrictcodes().size() == 0) {
+            patArchiveReq.setLeavehospitaldistrictcodes(null);
+        }
+        if (CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) || patArchiveReq.getLeaveldeptcodes().size() == 0) {
+            patArchiveReq.setLeaveldeptcodes(null);
+        }
+
+        List<PatArchiveOthreInfo> patArchiveList = new ArrayList<>();
+        if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 1) {
+            //  鏌ョ湅浣忛櫌  1  鏌ョ湅闂ㄨ瘖  2   鏌ョ湅浣撴  3
+            List<PatArchiveOthreInfo> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhosp(patArchiveReq);
+            if (CollectionUtils.isNotEmpty(patArchives1)) {
+                patArchiveList.addAll(patArchives1);
+            }
+        } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) {
+            // 鏌ョ湅浣忛櫌  1  鏌ョ湅闂ㄨ瘖  2   鏌ョ湅浣撴  3
+            List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchiveReq);
+            if (CollectionUtils.isNotEmpty(patArchives2)) {
+                patArchiveList.addAll(patArchives2);
+            }
+        } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) {
+            //  鏌ョ湅浣忛櫌  1  鏌ョ湅闂ㄨ瘖  2   鏌ョ湅浣撴  3
+            List<PatArchiveOthreInfo> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchiveReq);
+            if (CollectionUtils.isNotEmpty(patArchives3)) {
+                patArchiveList.addAll(patArchives3);
+            }
+        }
+
+        return patArchiveList;
+    }
+
+
     @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;
     }
@@ -313,6 +486,127 @@
         return "瀵煎嚭鎴愬姛";
     }
 
+    @Override
+    public List<PatArchive> patInfoByContion(PatArchiveReq patArchive) {
+        List<PatArchive> patArchives = new ArrayList<>();
+
+        //鏍规嵁鏉′欢鑾峰彇鎮h�呬俊鎭�
+//        List<PatArchive> patArchiveList = patArchiveMapper.patInfoByContion(patArchive);
+        List<PatArchiveOthreInfo> patArchiveList = new ArrayList<>();
+
+        if (patArchive.getEndtime() != null) {
+            //鍑洪櫌鏃堕棿鍙湁浣忛櫌鎵嶆湁
+            patArchive.setAllhosp(1L);
+        }
+
+        if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 0) {
+            List<PatArchiveOthreInfo> patArchives0 = patArchiveMapper.selectPatArchiveInfoByAllhosp(patArchive);
+            if (CollectionUtils.isNotEmpty(patArchives0)) {
+                patArchiveList.addAll(patArchives0);
+            }
+        } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 1) {
+            List<PatArchiveOthreInfo> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhosp(patArchive);
+            if (CollectionUtils.isNotEmpty(patArchives1)) {
+                patArchiveList.addAll(patArchives1);
+            }
+        } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 2) {
+            List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchive);
+            if (CollectionUtils.isNotEmpty(patArchives2)) {
+                patArchiveList.addAll(patArchives2);
+            }
+        } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 3) {
+            List<PatArchiveOthreInfo> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchive);
+            if (CollectionUtils.isNotEmpty(patArchives3)) {
+                patArchiveList.addAll(patArchives3);
+            }
+        }
+
+        //鏍规嵁鎮h�匢D杩涜鍒嗙粍
+        Map<Long, List<PatArchiveOthreInfo>> listMap = patArchiveList.stream().collect(Collectors.groupingBy(PatArchiveOthreInfo::getId));
+
+        //瀵规暟鎹繘琛屽皝瑁�
+        for (List<PatArchiveOthreInfo> 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("濮撳悕");
@@ -328,8 +622,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