| @ -0,0 +1,296 @@ | |||
| package com.hxhq.business.controller; | |||
| import com.alibaba.fastjson2.JSONObject; | |||
| import com.hxhq.business.domain.Study; | |||
| import com.hxhq.business.domain.StudyJcgj; | |||
| import com.hxhq.business.dto.study.StudyListDto; | |||
| import com.hxhq.business.enums.study.StudyStatusEnum; | |||
| import com.hxhq.business.enums.study.StudyTypeEnum; | |||
| import com.hxhq.business.form.common.SignForm; | |||
| import com.hxhq.business.form.study.StudySaveForm; | |||
| import com.hxhq.business.form.study.StudySearchForm; | |||
| import com.hxhq.business.service.IStudyJcgjService; | |||
| import com.hxhq.business.service.IStudyService; | |||
| import com.hxhq.common.core.utils.StringUtils; | |||
| import com.hxhq.common.core.web.controller.BaseController; | |||
| import com.hxhq.common.core.web.domain.AjaxResult; | |||
| import com.hxhq.common.core.web.page.TableDataInfo; | |||
| import com.hxhq.common.security.annotation.RequiresPermissions; | |||
| import com.hxhq.common.security.utils.SecurityUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * 试验Controller | |||
| * | |||
| * @author hxhq | |||
| * @date 2025-12-24 | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/business/nonTrial") | |||
| public class NonTrialController extends BaseController | |||
| { | |||
| @Autowired | |||
| private IStudyService studyService; | |||
| @Autowired | |||
| private IStudyJcgjService studyJcgjService; | |||
| /** | |||
| * 查询试验列表 | |||
| */ | |||
| @GetMapping("/list") | |||
| @RequiresPermissions("business:form:nonTrial:list") | |||
| public TableDataInfo list(StudySearchForm form) | |||
| { | |||
| form.setType(StudyTypeEnum.fsy.getValue()); | |||
| startPage(); | |||
| List<StudyListDto> list = studyService.queryList(form); | |||
| TableDataInfo table = getDataTable(list); | |||
| table.setRows(initFormCount((List<StudyListDto>)table.getRows())); | |||
| return table; | |||
| } | |||
| /** | |||
| * 设置表单数 | |||
| * @param list | |||
| * @return | |||
| */ | |||
| private List<StudyListDto> initFormCount(List<StudyListDto> list){ | |||
| if(list.size()>0){ | |||
| List<StudyListDto> countList = studyService.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; | |||
| } | |||
| /** | |||
| * 获取试验详细信息 | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:add", "business:form:nonTrial:edit", "business:form:nonTrial:detail"}) | |||
| @GetMapping(value = "/info") | |||
| public AjaxResult getInfo(Long id) | |||
| { | |||
| Study study = studyService.getById(id); | |||
| if(study==null){ | |||
| return AjaxResult.error("信息不存在"); | |||
| } | |||
| StudyListDto info = JSONObject.parseObject(JSONObject.toJSONString(study),StudyListDto.class); | |||
| List<Long> idList = new ArrayList<>(); | |||
| idList.add(info.getId()); | |||
| List<StudyListDto> countList = studyService.queryFormCountList(idList); | |||
| if(countList.size()>0){ | |||
| info.setFormCount(countList.get(0).getFormCount()); | |||
| }else{ | |||
| info.setFormCount(0); | |||
| } | |||
| return AjaxResult.success(info); | |||
| } | |||
| /** | |||
| * 新增/编辑试验信息 | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:add", "business:form:nonTrial:edit"}) | |||
| @PostMapping("/save") | |||
| public AjaxResult save(@RequestBody StudySaveForm form) | |||
| { | |||
| Study study = form.getStudy(); | |||
| if(study==null){ | |||
| return AjaxResult.error("参数有误"); | |||
| } | |||
| if(StringUtils.isBlank(study.getName())){ | |||
| return AjaxResult.error("试验名称不能为空"); | |||
| } | |||
| if(StringUtils.isBlank(study.getSn())){ | |||
| return AjaxResult.error("试验编号不能为空"); | |||
| } | |||
| if(study.getLeader()==null || study.getLeader().longValue()<=0){ | |||
| return AjaxResult.error("试验负责人不能为空"); | |||
| } | |||
| if(study.getStatus()==null || study.getStatus().intValue()<=0){ | |||
| return AjaxResult.error("状态值有误"); | |||
| } | |||
| if(!study.getStatus().equals(StudyStatusEnum.cg.getValue()) && !study.getStatus().equals(StudyStatusEnum.syz.getValue())){ | |||
| return AjaxResult.error("状态有误"); | |||
| } | |||
| if(study.getId()==null){ | |||
| study.setType(StudyTypeEnum.fsy.getValue()); | |||
| study.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDept().getDeptId()); | |||
| study.setDeptName(SecurityUtils.getLoginUser().getSysUser().getDept().getDeptName()); | |||
| } | |||
| studyService.saveInfo(form); | |||
| return AjaxResult.success(); | |||
| } | |||
| /** | |||
| * 稽查轨迹列表 | |||
| * @param form | |||
| * @return | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:detail"}) | |||
| @GetMapping("/jcgjList") | |||
| public TableDataInfo jcgjList(StudyJcgj form) | |||
| { | |||
| startPage(); | |||
| List<StudyJcgj> list = studyJcgjService.queryList(form); | |||
| return getDataTable(list); | |||
| } | |||
| /** | |||
| * 删除试验信息 | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:remove"}) | |||
| @PostMapping("/delete") | |||
| public AjaxResult delete(@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.del(form); | |||
| return AjaxResult.success(); | |||
| } | |||
| /** | |||
| * 检查锁定 | |||
| * @param form | |||
| * @return | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial: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:form:nonTrial: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(); | |||
| } | |||
| /** | |||
| * 解锁 | |||
| * @param form | |||
| * @return | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:js"}) | |||
| @PostMapping("/js") | |||
| public AjaxResult js(@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.js(form); | |||
| return AjaxResult.success(); | |||
| } | |||
| /** | |||
| * 归档 | |||
| * @param form | |||
| * @return | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:gd"}) | |||
| @PostMapping("/gd") | |||
| public AjaxResult gd(@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.gd(form); | |||
| return AjaxResult.success(); | |||
| } | |||
| /** | |||
| * 解档 | |||
| * @param form | |||
| * @return | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:jd"}) | |||
| @PostMapping("/jd") | |||
| public AjaxResult jd(@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.jd(form); | |||
| return AjaxResult.success(); | |||
| } | |||
| /** | |||
| * 借阅 | |||
| * @param form | |||
| * @return | |||
| */ | |||
| @RequiresPermissions({"business:form:nonTrial:jy"}) | |||
| @PostMapping("/jy") | |||
| public AjaxResult jy(@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 || StringUtils.isBlank(sign.getStartDate()) || StringUtils.isBlank(sign.getEndDate())){ | |||
| return AjaxResult.error("参数有误"); | |||
| } | |||
| studyService.jy(form); | |||
| return AjaxResult.success(); | |||
| } | |||
| } | |||