diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsDefineEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsDefineEnum.java index c24610c..4de6cdb 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsDefineEnum.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsDefineEnum.java @@ -26,6 +26,16 @@ public enum AcsDefineEnum { "高压泵运行故障", "24", "热风进风口开未到位故障", "25", "热风出风口开未到位故障", "26", "湿度1比较值超限", "27", "湿度2比较值超限", "28")), + //agv状态 1-关机2-运行中3-交通管制4-任务等待5-充电中6-故障中7-低电量 + AGV_STATUS(MapOf.of("关机", "1", "运行中", "2", "交通管制", "3", "任务等待", "4", "充电中", "5", "故障中", "6", "低电量", "7")), + + //RGV状态 1-空闲 2-工作中 3-手动 4-下线 + RGV_STATUS(MapOf.of("1","IDLE","2","WORK","3","UNAVAIL","4","OFFLINE")), + + //载具类型 + VEHICLE_TYPE(MapOf.of("普涂", "1", "连涂", "2")), + + //是否 IS_NOTANDYES(MapOf.of("否", "0", "是", "1")); 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 2d40e8d..826ddaf 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 @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.nl.acs.agv.server.ZheDaAgvService; import org.nl.acs.device.domain.Device; import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver; @@ -13,6 +14,7 @@ import org.nl.acs.device_driver.tianneng.baoshijian.BaoshijianSiteDeviceDriver; import org.nl.acs.device_driver.tianneng.guhuashi.GuhuashiSiteDeviceDriver; import org.nl.acs.device_driver.tianneng.site.SiteDeviceDriver; import org.nl.acs.device_driver.tianneng.site_status.SiteStatusDeviceDriver; +import org.nl.acs.enums.AcsDefineEnum; import org.nl.acs.instruction.domain.InstructionMybatis; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.opc.DeviceAppService; @@ -54,7 +56,7 @@ public class SyncDeviceStatus { try { log.info("自动线程开始查询浙大RGV设备状态"); HttpResponse response = agvService.queryAgvDeviceStatus("1"); - //查询AGV指令列表 + //查询RGV指令列表 JSONArray jsonArray = JSONArray.parseArray(response.body()); List task_codes = jsonArray.stream() .map(r -> ((JSONObject) r).getString("task_code")) @@ -66,6 +68,7 @@ public class SyncDeviceStatus { InstructionMybatis::getInstruction_code, InstructionMybatis::getTask_id )); + //缓存当前lms任务id jsonArray.forEach(r -> { JSONObject Item = (JSONObject) r; Item.put("task_id", ""); @@ -73,6 +76,8 @@ public class SyncDeviceStatus { if (taskId != null) { 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); }); } redisUtils.set("RGV", jsonArray); @@ -127,7 +132,7 @@ public class SyncDeviceStatus { json.put("required_time", guhuashiSiteDeviceDriver.getVW7018()); //固化工艺 0-固化;1-干燥; json.put("craft",guhuashiSiteDeviceDriver.getVW7036()); - json.put("device_statue", guhuashiSiteDeviceDriver.getVW7058()); + 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()); @@ -142,6 +147,7 @@ public class SyncDeviceStatus { json.put("production_time",siteStatusDeviceDriver.getProduction_time()); json.put("error_time",siteStatusDeviceDriver.getError_time()); json.put("end_time",siteStatusDeviceDriver.getEnd_time()); + json.put("device_status", siteStatusDeviceDriver.getError()==0?1:0); site.add(json); } else if (device.getDeviceDriver() instanceof SiteDeviceDriver) { SiteDeviceDriver siteDeviceDriver=(SiteDeviceDriver)device.getDeviceDriver(); @@ -149,9 +155,9 @@ public class SyncDeviceStatus { json.put("device_code", siteDeviceDriver.getDevice_code()); json.put("move", siteDeviceDriver.getMove()); json.put("action", siteDeviceDriver.getAction()); - json.put("pallet_type", siteDeviceDriver.getPallet_type()); + json.put("vehicle_type", siteDeviceDriver.getPallet_type()); json.put("error", siteDeviceDriver.getError()); - json.put("move", siteDeviceDriver.getMove()); + json.put("device_status", siteDeviceDriver.getError()==0?1:0); site.add(json); } else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { AgvNdcOneDeviceDriver agvNdcOneDeviceDriver=(AgvNdcOneDeviceDriver)device.getDeviceDriver(); 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 f591788..032b6e9 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 @@ -116,8 +116,8 @@ public class CockpitServiceImpl implements CockpitService { return null; }); //生产汇总 - CompletableFuture task6 = CompletableFuture.supplyAsync(() -> cockpitMapper.getProductionsummary(), pool); - task6.thenAccept((result) -> { + CompletableFuture task6 = CompletableFuture.supplyAsync(() -> { + JSONObject result =cockpitMapper.getProductionsummary(); List> productionSummaryList = new ArrayList<>(); for (String itemName : Arrays.asList("1", "2", "3")) { Map item = new HashMap<>(); @@ -134,15 +134,16 @@ public class CockpitServiceImpl implements CockpitService { }); } getHomeInfo.put("production_summary", productionSummaryList); - }).exceptionally((e) -> { + return null; + },pool); + task6.exceptionally((e) -> { log.error("生产汇总: {}", e.getMessage(), e); getHomeInfo.put("production_summary", null); return null; }); - //今日生产任务 - CompletableFuture>> task7 = CompletableFuture.supplyAsync(() -> cockpitMapper.getTdWorkmsg(), pool); - task7.thenAccept((result) -> { + CompletableFuture>> task7 = CompletableFuture.supplyAsync(() -> { + List> result =cockpitMapper.getTdWorkmsg(); List> today_work = new ArrayList<>(); if (ObjectUtil.isEmpty(result)) { //测试数据,上线后删除 @@ -157,52 +158,61 @@ public class CockpitServiceImpl implements CockpitService { today_work.add(item1); } getHomeInfo.put("today_work", today_work); - }).exceptionally((e) -> { + return null; + }, pool); + task7.exceptionally((e) -> { log.error("今日生产任务: {}", e.getMessage(), e); getHomeInfo.put("today_work", null); return null; }); //固化一周生产 - CompletableFuture>> task8 = CompletableFuture.supplyAsync(() -> cockpitMapper.getGhsQty("7"), pool); - task8.thenAccept((result) -> { + CompletableFuture>> task8 = CompletableFuture.supplyAsync(() -> { + List> result =cockpitMapper.getGhsQty("7"); List> gh_real_qty_default = new ArrayList<>(); getWeekWorkStatistics(result, gh_real_qty_default, "GHS", 7); getHomeInfo.put("ghs_produce", gh_real_qty_default); - }).exceptionally((e) -> { + return null; + }, pool); + task8.exceptionally((e) -> { log.error("固化一周生产: {}", e.getMessage(), e); getHomeInfo.put("ghs_produce", null); return null; }); + //涂板一周生产 - CompletableFuture>> task9 = CompletableFuture.supplyAsync(() -> cockpitMapper.getTxQty("7", "TBX"), pool); - task9.thenAccept((result) -> { + CompletableFuture>> task9 = CompletableFuture.supplyAsync(() ->{ + List> result =cockpitMapper.getTxQty("7", "TBX"); List> tb_real_qty_default = new ArrayList<>(); getWeekWorkStatistics(result, tb_real_qty_default, "TBX", 7); getHomeInfo.put("tbx_produce", tb_real_qty_default); - }).exceptionally((e) -> { + return null; + }, pool); + task9.exceptionally((e) -> { log.error("涂板一周生产: {}", e.getMessage(), e); getHomeInfo.put("tbx_produce", null); return null; }); - //实时故障告警 - CompletableFuture>> task10 = CompletableFuture.supplyAsync(() -> cockpitMapper.faultAlarm(), pool); - task10.thenAccept((result) -> { + CompletableFuture>> task10 = CompletableFuture.supplyAsync(() -> { + List> result =cockpitMapper.faultAlarm(); //测试数据,上线后删除 faultAlarmDefault(result, "GHS01"); getHomeInfo.put("fault_alarm", result); - }).exceptionally((e) -> { + return null; + }, pool); + task10.exceptionally((e) -> { log.error("实时故障告警: {}", e.getMessage(), e); getHomeInfo.put("fault_alarm", null); return null; }); //近30日故障统计 - CompletableFuture task11 = CompletableFuture.supplyAsync(() -> cockpitMapper.monthlyFaultStatistics(), pool); - task11.thenAccept((result) -> { + CompletableFuture task11 = CompletableFuture.supplyAsync(() -> { + JSONArray result=cockpitMapper.monthlyFaultStatistics(); //测试数据,上线后删除 - monthlyFaultStatisticsDefault(result, "GHS01"); getHomeInfo.put("monthly_fault_statistics", result); - }).exceptionally((e) -> { + return null; + }, pool); + task11.exceptionally((e) -> { log.error("近30日故障统计: {}", e.getMessage(), e); getHomeInfo.put("monthly_fault_statistics", null); return null; @@ -563,6 +573,8 @@ public class CockpitServiceImpl implements CockpitService { res.put("device_code", deviceCode); //todo 运行状态,信号缺失 res.put("mode", 2); + //1-待机;2-生产中;3-故障 + res.put("device_status", "1"); //todo 当前生产时间,信号缺失 res.put("production_time", 0); res.put("device_name", point.getPoint_name()); @@ -588,7 +600,10 @@ public class CockpitServiceImpl implements CockpitService { JSONObject jsonObject = (JSONObject) object; if (pointObj.getPoint_code().equals(jsonObject.getString("device_code"))) { one.put("move", jsonObject.getString("move") == null ? "0" : jsonObject.getString("move")); - one.put("mode", StringUtils.isBlank(jsonObject.getString("mode"))? "运行" : jsonObject.getString("mode")); + // 1正常运行,0故障 + one.put("mode", StringUtils.isBlank(jsonObject.getString("mode")) ? "运行" : jsonObject.getString("mode")); + // 1正常运行,0故障 + //one.put("device_status", jsonObject.getString("mode") == null ? "1" : jsonObject.getString("mode")); //todo 错误码(中文),信号缺失 one.put("error", jsonObject.getString("error") == null ? "0" : jsonObject.getString("error")); } @@ -808,8 +823,8 @@ public class CockpitServiceImpl implements CockpitService { vehicleInfo.put("end_time", end_time); String production_time = StringUtils.isNotBlank(vehicleInfo.getString("production_time")) ? String.valueOf((long) Double.parseDouble(vehicleInfo.getString("production_time")) / 3600) : ""; vehicleInfo.put("production_time", production_time); - //运行状态 - String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : ""; + //todo 正式环境可以去除,在ACS端处理运行状态 + String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : "4"; vehicleInfo.put("device_status", device_status); String vehicle_status = StringUtils.isNotBlank(vehicleInfo.getString("Error")) ? "故障" : "正常"; vehicleInfo.put("vehicle_status", vehicle_status); @@ -864,44 +879,127 @@ public class CockpitServiceImpl implements CockpitService { @Override public JSONArray allDeviceStatus() { JSONArray array = new JSONArray(); - //读取设备缓存信息 - CompletableFuture>> task1 = CompletableFuture.supplyAsync(() -> { - JSONArray baoshijian = (JSONArray) redisUtils.get("baoshijian1"); - JSONArray guhuashi = (JSONArray) redisUtils.get("guhuashi1"); - JSONArray AGV = (JSONArray) redisUtils.get("AGV1"); - JSONArray RGV = (JSONArray) redisUtils.get("RGV1"); - JSONArray site = (JSONArray) redisUtils.get("site1"); - array.add(baoshijian); - array.add(guhuashi); - array.add(AGV); - array.add(RGV); - array.add(site); - return null; + // 固化室详情 + CompletableFuture task1 = CompletableFuture.supplyAsync(() -> { + JSONArray result = cockpitMapper.getGHSInteriorList(); + if (ObjectUtil.isNotEmpty(result)) { + JSONObject ghsDetailInfo = new JSONObject(); + JSONArray ghsDetails = new JSONArray(); + JSONArray guHuaShi = (JSONArray) redisUtils.get("guhuashi1"); + array.add(guHuaShi); + // for (Object object : result) { + // //设备状态 按照lms点位管理来 1-无货;2-有货;3-进料;4固化;5出料,6故障 + // JSONObject d = (JSONObject) object; + // guHuaShi.forEach(r -> { + // JSONObject g = (JSONObject) r; + // if (g.getString("device_code").equals(d.getString("device"))) { + // d.put("device_status", g.getString("device_status")); + // ghsDetails.add(d); + // } + // }); + // } + ghsDetailInfo.put("ghs_detail", result); + array.add(ghsDetailInfo); + } + return array; }, pool); task1.exceptionally((e) -> { log.error("读取设备缓存信息: {}", e.getMessage(), e); return null; }); - // 固化室详情 - CompletableFuture task2 = CompletableFuture.supplyAsync(() -> cockpitMapper.getGHSInteriorList(), pool); - task2.thenAccept((result) -> { - JSONObject ghsDetail = new JSONObject(); - ghsDetail.put("ghs_detail", result); - array.add(ghsDetail); - }).exceptionally((e) -> { - log.error("固化室详情{}", e.getMessage(), e); - JSONObject ghsDetail = new JSONObject(); - ghsDetail.put("ghs_detail", null); - array.add(ghsDetail); + //查询保湿间信息 + CompletableFuture>> task2 = CompletableFuture.supplyAsync(() -> { + JSONArray baoShiJian = (JSONArray) redisUtils.get("baoshijian1"); + //todo 待补充信号逻辑 + for (Object object : baoShiJian) { + JSONObject jsonObject = (JSONObject) object; + if (StringUtils.isBlank(jsonObject.getString("device_status"))) { + jsonObject.put("device_status", "1"); + } + } + array.add(baoShiJian); + return null; + }, pool); + task2.exceptionally((e) -> { + log.error("读取设备缓存信息: {}", e.getMessage(), e); return null; }); - // 输送线详情 - CompletableFuture task3 = CompletableFuture.supplyAsync(() -> cockpitMapper.getSSXInteriorList(), pool); - task3.thenAccept((result) -> { + //查询检测站点数据 + CompletableFuture>> task3 = CompletableFuture.supplyAsync(() -> { + JSONArray site = (JSONArray) redisUtils.get("site1"); + //todo 待补充信号逻辑 + for (Object object : site) { + JSONObject jsonObject = (JSONObject) object; + if (StringUtils.isBlank(jsonObject.getString("device_status"))) { + //0故障1正常 + jsonObject.put("device_status", "1"); + } + } + array.add(site); + return null; + }, pool); + task3.exceptionally((e) -> { + log.error("读取设备缓存信息: {}", e.getMessage(), e); + return null; + }); + //查询AGV数据 + CompletableFuture>> task4 = CompletableFuture.supplyAsync(() -> { + JSONArray agv = (JSONArray) redisUtils.get("AGV1"); + //todo 待补充信号逻辑 + for (Object object : agv) { + JSONObject jsonObject = (JSONObject) object; + if (StringUtils.isBlank(jsonObject.getString("move"))) { + jsonObject.put("move", "0"); + } + if (StringUtils.isBlank(jsonObject.getString("full"))) { + jsonObject.put("full", "0"); + } + if (StringUtils.isBlank(jsonObject.getString("vehicle_type"))) { + jsonObject.put("vehicle_type", "0"); + } + } + array.add(agv); + return null; + }, pool); + task4.exceptionally((e) -> { + log.error("读取设备缓存信息: {}", e.getMessage(), e); + return null; + }); + //查询RGV设备信息 + CompletableFuture>> task5 = CompletableFuture.supplyAsync(() -> { + JSONArray rgv = (JSONArray) redisUtils.get("RGV1"); + //todo 待补充信号逻辑 + for (Object object : rgv) { + JSONObject jsonObject = (JSONObject) object; + //todo 正式环境可以去除,在ACS端处理运行状态 + String device_status = StringUtils.isNotBlank(jsonObject.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(jsonObject.getString("status")) : "4"; + jsonObject.put("device_status", device_status); + if (StringUtils.isBlank(jsonObject.getString("move"))) { + jsonObject.put("move", "0"); + } + if (StringUtils.isBlank(jsonObject.getString("full"))) { + jsonObject.put("full", "0"); + } + if (StringUtils.isBlank(jsonObject.getString("vehicle_type"))) { + jsonObject.put("vehicle_type", "0"); + } + } + array.add(rgv); + return null; + }, pool); + task5.exceptionally((e) -> { + log.error("读取设备缓存信息: {}", e.getMessage(), e); + return null; + }); + // todo 输送线详情,对接Redis + CompletableFuture task6 = CompletableFuture.supplyAsync(() -> { + JSONArray result = cockpitMapper.getSSXInteriorList(); JSONObject ssxDetail = new JSONObject(); ssxDetail.put("ssx_detail", result); array.add(ssxDetail); - }).exceptionally((e) -> { + return null; + }, pool); + task6.exceptionally((e) -> { log.error("输送线详情{}", e.getMessage(), e); JSONObject ssxDetail = new JSONObject(); ssxDetail.put("ssx_detail", ssxDetail); @@ -909,19 +1007,21 @@ public class CockpitServiceImpl implements CockpitService { return null; }); // 库位详情 - CompletableFuture task4 = CompletableFuture.supplyAsync(() -> cockpitMapper.getZCList(), pool); - task4.thenAccept((result) -> { + CompletableFuture task7 = CompletableFuture.supplyAsync(() -> { + JSONArray result = cockpitMapper.getZCList(); JSONObject storage = new JSONObject(); storage.put("storage", result); array.add(storage); - }).exceptionally((e) -> { + return null; + }, pool); + task7.exceptionally((e) -> { log.error("库位详情{}", e.getMessage(), e); JSONObject storage = new JSONObject(); storage.put("storage", null); array.add(storage); return null; }); - CompletableFuture allQuery = CompletableFuture.allOf(task1, task2, task3, task4); + CompletableFuture allQuery = CompletableFuture.allOf(task1, task2, task3, task4, task5, task6, task7); CompletableFuture future = allQuery.thenApply((result) -> array).exceptionally((e) -> { log.error(e.getMessage(), e); return null; diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/mapper/CockpitMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/mapper/CockpitMapper.xml index 0366d2b..8bf7628 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/mapper/CockpitMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/cockpit/service/mapper/CockpitMapper.xml @@ -263,20 +263,39 @@ AND point_type = '2'