|
|
@@ -12,6 +12,7 @@ import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.common.core.utils.StringUtils;
|
|
|
import com.xunmei.common.core.utils.bean.BeanUtils;
|
|
|
+import com.xunmei.common.core.vo.IdNameVo;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.core.question.QuestionSrcType;
|
|
|
@@ -31,7 +32,9 @@ import com.xunmei.core.safetyCheck.vo.regsiter.*;
|
|
|
import com.xunmei.system.api.Eto.RoleConditionEto;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.RemoteRoleService;
|
|
|
+import com.xunmei.system.api.RemoteUserService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import com.xunmei.system.api.model.LoginUser;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -73,6 +76,9 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
@Resource
|
|
|
RemoteOrgService remoteOrgService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ RemoteUserService remoteUserService;
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo appList(AppPageDto dto) {
|
|
|
Page<AppPageVo> page = dto.toPage();
|
|
|
@@ -443,7 +449,7 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
public Boolean grant(GrantDto dto) {
|
|
|
LambdaQueryWrapper<CoreSafetyTask> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(CoreSafetyTask::getPlanId, dto.getPlanId())
|
|
|
- .eq(CoreSafetyTask::getOrgId,dto.getBeCheckedOrgId())
|
|
|
+ .eq(CoreSafetyTask::getOrgId, dto.getBeCheckedOrgId())
|
|
|
.eq(CoreSafetyTask::getYmdDate, dto.getYmdDate());
|
|
|
List<CoreSafetyTask> tasks = baseMapper.selectList(wrapper);
|
|
|
Optional<CoreSafetyTask> taskOptional = tasks.stream().filter(t -> ObjectUtil.equal(t.getId(), dto.getTaskId())).findFirst();
|
|
|
@@ -454,16 +460,31 @@ public class SafetyCheckRegisterSericeImpl extends ServiceImpl<CoreSafetyTaskMap
|
|
|
if (ObjectUtil.equal(taskOptional.get().getStatus(), SafetyCheckTaskStatus.Completed.getValue())) {
|
|
|
throw new ServiceException("任务已完成");
|
|
|
}
|
|
|
-
|
|
|
Long loginUserId = SecurityUtils.getUserId();
|
|
|
+ if (ObjectUtil.isNotNull(dto.getUserId())) {
|
|
|
+ List<IdNameVo> roles = remoteUserService.getRoleInfoOfUser(dto.getUserId(), SecurityConstants.INNER);
|
|
|
+ if (CollectionUtil.isNotEmpty(roles)) {
|
|
|
+ LambdaQueryWrapper<CoreSafecheckPlanToRole> prWrapper = new LambdaQueryWrapper<>();
|
|
|
+ prWrapper.eq(CoreSafecheckPlanToRole::getPlanId, dto.getPlanId())
|
|
|
+ .select(CoreSafecheckPlanToRole::getRoleId);
|
|
|
+ List<Long> planRoles = coreSafecheckPlanToRoleMapper.selectList(prWrapper).stream()
|
|
|
+ .map(CoreSafecheckPlanToRole::getRoleId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollectionUtil.intersection(roles.stream().map(IdNameVo::getId).collect(Collectors.toList()), planRoles).size() > 0) {
|
|
|
+ throw new ServiceException("用户已在检查角色中,无需授权");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Long uncompletedCount = tasks.stream()
|
|
|
- .filter(t -> !ObjectUtil.equal(t.getStatus(), SafetyCheckTaskStatus.Completed.getValue()))
|
|
|
+ .filter(t -> !ObjectUtil.equal(t.getStatus(), SafetyCheckTaskStatus.Completed.getValue()) && ObjectUtil.isNull(t.getGrantUserId()))
|
|
|
.count();
|
|
|
Long selfCompletedCount = tasks.stream()
|
|
|
.filter(t -> ObjectUtil.equal(t.getStatus(), SafetyCheckTaskStatus.Completed.getValue()) && ObjectUtil.equal(t.getSubmitorId(), loginUserId))
|
|
|
.count();
|
|
|
if (uncompletedCount <= 1 && selfCompletedCount == 0) {
|
|
|
- throw new ServiceException("任务检查角色必须完成至少一次任务");
|
|
|
+ throw new ServiceException("至少完成一次任务");
|
|
|
}
|
|
|
|
|
|
LambdaUpdateWrapper<CoreSafetyTask> updateWrapper = new LambdaUpdateWrapper<>();
|