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());
|
List<String> idList = list.stream().map(SafetyCenterSubitemContacts::getId).collect(Collectors.toList());
|
||||||
this.removeByIds(idList);
|
this.removeByIds(idList);
|
||||||
}
|
}
|
||||||
|
public List<SafetyCenterSubitemContacts> listBySubitemId(String subitemId){
|
||||||
|
LambdaQueryWrapper<SafetyCenterSubitemContacts> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SafetyCenterSubitemContacts::getSubitemId,subitemId);
|
||||||
|
return this.list(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-6
@@ -17,6 +17,7 @@ import java.util.stream.Collectors;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.jero.functionalsafetycenter.mapper.SafetyCenterSubitemMapper;
|
import com.jero.functionalsafetycenter.mapper.SafetyCenterSubitemMapper;
|
||||||
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitem;
|
import com.jero.functionalsafetycenter.entity.SafetyCenterSubitem;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ import javax.annotation.Resource;
|
|||||||
*@date 2024-06-12 15:13
|
*@date 2024-06-12 15:13
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemMapper, SafetyCenterSubitem> {
|
public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemMapper, SafetyCenterSubitem> {
|
||||||
@Resource
|
@Resource
|
||||||
private SafetyCenterService safetyCenterService;
|
private SafetyCenterService safetyCenterService;
|
||||||
@@ -48,12 +50,34 @@ public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemM
|
|||||||
}
|
}
|
||||||
//判重,联系人是否重复
|
//判重,联系人是否重复
|
||||||
List<SafetyCenterSubitemContacts> contactsList = safetyCenterSubitem.getContactsList();
|
List<SafetyCenterSubitemContacts> contactsList = safetyCenterSubitem.getContactsList();
|
||||||
if (!contactsList.isEmpty()){
|
if (contactsList.isEmpty()){
|
||||||
List<String> collect = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
throw new JeroBootException("企业联系人不能为空");
|
||||||
if (collect.size() != contactsList.size()){
|
}
|
||||||
|
List<String> contactIdList = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||||
|
if (contactIdList.size() != contactsList.size()){
|
||||||
throw new JeroBootException("企业联系人重复");
|
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);
|
this.save(safetyCenterSubitem);
|
||||||
//保存成员单位联系人
|
//保存成员单位联系人
|
||||||
String subitemId = safetyCenterSubitem.getId();
|
String subitemId = safetyCenterSubitem.getId();
|
||||||
@@ -84,11 +108,32 @@ public class SafetyCenterSubitemService extends ServiceImpl<SafetyCenterSubitemM
|
|||||||
}
|
}
|
||||||
//判重,联系人是否重复
|
//判重,联系人是否重复
|
||||||
List<SafetyCenterSubitemContacts> contactsList = safetyCenterSubitem.getContactsList();
|
List<SafetyCenterSubitemContacts> contactsList = safetyCenterSubitem.getContactsList();
|
||||||
if (!contactsList.isEmpty()){
|
if (contactsList.isEmpty()){
|
||||||
List<String> collect = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
throw new JeroBootException("企业联系人不能为空");
|
||||||
if (collect.size() != contactsList.size()){
|
}
|
||||||
|
List<String> contactIdList = contactsList.stream().map(SafetyCenterSubitemContacts::getContactsId).distinct().collect(Collectors.toList());
|
||||||
|
if (contactIdList.size() != contactsList.size()){
|
||||||
throw new JeroBootException("企业联系人重复");
|
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);
|
this.updateById(safetyCenterSubitem);
|
||||||
//先删除之前保存的
|
//先删除之前保存的
|
||||||
|
|||||||
Reference in New Issue
Block a user