opt:优化秒级接口查询;
This commit is contained in:
@@ -26,6 +26,16 @@ public enum AcsDefineEnum {
|
|||||||
"高压泵运行故障", "24", "热风进风口开未到位故障", "25", "热风出风口开未到位故障", "26", "湿度1比较值超限", "27", "湿度2比较值超限", "28")),
|
"高压泵运行故障", "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"));
|
IS_NOTANDYES(MapOf.of("否", "0", "是", "1"));
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.nl.acs.agv.server.ZheDaAgvService;
|
import org.nl.acs.agv.server.ZheDaAgvService;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
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.guhuashi.GuhuashiSiteDeviceDriver;
|
||||||
import org.nl.acs.device_driver.tianneng.site.SiteDeviceDriver;
|
import org.nl.acs.device_driver.tianneng.site.SiteDeviceDriver;
|
||||||
import org.nl.acs.device_driver.tianneng.site_status.SiteStatusDeviceDriver;
|
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.domain.InstructionMybatis;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.opc.DeviceAppService;
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
@@ -54,7 +56,7 @@ public class SyncDeviceStatus {
|
|||||||
try {
|
try {
|
||||||
log.info("自动线程开始查询浙大RGV设备状态");
|
log.info("自动线程开始查询浙大RGV设备状态");
|
||||||
HttpResponse response = agvService.queryAgvDeviceStatus("1");
|
HttpResponse response = agvService.queryAgvDeviceStatus("1");
|
||||||
//查询AGV指令列表
|
//查询RGV指令列表
|
||||||
JSONArray jsonArray = JSONArray.parseArray(response.body());
|
JSONArray jsonArray = JSONArray.parseArray(response.body());
|
||||||
List<String> task_codes = jsonArray.stream()
|
List<String> task_codes = jsonArray.stream()
|
||||||
.map(r -> ((JSONObject) r).getString("task_code"))
|
.map(r -> ((JSONObject) r).getString("task_code"))
|
||||||
@@ -66,6 +68,7 @@ public class SyncDeviceStatus {
|
|||||||
InstructionMybatis::getInstruction_code,
|
InstructionMybatis::getInstruction_code,
|
||||||
InstructionMybatis::getTask_id
|
InstructionMybatis::getTask_id
|
||||||
));
|
));
|
||||||
|
//缓存当前lms任务id
|
||||||
jsonArray.forEach(r -> {
|
jsonArray.forEach(r -> {
|
||||||
JSONObject Item = (JSONObject) r;
|
JSONObject Item = (JSONObject) r;
|
||||||
Item.put("task_id", "");
|
Item.put("task_id", "");
|
||||||
@@ -73,6 +76,8 @@ public class SyncDeviceStatus {
|
|||||||
if (taskId != null) {
|
if (taskId != null) {
|
||||||
Item.put("task_id", 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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
redisUtils.set("RGV", jsonArray);
|
redisUtils.set("RGV", jsonArray);
|
||||||
@@ -127,7 +132,7 @@ public class SyncDeviceStatus {
|
|||||||
json.put("required_time", guhuashiSiteDeviceDriver.getVW7018());
|
json.put("required_time", guhuashiSiteDeviceDriver.getVW7018());
|
||||||
//固化工艺 0-固化;1-干燥;
|
//固化工艺 0-固化;1-干燥;
|
||||||
json.put("craft",guhuashiSiteDeviceDriver.getVW7036());
|
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("front_door", guhuashiSiteDeviceDriver.getVW70004()==0?1:0);
|
||||||
json.put("back_door", guhuashiSiteDeviceDriver.getVW7010());
|
json.put("back_door", guhuashiSiteDeviceDriver.getVW7010());
|
||||||
json.put("error", guhuashiSiteDeviceDriver.getVD7046());
|
json.put("error", guhuashiSiteDeviceDriver.getVD7046());
|
||||||
@@ -142,6 +147,7 @@ public class SyncDeviceStatus {
|
|||||||
json.put("production_time",siteStatusDeviceDriver.getProduction_time());
|
json.put("production_time",siteStatusDeviceDriver.getProduction_time());
|
||||||
json.put("error_time",siteStatusDeviceDriver.getError_time());
|
json.put("error_time",siteStatusDeviceDriver.getError_time());
|
||||||
json.put("end_time",siteStatusDeviceDriver.getEnd_time());
|
json.put("end_time",siteStatusDeviceDriver.getEnd_time());
|
||||||
|
json.put("device_status", siteStatusDeviceDriver.getError()==0?1:0);
|
||||||
site.add(json);
|
site.add(json);
|
||||||
} else if (device.getDeviceDriver() instanceof SiteDeviceDriver) {
|
} else if (device.getDeviceDriver() instanceof SiteDeviceDriver) {
|
||||||
SiteDeviceDriver siteDeviceDriver=(SiteDeviceDriver)device.getDeviceDriver();
|
SiteDeviceDriver siteDeviceDriver=(SiteDeviceDriver)device.getDeviceDriver();
|
||||||
@@ -149,9 +155,9 @@ public class SyncDeviceStatus {
|
|||||||
json.put("device_code", siteDeviceDriver.getDevice_code());
|
json.put("device_code", siteDeviceDriver.getDevice_code());
|
||||||
json.put("move", siteDeviceDriver.getMove());
|
json.put("move", siteDeviceDriver.getMove());
|
||||||
json.put("action", siteDeviceDriver.getAction());
|
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("error", siteDeviceDriver.getError());
|
||||||
json.put("move", siteDeviceDriver.getMove());
|
json.put("device_status", siteDeviceDriver.getError()==0?1:0);
|
||||||
site.add(json);
|
site.add(json);
|
||||||
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
} else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||||
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver=(AgvNdcOneDeviceDriver)device.getDeviceDriver();
|
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver=(AgvNdcOneDeviceDriver)device.getDeviceDriver();
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
//生产汇总
|
//生产汇总
|
||||||
CompletableFuture<JSONObject> task6 = CompletableFuture.supplyAsync(() -> cockpitMapper.getProductionsummary(), pool);
|
CompletableFuture<JSONObject> task6 = CompletableFuture.supplyAsync(() -> {
|
||||||
task6.thenAccept((result) -> {
|
JSONObject result =cockpitMapper.getProductionsummary();
|
||||||
List<Map<String, Object>> productionSummaryList = new ArrayList<>();
|
List<Map<String, Object>> productionSummaryList = new ArrayList<>();
|
||||||
for (String itemName : Arrays.asList("1", "2", "3")) {
|
for (String itemName : Arrays.asList("1", "2", "3")) {
|
||||||
Map<String, Object> item = new HashMap<>();
|
Map<String, Object> item = new HashMap<>();
|
||||||
@@ -134,15 +134,16 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getHomeInfo.put("production_summary", productionSummaryList);
|
getHomeInfo.put("production_summary", productionSummaryList);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
},pool);
|
||||||
|
task6.exceptionally((e) -> {
|
||||||
log.error("生产汇总: {}", e.getMessage(), e);
|
log.error("生产汇总: {}", e.getMessage(), e);
|
||||||
getHomeInfo.put("production_summary", null);
|
getHomeInfo.put("production_summary", null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
//今日生产任务
|
//今日生产任务
|
||||||
CompletableFuture<List<Map<String, Object>>> task7 = CompletableFuture.supplyAsync(() -> cockpitMapper.getTdWorkmsg(), pool);
|
CompletableFuture<List<Map<String, Object>>> task7 = CompletableFuture.supplyAsync(() -> {
|
||||||
task7.thenAccept((result) -> {
|
List<Map<String, Object>> result =cockpitMapper.getTdWorkmsg();
|
||||||
List<Map<String, Object>> today_work = new ArrayList<>();
|
List<Map<String, Object>> today_work = new ArrayList<>();
|
||||||
if (ObjectUtil.isEmpty(result)) {
|
if (ObjectUtil.isEmpty(result)) {
|
||||||
//测试数据,上线后删除
|
//测试数据,上线后删除
|
||||||
@@ -157,52 +158,61 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
today_work.add(item1);
|
today_work.add(item1);
|
||||||
}
|
}
|
||||||
getHomeInfo.put("today_work", today_work);
|
getHomeInfo.put("today_work", today_work);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task7.exceptionally((e) -> {
|
||||||
log.error("今日生产任务: {}", e.getMessage(), e);
|
log.error("今日生产任务: {}", e.getMessage(), e);
|
||||||
getHomeInfo.put("today_work", null);
|
getHomeInfo.put("today_work", null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
//固化一周生产
|
//固化一周生产
|
||||||
CompletableFuture<List<Map<String, Object>>> task8 = CompletableFuture.supplyAsync(() -> cockpitMapper.getGhsQty("7"), pool);
|
CompletableFuture<List<Map<String, Object>>> task8 = CompletableFuture.supplyAsync(() -> {
|
||||||
task8.thenAccept((result) -> {
|
List<Map<String, Object>> result =cockpitMapper.getGhsQty("7");
|
||||||
List<Map<String, Object>> gh_real_qty_default = new ArrayList<>();
|
List<Map<String, Object>> gh_real_qty_default = new ArrayList<>();
|
||||||
getWeekWorkStatistics(result, gh_real_qty_default, "GHS", 7);
|
getWeekWorkStatistics(result, gh_real_qty_default, "GHS", 7);
|
||||||
getHomeInfo.put("ghs_produce", gh_real_qty_default);
|
getHomeInfo.put("ghs_produce", gh_real_qty_default);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task8.exceptionally((e) -> {
|
||||||
log.error("固化一周生产: {}", e.getMessage(), e);
|
log.error("固化一周生产: {}", e.getMessage(), e);
|
||||||
getHomeInfo.put("ghs_produce", null);
|
getHomeInfo.put("ghs_produce", null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
//涂板一周生产
|
//涂板一周生产
|
||||||
CompletableFuture<List<Map<String, Object>>> task9 = CompletableFuture.supplyAsync(() -> cockpitMapper.getTxQty("7", "TBX"), pool);
|
CompletableFuture<List<Map<String, Object>>> task9 = CompletableFuture.supplyAsync(() ->{
|
||||||
task9.thenAccept((result) -> {
|
List<Map<String, Object>> result =cockpitMapper.getTxQty("7", "TBX");
|
||||||
List<Map<String, Object>> tb_real_qty_default = new ArrayList<>();
|
List<Map<String, Object>> tb_real_qty_default = new ArrayList<>();
|
||||||
getWeekWorkStatistics(result, tb_real_qty_default, "TBX", 7);
|
getWeekWorkStatistics(result, tb_real_qty_default, "TBX", 7);
|
||||||
getHomeInfo.put("tbx_produce", tb_real_qty_default);
|
getHomeInfo.put("tbx_produce", tb_real_qty_default);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task9.exceptionally((e) -> {
|
||||||
log.error("涂板一周生产: {}", e.getMessage(), e);
|
log.error("涂板一周生产: {}", e.getMessage(), e);
|
||||||
getHomeInfo.put("tbx_produce", null);
|
getHomeInfo.put("tbx_produce", null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
//实时故障告警
|
//实时故障告警
|
||||||
CompletableFuture<List<Map<String, Object>>> task10 = CompletableFuture.supplyAsync(() -> cockpitMapper.faultAlarm(), pool);
|
CompletableFuture<List<Map<String, Object>>> task10 = CompletableFuture.supplyAsync(() -> {
|
||||||
task10.thenAccept((result) -> {
|
List<Map<String, Object>> result =cockpitMapper.faultAlarm();
|
||||||
//测试数据,上线后删除
|
//测试数据,上线后删除
|
||||||
faultAlarmDefault(result, "GHS01");
|
faultAlarmDefault(result, "GHS01");
|
||||||
getHomeInfo.put("fault_alarm", result);
|
getHomeInfo.put("fault_alarm", result);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task10.exceptionally((e) -> {
|
||||||
log.error("实时故障告警: {}", e.getMessage(), e);
|
log.error("实时故障告警: {}", e.getMessage(), e);
|
||||||
getHomeInfo.put("fault_alarm", null);
|
getHomeInfo.put("fault_alarm", null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
//近30日故障统计
|
//近30日故障统计
|
||||||
CompletableFuture<JSONArray> task11 = CompletableFuture.supplyAsync(() -> cockpitMapper.monthlyFaultStatistics(), pool);
|
CompletableFuture<JSONArray> task11 = CompletableFuture.supplyAsync(() -> {
|
||||||
task11.thenAccept((result) -> {
|
JSONArray result=cockpitMapper.monthlyFaultStatistics();
|
||||||
//测试数据,上线后删除
|
//测试数据,上线后删除
|
||||||
monthlyFaultStatisticsDefault(result, "GHS01");
|
|
||||||
getHomeInfo.put("monthly_fault_statistics", result);
|
getHomeInfo.put("monthly_fault_statistics", result);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task11.exceptionally((e) -> {
|
||||||
log.error("近30日故障统计: {}", e.getMessage(), e);
|
log.error("近30日故障统计: {}", e.getMessage(), e);
|
||||||
getHomeInfo.put("monthly_fault_statistics", null);
|
getHomeInfo.put("monthly_fault_statistics", null);
|
||||||
return null;
|
return null;
|
||||||
@@ -563,6 +573,8 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
res.put("device_code", deviceCode);
|
res.put("device_code", deviceCode);
|
||||||
//todo 运行状态,信号缺失
|
//todo 运行状态,信号缺失
|
||||||
res.put("mode", 2);
|
res.put("mode", 2);
|
||||||
|
//1-待机;2-生产中;3-故障
|
||||||
|
res.put("device_status", "1");
|
||||||
//todo 当前生产时间,信号缺失
|
//todo 当前生产时间,信号缺失
|
||||||
res.put("production_time", 0);
|
res.put("production_time", 0);
|
||||||
res.put("device_name", point.getPoint_name());
|
res.put("device_name", point.getPoint_name());
|
||||||
@@ -588,7 +600,10 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
JSONObject jsonObject = (JSONObject) object;
|
JSONObject jsonObject = (JSONObject) object;
|
||||||
if (pointObj.getPoint_code().equals(jsonObject.getString("device_code"))) {
|
if (pointObj.getPoint_code().equals(jsonObject.getString("device_code"))) {
|
||||||
one.put("move", jsonObject.getString("move") == null ? "0" : jsonObject.getString("move"));
|
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 错误码(中文),信号缺失
|
//todo 错误码(中文),信号缺失
|
||||||
one.put("error", jsonObject.getString("error") == null ? "0" : jsonObject.getString("error"));
|
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);
|
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) : "";
|
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);
|
vehicleInfo.put("production_time", production_time);
|
||||||
//运行状态
|
//todo 正式环境可以去除,在ACS端处理运行状态
|
||||||
String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : "";
|
String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : "4";
|
||||||
vehicleInfo.put("device_status", device_status);
|
vehicleInfo.put("device_status", device_status);
|
||||||
String vehicle_status = StringUtils.isNotBlank(vehicleInfo.getString("Error")) ? "故障" : "正常";
|
String vehicle_status = StringUtils.isNotBlank(vehicleInfo.getString("Error")) ? "故障" : "正常";
|
||||||
vehicleInfo.put("vehicle_status", vehicle_status);
|
vehicleInfo.put("vehicle_status", vehicle_status);
|
||||||
@@ -864,44 +879,127 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
@Override
|
@Override
|
||||||
public JSONArray allDeviceStatus() {
|
public JSONArray allDeviceStatus() {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
//读取设备缓存信息
|
// 固化室详情
|
||||||
CompletableFuture<List<Map<String, Object>>> task1 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<JSONArray> task1 = CompletableFuture.supplyAsync(() -> {
|
||||||
JSONArray baoshijian = (JSONArray) redisUtils.get("baoshijian1");
|
JSONArray result = cockpitMapper.getGHSInteriorList();
|
||||||
JSONArray guhuashi = (JSONArray) redisUtils.get("guhuashi1");
|
if (ObjectUtil.isNotEmpty(result)) {
|
||||||
JSONArray AGV = (JSONArray) redisUtils.get("AGV1");
|
JSONObject ghsDetailInfo = new JSONObject();
|
||||||
JSONArray RGV = (JSONArray) redisUtils.get("RGV1");
|
JSONArray ghsDetails = new JSONArray();
|
||||||
JSONArray site = (JSONArray) redisUtils.get("site1");
|
JSONArray guHuaShi = (JSONArray) redisUtils.get("guhuashi1");
|
||||||
array.add(baoshijian);
|
array.add(guHuaShi);
|
||||||
array.add(guhuashi);
|
// for (Object object : result) {
|
||||||
array.add(AGV);
|
// //设备状态 按照lms点位管理来 1-无货;2-有货;3-进料;4固化;5出料,6故障
|
||||||
array.add(RGV);
|
// JSONObject d = (JSONObject) object;
|
||||||
array.add(site);
|
// guHuaShi.forEach(r -> {
|
||||||
return null;
|
// 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);
|
}, pool);
|
||||||
task1.exceptionally((e) -> {
|
task1.exceptionally((e) -> {
|
||||||
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
// 固化室详情
|
//查询保湿间信息
|
||||||
CompletableFuture<JSONArray> task2 = CompletableFuture.supplyAsync(() -> cockpitMapper.getGHSInteriorList(), pool);
|
CompletableFuture<List<Map<String, Object>>> task2 = CompletableFuture.supplyAsync(() -> {
|
||||||
task2.thenAccept((result) -> {
|
JSONArray baoShiJian = (JSONArray) redisUtils.get("baoshijian1");
|
||||||
JSONObject ghsDetail = new JSONObject();
|
//todo 待补充信号逻辑
|
||||||
ghsDetail.put("ghs_detail", result);
|
for (Object object : baoShiJian) {
|
||||||
array.add(ghsDetail);
|
JSONObject jsonObject = (JSONObject) object;
|
||||||
}).exceptionally((e) -> {
|
if (StringUtils.isBlank(jsonObject.getString("device_status"))) {
|
||||||
log.error("固化室详情{}", e.getMessage(), e);
|
jsonObject.put("device_status", "1");
|
||||||
JSONObject ghsDetail = new JSONObject();
|
}
|
||||||
ghsDetail.put("ghs_detail", null);
|
}
|
||||||
array.add(ghsDetail);
|
array.add(baoShiJian);
|
||||||
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task2.exceptionally((e) -> {
|
||||||
|
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
// 输送线详情
|
//查询检测站点数据
|
||||||
CompletableFuture<JSONArray> task3 = CompletableFuture.supplyAsync(() -> cockpitMapper.getSSXInteriorList(), pool);
|
CompletableFuture<List<Map<String, Object>>> task3 = CompletableFuture.supplyAsync(() -> {
|
||||||
task3.thenAccept((result) -> {
|
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<List<Map<String, Object>>> 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<List<Map<String, Object>>> 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<JSONArray> task6 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
JSONArray result = cockpitMapper.getSSXInteriorList();
|
||||||
JSONObject ssxDetail = new JSONObject();
|
JSONObject ssxDetail = new JSONObject();
|
||||||
ssxDetail.put("ssx_detail", result);
|
ssxDetail.put("ssx_detail", result);
|
||||||
array.add(ssxDetail);
|
array.add(ssxDetail);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task6.exceptionally((e) -> {
|
||||||
log.error("输送线详情{}", e.getMessage(), e);
|
log.error("输送线详情{}", e.getMessage(), e);
|
||||||
JSONObject ssxDetail = new JSONObject();
|
JSONObject ssxDetail = new JSONObject();
|
||||||
ssxDetail.put("ssx_detail", ssxDetail);
|
ssxDetail.put("ssx_detail", ssxDetail);
|
||||||
@@ -909,19 +1007,21 @@ public class CockpitServiceImpl implements CockpitService {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
// 库位详情
|
// 库位详情
|
||||||
CompletableFuture<JSONArray> task4 = CompletableFuture.supplyAsync(() -> cockpitMapper.getZCList(), pool);
|
CompletableFuture<JSONArray> task7 = CompletableFuture.supplyAsync(() -> {
|
||||||
task4.thenAccept((result) -> {
|
JSONArray result = cockpitMapper.getZCList();
|
||||||
JSONObject storage = new JSONObject();
|
JSONObject storage = new JSONObject();
|
||||||
storage.put("storage", result);
|
storage.put("storage", result);
|
||||||
array.add(storage);
|
array.add(storage);
|
||||||
}).exceptionally((e) -> {
|
return null;
|
||||||
|
}, pool);
|
||||||
|
task7.exceptionally((e) -> {
|
||||||
log.error("库位详情{}", e.getMessage(), e);
|
log.error("库位详情{}", e.getMessage(), e);
|
||||||
JSONObject storage = new JSONObject();
|
JSONObject storage = new JSONObject();
|
||||||
storage.put("storage", null);
|
storage.put("storage", null);
|
||||||
array.add(storage);
|
array.add(storage);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
CompletableFuture<Void> allQuery = CompletableFuture.allOf(task1, task2, task3, task4);
|
CompletableFuture<Void> allQuery = CompletableFuture.allOf(task1, task2, task3, task4, task5, task6, task7);
|
||||||
CompletableFuture<JSONArray> future = allQuery.thenApply((result) -> array).exceptionally((e) -> {
|
CompletableFuture<JSONArray> future = allQuery.thenApply((result) -> array).exceptionally((e) -> {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -263,20 +263,39 @@
|
|||||||
AND point_type = '2'
|
AND point_type = '2'
|
||||||
</select>
|
</select>
|
||||||
<select id="getSSXInteriorList" resultType="com.alibaba.fastjson.JSONObject">
|
<select id="getSSXInteriorList" resultType="com.alibaba.fastjson.JSONObject">
|
||||||
SELECT CAST(point_status - 1 AS SIGNED) AS move,
|
SELECT
|
||||||
point_code AS device_code,
|
CAST( point_status - 1 AS SIGNED ) AS move,
|
||||||
point_name AS device_name,
|
point_code AS device_code,
|
||||||
"1" AS mode,
|
point_name AS device_name,
|
||||||
"0" AS error,
|
"1" AS mode,
|
||||||
parent_point_code AS device
|
"0" AS error,
|
||||||
FROM `sch_base_point`
|
"1" AS device_status,
|
||||||
WHERE region_code = 'KJZC'
|
parent_point_code AS device,
|
||||||
|
CASE
|
||||||
|
vehicle_type
|
||||||
|
WHEN 1 THEN
|
||||||
|
"1"
|
||||||
|
WHEN 2 THEN
|
||||||
|
"2" ELSE "0"
|
||||||
|
END AS vehicle_type
|
||||||
|
FROM
|
||||||
|
`sch_base_point`
|
||||||
|
WHERE
|
||||||
|
region_code = 'KJZC'
|
||||||
AND point_type IN ('1', '3', '4')
|
AND point_type IN ('1', '3', '4')
|
||||||
</select>
|
</select>
|
||||||
<select id="getZCList" resultType="com.alibaba.fastjson.JSONObject">
|
<select id="getZCList" resultType="com.alibaba.fastjson.JSONObject">
|
||||||
SELECT CAST(point_status - 1 AS SIGNED) AS move,
|
SELECT CAST(point_status - 1 AS SIGNED) AS move,
|
||||||
point_code AS device_code,
|
point_code AS device_code,
|
||||||
point_name AS device_name
|
point_name AS device_name,
|
||||||
|
CASE
|
||||||
|
vehicle_type
|
||||||
|
WHEN 1 THEN
|
||||||
|
"1"
|
||||||
|
WHEN 2 THEN
|
||||||
|
"2"
|
||||||
|
ELSE "0"
|
||||||
|
END AS vehicle_type
|
||||||
FROM `sch_base_point`
|
FROM `sch_base_point`
|
||||||
WHERE region_code = 'ZC'
|
WHERE region_code = 'ZC'
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user