feat: 联络人管理增加重复联络人限制
This commit is contained in:
+157
-151
@@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* @Description: 联络人管理
|
* @Description: 联络人管理
|
||||||
* @Author: jero-boot
|
* @Author: jero-boot
|
||||||
* @Date: 2023-10-13
|
* @Date: 2023-10-13
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -37,8 +37,8 @@ import java.util.stream.Collectors;
|
|||||||
@Transactional(rollbackFor = JeroBootException.class)
|
@Transactional(rollbackFor = JeroBootException.class)
|
||||||
public class LawsContactManageServiceImpl extends ServiceImpl<LawsContactManageMapper, LawsContactManage> implements ILawsContactManageService {
|
public class LawsContactManageServiceImpl extends ServiceImpl<LawsContactManageMapper, LawsContactManage> implements ILawsContactManageService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysUserService sysUserService;
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
@@ -51,50 +51,50 @@ public class LawsContactManageServiceImpl extends ServiceImpl<LawsContactManageM
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<LawsContactManage> queryPage(LawsContactManage lawsContactManage, Integer pageNo, Integer pageSize,
|
public IPage<LawsContactManage> queryPage(LawsContactManage lawsContactManage, Integer pageNo, Integer pageSize,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
QueryWrapper<LawsContactManage> queryWrapper = QueryGenerator.initQueryWrapper(lawsContactManage, req.getParameterMap());
|
QueryWrapper<LawsContactManage> queryWrapper = QueryGenerator.initQueryWrapper(lawsContactManage, req.getParameterMap());
|
||||||
if (StringUtils.isNotBlank(lawsContactManage.getContact())){
|
if (StringUtils.isNotBlank(lawsContactManage.getContact())) {
|
||||||
List<SysUser> userList = sysUserService.list(new LambdaQueryWrapper<SysUser>()
|
List<SysUser> userList = sysUserService.list(new LambdaQueryWrapper<SysUser>()
|
||||||
.like(SysUser::getRealname, lawsContactManage.getContact()));
|
.like(SysUser::getRealname, lawsContactManage.getContact()));
|
||||||
if (userList.isEmpty()){
|
if (userList.isEmpty()) {
|
||||||
return new Page<>(pageNo, pageSize);
|
return new Page<>(pageNo, pageSize);
|
||||||
}
|
}
|
||||||
queryWrapper.in("contact_id", userList.stream().map(SysUser::getId).collect(Collectors.toList()));
|
queryWrapper.in("contact_id", userList.stream().map(SysUser::getId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
Page<LawsContactManage> page = new Page<>(pageNo, pageSize);
|
Page<LawsContactManage> page = new Page<>(pageNo, pageSize);
|
||||||
return page(page, queryWrapper);
|
return page(page, queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
*
|
*
|
||||||
* @param lawsContactManage
|
* @param lawsContactManage
|
||||||
* @param pageNo
|
* @param pageNo
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @param req
|
* @param req
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<LawsContactManage> queryPageMerge(LawsContactManage lawsContactManage, Integer pageNo, Integer pageSize,
|
public IPage<LawsContactManage> queryPageMerge(LawsContactManage lawsContactManage, Integer pageNo, Integer pageSize,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
QueryWrapper<LawsContactManage> queryWrapper = QueryGenerator.initQueryWrapper(lawsContactManage, req.getParameterMap());
|
QueryWrapper<LawsContactManage> queryWrapper = QueryGenerator.initQueryWrapper(lawsContactManage, req.getParameterMap());
|
||||||
queryWrapper.select("group_concat(id) as id, group_concat(create_by) as create_by, max(create_time) as create_time, " +
|
queryWrapper.select("group_concat(id) as id, group_concat(create_by) as create_by, max(create_time) as create_time, " +
|
||||||
"group_concat(update_by) as update_by, max(update_time) as update_time, group_concat(org_code) as org_code," +
|
"group_concat(update_by) as update_by, max(update_time) as update_time, group_concat(org_code) as org_code," +
|
||||||
" group_concat(depart_name) as depart_name, group_concat(depart_id) as depart_id, " +
|
" group_concat(depart_name) as depart_name, group_concat(depart_id) as depart_id, " +
|
||||||
"group_concat(engineer_id) as engineer_id, group_concat(leader_id) as leader_id,contact_id ");
|
"group_concat(engineer_id) as engineer_id, group_concat(leader_id) as leader_id,contact_id ");
|
||||||
String contactId = "contact_id";
|
String contactId = "contact_id";
|
||||||
if (StringUtils.isNotBlank(lawsContactManage.getContact())){
|
if (StringUtils.isNotBlank(lawsContactManage.getContact())) {
|
||||||
List<SysUser> userList = sysUserService.list(new LambdaQueryWrapper<SysUser>()
|
List<SysUser> userList = sysUserService.list(new LambdaQueryWrapper<SysUser>()
|
||||||
.like(SysUser::getRealname, lawsContactManage.getContact()));
|
.like(SysUser::getRealname, lawsContactManage.getContact()));
|
||||||
if (userList.isEmpty()){
|
if (userList.isEmpty()) {
|
||||||
return new Page<>(pageNo, pageSize);
|
return new Page<>(pageNo, pageSize);
|
||||||
}
|
}
|
||||||
queryWrapper.in(contactId, userList.stream().map(SysUser::getId).collect(Collectors.toList()));
|
queryWrapper.in(contactId, userList.stream().map(SysUser::getId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
queryWrapper.groupBy(contactId);
|
queryWrapper.groupBy(contactId);
|
||||||
Page<LawsContactManage> page = new Page<>(pageNo, pageSize);
|
Page<LawsContactManage> page = new Page<>(pageNo, pageSize);
|
||||||
return page(page, queryWrapper);
|
return page(page, queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表查询
|
* 列表查询
|
||||||
@@ -108,24 +108,30 @@ public class LawsContactManageServiceImpl extends ServiceImpl<LawsContactManageM
|
|||||||
return list(QueryGenerator.initQueryWrapper(lawsContactManage, req.getParameterMap()));
|
return list(QueryGenerator.initQueryWrapper(lawsContactManage, req.getParameterMap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
* @param lawsContactManage
|
* @param lawsContactManage
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void add(LawsContactManage lawsContactManage) {
|
public void add(LawsContactManage lawsContactManage) {
|
||||||
// 验证 部门名称+标准化工程师+联络人+部门联络人主管级领导唯一
|
// 验证 部门名称+标准化工程师+联络人+部门联络人主管级领导唯一
|
||||||
LambdaQueryWrapper<LawsContactManage> queryLawsContactManage = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<LawsContactManage> queryLawsContactManage = new LambdaQueryWrapper<>();
|
||||||
queryLawsContactManage.eq(LawsContactManage::getDepartId,lawsContactManage.getDepartId());
|
queryLawsContactManage.eq(LawsContactManage::getDepartId, lawsContactManage.getDepartId());
|
||||||
queryLawsContactManage.eq(LawsContactManage::getEngineerId,lawsContactManage.getEngineerId());
|
queryLawsContactManage.eq(LawsContactManage::getContactId, lawsContactManage.getContactId());
|
||||||
queryLawsContactManage.eq(LawsContactManage::getContactId,lawsContactManage.getContactId());
|
queryLawsContactManage.eq(LawsContactManage::getLeaderId, lawsContactManage.getLeaderId());
|
||||||
queryLawsContactManage.eq(LawsContactManage::getLeaderId,lawsContactManage.getLeaderId());
|
long l = count(queryLawsContactManage);
|
||||||
long l = count(queryLawsContactManage);
|
if (l > 0) {
|
||||||
if(l > 0){
|
throw new JeroBootException("部门和联络人匹配关系已存在,请重新选择");
|
||||||
throw new JeroBootException("部门名称+标准化工程师+联络人+部门联络人主管级领导已存在");
|
}
|
||||||
}
|
|
||||||
|
queryLawsContactManage.clear();
|
||||||
|
queryLawsContactManage.eq(LawsContactManage::getContactId, lawsContactManage.getContactId());
|
||||||
|
long n = count(queryLawsContactManage);
|
||||||
|
if (n > 0) {
|
||||||
|
throw new JeroBootException("已存在相同的联络人");
|
||||||
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
lawsContactManage.setCreateTime(now);
|
lawsContactManage.setCreateTime(now);
|
||||||
@@ -133,114 +139,114 @@ public class LawsContactManageServiceImpl extends ServiceImpl<LawsContactManageM
|
|||||||
save(lawsContactManage);
|
save(lawsContactManage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新
|
* 更新
|
||||||
*
|
*
|
||||||
* @param lawsContactManage
|
* @param lawsContactManage
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void editById(LawsContactManage lawsContactManage) {
|
public void editById(LawsContactManage lawsContactManage) {
|
||||||
// 验证 部门名称+标准化工程师+联络人+部门联络人主管级领导唯一
|
// 验证 部门名称+标准化工程师+联络人+部门联络人主管级领导唯一
|
||||||
LambdaQueryWrapper<LawsContactManage> queryLawsContactManage = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<LawsContactManage> queryLawsContactManage = new LambdaQueryWrapper<>();
|
||||||
queryLawsContactManage.eq(LawsContactManage::getDepartId,lawsContactManage.getDepartId());
|
queryLawsContactManage.eq(LawsContactManage::getDepartId, lawsContactManage.getDepartId());
|
||||||
queryLawsContactManage.eq(LawsContactManage::getEngineerId,lawsContactManage.getEngineerId());
|
queryLawsContactManage.eq(LawsContactManage::getEngineerId, lawsContactManage.getEngineerId());
|
||||||
queryLawsContactManage.eq(LawsContactManage::getContactId,lawsContactManage.getContactId());
|
queryLawsContactManage.eq(LawsContactManage::getContactId, lawsContactManage.getContactId());
|
||||||
queryLawsContactManage.eq(LawsContactManage::getLeaderId,lawsContactManage.getLeaderId());
|
queryLawsContactManage.eq(LawsContactManage::getLeaderId, lawsContactManage.getLeaderId());
|
||||||
queryLawsContactManage.ne(LawsContactManage::getId,lawsContactManage.getId());
|
queryLawsContactManage.ne(LawsContactManage::getId, lawsContactManage.getId());
|
||||||
long l = count(queryLawsContactManage);
|
long l = count(queryLawsContactManage);
|
||||||
if(l > 0){
|
if (l > 0) {
|
||||||
throw new JeroBootException("部门名称+标准化工程师+联络人+部门联络人主管级领导已存在");
|
throw new JeroBootException("部门名称+标准化工程师+联络人+部门联络人主管级领导已存在");
|
||||||
}
|
}
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
lawsContactManage.setUpdateTime(now);
|
lawsContactManage.setUpdateTime(now);
|
||||||
saveOrUpdate(lawsContactManage);
|
saveOrUpdate(lawsContactManage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(String id) {
|
public void deleteById(String id) {
|
||||||
removeById(id);
|
removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
*
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteByIds(List<String> ids) {
|
public void deleteByIds(List<String> ids) {
|
||||||
removeByIds(ids);
|
removeByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询
|
* 通过id查询
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LawsContactManage queryById(String id) {
|
public LawsContactManage queryById(String id) {
|
||||||
return getById(id);
|
return getById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String findContactUserByDept(String deptId) {
|
public String findContactUserByDept(String deptId) {
|
||||||
LambdaQueryWrapper<LawsContactManage> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<LawsContactManage> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(LawsContactManage::getDepartId, deptId);
|
wrapper.eq(LawsContactManage::getDepartId, deptId);
|
||||||
List<LawsContactManage> list = list(wrapper);
|
List<LawsContactManage> list = list(wrapper);
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
String contactUserId = list.get(0).getContactId();
|
String contactUserId = list.get(0).getContactId();
|
||||||
SysUser user = sysUserService.getById(contactUserId);
|
SysUser user = sysUserService.getById(contactUserId);
|
||||||
// 判断用户是否有效
|
// 判断用户是否有效
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
log.info("部门{}的联络人{}已经被删除", deptId, contactUserId);
|
log.info("部门{}的联络人{}已经被删除", deptId, contactUserId);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return contactUserId;
|
return contactUserId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String findStandardEngineerByDept(String deptId) {
|
public String findStandardEngineerByDept(String deptId) {
|
||||||
LambdaQueryWrapper<LawsContactManage> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<LawsContactManage> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(LawsContactManage::getDepartId, deptId);
|
wrapper.eq(LawsContactManage::getDepartId, deptId);
|
||||||
List<LawsContactManage> list = list(wrapper);
|
List<LawsContactManage> list = list(wrapper);
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
String engineerId = list.get(0).getEngineerId();
|
String engineerId = list.get(0).getEngineerId();
|
||||||
SysUser user = sysUserService.getById(engineerId);
|
SysUser user = sysUserService.getById(engineerId);
|
||||||
// 判断用户是否有效
|
// 判断用户是否有效
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
log.info("部门{}的联络人{}已经被删除", deptId, engineerId);
|
log.info("部门{}的联络人{}已经被删除", deptId, engineerId);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return engineerId;
|
return engineerId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LawsContactManage> queryByDepartIds(String deptIds) {
|
public List<LawsContactManage> queryByDepartIds(String deptIds) {
|
||||||
List<LawsContactManage> lawsContactManageList = new ArrayList<>();
|
List<LawsContactManage> lawsContactManageList = new ArrayList<>();
|
||||||
if (StringUtils.isNotBlank(deptIds)){
|
if (StringUtils.isNotBlank(deptIds)) {
|
||||||
List<String> departIdList = Arrays.asList(deptIds.split(","));
|
List<String> departIdList = Arrays.asList(deptIds.split(","));
|
||||||
lawsContactManageList = list(new LambdaQueryWrapper<LawsContactManage>()
|
lawsContactManageList = list(new LambdaQueryWrapper<LawsContactManage>()
|
||||||
.in(LawsContactManage::getDepartId, departIdList));
|
.in(LawsContactManage::getDepartId, departIdList));
|
||||||
for (LawsContactManage lawsContactManage : lawsContactManageList) {
|
for (LawsContactManage lawsContactManage : lawsContactManageList) {
|
||||||
lawsContactManage.setContactIdDictText(sysUserService.dictByIdsOrUserNames(lawsContactManage.getContactId(), ""));
|
lawsContactManage.setContactIdDictText(sysUserService.dictByIdsOrUserNames(lawsContactManage.getContactId(), ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lawsContactManageList;
|
return lawsContactManageList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user