update 功能安全中心成员-新增
This commit is contained in:
+6
@@ -23,4 +23,10 @@ public class SafetyCenterSubitemContactsService extends ServiceImpl<SafetyCenter
|
||||
List<String> idList = list.stream().map(SafetyCenterSubitemContacts::getId).collect(Collectors.toList());
|
||||
this.removeByIds(idList);
|
||||
}
|
||||
public List<SafetyCenterSubitemContacts> listBySubitemId(String subitemId){
|
||||
LambdaQueryWrapper<SafetyCenterSubitemContacts> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SafetyCenterSubitemContacts::getSubitemId,subitemId);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+53
-8
@@ -17,6 +17,7 @@ import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.functionalsafetycenter.mapper.SafetyCenterSubitemMapper;
|
||||
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitem;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -26,6 +27,7 @@ import javax.annotation.Resource;
|
||||
*@date 2024-06-12 15:13
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemMapper, SafetyCenterSubitem> {
|
||||
@Resource
|
||||
private SafetyCenterService safetyCenterService;
|
||||
@@ -48,12 +50,34 @@ public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemM
|
||||
}
|
||||
//判重,联系人是否重复
|
||||
List<SafetyCenterSubitemContacts> contactsList = safetyCenterSubitem.getContactsList();
|
||||
if (!contactsList.isEmpty()){
|
||||
List<String> collect = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||
if (collect.size() != contactsList.size()){
|
||||
throw new JeroBootException("企业联系人重复");
|
||||
if (contactsList.isEmpty()){
|
||||
throw new JeroBootException("企业联系人不能为空");
|
||||
}
|
||||
List<String> contactIdList = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||
if (contactIdList.size() != contactsList.size()){
|
||||
throw new JeroBootException("企业联系人重复");
|
||||
}
|
||||
//判断父级是否有所选企业和所选联系人
|
||||
Integer projectType = safetyCenter.getProjectType();
|
||||
if (SafetyCenterCommon.PROJECT_TYPE_3 != projectType){
|
||||
//判断企业
|
||||
String parentId = safetyCenter.getParentId();
|
||||
LambdaQueryWrapper<SafetyCenterSubitem> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(SafetyCenterSubitem::getProjectId,parentId);
|
||||
wrapper1.eq(SafetyCenterSubitem::getCompanyId,companyId);
|
||||
SafetyCenterSubitem parentCenterSubitem = this.getOne(wrapper);
|
||||
if (parentCenterSubitem == null){
|
||||
throw new JeroBootException("该成员单位无法添加到当前项目");
|
||||
}
|
||||
//判断联系人
|
||||
String parentCenterSubitemId = parentCenterSubitem.getId();
|
||||
List<SafetyCenterSubitemContacts> parentContactList = contactsService.listBySubitemId(parentCenterSubitemId);
|
||||
List<String> parentContactIdList = parentContactList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||
if (!parentContactIdList.containsAll(contactIdList)) {
|
||||
throw new JeroBootException("联系人无法添加到当前项目");
|
||||
}
|
||||
}
|
||||
//保存成员
|
||||
this.save(safetyCenterSubitem);
|
||||
//保存成员单位联系人
|
||||
String subitemId = safetyCenterSubitem.getId();
|
||||
@@ -84,10 +108,31 @@ public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemM
|
||||
}
|
||||
//判重,联系人是否重复
|
||||
List<SafetyCenterSubitemContacts> contactsList = safetyCenterSubitem.getContactsList();
|
||||
if (!contactsList.isEmpty()){
|
||||
List<String> collect = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||
if (collect.size() != contactsList.size()){
|
||||
throw new JeroBootException("企业联系人重复");
|
||||
if (contactsList.isEmpty()){
|
||||
throw new JeroBootException("企业联系人不能为空");
|
||||
}
|
||||
List<String> contactIdList = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||
if (contactIdList.size() != contactsList.size()){
|
||||
throw new JeroBootException("企业联系人重复");
|
||||
}
|
||||
//判断父级是否有所选企业和所选联系人
|
||||
Integer projectType = safetyCenter.getProjectType();
|
||||
if (SafetyCenterCommon.PROJECT_TYPE_3 != projectType){
|
||||
//判断企业
|
||||
String parentId = safetyCenter.getParentId();
|
||||
LambdaQueryWrapper<SafetyCenterSubitem> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(SafetyCenterSubitem::getProjectId,parentId);
|
||||
wrapper1.eq(SafetyCenterSubitem::getCompanyId,companyId);
|
||||
SafetyCenterSubitem parentCenterSubitem = this.getOne(wrapper);
|
||||
if (parentCenterSubitem == null){
|
||||
throw new JeroBootException("该成员单位无法添加到当前项目");
|
||||
}
|
||||
//判断联系人
|
||||
String parentCenterSubitemId = parentCenterSubitem.getId();
|
||||
List<SafetyCenterSubitemContacts> parentContactList = contactsService.listBySubitemId(parentCenterSubitemId);
|
||||
List<String> parentContactIdList = parentContactList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||
if (!parentContactIdList.containsAll(contactIdList)) {
|
||||
throw new JeroBootException("联系人无法添加到当前项目");
|
||||
}
|
||||
}
|
||||
this.updateById(safetyCenterSubitem);
|
||||
|
||||
Reference in New Issue
Block a user