任务相关
This commit is contained in:
parent
053c1a9984
commit
3c8b8a5ce6
|
@ -2,6 +2,7 @@ package com.hivekion.common.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +15,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||||
* @since 2025/7/22
|
* @since 2025/7/22
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
||||||
public class WsEndpointConfig {
|
public class WsEndpointConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public ServerEndpointExporter serverEndpointExporter() {
|
public ServerEndpointExporter serverEndpointExporter() {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class Room implements AutoCloseable {
|
||||||
private Map<String, Coordinate> resourceCoordinateMap = new ConcurrentHashMap<>();
|
private Map<String, Coordinate> resourceCoordinateMap = new ConcurrentHashMap<>();
|
||||||
//资源路线path
|
//资源路线path
|
||||||
private Map<String, Object> resourcePathMap = new ConcurrentHashMap<>();
|
private Map<String, Object> resourcePathMap = new ConcurrentHashMap<>();
|
||||||
private Map<String,ScenarioResource> scenarioResourceMap = new ConcurrentHashMap<>();
|
private Map<String, ScenarioResource> scenarioResourceMap = new ConcurrentHashMap<>();
|
||||||
/**
|
/**
|
||||||
* 任务管理相关
|
* 任务管理相关
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@ public class Room implements AutoCloseable {
|
||||||
|
|
||||||
private com.hivekion.statistic.service.ScenarioService scenarioService;
|
private com.hivekion.statistic.service.ScenarioService scenarioService;
|
||||||
|
|
||||||
private AtomicInteger numStatus = new AtomicInteger(0);
|
private AtomicInteger numStatus = new AtomicInteger(0);
|
||||||
/**
|
/**
|
||||||
* 任务容器
|
* 任务容器
|
||||||
*/
|
*/
|
||||||
|
@ -139,7 +139,6 @@ public class Room implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停
|
* 暂停
|
||||||
*/
|
*/
|
||||||
|
@ -172,8 +171,12 @@ public class Room implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
long curTime = duringTime.addAndGet(this.mag);
|
long curTime = duringTime.addAndGet(this.mag);
|
||||||
|
if (totalTime.get() - curTime > 0) {
|
||||||
sendRemainTime((totalTime.get() - curTime));
|
sendRemainTime((totalTime.get() - curTime));
|
||||||
|
} else {
|
||||||
|
future.cancel(true);
|
||||||
|
scheduler.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
NavigableMap<Long, Map<String, TaskAction>> actions = actionMap.headMap(curTime, true);
|
NavigableMap<Long, Map<String, TaskAction>> actions = actionMap.headMap(curTime, true);
|
||||||
if (!actions.isEmpty()) {
|
if (!actions.isEmpty()) {
|
||||||
|
@ -262,8 +265,8 @@ public class Room implements AutoCloseable {
|
||||||
scenario.getResourceList().forEach(resource -> {
|
scenario.getResourceList().forEach(resource -> {
|
||||||
scenarioResourceMap.put(resource.getId(), resource);
|
scenarioResourceMap.put(resource.getId(), resource);
|
||||||
});
|
});
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
log.info("======cost time============={}===================",endTime-begTime);
|
log.info("======cost time============={}===================", endTime - begTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addResourcePath(String resourceId, Object obj) {
|
public void addResourcePath(String resourceId, Object obj) {
|
||||||
|
@ -285,10 +288,12 @@ public class Room implements AutoCloseable {
|
||||||
public Map<String, Object> getPathMap() {
|
public Map<String, Object> getPathMap() {
|
||||||
return resourcePathMap;
|
return resourcePathMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, ScenarioResource> getScenarioResourceMap() {
|
public Map<String, ScenarioResource> getScenarioResourceMap() {
|
||||||
return scenarioResourceMap;
|
return scenarioResourceMap;
|
||||||
}
|
}
|
||||||
private void pushRoomInfo(){
|
|
||||||
|
private void pushRoomInfo() {
|
||||||
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
|
ResponseCmdInfo<Object> respObj = new ResponseCmdInfo<>();
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
dataMap.put("mag", this.getMag());
|
dataMap.put("mag", this.getMag());
|
||||||
|
@ -300,24 +305,25 @@ public class Room implements AutoCloseable {
|
||||||
Global.sendCmdInfoQueue.add(respObj);
|
Global.sendCmdInfoQueue.add(respObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearScenarioCache(){
|
private void clearScenarioCache() {
|
||||||
try {
|
try {
|
||||||
scenario.setResourceList(SpringUtil.getBean(ScenarioResourceServiceImpl.class)
|
scenario.setResourceList(SpringUtil.getBean(ScenarioResourceServiceImpl.class)
|
||||||
.getResourceListByScenarioId(scenario.getId()));
|
.getResourceListByScenarioId(scenario.getId()));
|
||||||
if (redisUtil == null) {
|
if (redisUtil == null) {
|
||||||
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
redisUtil = SpringUtil.getBean(RedisUtil.class);
|
||||||
}
|
}
|
||||||
for (ScenarioResource scenarioResource : this.scenario.getResourceList()) {
|
for (ScenarioResource scenarioResource : this.scenario.getResourceList()) {
|
||||||
ScenarioInfo scenarioInfo = scenarioService.listScenarioInfo(scenarioResource.getScenarioId(),
|
ScenarioInfo scenarioInfo = scenarioService.listScenarioInfo(
|
||||||
roomId, scenarioResource.getId());
|
scenarioResource.getScenarioId(),
|
||||||
|
roomId, scenarioResource.getId());
|
||||||
EditScenarioInfo updScenarioInfo = scenarioService.listEditScenarioInfo(
|
EditScenarioInfo updScenarioInfo = scenarioService.listEditScenarioInfo(
|
||||||
scenarioResource.getScenarioId(), roomId, scenarioResource.getId());
|
scenarioResource.getScenarioId(), roomId, scenarioResource.getId());
|
||||||
redisUtil.delete(
|
redisUtil.delete(
|
||||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId());
|
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId());
|
||||||
redisUtil.delete(
|
redisUtil.delete(
|
||||||
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId());
|
scenarioResource.getScenarioId() + "-" + roomId + "-" + scenarioResource.getId());
|
||||||
}
|
}
|
||||||
}catch (Exception ex){
|
} catch (Exception ex) {
|
||||||
log.error("===================clear cached fail==========================");
|
log.error("===================clear cached fail==========================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
spring.datasource.dynamic.primary=dm
|
spring.datasource.dynamic.primary=dm
|
||||||
spring.datasource.dynamic.strict=false
|
spring.datasource.dynamic.strict=false
|
||||||
spring.datasource.dynamic.datasource.dm.url=jdbc:dm://127.0.0.1:5236/SIMULATION
|
spring.datasource.dynamic.datasource.dm.url=jdbc:dm://192.168.0.53:5236/SIMULATION
|
||||||
spring.datasource.dynamic.datasource.dm.driver-class-name=dm.jdbc.driver.DmDriver
|
spring.datasource.dynamic.datasource.dm.driver-class-name=dm.jdbc.driver.DmDriver
|
||||||
spring.datasource.dynamic.datasource.dm.username=SYSDBA
|
spring.datasource.dynamic.datasource.dm.username=SYSDBA
|
||||||
spring.datasource.dynamic.datasource.dm.password=Admin123
|
spring.datasource.dynamic.datasource.dm.password=Admin123
|
||||||
|
|
|
@ -2,6 +2,13 @@ package com.hivekion;
|
||||||
|
|
||||||
import com.hivekion.baseData.entity.ModuleStatus;
|
import com.hivekion.baseData.entity.ModuleStatus;
|
||||||
import com.hivekion.baseData.service.ModuleStatusService;
|
import com.hivekion.baseData.service.ModuleStatusService;
|
||||||
|
import com.hivekion.common.uuid.IdUtils;
|
||||||
|
import com.hivekion.scenario.entity.ScenarioResource;
|
||||||
|
import com.hivekion.scenario.service.ScenarioResourceService;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -21,20 +28,26 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
*/
|
*/
|
||||||
@SpringBootTest(classes = DemoApplication.class)
|
@SpringBootTest(classes = DemoApplication.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
public class ApplicationTest {
|
public class ApplicationTest {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ModuleStatusService moduleStatusService;
|
private ModuleStatusService moduleStatusService;
|
||||||
@Test
|
@Resource
|
||||||
public void modStatus(){
|
private ScenarioResourceService scenarioResourceService;
|
||||||
ModuleStatus status = new ModuleStatus();
|
|
||||||
status.setModuleName("评估子系统");
|
@Test
|
||||||
status.setModuleUrl("/");
|
public void modStatus() {
|
||||||
status.setSortOrder(5);
|
ModuleStatus status = new ModuleStatus();
|
||||||
status.setModuleStatus("0");
|
status.setModuleName("评估子系统");
|
||||||
status.setModuleCode("evaluation_system");
|
status.setModuleUrl("/");
|
||||||
moduleStatusService.save(status);
|
status.setSortOrder(5);
|
||||||
}
|
status.setModuleStatus("0");
|
||||||
|
status.setModuleCode("evaluation_system");
|
||||||
|
moduleStatusService.save(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user