| | |
| | | package com.ruoyi.quartz.service.impl; |
| | | |
| | | import com.google.gson.Gson; |
| | | 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.smartor.mapper.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | private SysUserDeptMapper sysUserDeptMapper; |
| | | |
| | | @Autowired |
| | | private SysUserOrgMapper sysUserOrgMapper; |
| | | |
| | | @Autowired |
| | | private Icd10Mapper icd10Mapper; |
| | | |
| | | @Autowired |
| | |
| | | private static final long SHARDING_THRESHOLD = 5_000_000L; |
| | | private static final String PAT_ARCHIVE_TABLE = "pat_archive"; |
| | | private static final String PAT_MED_INHOSP_TABLE = "pat_med_inhosp"; |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | | |
| | | |
| | | @Override |
| | |
| | | List<PatMedInhosp> patMedInhospList1 = patMedInhospMapper.selectPatMedInhospListBySerialnum(pmi); |
| | | if (patMedInhospList1.size() == 0) { |
| | | pm.setCreateTime(new Date()); |
| | | //市一 院区id对应orgid,机构id为默认的1 |
| | | if(active.equals("hzszlyy")) { |
| | | pm.setCampusid(pm.getOrgid()); |
| | | pm.setOrgid("1"); |
| | | } |
| | | count += patMedInhospMapper.insertPatMedInhosp(pm); |
| | | } else { |
| | | pm.setInhospid(patMedInhospList1.get(0).getInhospid()); |
| | | pm.setUpdateTime(new Date()); |
| | | //市一 院区id对应orgid,机构id为默认的1 |
| | | if(active.equals("hzszlyy")) { |
| | | pm.setCampusid(pm.getOrgid()); |
| | | pm.setOrgid("1"); |
| | | } |
| | | count += patMedInhospMapper.updatePatMedInhosp(pm); |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | if (patMedOuthospsTemp.size() > 0) { |
| | | patMedOuthosp1.setUpdateTime(new Date()); |
| | | patMedOuthosp1.setId(patMedOuthospsTemp.get(0).getId()); |
| | | //市一 院区id对应orgid,机构id为默认的1 |
| | | if(active.equals("hzszlyy")) { |
| | | patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid()); |
| | | patMedOuthosp1.setOrgid("1"); |
| | | } |
| | | count += patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1); |
| | | } else { |
| | | patMedOuthosp1.setCreateTime(new Date()); |
| | | //市一 院区id对应orgid,机构id为默认的1 |
| | | if(active.equals("hzszlyy")) { |
| | | patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid()); |
| | | patMedOuthosp1.setOrgid("1"); |
| | | } |
| | | count += patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1); |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | public Integer selectUserList(SysUser sysUser) { |
| | | List<SysUser> sysUserList = chMapper.selectUserList(sysUser); |
| | | SysUser suerTemp = new SysUser(); |
| | | //用户-机构关系-科室 |
| | | List<SysUserDept> sysUserDeptAll = chMapper.yhyksxx(suerTemp); |
| | | //用户-机构关系-病区 |
| | | List<SysUserDept> sysUserDeptBfAll = chMapper.yhybfxx(suerTemp); |
| | | //用户-院区关系 |
| | | List<SysUserOrg> sysUserOrgAll = chMapper.yhyyqxx(suerTemp); |
| | | |
| | | log.info("sysUserList的采集到的数量为:{}", sysUserList.size()); |
| | | int i = 0;// sysUser2Mapper.batchUser(sysUserList); |
| | | for (SysUser sysUser1 : sysUserList) { |
| | | // log.info("sysUser1的ID为:{}", sysUser1.getUserId()); |
| | | // log.info("sysUser1的HISUSERID为:{}", sysUser1.getHisUserId()); |
| | | if (StringUtils.isEmpty(sysUser1.getHisUserId())) continue; |
| | | SysUser suTemp = new SysUser(); |
| | | suTemp.setHisUserId(sysUser1.getHisUserId()); |
| | | List<SysUser> usersTemp = sysUser2Mapper.selectUserList(suTemp); |
| | | |
| | | //新增用户与科室 |
| | | List<SysUserDept> sysUserDept = sysUserDeptAll.stream().filter((SysUserDept b) -> b.getUserCode().equals(sysUser1.getHisUserId())).collect(Collectors.toList()); |
| | | //新增用户与病区 |
| | | List<SysUserDept> sysUserDeptBf = sysUserDeptBfAll.stream().filter((SysUserDept b) -> b.getUserCode().equals(sysUser1.getHisUserId())).collect(Collectors.toList()); |
| | | //新增用户与院区 |
| | | List<SysUserOrg> sysUserOrg = sysUserOrgAll.stream().filter((SysUserOrg o) -> o.getUserId().equals(sysUser1.getHisUserId())).collect(Collectors.toList()); |
| | | |
| | | List<String> userDepts = sysUserDept.stream().map(SysUserDept::getDeptCode).distinct().collect(Collectors.toList()); |
| | | List<String> userDeptBfs = sysUserDeptBf.stream().map(SysUserDept::getDeptCode).distinct().collect(Collectors.toList()); |
| | | |
| | | if (usersTemp.size() > 0) { |
| | | sysUser1.setUserId(usersTemp.get(0).getUserId()); |
| | | sysUser1.setUserName(sysUser1.getHisUserId()); |
| | | //对应 SysUserServiceImpl selectUserByUserName2 191行 |
| | | if (!org.springframework.util.CollectionUtils.isEmpty(sysUserOrg)) { |
| | | sysUser1.setOrgid(sysUserOrg.get(0).getOrgid()); |
| | | sysUser1.setCampusid(sysUserOrg.get(0).getCampusid()); |
| | | } |
| | | //将部门我病区放到指定字段中 |
| | | Gson gson = new Gson(); |
| | | if(!userDepts.isEmpty()){ |
| | | sysUser1.setDeptInfo(gson.toJson(userDepts)); |
| | | } |
| | | if(!userDeptBfs.isEmpty()){ |
| | | sysUser1.setHospInfo(gson.toJson(userDeptBfs)); |
| | | } |
| | | sysUser2Mapper.updateUser(sysUser1); |
| | | } else { |
| | | sysUser1.setUserName(sysUser1.getHisUserId()); |
| | | //将部门我病区放到指定字段中 |
| | | Gson gson = new Gson(); |
| | | if(!userDepts.isEmpty()){ |
| | | sysUser1.setDeptInfo(gson.toJson(userDepts)); |
| | | } |
| | | if(!userDeptBfs.isEmpty()){ |
| | | sysUser1.setHospInfo(gson.toJson(userDeptBfs)); |
| | | } |
| | | sysUser2Mapper.insertUser(sysUser1); |
| | | //对应 SysUserServiceImpl selectUserByUserName2 191行 |
| | | if (!org.springframework.util.CollectionUtils.isEmpty(sysUserOrg)) { |
| | | sysUser1.setOrgid(sysUserOrg.get(0).getOrgid()); |
| | | sysUser1.setCampusid(sysUserOrg.get(0).getCampusid()); |
| | | } |
| | | usersTemp = sysUser2Mapper.selectUserList(suTemp); |
| | | } |
| | | |
| | | //新增用户与部门 |
| | | //List<SysUserDept> sysUserDept = chMapper.yhyksxx(sysUser1); |
| | | List<SysUserDept> sysUserDept = sysUserDeptAll.stream().filter((SysUserDept b) -> b.getUserCode().equals(sysUser1.getHisUserId())).collect(Collectors.toList()); |
| | | |
| | | for (SysUserDept sud : sysUserDept) { |
| | | if (usersTemp.size() > 0) { |
| | | if (!usersTemp.isEmpty()) { |
| | | sud.setDeptType("1"); |
| | | sud.setUserId(usersTemp.get(0).getUserId()); |
| | | sysUserDeptMapper.insertSysUserDept(sud); |
| | | } |
| | | } |
| | | for (SysUserDept sudb : sysUserDeptBf) { |
| | | if (!usersTemp.isEmpty()) { |
| | | sudb.setDeptType("2"); |
| | | sudb.setUserId(usersTemp.get(0).getUserId()); |
| | | sysUserDeptMapper.insertSysUserDept(sudb); |
| | | } |
| | | } |
| | | for (SysUserOrg suo : sysUserOrg) { |
| | | if (!usersTemp.isEmpty()) { |
| | | suo.setUserId(usersTemp.get(0).getUserId().toString()); |
| | | sysUserOrgMapper.insertSysUserOrg(suo); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (sysDeptTemp != null && sysDeptTemp.getDeptName() != null) { |
| | | row.setDeptId(sysDeptTemp.getDeptId()); |
| | | count += sysDept2Mapper.updateDept(row); |
| | | |
| | | } else { |
| | | count += sysDept2Mapper.insertDept(row); |
| | | } |