fix: rgv、标准版机械手、定时删除Lucene日志
This commit is contained in:
@@ -152,7 +152,7 @@ public class AgvWaitUtil {
|
||||
param.put("actionType", ActionTypeEnum.IN_FINISHING.getCode().toString());
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(inst.getCarno())
|
||||
.content("诺宝取货完成请求lms:" + inst.getTask_code() + "--" + ActionTypeEnum.IN_FINISHING.getCode().toString())
|
||||
.content("诺宝取货完成请求lms:" + inst.getTask_code() + "--" + ActionTypeEnum.IN_FINISHING.getStatus())
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
@@ -168,7 +168,7 @@ public class AgvWaitUtil {
|
||||
} else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(inst.getCarno())
|
||||
.content("追加动诺宝作块失败,返回参数:" + jo.getString("body"))
|
||||
.content("请求lms追加动诺宝作块失败,返回参数:" + jo.getString("body"))
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
|
||||
@@ -778,7 +778,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
//如果是放货二次分配,取放货二次分配需要重新追加动作块
|
||||
if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
|
||||
Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
|
||||
String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
|
||||
String newPointCode = applyXGAgvTask(task_code, actionType, instructionDto);
|
||||
// sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), deviceCodeNow, instructionDto);
|
||||
log.info("放货二次分配追加诺宝成功,新点位 - {}", newPointCode);
|
||||
JSONObject map = new JSONObject();
|
||||
@@ -823,14 +823,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
if (address.contains("GET")) {
|
||||
//取货完成
|
||||
JSONObject jsonObject = agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
|
||||
if (StringUtil.equals("200",jsonObject.getString("status"))){
|
||||
if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
||||
log.info("仙工AGV取货完成后离开,设备号 - {}", deviceCodeNow);
|
||||
return jsonObject;
|
||||
}
|
||||
} else if (address.contains("PUT")) {
|
||||
//放货完成
|
||||
JSONObject jsonObject = agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
|
||||
if (StringUtil.equals("200",jsonObject.getString("status"))){
|
||||
if (StringUtil.equals("200", jsonObject.getString("status"))) {
|
||||
log.info("仙工AGV放货完成后离开,设备号 - {}", deviceCodeNow);
|
||||
return jsonObject;
|
||||
}
|
||||
@@ -842,7 +842,6 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
}
|
||||
|
||||
private String applyCCAgvTask(String task_code, Instruction instructionDto) {
|
||||
try {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("task_code", task_code);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
@@ -873,12 +872,6 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
throw new BadRequestException("叉车二次分配请求lms返回失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private void sendAddSequencesToCCAgv(String instructionCode, String nextPoint, Instruction instructionDto) {
|
||||
@@ -956,47 +949,44 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
}
|
||||
|
||||
private String applyXGAgvTask(String task_code, Integer actionType, Instruction instructionDto) {
|
||||
try {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("taskCode", task_code);
|
||||
param.put("actionType", actionType.toString());
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("二次分配请求lms,参数:" + task_code + "--" + AgvActionTypeEnum.getStatus(actionType) )
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
String response = acsToWmsService.secondaryAllocationPoint(param);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getInteger("status") == 200) {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("二次分配请求lms,参数,接口返回:" + jo)
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
//二次分配更新点位
|
||||
updataTask(instructionDto, jo.getString("data"));
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
if (!ActionTypeEnum.IN_FINISHING.getCode().equals(actionType)) {
|
||||
//请求成功调用诺宝追加动作块
|
||||
sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), jo.getString("data"), instructionDto);
|
||||
}
|
||||
return jo.getString("data");
|
||||
|
||||
} else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("二次分配请求lms,返回参数:" + jo.getString("body"))
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
throw new BadRequestException("二次分配请求lms返回失败");
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("taskCode", task_code);
|
||||
param.put("actionType", actionType.toString());
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("二次分配请求lms,参数:" + task_code + "--" + ActionTypeEnum.getStatus(actionType))
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
String response = acsToWmsService.secondaryAllocationPoint(param);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getInteger("status") == 200) {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("二次分配请求lms,参数,接口返回:" + jo)
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
//二次分配更新点位
|
||||
updataTask(instructionDto, jo.getString("data"));
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
if (!ActionTypeEnum.IN_FINISHING.getCode().equals(actionType)) {
|
||||
//请求成功调用诺宝追加动作块
|
||||
sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), jo.getString("data"), instructionDto);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return jo.getString("data");
|
||||
|
||||
} else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(instructionDto.getCarno())
|
||||
.content("二次分配请求lms,返回参数:" + jo.getString("body"))
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
throw new BadRequestException("二次分配请求lms返回失败");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private void updataTask(Instruction instructionDto, String newPoint) {
|
||||
|
||||
@@ -196,7 +196,8 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
if (move != 0 && task > 0) {
|
||||
if (null!=inst) {
|
||||
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();
|
||||
} update_instruction_status();
|
||||
}
|
||||
update_instruction_status();
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
|
||||
@@ -358,7 +358,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
String response = acsToWmsService.deviceApplyTwo(param);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
message = "申请捆扎,参数,接口返回:" + jo;
|
||||
if (StrUtil.isNotEmpty(jo.getString("body")) || jo.getInteger("status") == 200) {
|
||||
if ( jo.getInteger("status") == 200) {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("申请捆扎,参数,接口返回:" + jo)
|
||||
@@ -376,6 +376,8 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
message = "申请捆扎报错,参数,接口返回:" + jo;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -444,6 +444,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
map2.put("value", 23);
|
||||
list2.add(map2);
|
||||
this.writing(list2);
|
||||
requireSucess = true;
|
||||
} else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
@@ -451,6 +452,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
message = "申请高度等级报错,返回参数:" + jo;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -511,6 +513,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
message = "申请退货入库报错,返回参数:" + jo;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -677,6 +680,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
map.put("value", mode);
|
||||
list1.add(map);
|
||||
this.writing(list1);
|
||||
requireSucess = true;
|
||||
} else {
|
||||
this.iserror = false;
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
@@ -684,6 +688,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
.content("木箱、子卷入库申请入库任务,返回参数:" + response)
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
message = "木箱、子卷入库申请入库任务报错,返回参数:" + jo;
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -264,7 +264,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
|
||||
requireSucess = true;
|
||||
packagePLCData(jo);
|
||||
String isUncap = jo.getString("isUncap");
|
||||
if ("1".equals(isUncap)){
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.rgv;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class
|
||||
ItemProtocol {
|
||||
|
||||
//心跳
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
//工作模式
|
||||
public static String item_mode = "mode";
|
||||
//光电信号
|
||||
public static String item_move = "move";
|
||||
//动作信号
|
||||
public static String item_action = "action";
|
||||
//行走列
|
||||
public static String item_walk_y = "walk_y";
|
||||
//任务号
|
||||
public static String item_task = "task";
|
||||
//报警
|
||||
public static String item_error = "error";
|
||||
|
||||
|
||||
|
||||
|
||||
private OneRgvDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(OneRgvDeviceDriver driver){
|
||||
this.driver=driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getMove() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getWalk_y() {
|
||||
return this.getOpcIntegerValue(item_walk_y);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isBlank(value)) {
|
||||
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB1.B1"));
|
||||
list.add(new ItemDto(item_move, "光电信号", "DB1.B2"));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
|
||||
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.rgv;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class OneRgvDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "one_rgv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "一楼rgv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "一楼rgv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new OneRgvDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return OneRgvDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.rgv);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.rgv;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceExtraService;
|
||||
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
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.ApplyManipulatorActionRequest;
|
||||
import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* RGV
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class OneRgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
|
||||
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
//光电信号
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
//动作信号
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
//行走列
|
||||
int walk_y = 0;
|
||||
int last_walk_y = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
//任务号
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
//气涨轴条码
|
||||
String barcode;
|
||||
String last_barcode;
|
||||
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
|
||||
|
||||
|
||||
String to_sub_volume_no;
|
||||
String last_to_sub_volume_no;
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
private Date instruction_update_time = new Date();
|
||||
private int instruction_update_time_out = 1000;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
|
||||
private int instruction_require_time_out = 3000;
|
||||
//行架机械手申请任务成功标识
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
private String error_type = "hxhj_error_type";
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
String left = "1";
|
||||
String right = "2";
|
||||
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
|
||||
//0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成
|
||||
int now_steps_type = 0;
|
||||
String notCreateTaskMessage = "";
|
||||
String notCreateInstMessage = "";
|
||||
String feedMessage = "";
|
||||
|
||||
|
||||
List<String> getDeviceCodeList = null;
|
||||
|
||||
List<String> putDeviceCodeList = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
move = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
walk_y = this.itemProtocol.getWalk_y();
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
|
||||
|
||||
if (mode != last_mode) {
|
||||
requireSucess = false;
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
|
||||
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "universal_off-line";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "universal_message3";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
|
||||
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_action = action;
|
||||
last_walk_y = walk_y;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
last_heartbeat = heartbeat;
|
||||
last_barcode = barcode;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* // * 申请任务
|
||||
* // *
|
||||
* // * @param
|
||||
* //
|
||||
*/
|
||||
public synchronized void applyTask() {
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
String direction = (String) this.getDevice().getExtraValue().get("direction");
|
||||
applyManipulatorActionRequest.setDevice_code(device_code);
|
||||
applyManipulatorActionRequest.setDirection(direction);//rgv申请位置
|
||||
applyManipulatorActionRequest.setQzz_no(String.valueOf(barcode));//气涨轴编码
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
if (applyManipulatorActionResponse.getstatus() == 200) {
|
||||
Map<String, String> data = applyManipulatorActionResponse.getData();
|
||||
String point_code2 = data.get("point_code2");//目标站点
|
||||
Device deviceByCode = deviceAppService.findDeviceByCode(point_code2);
|
||||
String address = deviceByCode.getExtraValue().get("address").toString();
|
||||
String material_code = data.get("material_code");//子卷号
|
||||
String to_is_labeling = data.get("to_is_labeling");//是否贴标
|
||||
map.put("to_target", address);
|
||||
map.put("to_sub_volume_no", material_code);
|
||||
map.put("to_command", "1");
|
||||
if (StrUtil.equals("1",to_is_labeling)){
|
||||
map.put("to_is_labeling","1");
|
||||
}else {
|
||||
map.put("to_is_labeling","0");
|
||||
}
|
||||
this.writing(map);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "universal_message12";
|
||||
requireSucess = true;
|
||||
} else {
|
||||
map.put("to_command", 99);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
message = "universal_message13";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务反馈失败,返回参数:" + applyManipulatorActionResponse);
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发多个电气信号" + itemMap)
|
||||
.build();
|
||||
logDto.setLog_level(3);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
String mode = "";
|
||||
String move = "";
|
||||
String action = "";
|
||||
String walk_y = "";
|
||||
if (this.getMode() == 0) {
|
||||
mode = LangProcess.msg("universal_off-line");
|
||||
} else if (this.getMode() == 1) {
|
||||
mode = LangProcess.msg("universal_stand-alone");
|
||||
} else if (this.getMode() == 2) {
|
||||
mode = LangProcess.msg("universal_standby");
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = LangProcess.msg("universal_operation");
|
||||
}
|
||||
|
||||
if (this.getMove() == 0) {
|
||||
move = LangProcess.msg("universal_no");
|
||||
map.put("hasGoods", false);
|
||||
} else if (this.getMove() == 1) {
|
||||
move = LangProcess.msg("universal_yes");
|
||||
map.put("hasGoods", true);
|
||||
} else if (this.getMove() == 2) {
|
||||
move = LangProcess.msg("universal_two_yes");
|
||||
map.put("hasGoods", true);
|
||||
}
|
||||
|
||||
String requireSucess = LangProcess.msg("universal_actionMessage4");
|
||||
if (this.requireSucess) {
|
||||
requireSucess = LangProcess.msg("universal_actionMessage5");
|
||||
}
|
||||
map.put("requireSucess", requireSucess);
|
||||
if (this.getAction() == 1) {
|
||||
action = LangProcess.msg("universal_delivery");
|
||||
} else if (this.getAction() == 2) {
|
||||
action = LangProcess.msg("universal_completed");
|
||||
} else if (this.getAction() == 3) {
|
||||
action = LangProcess.msg("universal_releasing");
|
||||
} else if (this.getAction() == 4) {
|
||||
action = LangProcess.msg("universal_releasing_completed");
|
||||
}
|
||||
|
||||
map.put("device_name", this.getDevice().getDevice_name());
|
||||
map.put("mode", mode);
|
||||
map.put("move", move);
|
||||
/*jo.put("action", action);*/
|
||||
/*jo.put("task", task);*/
|
||||
/*jo.put("walk_y", this.walk_y);*/
|
||||
map.put("isOnline", this.getIsonline());
|
||||
map.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError())));
|
||||
map.put("isError", this.getIserror());
|
||||
map.put("message", LangProcess.msg(message));
|
||||
/*jo.put("notCreateTaskMessage", notCreateTaskMessage);
|
||||
jo.put("notCreateInstMessage",notCreateInstMessage);*/
|
||||
map.put("feedMessage", LangProcess.msg(feedMessage));
|
||||
map.put("driver_type", "siemens_conveyor");
|
||||
map.put("is_click", true);
|
||||
JSONObject jo = new JSONObject(map);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
String requestSucess = data.getString("requireSucess");
|
||||
if (StrUtil.equals(requestSucess, "0")) {
|
||||
this.requireSucess = false;
|
||||
} else if (StrUtil.equals(requestSucess, "1")) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject feedLmsRealFailedInfo() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.getDevice().getDevice_code());
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("fault_code", String.valueOf(error));
|
||||
jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError())));
|
||||
jo.put("fault_type", error_type);
|
||||
return jo;
|
||||
}
|
||||
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
if (this.task > 0) {
|
||||
if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) {
|
||||
return this.inst;
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.standard_manipulator;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class
|
||||
ItemProtocol {
|
||||
|
||||
//心跳
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
//工作模式
|
||||
public static String item_mode = "mode";
|
||||
//光电信号
|
||||
public static String item_move = "move";
|
||||
//动作信号
|
||||
public static String item_action = "action";
|
||||
//行走列
|
||||
public static String item_walk_y = "walk_y";
|
||||
//任务号
|
||||
public static String item_task = "task";
|
||||
//报警
|
||||
public static String item_error = "error";
|
||||
|
||||
|
||||
|
||||
|
||||
private StandardManipulatoDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(StandardManipulatoDeviceDriver driver){
|
||||
this.driver=driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getMove() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getWalk_y() {
|
||||
return this.getOpcIntegerValue(item_walk_y);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isBlank(value)) {
|
||||
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB1.B1"));
|
||||
list.add(new ItemDto(item_move, "光电信号", "DB1.B2"));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
|
||||
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.standard_manipulator;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceExtraService;
|
||||
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
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.ApplyManipulatorActionRequest;
|
||||
import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* RGV
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class StandardManipulatoDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
|
||||
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
//光电信号
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
//动作信号
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
//行走列
|
||||
int walk_y = 0;
|
||||
int last_walk_y = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
//任务号
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
//气涨轴条码
|
||||
String barcode;
|
||||
String last_barcode;
|
||||
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
|
||||
|
||||
|
||||
String to_sub_volume_no;
|
||||
String last_to_sub_volume_no;
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
private Date instruction_update_time = new Date();
|
||||
private int instruction_update_time_out = 1000;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
|
||||
private int instruction_require_time_out = 3000;
|
||||
//行架机械手申请任务成功标识
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
private String error_type = "hxhj_error_type";
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
String left = "1";
|
||||
String right = "2";
|
||||
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
|
||||
//0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成
|
||||
int now_steps_type = 0;
|
||||
String notCreateTaskMessage = "";
|
||||
String notCreateInstMessage = "";
|
||||
String feedMessage = "";
|
||||
|
||||
|
||||
List<String> getDeviceCodeList = null;
|
||||
|
||||
List<String> putDeviceCodeList = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
move = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
walk_y = this.itemProtocol.getWalk_y();
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
|
||||
|
||||
if (mode != last_mode) {
|
||||
requireSucess = false;
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
|
||||
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "universal_off-line";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "universal_message3";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
|
||||
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_action = action;
|
||||
last_walk_y = walk_y;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
last_heartbeat = heartbeat;
|
||||
last_barcode = barcode;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* // * 申请任务
|
||||
* // *
|
||||
* // * @param
|
||||
* //
|
||||
*/
|
||||
public synchronized void applyTask() {
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
String direction = (String) this.getDevice().getExtraValue().get("direction");
|
||||
applyManipulatorActionRequest.setDevice_code(device_code);
|
||||
applyManipulatorActionRequest.setDirection(direction);//rgv申请位置
|
||||
applyManipulatorActionRequest.setQzz_no(String.valueOf(barcode));//气涨轴编码
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
if (applyManipulatorActionResponse.getstatus() == 200) {
|
||||
Map<String, String> data = applyManipulatorActionResponse.getData();
|
||||
String point_code2 = data.get("point_code2");//目标站点
|
||||
Device deviceByCode = deviceAppService.findDeviceByCode(point_code2);
|
||||
String address = deviceByCode.getExtraValue().get("address").toString();
|
||||
String material_code = data.get("material_code");//子卷号
|
||||
String to_is_labeling = data.get("to_is_labeling");//是否贴标
|
||||
map.put("to_target", address);
|
||||
map.put("to_sub_volume_no", material_code);
|
||||
map.put("to_command", "1");
|
||||
if (StrUtil.equals("1",to_is_labeling)){
|
||||
map.put("to_is_labeling","1");
|
||||
}else {
|
||||
map.put("to_is_labeling","0");
|
||||
}
|
||||
this.writing(map);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "universal_message12";
|
||||
requireSucess = true;
|
||||
} else {
|
||||
map.put("to_command", 99);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
message = "universal_message13";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请行架任务反馈失败,返回参数:" + applyManipulatorActionResponse);
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("下发多个电气信号" + itemMap)
|
||||
.build();
|
||||
logDto.setLog_level(3);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
||||
String mode = "";
|
||||
String move = "";
|
||||
String action = "";
|
||||
String walk_y = "";
|
||||
if (this.getMode() == 0) {
|
||||
mode = LangProcess.msg("universal_off-line");
|
||||
} else if (this.getMode() == 1) {
|
||||
mode = LangProcess.msg("universal_stand-alone");
|
||||
} else if (this.getMode() == 2) {
|
||||
mode = LangProcess.msg("universal_standby");
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = LangProcess.msg("universal_operation");
|
||||
}
|
||||
|
||||
if (this.getMove() == 0) {
|
||||
move = LangProcess.msg("universal_no");
|
||||
map.put("hasGoods", false);
|
||||
} else if (this.getMove() == 1) {
|
||||
move = LangProcess.msg("universal_yes");
|
||||
map.put("hasGoods", true);
|
||||
} else if (this.getMove() == 2) {
|
||||
move = LangProcess.msg("universal_two_yes");
|
||||
map.put("hasGoods", true);
|
||||
}
|
||||
|
||||
String requireSucess = LangProcess.msg("universal_actionMessage4");
|
||||
if (this.requireSucess) {
|
||||
requireSucess = LangProcess.msg("universal_actionMessage5");
|
||||
}
|
||||
map.put("requireSucess", requireSucess);
|
||||
if (this.getAction() == 1) {
|
||||
action = LangProcess.msg("universal_delivery");
|
||||
} else if (this.getAction() == 2) {
|
||||
action = LangProcess.msg("universal_completed");
|
||||
} else if (this.getAction() == 3) {
|
||||
action = LangProcess.msg("universal_releasing");
|
||||
} else if (this.getAction() == 4) {
|
||||
action = LangProcess.msg("universal_releasing_completed");
|
||||
}
|
||||
|
||||
map.put("device_name", this.getDevice().getDevice_name());
|
||||
map.put("mode", mode);
|
||||
map.put("move", move);
|
||||
/*jo.put("action", action);*/
|
||||
/*jo.put("task", task);*/
|
||||
/*jo.put("walk_y", this.walk_y);*/
|
||||
map.put("isOnline", this.getIsonline());
|
||||
map.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError())));
|
||||
map.put("isError", this.getIserror());
|
||||
map.put("message", LangProcess.msg(message));
|
||||
/*jo.put("notCreateTaskMessage", notCreateTaskMessage);
|
||||
jo.put("notCreateInstMessage",notCreateInstMessage);*/
|
||||
map.put("feedMessage", LangProcess.msg(feedMessage));
|
||||
map.put("driver_type", "siemens_conveyor");
|
||||
map.put("is_click", true);
|
||||
JSONObject jo = new JSONObject(map);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
String requestSucess = data.getString("requireSucess");
|
||||
if (StrUtil.equals(requestSucess, "0")) {
|
||||
this.requireSucess = false;
|
||||
} else if (StrUtil.equals(requestSucess, "1")) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject feedLmsRealFailedInfo() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.getDevice().getDevice_code());
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("fault_code", String.valueOf(error));
|
||||
jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError())));
|
||||
jo.put("fault_type", error_type);
|
||||
return jo;
|
||||
}
|
||||
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
if (this.task > 0) {
|
||||
if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) {
|
||||
return this.inst;
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.nl.acs.device_driver.one_manipulator.standard_manipulator;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StandardManipulatorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "standard_manipulator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "标准版机械手";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "标准版机械手";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new StandardManipulatoDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return StandardManipulatoDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.robot);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.device_driver.one_conveyor.manipulator_cache.ManipulatorCacheDeviceDriver;
|
||||
import org.nl.acs.device_driver.one_manipulator.trapped_manipulator.InteractionJsonDTO;
|
||||
import org.nl.acs.enums.VolumeTwoTypeEnum;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||
@@ -34,6 +36,7 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.enums.ActionTypeEnum;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
@@ -44,12 +47,13 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 捆扎智能行架
|
||||
* 子卷下线行架
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@@ -58,6 +62,8 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);;
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@@ -192,6 +198,10 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
}
|
||||
updateInstructionStatus();
|
||||
}
|
||||
//四个点行架任务,满轴放货完成后调lms生成rgv任务
|
||||
if (action == 6 && task > 0 ){
|
||||
creatAGV();
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
@@ -264,6 +274,45 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
|
||||
last_to_type = to_type;
|
||||
}
|
||||
|
||||
private void creatAGV() {
|
||||
Instruction instruction = checkInst();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("taskCode", instruction.getTask_code());
|
||||
param.put("actionType",ActionTypeEnum.RELEASE_FINISHING.getCode() );
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("满轴放货完成请求lms,参数:" + task + "--" +ActionTypeEnum.RELEASE_FINISHING.getStatus())
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
String response = acsToWmsService.secondaryAllocationPoint(param);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getInteger("status") == 200) {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("满轴放货完成请求lms,参数,接口返回:" + jo)
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
List list = new ArrayList();
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 6);
|
||||
list.add(map1);
|
||||
this.writing(list);
|
||||
|
||||
} else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("满轴放货完成请求lms,返回参数:" + jo)
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
throw new BadRequestException("满轴放货完成请求lms返回失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateInstructionStatus() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
|
||||
|
||||
@@ -294,6 +294,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
Boolean iserror = false;
|
||||
|
||||
String inst_message;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
@@ -334,6 +336,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
// 更新指令状态
|
||||
if (mode == 3 && task > 0 && command == 1 && error == 0) {
|
||||
if (null!=inst) {
|
||||
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();
|
||||
}
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
|
||||
@@ -1240,6 +1245,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("notCreateInstMessage", notCreateInstMessage);
|
||||
jo.put("inst_message", this.inst_message);
|
||||
return jo;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,16 @@ public enum ActionTypeEnum {
|
||||
/**
|
||||
* 防货二次分配
|
||||
*/
|
||||
OUT_STOCK(2, "防货二次分配"),
|
||||
OUT_STOCK(2, "放货二次分配"),
|
||||
/**
|
||||
* 取货完成
|
||||
*/
|
||||
IN_FINISHING(3, "取货完成");
|
||||
IN_FINISHING(3, "取货完成"),
|
||||
|
||||
/**
|
||||
* 行架四个点任务放满轴完成
|
||||
*/
|
||||
RELEASE_FINISHING(4, "满轴放货完成");
|
||||
|
||||
Integer code;
|
||||
String status;
|
||||
|
||||
@@ -25,6 +25,8 @@ public enum AgvActionTypeEnum {
|
||||
*/
|
||||
IN_OUT_STOCK(4, "取放货二次分配");
|
||||
|
||||
|
||||
|
||||
Integer code;
|
||||
String status;
|
||||
|
||||
|
||||
@@ -972,34 +972,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
instdto.setAgv_system_type(agv_system_type);
|
||||
instdto.setStart_height(start_height);
|
||||
instdto.setNext_height(next_height);
|
||||
|
||||
//判断agv系统
|
||||
//1、1楼叉车系统
|
||||
//2、2楼1区域AGV系统
|
||||
//3、2楼2区域AGV系统 -已废弃
|
||||
if (StrUtil.equals(agv_system_type, CommonFinalParam.TWO)) {
|
||||
// task_type
|
||||
//1、生箔; Itype=1:取空,取满,放空,放满;
|
||||
//2、分切 Itype=3取满、取空、放满、放空;
|
||||
//3、普通任务 Itype=2:取货、放货;
|
||||
//4、叉车任务
|
||||
//5、输送任务
|
||||
//6、行架
|
||||
//7、立库
|
||||
if (StrUtil.equals(task_type, CommonFinalParam.ONE)) {
|
||||
instdto.setAgv_inst_type(CommonFinalParam.ONE);
|
||||
} else if (StrUtil.equals(task_type, "3")) {
|
||||
instdto.setAgv_inst_type("2");
|
||||
} else if (StrUtil.equals(task_type, "2")) {
|
||||
instdto.setAgv_inst_type("3");
|
||||
} else if (StrUtil.equals(task_type, "8")) {
|
||||
instdto.setAgv_inst_type("2");
|
||||
} else {
|
||||
log.info("未找到对应的AGV指令类型,任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
|
||||
}
|
||||
} else {
|
||||
instdto.setAgv_inst_type("4");
|
||||
}
|
||||
instdto.setAgv_action_type(acsTask.getAgv_action_type());
|
||||
instructionservice.create2(instdto);
|
||||
acsTask.setTask_status(CommonFinalParam.ONE);
|
||||
this.update(acsTask);
|
||||
|
||||
@@ -57,6 +57,9 @@ public class AutoCreateInst {
|
||||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
|
||||
continue;
|
||||
}
|
||||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
|
||||
continue;
|
||||
}
|
||||
String taskid = acsTask.getTask_id();
|
||||
String taskcode = acsTask.getTask_code();
|
||||
String task_type = acsTask.getTask_type();
|
||||
|
||||
Reference in New Issue
Block a user