This commit is contained in:
USER-20220102CG\noblelift
2023-01-08 21:38:25 +08:00
parent 56de42b2cd
commit 8f0bfc0e9d
29 changed files with 587 additions and 221 deletions

View File

@@ -97,7 +97,6 @@ public class AgvServiceImpl implements AgvService {
if (address.indexOf("-") > 0) {
String str = address.substring(address.indexOf("-"), address.length());
address = address.substring(0, address.indexOf("-"));
System.out.println(address);
}
}
}

View File

@@ -9,6 +9,7 @@ import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
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.driver.AbstractDeviceDriver;
@@ -107,6 +108,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//货架
StandardStorageDeviceDriver standardStorageDeviceDriver;
//
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
//分配 车id
//(不需要WCS反馈)
@@ -163,6 +166,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setInst(inst);
}
if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
if(siemensConveyorDeviceDriver.getMove() == 1 && siemensConveyorDeviceDriver.getMode() == 2 ){
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
}
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
@@ -215,6 +225,12 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setInst(inst);
}
if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
siemensConveyorDeviceDriver.writing(2);
}
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
@@ -261,9 +277,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
// standardOrdinarySiteDeviceDriver.setAgvphase(phase);
// standardOrdinarySiteDeviceDriver.setIndex(index);
// standardOrdinarySiteDeviceDriver.setInst(inst);
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
@@ -311,16 +328,18 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
}
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
// standardOrdinarySiteDeviceDriver.setAgvphase(phase);
// standardOrdinarySiteDeviceDriver.setIndex(index);
// standardOrdinarySiteDeviceDriver.setInst(inst);
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);

View File

@@ -133,9 +133,6 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
String message = null;
device_code = this.getDeviceCode();
if (device_code.equals("A1_HK_05_1")){
System.out.println("1");
}
heartbeat = this.itemProtocol.getItem_heartbeat();
mode = this.itemProtocol.getItem_mode();
move = this.itemProtocol.getItem_move();

View File

@@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
@@ -19,6 +20,7 @@ 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.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
@@ -65,6 +67,8 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
//当前指令
Instruction inst = null;
@@ -83,8 +87,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
//任务号
int task = 0;
int last_task = 0;
int agvphase = 0;
int phase = 0;
int index = 0;
Boolean isonline = true;
int hasGoods = 0;
String message = null;
@@ -137,16 +143,20 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
if (mode == 2) {
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireSucess:" + requireSucess);
requireSucess = false;
requireApplyLabelingSuccess = false;
requireApplyLaStrangulationSuccess =false;
requireEmptyInSuccess =false;
requireEmptyOutSuccess =false;
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireSucess:" + requireSucess);
}
if (mode == 4) {
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireApplyLabelingSuccess:" + requireApplyLabelingSuccess);
requireApplyLabelingSuccess = false;
requireApplyLaStrangulationSuccess = false;
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireApplyLabelingSuccess:" + requireApplyLabelingSuccess);
}
if (mode == 5) {
logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireApplyLaStrangulationSuccess:" + requireApplyLaStrangulationSuccess);
requireApplyLaStrangulationSuccess = false;
requireApplyLabelingSuccess = false;
logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireApplyLaStrangulationSuccess:" + requireApplyLaStrangulationSuccess);
}
if (mode == 6) {
@@ -198,22 +208,86 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
int nextTask = siemensConveyorDeviceDriver.getTask();
if (nextTask == task) {
inst_message = "指令号:" + instruction.getInstruction_code() + " " + instruction.getStart_point_code() + "->" + instruction.getNext_point_code() + " 载具号:" + instruction.getVehicle_code();
if (StrUtil.equals(instruction.getInstruction_status(), "1")) {
inst = instruction;
finish_instruction();
this.clearWrite();
if(mode ==2 ){
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
int nextTask = siemensConveyorDeviceDriver.getTask();
if (nextTask == task) {
inst_message = "指令号:" + instruction.getInstruction_code() + " " + instruction.getStart_point_code() + "->" + instruction.getNext_point_code() + " 载具号:" + instruction.getVehicle_code();
if (StrUtil.equals(instruction.getInstruction_status(), "1")) {
inst = instruction;
finish_instruction();
this.clearWrite();
}
}
}
}
}
}
}
if (agvphase == 0x03) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("1");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
if (agvphase == 0x05) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("2");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// OneNDCSocketConnectionAutoRun.write(data);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
if (agvphase == 0x07) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("5");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// OneNDCSocketConnectionAutoRun.write(data);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
if (agvphase == 0x09) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status("6");
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
// OneNDCSocketConnectionAutoRun.write(data);
agvphase = 0;
index = 0;
inst = null;
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功");
} else {
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈");
}
}
} catch (Exception var17) {
inst_message = var17.getMessage();
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage());
@@ -270,15 +344,16 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
break;
case 4:
//申请贴标
if (move > 0 && !requireApplyLabelingSuccess) {
applyLabeling();
//申请捆扎
if (move > 0 && !requireApplyLaStrangulationSuccess) {
applyLaStrangulation();
}
break;
case 5:
//申请困扎
if (move > 0 && !requireApplyLaStrangulationSuccess) {
applyLaStrangulation();
//申请贴标
if (move > 0 && !requireApplyLabelingSuccess) {
applyLabeling();
}
break;
case 6:
@@ -286,6 +361,9 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
if (move > 0 && !requireEmptyInSuccess) {
emptyIn();
}
if (move > 0 && !requireSucess) {
instruction_require();
}
break;
case 7:
//空托盘满垛出库申请
@@ -573,6 +651,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//申请贴标
public synchronized void applyLabeling() {
Date date = new Date();
if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) {
@@ -580,6 +659,20 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return;
} else {
this.require_apply_labeling_time = date;
String vehicle_code = "";
if(task >0 ){
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:"+task+"异常");
message = "申请贴标电气设备任务号:"+task+"异常";
throw new RuntimeException("任务号为空!");
}
if(StrUtil.isEmpty(vehicle_code)){
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:"+task+"未找到载具号");
message = "申请贴标电气设备任务号:"+task+"未找到载具号";
throw new RuntimeException("载具号为空!");
}
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
new ApplyLabelingAndBindingRequest();
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
@@ -589,11 +682,28 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("1");
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if(ObjectUtil.isNotEmpty( applyLabelingAndBindingResponse.getData())){
Map datas = applyLabelingAndBindingResponse.getData();
String length = datas.get("box_length").toString();
String width = datas.get("box_width").toString();
String box_high = datas.get("box_high").toString();
String bundle_times = datas.get("bundle_times").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code","to_command");
map.put("value","5");
list.add(map);
this.writing(list);
}
requireApplyLabelingSuccess = true;
}
}
//申请捆扎
public synchronized void applyLaStrangulation() {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) {
@@ -601,6 +711,20 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return;
} else {
this.require_apply_strangulation_time = date;
String vehicle_code = "";
if(task >0 ){
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:"+task+"异常");
message = "申请捆扎电气设备任务号:"+task+"异常";
throw new RuntimeException("任务号为空!");
}
if(StrUtil.isEmpty(vehicle_code)){
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:"+task+"未找到载具号");
message = "申请捆扎电气设备任务号:"+task+"未找到载具号";
throw new RuntimeException("载具号为空!");
}
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
new ApplyLabelingAndBindingRequest();
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
@@ -610,7 +734,40 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("2");
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if(ObjectUtil.isNotEmpty( applyLabelingAndBindingResponse.getData())){
Map datas = applyLabelingAndBindingResponse.getData();
String length = datas.get("box_length").toString();
String width = datas.get("box_width").toString();
String box_high = datas.get("box_high").toString();
String bundle_times = datas.get("bundle_times").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code","to_length");
map.put("value",length);
list.add(map);
Map map2 = new HashMap();
map2.put("code","to_weight");
map2.put("value",width);
list.add(map2);
Map map3 = new HashMap();
map3.put("code","to_height");
map3.put("value",box_high);
list.add(map3);
Map map4 = new HashMap();
map4.put("code","to_strap_times");
map4.put("value",bundle_times);
list.add(map4);
Map map5 = new HashMap();
map5.put("code","to_command");
map5.put("value","4");
list.add(map5);
this.writing(list);
}
requireApplyLaStrangulationSuccess = true;
}
}
@@ -622,6 +779,26 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return;
} else {
this.require_empty_in_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type","2");
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "接口不通";
} else {
if (jo.getInteger("status") == 200) {
requireEmptyInSuccess = true;
} else {
requireEmptyInSuccess = false;
message = jo.get("message").toString();
}
}
}
}
}
@@ -632,6 +809,25 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return;
} else {
this.require_empty_out_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type","2");
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "接口不通";
} else {
if (jo.getInteger("status") == 200) {
requireEmptyOutSuccess = true;
} else {
requireEmptyOutSuccess = false;
message = jo.get("message").toString();
}
}
}
}
}

View File

@@ -1,9 +1,14 @@
package org.nl.acs.ext.wms.data;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
public class ApplyLabelingAndBindingResponse extends BaseResponse {
private Map<String, String> data = new HashMap();
}

View File

@@ -1,5 +1,8 @@
package org.nl.acs.ext.wms.liKuData;
import lombok.Data;
@Data
public class DeviceStatusData {
String deviceId;

View File

@@ -1,5 +1,8 @@
package org.nl.acs.ext.wms.liKuData;
import lombok.Data;
@Data
public class DeviceStatusRequest {
String deviceId;

View File

@@ -0,0 +1,14 @@
package org.nl.acs.ext.wms.liKuData;
import lombok.Data;
@Data
public class putEmptyPalletRequest {
String deviceId;
String orderId;
String type;
}

View File

@@ -55,5 +55,13 @@ public class LiKuToACSController {
return new ResponseEntity<>(liKuToAcsService.moveStoreReport(requestParam), HttpStatus.OK);
}
@SaIgnore
@PostMapping("/putEmptyPallet")
@Log("请求放空盘")
@ApiOperation("请求放空盘")
public ResponseEntity<Object> putEmptyPallet(@RequestBody putEmptyPalletRequest requestParam) throws Exception {
return new ResponseEntity<>(liKuToAcsService.putEmptyPallet(requestParam), HttpStatus.OK);
}
}

View File

@@ -93,7 +93,7 @@ public interface AcsToWmsService {
HttpResponse applyOutCacheLineTask(JSONObject param);
/**
* ACS系统申请出库任务
* 申请捆扎、贴标
*
* @param param
* @return

View File

@@ -29,4 +29,12 @@ public interface LiKuToAcsService {
*/
public Resp<MoveStoreReportResponse> moveStoreReport(MoveStoreReportRequest requestParam) throws Exception;
/**
* 移库任务上报
* @param requestParam
* @return
*/
public Resp<DeviceStatusResponse> putEmptyPallet(putEmptyPalletRequest requestParam) throws Exception;
}

View File

@@ -182,10 +182,10 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
public Resp<DeviceStatusResponse> querySsxDeviceStatus(DeviceStatusRequest requestParam) {
try {
MDC.put(log_file_type, log_type);
log.info("queryTsjDeviceStatus-----输入参数{}", requestParam);
log.info("querySsxDeviceStatus-----输入参数{}", requestParam);
String api = addressService.findByCode("querySsxDeviceStatus").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
log.info("queryTsjDeviceStatus-----输出参数{}", result);
log.info("querySsxDeviceStatus-----输出参数{}", result);
return RespUtil.getResp(result, new DeviceStatusRequest());
} finally {
MDC.remove(log_file_type);

View File

@@ -411,6 +411,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String url = wmsUrl + methods_url;
log.info("ApplyLabelingAndBindingRequest----请求参数{}", param);
try {
// String result = "";
String result = HttpRequest.post(url)
.body(JSON.toJSONString(param))
.execute().body();

View File

@@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.address.service.AddressService;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.ext.wms.AcsUtil;
import org.nl.acs.ext.wms.RespUtil;
import org.nl.acs.ext.wms.data.UpdateLKTaskRequest;
@@ -15,8 +18,12 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.LiKuToAcsService;
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.DeviceAppServiceImpl;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.slf4j.MDC;
import org.springframework.stereotype.Service;
@@ -260,4 +267,42 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
//请求放空盘
@Override
public Resp<DeviceStatusResponse> putEmptyPallet(putEmptyPalletRequest requestParam) throws Exception {
try {
MDC.put(log_file_type, log_type);
log.info("请求放空盘-----输入参数{}", requestParam.toString());
String device_code = requestParam.getDeviceId();
String type = requestParam.getType();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
JSONObject result = new JSONObject();
result.put("code", "0");
if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
if(StrUtil.equals(type,"1")){
if(siemensConveyorDeviceDriver.getMode() ==2 && siemensConveyorDeviceDriver.getMove() ==0){
result.put("result", "true");
result.put("comment", "");
} else {
result.put("result", "false");
result.put("comment", "当前设备光电信号:"+siemensConveyorDeviceDriver.getMove()+",工作模式:"+siemensConveyorDeviceDriver.getMode());
}
} else if(StrUtil.equals(type,"2")){
siemensConveyorDeviceDriver.writing("to_command","3");
result.put("result", "true");
result.put("comment", "");
}
}
log.info("请求放空盘-----输出参数{}", result);
return RespUtil.getResp(result.toString(), new DeviceStatusResponse());
} finally {
MDC.remove(log_file_type);
}
}
}

View File

@@ -95,7 +95,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
response.setMessage("success");
response.setErrArr(errArr);
log.info("createFromWms--------------:输出参数:" + response);
log.info("cancelFromWms--------------:输出参数:" + response);
return response;
}

View File

@@ -91,7 +91,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
if (is_error) {
log.info("设备OPC数据同步配置异常");
log.info("设备OPC数据同步配置异常," + err_message);
}
if (!OpcStartTag.is_run) {

View File

@@ -180,7 +180,6 @@ public class TaskFeedbackServiceImpl implements TaskFeedbackService {
e.printStackTrace();
}
int status = body.getStatus();
JSONObject jo = (JSONObject) JSONObject.toJSON(body.body());
dto.setTask_status(entity.getTask_status());
if (status == 200) {

View File

@@ -0,0 +1,44 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.map.MapUtil;
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.AgvService;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.ext.wms.liKuData.DeviceStatusRequest;
import org.nl.acs.ext.wms.liKuData.DeviceStatusResponse;
import org.nl.acs.ext.wms.liKuData.Resp;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 查询立库设备状态
*/
@Slf4j
@Component
public class QueryLKDeviceStatus {
@Autowired
AcsToLiKuService acsToLiKuService;
public void run() throws Exception {
DeviceStatusRequest deviceStatusRequest = new DeviceStatusRequest();
deviceStatusRequest.setDeviceId("0");
Resp<DeviceStatusResponse> carResp = acsToLiKuService.queryCarDeviceStatus(deviceStatusRequest);
Resp<DeviceStatusResponse> ssxResp = acsToLiKuService.querySsxDeviceStatus(deviceStatusRequest);
Resp<DeviceStatusResponse> tsjResp = acsToLiKuService.queryTsjDeviceStatus(deviceStatusRequest);
}
}

View File

@@ -1,164 +0,0 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.map.MapUtil;
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.AgvService;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 查询AGV任务状态
*/
@Slf4j
@Component
public class QueryZDAgvTaskStatus {
@Autowired
InstructionService instructionService;
@Autowired
ZheDaAgvService agvService;
public void run() throws Exception {
HttpResponse response = agvService.queryAgvInstStatus("1");
//查询AGV指令列表
JSONArray inst_rows = JSONArray.parseArray(response.body());
for (int i = 0; i < inst_rows.size(); i++) {
JSONObject inst_jo = inst_rows.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 state = inst_jo.getString("state");
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_PROCESSED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
} else if ("FINISHED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("2");
instructionService.finish(inst);
}
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
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);
}
}
}
}
HttpResponse response2 = agvService.queryAgvInstStatus("2");
//查询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 state = inst_jo.getString("state");
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_PROCESSED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
} else if ("FINISHED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("2");
instructionService.finish(inst);
}
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
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);
}
}
}
}
}
}