| | |
| | | private final static String LOCK_KEY_USERNAME = CommonConstant.LOCK_KEY_PREFIX + "username:"; |
| | | @Autowired |
| | | private PasswordEncoder passwordEncoder; |
| | | |
| | | @Resource |
| | | private ISysRoleUserService roleUserService; |
| | | @Resource |
| | | private ISysDictionariesService sysDictionariesService; |
| | | @Resource |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | | |
| | | @Autowired |
| | | private ISysOrganizationService organizationService; |
| | | @Autowired |
| | |
| | | private DistributedLock lock; |
| | | @Autowired |
| | | private SysDoctorMapper sysDoctorMapper; |
| | | |
| | | @Autowired |
| | | private SysRoleMapper sysRoleMapper; |
| | | @Autowired |
| | |
| | | @Override |
| | | public LoginAppUser findByUsername(String username) { |
| | | SysUser sysUser = this.selectByUsername(username); |
| | | return getLoginAppUser(sysUser); |
| | | if (sysUser == null) { |
| | | return null; |
| | | } else { |
| | | return getLoginAppUser(sysUser); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | /** |
| | | * 获取登录用户的一系列信息 hrj 06-04修改 |
| | | * |
| | | * @param sysUser |
| | | * @param sysUserNew |
| | | * @return |
| | | */ |
| | | @Override |
| | | public LoginAppUser getLoginAppUser(SysUser sysUser) { |
| | | public LoginAppUser getLoginAppUser(SysUser sysUserNew) { |
| | | LoginAppUser loginAppUser = new LoginAppUser(); |
| | | SysUser sysUserNew = this.baseMapper.selectById(sysUser); |
| | | SysUser sysUser = this.baseMapper.selectById(sysUserNew); |
| | | if (sysUser != null) { |
| | | //返回的数据为什么要把密码也返回?清空!! |
| | | loginAppUser.setPassword(""); |
| | | loginAppUser.setNewPassword(""); |
| | | loginAppUser.setOldPassword(""); |
| | | |
| | | BeanUtils.copyProperties(sysUser, loginAppUser); |
| | | //获取用户所属组织机构列表 |
| | | loginAppUser.setDefaultAuth(sysUserNew.getDefaultAuth()); |
| | | loginAppUser.setDefaultAuth(sysUser.getDefaultAuth()); |
| | | List<SysOrganization> sysOrganizations = organizationService.findListByUserId(sysUser.getId()); |
| | | //设置组织机构集合 |
| | | loginAppUser.setOrganizations(sysOrganizations); |
| | | if (sysOrganizations != null) { |
| | | loginAppUser.setOrganizations(sysOrganizations); |
| | | } |
| | | List<SysRole> sysRoles = roleUserService.findRolesByUserId(sysUser.getId()); |
| | | // 设置角色 |
| | | loginAppUser.setRoles(sysRoles); |
| | |
| | | loginAppUser.setPermissions(permissions); |
| | | } |
| | | } |
| | | //是否医院管理员 |
| | | com.kidgrow.usercenter.model.SysDoctor sysDoctor = findDoctorByUserId(sysUser.getId()); |
| | | if (sysDoctor.getIsAdminUser() != null) { |
| | | loginAppUser.setHAdminUser(sysDoctor.getIsAdminUser()); |
| | | } |
| | | //医院信息 只有H端要返回的信息 |
| | | if (sysUser.getTenantId().toLowerCase().equals(CommonConstant.H_TENANT.toLowerCase())) { |
| | | DoctorUserAll doctorUserAllVo = baseMapper.findDoctorUserAllData(sysUser.getId()); |
| | | |
| | | //医院信息 |
| | | DoctorUserAll doctorUserAllVo = baseMapper.findDoctorUserAllData(sysUser.getId()); |
| | | if (doctorUserAllVo != null) { |
| | | loginAppUser.setDoctorUserAllVO(doctorUserAllVo); |
| | | //是否医院管理员 |
| | | loginAppUser.setHAdminUser(doctorUserAllVo.getIsAdminUser()); |
| | | } |
| | | } |
| | | return loginAppUser; |
| | |
| | | |
| | | @Override |
| | | public ResultBody findCountByMap(Map<String, Object> map) { |
| | | map.put("enable",1); |
| | | map.put("is_del",0); |
| | | map.put("enable", 1); |
| | | map.put("isDel", 0); |
| | | Integer integer = baseMapper.selectCountByMap(map); |
| | | return ResultBody.ok().data(integer); |
| | | } |
| | |
| | | Long createUserId = CommonConstant.CREATE_USER_ID; |
| | | //创建人名称 |
| | | String createUserName = CommonConstant.CREATE_USER_NAME; |
| | | //销售服务人员 |
| | | SysUser sysUserSale = baseMapper.selectById(CommonConstant.SALE_USER_ID); |
| | | //运营服务人员 |
| | | SysUser sysUserOpration = baseMapper.selectById(CommonConstant.OPRATION_USER_ID); |
| | | //是否注册用户 |
| | | Boolean isReg = false; |
| | | //业务成功 |
| | |
| | | //业务失败提示信息 |
| | | String expMsg = ""; |
| | | //系统内置的注册医院和科室的组织数据 |
| | | Long organizationHos = CommonConstant.HOSPITAL_ORG_ID; |
| | | Long organizationDep = CommonConstant.DEPARTMENT_ORG_ID; |
| | | Long organizationHos = 0L; |
| | | Long organizationDep = 0L; |
| | | //检查判断是注册 还是添加用户,注册用户先走基本数据建设 医院/科室 |
| | | SysUserOrg sysUserOrgH = new SysUserOrg(); |
| | | SysUserOrg sysUserOrgD = new SysUserOrg(); |
| | |
| | | isReg = true; |
| | | if (CheckVerificationCode(ConstantSMS.REGISTER_SMS, userRegVo.getMobile(), userRegVo.getVerification())) { |
| | | userRegVo.setDoctorState(true); |
| | | //写医院数据 |
| | | SysHospital sysHospital = new SysHospital(); |
| | | sysHospital.setHospitalName(userRegVo.getHospitalName()); |
| | | sysHospital.setOrgId(organizationHos); |
| | | //注册的用户所在医院默认是试用状态 |
| | | sysHospital.setHospitalState(0); |
| | | sysHospital.setCreateUserId(createUserId); |
| | | sysHospital.setCreateUserName(createUserName); |
| | | |
| | | boolean h = hospitalService.save(sysHospital); |
| | | if (h) { |
| | | userRegVo.setHospitalId(sysHospital.getId()); |
| | | //保存科室数据 |
| | | SysDepartment sysDepartment = new SysDepartment(); |
| | | sysDepartment.setOrgId(organizationDep); |
| | | sysDepartment.setDepartmentName(userRegVo.getDepartmentName()); |
| | | sysDepartment.setSaleUserId(createUserId); |
| | | sysDepartment.setAccountsCount(1); |
| | | sysDepartment.setSaleUserName(createUserName); |
| | | sysDepartment.setSaleUserTel("0"); |
| | | sysDepartment.setServerUserId(createUserId); |
| | | sysDepartment.setServerUserTel("0"); |
| | | sysDepartment.setServerUserName(createUserName); |
| | | boolean d = departmentService.save(sysDepartment); |
| | | if (d) { |
| | | userRegVo.setDepartmentId(sysDepartment.getId()); |
| | | //自动充入系统指定的试用套餐 |
| | | if(!saveProductDetail(sysHospital.getId(),sysDepartment.getId(),sysHospital.getHospitalName(),sysDepartment.getDepartmentName())) |
| | | { |
| | | //写医院组织数据 |
| | | SysOrganization sysOrganizationH = new SysOrganization(); |
| | | sysOrganizationH.setOrgLevel(1); |
| | | sysOrganizationH.setOrgAttr(1); |
| | | sysOrganizationH.setOrgParentId(CommonConstant.ORG_PARENT_ID); |
| | | sysOrganizationH.setOrgName(userRegVo.getHospitalName()); |
| | | sysOrganizationH.setCreateUserId(createUserId); |
| | | sysOrganizationH.setCreateUserName(createUserName); |
| | | if (organizationService.save(sysOrganizationH)) { |
| | | //写科室组织数据 |
| | | SysOrganization sysOrganizationD = new SysOrganization(); |
| | | sysOrganizationD.setOrgLevel(2); |
| | | sysOrganizationD.setOrgAttr(2); |
| | | sysOrganizationD.setOrgParentId(sysOrganizationH.getId()); |
| | | sysOrganizationD.setOrgName(userRegVo.getDepartmentName()); |
| | | sysOrganizationD.setCreateUserId(createUserId); |
| | | sysOrganizationD.setCreateUserName(createUserName); |
| | | if (organizationService.save(sysOrganizationD)) { |
| | | //写医院组织数据 |
| | | SysHospital sysHospital = new SysHospital(); |
| | | sysHospital.setHospitalName(userRegVo.getHospitalName()); |
| | | sysHospital.setOrgId(sysOrganizationH.getId()); |
| | | //注册的用户所在医院默认是试用状态 |
| | | sysHospital.setHospitalState(0); |
| | | sysHospital.setCreateUserId(createUserId); |
| | | sysHospital.setCreateUserName(createUserName); |
| | | if (hospitalService.save(sysHospital)) { |
| | | userRegVo.setHospitalId(sysHospital.getId()); |
| | | //保存科室数据 |
| | | SysDepartment sysDepartment = new SysDepartment(); |
| | | sysDepartment.setOrgId(sysOrganizationD.getId()); |
| | | sysDepartment.setDepartmentName(userRegVo.getDepartmentName()); |
| | | sysDepartment.setSaleUserId(sysUserSale.getId()); |
| | | sysDepartment.setAccountsCount(1); |
| | | sysDepartment.setSaleUserName(sysUserSale.getNickname()); |
| | | sysDepartment.setSaleUserTel(sysUserSale.getMobile()); |
| | | sysDepartment.setServerUserId(sysUserOpration.getId()); |
| | | sysDepartment.setServerUserTel(sysUserOpration.getMobile()); |
| | | sysDepartment.setServerUserName(sysUserOpration.getNickname()); |
| | | sysDepartment.setCreateUserId(createUserId); |
| | | sysDepartment.setCreateUserName(createUserName); |
| | | if (departmentService.save(sysDepartment)) { |
| | | userRegVo.setDepartmentId(sysDepartment.getId()); |
| | | //自动充入系统指定的试用套餐 |
| | | if (!saveProductDetail(sysHospital.getId(), |
| | | sysDepartment.getId(), |
| | | sysHospital.getHospitalName(), |
| | | sysDepartment.getDepartmentName())) { |
| | | isSuccess = false; |
| | | expMsg = "试用套餐充值失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "科室数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "套餐充值失败"; |
| | | expMsg = "医院数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "科室数据写入失败"; |
| | | expMsg = "科室组织数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "医院数据写入失败"; |
| | | expMsg = "医院组织数据写入失败"; |
| | | } |
| | | } else { |
| | | return ResultBody.failed("无效的验证码"); |
| | |
| | | |
| | | //业务执行中途出错 |
| | | if (isReg && !isSuccess) { |
| | | //注册过程失败 |
| | | return ResultBody.failed(expMsg); |
| | | } |
| | | if (!isReg && departmetAccountsCount(userRegVo.getDepartmentId()) < 1) { |
| | |
| | | if (StringUtils.isNotBlank(userRegVo.getDoctorRank())) { |
| | | //检查医生职务是否存在 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("dictionariesName", userRegVo.getDoctorRank()); |
| | | selectMap.put("dictionariesNameAll", userRegVo.getDoctorRank().trim()); |
| | | List<SysDictionaries> dictionariesList = sysDictionariesService.findAll(selectMap); |
| | | boolean dicBool = false; |
| | | if (dictionariesList.size() > 0) { |
| | | for (int i = dictionariesList.size() - 1; i >= 0; i--) { |
| | | if (dictionariesList.get(i).getDictionariesName().equals(userRegVo.getDoctorRank())) { |
| | | if (dictionariesList.get(i).getDictionariesName().trim().equals(userRegVo.getDoctorRank().trim())) { |
| | | userRegVo.setDoctorRankId(dictionariesList.get(i).getId()); |
| | | dicBool = true; |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | } |
| | | else { |
| | | //创建字典数据 |
| | | sysDictionaries.setDictionariesClassId(DictionariesConstants.DOCTOR_RANK); |
| | | //将名称汉字转为拼音 |
| | |
| | | sysDoctor.setDoctorState(!isReg); |
| | | sysDoctor.setDoctorTel(userRegVo.getMobile()); |
| | | sysDoctor.setDoctorName(userRegVo.getNickname()); |
| | | sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysDoctor.setServerUserId(isReg ? sysUserSale.getId() : sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg ? sysUserSale.getNickname() : sysUserd.getUsername()); |
| | | sysDoctor.setIsAdminUser(false); |
| | | sysDoctor.setDoctorCcie(userRegVo.getDoctorCcie()); |
| | | sysDoctor.setEnabled(true); |
| | | if (sysDoctorMapper.insert(sysDoctor) == 1) { |
| | | //非自主注册的 返回信息带密码 |
| | |
| | | |
| | | /** |
| | | * feign客户端调用写入试用套餐 |
| | | * |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @param hospitalName |
| | | * @param departmentName |
| | | * @return |
| | | */ |
| | | private boolean saveProductDetail(Long hospitalId,Long departmentId,String hospitalName,String departmentName) |
| | | { |
| | | Map<String,Object> params=new HashMap<String,Object>(); |
| | | params.put("hospitalId",hospitalId); |
| | | params.put("departmentId",departmentId); |
| | | params.put("hospitalName",hospitalName); |
| | | params.put("departmentName",departmentName); |
| | | ResultBody resultBody= productOrderService.saveProductDetail(params); |
| | | return (boolean)resultBody.getData(); |
| | | private boolean saveProductDetail(Long hospitalId, Long departmentId, String hospitalName, String departmentName) { |
| | | Map<String, Object> params = new HashMap<String, Object>(); |
| | | params.put("hospitalId", hospitalId); |
| | | params.put("departmentId", departmentId); |
| | | params.put("hospitalName", hospitalName); |
| | | params.put("departmentName", departmentName); |
| | | ResultBody resultBody = productOrderService.saveProductDetail(params); |
| | | return (boolean) resultBody.getData(); |
| | | } |
| | | |
| | | /** |
| | | * 获取医院科室下的所有H端有效的医生 |
| | | * |
| | |
| | | } else { |
| | | listVoList = baseMapper.hospitalDoctorList(hospitalId, departmentId, CommonConstant.HOSPITAL_DOCTOR_ID, CommonConstant.HOSPITAL_ADMIN_ID); |
| | | } |
| | | listVoList.sort((e1,e2)-> |
| | | e2.getUserId().compareTo(e1.getUserId()) |
| | | ); |
| | | return ResultBody.ok().data(listVoList); |
| | | } else { |
| | | return ResultBody.failed("医院数据有误"); |
| | |
| | | if (sysDepartment == null) { |
| | | return 0; |
| | | } else { |
| | | Long sysHospitalId=HospitalIdByDepartmentId(depatmentId); |
| | | if (sysHospitalId>0) { |
| | | Long sysHospitalId = HospitalIdByDepartmentId(depatmentId); |
| | | if (sysHospitalId > 0) { |
| | | List<HospitalDoctorListVo> hospitalDoctorListVos = baseMapper.hospitalDoctorList(sysHospitalId, depatmentId, CommonConstant.HOSPITAL_DOCTOR_ID, CommonConstant.HOSPITAL_ADMIN_ID); |
| | | if (hospitalDoctorListVos != null) { |
| | | int doctorCount = hospitalDoctorListVos.size(); |
| | | int accountCount = sysDepartment.getAccountsCount().intValue(); |
| | | int liveCount=accountCount - doctorCount; |
| | | int liveCount = accountCount - doctorCount; |
| | | return liveCount; |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | QueryWrapper<SysDoctor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id", id); |
| | | List<SysDoctor> sysDoctors = sysDoctorMapper.selectList(queryWrapper); |
| | | if(!sysDoctors.isEmpty()){ |
| | | sysDoctors.forEach(e->{ |
| | | if (!sysDoctors.isEmpty()) { |
| | | sysDoctors.forEach(e -> { |
| | | e.setIsDel(true); |
| | | sysDoctorMapper.updateById(e); |
| | | }); |