UI-Project/config.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
UI-Project/src/utils/constants.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/AsyncTaskExecutorConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
UI-Project/config.js
@@ -1,10 +1,10 @@ export default { serverUrl: "10.153.19.150:88/api", // serverUrl: "10.153.19.150:88/api", // serverUrl: "192.168.1.199:88/api", // serverUrl: "127.0.0.1:88/api", serverUrl2: "10.153.19.150:88" serverUrl: "127.0.0.1:88/api", // serverUrl2: "10.153.19.150:88" // serverUrl2: "192.168.1.199:88" // serverUrl2: "127.0.0.1:88" serverUrl2: "127.0.0.1:88" //serverUrl:"res.abeim.cn" } UI-Project/src/utils/constants.js
@@ -1,4 +1,4 @@ // export const WebSocketHost = "192.168.1.199"; export const WebSocketHost = "10.153.19.150"; // export const WebSocketHost = "127.0.0.1"; // export const WebSocketHost = "10.153.19.150"; export const WebSocketHost = "127.0.0.1"; export const host = "88"; hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/AsyncTaskExecutorConfig.java
New file @@ -0,0 +1,51 @@ package com.mes.common.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.task.TaskExecutor; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.concurrent.ThreadPoolExecutor; /** * <p> @Title AsyncTaskExecutorConfig * <p> @Description 异步线程池配置 * * @author ACGkaka * @date 2023/4/24 19:48 */ @EnableAsync @Configuration public class AsyncTaskExecutorConfig { /** * 核心线程数(线程池维护线程的最小数量) */ private int corePoolSize = 10; /** * 最大线程数(线程池维护线程的最大数量) */ private int maxPoolSize = 200; /** * 队列最大长度 */ private int queueCapacity = 10; @Bean public TaskExecutor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); executor.setThreadNamePrefix("MyExecutor-"); // for passing in request scope context 转换请求范围的上下文 // executor.setTaskDecorator(new ContextCopyingDecorator()); // rejection-policy:当pool已经达到max size的时候,如何处理新任务 // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行 executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.setWaitForTasksToCompleteOnShutdown(true); executor.initialize(); return executor; } } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -30,6 +30,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -80,6 +81,7 @@ @Scheduled(fixedDelay = 300) @Async public void plcHomeEdgTask() { PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; String requestWord = plcParameterObject.getPlcParameter("requestWord").getValue(); @@ -129,6 +131,7 @@ } @Scheduled(fixedDelay = 300) @Async public void plcShelfFull() { List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull(); if (CollectionUtils.isNotEmpty(list)) { @@ -139,6 +142,7 @@ } @Scheduled(fixedDelay = 1000) @Async public void dealDamageTask() { Date startDate = new Date(); log.info("下片破损玻璃清除任务开始执行时间:{}", startDate); @@ -183,6 +187,7 @@ * 更新已绑定工位流程卡的破损/拿走的数量信息 */ @Scheduled(fixedDelay = 1000) @Async public void updateWorkStationOtherCount() { Date startDate = new Date(); log.info("下片破更新损玻璃数量任务开始执行时间:{}", startDate); hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
@@ -22,6 +22,8 @@ import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -32,6 +34,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.*; import java.util.stream.Collectors; @Slf4j @@ -48,6 +51,13 @@ private DownGlassTaskService downGlassTaskService; @Autowired private GlassInfoService glassInfoService; private final ExecutorService scanCodeThreadPool = new ThreadPoolExecutor( 10, // core pool size 20, // maximum pool size 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>() ); private final ExecutorService isRunThreadPool = Executors.newFixedThreadPool(5); @Value("${mes.scan.ip}") private String scanIp; @@ -186,52 +196,55 @@ @Scheduled(fixedDelay = 1000) public void isRun() { JSONObject jsonObject = new JSONObject(); //正在进行的任务 List<DownWorkstation> downWorkstation = downWorkstationService.getoneDownWorkstations(1, 6); jsonObject.append("downWorkstation", downWorkstation); List<DownGlassTask> downGlassTask = downGlassTaskService.selectOutTaskCache(); jsonObject.append("downGlassTask", downGlassTask); ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unLoadGlassIsRun"); if (sendwServer != null) { for (WebSocketServer webserver : sendwServer) { if (webserver != null) { webserver.sendMessage(jsonObject.toString()); } else { log.info("unLoadGlassIsRun is closed"); isRunThreadPool.execute(() -> { JSONObject jsonObject = new JSONObject(); //正在进行的任务 List<DownWorkstation> downWorkstation = downWorkstationService.getoneDownWorkstations(1, 6); jsonObject.append("downWorkstation", downWorkstation); List<DownGlassTask> downGlassTask = downGlassTaskService.selectOutTaskCache(); jsonObject.append("downGlassTask", downGlassTask); ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unLoadGlassIsRun"); if (sendwServer != null) { for (WebSocketServer webserver : sendwServer) { if (webserver != null) { webserver.sendMessage(jsonObject.toString()); } else { log.info("unLoadGlassIsRun is closed"); } } } } }); } @Async @Scheduled(fixedDelay = Long.MAX_VALUE) public void scanCodeTask() { JSONObject jsonObject = new JSONObject(); log.info("扫描任务已启动"); while (true) { new Thread(() -> { try (Socket socket = new Socket(scanIp, scanPort); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) { // 接收服务器响应 String response; log.info("等待扫码中......"); while ((response = in.readLine()) != null) { log.info("扫描到的玻璃id:{}", response); List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("scanCode"); if (CollectionUtils.isNotEmpty(sendwServer)) { //按照玻璃id获取玻璃信息返回给前端界面,具体需要哪些数据待确认 GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>() .eq(GlassInfo::getGlassId, response).last("limit 1")); if (null == glassInfo) { log.info("按照玻璃id:{},无法找到玻璃信息", response); } else { sendwServer.get(0).sendMessage(glassInfo.toString()); } try (Socket socket = new Socket(scanIp, scanPort); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) { // 接收服务器响应 // socket.setSoTimeout(1000); log.info("等待扫码中......"); String glassId = in.readLine(); log.info("扫描到的玻璃id:{}", glassId); List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass"); if (CollectionUtils.isNotEmpty(sendwServer)) { //按照玻璃id获取玻璃信息返回给前端界面,具体需要哪些数据待确认 GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>() .eq(GlassInfo::getGlassId, glassId).last("limit 1")); if (null == glassInfo) { log.info("按照玻璃id:{},无法找到玻璃信息", glassId); } else { jsonObject.append("scanGlass",glassInfo); sendwServer.get(0).sendMessage(jsonObject.toString()); } } } catch (Exception exception) { log.info("读取异常,原因为{}", exception.getMessage()); } }).start(); } catch (Exception exception) { log.info("读取异常,原因为{}", exception.getMessage()); } } } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml
@@ -8,6 +8,11 @@ name: unLoadGlass liquibase: enabled: false task: scheduling: pool: size: 10 thread-name-prefix: task-unLoad mybatis-plus: @@ -24,5 +29,5 @@ throughHeight: 2500 threshold: 5 #下片的最大阈值 scan: ip: 127.0.0.1 ip: 169.254.171.199 port: 5000