add:新增任务看板功能和LED驱动
This commit is contained in:
@@ -35,8 +35,11 @@ public enum DriverTypeEnum {
|
||||
|
||||
SIEMENS_CONVEYOR(14,"siemens_conveyor","西门子-输送机驱动","conveyor"),
|
||||
|
||||
BELT_CONVEYOR(13,"belt_conveyor","输送线","conveyor")
|
||||
;
|
||||
BELT_CONVEYOR(13,"belt_conveyor","输送线","conveyor"),
|
||||
|
||||
SCREEN(15, "led_screen", "LED点阵屏", "screen");
|
||||
|
||||
|
||||
|
||||
//驱动索引
|
||||
private int index;
|
||||
|
||||
@@ -9,7 +9,7 @@ public enum DeviceType {
|
||||
agv("自动导引搬运车辆-AGV", 4),
|
||||
rgv("有轨制导搬运车辆-RGV", 5),
|
||||
scanner("条码阅读器-BCR", 6),
|
||||
led("LED点阵屏", 7),
|
||||
screen("LED点阵屏", 7),
|
||||
storage("货架", 8),
|
||||
robot("机械手", 9),
|
||||
autodoor("自动门", 10),
|
||||
@@ -19,6 +19,7 @@ public enum DeviceType {
|
||||
shadow("影子设备", 15),
|
||||
other("其他设备", 16);
|
||||
|
||||
|
||||
private String code;
|
||||
|
||||
private int i;
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.domain.Task;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
@@ -32,6 +33,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static redis.clients.jedis.HostAndPort.localhost;
|
||||
|
||||
/**
|
||||
* 输送线
|
||||
*/
|
||||
@@ -137,6 +140,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
String vehicle_code;
|
||||
String inst_message;
|
||||
|
||||
//led点阵屏信息
|
||||
JSONObject led_message = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -494,6 +501,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
map.put("to_container_type", "1");
|
||||
map.put("to_container_no", "1");
|
||||
this.writing(map);
|
||||
led_message = getLedMessage(instdto);
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
@@ -558,6 +566,24 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务信息
|
||||
*/
|
||||
public JSONObject getLedMessage(Instruction instdto){
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_code", instdto.getTask_code());
|
||||
json.put("inst_code", instdto.getInstruction_code());
|
||||
json.put("start_device_code", instdto.getStart_device_code());
|
||||
json.put("next_device_code", instdto.getNext_device_code());
|
||||
json.put("material_type", instdto.getMaterial());
|
||||
json.put("quantity", instdto.getQuantity());
|
||||
json.put("vehicle_code", instdto.getVehicle_code());
|
||||
json.put("instruction_status",instdto.getInstruction_status());
|
||||
json.put("entry_time", instdto.getCreate_time());
|
||||
json.put("ip", localhost);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.nl.acs.device_driver.basedriver.led_screen;
|
||||
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.DeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LED点阵屏定义
|
||||
*/
|
||||
@Service
|
||||
public class LedScreenDefination implements DeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "led_screen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "LED点阵屏";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "LED点阵屏";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new LedScreenDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType(){
|
||||
return LedScreenDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.screen);
|
||||
return types;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package org.nl.acs.device_driver.basedriver.led_screen;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
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.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.opc.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;
|
||||
|
||||
/**
|
||||
* LED点阵屏
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class LedScreenDeviceDriver 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);
|
||||
|
||||
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 Boolean apply_handling = false;
|
||||
//申请物料
|
||||
private Boolean apply_material = false;
|
||||
|
||||
// 1取货完成 2放货完成 3进入区域 4离开区域
|
||||
private int flag;
|
||||
|
||||
//人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
|
||||
private int manua_confirm = 0;
|
||||
|
||||
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;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
hasGoods = this.getDevice().getHas_goods();
|
||||
batch = this.getDevice().getBatch();
|
||||
device_code = this.getDeviceCode();
|
||||
|
||||
if (agvphase == 0x03) {
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
agvphase = 0;
|
||||
index = 0;
|
||||
inst = null;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
|
||||
} else {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (agvphase == 0x05) {
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
inst.setExecute_status("2");
|
||||
instructionService.update(inst);
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
// OneNDCSocketConnectionAutoRun.write(data);
|
||||
agvphase = 0;
|
||||
index = 0;
|
||||
inst = null;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
|
||||
} else {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (agvphase == 0x07) {
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
inst.setExecute_status("5");
|
||||
instructionService.update(inst);
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
// OneNDCSocketConnectionAutoRun.write(data);
|
||||
agvphase = 0;
|
||||
index = 0;
|
||||
inst = null;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
|
||||
} else {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
|
||||
}
|
||||
}
|
||||
|
||||
if (agvphase == 0x09) {
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
inst.setExecute_status("6");
|
||||
instructionService.update(inst);
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
// OneNDCSocketConnectionAutoRun.write(data);
|
||||
agvphase = 0;
|
||||
index = 0;
|
||||
inst = null;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
|
||||
} else {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String mode = "";
|
||||
String action = "";
|
||||
String move = "";
|
||||
if (this.getMode() == 0) {
|
||||
mode = "未联机";
|
||||
} else if (this.getMode() == 1) {
|
||||
mode = "单机";
|
||||
} else if (this.getMode() == 2) {
|
||||
mode = "联机";
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
}
|
||||
|
||||
if (this.getMove() == 0) {
|
||||
move = "无货";
|
||||
jo.put("hasGoods", false);
|
||||
} else if (this.getMove() == 1) {
|
||||
move = "有货";
|
||||
jo.put("hasGoods", true);
|
||||
} else if (this.getMove() == 2) {
|
||||
move = "有托盘有货";
|
||||
jo.put("hasGoods", true);
|
||||
}
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("isOnline", true);
|
||||
jo.put("error", this.getError());
|
||||
jo.put("isError", this.getIserror());
|
||||
return jo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.taskscreen.mapper;
|
||||
|
||||
|
||||
import org.nl.acs.common.base.CommonMapper;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.domain.DeviceAssigned;
|
||||
import org.nl.common.base.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TaskScreenMapper extends CommonMapper<Device> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.nl.acs.taskscreen.rest;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.nl.acs.taskscreen.service.TaskScreenService;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author Tu Qiang
|
||||
* @date 2023-11-18
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "任务看板")
|
||||
@RequestMapping("/api/screen")
|
||||
public class TaskScreenController {
|
||||
|
||||
@Autowired
|
||||
private TaskScreenService taskScreenService;
|
||||
|
||||
@GetMapping
|
||||
@Log("下拉选设备")
|
||||
@ApiOperation("下拉选设备")
|
||||
public ResponseEntity<Object> selectLedList() {
|
||||
return new ResponseEntity<>(taskScreenService.selectLedList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getLedMessage/{device}")
|
||||
@Log("根据关联设备获取任务信息")
|
||||
@ApiOperation("根据关联设备获取任务信息")
|
||||
public ResponseEntity<Object> getLedMessage(@PathVariable String device) {
|
||||
return new ResponseEntity<>(taskScreenService.getLedMessage(device), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.acs.taskscreen.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
|
||||
public interface TaskScreenService extends IService<Device> {
|
||||
|
||||
/**
|
||||
* 前端设备下拉选列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JSONArray selectLedList();
|
||||
|
||||
JSONObject getLedMessage(String device);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package org.nl.acs.taskscreen.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.auto.initial.ApplicationAutoInitial;
|
||||
import org.nl.acs.common.base.PageInfo;
|
||||
import org.nl.acs.common.base.impl.CommonServiceImpl;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.dto.DeviceDto;
|
||||
import org.nl.acs.device.service.dto.DeviceQueryParam;
|
||||
import org.nl.acs.device.service.mapper.DeviceMapper;
|
||||
import org.nl.acs.device_driver.basedriver.belt_conveyor.BeltConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.storage_cell.service.dto.StorageCellDto;
|
||||
import org.nl.acs.taskscreen.mapper.TaskScreenMapper;
|
||||
import org.nl.acs.taskscreen.service.TaskScreenService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper,Device> implements TaskScreenService, ApplicationAutoInitial {
|
||||
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final DeviceAppService deviceAppservice;
|
||||
|
||||
@Override
|
||||
public void autoInitial() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONArray selectLedList() {
|
||||
List<Device> list = new LambdaQueryChainWrapper<Device>(deviceMapper)
|
||||
.like(Device::getDevice_code, "LED")
|
||||
.list();
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(list));
|
||||
JSONArray result = new JSONArray();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject obj = arr.getJSONObject(i);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("device_code",obj.getString("device_code"));
|
||||
result.add(json);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getLedMessage(String device_code) {
|
||||
if (!ObjectUtil.isNotEmpty(device_code)) {
|
||||
return null;
|
||||
}
|
||||
//根据设备号找到当前设备
|
||||
LambdaQueryChainWrapper<Device> wrapper = new LambdaQueryChainWrapper<Device>(deviceMapper)
|
||||
.eq(Device::getDevice_code, device_code);
|
||||
Device device1 = deviceMapper.selectOne(wrapper);
|
||||
//获取关联设备驱动信息
|
||||
String link_device_code = String.valueOf(device1.getExtraValue().get("link_device_code"));
|
||||
Device link_device = deviceAppservice.findDeviceByCode(link_device_code);
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
JSONObject json = new JSONObject();
|
||||
if (link_device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) link_device.getDeviceDriver();
|
||||
if(ObjectUtil.isNotEmpty(beltConveyorDeviceDriver.getLed_message())){
|
||||
Instruction inst = beltConveyorDeviceDriver.getInst();
|
||||
json = beltConveyorDeviceDriver.getLedMessage(inst);
|
||||
}
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user