|
@@ -1,17 +1,24 @@
|
|
|
package cn.iocoder.yudao.module.iscs.service.sop;
|
|
package cn.iocoder.yudao.module.iscs.service.sop;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopUserPageReqVO;
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopUserPageReqVO;
|
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopUserSaveReqVO;
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.sop.vo.SopUserSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopUserDO;
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.sop.SopUserDO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.sop.SopUserMapper;
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.sop.SopUserMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.attribute.AttributeDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.attribute.AttributeService;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* SOP用户 Service 实现类
|
|
* SOP用户 Service 实现类
|
|
@@ -24,15 +31,50 @@ public class SopUserServiceImpl extends ServiceImpl<SopUserMapper, SopUserDO> im
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private SopUserMapper sopUserMapper;
|
|
private SopUserMapper sopUserMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AttributeService attributeService;
|
|
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
@Override
|
|
@Override
|
|
|
- public Long createSopUser(SopUserSaveReqVO createReqVO) {
|
|
|
|
|
- // 插入
|
|
|
|
|
- SopUserDO sopUser = BeanUtils.toBean(createReqVO, SopUserDO.class);
|
|
|
|
|
- sopUserMapper.insert(sopUser);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public Boolean createSopUser(List<SopUserSaveReqVO> list) {
|
|
|
|
|
+ Assert.isFalse(list.isEmpty(), "请输入要新增的人员!");
|
|
|
|
|
+ // 检查是否存在重复人员(共锁人/上锁人)
|
|
|
|
|
+ AttributeDO jtcolocker = attributeService.getAttributeByKey("role.jtcolocker");
|
|
|
|
|
+ AttributeDO jtlocker = attributeService.getAttributeByKey("role.jtlocker");
|
|
|
|
|
+ Set<Long> collect = list.stream()
|
|
|
|
|
+ .filter(o -> o.getUserId() != null && o.getUserRole().equals(jtcolocker.getSysAttrValue()))
|
|
|
|
|
+ .map(SopUserSaveReqVO::getUserId).collect(Collectors.toSet());
|
|
|
|
|
+ Assert.isFalse(collect.size() < list.size(), "存在重复共锁人员信息!");
|
|
|
|
|
+ Set<Long> collect1 = list.stream()
|
|
|
|
|
+ .filter(o -> o.getUserId() != null && o.getUserRole().equals(jtlocker.getSysAttrValue()))
|
|
|
|
|
+ .map(SopUserSaveReqVO::getUserId).collect(Collectors.toSet());
|
|
|
|
|
+ Assert.isFalse(collect1.size() < list.size(), "存在重复上锁人员信息!");
|
|
|
|
|
+ for (SopUserSaveReqVO vo : list) {
|
|
|
|
|
+ Assert.notNull(vo.getUserId(), "请告知我userId");
|
|
|
|
|
+ Assert.notNull(vo.getUserType(), "请告知我用户类型");
|
|
|
|
|
+ Assert.notNull(vo.getUserRole(), "请告知我用户角色");
|
|
|
|
|
+ if (vo.getUserRole().equals(jtcolocker.getSysAttrValue())) {
|
|
|
|
|
+ // 检查共锁人员重复
|
|
|
|
|
+ List<SopUserDO> list1 = list(Wrappers.<SopUserDO>lambdaQuery()
|
|
|
|
|
+ .eq(SopUserDO::getUserId, vo.getUserId())
|
|
|
|
|
+ .eq(SopUserDO::getUserRole, jtcolocker.getSysAttrValue())
|
|
|
|
|
+ .eq(SopUserDO::getSopId, vo.getSopId()));
|
|
|
|
|
+ Assert.isTrue(list1.isEmpty(), "存在重复共锁人!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (vo.getUserRole().equals(jtlocker.getSysAttrValue())) {
|
|
|
|
|
+ // 检查上锁人员重复
|
|
|
|
|
+ List<SopUserDO> list2 = list(Wrappers.<SopUserDO>lambdaQuery()
|
|
|
|
|
+ .eq(SopUserDO::getUserId, vo.getUserId())
|
|
|
|
|
+ .eq(SopUserDO::getUserRole, jtlocker.getSysAttrValue())
|
|
|
|
|
+ .eq(SopUserDO::getSopId, vo.getSopId()));
|
|
|
|
|
+ Assert.isTrue(list2.isEmpty(), "存在重复上锁人!");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 插入
|
|
|
|
|
+ SopUserDO sopUser = BeanUtils.toBean(vo, SopUserDO.class);
|
|
|
|
|
+ sopUserMapper.insert(sopUser);
|
|
|
|
|
+ }
|
|
|
// 返回
|
|
// 返回
|
|
|
- return sopUser.getId();
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -43,10 +85,10 @@ public class SopUserServiceImpl extends ServiceImpl<SopUserMapper, SopUserDO> im
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void deleteSopUserListByIds(List<Long> ids) {
|
|
|
|
|
|
|
+ public void deleteSopUserListByIds(List<Long> ids) {
|
|
|
// 删除
|
|
// 删除
|
|
|
- sopUserMapper.deleteByIds(ids);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ sopUserMapper.physicalDeleteByIds(ids);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public SopUserDO getSopUser(Long id) {
|
|
public SopUserDO getSopUser(Long id) {
|