sinake
5 天以前 8f5a4a882870ce0dcfbdb5716b55ec55887924d6
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
ÎļþÃû´Ó ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISMapperServiceImpl.java ÐÞ¸Ä
@@ -1,21 +1,16 @@
package com.ruoyi.quartz.service.impl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.SysUserDept;
import com.ruoyi.common.core.domain.entity.SysUserRole;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.quartz.mapper.CollectHISMapper;
import com.ruoyi.quartz.service.ICollectHISMapperService;
import com.ruoyi.quartz.service.ICollectHISService;
import com.smartor.domain.*;
import com.smartor.mapper.*;
import com.smartor.service.impl.PatArchiveServiceImpl;
import com.smartor.service.impl.PatMedInhospServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
@@ -27,9 +22,9 @@
@Slf4j
@Service
public class CollectHISMapperServiceImpl implements ICollectHISMapperService {
public class CollectHISServiceImpl implements ICollectHISService {
    @Autowired
    private HNGatherPatArchiveMapper hnGatherPatArchiveMapper;
    private CollectHISMapper chMapper;
    @Autowired
    private SysUser2Mapper sysUser2Mapper;
@@ -68,7 +63,7 @@
    @Override
    public List<PatArchive> selectPatArchiveList(PatArchive patArchive) {
        return hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
        return chMapper.selectPatArchiveList(patArchive);
    }
//    @Override
@@ -86,11 +81,11 @@
    @Override
    public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp) {
        List<PatMedInhosp> patMedInhospList = hnGatherPatArchiveMapper.selectPatMedInhospList(patMedInhosp);
        List<PatMedInhosp> patMedInhospList = chMapper.selectPatMedInhospList(patMedInhosp);
        for (PatMedInhosp pm : patMedInhospList) {
            PatArchive patArchive = new PatArchive();
            patArchive.setPatientno(pm.getPatno());
            List<PatArchive> patArchives = hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
            List<PatArchive> patArchives = chMapper.selectPatArchiveList(patArchive);
            if (CollectionUtils.isEmpty(patArchives)) {
                //空了直接丢掉
                continue;
@@ -104,7 +99,27 @@
                patArchiveMapper.insertPatArchiveSingle(patArchives.get(0));
                pm.setPatid(patArchives.get(0).getId());
            }
            patMedInhospMapper.insertPatMedInhosp(pm);
            if (!Objects.isNull(patMedInhosp.getStartInHospTime()) && !Objects.isNull(patMedInhosp.getEndInHospTime())) {
                //入院
                pm.setInhospstate("0");
                pm.setCreateTime(new Date());
                patMedInhospMapper.insertPatMedInhosp(pm);
            } else if (!Objects.isNull(patMedInhosp.getStartOutHospTime()) && !Objects.isNull(patMedInhosp.getEndOutHospTime())) {
                //出院
                pm.setInhospstate("1");
                pm.setUpdateTime(new Date());
                PatMedInhosp pmi = new PatMedInhosp();
                pmi.setSerialnum(pm.getSerialnum());
                List<PatMedInhosp> patMedInhospList1 = patMedInhospMapper.selectPatMedInhospList(pmi);
                if (CollectionUtils.isEmpty(patMedInhospList1)) {
                    pm.setCreateTime(new Date());
                    patMedInhospMapper.insertPatMedInhosp(pm);
                } else {
                    pm.setInhospid(patMedInhospList1.get(0).getInhospid());
                    patMedInhospMapper.updatePatMedInhosp(pm);
                }
            }
        }
        return 0;
    }
@@ -119,16 +134,25 @@
        // å¾ªçŽ¯å¤„ç†æ¯ä¸€å¤©
        for (LocalDate currentDate = startDate; !currentDate.isAfter(endDate); currentDate = currentDate.plusDays(1)) {
            PatMedInhosp dailyCondition = new PatMedInhosp();
            //处理入院
            LocalDateTime dayStart = currentDate.atStartOfDay();
            LocalDateTime dayEnd = currentDate.atTime(23, 59, 59);
            dailyCondition.setStartInHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
            dailyCondition.setEndInHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
            selectPatMedInhospList(dailyCondition);
            //处理出院
            dailyCondition.setStartInHospTime(null);
            dailyCondition.setEndInHospTime(null);
            dailyCondition.setStartOutHospTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
            dailyCondition.setEndOutHospTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
            Integer pi = selectPatMedInhospList(dailyCondition);
            selectPatMedInhospList(dailyCondition);
            //处理门诊
            PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
            patMedOuthosp.setBeginTime(Date.from(dayStart.atZone(ZoneId.systemDefault()).toInstant()));
            patMedOuthosp.setEndTime(Date.from(dayEnd.atZone(ZoneId.systemDefault()).toInstant()));
            po = selectPatMedOuthospList(patMedOuthosp);
            selectPatMedOuthospList(patMedOuthosp);
        }
        return true;
    }
@@ -136,14 +160,14 @@
    @Override
    public Integer selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
        List<PatMedOuthosp> patMedOuthosps = hnGatherPatArchiveMapper.selectPatMedOuthospList(patMedOuthosp);
        List<PatMedOuthosp> patMedOuthosps = chMapper.selectPatMedOuthospList(patMedOuthosp);
        log.info("selectPatMedOuthospList的采集到的数量为:{}", patMedOuthosps.size());
        Integer i = null;
        for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
            //获取患者基本信息
            PatArchive patArchive = new PatArchive();
            patArchive.setPatientno(patMedOuthosp1.getPatno());
            List<PatArchive> patArchives = hnGatherPatArchiveMapper.selectPatArchiveList(patArchive);
            List<PatArchive> patArchives = chMapper.selectPatArchiveList(patArchive);
            //根据patno判断本地患者基本信息是否存在
            PatArchive pa = new PatArchive();
@@ -166,7 +190,7 @@
    @Override
    public Integer selectIcd10List(Icd10 icd10) {
        List<Icd10> icd10s = hnGatherPatArchiveMapper.selectIcd10List(icd10);
        List<Icd10> icd10s = chMapper.selectIcd10List(icd10);
        log.info("selectIcd10List的采集到的数量为:{}", icd10s.size());
        int i = icd10Mapper.batchIcd10(icd10s);
        return i;
@@ -174,14 +198,14 @@
    @Override
    public Integer selectUserList(SysUser sysUser) {
        List<SysUser> sysUserList = hnGatherPatArchiveMapper.selectUserList(sysUser);
        List<SysUser> sysUserList = chMapper.selectUserList(sysUser);
        log.info("sysUserList的采集到的数量为:{}", sysUserList.size());
        int i = sysUser2Mapper.batchUser(sysUserList);
        for (SysUser sysUser1 : sysUserList) {
            log.info("sysUser1的ID为:{}", sysUser1.getUserId());
            log.info("sysUser1的HISUSERID为:{}", sysUser1.getHisUserId());
            //新增用户与角色
            SysUserRole yhyjsxx = hnGatherPatArchiveMapper.yhyjsxx(sysUser1);
            SysUserRole yhyjsxx = chMapper.yhyjsxx(sysUser1);
            if (yhyjsxx == null) continue;
            yhyjsxx.setUserId(sysUser1.getUserId());
            List<SysUserRole> userRoleList = new ArrayList<>();
@@ -190,7 +214,7 @@
            //新增用户与部门
            if (StringUtils.isEmpty(sysUser1.getHisUserId())) continue;
            SysUserDept sysUserDept = hnGatherPatArchiveMapper.yhyksxx(sysUser1);
            SysUserDept sysUserDept = chMapper.yhyksxx(sysUser1);
            if (Objects.isNull(sysUserDept) || sysUserDept.getDeptId() == null) continue;
            SysDept dept = new SysDept();
            dept.setHisDeptId(sysUserDept.getDeptId().toString());
@@ -209,7 +233,7 @@
    @Override
    public Integer selectDeptList(SysDept dept) {
        List<SysDept> sysDepts = hnGatherPatArchiveMapper.selectDeptList(dept);
        List<SysDept> sysDepts = chMapper.selectDeptList(dept);
        log.info("selectDeptList的采集到的数量为:{}", sysDepts.size());
        int i = sysDept2Mapper.batchDept(sysDepts);
        return i;