立库设备状态同步

This commit is contained in:
pangshenghao
2023-06-05 09:34:42 +08:00
parent f726e3437e
commit f6d11509b7
6 changed files with 186 additions and 2 deletions

View File

@@ -53,7 +53,9 @@ public enum DriverTypeEnum {
LAMP_THREE_COLOR(21, "lamp_three_color", "标准版-三色灯", "三色灯"),
PAPER_TUBE_DEVICE(22, "paper_tube_conveyor", "纸管库设备", "conveyor");
PAPER_TUBE_DEVICE(22, "paper_tube_conveyor", "纸管库设备", "conveyor"),
DEVICE_STATUS(23,"device_status","立库设备状态","conveyor");
//驱动索引
private int index;

View File

@@ -0,0 +1,46 @@
package org.nl.acs.device_driver.basedriver.device_status;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
@Service
public class DeviceStatusDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "device_status";
}
@Override
public String getDriverName() {
return "立库设备状态";
}
@Override
public String getDriverDescription() {
return "立库设备状态";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new DeviceStatusDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return DeviceStatusDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
}

View File

@@ -0,0 +1,113 @@
package org.nl.acs.device_driver.basedriver.device_status;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 设备状态查询
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class DeviceStatusDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
@Autowired
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
Boolean isonline = false;
//报警信号
int error = 0;
int last_error = 0;
// 1 上位系统允许进入 2 上位系统允许离开
int option = 0;
String device_id = "";
String x = "";
String y = "";
String map_id = "";
String power = "";
String pallet = "";
String load = "";
String alarm = "";
String task_id = "";
@Override
public void setDeviceStatus(JSONObject data) {
String flag = data.getString("option");
if(StrUtil.isNotEmpty(flag)){
option = Integer.parseInt(flag);
}
}
@Override
public void execute() {
if (!(String.valueOf(error).equals(alarm)||"".equals(alarm))) {
DeviceErrorLogDto dto = new DeviceErrorLogDto();
dto.setDevice_code(device_id);
dto.setError_code(String.valueOf(error));
dto.setError_info(ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)));
deviceErrorLogService.create(dto);
}
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("device_id", device_id);
jo.put("x", x);
jo.put("y", y);
jo.put("map_id", map_id);
jo.put("power", power);
jo.put("pallet", pallet);
jo.put("load", load);
jo.put("alarm", alarm);
jo.put("task_id", task_id);
jo.put("isOnline", this.getIsonline());
return jo;
}
}

View File

@@ -169,6 +169,7 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
log.info("queryCarDeviceStatus-----输入参数{}", JSON.toJSONString(requestParam));
String api = addressService.findByCode("queryCarDeviceStatus").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
// String result = "{\"result\":true,\"code\":0,\"comment\":\"查询成功\",\"data\":[{\"deviceId\":\"1\",\"x\":\"18.126\",\"y\":\"89.375\",\"mapId\":\"1\",\"power\":\"90.0\",\"pallet\":null,\"taskId\":null,\"load\":\"false\",\"alarm\":\"0\"},{\"deviceId\":\"2\",\"x\":\"19.75\",\"y\":\"89.375\",\"mapId\":\"1\",\"power\":\"49.0\",\"pallet\":null,\"taskId\":null,\"load\":\"false\",\"alarm\":\"0\"},{\"deviceId\":\"3\",\"x\":\"19.751\",\"y\":\"89.375\",\"mapId\":\"1\",\"power\":\"45.0\",\"pallet\":null,\"taskId\":null,\"load\":\"false\",\"alarm\":\"0\"},{\"deviceId\":\"4\",\"x\":\"19.75\",\"y\":\"89.375\",\"mapId\":\"1\",\"power\":\"97.0\",\"pallet\":null,\"taskId\":null,\"load\":\"false\",\"alarm\":\"0\"},{\"deviceId\":\"5\",\"x\":\"19.75\",\"y\":\"13.525\",\"mapId\":\"1\",\"power\":\"43.0\",\"pallet\":null,\"taskId\":null,\"load\":\"false\",\"alarm\":\"0\"},{\"deviceId\":\"6\",\"x\":\"18.124\",\"y\":\"89.375\",\"mapId\":\"1\",\"power\":\"40.0\",\"pallet\":null,\"taskId\":null,\"load\":\"false\",\"alarm\":\"0\"}]}";
log.info("queryCarDeviceStatus-----输出参数{}", result);
return RespUtil.getResp(result, new DeviceStatusRequest());
} finally {
@@ -183,6 +184,7 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
log.info("queryTsjDeviceStatus-----输入参数{}", JSON.toJSONString(requestParam));
String api = addressService.findByCode("queryTsjDeviceStatus").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
// String result = "{\"result\":true,\"code\":0,\"comment\":null,\"data\":[{\"deviceId\":\"LT01\",\"floor\":\"1\",\"pallet\":null,\"load\":\"0\",\"alarm\":\"0\"},{\"deviceId\":\"LT02\",\"floor\":\"1\",\"pallet\":null,\"load\":\"0\",\"alarm\":\"0\"}]}";
log.info("queryTsjDeviceStatus-----输出参数{}", result);
return RespUtil.getResp(result, new DeviceStatusRequest());
} finally {
@@ -197,6 +199,7 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
log.info("querySsxDeviceStatus-----输入参数{}", JSON.toJSONString(requestParam));
String api = addressService.findByCode("querySsxDeviceStatus").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
// String result = "{\"result\":true,\"code\":0,\"comment\":null,\"data\":[{\"deviceId\":\"102\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"},{\"deviceId\":\"201\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"},{\"deviceId\":\"301\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"},{\"deviceId\":\"1018\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"},{\"deviceId\":\"104\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"},{\"deviceId\":\"202\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"},{\"deviceId\":\"302\",\"pallet\":null,\"taskId\":\"0\",\"load\":\"0\"}]}";
log.info("querySsxDeviceStatus-----输出参数{}", result);
return RespUtil.getResp(result, new DeviceStatusRequest());
} finally {

View File

@@ -100,6 +100,7 @@ import photoelectric_inspection_site from '@/views/acs/device/driver/photoelectr
import standard_autodoor from '@/views/acs/device/driver/standard_autodoor'
import lamp_three_color from '@/views/acs/device/driver/lamp_three_color'
import paper_tube_conveyor from '@/views/acs/device/driver/paper_tube_conveyor'
import device_status from '@/views/acs/device/driver/device_status'
export default {
name: 'DeviceConfig',
@@ -130,7 +131,8 @@ export default {
photoelectric_inspection_site,
standard_autodoor,
lamp_three_color,
paper_tube_conveyor
paper_tube_conveyor,
device_status
},
dicts: ['device_type'],
mixins: [crud],

View File

@@ -590,6 +590,24 @@ export default {
} else if (val === 'fault') {
const obj = { name: '异常', value: data[val] }
this.arr.push(obj)
} else if (val === 'map_id') {
const obj = { name: '楼层', value: data[val] }
this.arr.push(obj)
} else if (val === 'power') {
const obj = { name: '电量', value: data[val] }
this.arr.push(obj)
} else if (val === 'pallet') {
const obj = { name: '托盘', value: data[val] }
this.arr.push(obj)
} else if (val === 'load') {
const obj = { name: '有无货', value: data[val] }
this.arr.push(obj)
} else if (val === 'alarm') {
const obj = { name: '报警', value: data[val] }
this.arr.push(obj)
} else if (val === 'task_id') {
const obj = { name: '任务号', value: data[val] }
this.arr.push(obj)
}
}
}