liusheng
昨天 29069b790469cb7136cadba7ddcd63a83bc4ac70
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
@@ -9,6 +9,7 @@
import com.ruoyi.quartz.service.ICollectHISService;
import com.smartor.domain.*;
import com.smartor.mapper.*;
import com.smartor.service.IPatMedOuthospService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
@@ -35,7 +36,7 @@
    private SysUser2Mapper sysUser2Mapper;
    @Autowired
    private SysUserRole2Mapper sysUserRoleMapper;
    private IPatMedOuthospService patMedOuthospService;
    @Autowired
    private SysDept2Mapper sysDept2Mapper;
@@ -291,7 +292,7 @@
                        patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid());
                        patMedOuthosp1.setOrgid("1");
                    }
                    count += patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
                    count += patMedOuthospService.updatePatMedOuthosp(patMedOuthosp1);
                } else {
                    patMedOuthosp1.setCreateTime(new Date());
                    //市一 院区id对应orgid,机构id为默认的1
@@ -299,7 +300,7 @@
                        patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid());
                        patMedOuthosp1.setOrgid("1");
                    }
                    count += patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1);
                    count += patMedOuthospService.insertPatMedOuthosp(patMedOuthosp1);
                }
            } catch (Exception ex) {
                log.info("同步出入院:" + ex.getMessage());
@@ -413,7 +414,7 @@
                patArchiveMapper.insertPatArchiveSingle(patArchives.get(0));
                patMedOuthosp1.setPatid(patArchives.get(0).getId());
            }
            i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1);
            i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp1);
        }
        return i;
@@ -463,14 +464,38 @@
            List<SysUser> usersTemp = sysUser2Mapper.selectUserList(suTemp);
            //新增用户与科室
            List<SysUserDept> sysUserDept = sysUserDeptAll.stream().filter((SysUserDept b) -> b.getUserCode().equals(sysUser1.getHisUserId())).collect(Collectors.toList());
            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<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<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());
            List<String> userDepts = sysUserDept.stream().map(SysUserDept::getDeptCode).
                    distinct().collect(Collectors.toList());
            List<String> userDeptBfs = sysUserDeptBf.stream().map(SysUserDept::getDeptCode).
                    distinct().collect(Collectors.toList());
            //和queryHospUserInfoList采集的数据格式保持一致
            List<List<String>> userDeptsList = new ArrayList<>();
            if(!userDepts.isEmpty()){
                for(String userDept: userDepts){
                    List<String> uDept = new ArrayList<>();
                    uDept.add(userDept);
                    userDeptsList.add(uDept);
                }
            }
            List<List<String>> userDeptBfsList = new ArrayList<>();
            if(!userDeptBfs.isEmpty()){
                for(String userBfDept: userDeptBfs){
                    List<String> uBfDept = new ArrayList<>();
                    uBfDept.add(userBfDept);
                    userDeptBfsList.add(uBfDept);
                }
            }
            if (usersTemp.size() > 0) {
                sysUser1.setUserId(usersTemp.get(0).getUserId());
@@ -482,23 +507,17 @@
                }
                //将部门我病区放到指定字段中
                Gson gson = new Gson();
                if(!userDepts.isEmpty()){
                    sysUser1.setDeptInfo(gson.toJson(userDepts));
                }
                if(!userDeptBfs.isEmpty()){
                    sysUser1.setHospInfo(gson.toJson(userDeptBfs));
                }
                sysUser1.setHospInfo(gson.toJson(userDeptsList));
                sysUser1.setDeptInfo(gson.toJson(userDeptBfsList));
                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));
                }
                sysUser1.setHospInfo(gson.toJson(userDeptsList));
                sysUser1.setDeptInfo(gson.toJson(userDeptBfsList));
                sysUser2Mapper.insertUser(sysUser1);
                //对应 SysUserServiceImpl selectUserByUserName2 191行
                if (!org.springframework.util.CollectionUtils.isEmpty(sysUserOrg)) {