更新
This commit is contained in:
@@ -31,7 +31,6 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -698,7 +698,7 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
//码垛强制完成 半托缓存
|
||||
if (!requireSucess) {
|
||||
applyEmpty();
|
||||
mandatoryPalletizing();
|
||||
mandatoryPalletizing("0");
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
@@ -729,7 +729,7 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
//强制去包装
|
||||
if (!requireSucess) {
|
||||
applyEmpty();
|
||||
mandatoryPalletizing();
|
||||
mandatoryPalletizing("1");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -917,7 +917,11 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("device_code",this.device_code);
|
||||
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
|
||||
String demosub = linkobj.substring(1,linkobj.length()-1);
|
||||
String demoArray[] = demosub.split(",");
|
||||
List<String> demoList = Arrays.asList(demoArray);
|
||||
json.put("device_code",demoList.get(put_station-1).replace("\"",""));
|
||||
json.put("vehicle_code",barcode);
|
||||
JSONObject jo = acsToWmsService.getVehicle(json);
|
||||
|
||||
@@ -1071,7 +1075,8 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
String demosub = linkobj.substring(1,linkobj.length()-1);
|
||||
String demoArray[] = demosub.split(",");
|
||||
List<String> demoList = Arrays.asList(demoArray);
|
||||
json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("qty",qty);
|
||||
json.put("device_code",demoList.get(put_station-1).replace("\"",""));
|
||||
json.put("qty",qty);
|
||||
json.put("vehicle_code",barcode);
|
||||
json.put("is_full","1");
|
||||
json.put("product_code",product_code);
|
||||
@@ -1150,7 +1155,7 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public synchronized boolean mandatoryPalletizing() {
|
||||
public synchronized boolean mandatoryPalletizing(String 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);
|
||||
@@ -1165,7 +1170,8 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
json.put("device_code",demoList.get(put_station-1).replace("\"",""));
|
||||
json.put("qty",qty);
|
||||
json.put("vehicle_code",barcode);
|
||||
json.put("is_full","1");
|
||||
json.put("material_code",material);
|
||||
json.put("is_full",type);
|
||||
json.put("product_code",product_code);
|
||||
json.put("AlongSide",AlongSide);
|
||||
json.put("BshortSide",BshortSide);
|
||||
@@ -1230,8 +1236,8 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
|
||||
JSONObject jsonObject = JSONObject.parseObject(result.body());
|
||||
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
|
||||
this.writing(this.mode);
|
||||
this.setRequireSucess(true);
|
||||
}
|
||||
this.setRequireSucess(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
|
||||
package org.nl.acs.ext.xr_lk.rest;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.ext.xr_lk.service.AcsToXrlkService;
|
||||
import org.nl.annotation.Log;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author ludj
|
||||
* @date 2021-07-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "新锐立库接口")
|
||||
@RequestMapping("/api/xrlk")
|
||||
@Slf4j
|
||||
public class AcsToXrlkController {
|
||||
private final AcsToXrlkService acsToXrlkService;
|
||||
|
||||
@PostMapping("/isPutPermission")
|
||||
@Log("获取对接位是否允许放货")
|
||||
@ApiOperation("获取对接位是否允许放货")
|
||||
public ResponseEntity<Object> getPutPermission(@RequestBody String device_code) {
|
||||
return new ResponseEntity<>(acsToXrlkService.isPutPermission(device_code), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/isTakePermission")
|
||||
@Log("获取对接位是否允许取货")
|
||||
@ApiOperation("获取对接位是否允许取货")
|
||||
public ResponseEntity<Object> getTakePermission(@RequestBody String device_code) {
|
||||
return new ResponseEntity<>(acsToXrlkService.isTakePermission(device_code), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/invokeDoor")
|
||||
@Log("获取是否允许进入")
|
||||
@ApiOperation("获取是否允许进入")
|
||||
public ResponseEntity<Object> getInOutMode(@RequestBody String device_code) {
|
||||
return new ResponseEntity<>(acsToXrlkService.invokeDoor(device_code), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/AGVWorkStatus")
|
||||
@Log("动作完成")
|
||||
@ApiOperation("动作完成")
|
||||
public ResponseEntity<Object> AGVWorkStatus(@RequestBody String device_code, String type) {
|
||||
return new ResponseEntity<>(acsToXrlkService.AGVWorkStatus(device_code, type), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
package org.nl.acs.ext.xr_lk.rest;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.ext.xr_lk.service.XrlkToAcsService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wangs
|
||||
* @date 2021-07-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "新锐立库接口")
|
||||
@RequestMapping("/api/xrlk")
|
||||
@Slf4j
|
||||
public class XrlkToAcsController {
|
||||
private final XrlkToAcsService xrlkToAcsService;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.nl.acs.ext.xr_lk.service;
|
||||
|
||||
import cn.hutool.http.HttpResponse;
|
||||
|
||||
public interface AcsToXrlkService {
|
||||
|
||||
/**
|
||||
* 获取是否允许进入:
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
HttpResponse invokeDoor(String device_code);
|
||||
|
||||
/**
|
||||
* 获取对接位是否允许放货:
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
HttpResponse isPutPermission(String device_code);
|
||||
|
||||
/**
|
||||
* 获取对接位是否允许取货
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
HttpResponse isTakePermission(String device_code);
|
||||
|
||||
|
||||
/**
|
||||
* 动作完成
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
HttpResponse AGVWorkStatus(String device_code, String type);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package org.nl.acs.ext.xr_lk.service;
|
||||
|
||||
|
||||
public interface XrlkToAcsService {
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package org.nl.acs.ext.xr_lk.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.device.address.service.AddressService;
|
||||
import org.nl.acs.device.address.service.dto.AddressDto;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.ext.xr_lk.service.AcsToXrlkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AcsToXRlkServiceImpl implements AcsToXrlkService {
|
||||
|
||||
@Autowired
|
||||
AcsConfigService acsConfigService;
|
||||
|
||||
@Autowired
|
||||
DeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
AddressService addressService;
|
||||
|
||||
@Override
|
||||
public HttpResponse invokeDoor(String device_code) {
|
||||
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL);
|
||||
AddressDto addressDto = addressService.findByCode("invokeDoor");
|
||||
String url = wcsurl + addressDto.getMethods_url() + device_code;
|
||||
HttpResponse result = null;
|
||||
try {
|
||||
//{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"}
|
||||
result = HttpRequest.get(url)
|
||||
.execute();
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse isPutPermission(String device_code) {
|
||||
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL);
|
||||
AddressDto addressDto = addressService.findByCode("isPutPermission");
|
||||
String url = wcsurl + addressDto.getMethods_url() + device_code;
|
||||
HttpResponse result = null;
|
||||
try {
|
||||
//{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"}
|
||||
result = HttpRequest.get(url)
|
||||
.execute();
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse isTakePermission(String device_code) {
|
||||
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL);
|
||||
AddressDto addressDto = addressService.findByCode("isTakePermission");
|
||||
String url = wcsurl + addressDto.getMethods_url() + device_code;
|
||||
HttpResponse result = null;
|
||||
try {
|
||||
//{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"}
|
||||
result = HttpRequest.get(url)
|
||||
.execute();
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse AGVWorkStatus(String device_code, String type) {
|
||||
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL);
|
||||
AddressDto addressDto = addressService.findByCode("AGVWorkStatus");
|
||||
String url = wcsurl + addressDto.getMethods_url();
|
||||
HttpResponse result = null;
|
||||
try {
|
||||
//{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"}
|
||||
result = HttpRequest.get(url)
|
||||
.execute();
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.nl.acs.ext.xr_lk.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.ext.xr_lk.service.XrlkToAcsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class XrlkToAcsServiceImpl implements XrlkToAcsService {
|
||||
|
||||
private final InstructionService InstructionService;
|
||||
private final TaskService TaskService;
|
||||
private final DeviceService DeviceService;
|
||||
private final DeviceAppService DeviceAppService;
|
||||
private final RouteLineService RouteLineService;
|
||||
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.test.service.TestService;
|
||||
import org.nl.start.auto.run.LetteringSocketConnectionAutoRun;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
package org.nl.start.auto.run;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.config.server.impl.AcsConfigServiceImpl;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class LetteringSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
String ip = "127.0.0.1";
|
||||
int port = 1234;
|
||||
static DataOutputStream dos;
|
||||
static DataInputStream dis;
|
||||
private int recordTimeOut = 10000;
|
||||
private Date recordTime;
|
||||
boolean bConnected = true;
|
||||
|
||||
public LetteringSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return LetteringSocketConnectionAutoRun.class.getSimpleName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "海亮激光刻字在线连接";
|
||||
}
|
||||
|
||||
public void autoRun() throws IOException {
|
||||
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class);
|
||||
|
||||
ip = acsConfigService.findConfigFromCache().get(AcsConfig.LETTERINGURL);
|
||||
port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.LETTERINGPORT));
|
||||
byte[] b = new byte[1028];
|
||||
s = new Socket(ip, port);
|
||||
dos = new DataOutputStream(s.getOutputStream());
|
||||
dis = new DataInputStream(s.getInputStream());
|
||||
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
if (count == -1) {
|
||||
break;
|
||||
}
|
||||
int[] arr = new int[count];
|
||||
StringBuffer bs = new StringBuffer();
|
||||
for (int i = 0; i < count; i++) {
|
||||
int temp = b[i];
|
||||
if (temp < 0)
|
||||
temp += 256;
|
||||
arr[i] = temp;
|
||||
bs.append(asciiToString(String.valueOf(temp)));
|
||||
}
|
||||
System.out.println("收到请求参数:" + bs);
|
||||
//打印完成
|
||||
if (StrUtil.equals(bs.toString(), "MSG 3")) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(String str) throws IOException {
|
||||
System.out.println(str);
|
||||
dos.write(hexStringToByte(bytesToHexString(stringToByte(str))));
|
||||
}
|
||||
|
||||
public static byte[] stringToByte(String str) {
|
||||
byte[] bytes = str.getBytes();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static String bytesToHexString(byte[] src) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xff;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
builder.append(0);
|
||||
}
|
||||
builder.append(hv);
|
||||
}
|
||||
return builder.toString().toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
public static byte[] hexStringToByte(String hex) {
|
||||
byte[] b = new byte[hex.length() / 2];
|
||||
int j = 0;
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
char c0 = hex.charAt(j++);
|
||||
char c1 = hex.charAt(j++);
|
||||
b[i] = (byte) ((parse(c0) << 4) | parse(c1));
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
private static int parse(char c) {
|
||||
if (c >= 'a')
|
||||
return (c - 'a' + 10) & 0x0f;
|
||||
if (c >= 'A')
|
||||
return (c - 'A' + 10) & 0x0f;
|
||||
return (c - '0') & 0x0f;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ascii转换为字符串
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String asciiToString(String value) {
|
||||
StringBuffer sbu = new StringBuffer();
|
||||
String[] chars = value.split(",");
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
sbu.append((char) Integer.parseInt(chars[i]));
|
||||
}
|
||||
return sbu.toString();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
byte[] bytes = "你".getBytes("utf-8");
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
package org.nl.start.auto.run;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.AgvService;
|
||||
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.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.ext.xr_lk.service.AcsToXrlkService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.nl.acs.agv.server.impl.AgvServiceImpl.Bytes2HexString;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
String ip = "127.0.0.1";
|
||||
int port = 1234;
|
||||
static DataOutputStream dos;
|
||||
static DataInputStream dis;
|
||||
private int recordTimeOut = 10000;
|
||||
private Date recordTime;
|
||||
String[] ERROR = new String[]{
|
||||
"货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
|
||||
"停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
|
||||
"抬叉停止"};
|
||||
boolean bConnected = true;
|
||||
|
||||
boolean isReConnect = false;
|
||||
|
||||
@Autowired
|
||||
AcsConfigService acsConfigService;
|
||||
@Autowired
|
||||
AutoRunService autoRunService;
|
||||
|
||||
|
||||
public NDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return NDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "NDC在线连接";
|
||||
}
|
||||
|
||||
public void autoRun() {
|
||||
|
||||
try {
|
||||
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
AgvService AgvService = SpringContextHolder.getBean(AgvService.class);
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
AcsToXrlkService acsToXrlkService = SpringContextHolder.getBean(AcsToXrlkService.class);
|
||||
ip = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
||||
port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT));
|
||||
byte[] b = new byte[1028];
|
||||
s = new Socket(ip, port);
|
||||
dos = new DataOutputStream(s.getOutputStream());
|
||||
dis = new DataInputStream(s.getInputStream());
|
||||
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
|
||||
if (count == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
int[] arr = new int[count];
|
||||
StringBuffer bs = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int temp = b[i];
|
||||
if (temp < 0)
|
||||
temp += 256;
|
||||
arr[i] = temp;
|
||||
StringBuffer bs1 = new StringBuffer("0");
|
||||
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||
}
|
||||
|
||||
System.out.println("收到请求参数:" + bs);
|
||||
boolean flag = false;
|
||||
if (arr[8] * 256 + arr[9] == 0x73) {
|
||||
byte[] data = null;
|
||||
System.out.println("接收agv上报信息:" + bs);
|
||||
//执行阶段
|
||||
int phase = arr[16] * 256 + arr[17];
|
||||
// agv任务号
|
||||
int index = arr[12] * 256 + arr[13];
|
||||
//任务号
|
||||
int ikey = arr[26] * 256 + arr[27];
|
||||
//站点号
|
||||
int agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
Instruction inst = null;
|
||||
if (ikey != 0) {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
}
|
||||
log.info("接收agv上报信息:" + bs);
|
||||
log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
|
||||
Device device = null;
|
||||
String device_code = null;
|
||||
String old_device_code = null;
|
||||
String emptyNum = null;
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
}
|
||||
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
write(data);
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("agv上报不是0073类型动作,不处理");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
} finally {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
super.after();
|
||||
try {
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void write(byte[] b) {
|
||||
try {
|
||||
log.info("下发agv数据:" + Bytes2HexString(b));
|
||||
System.out.println("下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user