|
@@ -91,6 +91,7 @@ public class SysDingGroupServiceImpl extends ServiceImpl<SysDingGroupMapper, Sys
|
|
|
if (!CollectionUtils.isEmpty(sysDingGroupIdList)) {
|
|
|
List<Long> dbRoleIdList = sysDingObjService.list(new QueryWrapper<SysDingObj>()
|
|
|
.lambda()
|
|
|
+ .eq(SysDingObj::getType, DingObjTypeEnum.DING)
|
|
|
.in(SysDingObj::getDingGroupId, sysDingGroupIdList))
|
|
|
.stream()
|
|
|
.map(SysDingObj::getRoleId).distinct().collect(Collectors.toList());
|
|
@@ -110,14 +111,12 @@ public class SysDingGroupServiceImpl extends ServiceImpl<SysDingGroupMapper, Sys
|
|
|
String supplierName = sysSupplier.getName();
|
|
|
String serviceUnitName = tbServiceUnit.getName();
|
|
|
|
|
|
- String roleNames = sysRoleService.list(new QueryWrapper<SysRole>()
|
|
|
- .lambda()
|
|
|
- .in(SysRole::getId))
|
|
|
+ String roleNames = sysRoleService.listByIds(alreadyRoleIdList)
|
|
|
.stream()
|
|
|
.map(SysRole::getName)
|
|
|
.collect(Collectors.joining(","));
|
|
|
|
|
|
- String error = String.format("新增失败,服务单元[%s],供应商[%s],使用考勤对象为[%s] 的考勤组设置已经存在", serviceUnitName, supplierName, roleNames);
|
|
|
+ String error = String.format("新增失败,服务单元[%s],供应商[%s],适用考勤对象为[%s] 的考勤组设置已经存在", serviceUnitName, supplierName, roleNames);
|
|
|
throw ExceptionResultEnum.ERROR.exception(error);
|
|
|
}
|
|
|
}
|
|
@@ -129,7 +128,9 @@ public class SysDingGroupServiceImpl extends ServiceImpl<SysDingGroupMapper, Sys
|
|
|
sysDingGroupEntity.setCreateTime(System.currentTimeMillis());
|
|
|
sysDingGroupEntity.setEnable(true);
|
|
|
this.saveOrUpdate(sysDingGroupEntity);
|
|
|
- sysDingGroup.getDingObjs().forEach(e -> {
|
|
|
+ sysDingGroupRoleResultList.forEach(e -> {
|
|
|
+ // 重置数组id
|
|
|
+ e.setId(null);
|
|
|
e.setDingGroupId(sysDingGroupEntity.getId());
|
|
|
sysDingObjService.save(e);
|
|
|
});
|
|
@@ -145,8 +146,55 @@ public class SysDingGroupServiceImpl extends ServiceImpl<SysDingGroupMapper, Sys
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void update(SysDingGroupResult sysDingGroup) {
|
|
|
-
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ Long supplierId = sysDingGroup.getSupplierId();
|
|
|
+ Long serviceUnitId = sysDingGroup.getServiceId();
|
|
|
+
|
|
|
+ // 编辑校验
|
|
|
+ List<Long> sysDingGroupIdList = this.list(new QueryWrapper<SysDingGroup>().lambda()
|
|
|
+ .eq(SysDingGroup::getServiceId, serviceUnitId)
|
|
|
+ .eq(SysDingGroup::getSupplierId, supplierId)
|
|
|
+ .ne(SysDingGroup::getId, sysDingGroup.getId()))
|
|
|
+ .stream()
|
|
|
+ .map(BaseEntity::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Long> roleIdList = sysDingGroup.getDingObjs().stream()
|
|
|
+ .filter(e -> DingObjTypeEnum.DING.equals(e.getType()))
|
|
|
+ .map(SysDingObj::getRoleId).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(sysDingGroupIdList)) {
|
|
|
+ List<Long> dbRoleIdList = sysDingObjService.list(new QueryWrapper<SysDingObj>()
|
|
|
+ .lambda()
|
|
|
+ .eq(SysDingObj::getType, DingObjTypeEnum.DING)
|
|
|
+ .in(SysDingObj::getDingGroupId, sysDingGroupIdList))
|
|
|
+ .stream()
|
|
|
+ .map(SysDingObj::getRoleId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> alreadyRoleIdList = roleIdList.stream().filter(dbRoleIdList::contains).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(alreadyRoleIdList)) {
|
|
|
+ // 已存在的角色id集合
|
|
|
+ SysSupplier sysSupplier = sysSupplierService.getById(supplierId);
|
|
|
+ if (Objects.isNull(sysSupplier)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("供应商不存在");
|
|
|
+ }
|
|
|
+ TBService tbServiceUnit = tbServiceService.getById(serviceUnitId);
|
|
|
+ if (Objects.isNull(tbServiceUnit)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("服务单元不存在");
|
|
|
+ }
|
|
|
+ String supplierName = sysSupplier.getName();
|
|
|
+ String serviceUnitName = tbServiceUnit.getName();
|
|
|
+
|
|
|
+ String roleNames = sysRoleService.listByIds(alreadyRoleIdList)
|
|
|
+ .stream()
|
|
|
+ .map(SysRole::getName)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ String error = String.format("编辑失败,服务单元[%s],供应商[%s],适用考勤对象为[%s] 的考勤组设置已经存在", serviceUnitName, supplierName, roleNames);
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
sysDingGroup.setUpdateId(sysUser.getId());
|
|
|
sysDingGroup.setUpdateTime(System.currentTimeMillis());
|
|
|
this.saveOrUpdate(sysDingGroup);
|
|
@@ -181,5 +229,4 @@ public class SysDingGroupServiceImpl extends ServiceImpl<SysDingGroupMapper, Sys
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|