| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.model.TProjectTeam; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | |
| | | private TProjectTeamService projectTeamService; |
| | | @Autowired |
| | | private TProjectTeamStaffService projectTeamStaffService; |
| | | |
| | | @Autowired |
| | | private TClinicalTrialPointsService clinicalTrialPointsService; |
| | | @Autowired |
| | | private TExperimentDispatchParticipantsService experimentDispatchParticipantsService; |
| | | @Autowired |
| | | private TExperimentSchemePersonService experimentSchemePersonService; |
| | | @Autowired |
| | | private TNoticeService noticeService; |
| | | @Autowired |
| | | private TProjectProposalService projectProposalService; |
| | | @Autowired |
| | | private TQaProduceReportService qaProduceReportService; |
| | | @Autowired |
| | | private TQaTestItemService qaTestItemService; |
| | | @Autowired |
| | | private TResultWorkEvaluateService resultWorkEvaluateService; |
| | | @Autowired |
| | | private TSamplingRecordOperationService samplingRecordOperationService; |
| | | @Autowired |
| | | private TTestMethodConfirmSheetService testMethodConfirmSheetService; |
| | | @Autowired |
| | | private TTesterOtherTaskService testerOtherTaskService; |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | List<String> teamIds = staffs.stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | List<TProjectTeamStaff> teamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getTeamId, teamIds) |
| | | .eq(Objects.nonNull(roleId),TProjectTeamStaff::getRoleType,Integer.parseInt(roleId.toString()))); |
| | | LambdaQueryWrapper<TProjectTeamStaff> wrapper = new LambdaQueryWrapper<>(); |
| | | if(Objects.nonNull(roleId)){ |
| | | wrapper.eq(TProjectTeamStaff::getRoleType,Integer.parseInt(roleId.toString())); |
| | | } |
| | | wrapper.in(TProjectTeamStaff::getTeamId, teamIds); |
| | | List<TProjectTeamStaff> teamStaffs = projectTeamStaffService.list(wrapper); |
| | | List<Long> userIds = teamStaffs.stream().map(TProjectTeamStaff::getUserId).collect(Collectors.toList()); |
| | | |
| | | List<SysUser> list = userService.listByRole(userIds,nickName); |
| | |
| | | user.setCreateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("123456")); |
| | | user.setRoleType(Integer.parseInt(user.getRoleId().toString())); |
| | | user.setUserIdentification(CodeGenerateUtils.generateVolumeSn()); |
| | | userService.insertUser(user); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 账号继承 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | @ApiOperation(value = "账号继承,userId:继承账号id,oldUserId:老账号id",response = SysUser.class) |
| | | @Log(title = "用户信息-账号继承", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/open/system/user/inherit") |
| | | public R<String> inherit(@RequestParam Long userId, |
| | | @RequestParam Long oldUserId) |
| | | { |
| | | // 查询老帐号 |
| | | SysUser oldUser = userService.selectUserById(oldUserId); |
| | | if (Objects.isNull(oldUser)){ |
| | | return R.fail("原始账号不存在"); |
| | | } |
| | | if ("0".equals(oldUser.getStatus())){ |
| | | return R.fail("原始账号未停用,无法继承"); |
| | | } |
| | | SysUser user = userService.selectUserById(userId); |
| | | if (Objects.isNull(user)){ |
| | | return R.fail("继承账号不存在"); |
| | | } |
| | | if(!oldUser.getRoleType().equals(user.getRoleType())){ |
| | | return R.fail("原始账号和继承账号角色不一致"); |
| | | } |
| | | |
| | | Integer roleType = oldUser.getRoleType(); |
| | | Long oldUserUserId = oldUser.getUserId(); |
| | | switch (roleType){ |
| | | case 3: |
| | | // 工艺工程师 |
| | | // 临床试验积分 |
| | | clinicalTrialPointsService.update(Wrappers.lambdaUpdate(TClinicalTrialPoints.class) |
| | | .eq(TClinicalTrialPoints::getProcessEngineerId,oldUserUserId) |
| | | .set(TClinicalTrialPoints::getProcessEngineerId,userId)); |
| | | // QA检测项 |
| | | qaTestItemService.update(Wrappers.lambdaUpdate(TQaTestItem.class) |
| | | .eq(TQaTestItem::getCommitPersonId,oldUserUserId) |
| | | .set(TQaTestItem::getCommitPersonId,userId)); |
| | | break; |
| | | case 4: |
| | | // 化验师 |
| | | // 中试、生产验证分析报告;辅料;产品报告 |
| | | qaProduceReportService.update(Wrappers.lambdaUpdate(TQaProduceReport.class) |
| | | .eq(TQaProduceReport::getCommitPersonId,oldUserUserId) |
| | | .set(TQaProduceReport::getCommitPersonId,userId)); |
| | | break; |
| | | case 5: |
| | | // 实验员 |
| | | // 实验方案实验人员管理 |
| | | experimentSchemePersonService.update(Wrappers.lambdaUpdate(TExperimentSchemePerson.class) |
| | | .eq(TExperimentSchemePerson::getUserId,oldUserUserId) |
| | | .set(TExperimentSchemePerson::getUserId,userId)); |
| | | // 实验员其他任务 |
| | | testerOtherTaskService.update(Wrappers.lambdaUpdate(TTesterOtherTask.class) |
| | | .eq(TTesterOtherTask::getTesterId,oldUserUserId) |
| | | .set(TTesterOtherTask::getTesterId,userId)); |
| | | break; |
| | | } |
| | | // 实验调度参与人员 |
| | | experimentDispatchParticipantsService.update(Wrappers.lambdaUpdate(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getUserId,oldUserUserId) |
| | | .set(TExperimentDispatchParticipants::getUserId,userId)); |
| | | // 公告 |
| | | noticeService.update(Wrappers.lambdaUpdate(TNotice.class) |
| | | .eq(TNotice::getUserId,oldUserUserId) |
| | | .set(TNotice::getUserId,userId)); |
| | | // 项目课题 |
| | | projectProposalService.update(Wrappers.lambdaUpdate(TProjectProposal.class) |
| | | .eq(TProjectProposal::getCommitUserId,oldUserUserId) |
| | | .set(TProjectProposal::getCommitUserId,userId)); |
| | | // 项目组 |
| | | projectTeamStaffService.update(Wrappers.lambdaUpdate(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId,oldUserUserId) |
| | | .set(TProjectTeamStaff::getUserId,userId)); |
| | | // 实验结果汇报 |
| | | resultWorkEvaluateService.update(Wrappers.lambdaUpdate(TResultWorkEvaluate.class) |
| | | .eq(TResultWorkEvaluate::getUserId,oldUserUserId) |
| | | .set(TResultWorkEvaluate::getUserId,userId)); |
| | | // 取样操作管理 |
| | | samplingRecordOperationService.update(Wrappers.lambdaUpdate(TSamplingRecordOperation.class) |
| | | .eq(TSamplingRecordOperation::getHandlePersonId,oldUserUserId) |
| | | .set(TSamplingRecordOperation::getHandlePersonId,userId)); |
| | | samplingRecordOperationService.update(Wrappers.lambdaUpdate(TSamplingRecordOperation.class) |
| | | .eq(TSamplingRecordOperation::getSendPersonId,oldUserUserId) |
| | | .set(TSamplingRecordOperation::getSendPersonId,userId)); |
| | | samplingRecordOperationService.update(Wrappers.lambdaUpdate(TSamplingRecordOperation.class) |
| | | .eq(TSamplingRecordOperation::getReceiptsPersonId,oldUserUserId) |
| | | .set(TSamplingRecordOperation::getReceiptsPersonId,userId)); |
| | | // 检验方法确认单 |
| | | testMethodConfirmSheetService.update(Wrappers.lambdaUpdate(TTestMethodConfirmSheet.class) |
| | | .eq(TTestMethodConfirmSheet::getCommitUserId,oldUserUserId) |
| | | .set(TTestMethodConfirmSheet::getCommitUserId,userId)); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改用户签名 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @ApiOperation(value = "修改用户签名") |
| | | @Log(title = "用户信息-修改用户签名", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/api/system/user/editSignPicture") |
| | | public R editSignPicture(@RequestBody String param) |
| | | { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | SysUser user = JSON.parseObject(param,SysUser.class); |
| | | user.setUserId(userId); |
| | | return R.ok(userService.editSignPicture(user)); |
| | | } |
| | | |
| | | /** |
| | | * 删除用户 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:remove')") |