Browse Source

项目更新

master
loujf 2 years ago
parent
commit
d4345bcc7d
  1. BIN
      acs/nladmin-system/src/main/java/org/nl/acs/device.xls
  2. BIN
      acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls
  3. 2
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java
  4. 121
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java
  5. 78
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardConveyorControlDefination.java
  6. 438
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java
  7. 2
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java
  8. 106
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java
  9. 73
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java
  10. 455
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  11. 49
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDefination.java
  12. 376
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
  13. 49
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDefination.java
  14. 35
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDeviceDriver.java
  15. 2
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
  16. 2
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
  17. 2
      acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  18. 4
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  19. 6
      acs/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java
  20. 4
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java
  21. 8
      acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java
  22. 4
      acs/nladmin-system/src/main/resources/config/application-dev.yml

BIN
acs/nladmin-system/src/main/java/org/nl/acs/device.xls

Binary file not shown.

BIN
acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls

Binary file not shown.

2
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java

@ -135,7 +135,7 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_command;
+ "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);

121
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java

@ -1,121 +0,0 @@
package org.nl.acs.device_driver.standard_conveyor_control;
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_ioaction = "ioaction";
public static String item_height = "height";
public static String item_error = "error";
public static String item_direction = "direction";
public static String item_operation_type = "operation_type";
public static String item_task = "task";
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";
private StandardCoveyorControlDeviceDriver driver;
public ItemProtocol(StandardCoveyorControlDeviceDriver 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 getOperation_type() {
return this.getOpcIntegerValue(item_operation_type);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
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.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2"));
list.add(new ItemDto(item_action, "取放信号", "DB600.B3"));
list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4"));
list.add(new ItemDto(item_height, "高度类型", "DB600.B5"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_direction, "电机方向", "DB600.B7"));
list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8"));
list.add(new ItemDto(item_task, "任务号", "DB600.D22"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "目标站", "DB601.W4"));
list.add(new ItemDto(item_to_task, "任务号", "DB601.D8"));
return list;
}
}

78
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardConveyorControlDefination.java

@ -1,78 +0,0 @@
package org.nl.acs.device_driver.standard_conveyor_control;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 检测站点驱动定义
* 说明该站点为普通带光电检测站点
*/
@Service
public class StandardConveyorControlDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_conveyor_control";
}
@Override
public String getDriverName() {
return "标准版-输送机-控制点";
}
@Override
public String getDriverDescription() {
return "标准版-输送机-控制点";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardCoveyorControlDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardCoveyorControlDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true)));
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2"));
list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3"));
list.add(new ItemDto(ItemProtocol.item_ioaction, "进出类型", "DB600.B4"));
list.add(new ItemDto(ItemProtocol.item_height, "高度类型", "DB600.B5"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(ItemProtocol.item_direction, "电机方向", "DB600.B7"));
list.add(new ItemDto(ItemProtocol.item_operation_type, "作业类型", "DB600.B8"));
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D22"));
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

438
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java

@ -1,438 +0,0 @@
package org.nl.acs.device_driver.standard_conveyor_control;
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.config.server.AcsConfigService;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
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.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
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.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 输送机-控制点驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@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
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
int mode = 0;
int error = 0;
int move = 0;
int task = 0;
//出入库模式
int operation_type = 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;
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 Date instruction_apply_time = new Date();
private int instruction_require_time_out = 3000;
//请求成功标记
Boolean requireSucess = false;
//申请指令成功标记
Boolean applySucess = false;
String inst_message;
private int instruction_finished_time_out;
int branchProtocol = 0;
//备注
String remark;
//数量
String qty;
//物料
String material;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//申请搬运任务
private Boolean apply_handling = false;
//申请物料
private Boolean apply_material = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag = 0;
String device_code;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() throws Exception {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
operation_type = this.itemProtocol.getOperation_type();
if (mode != last_mode) {
}
if (move != last_move) {
if (move == 0) {
thingToNothing();
}
this.setRequireSucess(false);
}
if (error != last_error) {
}
if (mode == 2 && move != 0 && task > 0) {
//inst_message
inst = instructionService.findByCodeFromCache(String.valueOf(task));
if (inst != null) {
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
finish_instruction();
}
if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
}
}
} 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("设备运转模式:等待工作");
break;
case 2:
//申请任务
if (!StrUtil.isEmpty(material) && !StrUtil.isEmpty(qty) && material.length() > 0 && qty.length() > 0 && !requireSucess) {
this.instruction_require(container);
}
break;
case 3:
break;
case 4:
//叫料
break;
case 5:
//申请空盘
if (move == 0 && !requireSucess) {
apply_OutEmpty();
}
break;
case 6:
//申请入库
if (move != 0 && !applySucess) {
instruction_apply();
}
if (move != 0 && !requireSucess) {
apply_InEmpty();
}
break;
}
switch (flag) {
//取货完成
case 1:
writing(2);
break;
//放货完成
case 2:
writing(3);
break;
}
}
last_mode = mode;
last_error = error;
last_move = move;
last_task = task;
}
public boolean exe_error() {
if (this.error == 0) {
return true;
} else {
log.debug("设备报警");
return false;
}
}
protected void thingToNothing() {
log.debug("从有货到无货 清理数据");
this.setRequireSucess(false);
this.setApplySucess(false);
this.set_last_container(container, container_type_desc);
}
public void set_last_container(String barcode, String type_desc) {
this.setInst_message(null);
this.setContainer(null);
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);
ReadUtil.write(itemMap, server);
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
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);
ReadUtil.write(itemMap, server);
}
public void writing(int command, int target, int task) {
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>();
itemMap.put(to_command, command);
itemMap.put(to_target, target);
itemMap.put(to_task, task);
ReadUtil.write(itemMap, server);
}
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);
}
ReadUtil.write(itemMap, server);
}
public boolean instruction_apply() throws Exception {
return false;
}
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("0");
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);
requireSucess = false;
return true;
}
}
public synchronized boolean finish_instruction() throws Exception {
instructionService.finish(inst);
return true;
}
public void apply_OutEmpty() {
}
public synchronized boolean apply_InEmpty() throws Exception {
return false;
}
}

2
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java

@ -15,9 +15,9 @@ import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
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.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;

106
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java

@ -1,106 +0,0 @@
package org.nl.acs.device_driver.standard_inspect_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_ioaction = "ioaction";
public static String item_error = "error";
public static String item_task = "task";
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";
private StandardInspectSiteDeviceDriver driver;
public ItemProtocol(StandardInspectSiteDeviceDriver 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 getIoaction() {
return this.getOpcIntegerValue(item_ioaction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
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, "心跳", "DB2.B0"));
list.add(new ItemDto(item_mode, "工作状态", "DB2.B1", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB2.B2"));
list.add(new ItemDto(item_error, "报警信号", "DB2.B3"));
list.add(new ItemDto(item_task, "任务号", "DB2.D4"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB1.W0", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "目标站", "DB1.W2"));
list.add(new ItemDto(item_to_task, "任务号", "DB1.D4"));
return list;
}
}

73
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java

@ -1,73 +0,0 @@
package org.nl.acs.device_driver.standard_inspect_site;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 检测站点驱动定义
* 说明该站点为普通带光电检测站点
*/
@Service
public class StandardInspectSiteDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_inspect_site";
}
@Override
public String getDriverName() {
return "标准版-检测站点";
}
@Override
public String getDriverDescription() {
return "标准版-检测站点";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardInspectSiteDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB2.B0"));
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB2.B1", Boolean.valueOf(true)));
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB2.B2"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB2.B3"));
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB2.D4"));
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

455
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java

@ -1,455 +0,0 @@
package org.nl.acs.device_driver.standard_inspect_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.device_driver.standard_inspect.ReadUtil;
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.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
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.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 检测站点驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@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
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
int mode = 0;
int error = 0;
int move = 0;
int task = 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;
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;
//申请搬运任务
private Boolean apply_handling = false;
//申请物料
private Boolean apply_material = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String device_code;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
if (mode != last_mode) {
this.setRequireSucess(false);
logServer.deviceItemValue(this.device_code,"mode" ,String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code,"move" ,String.valueOf(move));
logServer.deviceExecuteLog(this.device_code,"","","信号move:" + last_move + "->" + move);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code,"error" ,String.valueOf(error));
logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code,"task",String.valueOf(task));
logServer.deviceExecuteLog(this.device_code,"","","信号task:" + last_task + "->" + task);
}
if (this.getApply_handling()) {
String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device link_device = appService.findDeviceByCode(link_device_code);
StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
if (link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
// if(standardInspectSiteDevicedriver.getMode() != 2){
// log.debug("设备未待机");
// return;
// }
// if(standardInspectSiteDevicedriver.getMove() != 0){
// log.debug("设备不满足放货条件");
// return;
// }
//如果目标设备申请叫料 则允许生成任务
if (standardInspectSiteDevicedriver.getApply_material()) {
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());
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
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(this.getDeviceCode());
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
standardInspectSiteDevicedriver.setApply_material(false);
}
}
this.setApply_handling(false);
}
} 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:
//申请任务
// if (this.getApply_handling()) {
// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
// Device link_device = appService.findDeviceByCode(link_device_code);
// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver;
// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver();
// if(standardInspectSiteDevicedriver.getMode() != 2){
// log.debug("设备未待机");
// return;
// }
// if(standardInspectSiteDevicedriver.getMove() != 0){
// log.debug("设备不满足放货条件");
// return;
// }
//
// //如果目标设备申请叫料 则允许生成任务
// if(standardInspectSiteDevicedriver.getApply_material()){
// 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());
//
// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO");
// dto.setTask_code("-"+taskcode);
// dto.setTask_status("0");
// 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);
// standardInspectSiteDevicedriver.setApply_material(false);
// }
// }
// this.setApply_handling(false);
// }
if (material.length() > 0 && qty.length() > 0 && !requireSucess) {
this.instruction_require(container);
}
}
switch (flag) {
//取货完成
case 1:
writing(2);
return;
//放货完成
case 2:
writing(3);
return;
}
}
last_mode = mode;
last_error = error;
last_move = move;
last_task = task;
}
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);
ReadUtil.write(itemMap, server);
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
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);
ReadUtil.write(itemMap, server);
}
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);
}
ReadUtil.write(itemMap, server);
}
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("0");
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);
requireSucess = false;
return true;
}
}
}

49
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDefination.java

@ -1,49 +0,0 @@
package org.nl.acs.device_driver.standard_ordinary_site;
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 StandardOrdinarySiteDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_ordinary_site";
}
@Override
public String getDriverName() {
return "标准版-无光电普通站点";
}
@Override
public String getDriverDescription() {
return "标准版-无光电普通站点";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardOrdinarySiteDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardOrdinarySiteDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
}

376
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java

@ -1,376 +0,0 @@
package org.nl.acs.device_driver.standard_ordinary_site;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
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.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.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
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.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.Date;
/**
* 普通站点
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@Autowired
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
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 devicecode;
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;
int mode = 2;
int move;
@Override
public void execute() {
hasGoods = this.getDevice().getHas_goods();
batch = this.getDevice().getBatch();
devicecode = this.getDeviceCode();
if (branchProtocol != last_branchProtocol) {
requireSucess = false;
}
switch (branchProtocol) {
case 1:
break;
//呼叫请求
case 2:
if (material.length() > 0 && Integer.parseInt(this.getQty()) > 0 && !requireSucess) {
}
break;
//响应生成任务
case 3:
if (material.length() > 0 && qty.length() > 0 && purpose.length() > 0 && !requireSucess) {
this.instruction_require(material, qty, this.getRemark(), purpose);
}
break;
//自动创建任务 叫料
case 4:
if (!requireSucess) {
autoCreateTask();
}
break;
//搬运空车、空托
case 5:
if (!requireSucess) {
autoCreateEmptyPallet();
}
break;
}
}
public boolean instruction_require(String container_code) {
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
}
/**
* 自动创建任务
*
* @return
*/
public synchronized boolean autoCreateTask() {
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());
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
String next_device_code = "";
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = (JSONObject) ja.get(i);
next_device_code = jo.get("next_device_code").toString();
Device nextdevice = appService.findDeviceByCode(next_device_code);
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver();
String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value");
if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) {
continue;
}
if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) {
break;
}
}
}
if (StrUtil.isEmpty(next_device_code)) {
throw new RuntimeException("该设备未找到对应路由");
}
dto.setNext_point_code(next_device_code);
dto.setUpdate_time(now);
dto.setCreate_time(now);
try {
taskserver.create(dto);
} catch (Exception e) {
e.printStackTrace();
}
this.setIslock(true);
requireSucess = false;
branchProtocol = 0;
return true;
}
}
/**
* 自动创建搬运空车任务
*
* @return
*/
public synchronized boolean autoCreateEmptyPallet() {
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());
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
String next_device_code = "";
dto.setRoute_plan_code("one");
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = (JSONObject) ja.get(j);
next_device_code = jo.get("next_device_code").toString();
Device nextdevice = appService.findDeviceByCode(next_device_code);
}
if (StrUtil.isEmpty(next_device_code)) {
throw new RuntimeException("该设备未找到对应路由");
}
dto.setNext_point_code(next_device_code);
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setMaterial(material);
try {
taskserver.create(dto);
} catch (Exception e) {
e.printStackTrace();
}
this.setIslock(true);
requireSucess = false;
branchProtocol = 0;
return true;
}
}
/**
* 请求任务
*
* @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("0");
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);
try {
taskserver.create(dto);
} catch (Exception e) {
e.printStackTrace();
}
requireSucess = false;
branchProtocol = 0;
return true;
}
}
/**
* 请求任务
*
* @param
* @param
*/
public synchronized boolean instruction_require(String material, String qty, String remark, String purpose) {
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.setStart_device_code(this.getDevice().getDevice_code());
dto.setVehicle_code("");
dto.setVehicle_type("");
dto.setRoute_plan_code("normal");
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
dto.setMaterial(this.getMaterial());
dto.setQuantity(new BigDecimal(this.getQty()));
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("该设备未找到对应路由");
}
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device purposedevice = appService.findDeviceByCode(purpose);
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver = null;
if (purposedevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) purposedevice.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setBranchProtocol(0);
standardOrdinarySiteDeviceDriver.setPurpose(null);
standardOrdinarySiteDeviceDriver.setRemark(null);
}
dto.setNext_point_code(purpose);
dto.setNext_device_code(purpose);
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setRemark(getRemark());
try {
taskserver.create(dto);
} catch (Exception e) {
e.printStackTrace();
}
last_branchProtocol = 2;
this.setBranchProtocol(0);
this.setRemark(null);
this.setPurpose(null);
this.setRequireSucess(true);
return true;
}
}
}

49
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDefination.java

@ -1,49 +0,0 @@
package org.nl.acs.device_driver.standard_storage;
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 StandardStorageDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_storage";
}
@Override
public String getDriverName() {
return "标准版-货架";
}
@Override
public String getDriverDescription() {
return "标准版-货架";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardStorageDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardStorageDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.storage);
return types;
}
}

35
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDeviceDriver.java

@ -1,35 +0,0 @@
package org.nl.acs.device_driver.standard_storage;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.StorageDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
/**
* 标准版货架
*/
@Slf4j
@Data
public class StandardStorageDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver {
public StandardStorageDeviceDriver() {
}
public boolean isTakeReady() {
return true;
}
public boolean isPutReady() {
return true;
}
public boolean fixTypes(Integer type) {
return true;
}
}

2
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -49,7 +49,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Autowired
DeviceExecuteLogService logServer;
@Value("${acsTowms.token}")
// @Value("${acsTowms.token}")
public String token;
private String log_file_type="log_file_type";

2
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java

@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_kiln_lane.LnshKilnLaneDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_labeling_machine.LnshLabelingMachineDeviceDriver;
@ -22,7 +23,6 @@ import org.nl.acs.device_driver.lnsh.lnsh_rgv.LnshRGVDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_split_manipulator.LnshSplitManipulatorDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver;
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.wms.service.WmsToAcsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;

2
acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -20,9 +20,9 @@ import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;

4
acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -21,8 +21,8 @@ import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.StorageCellService;
import org.nl.acs.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;

6
acs/nladmin-system/src/main/java/org/nl/modules/logicflow/service/impl/StageServiceImpl.java

@ -8,6 +8,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_kiln_lane.LnshKilnLaneDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_labeling_machine.LnshLabelingMachineDeviceDriver;
@ -18,10 +21,7 @@ import org.nl.acs.device_driver.lnsh.lnsh_rgv.LnshRGVDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_split_manipulator.LnshSplitManipulatorDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver;
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;

4
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -7,11 +7,11 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site.LnshFoldDiscSiteDeviceDriver;
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;

8
acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

@ -11,16 +11,16 @@ import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.config.server.impl.AcsConfigServiceImpl;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine.LnshLaminatingMachineDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator.LnshPalletizingManipulatorDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator_site.LnshPalletizingManipulatorSiteDeviceDriver;
import org.nl.acs.device_driver.lnsh.lnsh_station.LnshStationDeviceDriver;
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver;
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;

4
acs/nladmin-system/src/main/resources/config/application-dev.yml

@ -6,10 +6,10 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:yongyu_acs2}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lnsh_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:yongyu_acs2}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root}
password: ${DB_PWD:P@ssw0rd}
password: ${DB_PWD:123456}
# password: ${DB_PWD:Root.123456}
# 初始连接数
initial-size: 5

Loading…
Cancel
Save