Browse Source

feat: [试验管理] [试验详情] 增加试验详情功能

master
memorylkf 1 week ago
parent
commit
f0417eb893
11 changed files with 339 additions and 21 deletions
  1. +8
    -0
      hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/utils/SecurityUtils.java
  2. +46
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java
  3. +15
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Study.java
  4. +10
    -14
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudyJcgj.java
  5. +7
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/zykgl/JcgjlxEnum.java
  6. +68
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/common/SignForm.java
  7. +34
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySaveForm.java
  8. +15
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyJcgjService.java
  9. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStudyService.java
  10. +33
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyJcgjServiceImpl.java
  11. +96
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyServiceImpl.java

+ 8
- 0
hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/utils/SecurityUtils.java View File

@ -48,6 +48,14 @@ public class SecurityUtils
}
/**
* 获取用户名称
*/
public static String getNickName()
{
return getLoginUser().getSysUser().getNickName();
}
/**
* 获取用户key
*/
public static String getUserKey()

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

@ -3,9 +3,16 @@ package com.hxhq.business.controller;
import java.util.Arrays;
import java.util.List;
import com.alibaba.fastjson2.JSONObject;
import com.hxhq.business.domain.MjyJcgj;
import com.hxhq.business.domain.StudyJcgj;
import com.hxhq.business.dto.study.StudyListDto;
import com.hxhq.business.enums.study.StudyStatusEnum;
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.common.core.utils.StringUtils;
import com.hxhq.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -28,6 +35,8 @@ public class StudyController extends BaseController
{
@Autowired
private IStudyService studyService;
@Autowired
private IStudyJcgjService studyJcgjService;
/**
* 查询试验列表
@ -62,7 +71,13 @@ public class StudyController extends BaseController
@GetMapping(value = "/info")
public AjaxResult getInfo(Long id)
{
return AjaxResult.success(studyService.getById(id));
Study study = studyService.getById(id);
if(study==null){
return AjaxResult.error("信息不存在");
}
StudyListDto info = JSONObject.parseObject(JSONObject.toJSONString(study),StudyListDto.class);
info.setFormCount(0);
return AjaxResult.success(info);
}
/**
@ -70,9 +85,29 @@ public class StudyController extends BaseController
*/
@RequiresPermissions({"business:study:add", "business:study:edit"})
@PostMapping("/save")
public AjaxResult save(@RequestBody Study study)
public AjaxResult save(@RequestBody StudySaveForm form)
{
return toAjax(studyService.saveOrUpdate(study));
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("状态有误");
}
studyService.saveInfo(form);
return AjaxResult.success();
}
/**
@ -94,4 +129,12 @@ public class StudyController extends BaseController
}
return toAjax(studyService.removeById(study.getId()));
}
@GetMapping("/jcgjList")
public TableDataInfo jcgjList(StudyJcgj form)
{
startPage();
List<StudyJcgj> list = studyJcgjService.queryList(form);
return getDataTable(list);
}
}

+ 15
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Study.java View File

@ -1,6 +1,7 @@
package com.hxhq.business.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hxhq.common.core.annotation.Compare;
import com.hxhq.common.core.domain.MpBaseEntity;
@ -16,9 +17,11 @@ public class Study extends MpBaseEntity
private static final long serialVersionUID = 1L;
/** 试验编号 */
@Compare(name = "试验编号")
private String sn;
/** 试验名称 */
@Compare(name = "试验名称")
private String name;
/** 负责人id */
@ -33,6 +36,9 @@ public class Study extends MpBaseEntity
/** 借阅状态1未借阅,5待借阅,10借阅中 */
private Integer borrowStatus;
@Compare(name = "试验简述")
private String remark;
public void setSn(String sn)
{
@ -92,4 +98,13 @@ public class Study extends MpBaseEntity
return borrowStatus;
}
@Override
public String getRemark() {
return remark;
}
@Override
public void setRemark(String remark) {
this.remark = remark;
}
}

+ 10
- 14
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/StudyJcgj.java View File

@ -19,13 +19,13 @@ public class StudyJcgj extends MpBaseEntity
private Long studyId;
/** 稽查轨迹类型:1:流程;3:编辑;5:人员 */
private Long jcgjlx;
private Integer jcgjlx;
/** 稽查名称 */
private String jcmc;
/** 稽查名称颜色:1:蓝色;3:红色;5:绿色;7:橙色 */
private Long jcmcys;
private Integer jcmcys;
/** 稽查内容 */
private String jcnr;
@ -47,14 +47,12 @@ public class StudyJcgj extends MpBaseEntity
return studyId;
}
public void setJcgjlx(Long jcgjlx)
{
this.jcgjlx = jcgjlx;
public Integer getJcgjlx() {
return jcgjlx;
}
public Long getJcgjlx()
{
return jcgjlx;
public void setJcgjlx(Integer jcgjlx) {
this.jcgjlx = jcgjlx;
}
public void setJcmc(String jcmc)
@ -67,14 +65,12 @@ public class StudyJcgj extends MpBaseEntity
return jcmc;
}
public void setJcmcys(Long jcmcys)
{
this.jcmcys = jcmcys;
public Integer getJcmcys() {
return jcmcys;
}
public Long getJcmcys()
{
return jcmcys;
public void setJcmcys(Integer jcmcys) {
this.jcmcys = jcmcys;
}
public void setJcnr(String jcnr)

+ 7
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/zykgl/JcgjlxEnum.java View File

@ -1,7 +1,7 @@
package com.hxhq.business.enums.zykgl;
/**
* 稽查轨迹类型:1:流程3编辑
* 稽查轨迹类型:1:流程3编辑5人员
* @author tanfei
*/
public enum JcgjlxEnum {
@ -14,7 +14,12 @@ public enum JcgjlxEnum {
/**
* 编辑
*/
bj(3, "编辑");
bj(3, "编辑"),
/**
* 人员
*/
ry(5, "人员");
private int value;
private String text;

+ 68
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/common/SignForm.java View File

@ -0,0 +1,68 @@
package com.hxhq.business.form.common;
/**
* @author memory
*/
public class SignForm {
/**
* 签名意义
*/
private String qmyy;
/**
* 原因/备注
*/
private String remark;
/**
* 签名人id
*/
private Long qmrId;
/**
* 签名人名称
*/
private String qmrMc;
/**
* 签名密码
*/
private String qmrmm;
public String getQmyy() {
return qmyy;
}
public void setQmyy(String qmyy) {
this.qmyy = qmyy;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Long getQmrId() {
return qmrId;
}
public void setQmrId(Long qmrId) {
this.qmrId = qmrId;
}
public String getQmrMc() {
return qmrMc;
}
public void setQmrMc(String qmrMc) {
this.qmrMc = qmrMc;
}
public String getQmrmm() {
return qmrmm;
}
public void setQmrmm(String qmrmm) {
this.qmrmm = qmrmm;
}
}

+ 34
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/study/StudySaveForm.java View File

@ -0,0 +1,34 @@
package com.hxhq.business.form.study;
import com.hxhq.business.domain.Study;
import com.hxhq.business.form.common.SignForm;
/**
* @author memory
*/
public class StudySaveForm {
/**
* 试验信息
*/
private Study study;
/**
* 签名信息
*/
private SignForm sign;
public Study getStudy() {
return study;
}
public void setStudy(Study study) {
this.study = study;
}
public SignForm getSign() {
return sign;
}
public void setSign(SignForm sign) {
this.sign = sign;
}
}

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

@ -3,6 +3,8 @@ package com.hxhq.business.service;
import java.util.List;
import com.hxhq.business.domain.StudyJcgj;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hxhq.business.enums.zykgl.JcgjlxEnum;
import com.hxhq.business.enums.zykgl.JcmcysEnum;
/**
* 试验-稽查轨迹Service接口
@ -20,4 +22,17 @@ public interface IStudyJcgjService extends IService
*/
public List<StudyJcgj> queryList(StudyJcgj studyJcgj);
/**
* 保存稽查轨迹信息
* @param studyId
* @param jcgjlx
* @param jcmcys
* @param jcmc
* @param jcnr
* @param qmrId
* @param qmrMc
* @param remark
*/
void saveInfo(Long studyId, JcgjlxEnum jcgjlx, JcmcysEnum jcmcys,String jcmc,String jcnr,Long qmrId,String qmrMc,String remark);
}

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

@ -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.study.StudySaveForm;
import com.hxhq.business.form.study.StudySearchForm;
/**
@ -22,4 +23,10 @@ public interface IStudyService extends IService
*/
public List<StudyListDto> queryList(StudySearchForm form);
/**
* 保存
* @param form
*/
void saveInfo(StudySaveForm form);
}

+ 33
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyJcgjServiceImpl.java View File

@ -3,7 +3,12 @@ package com.hxhq.business.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.business.domain.MjyJcgj;
import com.hxhq.business.enums.zykgl.JcgjlxEnum;
import com.hxhq.business.enums.zykgl.JcmcysEnum;
import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.StudyJcgjMapper;
import com.hxhq.business.domain.StudyJcgj;
@ -28,8 +33,34 @@ public class StudyJcgjServiceImpl extends ServiceImpl
@Override
public List<StudyJcgj> queryList(StudyJcgj studyJcgj)
{
QueryWrapper<StudyJcgj> queryWrapper = Wrappers.query();
if(studyJcgj.getStudyId()==null||studyJcgj.getStudyId().longValue()<0){
throw new ServiceException("试验id不能为空");
}
QueryWrapper<StudyJcgj> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("study_id",studyJcgj.getStudyId());
if(studyJcgj.getJcgjlx()!=null&&studyJcgj.getJcgjlx().intValue()>0){
queryWrapper.eq("jcgjlx",studyJcgj.getJcgjlx());
}
if (StringUtils.isNoneBlank(studyJcgj.getJcmc())) {
queryWrapper.and(p -> p.like("`jcmc`", studyJcgj.getJcmc())
.or().like("`jcnr`", studyJcgj.getJcmc()));
}
queryWrapper.orderByDesc("id");
return this.list(queryWrapper);
}
@Override
public void saveInfo(Long studyId, JcgjlxEnum jcgjlx, JcmcysEnum jcmcys, String jcmc, String jcnr, Long qmrId, String qmrMc,String remark) {
StudyJcgj info = new StudyJcgj();
info.setStudyId(studyId);
info.setJcgjlx(jcgjlx.getValue());
info.setJcmcys(jcmcys.getValue());
info.setJcmc(jcmc);
info.setJcnr(jcnr);
info.setQmrId(qmrId);
info.setQmrMc(qmrMc);
info.setRemark(remark);
save(info);
}
}

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

@ -1,17 +1,36 @@
package com.hxhq.business.service.impl;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.domain.MjyJcgj;
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.zykgl.JcgjlxEnum;
import com.hxhq.business.enums.zykgl.JcmcysEnum;
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.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.StringUtils;
import com.hxhq.common.security.utils.SecurityUtils;
import com.hxhq.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.StudyMapper;
import com.hxhq.business.domain.Study;
import com.hxhq.business.service.IStudyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
/**
* 试验Service业务层处理
@ -22,6 +41,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class StudyServiceImpl extends ServiceImpl<StudyMapper, Study> implements IStudyService
{
@Autowired
private IStudyJcgjService studyJcgjService;
@Autowired
private ISysUserService sysUserService;
/**
* 查询试验列表
*
@ -55,4 +78,77 @@ public class StudyServiceImpl extends ServiceImpl implements
return baseMapper.queryList(queryWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveInfo(StudySaveForm form) {
Study study = form.getStudy();
SignForm sign = form.getSign();
if(study.getId()==null){
//新增
save(study);
if(study.getStatus().equals(StudyStatusEnum.cg.getValue())){
Map<String, String> formData = new LinkedHashMap<>();
formData.put("暂存人", SecurityUtils.getNickName());
studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"暂存实验", JctUtil.formatStr(formData),null,null,null);
}else{
checkPassword(sign);
studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"创建实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark());
}
}else{
//修改
Study old = getById(study.getId());
if(!old.getStatus().equals(StudyStatusEnum.cg.getValue()) && study.getStatus().equals(StudyStatusEnum.cg.getValue())){
throw new ServiceException("当前状态不允许暂存");
}
if(!old.getStatus().equals(StudyStatusEnum.cg.getValue()) && !old.getStatus().equals(StudyStatusEnum.syz.getValue())){
throw new ServiceException("当前状态不允许修改");
}
List<StudyJcgj> jcgjList = new ArrayList<>();
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(old, study);
if (fieldChanges.size() > 0) {
for (ObjectCompareUtil.FieldChange fieldChange : fieldChanges) {
StudyJcgj jcgj = new StudyJcgj();
jcgj.setStudyId(study.getId());
jcgj.setJcgjlx(JcgjlxEnum.bj.getValue());
jcgj.setJcmc("修改试验");
jcgj.setJcmcys(JcmcysEnum.orange.getValue());
jcgj.setJcnr(fieldChange.toString());
if(study.getStatus().equals(StudyStatusEnum.syz.getValue())){
jcgj.setQmrId(SecurityUtils.getUserId());
jcgj.setQmrMc(SecurityUtils.getNickName());
jcgj.setRemark(sign.getRemark());
}
jcgjList.add(jcgj);
}
}
studyJcgjService.saveBatch(jcgjList);
if(study.getStatus().equals(StudyStatusEnum.cg.getValue())){
Map<String, String> formData = new LinkedHashMap<>();
formData.put("暂存人", SecurityUtils.getNickName());
studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"暂存实验", JctUtil.formatStr(formData),null,null,null);
}else {
checkPassword(sign);
if(old.getStatus().equals(StudyStatusEnum.cg.getValue())){
studyJcgjService.saveInfo(study.getId(), JcgjlxEnum.lc, JcmcysEnum.blue,"创建实验", null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),sign.getRemark());
}
}
updateById(study);
}
}
void checkPassword(SignForm sign){
if(sign==null){
throw new ServiceException("签名参数有误");
}
if(StringUtils.isBlank(sign.getQmrmm())){
throw new ServiceException("签名密码不能为空");
}
sysUserService.checkPassword(SecurityUtils.getLoginUser().getSysUser(),sign.getQmrmm(),false);
}
}

Loading…
Cancel
Save