| | |
| | | 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 SysRoleMapper sysRoleMapper; |
| | | @Autowired |
| | | 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 |
| | |
| | | |
| | | 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); |
| | |
| | | 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) { |
| | |
| | | } |
| | | } 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()); |
| | | sysDictionaries.setCreateUserId(createUserId); |
| | | sysDictionaries.setCreateUserName(createUserName); |
| | | dicBool = sysDictionariesService.save(sysDictionaries); |
| | | if (dicBool) { |
| | | userRegVo.setDoctorRankId(sysDictionaries.getId()); |
| | | } |
| | | } |
| | | |
| | | if (dicBool) { |
| | | userRegVo.setDoctorRankId(sysDictionaries.getId()); |
| | | //写用户组织关系表 |
| | | List<SysUserOrg> sysUserOrgList = new ArrayList<SysUserOrg>(); |
| | | |
| | | 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(CommonConstant.H_DOCTOR_TYPE); |
| | | sysDoctor.setCreateUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setCreateUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | if (isReg) { |
| | | sysDoctor.setDoctorState(false); |
| | | } |
| | | else |
| | | { |
| | | sysDoctor.setDoctorState(true); |
| | | } |
| | | sysDoctor.setDoctorState(!isReg); |
| | | sysDoctor.setDoctorTel(userRegVo.getMobile()); |
| | | sysDoctor.setDoctorName(userRegVo.getNickname()); |
| | | sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId()); |
| | | sysDoctor.setServerUserName(isReg ? createUserName : sysUserd.getUsername()); |
| | | sysDoctor.setIsAdminUser(false); |
| | | 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(); |
| | | } |
| | | |
| | | /** |
| | | * 获取医院科室下的所有H端有效的医生 |
| | | * |
| | |
| | | * @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 { |
| | |
| | | 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 { |
| | | 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().intValue(); |
| | | int liveCount=accountCount - doctorCount; |
| | | return liveCount; |
| | | } 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; |
| | | } |
| | | |
| | | /** |
| | | * 检查用户登录名是否已经注册 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; |
| | | } |
| | | } |