| | |
| | | import com.kidgrow.common.utils.AesUtils; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.common.utils.Pinyin4jUtil; |
| | | import com.kidgrow.oprationcenter.feign.ProductOrderService; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.sms.feign.SmsChuangLanService; |
| | | import com.kidgrow.sms.model.ConstantSMS; |
| | |
| | | private SysUserRoleMapper sysUserRoleMapper; |
| | | @Autowired |
| | | private SysOrganizationMapper sysOrganizationMapper; |
| | | @Autowired |
| | | private ProductOrderService productOrderService; |
| | | |
| | | |
| | | @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; |
| | |
| | | organizationService.deleteByUserId(id); |
| | | //删除医生数据 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("userId", id); |
| | | params.put("user_id", id); |
| | | sysDoctorMapper.deleteByMap(params); |
| | | //删除用户数据 |
| | | return baseMapper.deleteById(id) > 0; |
| | |
| | | |
| | | @Override |
| | | public ResultBody findCountByMap(Map<String, Object> map) { |
| | | map.put("enable", 1); |
| | | map.put("is_del", 0); |
| | | Integer integer = baseMapper.selectCountByMap(map); |
| | | return ResultBody.ok().data(integer); |
| | | } |
| | |
| | | sysDepartment.setServerUserTel("0"); |
| | | sysDepartment.setServerUserName(createUserName); |
| | | boolean d = departmentService.save(sysDepartment); |
| | | if (!d) { |
| | | if (d) { |
| | | userRegVo.setDepartmentId(sysDepartment.getId()); |
| | | //自动充入系统指定的试用套餐 |
| | | if (!saveProductDetail(sysHospital.getId(), sysDepartment.getId(), sysHospital.getHospitalName(), sysDepartment.getDepartmentName())) { |
| | | isSuccess = false; |
| | | expMsg = "套餐充值失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "科室数据写入失败"; |
| | | } else { |
| | | userRegVo.setDepartmentId(sysDepartment.getId()); |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | |
| | | } |
| | | } |
| | | |
| | | //业务执行中途出错 手动撤回数据 |
| | | //业务执行中途出错 |
| | | if (isReg && !isSuccess) { |
| | | RollBackData(userRegVo.getHospitalId(), |
| | | userRegVo.getDepartmentId(), 0L, 0L, |
| | | 0L, 0L, 0L); |
| | | //注册过程失败 |
| | | return ResultBody.failed(expMsg); |
| | | } |
| | | if (!isReg && departmetAccountsCount(userRegVo.getDepartmentId()) < 1) { |
| | |
| | | //添加用户数据 如果没有输入密码,将会创建一个默认密码返回 |
| | | String defaultPassWord = ""; |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUsername(userRegVo.getUsername()); |
| | | sysUser.setUsername(userRegVo.getMobile()); |
| | | sysUser.setMobile(userRegVo.getMobile()); |
| | | if (StringUtils.isBlank(userRegVo.getPassword())) { |
| | | defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | |
| | | sysUser.setDefaultAuth(false); |
| | | sysUser.setOpenId(userRegVo.getOpenId()); |
| | | sysUser.setDel(false); |
| | | sysUser.setTenantId("hospital"); |
| | | sysUser.setTenantId(CommonConstant.H_TENANT); |
| | | boolean u = this.save(sysUser); |
| | | SysRoleUser sysRoleUser = new SysRoleUser(); |
| | | if (u) { |
| | |
| | | sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysDoctor.setIsAdminUser(false); |
| | | sysDoctor.setEnabled(!isReg); |
| | | sysDoctor.setDoctorCcie(userRegVo.getDoctorCcie()); |
| | | sysDoctor.setEnabled(true); |
| | | if (sysDoctorMapper.insert(sysDoctor) == 1) { |
| | | //非自主注册的 返回信息带密码 |
| | | if (!isReg) { |
| | |
| | | } |
| | | /***返回数据***/ |
| | | if (!isSuccess) { |
| | | //撤回数据 |
| | | RollBackData(0L, |
| | | 0L, sysUser.getId(), sysUserOrgH.getId(), |
| | | sysUserOrgH.getId(), sysDictionaries.getId(), |
| | | sysDoctor.getId()); |
| | | return ResultBody.failed(expMsg); |
| | | } else { |
| | | return ResultBody.ok().data(sysUser); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 手动撤回数据,需要撤回那个,给那个id传值,不需要的传0 |
| | | * feign客户端调用写入试用套餐 |
| | | * |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @param userId |
| | | * @param userOrgIdH |
| | | * @param userOrgIdD |
| | | * @param dicId |
| | | * @param doctorId |
| | | * @param hospitalName |
| | | * @param departmentName |
| | | * @return |
| | | */ |
| | | private void RollBackData(Long hospitalId, Long departmentId, |
| | | Long userId, Long userOrgIdH, Long userOrgIdD, |
| | | Long dicId, Long doctorId) { |
| | | if (hospitalId > 0) { |
| | | hospitalService.removeById(hospitalId); |
| | | } |
| | | if (departmentId > 0) { |
| | | departmentService.removeById(departmentId); |
| | | } |
| | | if (userId > 0) { |
| | | baseMapper.deleteById(userId); |
| | | sysUserRoleMapper.deleteById(userId); |
| | | } |
| | | if (userOrgIdH > 0) { |
| | | sysUserRoleMapper.deleteById(userOrgIdH); |
| | | } |
| | | if (userOrgIdD > 0) { |
| | | sysUserRoleMapper.deleteById(userOrgIdD); |
| | | } |
| | | if (dicId > 0) { |
| | | sysDictionariesService.removeById(dicId); |
| | | } |
| | | if (doctorId > 0) { |
| | | sysDoctorMapper.deleteById(doctorId); |
| | | } |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("mobile", phone); |
| | | selectMap.put("is_del", 0); |
| | | selectMap.put("tenant_id", "hospital"); |
| | | List<SysUser> sysUsers = baseMapper.selectByMap(selectMap); |
| | | return (sysUsers.size() > 0); |
| | | } |
| | |
| | | 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(); |
| | | return (accountCount - doctorCount); |
| | | int accountCount = sysDepartment.getAccountsCount().intValue(); |
| | | int liveCount = accountCount - doctorCount; |
| | | return liveCount; |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | } |
| | | return hospitalId; |
| | | } |
| | | /** |
| | | * 根据部门的id获取所属医院id |
| | | * |
| | | * @return |
| | | */ |
| | | // public List<Long> DepartmentIdListByhospitalId(Long hospitalId) { |
| | | // List<Long> hospitalIdList =new ArrayList<Long>(); |
| | | // SysHospital sysHospital = hospitalService.getById(hospitalId); |
| | | // if (sysHospital != null) { |
| | | // //先获取医院的组织数据 |
| | | // SysOrganization sysOrganization = sysOrganizationMapper.selectById(sysHospital.getOrgId()); |
| | | // if (sysOrganization != null) { |
| | | // //根据组织id获取下级科室组织id |
| | | // Map<String, Object> selectMap = new HashMap<>(); |
| | | // selectMap.put("org_parent_id", sysOrganization.getId()); |
| | | // List<SysOrganization> sysDepartmentList = sysOrganizationMapper.selectByMap(selectMap); |
| | | // if (sysDepartmentList != null && sysDepartmentList.size() > 0) { |
| | | // //hospitalIdList=sysDepartmentList.stream().sorted(Comparator.comparing(SysOrganization::getCreateTime).reversed()).map(SysOrganization::getId).collect(Collectors.toList()); |
| | | // sysDepartmentList.stream().sorted(Comparator.comparing(SysOrganization::getCreateTime).reversed()).map(SysOrganization::getId).collect(Collectors.toList()).get(0); |
| | | // } |
| | | // } |
| | | // } |
| | | // return hospitalIdList; |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 检查用户登录名是否已经注册 true存在 false不存在 |
| | |
| | | String encode = passwordEncoder.encode(password); |
| | | return ResultBody.ok().data(encode); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteNoContact(Long id) { |
| | | //删除医生数据 |
| | | QueryWrapper<SysDoctor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id", id); |
| | | List<SysDoctor> sysDoctors = sysDoctorMapper.selectList(queryWrapper); |
| | | if (!sysDoctors.isEmpty()) { |
| | | sysDoctors.forEach(e -> { |
| | | e.setIsDel(true); |
| | | sysDoctorMapper.updateById(e); |
| | | }); |
| | | } |
| | | //删除用户数据 |
| | | return baseMapper.deleteById(id) > 0; |
| | | } |
| | | } |