diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyMethodController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyMethodController.java index a56a068..ed814fb 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyMethodController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyMethodController.java @@ -72,6 +72,13 @@ public class StudyMethodController extends BaseController { return AjaxResult.success(); } + @PostMapping("/close") + public AjaxResult close(@RequestBody StudyMethodForm form) { + form.setQmrId(SecurityUtils.getUserId()); + studyMethodService.close(form); + return AjaxResult.success(); + } + @PostMapping("/read") @RequiresPermissions("business:studyMethod:read") public AjaxResult read(@RequestBody @Validated StudyMethodReadForm form) { diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudyMethod.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudyMethod.java index 2a5a9e0..ea1f4ae 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudyMethod.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudyMethod.java @@ -36,7 +36,10 @@ public class StudyMethod extends MpBaseEntity /** 方法归属人名称 */ private String userMc; - /** 状态 */ + /** 是否关闭状态 1-已关闭 10-未关闭 */ + private Integer status; + + /** 状态 */ @TableField(exist = false) private Integer zt; @@ -113,4 +116,12 @@ public class StudyMethod extends MpBaseEntity public void setFileName(String fileName) { this.fileName = fileName; } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudyMethodForm.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudyMethodForm.java index cd56544..02c46b0 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudyMethodForm.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudyMethodForm.java @@ -9,6 +9,8 @@ import javax.validation.constraints.NotNull; */ public class StudyMethodForm { + private Long id; + /** 所属试验id */ @NotNull(message = "请选择所属试验") private Long studyId; @@ -99,4 +101,12 @@ public class StudyMethodForm { public void setFileName(String fileName) { this.fileName = fileName; } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java index 966b802..56de772 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMethodMapper.java @@ -26,4 +26,10 @@ public interface StudyMethodMapper extends BaseMapper */ List queryList(@Param("ew") Wrapper queryWrapper, @Param("qmrId") Long qmrId); + /** + * 获取未读试验方法列表 + * @param queryWrapper + * @return + */ + List queryUnreadList(@Param("ew") Wrapper queryWrapper); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodReadService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodReadService.java index 3a3e4a2..b665485 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodReadService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodReadService.java @@ -21,4 +21,5 @@ public interface IStudyMethodReadService extends IService * @return 已读列表 */ List queryList(Long studyMethodId); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java index 74629cf..c6ad0b7 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyMethodService.java @@ -45,4 +45,9 @@ public interface IStudyMethodService extends IService */ HashMap checkAllMethodReadStatus(Long userId, Long studyId, Long studySubjectId); + /** + * 关闭 + * @param form + */ + void close(StudyMethodForm form); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodReadServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodReadServiceImpl.java index 41e3b0c..4a47f7d 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodReadServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodReadServiceImpl.java @@ -2,7 +2,9 @@ package com.hxhq.business.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hxhq.business.domain.Bacteria; import com.hxhq.business.domain.StudyMethod; import com.hxhq.business.domain.StudyMethodRead; import com.hxhq.business.form.study.StudyMethodForm; diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java index 41c31a0..ef89e5f 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java @@ -7,9 +7,12 @@ import java.util.stream.Collectors; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hxhq.business.domain.Bacteria; import com.hxhq.business.domain.Study; import com.hxhq.business.domain.StudyMethodRead; import com.hxhq.business.dto.select.DeptUserTreeDto; +import com.hxhq.business.enums.NormalEnum; import com.hxhq.business.enums.study.StudyMethodStatusEnum; import com.hxhq.business.enums.study.StudyTypeEnum; import com.hxhq.business.form.study.StudyMethodForm; @@ -118,6 +121,7 @@ public class StudyMethodServiceImpl extends ServiceImplo.getId()).collect(Collectors.toList()).contains(String.valueOf(userId)) && !study.getLeader().equals(userId)){ //排除sd - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(StudyMethodRead::getQmrId, userId) - .eq(StudyMethodRead::getStudyId, studyId); + QueryWrapper queryWrapper = Wrappers.query(); + queryWrapper.eq("del_flag", 0) + .eq("status", NormalEnum.yes.getValue()) + .eq("study_id", studyId); if(studySubjectId != null) { - queryWrapper.eq(StudyMethodRead::getStudySubjectId, studySubjectId); + queryWrapper.eq("study_subject_id", studySubjectId); + queryWrapper.and(p -> p.apply("(id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_id = {1} AND study_subject_id = {2}))" + , SecurityUtils.getUserId(), studyId, studySubjectId)); + } else { + queryWrapper.and(p -> p.apply("(id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_id = {1}))" + , SecurityUtils.getUserId(), studyId)); } - long readCount = studyMethodReadService.count(queryWrapper); - LambdaQueryWrapper studyMethodLambdaQueryWrapper = new LambdaQueryWrapper<>(); - studyMethodLambdaQueryWrapper.eq(StudyMethod::getStudyId, studyId); - if(studySubjectId != null) { - studyMethodLambdaQueryWrapper.eq(StudyMethod::getStudySubjectId, studySubjectId); - } - List list = this.list(studyMethodLambdaQueryWrapper); - if(readCount != list.size()) { + List list = baseMapper.queryUnreadList(queryWrapper); + + if(list.size() > 0) { // 获取未读方法 - StudyMethodSearchForm form = new StudyMethodSearchForm(); - form.setStudyId(studyId); - form.setStudySubjectId(studySubjectId); - form.setZt(StudyMethodStatusEnum.wd.getValue()); - List studyMethodList = queryList(form); String toUrl=study.getType().equals(StudyTypeEnum.sy.getValue())?("/study/enter/"+study.getId()+"/syff"):study.getType().equals(StudyTypeEnum.fsy.getValue())?("/nonTrial/enter/"+study.getId()+"/syff"):study.getType().equals(StudyTypeEnum.mjy.getValue())?("/drug/enter/"+study.getId()+"/syff"):""; result.put("toUrl",toUrl); - result.put("ffmc","《" + studyMethodList.stream().map(StudyMethod::getFfmc).collect(Collectors.joining(",")) + "》方法还未阅读,请先阅读后再进行操作"); + result.put("ffmc","《" + list.stream().map(StudyMethod::getFfmc).collect(Collectors.joining(",")) + "》方法还未阅读,请先阅读后再进行操作"); } } return result; } + @Override + public void close(StudyMethodForm form) { + SysUser qmr = sysUserService.selectUserById(form.getQmrId()); + sysUserService.checkPassword(qmr, form.getQmrmm(), false); + + StudyMethod studyMethod = getById(form.getId()); + if(studyMethod == null || !studyMethod.getUserId().equals(form.getQmrId())) { + throw new ServiceException("对象不存在"); + } + studyMethod.setStatus(NormalEnum.no.getValue()); + updateById(studyMethod); + + } + } diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMethodMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMethodMapper.xml index 56b5a26..4c1248f 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMethodMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMethodMapper.xml @@ -12,4 +12,12 @@ + \ No newline at end of file