Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.one_manipulator.box_storage_manipulator.BoxStorageManipulatorDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
@@ -39,20 +40,18 @@ public class AgvWaitUtil {
|
||||
//取货前等待
|
||||
public JSONObject waitInGet(String startDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
||||
|
||||
/*JSONObject responseBody = acsToWmsService.queryStationState(inst);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(responseBody) && "200".equals(responseBody.getString("status"))) {
|
||||
JSONArray data = JSON.parseArray(responseBody.getString("data"));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject datum = data.getJSONObject(i);
|
||||
if (startDeviceCode.equals(datum.getString("Station_Code")) && !datum.getBooleanValue("IsHasGoods")) {
|
||||
|
||||
}
|
||||
Device startDevice = deviceAppService.findDeviceByCode(startDeviceCode);
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
if(startDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startDevice.getDeviceDriver();
|
||||
if(standardInspectSiteDeviceDriver.getError() != 0){
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 500);
|
||||
map.put("message", "不允许取货!");
|
||||
log.info("不允许仙工AGV取货,烘箱对接位有报警,设备号 - {}", startDeviceCode);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
throw new BadRequestException("请求失败!");*/
|
||||
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许取货!");
|
||||
@@ -63,10 +62,8 @@ public class AgvWaitUtil {
|
||||
//取货完成等待
|
||||
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||
|
||||
inst.setExecute_status("2");
|
||||
instructionService.update(inst);
|
||||
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许离开!");
|
||||
@@ -77,13 +74,16 @@ public class AgvWaitUtil {
|
||||
//放货前等待
|
||||
public JSONObject waitInPut(String endDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode);
|
||||
|
||||
Device doordevice = deviceAppService.findDeviceByCode(endDeviceCode);
|
||||
BoxStorageManipulatorDeviceDriver boxStorageManipulatorDeviceDriver;
|
||||
if(doordevice.getDeviceDriver() instanceof BoxStorageManipulatorDeviceDriver){
|
||||
boxStorageManipulatorDeviceDriver = (BoxStorageManipulatorDeviceDriver) doordevice.getDeviceDriver();
|
||||
if(boxStorageManipulatorDeviceDriver.getMode() != 2 && boxStorageManipulatorDeviceDriver.getMove() != 0){
|
||||
throw new BadRequestException("请求失败!");
|
||||
Device endDevice = deviceAppService.findDeviceByCode(endDeviceCode);
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
if(endDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) endDevice.getDeviceDriver();
|
||||
if(standardInspectSiteDeviceDriver.getError() != 0){
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 500);
|
||||
map.put("message", "不允许放货!");
|
||||
log.info("不允许仙工AGV放货,烘箱对接位有报警,设备号 - {}", endDeviceCode);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
JSONObject map = new JSONObject();
|
||||
@@ -97,6 +97,8 @@ public class AgvWaitUtil {
|
||||
//放货完成等待
|
||||
public JSONObject waitOutPut(String endDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||
inst.setExecute_status("2");
|
||||
instructionService.update(inst);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许离开!");
|
||||
|
||||
@@ -683,8 +683,6 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
if (StrUtil.isBlank(address)) {
|
||||
throw new BadRequestException("请求失败,地址为空!");
|
||||
}
|
||||
|
||||
|
||||
if (address.contains("IN")) {
|
||||
String deviceCodeNow = address.substring(0, address.length() - 5);
|
||||
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package org.nl.acs.device_driver.conveyor.oven_inspection_site;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_task = "to_task";
|
||||
public static String item_weight = "weight";
|
||||
public static String item_material_type = "material_type";
|
||||
public static String item_barcode = "barcode";
|
||||
|
||||
private OvenInspectSiteDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(OvenInspectSiteDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getMove() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
|
||||
public int getMaterialType() {
|
||||
return this.getOpcIntegerValue(item_material_type);
|
||||
}
|
||||
|
||||
public int getBarcode() {
|
||||
return this.getOpcIntegerValue(item_barcode);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getToTarget() {
|
||||
return this.getOpcIntegerValue(item_to_target);
|
||||
}
|
||||
|
||||
public int getToTask() {
|
||||
return this.getOpcIntegerValue(item_to_task);
|
||||
}
|
||||
|
||||
/**
|
||||
*是否有货
|
||||
*/
|
||||
public int hasGoods(int move) {
|
||||
return move;
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB600.B4"));
|
||||
list.add(new ItemDto(item_material_type, "物料类型", "DB600.D6"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.B7"));
|
||||
list.add(new ItemDto(item_barcode, "条码", "DB600.D8"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.conveyor.oven_inspection_site;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
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.defination.OpcDeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 烘箱检测站点驱动定义
|
||||
* 说明:该站点为普通带光电检测站点
|
||||
*/
|
||||
@Service
|
||||
public class OvenInspectSiteDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "oven_inspect_site";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "标准版-烘箱检测站点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "标准版-烘箱检测站点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new OvenInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return OvenInspectSiteDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
package org.nl.acs.device_driver.conveyor.oven_inspection_site;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
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.device.domain.Device;
|
||||
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.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.WcsConfig;
|
||||
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.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.service.mapper.TaskMapper;
|
||||
import org.nl.acs.utils.ConvertUtil;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 烘箱检测站点
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class OvenInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
|
||||
TaskMapper taskMapper;
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
/**
|
||||
* 放货准备锁
|
||||
*/
|
||||
String putReadyLock = null;
|
||||
/**
|
||||
* 有货标记
|
||||
*/
|
||||
protected boolean has_goods_tag = false;
|
||||
|
||||
private Date time = new Date();
|
||||
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
int move = 0;
|
||||
int task = 0;
|
||||
int action = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_move = 0;
|
||||
int last_task = 0;
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
int io_action = 0;
|
||||
int last_io_action = 0;
|
||||
int material_type = 0;
|
||||
int last_material_type = 0;
|
||||
int barcode = 0;
|
||||
int last_barcode = 0;
|
||||
|
||||
|
||||
boolean hasVehicle = false;
|
||||
boolean isReady = false;
|
||||
protected int instruction_num = 0;
|
||||
protected int instruction_num_truth = 0;
|
||||
boolean isFold = false;
|
||||
private String assemble_check_tag;
|
||||
|
||||
protected String current_stage_instruction_message;
|
||||
protected String last_stage_instruction_message;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
String remark;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
String qty;
|
||||
/**
|
||||
* 物料
|
||||
*/
|
||||
String material;
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
String batch;
|
||||
/**
|
||||
* 当前指令
|
||||
*/
|
||||
Instruction inst = null;
|
||||
/**
|
||||
* 上次指令
|
||||
*/
|
||||
Instruction last_inst = null;
|
||||
|
||||
/**
|
||||
* 触摸屏手动触发任务
|
||||
*/
|
||||
private Boolean is_has_task = false;
|
||||
|
||||
/**
|
||||
* 满盅入库请求标记
|
||||
*/
|
||||
boolean Sucess = false;
|
||||
|
||||
/**
|
||||
* 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
*/
|
||||
int flag;
|
||||
|
||||
String devicecode;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
devicecode = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
move = this.itemProtocol.getMove();
|
||||
hasGoods = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
material_type = this.itemProtocol.getMaterialType();
|
||||
barcode = this.itemProtocol.getBarcode();
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
if (mode == 2) {
|
||||
this.writing(0);
|
||||
}
|
||||
}
|
||||
if (move != last_move) {
|
||||
}
|
||||
if (error != last_error) {
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
break;
|
||||
case 4:
|
||||
//叫料
|
||||
if (move == 0 && !requireSucess) {
|
||||
apply(4);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
//满料出库
|
||||
if (move == 1 && !requireSucess) {
|
||||
apply(5);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
//申请空盘
|
||||
if (move == 0 && !requireSucess) {
|
||||
apply(6);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
//空托盘出库
|
||||
if (move == 1 && !requireSucess) {
|
||||
apply(7);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
case 1:
|
||||
writing(2);
|
||||
return;
|
||||
//放货完成
|
||||
case 2:
|
||||
writing(3);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_move = move;
|
||||
last_task = task;
|
||||
last_material_type = material_type;
|
||||
last_barcode = barcode;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean exe_error() {
|
||||
if (this.error == 0) {
|
||||
return true;
|
||||
} else {
|
||||
log.debug("设备报警");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void thingToNothing() {
|
||||
log.debug("从有货到无货 清理数据");
|
||||
this.set_last_container(container, container_type_desc);
|
||||
}
|
||||
|
||||
public void set_last_container(String barcode, String type_desc) {
|
||||
this.set_last_container(barcode);
|
||||
this.set_last_container_type_desc(type_desc);
|
||||
}
|
||||
|
||||
public void set_last_container(String barcode) {
|
||||
}
|
||||
|
||||
public void set_last_container_type_desc(String type) {
|
||||
}
|
||||
|
||||
public boolean exe_business() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void executing(Instruction instruction) {
|
||||
this.executing(1, instruction, "");
|
||||
}
|
||||
|
||||
public void executing(int command, Instruction instruction, String appendMessage) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_task;
|
||||
if (appendMessage == null) {
|
||||
appendMessage = "";
|
||||
}
|
||||
if (instruction != null) {
|
||||
instruction_num = Integer.parseInt(instruction.getInstruction_code());
|
||||
}
|
||||
//String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
//Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, 1);
|
||||
itemMap.put(to_task, instruction_num);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
|
||||
//String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
//Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
public void writing(int type, int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_command;
|
||||
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + ItemProtocol.item_to_task;
|
||||
//String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
//Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
if (type == 1) {
|
||||
itemMap.put(to_command, command);
|
||||
} else if (type == 2) {
|
||||
itemMap.put(to_target, command);
|
||||
|
||||
} else if (type == 3) {
|
||||
itemMap.put(to_task, command);
|
||||
}
|
||||
this.control(itemMap);
|
||||
|
||||
}
|
||||
|
||||
public boolean instruction_require(String container_code) {
|
||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*
|
||||
* @param container_code
|
||||
* @param container_type
|
||||
*/
|
||||
public synchronized boolean instruction_require(String container_code, String container_type) {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
TaskDto dto = new TaskDto();
|
||||
String now = DateUtil.now();
|
||||
dto.setTask_id(IdUtil.simpleUUID());
|
||||
dto.setCreate_by(this.getDevice().getDevice_code());
|
||||
dto.setUpdate_by(this.getDevice().getDevice_code());
|
||||
dto.setStart_point_code(this.getDevice().getDevice_code());
|
||||
dto.setVehicle_code(container_code);
|
||||
dto.setVehicle_type(container_type);
|
||||
|
||||
String taskcode = CodeUtil.getNewCode("TASK_NO");
|
||||
dto.setTask_code("-" + taskcode);
|
||||
dto.setTask_status(TaskStatusEnum.READY.getIndex());
|
||||
dto.setPriority("101");
|
||||
RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
|
||||
String next_device_codecode = jo.getNext_device_code();
|
||||
if (StrUtil.isEmpty(next_device_codecode)) {
|
||||
throw new RuntimeException("该设备未找到对应路由");
|
||||
}
|
||||
dto.setNext_point_code(next_device_codecode);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
//
|
||||
// wo.insert(json);
|
||||
|
||||
Task entity = ConvertUtil.convert(dto, Task.class);
|
||||
taskMapper.insert(entity);
|
||||
requireSucess = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@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", this.getIsonline());
|
||||
jo.put("error", this.getError());
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("task", this.getTask());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* lms申请任务
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public synchronized boolean apply(Integer type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.oven_inspection_site.OvenInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
@@ -143,6 +144,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
List<String> getDeviceCodeList = null;
|
||||
|
||||
|
||||
List<String> putDeviceCodeList = null;
|
||||
|
||||
|
||||
@@ -349,6 +351,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
//PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
|
||||
// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
|
||||
// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
// if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) {
|
||||
@@ -356,6 +359,36 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
if(startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
|
||||
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!指令号:" + instruction.getInstruction_code();
|
||||
return false;
|
||||
}
|
||||
//判断经过的烘箱是否关门
|
||||
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(start_device_code, next_device_code);
|
||||
if(!hongxiangCloseDoor){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
|
||||
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!指令号:" + instruction.getInstruction_code();
|
||||
return false;
|
||||
}
|
||||
//判断经过的烘箱是否关门
|
||||
boolean hongxiangCloseDoor = this.hongxiangCloseDoor( next_device_code, start_device_code);
|
||||
if(!hongxiangCloseDoor){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMove() != 1) {
|
||||
@@ -449,9 +482,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
if (!ObjectUtil.isEmpty(task)) {
|
||||
Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code());
|
||||
Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code());
|
||||
// PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
|
||||
// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
|
||||
// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
// if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) {
|
||||
@@ -459,6 +492,36 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
if(startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
|
||||
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!任务号:" + task.getTask_code();
|
||||
return false;
|
||||
}
|
||||
//判断经过的烘箱是否关门
|
||||
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(task.getStart_device_code(), task.getNext_device_code());
|
||||
if(!hongxiangCloseDoor){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + task.getStart_device_code() + ",放货位:" + task.getNext_device_code() + ",存在关联的同一列烘箱设备未关门!任务号:" + task.getTask_code();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(nextdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
|
||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if(ovenInspectSiteDeviceDriver.getMove() != 1 || standardInspectSiteDeviceDriver.getMove() == 1){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->烘箱检测站点-普通检测站点:" + ovenInspectSiteDeviceDriver.getDevicecode() +
|
||||
"无货,无法下发指令或"+standardInspectSiteDeviceDriver.getDevicecode()+ "有货,无法下发指令!" +"!任务号:" + task.getTask_code();
|
||||
return false;
|
||||
}
|
||||
//判断经过的烘箱是否关门
|
||||
boolean hongxiangCloseDoor = this.hongxiangCloseDoor(task.getStart_device_code(), task.getNext_device_code());
|
||||
if(!hongxiangCloseDoor){
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + task.getStart_device_code() + ",放货位:" + task.getNext_device_code() + ",存在关联的同一列烘箱设备未关门!任务号:" + task.getTask_code();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (standardInspectSiteDeviceDriver.getMove() != 1) {
|
||||
@@ -495,6 +558,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String taskid = task.getTask_id();
|
||||
String taskcode = task.getTask_code();
|
||||
String vehiclecode = task.getVehicle_code();
|
||||
@@ -600,6 +664,41 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断经过的烘箱是否关门
|
||||
*/
|
||||
private boolean hongxiangCloseDoor(String start_device_code,String next_device_code) {
|
||||
boolean flag = true;
|
||||
List<String> ovenDeviceCodeList = null;
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
|
||||
if (ObjectUtil.isEmpty(ovenDeviceCodeList) && startDevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver) {
|
||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startDevice.getDeviceDriver();
|
||||
ovenDeviceCodeList = ovenInspectSiteDeviceDriver.getExtraDeviceCodes("link_device_code");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(ovenDeviceCodeList) && nextDevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver) {
|
||||
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) nextDevice.getDeviceDriver();
|
||||
ovenDeviceCodeList = ovenInspectSiteDeviceDriver.getExtraDeviceCodes("link_device_code");
|
||||
}
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
if(CollUtil.isNotEmpty(ovenDeviceCodeList)){
|
||||
for (String s : ovenDeviceCodeList) {
|
||||
Device device = deviceAppService.findDeviceByCode(s);
|
||||
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
|
||||
//判断关联设备是否开门
|
||||
if (hongXiangConveyorDeviceDriver.getDoor() == 1) {
|
||||
notCreateInstMessage = "关联设备->" + device + "烘箱门未关闭!";
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
//判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门
|
||||
public boolean judgeCloseDoor(String start_device_code, String next_device_code) {
|
||||
Boolean isClose = false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.task.rest;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -60,8 +61,7 @@ public class TaskController {
|
||||
|
||||
@PostMapping
|
||||
@Log("新增任务")
|
||||
|
||||
//@PreAuthorize("@el.check('task:add')")
|
||||
//@SaCheckPermission("task:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody TaskDto dto) throws Exception {
|
||||
taskService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
|
||||
@@ -116,7 +116,6 @@ public class SysMenuController {
|
||||
}
|
||||
|
||||
@Log("删除菜单")
|
||||
|
||||
@DeleteMapping
|
||||
@SaCheckPermission("menu:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
|
||||
Reference in New Issue
Block a user