@ -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 ServiceImpl
BeanUtils . copyProperties ( form , studyMethod ) ;
studyMethod . setUserId ( qmr . getUserId ( ) ) ;
studyMethod . setUserMc ( qmr . getNickName ( ) ) ;
studyMethod . setStatus ( NormalEnum . yes . getValue ( ) ) ;
this . save ( studyMethod ) ;
StudyMethodRead studyMethodRead = new StudyMethodRead ( ) ;
@ -182,34 +186,44 @@ public class StudyMethodServiceImpl extends ServiceImpl
if ( depts . stream ( ) . map ( o - > o . getId ( ) ) . collect ( Collectors . toList ( ) ) . contains ( String . valueOf ( userId ) ) & & ! study . getLeader ( ) . equals ( userId ) ) {
/ / 排除sd
LambdaQueryWrapper < StudyMethodRead > queryWrapper = new LambdaQueryWrapper < > ( ) ;
queryWrapper . eq ( StudyMethodRead : : getQmrId , userId )
. eq ( StudyMethodRead : : getStudyId , studyId ) ;
QueryWrapper < StudyMethod > 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 < StudyMethod > studyMethodLambdaQueryWrapper = new LambdaQueryWrapper < > ( ) ;
studyMethodLambdaQueryWrapper . eq ( StudyMethod : : getStudyId , studyId ) ;
if ( studySubjectId ! = null ) {
studyMethodLambdaQueryWrapper . eq ( StudyMethod : : getStudySubjectId , studySubjectId ) ;
}
List < StudyMethod > list = this . list ( studyMethodLambdaQueryWrapper ) ;
if ( readCount ! = list . size ( ) ) {
List < StudyMethod > list = baseMapper . queryUnreadList ( queryWrapper ) ;
if ( list . size ( ) > 0 ) {
/ / 获取未读方法
StudyMethodSearchForm form = new StudyMethodSearchForm ( ) ;
form . setStudyId ( studyId ) ;
form . setStudySubjectId ( studySubjectId ) ;
form . setZt ( StudyMethodStatusEnum . wd . getValue ( ) ) ;
List < StudyMethod > 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" , "《" + studyMethodL ist. 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 ) ;
}
}