@ -2,10 +2,15 @@ package com.hxhq.business.service.impl;
import java.util.List ;
import java.util.List ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.hxhq.business.domain.StudyMethodRead ;
import com.hxhq.business.enums.study.StudyMethodStatusEnum ;
import com.hxhq.business.form.study.StudyMethodForm ;
import com.hxhq.business.form.study.StudyMethodForm ;
import com.hxhq.business.form.study.StudyMethodSearchForm ;
import com.hxhq.business.service.IStudyMethodReadService ;
import com.hxhq.common.security.utils.SecurityUtils ;
import com.hxhq.system.api.domain.SysUser ;
import com.hxhq.system.api.domain.SysUser ;
import com.hxhq.system.service.ISysUserService ;
import com.hxhq.system.service.ISysUserService ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
@ -27,6 +32,9 @@ public class StudyMethodServiceImpl extends ServiceImpl
@Autowired
@Autowired
private ISysUserService sysUserService ;
private ISysUserService sysUserService ;
@Autowired
private IStudyMethodReadService studyMethodReadService ;
/ * *
/ * *
* 查询试验 - 试验方法列表
* 查询试验 - 试验方法列表
*
*
@ -34,8 +42,36 @@ public class StudyMethodServiceImpl extends ServiceImpl
* @return 试验 - 试验方法
* @return 试验 - 试验方法
* /
* /
@Override
@Override
public List < StudyMethod > queryList ( StudyMethodForm form ) {
return null ;
public List < StudyMethod > queryList ( StudyMethodSearchForm form ) {
QueryWrapper < StudyMethod > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "m.del_flag" , 0 ) ;
if ( form . getStudySubjectId ( ) ! = null ) {
queryWrapper . eq ( "m.study_subject_id" , form . getStudySubjectId ( ) ) ;
}
if ( StringUtils . isNotEmpty ( form . getFfmc ( ) ) ) {
queryWrapper . like ( "m.ffmc" , form . getFfmc ( ) ) ;
}
if ( StringUtils . isNotEmpty ( form . getCreateUser ( ) ) ) {
queryWrapper . like ( "m.user_mc" , form . getCreateUser ( ) ) ;
}
if ( StringUtils . isNotEmpty ( form . getStartDate ( ) ) ) {
queryWrapper . ge ( "m.create_time" , form . getStartDate ( ) ) ;
}
if ( StringUtils . isNotEmpty ( form . getEndDate ( ) ) ) {
queryWrapper . le ( "m.create_time" , form . getEndDate ( ) ) ;
}
/ / 已读
if ( form . getZt ( ) ! = null & & form . getZt ( ) = = StudyMethodStatusEnum . yd . getValue ( ) ) {
queryWrapper . and ( p - > p . apply ( "(m.id IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_subject_id = {1}))"
, SecurityUtils . getUserId ( ) , form . getStudySubjectId ( ) ) ) ;
}
/ / 未读
if ( form . getZt ( ) ! = null & & form . getZt ( ) = = StudyMethodStatusEnum . wd . getValue ( ) ) {
queryWrapper . and ( p - > p . apply ( "(m.id NOT IN (SELECT study_method_id FROM t_study_method_read WHERE del_flag = 0 AND qmr_id = {0} AND study_subject_id = {1}))"
, SecurityUtils . getUserId ( ) , form . getStudySubjectId ( ) ) ) ;
}
queryWrapper . orderByDesc ( "m.create_time" ) ;
return baseMapper . queryList ( queryWrapper , SecurityUtils . getUserId ( ) ) ;
}
}
@Override
@Override
@ -44,7 +80,18 @@ public class StudyMethodServiceImpl extends ServiceImpl
/ / TODO
/ / TODO
StudyMethod studyMethod = new StudyMethod ( ) ;
StudyMethod studyMethod = new StudyMethod ( ) ;
BeanUtils . copyProperties ( form , studyMethod ) ;
BeanUtils . copyProperties ( form , studyMethod ) ;
studyMethod . setUserId ( qmr . getUserId ( ) ) ;
studyMethod . setUserMc ( qmr . getNickName ( ) ) ;
this . save ( studyMethod ) ;
this . save ( studyMethod ) ;
StudyMethodRead studyMethodRead = new StudyMethodRead ( ) ;
studyMethodRead . setStudyId ( studyMethod . getStudyId ( ) ) ;
studyMethodRead . setStudySubjectId ( studyMethod . getStudySubjectId ( ) ) ;
studyMethodRead . setStudyMethodId ( studyMethod . getId ( ) ) ;
studyMethodRead . setQmrId ( qmr . getUserId ( ) ) ;
studyMethodRead . setQmrMc ( qmr . getNickName ( ) ) ;
studyMethodRead . setQmyy ( "阅读" ) ;
studyMethodReadService . save ( studyMethodRead ) ;
}
}
}
}