From 0195ecfb31e24eaa38cc70412701cabe166925c6 Mon Sep 17 00:00:00 2001 From: memorylkf <312904636@qq.com> Date: Sun, 4 Jan 2026 16:47:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[=E8=AF=95=E9=AA=8C=E7=AE=A1=E7=90=86]?= =?UTF-8?q?=20=E9=94=81=E5=AE=9A=E8=AF=95=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hxhq/business/controller/StudyController.java | 41 ++++++++++++++++++++++ .../java/com/hxhq/business/mapper/StudyMapper.java | 7 ++++ .../hxhq/business/mapper/StudySubjectMapper.java | 16 +++++++++ .../com/hxhq/business/service/IStudyService.java | 12 +++++++ .../business/service/impl/StudyServiceImpl.java | 29 +++++++++++++++ .../service/impl/StudySubjectServiceImpl.java | 23 ++++++++---- .../main/resources/mapper/business/StudyMapper.xml | 10 ++++-- .../mapper/business/StudySubjectMapper.xml | 20 +++++++++++ 8 files changed, 150 insertions(+), 8 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 9239580..b7c56e1 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 @@ -247,4 +247,45 @@ public class StudyController extends BaseController return AjaxResult.success(); } + /** + * 检查锁定 + * @param form + * @return + */ + @RequiresPermissions({"business:study:sd"}) + @PostMapping("/checkSd") + public AjaxResult checkSd(@RequestBody StudySaveForm form) + { + Study study = form.getStudy(); + if(study==null){ + return AjaxResult.error("参数有误"); + } + if(study.getId()==null || study.getId().longValue()<=0){ + return AjaxResult.error("参数有误"); + } + studyService.checkSd(studyService.getById(study.getId())); + return AjaxResult.success(); + } + + /** + * 锁定 + * @param form + * @return + */ + @RequiresPermissions({"business:study:sd"}) + @PostMapping("/sd") + public AjaxResult sd(@RequestBody StudySaveForm form) + { + Study study = form.getStudy(); + SignForm sign = form.getSign(); + if(study==null || sign==null){ + return AjaxResult.error("参数有误"); + } + if(study.getId()==null || study.getId().longValue()<=0){ + return AjaxResult.error("参数有误"); + } + studyService.sd(form); + return AjaxResult.success(); + } + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMapper.java index b3dda58..014dfa2 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMapper.java @@ -29,4 +29,11 @@ public interface StudyMapper extends BaseMapper * @return */ List queryFormCountList(@Param("idList") List idList); + + /** + * 获取未完成的表单的名称 + * @param studyId + * @return + */ + String queryNotFinishFormName(@Param("studyId") Long studyId); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java index 94e3c96..6d54e40 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java @@ -2,6 +2,8 @@ package com.hxhq.business.mapper; import com.hxhq.business.domain.StudySubject; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hxhq.business.dto.study.StudyListDto; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -18,4 +20,18 @@ public interface StudySubjectMapper extends BaseMapper * @return */ List selectAllSubject(); + + /** + * 获取学科下的填报表单数量 + * @param idList + * @return + */ + List queryFormCountList(@Param("idList") List idList); + + /** + * 获取学科下的预填表单数量 + * @param idList + * @return + */ + List queryPreFormCountList(@Param("idList") List idList); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java index de75072..08bcc9e 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java @@ -50,6 +50,18 @@ public interface IStudyService extends IService void gd(StudySaveForm form); /** + * 检查锁定 + * @param study + */ + void checkSd(Study study); + + /** + * 锁定 + * @param form + */ + void sd(StudySaveForm form); + + /** * 解锁 * @param form */ 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 f489d45..374eada 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 @@ -204,6 +204,35 @@ public class StudyServiceImpl extends ServiceImpl implements } @Override + public void checkSd(Study study) { + 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("该试验已锁定"); + } + String name = baseMapper.queryNotFinishFormName(study.getId()); + if(StringUtils.isNoneBlank(name)){ + throw new ServiceException("该实验下"+name+"还未结束,请先完成该表单后再进行锁定试验"); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void sd(StudySaveForm form) { + Study info = getById(form.getStudy().getId()); + checkSd(info); + SignForm sign = form.getSign(); + checkPassword(sign); + info.setStatus(StudyStatusEnum.ysd.getValue()); + updateById(info); + studyJcgjService.saveInfo(info.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"锁定实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark()); + } + + @Override @Transactional(rollbackFor = Exception.class) public void js(StudySaveForm form) { diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java index 931ed26..90038f1 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java @@ -9,6 +9,7 @@ import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hxhq.business.domain.Study; +import com.hxhq.business.dto.study.StudyListDto; import com.hxhq.business.enums.zykgl.JcgjlxEnum; import com.hxhq.business.enums.zykgl.JcmcysEnum; import com.hxhq.business.form.study.StudySubjectSaveForm; @@ -129,19 +130,29 @@ public class StudySubjectServiceImpl extends ServiceImpl0){ - saveBatch(addList); - } - if(modifyList.size()>0){ - updateBatchById(modifyList); - } + if(deleteList.size()>0){ + //已有表单的学科不能删除(预填+填报) + List formCountList = baseMapper.queryFormCountList(deleteList.stream().map(o->o.getId()).collect(Collectors.toList())); + List preFormCountList = baseMapper.queryPreFormCountList(deleteList.stream().map(o->o.getId()).collect(Collectors.toList())); + for(StudySubject del : deleteList){ + if(formCountList.stream().filter(o->o.getId().equals(del.getId())).count()>0 || preFormCountList.stream().filter(o->o.getId().equals(del.getId())).count()>0){ + throw new ServiceException(del.getDeptName()+"下已有表单,不能取消勾选"); + } + } + removeBatchByIds(deleteList); for(StudySubject del : deleteList){ studySubjectUserService.deleteByStudySubjectId(del.getId()); } } + if(addList.size()>0){ + saveBatch(addList); + } + if(modifyList.size()>0){ + updateBatchById(modifyList); + } if(deleteNameList.size()>0 || addNameList.size()>0){ Map formData = new LinkedHashMap<>(); if(addNameList.size()>0){ diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml index 2f19002..58c4bda 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + \ No newline at end of file diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectMapper.xml index 26eeda8..aa465ea 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectMapper.xml @@ -7,4 +7,24 @@ SELECT dept_id,dept_name FROM `sys_dept` WHERE del_flag='0' AND `type`=3 ORDER BY CONVERT(dept_name USING gbk) ASC + + \ No newline at end of file