fix
This commit is contained in:
@@ -19,9 +19,9 @@ public class ItemProtocol {
|
||||
public static String item_error_time = "error_time";
|
||||
public static String item_end_time = "end_time";
|
||||
|
||||
private StandardInspectSiteDeviceDriver driver;
|
||||
private SiteStatusDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(StandardInspectSiteDeviceDriver driver) {
|
||||
public ItemProtocol(SiteStatusDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* 说明:该站点为普通带光电检测站点
|
||||
*/
|
||||
@Service
|
||||
public class StandardInspectSiteDefination implements OpcDeviceDriverDefination {
|
||||
public class SiteStatusDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "standard_inspect_site";
|
||||
@@ -33,13 +33,13 @@ public class StandardInspectSiteDefination implements OpcDeviceDriverDefination
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new StandardInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
return (new SiteStatusDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return StandardInspectSiteDeviceDriver.class;
|
||||
return SiteStatusDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -10,11 +10,9 @@ 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.RequestMethodEnum;
|
||||
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.data.feedBackTaskStatus.FeedBackTaskStatusRequest;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
@@ -32,8 +30,6 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -42,7 +38,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver , DeviceStageMonitor {
|
||||
public class SiteStatusDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver , DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@@ -145,16 +141,10 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
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);
|
||||
// this.writing(0);
|
||||
}
|
||||
}
|
||||
if (move != last_move) {
|
||||
@@ -186,51 +176,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
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;
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
//取货完成
|
||||
case 1:
|
||||
writing(2);
|
||||
return;
|
||||
//放货完成
|
||||
case 2:
|
||||
writing(3);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
@@ -272,69 +218,14 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
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);
|
||||
@@ -429,48 +320,4 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* lms申请任务
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public synchronized boolean apply(Integer type) {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.time);
|
||||
return false;
|
||||
} else {
|
||||
this.time = date;
|
||||
FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest();
|
||||
request.setDevice_code(devicecode);
|
||||
request.setMaterial_type(String.valueOf(material_type));
|
||||
request.setVehicle_code(String.valueOf(barcode));
|
||||
if (devicecode.startsWith("TBX")&&type==5&&barcode>0) {
|
||||
//满架下料
|
||||
request.setRequest_medthod_code(RequestMethodEnum.apply_mjxl.getCode());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.apply_mjxl.getName());
|
||||
}else if (devicecode.startsWith("TBX")&&type==6) {
|
||||
//补空架
|
||||
request.setRequest_medthod_code(RequestMethodEnum.apply_tbxbkj.getCode());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.apply_tbxbkj.getName());
|
||||
}else if (type==7) {
|
||||
//空托盘出库,包片机和销售出库空位都可以
|
||||
request.setRequest_medthod_code(RequestMethodEnum.apply_kghjrk.getCode());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.apply_kghjrk.getName());
|
||||
}else if(devicecode.startsWith("BP")&&material_type>0){
|
||||
request.setRequest_medthod_code(RequestMethodEnum.apply_bpsl.getCode());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.apply_bpsl.getName());
|
||||
}
|
||||
String resp = acsToWmsService.applyTask(request);
|
||||
JSONObject res_jo = JSONObject.parseObject(resp);
|
||||
if (StrUtil.equals(res_jo.getString("code"), "200")) {
|
||||
this.writing(type);
|
||||
this.setRequireSucess(true);
|
||||
log.info("acs申请任务", this.devicecode, "满盅入库任务申请成功!");
|
||||
}else{
|
||||
this.writing(99);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package org.nl.quartz.task;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.ZheDaAgvService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 查询AGV任务状态
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class QueryZDAgvTaskStatus {
|
||||
|
||||
@Autowired
|
||||
InstructionService instructionService;
|
||||
|
||||
@Autowired
|
||||
ZheDaAgvService agvService;
|
||||
|
||||
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
HttpResponse response2 = agvService.queryAgvInstStatus("1");
|
||||
//查询AGV指令列表
|
||||
JSONArray inst_rows2 = JSONArray.parseArray(response2.body());
|
||||
for (int i = 0; i < inst_rows2.size(); i++) {
|
||||
JSONObject inst_jo = inst_rows2.getJSONObject(i);
|
||||
String inst_code = inst_jo.getString("task_code");
|
||||
Instruction inst = instructionService.findByCodeFromCache(inst_code);
|
||||
if (ObjectUtil.isEmpty(inst)){
|
||||
continue;
|
||||
}
|
||||
//反馈结果状态
|
||||
log.info("instcode:" + inst_code + "," + inst_jo.toString());
|
||||
|
||||
String status = inst_jo.getString("status");
|
||||
String vehicle = "";
|
||||
//正在执行指令agv车号
|
||||
if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) {
|
||||
vehicle = inst_jo.getString("vehicle");
|
||||
inst.setCarno(vehicle);
|
||||
}
|
||||
// RAW:初始状态
|
||||
// ACTIVE:业务订单已激活
|
||||
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
|
||||
// BEING_PROCESSED:业务订单正在被执行
|
||||
// WITHDRAWN:业务订单已被撤销
|
||||
// FINISHED:业务订单已完成
|
||||
// FAILED:业务订单已失败
|
||||
// UNROUTABLE:无法规划该业务订单的执行路线
|
||||
|
||||
//执行中
|
||||
if ("BEING_PdROCESSED".equals(status) || "ACTIVE".equals(status)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
}
|
||||
} else if ("FINISHED".equals(status)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
}
|
||||
} else if ("WITHDRAWN".equals(status) || "FAILED".equals(status)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("3");
|
||||
instructionService.update(inst);
|
||||
instructionService.removeByCodeFromCache(inst_jo.getString("task_code"));
|
||||
}
|
||||
}
|
||||
JSONArray ja = inst_jo.getJSONArray("destinations");
|
||||
for (int j = 0; j < ja.size(); j++) {
|
||||
JSONObject jo = ja.getJSONObject(j);
|
||||
JSONArray pro_rows = jo.getJSONArray("properties");
|
||||
//Load 取货动作 Unload放货动作 Wait等待
|
||||
String operation = jo.getString("operation");
|
||||
String device = jo.getString("locationName");
|
||||
for (int k = 0; k < pro_rows.size(); k++) {
|
||||
JSONObject item = pro_rows.getJSONObject(k);
|
||||
if ("true".equals(item.get("value"))) {
|
||||
String param = item.get("key").toString();
|
||||
//EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待
|
||||
agvService.process(inst_code, param, device, operation, vehicle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,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:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:cw_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:tn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
password: ${DB_PWD:123456}
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.4.121}:${DB_PORT:3306}/${DB_NAME:yy_lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.4.121}:${DB_PORT:3306}/${DB_NAME:tn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
password: ${DB_PWD:123456}
|
||||
# 初始连接数
|
||||
|
||||
Reference in New Issue
Block a user