fix[project]: syncPhase接口改为异步执行
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.sdm.project.controller;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.req.lyric.SpdmAcceptTodoInfoReq;
|
||||
import com.sdm.common.entity.req.project.SpdmNodeListReq;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
@@ -18,11 +19,16 @@ import com.sdm.project.service.impl.TaskServiceImpl;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/node")
|
||||
@@ -46,6 +52,9 @@ public class SimulationLyricNodeController {
|
||||
@Autowired
|
||||
private ISimulationTaskService simulationTaskService;
|
||||
|
||||
@Value("${lyric.syncPhaseWaitSeconds:3}")
|
||||
private Long syncPhaseWaitSeconds;
|
||||
|
||||
@GetMapping("/updateApprovalStatus")
|
||||
@Operation(summary = "仿真节点审批状态更新", description = "仿真节点审批状态更新")
|
||||
public SdmResponse updateApprovalStatus(@RequestParam(value = "projectName") @Validated String projectName, @RequestParam(value = "workspaceName") @Validated String workspaceName, @RequestParam(value = "approvalStatus") @Validated Integer approvalStatus) {
|
||||
@@ -165,7 +174,19 @@ public class SimulationLyricNodeController {
|
||||
@PostMapping("/syncPhase")
|
||||
@Operation(summary = "同步阶段机台工位", description = "同步阶段机台工位")
|
||||
public SdmResponse syncPhase(@RequestBody @Validated EpSyncPhaseReq req) {
|
||||
return lyricInternalService.syncPhase(req);
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
String jobNumber = ThreadLocalContext.getJobNumber();
|
||||
String userName = ThreadLocalContext.getUserName();
|
||||
CompletableFuture<SdmResponse> syncTodoDataFeature = CompletableFuture.supplyAsync(() ->
|
||||
lyricInternalService.syncPhase(req,tenantId,userId,jobNumber,userName));
|
||||
SdmResponse sdmResponse;
|
||||
try {
|
||||
sdmResponse = syncTodoDataFeature.get(syncPhaseWaitSeconds, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
return SdmResponse.failed("同步阶段机台工位失败,请稍后再试");
|
||||
}
|
||||
return sdmResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@ public interface ILyricInternalService {
|
||||
|
||||
SdmResponse queryProjectInfoList(EpProjectQueryReq req);
|
||||
|
||||
SdmResponse syncPhase(EpSyncPhaseReq req);
|
||||
SdmResponse syncPhase(EpSyncPhaseReq req, Long tenantId, Long userId, String jobNumber, String userName);
|
||||
|
||||
SdmResponse getHkToken();
|
||||
|
||||
|
||||
@@ -1937,9 +1937,12 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse syncPhase(EpSyncPhaseReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
Long jobNumber = ThreadLocalContext.getUserId();
|
||||
public SdmResponse syncPhase(EpSyncPhaseReq req, Long tenantId, Long userId, String jobNumber, String userName) {
|
||||
ThreadLocalContext.setTenantId(tenantId);
|
||||
ThreadLocalContext.setUserId(userId);
|
||||
ThreadLocalContext.setJobNumber(jobNumber);
|
||||
ThreadLocalContext.setUserName(userName);
|
||||
|
||||
String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
// 根据projectId查询项目机台工位信息的视图
|
||||
List<LyricVProjectStationToDM> projectStationList = lyricVProjectStationToDmService.lambdaQuery()
|
||||
@@ -1964,7 +1967,7 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
phaseNode.setNodeName(currentPhase);
|
||||
phaseNode.setNodeType(NodeTypeEnum.PHASE.getValue());
|
||||
phaseNode.setCreateTime(curDateStr);
|
||||
phaseNode.setCreator(jobNumber);
|
||||
phaseNode.setCreator(userId);
|
||||
phaseNode.setTenantId(tenantId);
|
||||
phaseNode.setProjectSource(SYNC_PROJECT_SOURCE);
|
||||
phaseNode.setPid(req.getUuid());
|
||||
@@ -1980,7 +1983,7 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
machineNode.setNodeName(projectStationByMachineNumberList.get(0).getMachineName());
|
||||
machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue());
|
||||
machineNode.setCreateTime(curDateStr);
|
||||
machineNode.setCreator(jobNumber);
|
||||
machineNode.setCreator(userId);
|
||||
machineNode.setTenantId(tenantId);
|
||||
machineNode.setProjectSource(SYNC_PROJECT_SOURCE);
|
||||
machineNode.setPid(phaseNode.getUuid());
|
||||
@@ -1992,7 +1995,7 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
fixedWorkspaceNode.setNodeName(machineNumber + "-M");
|
||||
fixedWorkspaceNode.setNodeType(NodeTypeEnum.WORKSPACE.getValue());
|
||||
fixedWorkspaceNode.setCreateTime(curDateStr);
|
||||
fixedWorkspaceNode.setCreator(jobNumber);
|
||||
fixedWorkspaceNode.setCreator(userId);
|
||||
fixedWorkspaceNode.setTenantId(tenantId);
|
||||
fixedWorkspaceNode.setProjectSource(SYNC_PROJECT_SOURCE);
|
||||
fixedWorkspaceNode.setPid(machineNode.getUuid());
|
||||
@@ -2004,7 +2007,7 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
workspaceNode.setNodeName(lyricVProjectStationToDM.getStationName());
|
||||
workspaceNode.setNodeType(NodeTypeEnum.WORKSPACE.getValue());
|
||||
workspaceNode.setCreateTime(curDateStr);
|
||||
workspaceNode.setCreator(jobNumber);
|
||||
workspaceNode.setCreator(userId);
|
||||
workspaceNode.setTenantId(tenantId);
|
||||
workspaceNode.setProjectSource(SYNC_PROJECT_SOURCE);
|
||||
workspaceNode.setPid(machineNode.getUuid());
|
||||
@@ -2059,7 +2062,7 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
// addNode.getPid()不为空时,在创建阶段,ownRootNodeUuid就是入参的pid父节点
|
||||
addNode.setOwnRootNodeUuid(ObjectUtils.isEmpty(addNode.getPid()) ? addNode.getUuid() : addNode.getPid());
|
||||
addNode.setCreateTime(curDateStr);
|
||||
addNode.setCreator(jobNumber);
|
||||
addNode.setCreator(userId);
|
||||
addNode.setTenantId(tenantId);
|
||||
try {
|
||||
// tagReq.getValue()="Tag1"
|
||||
@@ -2080,7 +2083,6 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
createDir(node.getUuid(), node.getNodeType(), node.getPid(), node.getNodeName(), node);
|
||||
}
|
||||
// 更新文件权限
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq();
|
||||
updatePermissionReq.setUserId(userId);
|
||||
updatePermissionReq.setUuid(req.getUuid());
|
||||
|
||||
Reference in New Issue
Block a user