|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
@ -12,6 +13,7 @@ import com.hxhq.business.domain.StudyJcgj; |
|
|
|
import com.hxhq.business.dto.study.StudyListDto; |
|
|
|
import com.hxhq.business.enums.study.StudyBorrowStatusEnum; |
|
|
|
import com.hxhq.business.enums.study.StudyStatusEnum; |
|
|
|
import com.hxhq.business.enums.study.StudyTypeEnum; |
|
|
|
import com.hxhq.business.enums.zykgl.JcgjlxEnum; |
|
|
|
import com.hxhq.business.enums.zykgl.JcmcysEnum; |
|
|
|
import com.hxhq.business.form.common.SignForm; |
|
|
|
@ -22,6 +24,7 @@ import com.hxhq.business.utils.JctUtil; |
|
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
|
import com.hxhq.common.core.exception.ServiceException; |
|
|
|
import com.hxhq.common.core.utils.DateUtils; |
|
|
|
import com.hxhq.common.core.utils.PageUtils; |
|
|
|
import com.hxhq.common.core.utils.StringUtils; |
|
|
|
import com.hxhq.common.core.web.domain.AjaxResult; |
|
|
|
import com.hxhq.common.security.auth.AuthUtil; |
|
|
|
@ -48,16 +51,9 @@ public class StudyServiceImpl extends ServiceImpl implements |
|
|
|
private IStudyJcgjService studyJcgjService; |
|
|
|
@Autowired |
|
|
|
private ISysUserService sysUserService; |
|
|
|
/** |
|
|
|
* 查询试验列表 |
|
|
|
* |
|
|
|
* @param form 试验 |
|
|
|
* @return 试验 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<StudyListDto> queryList(StudySearchForm form) |
|
|
|
{ |
|
|
|
QueryWrapper<StudyListDto> queryWrapper = Wrappers.query(); |
|
|
|
|
|
|
|
private QueryWrapper<StudyListDto> getListBaseQuery(StudySearchForm form){ |
|
|
|
QueryWrapper<StudyListDto> queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.eq("s.del_flag","0"); |
|
|
|
if(form.getType()!=null && form.getType().intValue()>0){ |
|
|
|
queryWrapper.eq("s.type",form.getType()); |
|
|
|
@ -80,6 +76,20 @@ public class StudyServiceImpl extends ServiceImpl implements |
|
|
|
if(form.getStatus()!=null && form.getStatus().intValue()>0){ |
|
|
|
queryWrapper.eq("s.status",form.getStatus()); |
|
|
|
} |
|
|
|
return queryWrapper; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询试验列表 |
|
|
|
* |
|
|
|
* @param form 试验 |
|
|
|
* @return 试验 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<StudyListDto> queryList(StudySearchForm form) |
|
|
|
{ |
|
|
|
QueryWrapper<StudyListDto> queryWrapper = getListBaseQuery(form); |
|
|
|
//试验管理 |
|
|
|
//TFM看所有试验,其他只能看自己进入的试验 |
|
|
|
String tmfRole = "TFM"; |
|
|
|
if (!AuthUtil.hasRole(tmfRole)) |
|
|
|
@ -92,9 +102,49 @@ public class StudyServiceImpl extends ServiceImpl implements |
|
|
|
"s.id IN (\n" + |
|
|
|
"SELECT study_id FROM `t_study_subject_user` WHERE del_flag='0' AND user_id={0}\n" + |
|
|
|
")\n" + |
|
|
|
"OR create_by={0}\n" + |
|
|
|
"OR s.leader={0}\n" + |
|
|
|
")",SecurityUtils.getUserId()); |
|
|
|
} |
|
|
|
|
|
|
|
queryWrapper.orderByDesc("s.id"); |
|
|
|
return baseMapper.queryList(queryWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<StudyListDto> queryNonList(StudySearchForm form) { |
|
|
|
QueryWrapper<StudyListDto> queryWrapper = getListBaseQuery(form); |
|
|
|
// 非试验管理: |
|
|
|
// 特殊部门QA可以看所有列表+审核表单 |
|
|
|
// 特殊角色:可以看部门级下级部门的所有非试验,操作非试验(锁定、解锁...),可以审核表单 |
|
|
|
// 其他只能看所在部门级下级部门的所有非试验 |
|
|
|
|
|
|
|
// 总结:有这个菜单,特殊部QA可以看所有+审核表单,其他只能看部门级下级部门的列表(部长可以操作+审核表单) |
|
|
|
Long deptId = sysUserService.selectUserById(SecurityUtils.getLoginUser().getUserid()).getDeptId(); |
|
|
|
if (!deptId.equals(216L)) |
|
|
|
{ |
|
|
|
queryWrapper.apply("(\n" + |
|
|
|
"s.dept_id IN(\n" + |
|
|
|
"SELECT dept_id FROM sys_dept WHERE del_flag = '0' AND FIND_IN_SET({0}, ancestors) \n" + |
|
|
|
")\n" + |
|
|
|
"OR s.dept_id={0}\n" + |
|
|
|
")",deptId); |
|
|
|
} |
|
|
|
|
|
|
|
queryWrapper.orderByDesc("s.id"); |
|
|
|
PageUtils.startPage(); |
|
|
|
return baseMapper.queryList(queryWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<StudyListDto> queryDrugList(StudySearchForm form) { |
|
|
|
QueryWrapper<StudyListDto> queryWrapper = getListBaseQuery(form); |
|
|
|
|
|
|
|
// 麻精药管理: |
|
|
|
// 特殊部门QA可以看所有列表+审核表单 |
|
|
|
// 特殊角色:麻精药,角色下所有人都能看所有麻精药表单列表 |
|
|
|
// (是部长角色的话能看所有麻精药列表+操作+可以审核表单) |
|
|
|
|
|
|
|
// 总结:只要有这个菜单就能看所有列表,特殊部门QA可以审核表单,部长角色的话能操作+可以审核表单 |
|
|
|
queryWrapper.orderByDesc("s.id"); |
|
|
|
return baseMapper.queryList(queryWrapper); |
|
|
|
} |
|
|
|
@ -108,6 +158,25 @@ public class StudyServiceImpl extends ServiceImpl implements |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<StudyListDto> initFormCount(List<StudyListDto> list) { |
|
|
|
if(list.size()>0){ |
|
|
|
List<StudyListDto> countList = queryFormCountList(list.stream().map(o->o.getId()).collect(Collectors.toList())); |
|
|
|
for(StudyListDto l : list){ |
|
|
|
List<StudyListDto> matchList = countList.stream().filter(o->o.getId().equals(l.getId())).collect(Collectors.toList()); |
|
|
|
if(matchList.size()>0){ |
|
|
|
l.setFormCount(matchList.get(0).getFormCount()); |
|
|
|
l.setFormFinishCount(matchList.get(0).getFormFinishCount()); |
|
|
|
}else{ |
|
|
|
l.setFormCount(0); |
|
|
|
l.setFormFinishCount(0); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void saveInfo(StudySaveForm form) { |
|
|
|
Study study = form.getStudy(); |
|
|
|
|