Compare commits

..

3 Commits

6 changed files with 141 additions and 33 deletions

View File

@@ -28,13 +28,13 @@ public interface SimulationDemandMapper extends BaseMapper<SimulationDemand> {
List<SpdmDemandVo> getDemandList(@Param("tenantId") Long tenantId,@Param("req") SpdmDemandListReq req);
List<SpdmDemandVo> getDemandListNoPermission(@Param("req") SpdmDemandListReq req);
List<SpdmDemandVo> getDemandListNoPermission(@Param("tenantId") Long tenantId, @Param("req") SpdmDemandListReq req);
List<SpdmDemandMemberVo> getMemberList(@Param("demandIdList") List<String> demandIdList, @Param("memberType") Integer memberType);
SpdmDemandVo getDemandByName(@Param("tenantId") Long tenantId,@Param("demandName") String demandName);
SpdmDemandVo getDemandByNameNoPermission(@Param("demandName") String demandName);
SpdmDemandVo getDemandByNameNoPermission(@Param("tenantId") Long tenantId,@Param("demandName") String demandName);
List<SpdmDemandExtraVo> getDemandExtraList(@Param("demandIdList") List<String> demandIdList);

View File

@@ -218,6 +218,10 @@ public class SpdmNewTaskVo extends BaseEntity {
private String phaseName;
private String machineName;
private String workspaceName;
private String disciplineName;
private String imageFileId = "";

View File

@@ -165,4 +165,17 @@ public class SpdmTaskDetailVo extends BaseEntity {
* 军令状时间
*/
private String commitmentDeadline;
private String discipline;
private String tag1Code;
private String tag2Code;
private String tag3Code;
private String tag4Code;
private String tag5Code;
private String tag6Code;
private String tag7Code;
private String tag8Code;
private String tag9Code;
private String tag10Code;
}

View File

@@ -623,14 +623,22 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
}
List<SpdmDemandMemberVo> eachDemandMemberList;
List<String> nodeIdList = new ArrayList<>();
List<String> projectIdList = demandList.stream().map(SpdmDemandVo::getProjectId).toList();
List<String> projectIdList = demandList.stream().map(SpdmDemandVo::getProjectId).filter(StringUtils::isNotBlank).toList();
List<String> phaseIdList = demandList.stream().map(SpdmDemandVo::getPhaseId).filter(StringUtils::isNotBlank).toList();
List<String> machineIdList = demandList.stream().map(SpdmDemandVo::getMachineId).filter(StringUtils::isNotBlank).toList();
List<String> workspaceIdList = demandList.stream().map(SpdmDemandVo::getWorkspaceId).filter(StringUtils::isNotBlank).toList();
if (CollectionUtils.isNotEmpty(projectIdList)) {
nodeIdList.addAll(projectIdList);
}
List<String> phaseIdList = demandList.stream().map(SpdmDemandVo::getPhaseId).toList();
if (CollectionUtils.isNotEmpty(phaseIdList)) {
nodeIdList.addAll(phaseIdList);
}
if (CollectionUtils.isNotEmpty(machineIdList)) {
nodeIdList.addAll(machineIdList);
}
if (CollectionUtils.isNotEmpty(workspaceIdList)) {
nodeIdList.addAll(workspaceIdList);
}
Map<String, List<SpdmNodeVo>> nodeMap = Map.of();
if (CollectionUtils.isNotEmpty(nodeIdList)) {
List<SpdmNodeVo> nodeList = nodeMapper.getNodeListByIds(nodeIdList);
@@ -1206,7 +1214,7 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
req.setCreateTime(curDateStr);
req.setUuid(RandomUtil.generateString(32));
SpdmDemandVo demandByName = mapper.getDemandByNameNoPermission(req.getDemandName());
SpdmDemandVo demandByName = mapper.getDemandByNameNoPermission(tenantId,req.getDemandName());
if (ObjectUtils.isNotEmpty(demandByName)) {
return SdmResponse.failed("需求名称:" + demandByName.getDemandName() + "已存在,请修改");
}
@@ -1719,9 +1727,10 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
@Override
public SdmResponse listNoPermission(SpdmDemandListReq req) {
Long tenantId = ThreadLocalContext.getTenantId();
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", new ArrayList<>());
List<SpdmDemandVo> demandList = mapper.getDemandListNoPermission(req);
List<SpdmDemandVo> demandList = mapper.getDemandListNoPermission(tenantId,req);
if (CollectionUtils.isEmpty(demandList)) {
log.error("未查询到需求");
return SdmResponse.success(jsonObject);
@@ -1894,14 +1903,22 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
}
List<SpdmDemandMemberVo> eachDemandMemberList;
List<String> nodeIdList = new ArrayList<>();
List<String> projectIdList = demandList.stream().map(SpdmDemandVo::getProjectId).toList();
List<String> projectIdList = demandList.stream().map(SpdmDemandVo::getProjectId).filter(StringUtils::isNotBlank).toList();
List<String> phaseIdList = demandList.stream().map(SpdmDemandVo::getPhaseId).filter(StringUtils::isNotBlank).toList();
List<String> machineIdList = demandList.stream().map(SpdmDemandVo::getMachineId).filter(StringUtils::isNotBlank).toList();
List<String> workspaceIdList = demandList.stream().map(SpdmDemandVo::getWorkspaceId).filter(StringUtils::isNotBlank).toList();
if (CollectionUtils.isNotEmpty(projectIdList)) {
nodeIdList.addAll(projectIdList);
}
List<String> phaseIdList = demandList.stream().map(SpdmDemandVo::getPhaseId).toList();
if (CollectionUtils.isNotEmpty(phaseIdList)) {
nodeIdList.addAll(phaseIdList);
}
if (CollectionUtils.isNotEmpty(machineIdList)) {
nodeIdList.addAll(machineIdList);
}
if (CollectionUtils.isNotEmpty(workspaceIdList)) {
nodeIdList.addAll(workspaceIdList);
}
Map<String, List<SpdmNodeVo>> nodeMap = Map.of();
if (CollectionUtils.isNotEmpty(nodeIdList)) {
List<SpdmNodeVo> nodeList = nodeMapper.getNodeListByIds(nodeIdList);

View File

@@ -81,6 +81,7 @@ import javax.annotation.Resource;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -2934,6 +2935,32 @@ public class TaskServiceImpl implements ITaskService {
return SdmResponse.success(resultResponse);
}
/**
* 通用节点信息赋值方法
* @param nodeMap 提前查出来的所有节点信息map
* @param nodeKey 从nodeMap取节点的keynewTag1/newTag2等
* @param nameSetter 名称字段的setter如setProjectName
* @param tagSetter 标签字段的setter如setTag1
* @param codeSetter 编码字段的setter如setTag1Code
*/
private void setNodeInfo(Map<String, SimulationNode> nodeMap, String nodeKey,
Consumer<String> nameSetter,
Consumer<String> tagSetter,
Consumer<String> codeSetter) {
// 1. 判空key避免nodeMap.get(null)同时node为null直接返回
if (ObjectUtils.isEmpty(nodeKey)) {
return;
}
SimulationNode node = nodeMap.get(nodeKey);
if (node == null) {
return;
}
// 2. 统一赋值
nameSetter.accept(node.getNodeName());
tagSetter.accept(node.getNodeName());
codeSetter.accept(node.getNodeCode());
}
@Override
public SdmResponse getTaskListByDemandId(SpdmTaskListReq req) {
SdmResponse taskRespond = list(req);
@@ -2947,8 +2974,57 @@ public class TaskServiceImpl implements ITaskService {
jsonObject.put("data", new ArrayList<>());
return SdmResponse.success(jsonObject);
}
// 取出任务所关联的所有节点id
Set<String> nodeIdSet = taskVoList.stream()
// 把每个对象的10个tag字段转成流
.flatMap(vo -> Stream.of(
vo.getTag1(), vo.getTag2(), vo.getTag3(), vo.getTag4(), vo.getTag5(),
vo.getTag6(), vo.getTag7(), vo.getTag8(), vo.getTag9(), vo.getTag10()
))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 初始化空Map避免空指针
Map<String, SimulationNode> nodeMap = Collections.emptyMap();
if (CollectionUtils.isNotEmpty(nodeIdSet)) {
nodeMap = nodeService.lambdaQuery()
.in(SimulationNode::getUuid, nodeIdSet)
.list() // 查询列表,允许为空
.stream()
.collect(Collectors.toMap(
SimulationNode::getUuid,
Function.identity(),
(oldVal, newVal) -> newVal
));
}
// 遍历任务列表,批量赋值节点信息
for (SpdmNewTaskVo spdmNewTaskVo : taskVoList) {
// 1. 项目信息newTag1 → projectName/tag1/tag1Code
setNodeInfo(nodeMap, spdmNewTaskVo.getNewTag1(),
spdmNewTaskVo::setProjectName,
spdmNewTaskVo::setTag1,
spdmNewTaskVo::setTag1Code);
// 2. 阶段信息newTag2 → phaseName/tag2/tag2Code
setNodeInfo(nodeMap, spdmNewTaskVo.getNewTag2(),
spdmNewTaskVo::setPhaseName,
spdmNewTaskVo::setTag2,
spdmNewTaskVo::setTag2Code);
// 3. 机台信息newTag4 → machineName/tag4/tag4Code
setNodeInfo(nodeMap, spdmNewTaskVo.getNewTag4(),
spdmNewTaskVo::setMachineName,
spdmNewTaskVo::setTag4,
spdmNewTaskVo::setTag4Code);
// 4. 工位信息newTag5 → workspaceName/tag5/tag5Code
setNodeInfo(nodeMap, spdmNewTaskVo.getNewTag5(),
spdmNewTaskVo::setWorkspaceName,
spdmNewTaskVo::setTag5,
spdmNewTaskVo::setTag5Code);
}
taskVoList.forEach(task -> {
SpdmNodeVo phaseNode = nodeMapper.getNodeById(task.getNewTag2());
if (phaseNode != null) {
task.setPhaseName(phaseNode.getNodeName());
task.setTag2(phaseNode.getNodeName());

View File

@@ -194,31 +194,29 @@
</select>
<select id="getDemandListNoPermission" resultType="com.sdm.project.model.vo.SpdmDemandVo">
select * from simulation_demand
<trim prefix="WHERE" suffixOverrides ="and">
<if test="req.demandName != null and req.demandName != ''">
<bind name="searchKey1" value="'%' + req.demandName + '%'"/>
demand_name like #{searchKey1} and
</if>
<if test="req.projectId != null and req.projectId != ''">
project_id = #{req.projectId} and
</if>
<if test="req.phaseId != null and req.phaseId != ''">
phase_id = #{req.phaseId} and
</if>
<if test="req.demandType != null and req.demandType != ''">
demand_type = #{req.demandType} and
</if>
<if test="req.simType != null and req.simType != ''">
sim_type = #{req.simType} and
</if>
<if test='req.sortOrder != null and req.sortOrder == "0"'>
order by create_time
</if>
<if test='req.sortOrder != null and req.sortOrder == "1"'>
order by create_time desc
</if>
</trim>
select * from simulation_demand where tenant_id = #{tenantId}
<if test="req.demandName != null and req.demandName != ''">
<bind name="searchKey1" value="'%' + req.demandName + '%'"/>
and demand_name like #{searchKey1}
</if>
<if test="req.projectId != null and req.projectId != ''">
and project_id = #{req.projectId}
</if>
<if test="req.phaseId != null and req.phaseId != ''">
and phase_id = #{req.phaseId}
</if>
<if test="req.demandType != null and req.demandType != ''">
and demand_type = #{req.demandType}
</if>
<if test="req.simType != null and req.simType != ''">
and sim_type = #{req.simType}
</if>
<if test='req.sortOrder != null and req.sortOrder == "0"'>
order by create_time
</if>
<if test='req.sortOrder != null and req.sortOrder == "1"'>
order by create_time desc
</if>
</select>
</mapper>