|
|
@@ -1,14 +1,17 @@
|
|
|
package com.railway.business.safetool.service.impl;
|
|
|
|
|
|
+import com.railway.business.safetool.domain.BaseSafetyTool;
|
|
|
import com.railway.business.safetool.domain.SecScheduled;
|
|
|
import com.railway.business.safetool.domain.SecScheduledTool;
|
|
|
import com.railway.business.safetool.domain.vo.SecScheduledCountVo;
|
|
|
import com.railway.business.safetool.domain.vo.SecScheduledListParmVo;
|
|
|
import com.railway.business.safetool.domain.vo.SecScheduledToolListVo;
|
|
|
import com.railway.business.safetool.domain.vo.SecScheduledToolVo;
|
|
|
+import com.railway.business.safetool.mapper.BaseSafetyToolMapper;
|
|
|
import com.railway.business.safetool.mapper.SecScheduledMapper;
|
|
|
import com.railway.business.safetool.mapper.SecScheduledToolMapper;
|
|
|
import com.railway.business.safetool.service.ISecScheduledService;
|
|
|
+import com.railway.common.core.domain.entity.SysUser;
|
|
|
import com.railway.common.utils.SecurityUtils;
|
|
|
import com.railway.common.utils.bean.BeanUtils;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -31,11 +34,14 @@ public class SecScheduledServiceImpl implements ISecScheduledService {
|
|
|
|
|
|
private final SecScheduledMapper secScheduledMapper;
|
|
|
private final SecScheduledToolMapper secScheduledToolMapper;
|
|
|
+ private final BaseSafetyToolMapper safetyToolMapper;
|
|
|
|
|
|
public SecScheduledServiceImpl(SecScheduledMapper secScheduledMapper,
|
|
|
- SecScheduledToolMapper secScheduledToolMapper) {
|
|
|
+ SecScheduledToolMapper secScheduledToolMapper,
|
|
|
+ BaseSafetyToolMapper safetyToolMapper) {
|
|
|
this.secScheduledMapper = secScheduledMapper;
|
|
|
this.secScheduledToolMapper = secScheduledToolMapper;
|
|
|
+ this.safetyToolMapper = safetyToolMapper;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -133,7 +139,12 @@ public class SecScheduledServiceImpl implements ISecScheduledService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int addTools(SecScheduledToolVo toolsVo) {
|
|
|
+ public int addTools(SecScheduledToolVo toolsVo) throws Exception {
|
|
|
+ BaseSafetyTool safetyTool = safetyToolMapper.getInfo(toolsVo.getToolId());
|
|
|
+ SysUser sysUser = SecurityUtils.getLoginUser().getUser();
|
|
|
+ if (!safetyTool.getDeptId().equals(sysUser.getDeptId())) {
|
|
|
+ throw new Exception("该工具归属“" + safetyTool.getDeptName() + "”管理,请检查后重新操作");
|
|
|
+ }
|
|
|
|
|
|
SecScheduledTool secScheduledTool = new SecScheduledTool();
|
|
|
secScheduledTool.setScheduledId(toolsVo.getScheduledId());
|
|
|
@@ -142,7 +153,7 @@ public class SecScheduledServiceImpl implements ISecScheduledService {
|
|
|
if (secScheduledToolMapper.check(secScheduledTool) == 0) {
|
|
|
return secScheduledToolMapper.insert(secScheduledTool);
|
|
|
} else {
|
|
|
- return 0;
|
|
|
+ throw new Exception("该工具已经添加到其他计划中,请删除后重新操作");
|
|
|
}
|
|
|
|
|
|
}
|