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