|
|
|
@ -1,13 +1,30 @@ |
|
|
|
package com.hxhq.business.service.impl; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
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.YqJcgj; |
|
|
|
import com.hxhq.business.enums.zykgl.JcgjlxEnum; |
|
|
|
import com.hxhq.business.enums.zykgl.JcmcysEnum; |
|
|
|
import com.hxhq.business.form.yq.YqForm; |
|
|
|
import com.hxhq.business.service.IYqJcgjService; |
|
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
|
import com.hxhq.common.core.exception.ServiceException; |
|
|
|
import com.hxhq.common.security.utils.SecurityUtils; |
|
|
|
import com.hxhq.system.api.domain.SysUser; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.hxhq.business.mapper.YqMapper; |
|
|
|
import com.hxhq.business.domain.Yq; |
|
|
|
import com.hxhq.business.service.IYqService; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
/** |
|
|
|
* 仪器管理Service业务层处理 |
|
|
|
@ -18,6 +35,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
@Service |
|
|
|
public class YqServiceImpl extends ServiceImpl<YqMapper, Yq> implements IYqService |
|
|
|
{ |
|
|
|
@Autowired |
|
|
|
private IYqJcgjService yqJcgjService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询仪器管理列表 |
|
|
|
* |
|
|
|
@ -31,4 +51,47 @@ public class YqServiceImpl extends ServiceImpl implements IYqServi |
|
|
|
return this.list(queryWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void addYq(YqForm yqForm) { |
|
|
|
Yq yq = new Yq(); |
|
|
|
BeanUtils.copyProperties(yqForm, yq); |
|
|
|
save(yq); |
|
|
|
yqJcgjService.saveJcgj(yq.getId(), JcgjlxEnum.bj.getValue(), "新增仪器", JcmcysEnum.blue.getValue(), null); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void updateYq(YqForm yqForm) { |
|
|
|
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser(); |
|
|
|
|
|
|
|
Yq yq = getById(yqForm.getId()); |
|
|
|
if(yq == null) { |
|
|
|
throw new ServiceException("仪器不存在或已删除"); |
|
|
|
} |
|
|
|
|
|
|
|
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(yq, yqForm); |
|
|
|
if (fieldChanges.size() == 0) { |
|
|
|
throw new SecurityException("你没有修改任何内容"); |
|
|
|
} |
|
|
|
BeanUtils.copyProperties(yqForm, yq); |
|
|
|
updateById(yq); |
|
|
|
|
|
|
|
// 稽查轨迹 |
|
|
|
List<YqJcgj> yqJcgjList = new ArrayList<>(); |
|
|
|
for (ObjectCompareUtil.FieldChange fieldChange : fieldChanges) { |
|
|
|
YqJcgj yqJcgj = new YqJcgj(); |
|
|
|
yqJcgj.setYqId(yq.getId()); |
|
|
|
yqJcgj.setJcgjlx(JcgjlxEnum.bj.getValue()); |
|
|
|
yqJcgj.setJcmc("编辑仪器"); |
|
|
|
yqJcgj.setQmyy("编辑"); |
|
|
|
yqJcgj.setJcmcys(JcmcysEnum.orange.getValue()); |
|
|
|
yqJcgj.setJcnr(fieldChange.toString()); |
|
|
|
yqJcgj.setQmrId(sysUser.getUserId()); |
|
|
|
yqJcgj.setQmrMc(sysUser.getNickName()); |
|
|
|
yqJcgjList.add(yqJcgj); |
|
|
|
} |
|
|
|
yqJcgjService.saveBatch(yqJcgjList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |