liusheng
10 天以前 5a6f20263ef584485ae3df8b6f25b4e2fb970293
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.smartor.service.impl;
 
import com.ruoyi.common.core.domain.entity.SysDept;
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.*;
import com.smartor.service.IHNGatherPatArchiveService;
import com.smartor.service.IPatArchiveService;
import com.smartor.service.IPatMedInhospService;
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.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 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;
 
/**
 * 患者档案Service业务层处理
 *
 * @author smartor
 * @date 2023-03-04
 */
@Slf4j
@Service
public class HNGatherPatArchiveServiceImpl implements IHNGatherPatArchiveService {
    @Autowired
    private HNGatherPatArchiveMapper hnGatherPatArchiveMapper;
 
    @Autowired
    private SysUser2Mapper sysUser2Mapper;
 
    @Autowired
    private SysDept2Mapper sysDept2Mapper;
 
    @Autowired
    private Icd10Mapper icd10Mapper;
 
    @Autowired
    private PatMedOuthospMapper patMedOuthospMapper;
 
    @Autowired
    private PatMedInhospMapper patMedInhospMapper;
 
    @Autowired
    private PatArchiveMapper patArchiveMapper;
 
 
    @Override
    public List<PatArchive> selectPatArchiveList(PatArchive patArchive) {
        return hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
    }
 
    @Override
    public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp) {
        Long patArchiveCount = hnGatherPatArchiveMapper.selectPatArchiveCount(null);
        Long patOffst = (patArchiveCount + 1000 - 1) / 1000;
        PatArchive patArchive = new PatArchive();
        Long patSize = 0L;
        for (int i = 0; i <= patOffst; i++) {
            patArchive.setPs(1000);
            patArchive.setPn(1000 * i);
            List<PatArchive> patArchives = hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
            if (patArchives != null && !patArchives.isEmpty()) {
                patArchiveMapper.insertPatArchive(patArchives);
            }
            patSize = patSize + patArchives.size();
        }
        log.info("patArchives处理结束一共:{}", patSize);
 
 
        Long count = hnGatherPatArchiveMapper.selectPatMedInhospListCount(null);
        Long aa = (count + 1000 - 1) / 1000;
        //进行分页查询
        for (int i = 0; i <= aa; i++) {
            patMedInhosp.setPs(1000);
            patMedInhosp.setPn(1000 * i);
            List<PatMedInhosp> patMedInhospList = hnGatherPatArchiveMapper.selectPatMedInhospList(patMedInhosp);
            for (PatMedInhosp pm : patMedInhospList) {
                String patno = pm.getPatno();
                PatArchive pa = new PatArchive();
                //先去我们自己的表里通过patno查询该患者是否存在
                pa.setPatientno(patno);
                List<PatArchive> patArchives = patArchiveMapper.selectPatArchiveList(pa);
                if (CollectionUtils.isEmpty(patArchives)) {
                    continue;
                } else {
                    //直接将patid放到出入院表中
                    pm.setPatid(patArchives.get(0).getId());
                }
            }
            if (patMedInhospList != null && !patMedInhospList.isEmpty()) {
                patMedInhospMapper.insertPatMedInhospBatch(patMedInhospList);
            }
        }
        return null;
    }
 
    @Override
    public Integer selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
        List<PatMedOuthosp> patMedOuthosps = hnGatherPatArchiveMapper.selectPatMedOuthospList(patMedOuthosp);
        log.info("selectPatMedOuthospList的采集到的数量为:{}", patMedOuthosps.size());
        int i = patMedOuthospMapper.batchPatMedOuthosp(patMedOuthosps);
 
        return i;
    }
 
    @Override
    public Integer selectIcd10List(Icd10 icd10) {
        List<Icd10> icd10s = hnGatherPatArchiveMapper.selectIcd10List(icd10);
        log.info("selectIcd10List的采集到的数量为:{}", icd10s.size());
        int i = icd10Mapper.batchIcd10(icd10s);
        return i;
    }
 
    @Override
    public Integer selectUserList(SysUser sysUser) {
        List<SysUser> sysUserList = hnGatherPatArchiveMapper.selectUserList(sysUser);
        log.info("sysUserList的采集到的数量为:{}", sysUserList.size());
        int i = sysUser2Mapper.batchUser(sysUserList);
        return i;
    }
 
    @Override
    public Integer selectDeptList(SysDept dept) {
        List<SysDept> sysDepts = hnGatherPatArchiveMapper.selectDeptList(dept);
        log.info("selectDeptList的采集到的数量为:{}", sysDepts.size());
        int i = sysDept2Mapper.batchDept(sysDepts);
        return i;
    }
}