opt:优化秒级接口查询;

This commit is contained in:
2024-09-29 14:49:43 +08:00
parent a10d3650d6
commit 0dc2b107bc
4 changed files with 204 additions and 69 deletions

View File

@@ -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"));

View File

@@ -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<String> 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();