Browse Source

add createTask cancleTask

master
汪菘 2 years ago
parent
commit
a2caa4f214
  1. 6
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java
  2. 12
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java
  3. 52
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  4. 2
      acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java
  5. 11
      acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  6. 2
      acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  7. 2823
      acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java
  8. 2
      acs/hd/nladmin-system/src/main/resources/config/application-dev.yml
  9. 2
      acs/hd/nladmin-system/src/main/resources/config/application-prod.yml
  10. 2
      acs/hd/nladmin-system/src/main/resources/initsql.txt

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

@ -74,7 +74,7 @@ public class ItemProtocol {
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegerValue(protocol);
if (value == null) {
log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
//log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
@ -89,8 +89,8 @@ public class ItemProtocol {
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_error, "报警信号", "DB600.B7"));
list.add(new ItemDto(item_task, "任务号", "DB600.D10"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B4"));
list.add(new ItemDto(item_task, "任务号", "DB600.D6"));
return list;
}

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

@ -52,17 +52,7 @@ public class StandardInspectSiteDefination implements OpcDeviceDriverDefination
@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.B2", true));
list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B3"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B7"));
list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D10"));
return list;
return ItemProtocol.getReadableItemDtos();
}
@Override

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

@ -90,7 +90,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
private int instruction_require_time_out = 3000;
boolean requireSucess = false;
boolean inrequireSucess = false;
boolean emptyrequireSucess = false;
@ -134,10 +134,11 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
@Override
public void execute() {
public void execute() throws Exception {
String message = null;
try {
String device_code = this.getDeviceCode();
devicecode = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
@ -145,12 +146,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
hasGoods = this.itemProtocol.getMove();
if (mode != last_mode) {
if (mode == 5){
this.setEmptyrequireSucess(false);
}
if (mode == 6){
this.setInrequireSucess(false);
}
this.execute_log.setResource(this.devicecode, this.device.getDevice_name());
this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode);
}
@ -291,10 +288,25 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
if (material.length() > 0 && qty.length() > 0 && !requireSucess) {
this.execute_log.log("设备:" + devicecode + ",material:" + material + ",qty:" + qty);
this.instruction_require(container);
}
break;
//申请
case 3:
if (!inrequireSucess){
if (move == 1){
this.execute_log.log("设备:" + devicecode + ",move:" + move);
this.apply_in_require(container);
}
}
break;
//取消
case 4:
this.cancle_require();
case 5:
if (!emptyrequireSucess){
//mode = 5 并且工位上无货时申请空托盘
@ -438,6 +450,32 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
return apply_in_require(container_code, WcsConfig.task_container_type_default_desc);
}
/**
* 请求取消指令
*
*/
public synchronized boolean cancle_require() throws Exception {
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;
List<TaskDto> taskList = taskserver.queryTaskByDeviceCode(this.devicecode);
if(taskList.size() != 0){
for(int i=0;i<taskList.size();i++){
TaskDto task = taskList.get(i);
Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code());
if(ObjectUtil.isNotEmpty(inst)){
instructionService.cancel(inst.getInstruction_id());
}
taskserver.cancel(task.getTask_id());
}
}
return true;
}
}
/**
* 请求指令

2
acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java

@ -180,6 +180,8 @@ public interface InstructionService {
Instruction findByBarcodeFromCache(String barcode);
Instruction findByTaskCodeFromCache(String task_code);
/**
* 根据设备缓存查询
*

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

@ -1038,6 +1038,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
return null; }
@Override
public Instruction findByTaskCodeFromCache(String task_code) {
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
if (StrUtil.equals(task_code, inst.getTask_code())) {
return inst;
}
}
return null;
}
@Override
public Instruction findByIdFromCache(String id) {

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

@ -414,7 +414,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "0")) {
if (task.getStart_device_code().equals(device_code)) {
list.add(task);
}
}

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

File diff suppressed because it is too large

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

@ -9,7 +9,7 @@ spring:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:zgln_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hs_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nywl_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
# password: ${DB_PWD:P@ssw0rd}
# password: ${DB_PWD:Root.123456}

2
acs/hd/nladmin-system/src/main/resources/config/application-prod.yml

@ -8,7 +8,7 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:tg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nywl_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
password: ${DB_PWD:123456}
# 初始连接数

2
acs/hd/nladmin-system/src/main/resources/initsql.txt

@ -10,7 +10,7 @@ delete from acs_task;
delete from sys_log;
delete from acs_log;
delete from acs_task_feedback;
delete from sys_quartz_log;
delete from sys_quartz_log;d
delete from acs_storage_cell;
update acs_stage_actor set device_code='',image_name ='1';
update sys_code_rule_detail set current_value=0;
Loading…
Cancel
Save