From dda2e3f49fe9c942fb6a487204ff8c8e66e46a12 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 27 六月 2025 18:08:14 +0800 Subject: [PATCH] bug修改 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 5 ++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TResultWorkEvaluateController.java | 2 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 8 ++++ ruoyi-system/src/main/resources/mapper/system/TInspectionReportMapper.xml | 2 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java | 4 ++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java | 31 +++++++++++++-- ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java | 10 +++++ ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java | 4 ++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java | 32 ++++++++++++++++ ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java | 8 ++- 10 files changed, 97 insertions(+), 9 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TResultWorkEvaluateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TResultWorkEvaluateController.java index 61a872d..c9d2aae 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TResultWorkEvaluateController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TResultWorkEvaluateController.java @@ -157,7 +157,7 @@ @Log(title = "实验结果工作评定管理-删除化验师、实验员工作评定", businessType = BusinessType.DELETE) @ApiOperation(value = "删除化验师、实验员工作评定") @DeleteMapping(value = "/open/t-result-work-evaluate/deleteById") - public R<Boolean> deleteById(@RequestBody String id) { + public R<Boolean> deleteById(@RequestParam String id) { tResultWorkEvaluateService.removeById(id); return R.ok(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java index 472321a..3db12d7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java @@ -27,9 +27,7 @@ import java.text.SimpleDateFormat; import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -56,8 +54,9 @@ private final TProjectTeamStaffService projectTeamStaffService; private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; private final TNoticeService noticeService; + private final TInspectionReportService inspectionReportService; @Autowired - public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TNoticeService noticeService) { + public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TNoticeService noticeService, TInspectionReportService inspectionReportService) { this.samplingRecordService = samplingRecordService; this.tokenService = tokenService; this.sysUserService = sysUserService; @@ -69,6 +68,7 @@ this.projectTeamStaffService = projectTeamStaffService; this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; this.noticeService = noticeService; + this.inspectionReportService = inspectionReportService; } /** @@ -110,6 +110,29 @@ query.setDispatchIds(dispatchIds); } } + if(roleType == 4){ + // 查询检验报告 + List<TInspectionReport> inspectionReports = inspectionReportService.list(Wrappers.lambdaQuery(TInspectionReport.class) + .eq(TInspectionReport::getStatus, 1)); + if (!CollectionUtils.isEmpty(inspectionReports)) { + List<String> dispatchIds = inspectionReports.stream().map(TInspectionReport::getDispatchId).distinct().collect(Collectors.toList()); + List<String> dispatchIds1 = query.getDispatchIds(); + Iterator<String> iterator = dispatchIds1.iterator(); + while (iterator.hasNext()) { + String next = iterator.next(); + if (!dispatchIds.contains(next)) { + iterator.remove(); + } + } + if(CollectionUtils.isEmpty(dispatchIds1)){ + List<String> id = new ArrayList<>(); + id.add("-1"); + query.setDispatchIds(id); + }else { + query.setDispatchIds(dispatchIds1); + } + } + } } return R.ok(samplingRecordService.pageList(query)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 1fab943..2893952 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -12,6 +12,7 @@ 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; @@ -201,11 +202,42 @@ 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("原始账号不存在"); + } + SysUser user = userService.selectUserById(userId); + if (Objects.isNull(user)){ + return R.fail("继承账号不存在"); + } + Long oldUserUserId = oldUser.getUserId(); + List<SysUser> oldUserList = userService.selectOldList(); +// oldUser.setUserId(); +// userService.updateUserOldUser(oldUser); + user.setParentId(oldUser.getUserId()); + user.setParentAccount(oldUser.getUserName()); + +// userService.updateUserInherit(user); + return R.ok(); + } + + /** * 修改用户 */ // @PreAuthorize("@ss.hasPermi('system:user:edit')") diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index f93a76b..373dfe2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -142,6 +142,16 @@ @TableField("sign_picture") private String signPicture; + @ApiModelProperty(value = "用户唯一标识") + @TableField("userIdentification") + private String userIdentification; + @ApiModelProperty(value = "继承账号id") + @TableField("parentId") + private Long parentId; + @ApiModelProperty(value = "继承账号") + @TableField("parentAccount") + private String parentAccount; + public Integer getRoleType() { return roleType; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java index 76492bc..f0fa5d5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java @@ -3,8 +3,6 @@ import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.Date; -import java.util.concurrent.atomic.AtomicInteger; /** * @Description @@ -66,11 +64,15 @@ Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); String dateTime = dateFormat.format(calendar.getTime()); - dateTime = dateTime.substring(2); + dateTime = dateTime.substring(0); String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000); timestampPart = timestampPart.replace(".", "").replace("E", ""); timestampPart = timestampPart.substring(0, 0); return dateTime + timestampPart; } + public static void main(String[] args) { + System.err.println(generateVolumeSn()); + } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 738ab7e..519b71c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -182,4 +182,8 @@ List<SysUser> selectListByNameAndUserIds(@Param("nickName")String nickName, @Param("userIds")List<Long> userIds); int editSignPicture(SysUser user); + + List<SysUser> selectOldList(); + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index b8b35bd..5f942e9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -282,4 +282,8 @@ * @return */ Integer editSignPicture(SysUser user); + + List<SysUser> selectOldList(); + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 27019cb..9d9bc59 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -698,6 +698,11 @@ return userMapper.editSignPicture(user); } + @Override + public List<SysUser> selectOldList() { + return userMapper.selectOldList(); + } + // @Override // public UserInfoVo userInfo(Long userId) { // return userMapper.userInfo(userId); diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index c76e470..71fe532 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -294,6 +294,12 @@ AND u.nick_name LIKE concat('%',#{nickName},'%') </if> </select> + <select id="selectOldList" resultType="com.ruoyi.common.core.domain.entity.SysUser"> + select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, + u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, + u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark + from sys_user u where user_id < 0 and u.status = 0 and u.del_flag = 0 order by user_id desc + </select> <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> insert into sys_user( @@ -313,6 +319,7 @@ <if test="ifBlack != null">ifBlack,</if> <if test="districtId != null">districtId,</if> <if test="roleType != null">role_type,</if> + <if test="userIdentification != null and userIdentification != ''">userIdentification,</if> create_time )values( <if test="userId != null and userId != ''">#{userId},</if> @@ -331,6 +338,7 @@ <if test="ifBlack != null">#{ifBlack},</if> <if test="districtId != null">#{districtId},</if> <if test="roleType != null">#{roleType},</if> + <if test="userIdentification != null and userIdentification != ''">#{userIdentification},</if> sysdate() ) </insert> diff --git a/ruoyi-system/src/main/resources/mapper/system/TInspectionReportMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TInspectionReportMapper.xml index f0e6e0a..63e347f 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TInspectionReportMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TInspectionReportMapper.xml @@ -50,7 +50,7 @@ </foreach> </if> <if test="query.roleType != null and query.roleType == 4"> - and tir.status = 1 + and tir.status in (-1, 1) </if> <if test="query.status == null"> and tir.status != -1 -- Gitblit v1.7.1