| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.constant.DictionariesConstants; |
| | |
| | | private SysRoleMapper sysRoleMapper; |
| | | @Autowired |
| | | private SysUserRoleMapper sysUserRoleMapper; |
| | | @Autowired |
| | | private SysOrganizationMapper sysOrganizationMapper; |
| | | |
| | | @Override |
| | | public LoginAppUser findByUsername(String username) { |
| | | SysUser sysUser = this.selectByUsername(username); |
| | |
| | | |
| | | SysUser sysUser = baseMapper.selectById(id); |
| | | if (StrUtil.isNotBlank(oldPassword)) { |
| | | oldPassword=AesUtils.desEncrypt(oldPassword).trim(); |
| | | oldPassword = AesUtils.desEncrypt(oldPassword).trim(); |
| | | if (!passwordEncoder.matches(oldPassword, sysUser.getPassword())) { |
| | | return ResultBody.failed("旧密码错误!"); |
| | | } |
| | | } |
| | | if (StrUtil.isBlank(newPassword)) { |
| | | newPassword = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | }else { |
| | | newPassword=AesUtils.desEncrypt(newPassword).trim(); |
| | | } else { |
| | | newPassword = AesUtils.desEncrypt(newPassword).trim(); |
| | | } |
| | | SysUser user = new SysUser(); |
| | | user.setId(id); |
| | | user.setPassword(passwordEncoder.encode(newPassword)); |
| | | if (isdefault) { |
| | | user.setDefaultAuth(true); |
| | | }else { |
| | | } else { |
| | | user.setDefaultAuth(false); |
| | | } |
| | | baseMapper.updateById(user); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResultBody updateUserTel(Map<String, Object> params) throws Exception { |
| | | public ResultBody updateUserTel(Map<String, Object> params) throws Exception { |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | String oldTel = MapUtils.getString(params, "oldTel"); |
| | | String newTel = AesUtils.desEncrypt(MapUtils.getString(params, "newTel")).trim(); |
| | |
| | | } else { |
| | | return ResultBody.failed("手机号修改失败!"); |
| | | } |
| | | }else { |
| | | } else { |
| | | return ResultBody.failed("用户信息验证失败,请提供正确的手机号和密码!"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.failed("无效的验证码"); |
| | | } |
| | | } else { |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public ResultBody saveOrUpdateUser(SysUser sysUser) { |
| | | String defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | if (sysUser.getId() == null) { |
| | | if (StringUtils.isBlank(sysUser.getType())) { |
| | | sysUser.setType(UserType.BACKEND.name()); |
| | | } |
| | | String defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | sysUser.setPassword(passwordEncoder.encode(defaultPassWord)); |
| | | sysUser.setEnabled(Boolean.TRUE); |
| | | } |
| | |
| | | roleUserService.saveBatch(roleUsers); |
| | | } |
| | | } |
| | | sysUser.setPassword(defaultPassWord); |
| | | return result ? ResultBody.ok().data(sysUser).msg("操作成功") : ResultBody.failed("操作失败"); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | |
| | | if (newPass == null || "".equals(newPass.trim())) { |
| | | return ResultBody.failed("请输入正确的密码"); |
| | | } |
| | | phone= AesUtils.desEncrypt(phone.trim()); |
| | | verificationCode= AesUtils.desEncrypt(verificationCode.trim()); |
| | | newPass= AesUtils.desEncrypt(newPass.trim()); |
| | | phone = AesUtils.desEncrypt(phone.trim()); |
| | | verificationCode = AesUtils.desEncrypt(verificationCode.trim()); |
| | | newPass = AesUtils.desEncrypt(newPass.trim()); |
| | | if (CheckVerificationCode(ConstantSMS.PASSWORD_SMS, phone, verificationCode)) { |
| | | //查询表 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public ResultBody doctorUserReg(UserRegVo userRegVo, SysUser sysUserd) throws Exception { |
| | | if(sysUserd.getId()==null){ |
| | | if (sysUserd.getId() == null) { |
| | | sysUserd = this.baseMapper.selectById(userRegVo.getUserId()); |
| | | } |
| | | userRegVo.setPassword(AesUtils.desEncrypt(userRegVo.getPassword()).trim()); |
| | |
| | | SysHospital sysHospital = new SysHospital(); |
| | | sysHospital.setHospitalName(userRegVo.getHospitalName()); |
| | | sysHospital.setOrgId(organizationHos); |
| | | //注册的用户所在医院默认是试用状态 |
| | | sysHospital.setHospitalState(0); |
| | | sysHospital.setCreateUserId(createUserId); |
| | | sysHospital.setCreateUserName(createUserName); |
| | |
| | | userRegVo.setHospitalId(sysHospital.getId()); |
| | | //保存科室数据 |
| | | SysDepartment sysDepartment = new SysDepartment(); |
| | | sysDepartment.setHospitalId(sysHospital.getId()); |
| | | sysDepartment.setOrgId(organizationDep); |
| | | sysDepartment.setDepartmentName(userRegVo.getDepartmentName()); |
| | | sysDepartment.setSaleUserId(createUserId); |
| | |
| | | } |
| | | } else { |
| | | //创建字典数据 |
| | | sysDictionaries.setDictionariesKey(DictionariesConstants.DOCTOR_RANK); |
| | | sysDictionaries.setDictionariesClassId(DictionariesConstants.DOCTOR_RANK_ID.toString()); |
| | | sysDictionaries.setDictionariesClassId(DictionariesConstants.DOCTOR_RANK); |
| | | //将名称汉字转为拼音 |
| | | sysDictionaries.setDictionariesKey(Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(userRegVo.getDoctorRank(), true))); |
| | | sysDictionaries.setDictionariesName(userRegVo.getDoctorRank()); |
| | |
| | | |
| | | sysUserOrgH.setUserId(sysUser.getId()); |
| | | sysUserOrgH.setOrgId(organizationHos); |
| | | sysUserOrgH.setFromLevel(CommonConstant.SYSTEM_ORG_HOS_LEVEL); |
| | | sysUserOrgH.setFromId(userRegVo.getHospitalId()); |
| | | sysUserOrgH.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysUserOrgH.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysUserOrgList.add(sysUserOrgH); |
| | | |
| | | sysUserOrgD.setUserId(sysUser.getId()); |
| | | sysUserOrgD.setOrgId(organizationDep); |
| | | sysUserOrgD.setFromId(userRegVo.getDepartmentId()); |
| | | sysUserOrgD.setFromLevel(CommonConstant.SYSTEM_ORG_DEP_LEVEL); |
| | | sysUserOrgD.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysUserOrgD.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysUserOrgList.add(sysUserOrgD); |
| | |
| | | sysDoctor.setDepartmentName(userRegVo.getDepartmentName()); |
| | | sysDoctor.setDoctorRank(userRegVo.getDoctorRank()); |
| | | sysDoctor.setDoctorRankId(userRegVo.getDoctorRankId()); |
| | | sysDoctor.setDoctorType(1); |
| | | sysDoctor.setDoctorType(CommonConstant.H_DOCTOR_TYPE); |
| | | sysDoctor.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | if (isReg) { |
| | | sysDoctor.setDoctorState(false); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | sysDoctor.setDoctorState(true); |
| | | } |
| | | sysDoctor.setDoctorTel(userRegVo.getMobile()); |
| | |
| | | sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysDoctor.setIsAdminUser(false); |
| | | sysDoctor.setEnabled(false); |
| | | sysDoctor.setEnabled(!isReg); |
| | | if (sysDoctorMapper.insert(sysDoctor) == 1) { |
| | | //非自主注册的 返回信息带密码 |
| | | if (!isReg) { |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody hospitalDoctorList(Long hospitalId, Long departmentId,Boolean isIncluddel) { |
| | | public ResultBody hospitalDoctorList(Long hospitalId, Long departmentId, Boolean isIncluddel) { |
| | | if (hospitalId > 0 && departmentId > 0) { |
| | | List<HospitalDoctorListVo> listVoList; |
| | | if(isIncluddel){ |
| | | listVoList= baseMapper.hospitalDoctorListAndDel(hospitalId, departmentId,CommonConstant.HOSPITAL_DOCTOR_ID,CommonConstant.HOSPITAL_ADMIN_ID); |
| | | }else { |
| | | listVoList=baseMapper.hospitalDoctorList(hospitalId, departmentId,CommonConstant.HOSPITAL_DOCTOR_ID,CommonConstant.HOSPITAL_ADMIN_ID); |
| | | if (isIncluddel) { |
| | | listVoList = baseMapper.hospitalDoctorListAndDel(hospitalId, departmentId, CommonConstant.HOSPITAL_DOCTOR_ID, CommonConstant.HOSPITAL_ADMIN_ID); |
| | | } else { |
| | | listVoList = baseMapper.hospitalDoctorList(hospitalId, departmentId, CommonConstant.HOSPITAL_DOCTOR_ID, CommonConstant.HOSPITAL_ADMIN_ID); |
| | | } |
| | | return ResultBody.ok().data(listVoList); |
| | | } else { |
| | |
| | | if (sysDepartment == null) { |
| | | return 0; |
| | | } else { |
| | | List<HospitalDoctorListVo> hospitalDoctorListVos = baseMapper.hospitalDoctorList(sysDepartment.getHospitalId(), depatmentId, CommonConstant.HOSPITAL_DOCTOR_ID, CommonConstant.HOSPITAL_ADMIN_ID); |
| | | if (hospitalDoctorListVos != null) { |
| | | int doctorCount = hospitalDoctorListVos.size(); |
| | | int accountCount = sysDepartment.getAccountsCount(); |
| | | return (accountCount - doctorCount); |
| | | } else { |
| | | 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); |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return 0; |
| | | } |
| | | } |
| | | } |
| | | // private Integer departmetAccountsCount(Long depatmentId) { |
| | | // SysDepartment sysDepartment = departmentService.getById(depatmentId); |
| | | // if (sysDepartment == null) { |
| | | // return 0; |
| | | // } else { |
| | | // Map<String, Object> selectMap = new HashMap<>(); |
| | | // selectMap.put("department_id", depatmentId); |
| | | // selectMap.put("enabled", 1); |
| | | // List<SysDoctor> sysDoctorList = sysDoctorMapper.selectByMap(selectMap); |
| | | // if (sysDoctorList != null) { |
| | | // int doctorCount = sysDoctorList.size(); |
| | | // int accountCount = sysDepartment.getAccountsCount(); |
| | | // return (accountCount - doctorCount); |
| | | // } else { |
| | | // return 0; |
| | | |
| | | /** |
| | | * 根据部门的id获取所属医院id |
| | | * |
| | | * @return |
| | | */ |
| | | public Long HospitalIdByDepartmentId(Long departmentId) { |
| | | Long hospitalId = -1L; |
| | | SysDepartment sysDepartment = departmentService.getById(departmentId); |
| | | if (sysDepartment != null) { |
| | | //先获取科室的组织数据 |
| | | SysOrganization sysOrganization = sysOrganizationMapper.selectById(sysDepartment.getOrgId()); |
| | | if (sysOrganization != null) { |
| | | //获取上级组织id |
| | | sysOrganization = sysOrganizationMapper.selectById(sysOrganization.getOrgParentId()); |
| | | if (sysOrganization != null) { |
| | | //根据组织id获取上级医院id |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("org_id", sysOrganization.getId()); |
| | | List<SysHospital> sysHospitalList = hospitalService.listByMap(selectMap); |
| | | if (sysHospitalList != null && sysHospitalList.size() > 0) { |
| | | //取第一个 |
| | | hospitalId = sysHospitalList.get(0).getId(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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不存在 |
| | |
| | | |
| | | /** |
| | | * 检查手机号是注册用户还是正式用户 |
| | | * |
| | | * @param userTel |
| | | * @return |
| | | */ |
| | | public ResultBody isRegUser(String userTel) |
| | | { |
| | | public ResultBody isRegUser(String userTel) { |
| | | if (StringUtils.isNotBlank(userTel)) { |
| | | List<SysUser> users = baseMapper.selectList( |
| | | new QueryWrapper<SysUser>().eq("username", userTel) |
| | | ); |
| | | if (users != null&&users.size()==1) { |
| | | SysUser sysUser=users.get(0); |
| | | if (sysUser.getCreateUserId()==CommonConstant.CREATE_USER_ID&&sysUser.getCreateUserName().equals(CommonConstant.CREATE_USER_NAME)) { |
| | | if (users != null && users.size() == 1) { |
| | | SysUser sysUser = users.get(0); |
| | | if (sysUser.getCreateUserId() == CommonConstant.CREATE_USER_ID && sysUser.getCreateUserName().equals(CommonConstant.CREATE_USER_NAME)) { |
| | | return ResultBody.ok().data(true); |
| | | } |
| | | return ResultBody.ok().data(false); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.failed("用户数据有误!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.failed("必要参数有误!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody jiaMipython(String password) { |
| | | 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; |
| | | } |
| | | } |