add:增加agv充电 取消充电
This commit is contained in:
@@ -72,4 +72,12 @@ public interface NDCAgvService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean createChargingTaskToNDC(String carno);
|
public boolean createChargingTaskToNDC(String carno);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下发取消充电任务
|
||||||
|
*
|
||||||
|
* @param carno
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean cancelChargingTaskToNDC(String carno);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,6 +274,40 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean cancelChargingTaskToNDC(String carno) {
|
||||||
|
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||||
|
byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
|
||||||
|
|
||||||
|
String str = "十进制下发:";
|
||||||
|
String str1 = "十六进制下发:";
|
||||||
|
str += "carno:" + (Integer.parseInt(carno));
|
||||||
|
str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
|
||||||
|
|
||||||
|
System.out.println(str);
|
||||||
|
System.out.println(str1);
|
||||||
|
|
||||||
|
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||||
|
(byte) 0X00, (byte) 0X08,
|
||||||
|
(byte) 0X00, (byte) 0X08,
|
||||||
|
(byte) 0X00, (byte) 0X01,
|
||||||
|
(byte) 0X00, (byte) 0X6E,
|
||||||
|
(byte) 0X00, (byte) 0X03,
|
||||||
|
(byte) 0X00, (byte) 0X00,
|
||||||
|
(byte) carhigh, (byte) carlow
|
||||||
|
};
|
||||||
|
log.info("下发AGV取消充电任务--{}", str1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
OneNDCSocketConnectionAutoRun.write(b);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.getMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
System.out.println("下发agv取消充电任务数据:" + Bytes2HexString(b));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
String hexToString(int i) {
|
String hexToString(int i) {
|
||||||
return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase();
|
return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package org.nl.acs.ext.wms.data.one;
|
package org.nl.acs.ext.wms.data.one;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -13,6 +16,7 @@ public class BaseResponse {
|
|||||||
private String message;
|
private String message;
|
||||||
private JSONArray errArr = new JSONArray();
|
private JSONArray errArr = new JSONArray();
|
||||||
private Map<String, String> parameters = new HashMap();
|
private Map<String, String> parameters = new HashMap();
|
||||||
|
private List<JSONObject> dataList = new ArrayList<>();
|
||||||
|
|
||||||
public BaseResponse() {
|
public BaseResponse() {
|
||||||
}
|
}
|
||||||
@@ -41,6 +45,9 @@ public class BaseResponse {
|
|||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDataList(List<JSONObject> dataList) {
|
||||||
|
this.dataList = dataList;
|
||||||
|
}
|
||||||
public Object getParameter(String key) {
|
public Object getParameter(String key) {
|
||||||
return this.parameters.get(key);
|
return this.parameters.get(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,4 +136,25 @@ public class WmsToAcsController {
|
|||||||
return new ResponseEntity<>(wmstoacsService.getDevice(param), HttpStatus.OK);
|
return new ResponseEntity<>(wmstoacsService.getDevice(param), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getAgvDevice")
|
||||||
|
@Log("wms获取agv设备")
|
||||||
|
@SaIgnore
|
||||||
|
public ResponseEntity<Object> getAgvDevice(@RequestBody JSONObject param) {
|
||||||
|
return new ResponseEntity<>(wmstoacsService.getAgvDevice(param), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sendCharge")
|
||||||
|
@Log("wms下发充电任务")
|
||||||
|
@SaIgnore
|
||||||
|
public ResponseEntity<Object> sendCharge(@RequestBody JSONObject param) {
|
||||||
|
return new ResponseEntity<>(wmstoacsService.sendCharge(param), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/cancelCharge")
|
||||||
|
@Log("wms下发取消充电任务")
|
||||||
|
@SaIgnore
|
||||||
|
public ResponseEntity<Object> cancelCharge(@RequestBody JSONObject param) {
|
||||||
|
return new ResponseEntity<>(wmstoacsService.cancelCharge(param), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,4 +134,31 @@ public interface WmsToAcsService {
|
|||||||
CreateTaskResponse isGetPut(JSONObject param);
|
CreateTaskResponse isGetPut(JSONObject param);
|
||||||
|
|
||||||
CreateTaskResponse getDevice(JSONObject param);
|
CreateTaskResponse getDevice(JSONObject param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取agv设备
|
||||||
|
* @param param {
|
||||||
|
* device_code: 车号
|
||||||
|
* }
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
CreateTaskResponse getAgvDevice(JSONObject param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wms 下发充电任务
|
||||||
|
* @param param {
|
||||||
|
* device_code : 车号
|
||||||
|
* }
|
||||||
|
* @return CreateTaskResponse
|
||||||
|
*/
|
||||||
|
CreateTaskResponse sendCharge(JSONObject param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wms 下发取消充电任务
|
||||||
|
* @param param {
|
||||||
|
* device_code : 车号
|
||||||
|
* }
|
||||||
|
* @return CreateTaskResponse
|
||||||
|
*/
|
||||||
|
CreateTaskResponse cancelCharge(JSONObject param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
|
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.pallet_dispenser.PalletDispenseDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.pallet_dispenser.PalletDispenseDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.weight_platform.WeightPlatformDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.weight_platform.WeightPlatformDeviceDriver;
|
||||||
@@ -41,6 +43,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -59,6 +62,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TaskService taskserver;
|
private TaskService taskserver;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NDCAgvService ndcAgvService;
|
||||||
|
|
||||||
|
|
||||||
private String log_file_type = "log_file_type";
|
private String log_file_type = "log_file_type";
|
||||||
private String log_type = "LMS请求ACS";
|
private String log_type = "LMS请求ACS";
|
||||||
@@ -604,4 +610,82 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreateTaskResponse getAgvDevice(JSONObject param) {
|
||||||
|
log.info("wms获取agv设备-----输入参数{}", param);
|
||||||
|
CreateTaskResponse response = new CreateTaskResponse();
|
||||||
|
// 获取全部设备
|
||||||
|
List<Device> allDeviceList = deviceAppService.findAllDevice();
|
||||||
|
// 找出agv设备
|
||||||
|
List<Device> agvList = allDeviceList.stream()
|
||||||
|
.filter(row -> "agv".equals(row.getDevice_type()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(param.getString("device_code"))) {
|
||||||
|
String deviceCode = param.getString("device_code");
|
||||||
|
agvList = allDeviceList.stream()
|
||||||
|
.filter(row -> "agv".equals(row.getDevice_type()) && row.getDevice_code().equals(deviceCode))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<JSONObject> resulList = new ArrayList<>();
|
||||||
|
agvList.forEach(device -> {
|
||||||
|
AgvNdcOneDeviceDriver driver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||||
|
// 电量
|
||||||
|
int electricQty = driver.getElectric_qty();
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
// 车号
|
||||||
|
json.put("device_code",device.getDevice_code());
|
||||||
|
// 当前电量
|
||||||
|
json.put("electric_qty",electricQty);
|
||||||
|
// 车辆状态
|
||||||
|
json.put("status",driver.getStatus());
|
||||||
|
resulList.add(json);
|
||||||
|
});
|
||||||
|
log.info("wms获取agv设备-----输出参数{}", resulList);
|
||||||
|
response.setStatus(200);
|
||||||
|
response.setDataList(resulList);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreateTaskResponse sendCharge(JSONObject param) {
|
||||||
|
log.info("ACS接收WMS下发充电任务-----输入参数{}", param);
|
||||||
|
|
||||||
|
CreateTaskResponse response = new CreateTaskResponse();
|
||||||
|
String deviceCode = param.getString("device_code");
|
||||||
|
try {
|
||||||
|
// 调用ndc下发接口
|
||||||
|
ndcAgvService.createChargingTaskToNDC(deviceCode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
response.setStatus(400);
|
||||||
|
response.setMessage("下发充电失败:"+e.getMessage());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
response.setStatus(200);
|
||||||
|
response.setMessage("下发充电成功");
|
||||||
|
log.info("ACS接收WMS下发充电任务-----输出参数{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreateTaskResponse cancelCharge(JSONObject param) {
|
||||||
|
log.info("ACS接收WMS下发取消充电任务-----输入参数{}", param);
|
||||||
|
|
||||||
|
CreateTaskResponse response = new CreateTaskResponse();
|
||||||
|
String deviceCode = param.getString("device_code");
|
||||||
|
try {
|
||||||
|
// 调用ndc取消充电接口
|
||||||
|
ndcAgvService.cancelChargingTaskToNDC(deviceCode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
response.setStatus(400);
|
||||||
|
response.setMessage("下发充电失败:"+e.getMessage());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
response.setStatus(200);
|
||||||
|
response.setMessage("下发充电成功");
|
||||||
|
log.info("ACS接收WMS下发取消充电任务-----输出参数{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.nl.system.service.quartz.task;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -10,6 +11,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
import org.nl.acs.common.base.CommonFinalParam;
|
import org.nl.acs.common.base.CommonFinalParam;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device_driver.basedriver.pallet_dispenser.PalletDispenseDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.pallet_dispenser.PalletDispenseDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.basedriver.weight_platform.WeightPlatformDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||||
import org.nl.acs.instruction.domain.Instruction;
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
@@ -89,11 +91,29 @@ public class AutoCreateInst {
|
|||||||
// 查询所有执行中的任务
|
// 查询所有执行中的任务
|
||||||
List<TaskDto> readyExTask = taskserver.findReadyExTask();
|
List<TaskDto> readyExTask = taskserver.findReadyExTask();
|
||||||
boolean is_like = readyExTask.stream()
|
boolean is_like = readyExTask.stream()
|
||||||
.anyMatch(row -> row.getStart_device_code().equals("CZJT01") || row.getNext_device_code().equals("CZJT01"));
|
.anyMatch(row -> row.getStart_device_code().equals("CZJT01")
|
||||||
|
|| row.getNext_device_code().equals("CZJT01")
|
||||||
|
|| row.getNext_device_code().equals("CZJT03")
|
||||||
|
);
|
||||||
if (is_like) {
|
if (is_like) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据设备编码获取重量
|
||||||
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
|
Device device = deviceAppService.findDeviceByCode(acsTask.getNext_device_code());
|
||||||
|
if (ObjectUtil.isEmpty(device)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
WeightPlatformDeviceDriver driver = (WeightPlatformDeviceDriver) device.getDeviceDriver();
|
||||||
|
Integer weight = driver.getWeight();
|
||||||
|
if (ObjectUtil.isEmpty(weight) || weight == 0) {
|
||||||
|
weight = driver.getWeight();
|
||||||
|
}
|
||||||
|
if (weight > 500) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 向WMS申请是否可以创建指令
|
// 向WMS申请是否可以创建指令
|
||||||
JSONObject paramTask = new JSONObject().fluentPut("device_code", acsTask.getNext_device_code());
|
JSONObject paramTask = new JSONObject().fluentPut("device_code", acsTask.getNext_device_code());
|
||||||
HttpResponse httpResponse = acsToWmsService.checkTask(paramTask);
|
HttpResponse httpResponse = acsToWmsService.checkTask(paramTask);
|
||||||
@@ -109,11 +129,29 @@ public class AutoCreateInst {
|
|||||||
// 查询所有执行中的任务
|
// 查询所有执行中的任务
|
||||||
List<TaskDto> readyExTask = taskserver.findReadyExTask();
|
List<TaskDto> readyExTask = taskserver.findReadyExTask();
|
||||||
boolean is_like = readyExTask.stream()
|
boolean is_like = readyExTask.stream()
|
||||||
.anyMatch(row -> row.getStart_device_code().equals("CZJT02") || row.getNext_device_code().equals("CZJT02"));
|
.anyMatch(row -> row.getStart_device_code().equals("CZJT02")
|
||||||
|
|| row.getNext_device_code().equals("CZJT02")
|
||||||
|
|| row.getNext_device_code().equals("CZJT04")
|
||||||
|
);
|
||||||
if (is_like) {
|
if (is_like) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据设备编码获取重量
|
||||||
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
|
Device device = deviceAppService.findDeviceByCode(acsTask.getNext_device_code());
|
||||||
|
if (ObjectUtil.isEmpty(device)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
WeightPlatformDeviceDriver driver = (WeightPlatformDeviceDriver) device.getDeviceDriver();
|
||||||
|
Integer weight = driver.getWeight();
|
||||||
|
if (ObjectUtil.isEmpty(weight) || weight == 0) {
|
||||||
|
weight = driver.getWeight();
|
||||||
|
}
|
||||||
|
if (weight > 500) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 向WMS申请是否可以创建指令
|
// 向WMS申请是否可以创建指令
|
||||||
JSONObject paramTask = new JSONObject().fluentPut("device_code", acsTask.getNext_device_code());
|
JSONObject paramTask = new JSONObject().fluentPut("device_code", acsTask.getNext_device_code());
|
||||||
HttpResponse httpResponse = acsToWmsService.checkTask(paramTask);
|
HttpResponse httpResponse = acsToWmsService.checkTask(paramTask);
|
||||||
|
|||||||
Reference in New Issue
Block a user