add:监控大屏AGV、CTU显示

This commit is contained in:
2025-08-13 15:59:08 +08:00
parent 1363bea736
commit f0d8573c58
29 changed files with 1671 additions and 639 deletions

View File

@@ -92,7 +92,10 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
@Override
public <T> UnifiedResponse<T> queryXZAgvDeviceStatus(String vehicles, Class<T> type) {
String path = "/robotsStatus" + vehicles == null ? "" : "vehicles = " + vehicles;
String path = "/robotsStatus";
if (vehicles != null) {
path = "/robotsStatus?vehicles=" + vehicles;
}
return xgHttpUtil.sendGetRequest(path, type);
}
@@ -116,7 +119,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
String path = "/terminate";
JSONObject reqParam = new JSONObject();
reqParam.put("id", instCode);
reqParam.put("disableVehicle",false);
reqParam.put("disableVehicle", false);
return xgHttpUtil.sendPostRequest(path, reqParam);
}

View File

@@ -129,4 +129,7 @@ public interface DeviceAppService {
* 查找设备区域
*/
TreeSet<Integer> selectRegion();
List<Device> findDeviceByRegion(String region);
}

View File

@@ -20,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
/**
* @author 20220102CG\noblelift
@@ -404,6 +406,7 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
}
}
@Override
public TreeSet<Integer> selectRegion() {
TreeSet<Integer> set = new TreeSet<>();
@@ -413,4 +416,14 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
return set;
}
@Override
public List<Device> findDeviceByRegion(String region) {
return Optional.ofNullable(this.devices)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(device -> StrUtil.equals(device.getRegion(), region))
.sorted(Comparator.comparing(Device::getDevice_code))
.collect(Collectors.toList());
}
}

View File

@@ -901,60 +901,60 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (!StrUtil.isEmpty(hasGoodStatus)) {
standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(hasGoodStatus));
device.setHas_goods(Integer.parseInt(hasGoodStatus));
}
if (StrUtil.isNotEmpty(material_type)) {
standardOrdinarySiteDeviceDriver.setMaterial(material_type);
device.setMaterial_type(material_type);
} else {
standardOrdinarySiteDeviceDriver.setMaterial("");
device.setMaterial_type("");
}
if (StrUtil.isNotEmpty(quantity)) {
standardOrdinarySiteDeviceDriver.setQty(quantity);
device.setQuantity(quantity);
} else {
standardOrdinarySiteDeviceDriver.setQty("");
device.setQuantity("");
}
if (StrUtil.isNotEmpty(remark)) {
standardOrdinarySiteDeviceDriver.setRemark(remark);
device.setRemark(remark);
} else {
standardOrdinarySiteDeviceDriver.setRemark("");
device.setRemark("");
}
if (StrUtil.isNotEmpty(batch)) {
standardOrdinarySiteDeviceDriver.setBatch(batch);
device.setBatch(batch);
} else {
standardOrdinarySiteDeviceDriver.setBatch("");
device.setBatch("");
}
// WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint");
// JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0);
DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper)
.eq(DeviceRunpoint::getDevice_code, device_code)
.one();
if (!ObjectUtil.isEmpty(deviceRunpoint)) {
// DeviceRunpointDto obj = json.toJavaObject(DeviceRunpointDto.class);
deviceRunpoint.setHasgoods(hasGoodStatus);
deviceRunpoint.setMaterial_type(material_type);
deviceRunpoint.setBatch(batch);
device.setHas_goods(Integer.parseInt(hasGoodStatus));
device.setMaterial_type(material_type);
device.setRemark(remark);
device.setQuantity(quantity);
device.setBatch(batch);
device.setIslock(islock);
// JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
// runpointwo.update(updatejson, "device_code = '" + device_code + "'");
LambdaQueryWrapper<DeviceRunpoint> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DeviceRunpoint::getDevice_code, device_code);
deviceRunpointMapper.delete(wrapper);
}
// if (!StrUtil.isEmpty(hasGoodStatus)) {
// standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(hasGoodStatus));
// device.setHas_goods(Integer.parseInt(hasGoodStatus));
// }
// if (StrUtil.isNotEmpty(material_type)) {
// standardOrdinarySiteDeviceDriver.setMaterial(material_type);
// device.setMaterial_type(material_type);
// } else {
// standardOrdinarySiteDeviceDriver.setMaterial("");
// device.setMaterial_type("");
// }
// if (StrUtil.isNotEmpty(quantity)) {
// standardOrdinarySiteDeviceDriver.setQty(quantity);
// device.setQuantity(quantity);
// } else {
// standardOrdinarySiteDeviceDriver.setQty("");
// device.setQuantity("");
// }
// if (StrUtil.isNotEmpty(remark)) {
// standardOrdinarySiteDeviceDriver.setRemark(remark);
// device.setRemark(remark);
// } else {
// standardOrdinarySiteDeviceDriver.setRemark("");
// device.setRemark("");
// }
// if (StrUtil.isNotEmpty(batch)) {
// standardOrdinarySiteDeviceDriver.setBatch(batch);
// device.setBatch(batch);
// } else {
// standardOrdinarySiteDeviceDriver.setBatch("");
// device.setBatch("");
// }
//// WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint");
//// JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0);
// DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper)
// .eq(DeviceRunpoint::getDevice_code, device_code)
// .one();
// if (!ObjectUtil.isEmpty(deviceRunpoint)) {
//// DeviceRunpointDto obj = json.toJavaObject(DeviceRunpointDto.class);
// deviceRunpoint.setHasgoods(hasGoodStatus);
// deviceRunpoint.setMaterial_type(material_type);
// deviceRunpoint.setBatch(batch);
// device.setHas_goods(Integer.parseInt(hasGoodStatus));
// device.setMaterial_type(material_type);
// device.setRemark(remark);
// device.setQuantity(quantity);
// device.setBatch(batch);
// device.setIslock(islock);
//// JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
//// runpointwo.update(updatejson, "device_code = '" + device_code + "'");
// LambdaQueryWrapper<DeviceRunpoint> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(DeviceRunpoint::getDevice_code, device_code);
// deviceRunpointMapper.delete(wrapper);
// }
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.setMaterial(material_type);

View File

@@ -0,0 +1,50 @@
package org.nl.acs.device.driver.agv.hik_ctu;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.enums.DeviceType;
import org.nl.acs.device.driver.DeviceDriver;
import org.nl.acs.device.driver.DeviceDriverDefination;
import org.nl.acs.device.driver.agv.xg_agv_car.XgAgvCarDeviceDriver;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 海康CTU
*/
@Service
public class HikCtuCarDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "hik_ctu_car";
}
@Override
public String getDriverName() {
return "HikCtu车";
}
@Override
public String getDriverDescription() {
return "HikCtu车";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new HikCtuCarDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return HikCtuCarDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.agv);
return types;
}
}

View File

@@ -0,0 +1,102 @@
package org.nl.acs.device.driver.agv.hik_ctu;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.nl.acs.device.driver.AbstractDeviceDriver;
import org.nl.acs.device.driver.DeviceDriver;
import org.nl.acs.device.driver.ExecutableDeviceDriver;
import org.nl.acs.device.driver.RouteableDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.config.SpringContextHolder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 海康CTU
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class HikCtuCarDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
private static final Map<String, String> STATUS_MAP = new HashMap<>();
static {
STATUS_MAP.put("1", "任务完成");
STATUS_MAP.put("2", "任务执行中");
STATUS_MAP.put("3", "任务异常");
STATUS_MAP.put("4", "任务空闲");
STATUS_MAP.put("5", "机器人暂停");
STATUS_MAP.put("6", "举升货架状态");
STATUS_MAP.put("7", "充电状态");
STATUS_MAP.put("8", "弧线行走中");
STATUS_MAP.put("9", "充满维护");
STATUS_MAP.put("11", "背货未识别");
STATUS_MAP.put("12", "货架偏角过大");
STATUS_MAP.put("13", "运动库异常");
STATUS_MAP.put("14", "货码无法识别");
STATUS_MAP.put("15", "货码不匹配");
STATUS_MAP.put("16", "举升异常");
STATUS_MAP.put("17", "充电桩异常");
STATUS_MAP.put("18", "电量无增加");
STATUS_MAP.put("20", "充电指令角度错误");
STATUS_MAP.put("21", "平台下发指令错误");
STATUS_MAP.put("23", "外力下放");
STATUS_MAP.put("24", "货架为止偏移");
STATUS_MAP.put("25", "小车不在锁定区");
STATUS_MAP.put("27", "货架摆歪");
STATUS_MAP.put("28", "举升电池点量太低");
STATUS_MAP.put("29", "后退角度偏大");
STATUS_MAP.put("30", "未背货架举升");
STATUS_MAP.put("31", "区域锁定失败");
STATUS_MAP.put("33", "旋转申请暂时失败");
STATUS_MAP.put("34", "地图切换点地码未识别");
}
private String device_code;
private String status = null;
private String task = null;
private Float battery_level = 1.0f;
private Float x;
private Float y;
private Boolean isError = false;
@Override
public void execute() {
this.device_code = this.getDevice().getDevice_code();
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
List<String> instCodeListByAgvCar = instructionService.getInstCodeListByAgvCar(this.device_code);
jo.put("device_code", this.device_code);
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("status", STATUS_MAP.get(this.status));
jo.put("isError", this.isError);
jo.put("isOnline", true);
jo.put("task", CollectionUtils.isEmpty(instCodeListByAgvCar) ? null : JSON.toJSONString(instCodeListByAgvCar));
jo.put("battery_level", this.battery_level);
jo.put("x", this.x);
jo.put("y", this.y);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

View File

@@ -1,33 +1,15 @@
package org.nl.acs.device.driver.agv.xg_agv_car;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.device.service.DeviceService;
import org.nl.acs.device.driver.DeviceDriver;
import org.nl.acs.device.driver.RouteableDeviceDriver;
import org.nl.acs.device.driver.AbstractDeviceDriver;
import org.nl.acs.device.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.config.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
/**
@@ -37,168 +19,54 @@ import java.util.Date;
@Data
@RequiredArgsConstructor
public class XgAgvCarDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@Autowired
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
@Autowired
private XianGongAgvService xianGongAgvService;
Integer hasGoods = 0;
int error = 0;
Boolean iserror = false;
Boolean islock = false;
int branchProtocol = 0;
int last_branchProtocol = 0;
/**
* 是否需要输入物料
*/
String input_material = "0";
/**
* 备注
*/
String remark = "";
/**
* 数量
*/
String qty = "";
/**
* 批次
*/
String batch = "";
/**
* 物料
*/
String material = "";
/**
* 目标点位
*/
String purpose = "";
/**
* 当前指令
*/
Instruction inst = null;
/**
* 上次指令
*/
Instruction last_inst = null;
boolean requireSucess = false;
/**
* 触摸屏手动触发任务
* 设备号
*/
private Boolean is_has_task = false;
private String device_code;
/**
* 申请搬运任务
* 机器人状态
*/
private Boolean apply_handling = false;
/**
* 申请物料
*/
private Boolean apply_material = false;
private String status = null;
/**
* 1取货完成 2放货完成 3进入区域 4离开区域
* 机器人执行任务号
*/
private int flag;
private String task = null;
/**
* 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
* 机器人电量
*/
private int manua_confirm = 0;
private Float battery_level = 1.0f;
/**
* 是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
* x坐标
*/
private String upload_scene_status;
private Float x;
/**
* 机器人当前运单
* y坐标
*/
private String current_order;
/**
* 机器人连接状态 0表示断连 1表示连接上
*/
private String connection_status;
/**
* 机器人可接单状态 true=可接单 false=不可接单
*/
private String dispatchable;
/**
* core出错标识
*/
private boolean is_error;
/**
* 是否正在执行用户下发的运单
*/
private boolean procBusiness;
String device_code = null;
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
String message;
// 1 上位系统允许进入 2 上位系统允许离开
int status = 0;
int agvphase = 0;
int index = 0;
int mode = 2;
int move;
private Float y;
@Override
public void execute() {
this.device_code = this.getDevice().getDevice_code();
}
@Override
public JSONObject getDeviceStatusName() {
getAgvStatus();
JSONObject jo = new JSONObject();
String isError;
if (is_error) {
isError = "报错";
} else {
isError = "正常";
}
if (CommonFinalParam.ONE.equals(upload_scene_status)) {
upload_scene_status = "正在更新场景";
} else if (CommonFinalParam.TWO.equals(upload_scene_status)) {
upload_scene_status = "正在执行运单";
} else if (CommonFinalParam.DELETE.equals(upload_scene_status)) {
upload_scene_status = "可推送";
}
jo.put("is_error", isError);
jo.put("upload_scene_status", upload_scene_status);
jo.put("procBusiness", procBusiness);
jo.put("current_order", current_order);
jo.put("connection_status", connection_status);
jo.put("dispatchable", dispatchable);
jo.put("device_code", this.device_code);
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("status", "1".equals(this.status) ? "工作中" : "2".equals(this.status) ? "充电中" : "3".equals(this.status) ? "故障" : "4".equals(this.status) ? "休息中" : "5".equals(this.status) ? "关机" : "未知");
jo.put("isError", "3".equals(this.status));
jo.put("isOnline", "5".equals(this.status) ? false : true);
jo.put("task", this.task);
jo.put("battery_level", this.battery_level);
jo.put("x", this.x);
jo.put("y", this.y);
return jo;
}
@@ -209,33 +77,5 @@ public class XgAgvCarDeviceDriver extends AbstractDeviceDriver implements Device
}
/**
* 获取机器人信息
*/
private void getAgvStatus() {
UnifiedResponse<JSONObject> resp = xianGongAgvService.getRobotInfo(this.getDevice().getDevice_name(), JSONObject.class);
if (resp.isSuccess()) {
JSONObject jsonObject = resp.getData();
String report = jsonObject.getString("report");
//core出错标识
is_error = jsonObject.getBooleanValue("is_error");
//是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
upload_scene_status = jsonObject.getString("upload_scene_status");
JSONArray objects = JSONObject.parseArray(report);
for (Object object : objects) {
JSONObject json = (JSONObject) object;
//是否正在执行用户下发的运单
procBusiness = json.getBooleanValue("procBusiness");
//机器人当前运单
current_order = json.getString("current_order");
//机器人连接状态 0表示断连 1表示连接上
connection_status = json.getString("connection_status");
//机器人可接单状态 true=可接单 false=不可接单
dispatchable = json.getString("dispatchable");
}
} else {
log.info("请求{}机器人状态失败", this.getDevice().getDevice_name());
}
}
}

View File

@@ -270,18 +270,20 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.withStationRequireSuccess = false;
}
if (this.error != this.lastError && this.error != 0) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")) {
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: " + ErrorEnum.getLabel(this.error));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
if (this.status == 1) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")) {
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: " + ErrorEnum.getLabel(this.error));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
if (this.mode != this.lastMode) {

View File

@@ -511,19 +511,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
if ((this.back_Zerror != this.lastBack_Zerror && this.back_Zerror != 0) || (this.front_Zerror != this.lastFront_Zerror && this.front_Zerror != 0)) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")) {
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: 前叉 " + ErrorEnum.getDesc(this.front_Zerror) + ", 后叉 " + ErrorEnum.getDesc(this.back_Zerror));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
if (this.mode == ModeEnum.MODE_3.getNum() && !AGAIN_ERROR.contains(this.back_Zerror) && !AGAIN_ERROR.contains(this.front_Zerror)) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")) {
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: 前叉 " + ErrorEnum.getDesc(this.front_Zerror) + ", 后叉 " + ErrorEnum.getDesc(this.back_Zerror));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
@@ -2307,6 +2310,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
List<Instruction> frontInsts = instructionService.findAllInstByPriorityCreateTime(getLinkDeviceCode, getFrontDeviceCodeList, frontNoY);
//遍历前叉指令信息,判断前叉指令起点是深库位还是浅库位
if (CollectionUtils.isNotEmpty(frontInsts)) {
boolean executed = false;
for (Instruction inst : frontInsts) {
String start_device_code = inst.getStart_device_code();
//判断当前库位是深库位还是浅库位
@@ -2326,10 +2330,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallInst.getFrom_y())))) {
// 如果前叉可达,则下发前叉移库指令的取货信息 break;
this.frontWrite(shallInst);
executed = true;
break;
}
// 否则直接下发后叉放货信息 break
this.sendPutInfoToPlc(null, backInst);
executed = true;
break;
}
continue;
@@ -2355,11 +2361,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "后叉出库任务,取货完成后,创建前叉移库指令时出现异常,原因:" + e.getMessage()));
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage()));
this.sendPutInfoToPlc(null, backInst);
executed = true;
return;
}
}
// 否则直接下发后叉放货信息 break
this.sendPutInfoToPlc(null, backInst);
executed = true;
break;
}
continue;
@@ -2367,9 +2375,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
frontInst = inst;
this.frontWrite(frontInst);
executed = true;
//直接下发前叉取货信息
break;
}
if (!executed) {
this.sendPutInfoToPlc(null, backInst);
}
} else {
this.sendPutInfoToPlc(null, backInst);
}
@@ -2394,6 +2406,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
List<Instruction> backInsts = instructionService.findAllInstByPriorityCreateTime(getLinkDeviceCode, getBackDeviceCodeList, backNoY);
//遍历后叉指令信息,判断后叉指令起点是深库位还是浅库位
if (CollectionUtils.isNotEmpty(backInsts)) {
boolean executed = false;
for (Instruction inst : backInsts) {
String start_device_code = inst.getStart_device_code();
//判断当前库位是深库位还是浅库位
@@ -2413,10 +2426,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (!currentNoY.contains(String.valueOf(Integer.parseInt(shallInst.getFrom_y())))) {
// 如果后叉可达,则下发后叉移库指令的取货信息 break;
this.backWrite(shallInst);
executed = true;
break;
}
// 否则直接下发前叉放货信息 break
this.sendPutInfoToPlc(frontInst, null);
executed = true;
break;
}
continue;
@@ -2442,11 +2457,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "前叉出库任务,取货完成后,创建后叉移库指令时出现异常,原因:" + e.getMessage()));
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage()));
this.sendPutInfoToPlc(frontInst, null);
executed = true;
return;
}
}
// 否则直接下发前叉放货信息 break
this.sendPutInfoToPlc(frontInst, null);
executed = true;
break;
}
continue;
@@ -2455,8 +2472,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
//直接下发后叉取货信息
backInst = inst;
this.backWrite(backInst);
executed = true;
break;
}
if (!executed) {
this.sendPutInfoToPlc(frontInst, null);
}
} else {
this.sendPutInfoToPlc(frontInst, null);
}

View File

@@ -31,6 +31,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
@RequiredArgsConstructor
@@ -63,11 +65,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
boolean o2ContainsDash = containsDash(o2);
if (o1ContainsDash && !o2ContainsDash) {
return -1;
}
else if (!o1ContainsDash && o2ContainsDash) {
} else if (!o1ContainsDash && o2ContainsDash) {
return 1;
}
else {
} else {
return 0;
}
}
@@ -452,10 +452,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
.podDir("1")
.indBind(indBind)
.build();
// BaseReq<BindPodAndBerthReq> baseReq = BaseReq.<BindPodAndBerthReq>builder().data(bindPodAndBerthReq).build();
UnifiedResponse<Object> unifiedResponse = acsToHkService.bindPodAndBerth(bindPodAndBerthReq);
JSONObject resp = new JSONObject();
if (!unifiedResponse.isSuccess()) {
Pattern pattern = Pattern.compile("([A-Za-z0-9]+)$");
Matcher matcher = pattern.matcher(unifiedResponse.getMessage());
if (matcher.find()) {
String result = matcher.group(1);
StorageCell storageCell = storageCellMapper.selectOne(new LambdaQueryWrapper<StorageCell>().eq(StorageCell::getParent_storage_code, result));
if (ObjectUtil.isNotEmpty(storageCell)) {
resp.put("code", "400");
resp.put("msg", "下发失败," + unifiedResponse.getMessage() + ", 对应地面点位:" + storageCell.getStorage_code());
log.info("bindPodAndBerth--------------:输出参数:" + JSON.toJSONString(resp));
return resp;
}
}
resp.put("code", "400");
resp.put("msg", "下发失败," + unifiedResponse.getMessage());
log.info("bindPodAndBerth--------------:输出参数:" + JSON.toJSONString(resp));

View File

@@ -0,0 +1,174 @@
package org.nl.acs.hand.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.hand.service.HandService;
import org.nl.common.exception.BadRequestException;
import org.nl.common.logging.annotation.Log;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.dao.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Map;
/**
* @author zhoujj
* @date 2023-05-04
**/
@RestController
@RequestMapping("/api/hand")
@Slf4j
public class HandController {
@Autowired
private HandService handService;
@Autowired
private ISysParamService iSysParamService;
@PostMapping("/tasks")
@Log("查询任务")
@SaIgnore
public ResponseEntity<Object> queryTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(handService.queryTask(whereJson), HttpStatus.OK);
}
@PostMapping("/queryArea")
@Log("查询区域")
@SaIgnore
public ResponseEntity<Object> query() {
return new ResponseEntity<>(handService.queryArea(null), HttpStatus.OK);
}
@PostMapping("/queryPointByArea")
@Log("查询设备编号及状态")
@SaIgnore
public ResponseEntity<Object> queryPoint(@RequestBody Map<String, String> whereJson) {
String areaCode = (String) whereJson.get("areaCode");
return new ResponseEntity<>(handService.queryPointByArea(areaCode), HttpStatus.OK);
}
@PostMapping("/bindpoint")
@Log("点位绑定")
@SaIgnore
public ResponseEntity<Object> bindPoint(@RequestBody JSONObject reqParam) {
return new ResponseEntity<>(handService.bindPoint(reqParam), HttpStatus.OK);
}
@PostMapping("/insts")
@Log("查询指令")
@SaIgnore
public ResponseEntity<Object> queryInst(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(handService.queryInst(whereJson), HttpStatus.OK);
}
@PostMapping("/callTask")
@Log("创建任务")
@SaIgnore
public ResponseEntity<Object> createTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(handService.createTask(whereJson), HttpStatus.OK);
}
@PostMapping("/inst")
@Log("指令操作")
@SaIgnore
public ResponseEntity<Object> Instoperation(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(handService.Instoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/taskoperation")
@Log("任务操作")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Taskoperation(@RequestBody Map<String, String> whereJson) throws Exception {
return new ResponseEntity<>(handService.Taskoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/login")
@Log("手持登陆验证")
@SaIgnore
public ResponseEntity<Object> handlogin(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(handService.handleLogin(whereJson), HttpStatus.OK);
}
@RequestMapping("/download/app-release")
@SaIgnore
public void setPrint(HttpServletResponse response){
Param byCode = iSysParamService.findByCode("apkurl");
if (byCode==null){
throw new BadRequestException("更新失败:未配置apk下载地址");
}
System.out.println(byCode.getValue());
try {
downloadFile(response,byCode.getValue(),"release");
}catch (Exception ex){
ex.printStackTrace();
}
}
/**
* 附件下载
* @param response
* @param fileName
* @param path
* @return
* @throws Exception
*/
public void downloadFile(HttpServletResponse response, String path, String fileName) throws Exception {
if (fileName != null) {
//设置文件路径
File file = new File(path);
if (file.exists()) {
response.setHeader("content-type", "application/octet-stream");
response.setContentType("application/octet-stream");
try {
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("utf-8"),"ISO-8859-1")+".apk");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] buffer = new byte[1024];
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
OutputStream os = response.getOutputStream();
int i = bis.read(buffer);
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
}

View File

@@ -0,0 +1,35 @@
package org.nl.acs.hand.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.logging.annotation.Log;
import org.nl.config.MapOf;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @Description TODO
* @Author Gengby
* @Date 2025/8/1
*/
@RestController
@RequestMapping("/api/pda")
@Slf4j
public class PdaController {
/**
*
*/
@PostMapping("/update")
@Log("获取升级地址")
@SaIgnore
public ResponseEntity<Map> apkUrl() {
Map of = MapOf.of("versionName", "1.0.1", "url", "http://192.168.18.218:8011/api/hand/download/app-release");
return new ResponseEntity<>(of, HttpStatus.OK);
}
}

View File

@@ -0,0 +1,83 @@
package org.nl.acs.hand.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
* @author zhoujj
* @description 服务接口
* @date 2023-05-04
**/
public interface HandService {
/**
* 查询区域
*
* @param whereJson 条件
* @return Map<String, Object>
*/
Map<String, Object> queryArea(Map whereJson);
/**
* 查询设备编号及状态
*
* @return Map<String, Object>
*/
Map<String, Object> queryPointByArea(String dict_id);
Map<String, Object> bindPoint(JSONObject reqParam);
/**
* 查询指令
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryInst(Map<String, String> jsonObject);
/**
* 创建任务
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> createTask(Map<String, String> jsonObject);
/**
* 查询任务
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryTask(Map<String, String> jsonObject);
/**
* 指令操作
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> Instoperation(Map<String, String> jsonObject);
/**
* 任务操作
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> Taskoperation(Map<String, String> jsonObject) throws Exception;
/**
* 手持登陆
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> handleLogin(Map<String, String> jsonObject);
}

View File

@@ -0,0 +1,574 @@
package org.nl.acs.hand.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.domain.DeviceRunpoint;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.device.device.service.DeviceRunpointService;
import org.nl.acs.device.device.service.DeviceService;
import org.nl.acs.device.device.service.impl.DeviceAppServiceImpl;
import org.nl.acs.device.driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.hand.service.HandService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.acs.task.enums.InstTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
import org.nl.common.utils.RsaUtils;
import org.nl.config.RsaProperties;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.secutiry.dto.UserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Slf4j
public class HandServicelmpl implements HandService {
@Autowired
private DeviceAppService deviceAppService;
@Autowired
private InstructionService instructionService;
@Autowired
private TaskService taskService;
@Autowired
private XianGongAgvService xianGongAgvService;
@Autowired
private DeviceRunpointService deviceRunpointService;
@Override
public Map<String, Object> queryTask(Map<String, String> jsonObject) {
String start_point = jsonObject.get("start_devicecode");
String next_point = jsonObject.get("next_devicecode");
List<TaskDto> taskDtos = taskService.findAllTaskFromCache();
List<TaskDto> taskDtoList = Optional.ofNullable(taskDtos)
.orElse(new ArrayList<>())
.stream()
.filter(taskDto -> taskDto.getTask_type().equals(TaskTypeEnum.P2P_AGV_TASK.getCode()))
.filter(taskDto -> {
if (StrUtil.isNotBlank(start_point)) {
return taskDto.getStart_point_code().contains(start_point);
}
return true;
})
.filter(taskDto -> {
if (StrUtil.isNotBlank(next_point)) {
return taskDto.getNext_point_code().contains(next_point);
}
return true;
})
.filter(taskDto -> taskDto.getTask_code().contains("-"))
.collect(Collectors.toList());
List<Map<String,Object>> resultList = new ArrayList();
for (TaskDto taskDto : taskDtoList) {
Map<String,Object> map = new HashMap();
map.put("task_uuid", taskDto.getTask_id());
map.put("task_no", taskDto.getTask_code());
map.put("start_devicecode", taskDto.getStart_point_code());
map.put("next_devicecode", taskDto.getNext_point_code());
map.put("task_type", taskDto.getTask_type());
map.put("material_type", taskDto.getMaterial());
map.put("material_type_name", "");
map.put("task_status", taskDto.getTask_status());
map.put("task_status_name", StrUtil.equals(taskDto.getTask_status(),"0") ? "就绪" : "执行中");
map.put("carrier", taskDto.getVehicle_code());
map.put("create_time", taskDto.getCreate_time());
map.put("priority", taskDto.getPriority());
resultList.add(map);
}
JSONObject resultJson = new JSONObject();
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultList);
return resultJson;
}
@Override
public Map<String, Object> Taskoperation(Map<String, String> jsonObject) throws Exception {
JSONObject jo = new JSONObject();
String task_uuid = jsonObject.get("inst_uuid");
String type = jsonObject.get("type");
if (StrUtil.isEmpty(task_uuid)) {
throw new BadRequestException("id不能为空");
}
if (StrUtil.isEmpty(type)) {
throw new BadRequestException("操作类型不能为空!");
}
TaskDto taskDto = taskService.findById(task_uuid);
if (ObjectUtil.isEmpty(taskDto) ||
StrUtil.equals(taskDto.getTask_status(), TaskStatusEnum.FINISHED.getIndex()) ||
StrUtil.equals(taskDto.getTask_status(), TaskStatusEnum.CANCEL.getIndex())) {
jo.put("code", "2");
jo.put("desc", "任务已完成或已取消,无法操作");
jo.put("result", "");
return jo;
}
Instruction instruction = instructionService.findByTaskCodeFromCache(taskDto.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)) {
jo.put("code", "2");
jo.put("desc", "操作失败" + "任务号: " + taskDto.getTask_code() + ", 已存在待完成指令!");
jo.put("result", "任务号: " + taskDto.getTask_code() + ", 已存在待完成指令!");
return jo;
}
//重新生成
if (type.equals("1")) {
//重新生产指令
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
instdto.setRemark(taskDto.getRemark());
instdto.setMaterial(taskDto.getMaterial());
instdto.setTask_id(taskDto.getMaterial());
instdto.setTask_code(taskDto.getTask_code());
instdto.setVehicle_code(taskDto.getVehicle_code());
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("手持创建");
instdto.setStart_point_code(taskDto.getStart_point_code());
instdto.setNext_point_code(taskDto.getNext_point_code());
instdto.setStart_device_code(taskDto.getStart_device_code());
instdto.setNext_device_code(taskDto.getNext_device_code());
instdto.setAgv_system_type(AgvSystemTypeEnum.XG_SYSTEM_TYPE.getCode());
instdto.setInstruction_status("0");
try {
instructionService.create(instdto);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", e.getMessage());
jo.put("result", "");
return jo;
}
}
//强制完成
if (type.equals("2")) {
taskService.finish(taskDto.getTask_id());
}
jo.put("code", "1");
jo.put("desc", "操作成功");
jo.put("result", new JSONObject());
return jo;
}
@Override
public Map<String, Object> queryInst(Map<String, String> jsonObject) {
String start_point = jsonObject.get("start_devicecode");
String next_point = jsonObject.get("next_devicecode");
List<Instruction> instructions = instructionService.findAllInstFromCache();
List<Instruction> instructionList = Optional.ofNullable(instructions)
.orElse(new ArrayList<>())
.stream()
.filter(instruction -> instruction.getTask_code().contains("-"))
.filter(instruction -> instruction.getInstruction_type().equals(InstTypeEnum.P2P_AGV_TASK.getCode()))
.filter(instruction -> {
if (StrUtil.isNotBlank(start_point)) {
return instruction.getStart_point_code().contains(start_point);
}
return true;
})
.filter(instruction -> {
if (StrUtil.isNotBlank(next_point)) {
return instruction.getNext_point_code().contains(next_point);
}
return true;
})
.collect(Collectors.toList());
List<Map<String,Object>> resultList = new ArrayList();
for (Instruction inst : instructionList) {
Map<String,Object> map = new HashMap();
map.put("inst_uuid", inst.getInstruction_id());
map.put("task_no", inst.getTask_code());
map.put("inst_no", inst.getInstruction_code());
map.put("start_devicecode", inst.getStart_point_code());
map.put("next_devicecode", inst.getNext_point_code());
map.put("material_type_name", "");
map.put("inst_status", inst.getInstruction_status());
map.put("inst_status_name", StrUtil.equals(inst.getInstruction_status(),"0") ? "就绪" : "执行中");
map.put("carrier", inst.getVehicle_code());
map.put("create_time", inst.getCreate_time());
map.put("priority", inst.getPriority());
map.put("carno", inst.getCarno());
resultList.add(map);
}
//查询位完成的指令
JSONObject resultJson = new JSONObject();
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultList);
return resultJson;
}
@Override
public Map<String, Object> Instoperation(Map<String, String> jsonObject) {
JSONObject jo = new JSONObject();
String type = jsonObject.get("type");
String inst_uuid = jsonObject.get("inst_uuid");
Instruction inst = instructionService.findByIdFromCache(inst_uuid);
if (inst == null || StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.FINISHED.getIndex()) ||
StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.CANCEL.getIndex())) {
jo.put("code", "2");
jo.put("desc", "指令已完成或已取消,无法操作!");
jo.put("result", "");
return jo;
}
/* 1 指令撤销
2 重新下发
3 强制完成*/
if (type.equals("1")) {
//调用agv删除任务的接口
try {
if (StrUtil.equals(inst.getAgv_system_type(), AgvSystemTypeEnum.XG_SYSTEM_TYPE.getCode())) {
xianGongAgvService.deleteXZAgvInst(inst.getInstruction_code());
}
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", "下发agv失败");
jo.put("result", "");
return jo;
}
}
if (type.equals("2")) {
try {
if (!StrUtil.equals(inst.getSend_status(), "1")) {
UnifiedResponse<Object> unifiedResponse = xianGongAgvService.sendOrderSequencesToXZ(inst);
if (unifiedResponse.isSuccess()) {
inst.setSend_status("1");
instructionService.update(inst);
} else {
jo.put("code", "2");
jo.put("desc", "重新下发agv失败");
jo.put("result", unifiedResponse.getMessage());
return jo;
}
}
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", "重新下发agv失败");
jo.put("result", e.getMessage());
return jo;
}
}
if (type.equals("3")) {
//完成指令
try {
instructionService.finish(inst_uuid);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", e.getMessage());
jo.put("result", "");
return jo;
}
}
jo.put("code", "1");
jo.put("desc", "操作成功");
jo.put("result", new JSONObject());
return jo;
}
@Override
public Map<String, Object> queryArea(Map whereJson) {
JSONObject jo = new JSONObject();
List<Map<String, String>> regions = new ArrayList<>();
Map<String, String> region = new HashMap<>();
region.put("region_id", "21");
region.put("region_code", "21");
region.put("region_name", "清洗车间区域");
regions.add(region);
region = new HashMap<>();
region.put("region_id", "22");
region.put("region_code", "22");
region.put("region_name", "质检区域");
regions.add(region);
region = new HashMap<>();
region.put("region_id", "23");
region.put("region_code", "23");
region.put("region_name", "四号楼一层仓库区域");
regions.add(region);
region = new HashMap<>();
region.put("region_id", "24");
region.put("region_code", "24");
region.put("region_name", "四号楼二层产线区域");
regions.add(region);
region = new HashMap<>();
region.put("region_id", "25");
region.put("region_code", "25");
region.put("region_name", "五号楼一层仓库区域");
regions.add(region);
region = new HashMap<>();
region.put("region_id", "26");
region.put("region_code", "26");
region.put("region_name", "五号楼二层仓库区域");
regions.add(region);
region = new HashMap<>();
region.put("region_id", "27");
region.put("region_code", "27");
region.put("region_name", "一号楼一楼产线");
regions.add(region);
jo.put("code", "1");
jo.put("desc", "查询成功");
jo.put("result", regions);
return jo;
}
@Override
public Map<String, Object> queryPointByArea(String dict_id) {
JSONArray resultArr = new JSONArray();
JSONObject resultJson = new JSONObject();
//根据value值去查所有的设备
List<Device> deviceList = deviceAppService.findDeviceByRegion(dict_id);
for (Device acsDevice : deviceList) {
String device_code = acsDevice.getDevice_code();
Device device = deviceAppService.findDeviceByCode(device_code);
//点位状态status对应status_name 0空 1有货 2有任务
String status = "0";
String status_name = "无货";
String input_material = "0";
String allow_update = "0";
JSONObject jo = new JSONObject();
//无光电普通站点
if (device != null && device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
DeviceRunpoint deviceRunpoint = deviceRunpointService.getOne(new LambdaQueryWrapper<DeviceRunpoint>().eq(DeviceRunpoint::getDevice_code, device_code));
String hasgoods = deviceRunpoint.getHasgoods();
if ("1".equals(hasgoods)) {
status = "1";
status_name = "有货";
}
allow_update = "1";
input_material = "1";
jo.put("device_id", device.getDevice_id());
jo.put("device_code", device.getDevice_code());
jo.put("device_name", device.getDevice_name());
jo.put("allow_update", allow_update);
jo.put("status", status);
jo.put("status_name", status_name);
jo.put("input_material", input_material);
}
resultArr.add(jo);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultArr);
return resultJson;
}
@Override
public Map<String, Object> bindPoint(JSONObject reqParam) {
String device_code = reqParam.getString("device_code");
String status = reqParam.getString("status");
if (StrUtil.isEmpty(device_code)) {
throw new BadRequestException("设备号不能为空!");
}
if (StrUtil.isEmpty(status)) {
throw new BadRequestException("点位状态不能为空!");
}
Device device = deviceAppService.findDeviceByCode(device_code);
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
JSONObject jo = new JSONObject();
JSONObject map = new JSONObject();
map.put("hasgoods", status);
DeviceRunpoint deviceRunpoint = deviceRunpointService.getOne(new LambdaQueryWrapper<DeviceRunpoint>().eq(DeviceRunpoint::getDevice_code, device_code));
if (deviceRunpoint != null) {
deviceRunpoint.setHasgoods(status);
deviceRunpointService.updateById(deviceRunpoint);
}
if (device != null && device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setHasGoods(Integer.valueOf(status));
device.setHas_goods(Integer.valueOf(status));
}
jo.put("code", "1");
jo.put("desc", "成功");
return jo;
}
@Override
public Map<String, Object> createTask(Map<String, String> jsonObject) {
String start_devicecode = jsonObject.get("start_device_codes");
String next_devicecode = jsonObject.get("next_device_code");
String material_type = jsonObject.get("material_type");
String priority = jsonObject.get("priority");
String carrier = jsonObject.get("carrier");
JSONObject resultJson = new JSONObject();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device startDevice = appService.findDeviceByCode(start_devicecode);
if (startDevice != null) {
List<String> link_next_device = this.getExtraDeviceCodes(startDevice, "link_next_device");
if (ObjectUtil.isEmpty(link_next_device)) {
resultJson.put("code", "0");
resultJson.put("desc", "未配置该起点对应的终点点位");
resultJson.put("result", "");
return resultJson;
}
if (!link_next_device.contains(next_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "该起点不能到达其终点位置");
resultJson.put("result", "");
return resultJson;
}
}
Device nextDevice = appService.findDeviceByCode(next_devicecode);
if (StrUtil.isEmpty(start_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "起点不能为空");
resultJson.put("result", "");
return resultJson;
}
if (StrUtil.isEmpty(next_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "终点不能为空");
resultJson.put("result", "");
return resultJson;
}
//判断起点有货,终点为空
if (ObjectUtil.isEmpty(startDevice.getHas_goods()) || startDevice.getHas_goods() == 0) {
resultJson.put("code", "0");
resultJson.put("desc", "起点必须有货");
resultJson.put("result", "");
return resultJson;
}
if (!ObjectUtil.isEmpty(nextDevice.getHas_goods()) && nextDevice.getHas_goods() == 1) {
resultJson.put("code", "0");
resultJson.put("desc", "终点必须无货");
resultJson.put("result", "");
return resultJson;
}
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
//判断是否有起点的任务
TaskDto start_taskDto = taskService.findByStartCode(start_devicecode);
//判断是否有终点的任务
TaskDto next_taskDto = taskService.findByNextCode(next_devicecode);
if (ObjectUtil.isNotEmpty(start_taskDto) || ObjectUtil.isNotEmpty(next_taskDto)) {
throw new BadRequestException("已存在该点位的任务,不能生成任务!");
}
if (StrUtil.isEmpty(priority)) {
priority = "1";
}
if (start_devicecode.equals(next_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "起点和终点不能是同一设备【" + next_devicecode + "");
resultJson.put("result", "");
return resultJson;
}
TaskDto dto = new TaskDto();
dto.setIs_active("1");
dto.setIs_delete("0");
dto.setMaterial(material_type);
dto.setStart_point_code(start_devicecode);
dto.setNext_point_code(next_devicecode);
dto.setMaterial(material_type);
dto.setTask_type(TaskTypeEnum.P2P_AGV_TASK.getCode());
dto.setPriority(priority);
dto.setVehicle_code(carrier);
dto.setAgv_system_type(AgvSystemTypeEnum.XG_SYSTEM_TYPE.getCode());
try {
taskService.create(dto);
} catch (Exception e) {
resultJson.put("code", "2");
resultJson.put("desc", e.getMessage());
resultJson.put("result", "");
return resultJson;
}
resultJson.put("code", "1");
resultJson.put("desc", "生成成功!");
resultJson.put("result", "");
return resultJson;
}
@SneakyThrows
@Override
public Map<String, Object> handleLogin(Map<String, String> jsonObject) {
JSONObject resultJson = new JSONObject();
String user = jsonObject.get("username");
String password = jsonObject.get("password");
if (StrUtil.isEmpty("user")) {
resultJson.put("code", "1");
resultJson.put("desc", "用户不能为空");
return resultJson;
}
if (StrUtil.isEmpty("password")) {
resultJson.put("code", "1");
resultJson.put("desc", "密码不能为空!");
return resultJson;
}
boolean is_match = false;
Long account_id = 1L;
// try {
// String pwd = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, password);
// UserDto userDto = userService.findByName(user);
// account_id = userDto.getId();
// is_match = passwordEncoder.matches(pwd, userDto.getPassword());
//
// } catch (Exception e) {
// e.printStackTrace();
// }
if (true) {
resultJson.put("code", "1");
resultJson.put("desc", "登陆成功");
} else {
resultJson.put("code", "2");
resultJson.put("desc", "登陆失败!");
}
JSONObject jo = new JSONObject();
jo.put("user_name", user);
jo.put("account_id", account_id);
resultJson.put("result", jo);
return resultJson;
}
private List<String> getExtraDeviceCodes(Device device, String extraName) {
String extraValue = (String) device.getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devicesString.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
}

View File

@@ -563,6 +563,8 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
Instruction findByNextPointCode(String nextPointCode);
List<Instruction> findByNextDeviceCode(String nextDeviceCode);
/**
* 根据优先级和创建时间顺序去查找前/后叉可取指令信息
@@ -581,4 +583,7 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
* @return
*/
List<Instruction> findAllInstByPriorityCreateTime(String link_device_code, List<String> next_device_code_list, String noY);
List<String> getInstCodeListByAgvCar(String agvCarCode);
}

View File

@@ -2242,6 +2242,15 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.orElse(null);
}
@Override
public List<Instruction> findByNextDeviceCode(String nextDeviceCode) {
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getNext_device_code().equals(nextDeviceCode))
.collect(Collectors.toList());
}
@Override
public List<Instruction> findAllInstByPriorityCreateTime(List<String> next_device_code_list, String noY) {
@@ -2305,5 +2314,15 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.collect(Collectors.toList());
}
@Override
public List<String> getInstCodeListByAgvCar(String agvCarCode) {
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> StrUtil.equals(agvCarCode,inst.getCarno()))
.map(Instruction::getInstruction_code)
.collect(Collectors.toList());
}
}

View File

@@ -19,7 +19,8 @@ public enum InstTypeEnum {
CTU_IN_TASK("3", "A011", "CTU入库任务"),
CTU_OUT_TASK("4", "A012", "CTU出库任务"),
CTU_MOVE_TASK("5", "A013", "CTU移库任务"),
OTHER_TASK("6", "other", "其它任务类型");
OTHER_TASK("6", "other", "其它任务类型"),
P2P_AGV_TASK("99", "99", "定点AGV任务");
/**

View File

@@ -17,7 +17,8 @@ public enum TaskTypeEnum {
Stacker_Task("1", "1", "堆垛机任务"),
AGV_TASK("2", "2", "AGV任务"),
CTU_TASK("3", "3", "CTU任务"),
YK_TASK("4", "4", "呆料转移任务");
YK_TASK("4", "4", "呆料转移任务"),
P2P_AGV_TASK("99", "99", "定点AGV任务");
/**

View File

@@ -266,6 +266,15 @@ public interface TaskService extends CommonService<Task> {
List<TaskDto> findReadyByTaskType(String task_type);
/**
* 根据Agv系统类型查询任务信息
*
* @param agvSystemType
* @return
*/
List<TaskDto> findReadyByAgvSystemType(String agvSystemType);
/**
* 根据目的地设备编号查询当前是否有设备
*

View File

@@ -21,12 +21,15 @@ import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.domain.DeviceRunpoint;
import org.nl.acs.device.device.enums.DeviceType;
import org.nl.acs.device.device.service.DeviceAssignedService;
import org.nl.acs.device.device.service.DeviceRunpointService;
import org.nl.acs.device.device.service.DeviceService;
import org.nl.acs.device.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device.driver.DeviceDriverDefination;
import org.nl.acs.device.driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
@@ -111,6 +114,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
private InstructionService instructionService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private DeviceRunpointService deviceRunpointService;
/**
* 缓存
@@ -397,36 +402,36 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
}
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
JSONObject jo = new JSONObject();
JSONObject jo2 = new JSONObject();
if (!StrUtil.isEmpty(dto.getMaterial())) {
if (!StrUtil.equals(dto.getMaterial(), CommonFinalParam.ONE)) {
jo.put("hasGoodStatus", "2");
jo.put("material_type", dto.getMaterial());
} else {
jo.put("hasGoodStatus", CommonFinalParam.ONE);
jo.put("material_type", CommonFinalParam.ONE);
}
} else {
jo.put("hasGoodStatus", CommonFinalParam.ONE);
jo.put("material_type", CommonFinalParam.ONE);
}
jo.put("device_code", dto.getStart_device_code());
jo.put("quantity", dto.getQuantity());
jo.put("remark", dto.getRemark());
jo.put("batch", startdevice.getBatch());
jo.put("islock", "true");
deviceService.changeDeviceStatus(jo);
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code());
jo2.put("device_code", dto.getNext_device_code());
jo2.put("hasGoodStatus", deviceByCode.getHas_goods());
jo2.put("quantity", deviceByCode.getQuantity());
jo2.put("remark", deviceByCode.getRemark());
jo2.put("material_type", deviceByCode.getMaterial_type());
jo2.put("batch", deviceByCode.getBatch());
jo2.put("islock", "true");
deviceService.changeDeviceStatus(jo2);
// JSONObject jo = new JSONObject();
// JSONObject jo2 = new JSONObject();
// if (!StrUtil.isEmpty(dto.getMaterial())) {
// if (!StrUtil.equals(dto.getMaterial(), CommonFinalParam.ONE)) {
// jo.put("hasGoodStatus", "2");
// jo.put("material_type", dto.getMaterial());
// } else {
// jo.put("hasGoodStatus", CommonFinalParam.ONE);
// jo.put("material_type", CommonFinalParam.ONE);
// }
//
// } else {
// jo.put("hasGoodStatus", CommonFinalParam.ONE);
// jo.put("material_type", CommonFinalParam.ONE);
// }
// jo.put("device_code", dto.getStart_device_code());
// jo.put("quantity", dto.getQuantity());
// jo.put("remark", dto.getRemark());
// jo.put("batch", startdevice.getBatch());
// jo.put("islock", "true");
// deviceService.changeDeviceStatus(jo);
// Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code());
// jo2.put("device_code", dto.getNext_device_code());
// jo2.put("hasGoodStatus", deviceByCode.getHas_goods());
// jo2.put("quantity", deviceByCode.getQuantity());
// jo2.put("remark", deviceByCode.getRemark());
// jo2.put("material_type", deviceByCode.getMaterial_type());
// jo2.put("batch", deviceByCode.getBatch());
// jo2.put("islock", "true");
// deviceService.changeDeviceStatus(jo2);
}
}
Task entity = ConvertUtil.convert(dto, Task.class);
@@ -603,6 +608,29 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
Task task = ConvertUtil.convert(entity, Task.class);
taskMapper.updateById(task);
Device start_device = deviceAppService.findDeviceByCode(entity.getStart_device_code());
if (start_device != null && start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
DeviceRunpoint deviceRunpoint = deviceRunpointService.getOne(new LambdaQueryWrapper<DeviceRunpoint>().eq(DeviceRunpoint::getDevice_code, entity.getStart_device_code()));
if (ObjectUtil.isNotEmpty(deviceRunpoint)) {
start_device.setHas_goods(0);
deviceRunpoint.setHasgoods("0");
deviceRunpoint.setUpdate_time(now);
deviceRunpoint.setUpdate_by(currentUsername);
deviceRunpointService.updateById(deviceRunpoint);
}
}
Device next_device = deviceAppService.findDeviceByCode(entity.getNext_device_code());
if (next_device != null && next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
DeviceRunpoint deviceRunpoint = deviceRunpointService.getOne(new LambdaQueryWrapper<DeviceRunpoint>().eq(DeviceRunpoint::getDevice_code, entity.getNext_device_code()));
if (ObjectUtil.isNotEmpty(deviceRunpoint)) {
next_device.setHas_goods(1);
deviceRunpoint.setHasgoods("1");
deviceRunpoint.setUpdate_time(now);
deviceRunpoint.setUpdate_by(currentUsername);
deviceRunpointService.updateById(deviceRunpoint);
}
}
//移除任务缓存信息
this.removeByCodeFromCache(entity.getTask_code());
//反馈上位系统任务状态
@@ -844,6 +872,16 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
.collect(Collectors.toList());
}
@Override
public List<TaskDto> findReadyByAgvSystemType(String agvSystemType) {
return Optional.ofNullable(this.tasks)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(taskDto -> StrUtil.equals(taskDto.getAgv_system_type(), agvSystemType))
.filter(taskDto -> taskDto.getTask_status().equals(TaskStatusEnum.READY.getIndex()))
.collect(Collectors.toList());
}
@Override
public TaskDto findByNextCode(String device_code) {
Optional<TaskDto> optionalTask = tasks.stream()
@@ -912,7 +950,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(task -> StrUtil.equals(task.getStart_point_code(), start_point_code))
.filter(task -> StrUtil.equals(task.getTask_status(),TaskStatusEnum.READY.getIndex()))
.filter(task -> StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex()))
.findFirst()
.orElse(null);
}
@@ -1253,8 +1291,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
}
@Override
public TaskDto findByTaskCode(String task_code) {
return Optional.ofNullable(this.tasks)

View File

@@ -12,8 +12,8 @@ import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.utils.SecurityUtils;
@@ -44,7 +44,7 @@ public class AutoCreateInst {
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
*/
public void run() throws Exception {
List<TaskDto> list = taskService.findReadyByTaskType(TaskTypeEnum.AGV_TASK.getCode());
List<TaskDto> list = taskService.findReadyByAgvSystemType(AgvSystemTypeEnum.XG_SYSTEM_TYPE.getCode());
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
String taskid = acsTask.getTask_id();

View File

@@ -5,7 +5,6 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
@@ -45,8 +44,10 @@ public class AutoCreateYkInst {
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
*/
public void run() throws Exception {
List<TaskDto> list = taskService.findReadyByTaskType(TaskTypeEnum.YK_TASK.getCode());
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
@@ -111,6 +112,12 @@ public class AutoCreateYkInst {
next_point_code = next_device_code;
}
//呆料任务只能一次生成三个
List<Instruction> instructionList = instructionService.findByNextDeviceCode(next_device_code);
if (instructionList.size() >= 3) {
return;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(InstTypeEnum.STACKER_TASK.getCode());
instdto.setInstruction_id(IdUtil.simpleUUID());

View File

@@ -0,0 +1,111 @@
package org.nl.system.service.quartz.task;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.device.driver.agv.hik_ctu.HikCtuCarDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.hk.service.AcsToHkService;
import org.nl.acs.ext.hk.service.data.QueryAgvStatusReq;
import org.nl.acs.ext.hk.service.data.dto.QueryAgvStatusDto;
import org.nl.acs.ext.utils.TypeCastingUtil;
import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* @Description TODO
* @Author Gengby
* @Date 2025/6/11
*/
@Slf4j
@Component
public class AutoQueryCtuStatus {
private static final Map<String, String> STATUS_MAP = new HashMap<>();
private static final List<String> MAP_CODE_LIST = Arrays.asList("AA", "BB");
static {
STATUS_MAP.put("3", "任务异常");
STATUS_MAP.put("5", "机器人暂停");
STATUS_MAP.put("13", "运动库异常");
STATUS_MAP.put("16", "举升异常");
STATUS_MAP.put("17", "充电桩异常");
STATUS_MAP.put("18", "电量无增加");
STATUS_MAP.put("20", "充电指令角度错误");
STATUS_MAP.put("21", "平台下发指令错误");
STATUS_MAP.put("25", "小车不在锁定区");
STATUS_MAP.put("26", "下发重试失败");
STATUS_MAP.put("28", "举升电池电量太低");
STATUS_MAP.put("31", "区域锁定失败");
STATUS_MAP.put("33", "旋转申请暂时失败");
STATUS_MAP.put("34", "地图切换点地码未识别");
}
@Autowired
private AcsToHkService acsToHkService;
@Autowired
private AcsToWmsService acsToWmsService;
@Autowired
private ISysParamService sysParamService;
@Autowired
private DeviceAppService deviceAppService;
public void run() {
for (String mapCode : MAP_CODE_LIST) {
QueryAgvStatusReq qasReq = QueryAgvStatusReq.builder()
.mapCode(mapCode)
.build();
UnifiedResponse<List> unifiedResponse = acsToHkService.queryAgvStatus(qasReq, List.class);
List<QueryAgvStatusDto> data = TypeCastingUtil.convertToList(unifiedResponse.getData(), QueryAgvStatusDto.class);
if (CollectionUtils.isNotEmpty(data)) {
for (QueryAgvStatusDto queryAgvStatusDto : data) {
String robotCode = queryAgvStatusDto.getRobotCode();
String battery = queryAgvStatusDto.getBattery();
Float batteryLevel = Float.parseFloat(battery) / 100;
String posX = queryAgvStatusDto.getPosX();
String posY = queryAgvStatusDto.getPosY();
String status = queryAgvStatusDto.getStatus();
Device device = deviceAppService.findDeviceByCode(robotCode);
HikCtuCarDeviceDriver hikCtuCarDeviceDriver = null;
if (device != null && device.getDeviceDriver() instanceof HikCtuCarDeviceDriver){
hikCtuCarDeviceDriver = (HikCtuCarDeviceDriver) device.getDeviceDriver();
hikCtuCarDeviceDriver.setStatus(status);
hikCtuCarDeviceDriver.setBattery_level(batteryLevel);
hikCtuCarDeviceDriver.setX(Float.parseFloat(posX));
hikCtuCarDeviceDriver.setY(Float.parseFloat(posY));
}
if (STATUS_MAP.keySet().contains(status)) {
if (hikCtuCarDeviceDriver != null){
hikCtuCarDeviceDriver.setIsError(true);
}
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")) {
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "CTU设备" + queryAgvStatusDto.getRobotCode() + "报警, 报警信息: " + STATUS_MAP.get(status));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
} else {
if (hikCtuCarDeviceDriver != null){
hikCtuCarDeviceDriver.setIsError(false);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,114 @@
package org.nl.system.service.quartz.task;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.device.device.domain.Device;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.device.driver.agv.xg_agv_car.XgAgvCarDeviceDriver;
import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.wms.data.req.CommonRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* @Description TODO
* @Author Gengby
* @Date 2025/6/11
*/
@Slf4j
@Component
public class AutoQueryXgAgvStatus {
@Autowired
private XianGongAgvService xianGongAgvService;
@Autowired
private ISysParamService sysParamService;
@Autowired
private AcsToWmsService acsToWmsService;
@Autowired
private DeviceAppService deviceAppService;
public void run() {
UnifiedResponse<JSONObject> unifiedResponse = xianGongAgvService.queryXZAgvDeviceStatus(null, JSONObject.class);
if (unifiedResponse.isSuccess()) {
JSONObject data = unifiedResponse.getData();
JSONArray ja = data.getJSONArray("report");
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
String agv_code = jo.getString("uuid");
//机器人详细状态信息
JSONObject rbk_report = jo.getJSONObject("rbk_report");
//是否正在充电
Boolean charging = rbk_report.getBoolean("charging");
//电量
Float battery_level = rbk_report.getFloatValue("battery_level");
//x坐标
float x = rbk_report.getFloatValue("x");
//y坐标
float y = rbk_report.getFloatValue("y");
//是否正在执行任务
Boolean procBusiness = jo.getBoolean("procBusiness");
//agv是否故障
Boolean is_error = jo.getBoolean("is_error");
//执行运单信息
JSONObject current_order = jo.getJSONObject("current_order");
Integer connectionStatus = jo.getInteger("connection_status");
String inst_code = current_order.getString("id");
Device device = deviceAppService.findDeviceByCode(agv_code);
String status = "0";
if (connectionStatus == 0) {
//关机
status = "5";
} else {
if (procBusiness && !is_error) {
//工作中
status = "1";
} else {
if (charging) {
//充电中
status = "2";
} else {
if (is_error) {
//故障
status = "3";
} else {
//休息中
status = "4";
}
}
}
}
if (device != null && device.getDeviceDriver() instanceof XgAgvCarDeviceDriver){
XgAgvCarDeviceDriver xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) device.getDeviceDriver();
xgAgvCarDeviceDriver.setStatus(status);
xgAgvCarDeviceDriver.setBattery_level(battery_level);
xgAgvCarDeviceDriver.setX(x);
xgAgvCarDeviceDriver.setY(y);
xgAgvCarDeviceDriver.setTask(inst_code);
}
if (is_error) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")) {
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "AGV设备:" + agv_code + " 报警, 报警信息: 请查看AGV设备详情");
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
}
}
}