From 6572a4e8312cc46a0acafac958823ef8ba08bc51 Mon Sep 17 00:00:00 2001 From: memorylkf <312904636@qq.com> Date: Sun, 4 Jan 2026 19:15:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[=E8=AF=95=E9=AA=8C=E7=AE=A1=E7=90=86]?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0TFM=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hxhq/business/controller/StudyController.java | 57 +++++++++++----------- .../business/service/impl/StudyServiceImpl.java | 25 ++++++++-- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java index b7c56e1..457ed6b 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java @@ -185,34 +185,33 @@ public class StudyController extends BaseController } /** - * 解锁 + * 检查锁定 * @param form * @return */ - @RequiresPermissions({"business:study:js"}) - @PostMapping("/js") - public AjaxResult js(@RequestBody StudySaveForm form) + @RequiresPermissions({"business:study:sd"}) + @PostMapping("/checkSd") + public AjaxResult checkSd(@RequestBody StudySaveForm form) { Study study = form.getStudy(); - SignForm sign = form.getSign(); - if(study==null || sign==null){ + if(study==null){ return AjaxResult.error("参数有误"); } if(study.getId()==null || study.getId().longValue()<=0){ return AjaxResult.error("参数有误"); } - studyService.js(form); + studyService.checkSd(studyService.getById(study.getId())); return AjaxResult.success(); } /** - * 解档 + * 锁定 * @param form * @return */ - @RequiresPermissions({"business:study:jd"}) - @PostMapping("/jd") - public AjaxResult jd(@RequestBody StudySaveForm form) + @RequiresPermissions({"business:study:sd"}) + @PostMapping("/sd") + public AjaxResult sd(@RequestBody StudySaveForm form) { Study study = form.getStudy(); SignForm sign = form.getSign(); @@ -222,18 +221,18 @@ public class StudyController extends BaseController if(study.getId()==null || study.getId().longValue()<=0){ return AjaxResult.error("参数有误"); } - studyService.jd(form); + studyService.sd(form); return AjaxResult.success(); } /** - * 借阅 + * 解锁 * @param form * @return */ - @RequiresPermissions({"business:study:jy"}) - @PostMapping("/jy") - public AjaxResult jy(@RequestBody StudySaveForm form) + @RequiresPermissions({"business:study:js"}) + @PostMapping("/js") + public AjaxResult js(@RequestBody StudySaveForm form) { Study study = form.getStudy(); SignForm sign = form.getSign(); @@ -243,38 +242,39 @@ public class StudyController extends BaseController if(study.getId()==null || study.getId().longValue()<=0){ return AjaxResult.error("参数有误"); } - studyService.jy(form); + studyService.js(form); return AjaxResult.success(); } /** - * 检查锁定 + * 解档 * @param form * @return */ - @RequiresPermissions({"business:study:sd"}) - @PostMapping("/checkSd") - public AjaxResult checkSd(@RequestBody StudySaveForm form) + @RequiresPermissions({"business:study:jd"}) + @PostMapping("/jd") + public AjaxResult jd(@RequestBody StudySaveForm form) { Study study = form.getStudy(); - if(study==null){ + SignForm sign = form.getSign(); + if(study==null || sign==null){ return AjaxResult.error("参数有误"); } if(study.getId()==null || study.getId().longValue()<=0){ return AjaxResult.error("参数有误"); } - studyService.checkSd(studyService.getById(study.getId())); + studyService.jd(form); return AjaxResult.success(); } /** - * 锁定 + * 借阅 * @param form * @return */ - @RequiresPermissions({"business:study:sd"}) - @PostMapping("/sd") - public AjaxResult sd(@RequestBody StudySaveForm form) + @RequiresPermissions({"business:study:jy"}) + @PostMapping("/jy") + public AjaxResult jy(@RequestBody StudySaveForm form) { Study study = form.getStudy(); SignForm sign = form.getSign(); @@ -284,8 +284,7 @@ public class StudyController extends BaseController if(study.getId()==null || study.getId().longValue()<=0){ return AjaxResult.error("参数有误"); } - studyService.sd(form); + studyService.jy(form); return AjaxResult.success(); } - } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java index 374eada..9f2063a 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java @@ -192,6 +192,7 @@ public class StudyServiceImpl extends ServiceImpl implements if(!info.getStatus().equals(StudyStatusEnum.cg.getValue())){ throw new ServiceException("当前状态不能删除"); } + checkPermit(info); checkPassword(sign); studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.red,"删除实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark()); removeById(study.getId()); @@ -208,12 +209,10 @@ public class StudyServiceImpl extends ServiceImpl implements if(study==null){ throw new ServiceException("信息不存在"); } - if(!study.getCreateBy().equals(SecurityUtils.getUserId().toString())){ - throw new ServiceException("SD才能锁定"); - } if(study.getStatus().equals(StudyStatusEnum.ysd.getValue())){ throw new ServiceException("该试验已锁定"); } + checkPermit(study); String name = baseMapper.queryNotFinishFormName(study.getId()); if(StringUtils.isNoneBlank(name)){ throw new ServiceException("该实验下"+name+"还未结束,请先完成该表单后再进行锁定试验"); @@ -235,7 +234,20 @@ public class StudyServiceImpl extends ServiceImpl implements @Override @Transactional(rollbackFor = Exception.class) public void js(StudySaveForm form) { + Study study = form.getStudy(); + SignForm sign = form.getSign(); + Study info = getById(study.getId()); + if(info==null){ + throw new ServiceException("信息不存在"); + } + if(!info.getStatus().equals(StudyStatusEnum.ysd.getValue())){ + throw new ServiceException("当前状态不能解锁"); + } + checkPermit(info); + checkPassword(sign); + info.setStatus(StudyStatusEnum.syz.getValue()); + studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"解锁实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark()); } @Override @@ -260,4 +272,11 @@ public class StudyServiceImpl extends ServiceImpl implements } sysUserService.checkPassword(SecurityUtils.getLoginUser().getSysUser(),sign.getQmrmm(),false); } + + private void checkPermit(Study study){ + String tfmRole = "TFM"; + if(!AuthUtil.hasRole(tfmRole) && !study.getLeader().equals(SecurityUtils.getUserId())){ + throw new ServiceException("没有该试验操作权限"); + } + } }