From a22740bb52a0a77593ac6b6d3ad6fe3823ffa333 Mon Sep 17 00:00:00 2001 From: gongbaoxiong <751575283@qq.com> Date: Tue, 8 Oct 2024 20:53:03 +0800 Subject: [PATCH] =?UTF-8?q?opt:=E4=BC=98=E5=8C=96lms=E4=BB=BB=E5=8A=A1id?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=A0=A1=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/quartz/task/SyncDeviceStatus.java | 497 ++++++++++++++++-- .../service/impl/CockpitServiceImpl.java | 49 +- 2 files changed, 485 insertions(+), 61 deletions(-) diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/SyncDeviceStatus.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/SyncDeviceStatus.java index 826ddaf..86f6eab 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/SyncDeviceStatus.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/SyncDeviceStatus.java @@ -1,7 +1,6 @@ package org.nl.quartz.task; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -23,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -55,31 +55,348 @@ public class SyncDeviceStatus { private void rgv() { try { log.info("自动线程开始查询浙大RGV设备状态"); - HttpResponse response = agvService.queryAgvDeviceStatus("1"); +// HttpResponse response = agvService.queryAgvDeviceStatus("1"); +// JSONArray jsonArray = JSONArray.parseArray(response.body()); //查询RGV指令列表 - JSONArray jsonArray = JSONArray.parseArray(response.body()); + String rgvInfo = "[\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"48948\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2012- 2- 18 0: 22: 44\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2012- 2- 18 0: 24: 3\",\n" + + " \"production_time\": \"90922\",\n" + + " \"vehicle\": \"22\",\n" + + " \"standby_time\": \"9772298\",\n" + + " \"energyLevel\": \"0.0\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"4-78-21\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"8288\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 6 23: 18: 42\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 7- 10 13: 38: 5\",\n" + + " \"production_time\": \"404589\",\n" + + " \"vehicle\": \"11\",\n" + + " \"standby_time\": \"7543490\",\n" + + " \"energyLevel\": \"95.41999816894531\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"4-78-20\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"9702\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 18 9: 33: 33\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 9- 6 2: 33: 8\",\n" + + " \"production_time\": \"224840\",\n" + + " \"vehicle\": \"12\",\n" + + " \"standby_time\": \"7950135\",\n" + + " \"energyLevel\": \"51.61000061035156\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-48-3\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"141089\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 8- 26 8: 45: 31\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 8- 26 8: 46: 13\",\n" + + " \"production_time\": \"713764\",\n" + + " \"vehicle\": \"23\",\n" + + " \"standby_time\": \"9057202\",\n" + + " \"energyLevel\": \"0.0\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-24-2\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"85041\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2012- 2- 20 16: 0: 17\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2012- 2- 20 16: 0: 40\",\n" + + " \"production_time\": \"31417\",\n" + + " \"vehicle\": \"24\",\n" + + " \"standby_time\": \"14158946\",\n" + + " \"energyLevel\": \"0.0\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"5-63-40\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"3439\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2012- 2- 24 17: 59: 46\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 8- 6 13: 36: 32\",\n" + + " \"production_time\": \"116749\",\n" + + " \"vehicle\": \"25\",\n" + + " \"standby_time\": \"9792348\",\n" + + " \"energyLevel\": \"0.0\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"2-43-21\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"720\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2012- 3- 25 21: 38: 58\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2012- 3- 27 22: 52: 2\",\n" + + " \"production_time\": \"20154\",\n" + + " \"vehicle\": \"26\",\n" + + " \"standby_time\": \"9551801\",\n" + + " \"energyLevel\": \"0.0\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"3-35-40\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"task_id\": \"1834031476203720704\",\n" + + " \"error_time\": \"45573\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 8- 1 13: 23: 19\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 8- 1 13: 23: 31\",\n" + + " \"production_time\": \"480209\",\n" + + " \"vehicle\": \"1\",\n" + + " \"standby_time\": \"8710808\",\n" + + " \"energyLevel\": \"68.38999938964844\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"5-63-39\",\n" + + " \"status\": \"WORK\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"8001\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 9- 10 5: 57: 21\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 9- 10 5: 57: 52\",\n" + + " \"production_time\": \"377075\",\n" + + " \"vehicle\": \"2\",\n" + + " \"standby_time\": \"8232806\",\n" + + " \"energyLevel\": \"50.560001373291016\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-38-3\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"40925\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 10 22: 42: 4\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 8- 29 15: 43: 31\",\n" + + " \"production_time\": \"465561\",\n" + + " \"vehicle\": \"3\",\n" + + " \"standby_time\": \"6883401\",\n" + + " \"energyLevel\": \"68.94000244140625\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-44-3\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"10041\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 23 7: 59: 21\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 7- 23 7: 58: 53\",\n" + + " \"production_time\": \"213821\",\n" + + " \"vehicle\": \"4\",\n" + + " \"standby_time\": \"8950011\",\n" + + " \"energyLevel\": \"65.37000274658203\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-24-3\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"11798\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 14 10: 40: 2\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 7- 20 9: 9: 5\",\n" + + " \"production_time\": \"425080\",\n" + + " \"vehicle\": \"5\",\n" + + " \"standby_time\": \"7560725\",\n" + + " \"energyLevel\": \"55.34000015258789\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"2-43-20\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"16034\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 1 15: 8: 12\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 7- 10 13: 39: 1\",\n" + + " \"production_time\": \"171190\",\n" + + " \"vehicle\": \"6\",\n" + + " \"standby_time\": \"7916560\",\n" + + " \"energyLevel\": \"64.12999725341797\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"4-72-20\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"32339\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 15 0: 28: 31\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 9- 2 17: 29: 51\",\n" + + " \"production_time\": \"364371\",\n" + + " \"vehicle\": \"7\",\n" + + " \"standby_time\": \"7942815\",\n" + + " \"energyLevel\": \"60.650001525878906\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"2-45-20\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"28019\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 8- 15 20: 52: 23\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 8- 15 20: 52: 0\",\n" + + " \"production_time\": \"540534\",\n" + + " \"vehicle\": \"8\",\n" + + " \"standby_time\": \"8801165\",\n" + + " \"energyLevel\": \"100.48999786376953\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-79-3\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"8138\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 14 17: 25: 12\",\n" + + " \"Error\": \"1\",\n" + + " \"open_time\": \"2024- 9- 2 10: 25: 9\",\n" + + " \"production_time\": \"445748\",\n" + + " \"vehicle\": \"9\",\n" + + " \"standby_time\": \"8255670\",\n" + + " \"energyLevel\": \"53.77000045776367\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"3-35-39\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"234822\",\n" + + " \"task_code\": \"\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 18 9: 38: 33\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 9- 6 2: 42: 27\",\n" + + " \"production_time\": \"805015\",\n" + + " \"vehicle\": \"21\",\n" + + " \"standby_time\": \"18739655\",\n" + + " \"energyLevel\": \"0.0\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-48-2\",\n" + + " \"status\": \"IDLE\"\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"error_time\": \"34089\",\n" + + " \"task_code\": \"9758\",\n" + + " \"Has_goods\": \"0\",\n" + + " \"end_time\": \"2024- 7- 1 8: 25: 26\",\n" + + " \"Error\": \"\",\n" + + " \"open_time\": \"2024- 7- 1 8: 25: 6\",\n" + + " \"production_time\": \"357883\",\n" + + " \"vehicle\": \"10\",\n" + + " \"standby_time\": \"8148975\",\n" + + " \"energyLevel\": \"48.93000030517578\",\n" + + " \"Relation_vehicle\": \"\",\n" + + " \"angle\": \"0.0\",\n" + + " \"rfid\": \"1-65-3\",\n" + + " \"status\": \"IDLE\"\n" + + " }\n" + + "]"; + + JSONArray jsonArray = JSONArray.parseArray(rgvInfo); + Map taskCodeToTaskIdMap = new HashMap<>(); List task_codes = jsonArray.stream() .map(r -> ((JSONObject) r).getString("task_code")) + .filter(task_code -> task_code != null && !task_code.isEmpty()) .collect(Collectors.toList()); - List instructionList = instructionService.list(new LambdaQueryWrapper().in(InstructionMybatis::getInstruction_code, task_codes)); - if (ObjectUtil.isNotEmpty(instructionList)) { - Map taskCodeToTaskIdMap = instructionList.stream() + if (ObjectUtil.isNotEmpty(task_codes)) { + List instructionList = instructionService.list(new LambdaQueryWrapper().in(InstructionMybatis::getInstruction_code, task_codes)); + taskCodeToTaskIdMap = instructionList.stream() + .filter(instruction -> StringUtils.isNotBlank(instruction.getExt_task_id())) .collect(Collectors.toMap( InstructionMybatis::getInstruction_code, - InstructionMybatis::getTask_id + InstructionMybatis::getExt_task_id )); - //缓存当前lms任务id - jsonArray.forEach(r -> { - JSONObject Item = (JSONObject) r; - Item.put("task_id", ""); - String taskId = taskCodeToTaskIdMap.get(Item.getString("task_code")); - if (taskId != null) { + } + //缓存当前lms任务id + Map finalTaskCodeToTaskIdMap = taskCodeToTaskIdMap; + jsonArray.forEach(r -> { + JSONObject Item = (JSONObject) r; + Item.put("task_id", ""); + if (ObjectUtil.isNotEmpty(finalTaskCodeToTaskIdMap)) { + String taskId = finalTaskCodeToTaskIdMap.get(Item.getString("task_code")); + if (StringUtils.isNotBlank(taskId)) { Item.put("task_id", taskId); } - String deviceStatus = StringUtils.isNotBlank(Item.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(Item.getString("status")) : "4"; - Item.put("device_status", deviceStatus); - }); - } + } + String deviceStatus = StringUtils.isNotBlank(Item.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(Item.getString("status")) : "4"; + Item.put("device_status", deviceStatus); + }); redisUtils.set("RGV", jsonArray); } catch (Exception e) { log.error("自动线程查询浙大RGV设备状态失败{}{}", e, e.getMessage()); @@ -121,21 +438,21 @@ public class SyncDeviceStatus { //温度显示 json.put("temperature", guhuashiSiteDeviceDriver.getVW7012()); //湿度设定 - json.put("humidity_setting", guhuashiSiteDeviceDriver.getVW7014()); + json.put("humidity_setting", guhuashiSiteDeviceDriver.getVW7014()); //湿度显示 - json.put("humidity", guhuashiSiteDeviceDriver.getVW7016()); + json.put("humidity", guhuashiSiteDeviceDriver.getVW7016()); //运行时间 - json.put("total_running_time", guhuashiSiteDeviceDriver.getVW7038()); + json.put("total_running_time", guhuashiSiteDeviceDriver.getVW7038()); //固化阶段 - json.put("executing_stage_num", guhuashiSiteDeviceDriver.getVW7044()); + json.put("executing_stage_num", guhuashiSiteDeviceDriver.getVW7044()); //当前阶段需固化时间 - json.put("required_time", guhuashiSiteDeviceDriver.getVW7018()); + json.put("required_time", guhuashiSiteDeviceDriver.getVW7018()); //固化工艺 0-固化;1-干燥; - json.put("craft",guhuashiSiteDeviceDriver.getVW7036()); - json.put("device_status", guhuashiSiteDeviceDriver.getVW7058()); - json.put("front_door", guhuashiSiteDeviceDriver.getVW70004()==0?1:0); - json.put("back_door", guhuashiSiteDeviceDriver.getVW7010()); - json.put("error", guhuashiSiteDeviceDriver.getVD7046()); + json.put("craft", guhuashiSiteDeviceDriver.getVW7036()); + json.put("device_status", guhuashiSiteDeviceDriver.getVW7058()); + json.put("front_door", guhuashiSiteDeviceDriver.getVW70004() == 0 ? 0 : 1); + json.put("back_door", guhuashiSiteDeviceDriver.getVW70006() == 0 ? 0 : 1); + json.put("error", guhuashiSiteDeviceDriver.getVD7046()); guhuashi.add(json); } else if (device.getDeviceDriver() instanceof SiteStatusDeviceDriver) { SiteStatusDeviceDriver siteStatusDeviceDriver=(SiteStatusDeviceDriver)device.getDeviceDriver(); @@ -176,6 +493,98 @@ public class SyncDeviceStatus { redisUtils.set("baoshijian", baoshijian); redisUtils.set("guhuashi", guhuashi); redisUtils.set("site", site); + String agvInfo = "[\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 0,\n" + + " \"device_status\": 6,\n" + + " \"transportOrder\": \"240912003\",\n" + + " \"device_name\": \"AGV08\",\n" + + " \"energyLevel\": 0,\n" + + " \"device_code\": \"AGV08\",\n" + + " \"positionAngle\": 0,\n" + + " \"positionX\": 0\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 10851,\n" + + " \"device_status\": 4,\n" + + " \"transportOrder\": \"\",\n" + + " \"device_name\": \"AGV03\",\n" + + " \"energyLevel\": 85,\n" + + " \"device_code\": \"AGV03\",\n" + + " \"positionAngle\": 270,\n" + + " \"positionX\": 4901\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 10852,\n" + + " \"device_status\": 4,\n" + + " \"transportOrder\": \"\",\n" + + " \"device_name\": \"AGV06\",\n" + + " \"energyLevel\": 96,\n" + + " \"device_code\": \"AGV06\",\n" + + " \"positionAngle\": 270,\n" + + " \"positionX\": 5161\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 16317,\n" + + " \"device_status\": 4,\n" + + " \"transportOrder\": \"\",\n" + + " \"device_name\": \"AGV05\",\n" + + " \"energyLevel\": 73,\n" + + " \"device_code\": \"AGV05\",\n" + + " \"positionAngle\": 271,\n" + + " \"positionX\": 9287\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"task_id\": \"1834024962374111232\",\n" + + " \"positionY\": 10851,\n" + + " \"device_status\": 2,\n" + + " \"transportOrder\": \"\",\n" + + " \"device_name\": \"AGV01\",\n" + + " \"energyLevel\": 70,\n" + + " \"device_code\": \"AGV01\",\n" + + " \"positionAngle\": 270,\n" + + " \"positionX\": 4380\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 10849,\n" + + " \"device_status\": 4,\n" + + " \"transportOrder\": \"\",\n" + + " \"device_name\": \"AGV07\",\n" + + " \"energyLevel\": 79,\n" + + " \"device_code\": \"AGV07\",\n" + + " \"positionAngle\": 270,\n" + + " \"positionX\": 5420\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 16315,\n" + + " \"device_status\": 4,\n" + + " \"transportOrder\": \"\",\n" + + " \"device_name\": \"AGV04\",\n" + + " \"energyLevel\": 68,\n" + + " \"device_code\": \"AGV04\",\n" + + " \"positionAngle\": 270,\n" + + " \"positionX\": 9030\n" + + " },\n" + + " {\n" + + " \"@type\": \"com.alibaba.fastjson.JSONObject\",\n" + + " \"positionY\": 10850,\n" + + " \"device_status\": 2,\n" + + " \"transportOrder\": \"240912005\",\n" + + " \"device_name\": \"AGV02\",\n" + + " \"energyLevel\": 84,\n" + + " \"device_code\": \"AGV02\",\n" + + " \"positionAngle\": 270,\n" + + " \"positionX\": 4640\n" + + " }\n" + + "]"; + agv = JSONArray.parseArray(agvInfo); if (ObjectUtil.isNotEmpty(agv)) { List deviceCodes = agv.stream() .map(r -> { @@ -183,22 +592,26 @@ public class SyncDeviceStatus { return deviceCode.substring(deviceCode.length() - 1); }) .collect(Collectors.toList()); - List instructionList = instructionService.list(new LambdaQueryWrapper().in(InstructionMybatis::getCarno, deviceCodes)); - if (ObjectUtil.isNotEmpty(instructionList)) { - Map taskCodeToTaskIdMap = instructionList.stream() - .collect(Collectors.toMap( - InstructionMybatis::getInstruction_code, - InstructionMybatis::getTask_id - )); - agv.forEach(r -> { - JSONObject Item = (JSONObject) r; - String taskId = taskCodeToTaskIdMap.get(Item.getString("task_code")); - Item.put("task_id", ""); - if (taskId != null) { - Item.put("task_id", taskId); - } - }); + if (ObjectUtil.isNotEmpty(deviceCodes)) { + List instructionList = instructionService.list(new LambdaQueryWrapper().in(InstructionMybatis::getCarno, deviceCodes).lt(InstructionMybatis::getInstruction_status, 2).eq(InstructionMybatis::getIs_delete, 0)); + if (ObjectUtil.isNotEmpty(instructionList)) { + Map taskCodeToTaskIdMap = instructionList.stream() + .filter(instruction -> StringUtils.isNotBlank(instruction.getExt_task_id())) + .collect(Collectors.toMap( + InstructionMybatis::getInstruction_code, + InstructionMybatis::getExt_task_id + )); + agv.forEach(r -> { + JSONObject Item = (JSONObject) r; + String taskId = taskCodeToTaskIdMap.get(Item.getString("task_code")); + Item.put("task_id", ""); + if (StringUtils.isNotBlank(taskId)) { + Item.put("task_id", taskId); + } + }); + } } + } redisUtils.set("agv", agv); log.trace("自动上报驱动状态,完毕耗时{}", System.currentTimeMillis() - startTime); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java index 032b6e9..9f01ffb 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java @@ -73,44 +73,56 @@ public class CockpitServiceImpl implements CockpitService { //库存结构 JSONObject zc_storage_info = new JSONObject(); //状态信息 - CompletableFuture>> task1 = CompletableFuture.supplyAsync(() -> cockpitMapper.statusInfo(), pool); - task1.thenAccept((result) -> { + CompletableFuture task1 = CompletableFuture.supplyAsync(() -> { + List> result =cockpitMapper.statusInfo(); device_status.put("status_info", result); - }).exceptionally((e) -> { + return null; + },pool); + task1.exceptionally((e) -> { log.error("状态信息: {}", e.getMessage(), e); + device_status.put("status_info", null); return null; }); //固化架信息 - CompletableFuture>> task2 = CompletableFuture.supplyAsync(() -> cockpitMapper.storageInfo(), pool); - task2.thenAccept((result) -> { + CompletableFuture task2 = CompletableFuture.supplyAsync(() -> { + List> result = cockpitMapper.storageInfo(); device_status.put("storage_info", result); - }).exceptionally((e) -> { + return null; + },pool); + task2.exceptionally((e) -> { log.error("固化架信息: {}", e.getMessage(), e); + device_status.put("storage_info", null); return null; }); //暂存库库存结构 - CompletableFuture>> task3 = CompletableFuture.supplyAsync(() -> cockpitMapper.getZcMaterialmsg(), pool); - task3.thenAccept((result) -> { + CompletableFuture task3 = CompletableFuture.supplyAsync(() -> { + List> result =cockpitMapper.getZcMaterialmsg(); zc_storage_info.put("material_info", result); - }).exceptionally((e) -> { + return null; + },pool); + task3.exceptionally((e) -> { log.error("暂存库库存结构: {}", e.getMessage(), e); - zc_storage_info.put("material_info", ""); + zc_storage_info.put("material_info", null); return null; }); //库位使用占比 - CompletableFuture task4 = CompletableFuture.supplyAsync(() -> cockpitMapper.percent(), pool); - task4.thenAccept((result) -> { + CompletableFuture task4 = CompletableFuture.supplyAsync(() -> { + String result =cockpitMapper.percent(); zc_storage_info.put("percent", result); - }).exceptionally((e) -> { + return null; + },pool); + task4.exceptionally((e) -> { log.error("库位使用占比: {}", e.getMessage(), e); - zc_storage_info.put("percent", ""); + getHomeInfo.put("percent", null); return null; }); //生产任务目标达成 - CompletableFuture task5 = CompletableFuture.supplyAsync(() -> cockpitMapper.getProductTarget(), pool); - task5.thenAccept((result) -> { + CompletableFuture task5 = CompletableFuture.supplyAsync(() -> { + JSONObject result =cockpitMapper.getProductTarget(); getHomeInfo.put("target_achievement", result); - }).exceptionally((e) -> { + return null; + },pool); + task5.exceptionally((e) -> { log.error("获取生产任务目标达成: {}", e.getMessage(), e); getHomeInfo.put("target_achievement", null); return null; @@ -178,7 +190,6 @@ public class CockpitServiceImpl implements CockpitService { getHomeInfo.put("ghs_produce", null); return null; }); - //涂板一周生产 CompletableFuture>> task9 = CompletableFuture.supplyAsync(() ->{ List> result =cockpitMapper.getTxQty("7", "TBX"); @@ -910,7 +921,7 @@ public class CockpitServiceImpl implements CockpitService { //查询保湿间信息 CompletableFuture>> task2 = CompletableFuture.supplyAsync(() -> { JSONArray baoShiJian = (JSONArray) redisUtils.get("baoshijian1"); - //todo 待补充信号逻辑 + //todo 设备状态待补充信号逻辑 for (Object object : baoShiJian) { JSONObject jsonObject = (JSONObject) object; if (StringUtils.isBlank(jsonObject.getString("device_status"))) {