diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java index 6d91d36..4b7c4e9 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java @@ -110,31 +110,107 @@ public class StudyController extends BaseController return AjaxResult.success(); } + @GetMapping("/jcgjList") + public TableDataInfo jcgjList(StudyJcgj form) + { + startPage(); + List list = studyJcgjService.queryList(form); + return getDataTable(list); + } + /** * 删除试验信息 */ @RequiresPermissions({"business:study:remove"}) @PostMapping("/delete") - public AjaxResult delete(@RequestBody Study study) + 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("参数有误"); } - Study info = studyService.getById(study.getId()); - if(info==null){ - return AjaxResult.error("信息不存在"); + studyService.del(form); + return AjaxResult.success(); + } + + /** + * 删除试验信息 + */ + @RequiresPermissions({"business:study: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(!info.getStatus().equals(StudyStatusEnum.cg.getValue())){ - return AjaxResult.error("当前状态不能删除"); + if(study.getId()==null || study.getId().longValue()<=0){ + return AjaxResult.error("参数有误"); } - return toAjax(studyService.removeById(study.getId())); + studyService.gd(form); + return AjaxResult.success(); } - @GetMapping("/jcgjList") - public TableDataInfo jcgjList(StudyJcgj form) + /** + * 删除试验信息 + */ + @RequiresPermissions({"business:study:js"}) + @PostMapping("/js") + public AjaxResult js(@RequestBody StudySaveForm form) { - startPage(); - List list = studyJcgjService.queryList(form); - return getDataTable(list); + 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(); + } + + /** + * 删除试验信息 + */ + @RequiresPermissions({"business:study: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(); + } + + /** + * 借阅 + */ + @RequiresPermissions({"business:study: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){ + return AjaxResult.error("参数有误"); + } + studyService.jy(form); + return AjaxResult.success(); } + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java index c58470c..5f96638 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectController.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.hxhq.business.domain.Study; +import com.hxhq.business.form.common.SignForm; import com.hxhq.business.form.study.StudySubjectSaveForm; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -54,7 +56,7 @@ public class StudySubjectController extends BaseController @PostMapping("/save") public AjaxResult save(@RequestBody StudySubjectSaveForm form) { - if(form.getStudyId()==null || form.getStudyId().longValue()<=0 || form.getSubjectList()==null){ + if(form.getStudyId()==null || form.getStudyId().longValue()<=0 || form.getSubjectList()==null || form.getSign()==null){ return AjaxResult.error("参数有误"); } studySubjectService.saveInfo(form); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java index e28b602..33f7a5d 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudySubjectUserController.java @@ -43,7 +43,7 @@ public class StudySubjectUserController extends BaseController @PostMapping("/save") public AjaxResult save(@RequestBody StudySubjectUserSaveForm form) { - if(form.getStudySubjectId()==null || form.getStudySubjectId().longValue()<=0 || form.getSubjectUserList()==null){ + if(form.getStudySubjectId()==null || form.getStudySubjectId().longValue()<=0 || form.getSubjectUserList()==null ||form.getSign()==null){ return AjaxResult.error("参数有误"); } studySubjectUserService.saveInfo(form); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectSaveForm.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectSaveForm.java index 3d66eff..e4bdb81 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectSaveForm.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectSaveForm.java @@ -1,6 +1,7 @@ package com.hxhq.business.form.study; import com.hxhq.business.domain.StudySubject; +import com.hxhq.business.form.common.SignForm; import java.util.List; @@ -17,6 +18,10 @@ public class StudySubjectSaveForm { * 学科信息 */ private List subjectList; + /** + * 签名信息 + */ + private SignForm sign; public Long getStudyId() { return studyId; @@ -33,4 +38,12 @@ public class StudySubjectSaveForm { public void setSubjectList(List subjectList) { this.subjectList = subjectList; } + + public SignForm getSign() { + return sign; + } + + public void setSign(SignForm sign) { + this.sign = sign; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectUserSaveForm.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectUserSaveForm.java index 43d89b9..4e11fd8 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectUserSaveForm.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySubjectUserSaveForm.java @@ -2,6 +2,7 @@ package com.hxhq.business.form.study; import com.hxhq.business.domain.StudySubject; import com.hxhq.business.domain.StudySubjectUser; +import com.hxhq.business.form.common.SignForm; import java.util.List; @@ -18,6 +19,10 @@ public class StudySubjectUserSaveForm { * 成员列表 */ private List subjectUserList; + /** + * 签名信息 + */ + private SignForm sign; public Long getStudySubjectId() { return studySubjectId; @@ -34,4 +39,12 @@ public class StudySubjectUserSaveForm { public void setSubjectUserList(List subjectUserList) { this.subjectUserList = subjectUserList; } + + public SignForm getSign() { + return sign; + } + + public void setSign(SignForm sign) { + this.sign = sign; + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java index c3c641c..dc9f9a7 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java @@ -4,6 +4,7 @@ import java.util.List; import com.hxhq.business.domain.Study; import com.baomidou.mybatisplus.extension.service.IService; import com.hxhq.business.dto.study.StudyListDto; +import com.hxhq.business.form.common.SignForm; import com.hxhq.business.form.study.StudySaveForm; import com.hxhq.business.form.study.StudySearchForm; @@ -29,4 +30,40 @@ public interface IStudyService extends IService */ void saveInfo(StudySaveForm form); + /** + * 删除 + * @param form + */ + void del(StudySaveForm form); + + /** + * 归档 + * @param form + */ + void gd(StudySaveForm form); + + /** + * 解锁 + * @param form + */ + void js(StudySaveForm form); + + /** + * 解档 + * @param form + */ + void jd(StudySaveForm form); + + /** + * 借阅 + * @param form + */ + void jy(StudySaveForm form); + + /** + * 检查密码 + * @param sign + */ + void checkPassword(SignForm sign); + } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java index 832eb10..0b3e399 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java @@ -22,6 +22,7 @@ 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.StringUtils; +import com.hxhq.common.core.web.domain.AjaxResult; import com.hxhq.common.security.utils.SecurityUtils; import com.hxhq.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -74,7 +75,7 @@ public class StudyServiceImpl extends ServiceImpl implements if(form.getStatus()!=null && form.getStatus().intValue()>0){ queryWrapper.eq("s.status",form.getStatus()); } - queryWrapper.orderByDesc("s.create_time"); + queryWrapper.orderByDesc("s.id"); return baseMapper.queryList(queryWrapper); } @@ -142,7 +143,50 @@ public class StudyServiceImpl extends ServiceImpl implements } } - void checkPassword(SignForm sign){ + @Override + @Transactional(rollbackFor = Exception.class) + public void del(StudySaveForm form) { + Study study = form.getStudy(); + SignForm sign = form.getSign(); + + Study info = getById(study.getId()); + if(info==null){ + throw new ServiceException("信息不存在"); + } + if(!info.getStatus().equals(StudyStatusEnum.cg.getValue())){ + throw new ServiceException("当前状态不能删除"); + } + checkPassword(sign); + studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.red,"删除实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark()); + removeById(study.getId()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void gd(StudySaveForm form) { + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void js(StudySaveForm form) { + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void jd(StudySaveForm form) { + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void jy(StudySaveForm form) { + + } + + @Override + public void checkPassword(SignForm sign){ if(sign==null){ throw new ServiceException("签名参数有误"); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java index c3fc045..931ed26 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectServiceImpl.java @@ -1,16 +1,23 @@ package com.hxhq.business.service.impl; 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; import com.hxhq.business.domain.Study; +import com.hxhq.business.enums.zykgl.JcgjlxEnum; +import com.hxhq.business.enums.zykgl.JcmcysEnum; import com.hxhq.business.form.study.StudySubjectSaveForm; +import com.hxhq.business.service.IStudyJcgjService; import com.hxhq.business.service.IStudyService; import com.hxhq.business.service.IStudySubjectUserService; +import com.hxhq.business.utils.JctUtil; import com.hxhq.common.core.exception.ServiceException; +import com.hxhq.common.security.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.StudySubjectMapper; @@ -32,6 +39,8 @@ public class StudySubjectServiceImpl extends ServiceImpl itemList = form.getSubjectList(); @@ -93,18 +103,30 @@ public class StudySubjectServiceImpl extends ServiceImpl addList = new ArrayList<>(); List modifyList = new ArrayList<>(); + List addNameList = new ArrayList<>(); + List deleteNameList = new ArrayList<>(); + + for(StudySubject item : itemList){ - if(oldList.stream().filter(o->o.getDeptId().equals(item.getDeptId())).collect(Collectors.toList()).size()==0){ + List exists = oldList.stream().filter(o->o.getDeptId().equals(item.getDeptId())).collect(Collectors.toList()); + if(exists.size()==0){ item.setStudyId(form.getStudyId()); addList.add(item); + + addNameList.add(item.getLeaderName()); }else{ modifyList.add(item); + if(!exists.get(0).getLeaderName().equals(item.getLeaderName())){ + addNameList.add(item.getLeaderName()); + deleteNameList.add(exists.get(0).getLeaderName()); + } } } for(StudySubject old : oldList){ if(itemList.stream().filter(o->o.getDeptId().equals(old.getDeptId())).collect(Collectors.toList()).size()==0){ deleteList.add(old); + deleteNameList.add(old.getLeaderName()); } } if(addList.size()>0){ @@ -119,5 +141,16 @@ public class StudySubjectServiceImpl extends ServiceImpl0 || addNameList.size()>0){ + Map formData = new LinkedHashMap<>(); + if(addNameList.size()>0){ + formData.put("新增人员", String.join(",",addNameList)); + } + if(deleteNameList.size()>0){ + formData.put("删除人员", String.join(",",deleteNameList)); + } + studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.ry, JcmcysEnum.blue,"人员变更", JctUtil.formatStr(formData), SecurityUtils.getUserId(),SecurityUtils.getNickName(),form.getSign().getRemark()); + } } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java index 1636681..c6469a3 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudySubjectUserServiceImpl.java @@ -1,17 +1,24 @@ package com.hxhq.business.service.impl; 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; import com.hxhq.business.domain.Study; import com.hxhq.business.domain.StudySubject; +import com.hxhq.business.enums.zykgl.JcgjlxEnum; +import com.hxhq.business.enums.zykgl.JcmcysEnum; import com.hxhq.business.form.study.StudySubjectUserSaveForm; +import com.hxhq.business.service.IStudyJcgjService; import com.hxhq.business.service.IStudyService; import com.hxhq.business.service.IStudySubjectService; +import com.hxhq.business.utils.JctUtil; import com.hxhq.common.core.exception.ServiceException; +import com.hxhq.common.security.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hxhq.business.mapper.StudySubjectUserMapper; @@ -31,6 +38,10 @@ public class StudySubjectUserServiceImpl extends ServiceImpl getListByStudySubjectId(Long studySubjectId) { @@ -46,6 +57,7 @@ public class StudySubjectUserServiceImpl extends ServiceImpl itemList = form.getSubjectUserList(); //已经设置的学科信息 @@ -54,20 +66,31 @@ public class StudySubjectUserServiceImpl extends ServiceImpl addList = new ArrayList<>(); List modifyList = new ArrayList<>(); + List addNameList = new ArrayList<>(); + List deleteNameList = new ArrayList<>(); + for(StudySubjectUser item : itemList){ List existsList = oldList.stream().filter(o->o.getUserId().equals(item.getUserId())).collect(Collectors.toList()); if(existsList.size()==0){ item.setStudySubjectId(form.getStudySubjectId()); addList.add(item); + + addNameList.add(item.getUserName()); }else{ item.setId(existsList.get(0).getId()); modifyList.add(item); + + if(!existsList.get(0).getUserName().equals(item.getUserName())){ + addNameList.add(item.getUserName()); + deleteNameList.add(existsList.get(0).getUserName()); + } } } for(StudySubjectUser old : oldList){ if(itemList.stream().filter(o->o.getUserId().equals(old.getUserId())).collect(Collectors.toList()).size()==0){ deleteList.add(old); + deleteNameList.add(old.getUserName()); } } if(addList.size()>0){ @@ -79,6 +102,17 @@ public class StudySubjectUserServiceImpl extends ServiceImpl0){ removeBatchByIds(deleteList); } + + if(deleteNameList.size()>0 || addNameList.size()>0){ + Map formData = new LinkedHashMap<>(); + if(addNameList.size()>0){ + formData.put("新增人员", String.join(",",addNameList)); + } + if(deleteNameList.size()>0){ + formData.put("删除人员", String.join(",",deleteNameList)); + } + studyJcgjService.saveInfo(studySubject.getStudyId(), JcgjlxEnum.ry, JcmcysEnum.blue,"人员变更", JctUtil.formatStr(formData), SecurityUtils.getUserId(),SecurityUtils.getNickName(),form.getSign().getRemark()); + } } @Override