修改开始检测->选择项目,有问题待确认

This commit is contained in:
xiaofajia 2024-12-11 11:46:34 +08:00
parent 10ea5856b3
commit 5524a08201
3 changed files with 70 additions and 4 deletions

View File

@ -267,4 +267,18 @@ public class InspectionInfoController extends BaseController {
public CommonResult isExamine(){ public CommonResult isExamine(){
return success(inspectionInfoService.isExamine()); return success(inspectionInfoService.isExamine());
} }
/**
* 获取某个工单针对当前操作用户某个状态的项目们
*
* @author 小李
* @date 10:48 2024/12/11
* @param id 工单ID
* @param status 状态
**/
@GetMapping("/getWorkNodeByIdAndNow")
public CommonResult<?> getWorkNodeByIdAndNow(Long id, String status){
return success(inspectionInfoService.getWorkNodeByIdAndNow(id, status));
}
} }

View File

@ -109,4 +109,14 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
* @return * @return
*/ */
Boolean isExamine(); Boolean isExamine();
/**
* 获取某个工单针对当前操作用户某个状态的项目们
*
* @author 小李
* @date 10:48 2024/12/11
* @param id 工单ID
* @param status 状态
**/
Map<String, String> getWorkNodeByIdAndNow(Long id, String status);
} }

View File

@ -3,10 +3,7 @@ package cn.iocoder.yudao.module.inspection.service.impl;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
@ -57,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS; import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
/** /**
* 请填写功能名称Service业务层处理 * 请填写功能名称Service业务层处理
@ -99,6 +97,9 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
private InspectionSocket inspectionSocket; private InspectionSocket inspectionSocket;
@Resource @Resource
private RoleMapper roleMapper; private RoleMapper roleMapper;
@Resource
@Lazy
private DlInspectionProjectService projectService;
/** /**
* 查询请填写功能名称 * 查询请填写功能名称
@ -555,4 +556,45 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
} }
return false; return false;
} }
/**
* 获取某个工单针对当前操作用户某个状态的项目们
*
* @author 小李
* @date 10:48 2024/12/11
* @param id 工单ID
* @param status 状态
**/
@Override
public Map<String, String> getWorkNodeByIdAndNow(Long id, String status){
Long userId = SecurityFrameworkUtils.getLoginUserId();
List<UserRoleDO> roles = roleService.getByUserId(userId);
if (CollUtil.isEmpty(roles)){
throw exception0(500, "查询角色为空");
}
List<Long> roleIds = roles.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
List<InspectionWorkNode> workNodes = workNodeService.list(new LambdaQueryWrapper<InspectionWorkNode>()
.and(i ->
i.eq(InspectionWorkNode::getInspectionInfoId, id)
.in(InspectionWorkNode::getRoleId, roleIds)
.eq(InspectionWorkNode::getStatus, status)
));
if (CollUtil.isEmpty(workNodes)){
throw exception0(500, "查询节点为空");
}
List<String> projectIds = workNodes.stream().map(InspectionWorkNode::getProjectId).collect(Collectors.toList());
if (CollUtil.isEmpty(projectIds)){
throw exception0(500, "查询项目时为空");
}
List<DlInspectionProject> projects = projectService.listByIds(projectIds);
if (CollUtil.isEmpty(projects)){
throw exception0(500, "查询项目时为空");
}
Map<String, String> map = projects.stream().collect(Collectors.toMap(DlInspectionProject::getId, DlInspectionProject::getProjectName));
Map<String, String> result = new HashMap<>();
workNodes.forEach(item -> {
result.put(item.getId(), map.get(item.getProjectId()));
});
return result;
}
} }