| | |
| | | } |
| | | //医院信息 只有H端要返回的信息 |
| | | if (sysUser.getTenantId().toLowerCase().equals(CommonConstant.H_TENANT.toLowerCase())) { |
| | | DoctorUserAll doctorUserAllVo=baseMapper.findDoctorUserAllData(sysUser.getId()); |
| | | DoctorUserAll doctorUserAllVo = baseMapper.findDoctorUserAllData(sysUser.getId()); |
| | | loginAppUser.setDoctorUserAllVO(doctorUserAllVo); |
| | | } |
| | | } |
| | |
| | | |
| | | if (id > 0 && StringUtils.isNotBlank(oldTel) && StringUtils.isNotBlank(newTel) && StringUtils.isNotBlank(authCode) && StringUtils.isNotBlank(userPassword)) { |
| | | //检查验证码 |
| | | Object hget = redisUtils.hget(ConstantSMS.PHONE_SMS, newTel); |
| | | if (hget != null) { |
| | | JSONObject redisJson = JSON.parseObject(JSON.toJSONString(hget)); |
| | | Object verificationCodeObject = redisJson.get("verificationCode"); |
| | | //核对验证码 |
| | | if (authCode.equals(verificationCodeObject)) { |
| | | if (CheckVerificationCode(ConstantSMS.PHONE_SMS, newTel, authCode)) { |
| | | //查询手机号是否已经存在 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("mobile", newTel); |
| | | List<SysUser> sysUsersList = baseMapper.selectByMap(selectMap); |
| | | if (sysUsersList.size() > 0) { |
| | | return ResultBody.failed("该手机号已经存在!"); |
| | | } else { |
| | | //验证旧手机号和密码 |
| | | SysUser sysUser = baseMapper.selectById(id); |
| | | if (passwordEncoder.matches(userPassword, sysUser.getPassword()) && sysUser.getMobile().equals((oldTel))) { |
| | | Object date = redisJson.get("endTime"); |
| | | long time = DateUtils.parseDate(date.toString()).getTime(); |
| | | long timeNow = new Date().getTime(); |
| | | if (timeNow <= time) { |
| | | //查询手机号是否已经存在 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("mobile", newTel); |
| | | List<SysUser> sysUsersList = baseMapper.selectByMap(selectMap); |
| | | if (sysUsersList.size() > 0) { |
| | | return ResultBody.failed("该手机号已经存在!"); |
| | | } else { |
| | | //验证通过,修改手机号 |
| | | SysUser user = new SysUser(); |
| | | user.setId(id); |
| | | user.setMobile(newTel); |
| | | user.setUsername(newTel); |
| | | //修改doctor表 |
| | | com.kidgrow.usercenter.model.SysDoctor sysDoctorModel = findDoctorByUserId(user.getId()); |
| | | com.kidgrow.usercenter.model.SysDoctor newsysDoctorModel = new com.kidgrow.usercenter.model.SysDoctor(); |
| | | if (sysDoctorModel != null) { |
| | | //理论上只有一个,如果有多个 只取第一个 |
| | | newsysDoctorModel.setId(sysDoctorModel.getId()); |
| | | newsysDoctorModel.setDoctorTel(newTel); |
| | | sysDoctorMapper.updateById(newsysDoctorModel); |
| | | } |
| | | if (baseMapper.updateById(user) > 0) { |
| | | //将Redis清除 |
| | | redisUtils.hdel(ConstantSMS.PHONE_SMS, newTel); |
| | | return ResultBody.ok().msg("手机号修改成功!"); |
| | | } else { |
| | | return ResultBody.failed("手机号修改失败!"); |
| | | } |
| | | } |
| | | } else { |
| | | return ResultBody.failed("手机验证码已过期!"); |
| | | //验证通过,修改手机号 |
| | | SysUser user = new SysUser(); |
| | | user.setId(id); |
| | | user.setMobile(newTel); |
| | | user.setUsername(newTel); |
| | | //修改doctor表 |
| | | com.kidgrow.usercenter.model.SysDoctor sysDoctorModel = findDoctorByUserId(user.getId()); |
| | | com.kidgrow.usercenter.model.SysDoctor newsysDoctorModel = new com.kidgrow.usercenter.model.SysDoctor(); |
| | | if (sysDoctorModel != null) { |
| | | //理论上只有一个,如果有多个 只取第一个 |
| | | newsysDoctorModel.setId(sysDoctorModel.getId()); |
| | | newsysDoctorModel.setDoctorTel(newTel); |
| | | sysDoctorMapper.updateById(newsysDoctorModel); |
| | | } |
| | | } else { |
| | | if (baseMapper.updateById(user) > 0) { |
| | | //将Redis清除 |
| | | redisUtils.hdel(ConstantSMS.PHONE_SMS, newTel); |
| | | return ResultBody.ok().msg("手机号修改成功!"); |
| | | } else { |
| | | return ResultBody.failed("手机号修改失败!"); |
| | | } |
| | | }else { |
| | | return ResultBody.failed("用户信息验证失败,请提供正确的手机号和密码!"); |
| | | } |
| | | } else { |
| | | return ResultBody.failed("手机验证码有误!"); |
| | | } |
| | | } else { |
| | | //redis获取失败 |
| | | return ResultBody.failed("请重新获取验证码!"); |
| | | } |
| | | else |
| | | { |
| | | return ResultBody.failed("无效的验证码"); |
| | | } |
| | | } else { |
| | | return ResultBody.failed("必须参数有误!"); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 验证手机验证码 |
| | | * |
| | | * @param constantSMS |
| | | * @param phone |
| | | * @param inputCode |
| | | * @return |
| | | */ |
| | | public boolean CheckVerificationCode(String constantSMS, String phone, String inputCode) { |
| | | //获取缓存中的验证码对象 |
| | | Object hget = redisUtils.hget(constantSMS, phone); |
| | | if (hget != null) { |
| | | //序列化验证码 |
| | | JSONObject redisJson = JSON.parseObject(JSON.toJSONString(hget)); |
| | | //拿取验证码 |
| | | String verificationCodeObject = redisJson.get("verificationCode").toString(); |
| | | //核对验证码 |
| | | if (inputCode.equals(verificationCodeObject)) { |
| | | Object date = redisJson.get("endTime"); |
| | | long time = DateUtils.parseDate(date.toString()).getTime(); |
| | | Date dateNow = new Date(); |
| | | long timeNow = dateNow.getTime(); |
| | | return (timeNow <= time); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 通过手机号 修改密码 |
| | | * |
| | | * @param map |
| | |
| | | if (newPass == null || "".equals(newPass.trim())) { |
| | | return ResultBody.failed("请输入正确的密码"); |
| | | } |
| | | Object hget = redisUtils.hget(ConstantSMS.PASSWORD_SMS, map.get("phone").toString()); |
| | | if (hget != null) { |
| | | JSONObject redisJson = JSON.parseObject(JSON.toJSONString(hget)); |
| | | Object verificationCodeObject = redisJson.get("verificationCode"); |
| | | if (verificationCode.equals(verificationCodeObject)) { |
| | | Object date = redisJson.get("endTime"); |
| | | long time = DateUtils.parseDate(date.toString()).getTime(); |
| | | Date dateNow = new Date(); |
| | | long timeNow = dateNow.getTime(); |
| | | if (timeNow <= time) { |
| | | //查询表 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("mobile", phone); |
| | | List<SysUser> sysUsers = baseMapper.selectByMap(selectMap); |
| | | if (sysUsers.size() > 0) { |
| | | SysUser user = new SysUser(); |
| | | user.setId(sysUsers.get(0).getId()); |
| | | user.setPassword(passwordEncoder.encode(newPass)); |
| | | baseMapper.updateById(user); |
| | | //将Redis 清除 |
| | | redisUtils.hdel(ConstantSMS.PASSWORD_SMS, phone); |
| | | return ResultBody.ok(); |
| | | } else { |
| | | return ResultBody.failed("暂无该手机号信息"); |
| | | } |
| | | } else { |
| | | return ResultBody.failed("验证码超时"); |
| | | } |
| | | if (CheckVerificationCode(ConstantSMS.PASSWORD_SMS, map.get("phone").toString(), verificationCode)) { |
| | | //查询表 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("mobile", phone); |
| | | List<SysUser> sysUsers = baseMapper.selectByMap(selectMap); |
| | | if (sysUsers.size() > 0) { |
| | | SysUser user = new SysUser(); |
| | | user.setId(sysUsers.get(0).getId()); |
| | | user.setPassword(passwordEncoder.encode(newPass)); |
| | | baseMapper.updateById(user); |
| | | //将Redis 清除 |
| | | redisUtils.hdel(ConstantSMS.PASSWORD_SMS, phone); |
| | | return ResultBody.ok(); |
| | | } else { |
| | | return ResultBody.failed("验证码错误"); |
| | | return ResultBody.failed("暂无该手机号信息"); |
| | | } |
| | | } else { |
| | | return ResultBody.failed("该手机号没有验证码"); |
| | | return ResultBody.failed("无效的验证码"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * H端用户注册 管理员添加用户 |
| | | * |
| | | * @param userRegVo |
| | | * @return |
| | | */ |
| | |
| | | return ResultBody.failed("该手机号已经注册"); |
| | | } |
| | | //创建人id |
| | | Long createUserId=0L; |
| | | Long createUserId = 0L; |
| | | //创建人id |
| | | String createUserName="自动创建"; |
| | | String createUserName = "自动创建"; |
| | | //是否注册用户 |
| | | Boolean isReg=false; |
| | | Boolean isReg = false; |
| | | //业务成功 |
| | | Boolean isSuccess=true; |
| | | Boolean isSuccess = true; |
| | | //业务失败提示信息 |
| | | String expMsg=""; |
| | | //检查判断是注册 还是添加用户,注册用户先走基本数据建设 组织/医院/科室 |
| | | SysOrganization sysOrganizationHos=new SysOrganization(); |
| | | SysOrganization sysOrganizationDe=new SysOrganization(); |
| | | SysUserOrg sysUserOrgH=new SysUserOrg(); |
| | | SysUserOrg sysUserOrgD=new SysUserOrg(); |
| | | SysDictionaries sysDictionaries=new SysDictionaries(); |
| | | List<SysOrganization> sysOrganizationList=new ArrayList<SysOrganization>(); |
| | | SysDoctor sysDoctor=new SysDoctor(); |
| | | if (userRegVo.getHospitalId()==null) { |
| | | isReg=true; |
| | | userRegVo.setDoctorState(true); |
| | | //添加医院组织结构数据 |
| | | sysOrganizationHos.setOrgAttr(1); |
| | | sysOrganizationHos.setOrgLevel(1); |
| | | sysOrganizationHos.setOrgName(userRegVo.getHospitalName()); |
| | | sysOrganizationHos.setCreateUserName(createUserName); |
| | | sysOrganizationHos.setCreateUserId(createUserId); |
| | | Boolean H=organizationService.save(sysOrganizationHos); |
| | | if (H) { |
| | | sysOrganizationList.add(sysOrganizationHos); |
| | | //添加科室组织数据 |
| | | sysOrganizationDe.setOrgAttr(2); |
| | | sysOrganizationDe.setOrgLevel(2); |
| | | sysOrganizationDe.setOrgName(userRegVo.getDepartmentName()); |
| | | sysOrganizationDe.setCreateUserName(createUserName); |
| | | sysOrganizationDe.setCreateUserId(createUserId); |
| | | Boolean D=organizationService.save(sysOrganizationDe); |
| | | if (D) { |
| | | sysOrganizationList.add(sysOrganizationDe); |
| | | //写医院数据 |
| | | SysHospital sysHospital=new SysHospital(); |
| | | sysHospital.setHospitalName(userRegVo.getHospitalName()); |
| | | sysHospital.setOrgId(sysOrganizationHos.getId()); |
| | | sysHospital.setHospitalState(0); |
| | | sysHospital.setCreateUserId(createUserId); |
| | | sysHospital.setCreateUserName(createUserName); |
| | | String expMsg = ""; |
| | | //系统内置的注册医院和科室的组织数据 |
| | | Long organizationHos = CommonConstant.HOSPITAL_ORG_ID; |
| | | Long organizationDep = CommonConstant.DEPARTMENT_ORG_ID; |
| | | //检查判断是注册 还是添加用户,注册用户先走基本数据建设 医院/科室 |
| | | SysUserOrg sysUserOrgH = new SysUserOrg(); |
| | | SysUserOrg sysUserOrgD = new SysUserOrg(); |
| | | SysDictionaries sysDictionaries = new SysDictionaries(); |
| | | SysDoctor sysDoctor = new SysDoctor(); |
| | | if (userRegVo.getHospitalId() == null) { |
| | | 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.setHospitalId(sysHospital.getId()); |
| | | sysDepartment.setOrgId(sysOrganizationDe.getId()); |
| | | 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) { |
| | | isSuccess=false; |
| | | expMsg="科室数据写入失败"; |
| | | } |
| | | else |
| | | { |
| | | userRegVo.setDepartmentId(sysDepartment.getId()); |
| | | } |
| | | boolean h = hospitalService.save(sysHospital); |
| | | if (h) { |
| | | userRegVo.setHospitalId(sysHospital.getId()); |
| | | //保存科室数据 |
| | | SysDepartment sysDepartment = new SysDepartment(); |
| | | sysDepartment.setHospitalId(sysHospital.getId()); |
| | | 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) { |
| | | isSuccess = false; |
| | | expMsg = "科室数据写入失败"; |
| | | } else { |
| | | userRegVo.setDepartmentId(sysDepartment.getId()); |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="医院数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "医院数据写入失败"; |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="科室组织数据写入失败"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="医院组织数据写入失败"; |
| | | } else { |
| | | return ResultBody.failed("无效的验证码"); |
| | | } |
| | | } |
| | | |
| | | //业务执行中途出错 手动撤回数据 |
| | | if (isReg&&!isSuccess) { |
| | | RollBackData(sysOrganizationList,userRegVo.getHospitalId(), |
| | | userRegVo.getDepartmentId(),0L,0L, |
| | | 0L,0L, 0L); |
| | | if (isReg && !isSuccess) { |
| | | RollBackData(userRegVo.getHospitalId(), |
| | | userRegVo.getDepartmentId(), 0L, 0L, |
| | | 0L, 0L, 0L); |
| | | return ResultBody.failed(expMsg); |
| | | } |
| | | if (!isReg&&departmetAccountsCount(userRegVo.getDepartmentId())<1) { |
| | | if (!isReg && departmetAccountsCount(userRegVo.getDepartmentId()) < 1) { |
| | | return ResultBody.failed("当前科室可创建账户数量已满"); |
| | | } |
| | | //添加用户数据 如果没有输入密码,将会创建一个默认密码返回 |
| | | String defaultPassWord=""; |
| | | SysUser sysUser=new SysUser(); |
| | | String defaultPassWord = ""; |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUsername(userRegVo.getUsername()); |
| | | sysUser.setMobile(userRegVo.getMobile()); |
| | | if (StringUtils.isBlank(userRegVo.getPassword())) { |
| | | defaultPassWord=com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | defaultPassWord = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | sysUser.setPassword(passwordEncoder.encode(defaultPassWord)); |
| | | sysUser.setDefaultAuth(true); |
| | | sysUser.setDefaultAuth(false); |
| | | userRegVo.setPassword(defaultPassWord); |
| | | } |
| | | else { |
| | | } else { |
| | | sysUser.setPassword(passwordEncoder.encode(userRegVo.getPassword())); |
| | | sysUser.setDefaultAuth(false); |
| | | } |
| | |
| | | sysUser.setEnabled(true); |
| | | if (StringUtils.isNotBlank(userRegVo.getType())) { |
| | | sysUser.setType(userRegVo.getType()); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | sysUser.setType(UserType.DOCTOR.name()); |
| | | } |
| | | sysUser.setHAdminUser(false); |
| | | sysUser.setOpenId(userRegVo.getOpenId()); |
| | | sysUser.setDel(false); |
| | | sysUser.setTenantId("hospital"); |
| | | boolean u=this.save(sysUser); |
| | | SysRoleUser sysRoleUser=new SysRoleUser(); |
| | | if(u) |
| | | { |
| | | boolean u = this.save(sysUser); |
| | | SysRoleUser sysRoleUser = new SysRoleUser(); |
| | | if (u) { |
| | | //保存角色用户绑定信息 sys_role_user |
| | | Map<String,Object> map= new HashMap<>(); |
| | | map.put("code",CommonConstant.HOSPITAL_DOCTOR_CODE); |
| | | map.put("enabled",1); |
| | | map.put("is_del",0); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("code", CommonConstant.HOSPITAL_DOCTOR_CODE); |
| | | map.put("enabled", 1); |
| | | map.put("is_del", 0); |
| | | List<SysRole> sysRoles = sysRoleMapper.selectByMap(map); |
| | | if(sysRoles.size()>0){ |
| | | if (sysRoles.size() > 0) { |
| | | //保存角色和用户绑定关系数据 |
| | | SysRole sysRole = sysRoles.get(0); |
| | | sysRoleUser.setRoleId(sysRole.getId()); |
| | | sysRoleUser.setUserId(sysUser.getId()); |
| | | int insert = sysUserRoleMapper.insert(sysRoleUser); |
| | | if (insert>0) { |
| | | if (insert > 0) { |
| | | //写入职务数据 |
| | | if (StringUtils.isNotBlank(userRegVo.getDoctorRank())) { |
| | | //检查医生职务是否存在 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("dictionaries_name", userRegVo.getDoctorRank()); |
| | | List<SysDictionaries> dictionariesList=sysDictionariesService.findAll(selectMap); |
| | | if (dictionariesList.size()>0) { |
| | | selectMap.put("dictionariesName", userRegVo.getDoctorRank()); |
| | | 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())) { |
| | | userRegVo.setDoctorRankId(dictionariesList.get(i).getId()); |
| | | dicBool = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | //创建字典数据 |
| | | sysDictionaries.setDictionariesKey(DictionariesConstants.DOCTOR_RANK); |
| | | sysDictionaries.setDictionariesClassId(DictionariesConstants.DOCTOR_RANK_ID.toString()); |
| | | //将名称汉字转为拼音 |
| | | sysDictionaries.setDictionariesKey(Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(userRegVo.getDoctorRank(),true))); |
| | | sysDictionaries.setDictionariesKey(Pinyin4jUtil.makeStringByStringSet(Pinyin4jUtil.getPinyin(userRegVo.getDoctorRank(), true))); |
| | | sysDictionaries.setDictionariesName(userRegVo.getDoctorRank()); |
| | | sysDictionaries.setCreateUserId(createUserId); |
| | | sysDictionaries.setCreateUserName(createUserName); |
| | | boolean d=sysDictionariesService.save(sysDictionaries); |
| | | if (d) { |
| | | userRegVo.setDoctorRankId(sysDictionaries.getId()); |
| | | //写用户组织关系表 |
| | | List<SysUserOrg> sysUserOrgList=new ArrayList<SysUserOrg>(); |
| | | |
| | | sysUserOrgH.setUserId(sysUser.getId()); |
| | | sysUserOrgH.setOrgId(sysOrganizationHos.getId()); |
| | | sysUserOrgH.setCreateUserId(isReg?createUserId:sysUserd.getId()); |
| | | sysUserOrgH.setCreateUserName(isReg?createUserName:sysUserd.getUsername()); |
| | | sysUserOrgList.add(sysUserOrgH); |
| | | |
| | | sysUserOrgD.setUserId(sysUser.getId()); |
| | | sysUserOrgD.setOrgId(sysOrganizationHos.getId()); |
| | | sysUserOrgD.setCreateUserId(isReg?createUserId:sysUserd.getId()); |
| | | sysUserOrgD.setCreateUserName(isReg?createUserName:sysUserd.getUsername()); |
| | | sysUserOrgList.add(sysUserOrgD); |
| | | boolean uOrg=iSysUserOrgService.saveBatch(sysUserOrgList); |
| | | if (uOrg) { |
| | | //写入医生数据 |
| | | sysDoctor.setUserId(sysUser.getId()); |
| | | sysDoctor.setHospitalId(userRegVo.getHospitalId()); |
| | | sysDoctor.setHospitalName(userRegVo.getHospitalName()); |
| | | sysDoctor.setDepartmentId(userRegVo.getDepartmentId()); |
| | | sysDoctor.setDepartmentName(userRegVo.getDepartmentName()); |
| | | sysDoctor.setDoctorRank(userRegVo.getDoctorRank()); |
| | | sysDoctor.setDoctorRankId(userRegVo.getDoctorRankId()); |
| | | sysDoctor.setCreateUserId(isReg?createUserId:sysUserd.getId()); |
| | | sysDoctor.setCreateUserName(isReg?createUserName:sysUserd.getUsername()); |
| | | sysDoctor.setDoctorState(userRegVo.getDoctorState()); |
| | | sysDoctor.setDoctorTel(userRegVo.getMobile()); |
| | | sysDoctor.setDoctorName(userRegVo.getNickname()); |
| | | sysDoctor.setServerUserId(isReg?createUserId:sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg?createUserName:sysUserd.getUsername()); |
| | | if (sysDoctorMapper.insert(sysDoctor)==1) { |
| | | //非自主注册的 返回信息带密码 |
| | | if (!isReg) { |
| | | sysUser.setPassword(userRegVo.getPassword()); |
| | | } |
| | | else |
| | | { |
| | | sysUser.setPassword(""); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="医生数据写入失败"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="用户组织数据写入失败"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="职称数据写入失败"; |
| | | } |
| | | dicBool = sysDictionariesService.save(sysDictionaries); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | if (dicBool) { |
| | | userRegVo.setDoctorRankId(sysDictionaries.getId()); |
| | | //写用户组织关系表 |
| | | List<SysUserOrg> sysUserOrgList = new ArrayList<SysUserOrg>(); |
| | | |
| | | sysUserOrgH.setUserId(sysUser.getId()); |
| | | sysUserOrgH.setOrgId(organizationHos); |
| | | sysUserOrgH.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysUserOrgH.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysUserOrgList.add(sysUserOrgH); |
| | | |
| | | sysUserOrgD.setUserId(sysUser.getId()); |
| | | sysUserOrgD.setOrgId(organizationDep); |
| | | sysUserOrgD.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysUserOrgD.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysUserOrgList.add(sysUserOrgD); |
| | | boolean uOrg = iSysUserOrgService.saveBatch(sysUserOrgList); |
| | | if (uOrg) { |
| | | //写入医生数据 |
| | | sysDoctor.setUserId(sysUser.getId()); |
| | | sysDoctor.setHospitalId(userRegVo.getHospitalId()); |
| | | sysDoctor.setHospitalName(userRegVo.getHospitalName()); |
| | | sysDoctor.setDepartmentId(userRegVo.getDepartmentId()); |
| | | sysDoctor.setDepartmentName(userRegVo.getDepartmentName()); |
| | | sysDoctor.setDoctorRank(userRegVo.getDoctorRank()); |
| | | sysDoctor.setDoctorRankId(userRegVo.getDoctorRankId()); |
| | | sysDoctor.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysDoctor.setDoctorState(userRegVo.getDoctorState()); |
| | | sysDoctor.setDoctorTel(userRegVo.getMobile()); |
| | | sysDoctor.setDoctorName(userRegVo.getNickname()); |
| | | sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | if (sysDoctorMapper.insert(sysDoctor) == 1) { |
| | | //非自主注册的 返回信息带密码 |
| | | if (!isReg) { |
| | | sysUser.setPassword(userRegVo.getPassword()); |
| | | } else { |
| | | sysUser.setPassword(""); |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "医生数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "用户组织数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "职称数据写入失败"; |
| | | } |
| | | } else { |
| | | //没有职务数据 |
| | | isSuccess=false; |
| | | expMsg="没有职称数据"; |
| | | isSuccess = false; |
| | | expMsg = "没有职称数据"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "角色绑定数据写入失败"; |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="角色绑定数据写入失败"; |
| | | } |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "对应角色没有数据"; |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="对应角色没有数据"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | isSuccess=false; |
| | | expMsg="用户数据写入失败"; |
| | | } else { |
| | | isSuccess = false; |
| | | expMsg = "用户数据写入失败"; |
| | | } |
| | | /***返回数据***/ |
| | | if (!isSuccess) { |
| | | //撤回数据 |
| | | RollBackData(null,0L, |
| | | 0L,sysUser.getId(),sysUserOrgH.getId(), |
| | | sysUserOrgH.getId(),sysDictionaries.getId(), |
| | | RollBackData(0L, |
| | | 0L, sysUser.getId(), sysUserOrgH.getId(), |
| | | sysUserOrgH.getId(), sysDictionaries.getId(), |
| | | sysDoctor.getId()); |
| | | return ResultBody.failed(expMsg); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.ok().data(sysUser); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 手动撤回数据,需要撤回那个,给那个id传值,不需要的传0 |
| | | * @param sysOrganizationList |
| | | * |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @param userId |
| | |
| | | * @param dicId |
| | | * @param doctorId |
| | | */ |
| | | private void RollBackData(List<SysOrganization> sysOrganizationList,Long hospitalId,Long departmentId, |
| | | Long userId,Long userOrgIdH,Long userOrgIdD,Long dicId,Long doctorId) |
| | | { |
| | | if (sysOrganizationList!=null&&sysOrganizationList.size()>0) { |
| | | for (int i = 0; i < sysOrganizationList.size(); i++) { |
| | | organizationService.removeById(sysOrganizationList.get(i)); |
| | | } |
| | | } |
| | | if (hospitalId>0) { |
| | | 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) { |
| | | if (departmentId > 0) { |
| | | departmentService.removeById(departmentId); |
| | | } |
| | | if (userId>0) { |
| | | if (userId > 0) { |
| | | baseMapper.deleteById(userId); |
| | | sysUserRoleMapper.deleteById(userId); |
| | | } |
| | | if (userOrgIdH>0) { |
| | | if (userOrgIdH > 0) { |
| | | sysUserRoleMapper.deleteById(userOrgIdH); |
| | | } |
| | | if (userOrgIdD>0) { |
| | | if (userOrgIdD > 0) { |
| | | sysUserRoleMapper.deleteById(userOrgIdD); |
| | | } |
| | | if (dicId>0) { |
| | | if (dicId > 0) { |
| | | sysDictionariesService.removeById(dicId); |
| | | } |
| | | if (doctorId>0) { |
| | | if (doctorId > 0) { |
| | | sysDoctorMapper.deleteById(doctorId); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取医院科室下的所有有效的医生 |
| | | * |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody hospitalDoctorList(Long hospitalId, Long departmentId) { |
| | | if (hospitalId>0&&departmentId>0) { |
| | | List<HospitalDoctorListVo> listVoList=baseMapper.hospitalDoctorList(hospitalId,departmentId); |
| | | if (hospitalId > 0 && departmentId > 0) { |
| | | List<HospitalDoctorListVo> listVoList = baseMapper.hospitalDoctorList(hospitalId, departmentId); |
| | | return ResultBody.ok().data(listVoList); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.failed("医院数据有误"); |
| | | } |
| | | } |
| | |
| | | List<SysUser> sysUsers = baseMapper.selectByMap(selectMap); |
| | | return (sysUsers.size() > 0); |
| | | } |
| | | |
| | | /** |
| | | * 检查科室有效剩余账户数量 |
| | | * |
| | |
| | | SysDepartment sysDepartment = departmentService.getById(depatmentId); |
| | | if (sysDepartment == null) { |
| | | return 0; |
| | | } |
| | | else { |
| | | } else { |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("departmentId",depatmentId); |
| | | selectMap.put("enabled",1); |
| | | List<SysDoctor> sysDoctorList=sysDoctorMapper.selectByMap(selectMap); |
| | | selectMap.put("departmentId", 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 |
| | | { |
| | | int doctorCount = sysDoctorList.size(); |
| | | int accountCount = sysDepartment.getAccountsCount(); |
| | | return (accountCount - doctorCount); |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 检查用户登录名是否已经注册 true存在 false不存在 |
| | | * |