This commit is contained in:
USER-20220102CG\noblelift
2023-01-08 21:38:25 +08:00
parent 56de42b2cd
commit 8f0bfc0e9d
29 changed files with 587 additions and 221 deletions

View File

@@ -0,0 +1,44 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.ext.wms.liKuData.DeviceStatusRequest;
import org.nl.acs.ext.wms.liKuData.DeviceStatusResponse;
import org.nl.acs.ext.wms.liKuData.Resp;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 查询立库设备状态
*/
@Slf4j
@Component
public class QueryLKDeviceStatus {
@Autowired
AcsToLiKuService acsToLiKuService;
public void run() throws Exception {
DeviceStatusRequest deviceStatusRequest = new DeviceStatusRequest();
deviceStatusRequest.setDeviceId("0");
Resp<DeviceStatusResponse> carResp = acsToLiKuService.queryCarDeviceStatus(deviceStatusRequest);
Resp<DeviceStatusResponse> ssxResp = acsToLiKuService.querySsxDeviceStatus(deviceStatusRequest);
Resp<DeviceStatusResponse> tsjResp = acsToLiKuService.queryTsjDeviceStatus(deviceStatusRequest);
}
}

View File

@@ -1,164 +0,0 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 查询AGV任务状态
*/
@Slf4j
@Component
public class QueryZDAgvTaskStatus {
@Autowired
InstructionService instructionService;
@Autowired
ZheDaAgvService agvService;
public void run() throws Exception {
HttpResponse response = agvService.queryAgvInstStatus("1");
//查询AGV指令列表
JSONArray inst_rows = JSONArray.parseArray(response.body());
for (int i = 0; i < inst_rows.size(); i++) {
JSONObject inst_jo = inst_rows.getJSONObject(i);
String inst_code = inst_jo.getString("task_code");
Instruction inst = instructionService.findByCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(inst)){
continue;
}
//反馈结果状态
log.info("instcode" + inst_code + "," + inst_jo.toString());
String state = inst_jo.getString("state");
String vehicle = "";
//正在执行指令agv车号
if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) {
vehicle = inst_jo.getString("vehicle");
inst.setCarno(vehicle);
}
// RAW初始状态
// ACTIVE业务订单已激活
// DISPATCHABLE业务订单已通过系统验证等待被调度执行
// BEING_PROCESSED业务订单正在被执行
// WITHDRAWN业务订单已被撤销
// FINISHED业务订单已完成
// FAILED业务订单已失败
// UNROUTABLE无法规划该业务订单的执行路线
//执行中
if ("BEING_PROCESSED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
} else if ("FINISHED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("2");
instructionService.finish(inst);
}
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("3");
instructionService.update(inst);
instructionService.removeByCodeFromCache(inst_jo.getString("task_code"));
}
}
JSONArray ja = inst_jo.getJSONArray("destinations");
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = ja.getJSONObject(j);
JSONArray pro_rows = jo.getJSONArray("properties");
//Load 取货动作 Unload放货动作 Wait等待
String operation = jo.getString("operation");
String device = jo.getString("locationName");
for (int k = 0; k < pro_rows.size(); k++) {
JSONObject item = pro_rows.getJSONObject(k);
if ("True".equals(item.get("value"))) {
String param = item.get("key").toString();
//EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待
agvService.process(inst_code, param, device, operation, vehicle);
}
}
}
}
HttpResponse response2 = agvService.queryAgvInstStatus("2");
//查询AGV指令列表
JSONArray inst_rows2 = JSONArray.parseArray(response2.body());
for (int i = 0; i < inst_rows2.size(); i++) {
JSONObject inst_jo = inst_rows2.getJSONObject(i);
String inst_code = inst_jo.getString("task_code");
Instruction inst = instructionService.findByCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(inst)){
continue;
}
//反馈结果状态
log.info("instcode" + inst_code + "," + inst_jo.toString());
String state = inst_jo.getString("state");
String vehicle = "";
//正在执行指令agv车号
if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) {
vehicle = inst_jo.getString("vehicle");
inst.setCarno(vehicle);
}
// RAW初始状态
// ACTIVE业务订单已激活
// DISPATCHABLE业务订单已通过系统验证等待被调度执行
// BEING_PROCESSED业务订单正在被执行
// WITHDRAWN业务订单已被撤销
// FINISHED业务订单已完成
// FAILED业务订单已失败
// UNROUTABLE无法规划该业务订单的执行路线
//执行中
if ("BEING_PROCESSED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
} else if ("FINISHED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("2");
instructionService.finish(inst);
}
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("3");
instructionService.update(inst);
instructionService.removeByCodeFromCache(inst_jo.getString("task_code"));
}
}
JSONArray ja = inst_jo.getJSONArray("destinations");
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = ja.getJSONObject(j);
JSONArray pro_rows = jo.getJSONArray("properties");
//Load 取货动作 Unload放货动作 Wait等待
String operation = jo.getString("operation");
String device = jo.getString("locationName");
for (int k = 0; k < pro_rows.size(); k++) {
JSONObject item = pro_rows.getJSONObject(k);
if ("True".equals(item.get("value"))) {
String param = item.get("key").toString();
//EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待
agvService.process(inst_code, param, device, operation, vehicle);
}
}
}
}
}
}