Browse Source

feat: [试验管理] 锁定试验

master
memorylkf 1 week ago
parent
commit
0195ecfb31
8 changed files with 150 additions and 8 deletions
  1. +41
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java
  2. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMapper.java
  3. +16
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java
  4. +12
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java
  5. +29
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java
  6. +17
    -6
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java
  7. +8
    -2
      hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml
  8. +20
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectMapper.xml

+ 41
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java View File

@ -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();
}
}

+ 7
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudyMapper.java View File

@ -29,4 +29,11 @@ public interface StudyMapper extends BaseMapper
* @return
*/
List<StudyListDto> queryFormCountList(@Param("idList") List<Long> idList);
/**
* 获取未完成的表单的名称
* @param studyId
* @return
*/
String queryNotFinishFormName(@Param("studyId") Long studyId);
}

+ 16
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/StudySubjectMapper.java View File

@ -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<StudySubject> selectAllSubject();
/**
* 获取学科下的填报表单数量
* @param idList
* @return
*/
List<StudyListDto> queryFormCountList(@Param("idList") List<Long> idList);
/**
* 获取学科下的预填表单数量
* @param idList
* @return
*/
List<StudyListDto> queryPreFormCountList(@Param("idList") List<Long> idList);
}

+ 12
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java View File

@ -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
*/

+ 29
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java View File

@ -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) {

+ 17
- 6
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java View File

@ -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 ServiceImpl
deleteNameList.add(old.getLeaderName());
}
}
if(addList.size()>0){
saveBatch(addList);
}
if(modifyList.size()>0){
updateBatchById(modifyList);
}
if(deleteList.size()>0){
//已有表单的学科不能删除(预填+填报)
List<StudyListDto> formCountList = baseMapper.queryFormCountList(deleteList.stream().map(o->o.getId()).collect(Collectors.toList()));
List<StudyListDto> 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<String, String> formData = new LinkedHashMap<>();
if(addNameList.size()>0){

+ 8
- 2
hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudyMapper.xml View File

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hxhq.business.mapper.StudyMapper">
<select id="queryList" resultType="com.hxhq.business.dto.study.StudyListDto">
SELECT s.`id`,s.`sn`,s.`name`,s.`leader`,s.`leader_name`,s.`status`,s.`borrow_status`,s.`create_time` FROM `t_study` s
SELECT s.`id`,s.`sn`,s.`name`,s.`leader`,s.`leader_name`,s.`status`,s.`borrow_status`,s.`create_time`,s.`create_by` FROM `t_study` s
<if test="ew.sqlSegment != '' and ew.sqlSegment != null">
<where>
${ew.sqlSegment}
@ -13,7 +13,7 @@
</select>
<select id="queryFormCountList" resultType="com.hxhq.business.dto.study.StudyListDto">
SELECT study_id AS id, COUNT(0) AS formCount,COUNT(IF(bdzt=5 OR bdzt=7 OR bdzt=9 OR bdzt=11,id,NULL)) AS formFinishCount
SELECT study_id AS id, COUNT(0) AS formCount,COUNT(IF(bdzt=5 OR bdzt=7 OR bdzt=11,id,NULL)) AS formFinishCount
FROM `t_study_form_fill`
WHERE del_flag='0'
AND study_id IN
@ -22,4 +22,10 @@
</foreach>
GROUP BY study_id
</select>
<select id="queryNotFinishFormName" resultType="java.lang.String">
SELECT GROUP_CONCAT(bdmc ORDER BY id SEPARATOR '、') FROM `t_study_form_fill` WHERE
del_flag='0' AND study_id=#{studyId}
AND bdzt NOT IN (5,7,11)
</select>
</mapper>

+ 20
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/business/StudySubjectMapper.xml View File

@ -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
</select>
<select id="queryPreFormCountList" resultType="com.hxhq.business.dto.study.StudyListDto">
SELECT study_subject_id AS id, COUNT(0) AS formCount
FROM `t_study_form_pre`
WHERE del_flag='0'
AND study_subject_id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY study_subject_id
</select>
<select id="queryFormCountList" resultType="com.hxhq.business.dto.study.StudyListDto">
SELECT study_subject_id AS id, COUNT(0) AS formCount
FROM `t_study_form_fill`
WHERE del_flag='0'
AND study_subject_id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY study_subject_id
</select>
</mapper>

Loading…
Cancel
Save