add:科冲接口新增
This commit is contained in:
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.AcsConfig;
|
import org.nl.acs.AcsConfig;
|
||||||
|
import org.nl.acs.agv.server.dao.AgvResponse;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device_driver.agv.xg_agv_car.XgAgvCarDeviceDriver;
|
import org.nl.acs.device_driver.agv.xg_agv_car.XgAgvCarDeviceDriver;
|
||||||
import org.nl.acs.instruction.domain.Instruction;
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
@@ -45,23 +46,27 @@ public class QueryAGVStatus {
|
|||||||
TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
TaskService taskService = SpringContextHolder.getBean(TaskService.class);
|
||||||
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||||
List<Instruction> allInstFromCache = instructionService.findAllInstFromCache();
|
List<Instruction> allInstFromCache = instructionService.findAllInstFromCache();
|
||||||
List<Instruction> agvInstruction = allInstFromCache.stream().filter(item -> AgvSystemTypeEnum.One_NDC_System_Type.getIndex().equals(item.getAgv_system_type()) || AgvSystemTypeEnum.XG_System_Type.getIndex().equals(item.getAgv_system_type())).collect(Collectors.toList());
|
// List<Instruction> agvInstruction = allInstFromCache.stream().filter(item -> AgvSystemTypeEnum.One_NDC_System_Type.getIndex().equals(item.getAgv_system_type()) || AgvSystemTypeEnum.XG_System_Type.getIndex().equals(item.getAgv_system_type())).collect(Collectors.toList());
|
||||||
if (CollUtil.isEmpty(agvInstruction) || agvInstruction.size() < 1) {
|
if (CollUtil.isEmpty(allInstFromCache) || allInstFromCache.size() < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Instruction instruction : agvInstruction) {
|
for (Instruction instruction : allInstFromCache) {
|
||||||
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
agvurl = agvurl + ":" + agvport + "/orderDetails/" + instruction.getInstruction_code();
|
agvurl = agvurl + ":" + agvport + "/api/fms/taskStatus ";
|
||||||
|
param.put("TaskNo", instruction.getInstruction_code());
|
||||||
log.info("根据运单号查询运单状态的请求:{}", agvurl);
|
log.info("根据运单号查询运单状态的请求:{}", agvurl);
|
||||||
HttpResponse result = HttpRequest.get(agvurl)
|
HttpResponse result = HttpRequest.get(agvurl)
|
||||||
|
.body(String.valueOf(param))
|
||||||
.timeout(20000)//超时,毫秒
|
.timeout(20000)//超时,毫秒
|
||||||
.execute();
|
.execute();
|
||||||
log.info("根据运单号查询运单状态的请求反馈:{}", result);
|
log.info("根据运单号查询运单状态的请求反馈:{}", result);
|
||||||
String body = result.body();
|
String body = result.body();
|
||||||
JSONObject json = JSONObject.parseObject(body);
|
JSONObject json = JSONObject.parseObject(body);
|
||||||
if (result.getStatus() == 200 && json.getString("id").equals(instruction.getInstruction_code())) {
|
JSONObject taskStatus = json.getJSONObject("TaskStatus");
|
||||||
|
String taskNo = taskStatus.getString("TaskNo");
|
||||||
|
if ("true".equals(json.getString("Result")) && taskNo.equals(instruction.getInstruction_code())) {
|
||||||
// 已创建=CREATED,
|
// 已创建=CREATED,
|
||||||
// 待分配=TOBEDISPATCHED,
|
// 待分配=TOBEDISPATCHED,
|
||||||
// 正在执行=RUNNING,
|
// 正在执行=RUNNING,
|
||||||
@@ -71,10 +76,10 @@ public class QueryAGVStatus {
|
|||||||
// 无法执行=Error(参数错误),
|
// 无法执行=Error(参数错误),
|
||||||
// 等待=WAITING
|
// 等待=WAITING
|
||||||
//执行中
|
//执行中
|
||||||
String state = json.getString("state");
|
String state = json.getString("Status");
|
||||||
String carNo = json.getString("vehicle");
|
String carNo = json.getString("VehicleNo");
|
||||||
String instructionCode = json.getString("id");
|
String instructionCode = json.getString("id");
|
||||||
if ("RUNNING".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
if ("running".equals(state)) {
|
||||||
if ("1".equals(instruction.getInstruction_status())) {
|
if ("1".equals(instruction.getInstruction_status())) {
|
||||||
instruction.setCarno(carNo);
|
instruction.setCarno(carNo);
|
||||||
TaskDto task = new TaskDto();
|
TaskDto task = new TaskDto();
|
||||||
@@ -83,19 +88,19 @@ public class QueryAGVStatus {
|
|||||||
task.setTask_id(instruction.getTask_id());
|
task.setTask_id(instruction.getTask_id());
|
||||||
instructionService.update(instruction);
|
instructionService.update(instruction);
|
||||||
taskService.update(task);
|
taskService.update(task);
|
||||||
if (StrUtil.isNotEmpty(instructionCode)) {
|
// if (StrUtil.isNotEmpty(instructionCode)) {
|
||||||
Device carCode = deviceAppService.findDeviceByCode(instructionCode);
|
// Device carCode = deviceAppService.findDeviceByCode(instructionCode);
|
||||||
XgAgvCarDeviceDriver xgAgvCarDeviceDriver;
|
// XgAgvCarDeviceDriver xgAgvCarDeviceDriver;
|
||||||
if (null != carCode) {
|
// if (null != carCode) {
|
||||||
if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver) {
|
// if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver) {
|
||||||
xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver();
|
// xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver();
|
||||||
xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type()));
|
// xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("FINISHED".equals(state)) {
|
} else if ("finish".equals(state)) {
|
||||||
if (!"2".equals(instruction.getInstruction_status())) {
|
if (!"2".equals(instruction.getInstruction_status())) {
|
||||||
instruction.setInstruction_status("2");
|
instruction.setInstruction_status("2");
|
||||||
try {
|
try {
|
||||||
@@ -105,7 +110,7 @@ public class QueryAGVStatus {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
} else if ("paused".equals(state) || "aborted".equals(state) || "Error".equals(state)) {
|
||||||
if (!"1".equals(instruction.getInstruction_status())) {
|
if (!"1".equals(instruction.getInstruction_status())) {
|
||||||
instruction.setInstruction_status("1");
|
instruction.setInstruction_status("1");
|
||||||
instructionService.update(instruction);
|
instructionService.update(instruction);
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package org.nl.acs.agv.rest;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.agv.server.KeCongAgvService;
|
||||||
|
import org.nl.acs.agv.server.dao.AgvResponse;
|
||||||
|
import org.nl.common.logging.annotation.Log;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
|
||||||
|
@RequestMapping("/api/fms")
|
||||||
|
@Slf4j
|
||||||
|
public class KeCongAgvController {
|
||||||
|
private final KeCongAgvService keCongAgvService;
|
||||||
|
|
||||||
|
@PostMapping("/waitPointRequest")
|
||||||
|
@Log("等待点请求")
|
||||||
|
@SaIgnore
|
||||||
|
public ResponseEntity<AgvResponse> waitPointRequest(@RequestBody JSONObject requestParam) {
|
||||||
|
return new ResponseEntity<>(keCongAgvService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/requestResource")
|
||||||
|
@Log("请求资源")
|
||||||
|
@SaIgnore
|
||||||
|
public ResponseEntity<AgvResponse> requestResource(@RequestBody JSONObject requestParam) {
|
||||||
|
return new ResponseEntity<>(keCongAgvService.requestResource(requestParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/releaseResource")
|
||||||
|
@Log("释放资源")
|
||||||
|
@SaIgnore
|
||||||
|
public ResponseEntity<AgvResponse> releaseResource(@RequestBody JSONObject requestParam) {
|
||||||
|
return new ResponseEntity<>(keCongAgvService.releaseResource(requestParam), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.nl.acs.agv.server;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.acs.agv.server.dao.AgvResponse;
|
||||||
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
|
|
||||||
|
public interface KeCongAgvService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下发运单序列
|
||||||
|
*
|
||||||
|
* @param inst
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public HttpResponse addTask(Instruction inst) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询AGV任务状态
|
||||||
|
* @param instCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public HttpResponse queryKZAgvInstStatus(String instCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询AGV状态
|
||||||
|
* @param vehicleCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public HttpResponse queryKZAgvStatus(String vehicleCode);
|
||||||
|
|
||||||
|
AgvResponse xgAGVWaitPointRequest(JSONObject requestParam);
|
||||||
|
|
||||||
|
public AgvResponse updateKZAgvInst(JSONObject requestParam);
|
||||||
|
|
||||||
|
AgvResponse requestResource(JSONObject requestParam);
|
||||||
|
|
||||||
|
AgvResponse releaseResource(JSONObject requestParam);
|
||||||
|
|
||||||
|
HttpResponse getRobotInfo(String robotCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务状态
|
||||||
|
* @param instCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
// public JSONObject updateKZAgvInstStatus(String instCode);
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package org.nl.acs.agv.server.dao;
|
||||||
|
|
||||||
|
public class AgvRequest {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.nl.acs.agv.server.dao;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AgvResponse {
|
||||||
|
private int ErrCode;
|
||||||
|
|
||||||
|
private String ErrMsg;
|
||||||
|
|
||||||
|
private String result;//Result: true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,346 @@
|
|||||||
|
package org.nl.acs.agv.server.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.AcsConfig;
|
||||||
|
import org.nl.acs.agv.server.KeCongAgvService;
|
||||||
|
import org.nl.acs.agv.server.MagicAgvService;
|
||||||
|
import org.nl.acs.agv.server.dao.AgvResponse;
|
||||||
|
import org.nl.acs.common.base.CommonFinalParam;
|
||||||
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||||
|
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||||
|
import org.nl.system.service.param.ISysParamService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class KeCongAgvServiceImpl implements KeCongAgvService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LuceneExecuteLogService luceneExecuteLogService;
|
||||||
|
@Autowired
|
||||||
|
private InstructionService instructionService;
|
||||||
|
private final ISysParamService paramService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResponse addTask(Instruction inst) throws Exception {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
jo.put("TaskType", inst.getInstruction_type());
|
||||||
|
JSONObject json1 = new JSONObject();
|
||||||
|
json1.put("Key", "TaskId");
|
||||||
|
json1.put("Value", inst.getInstruction_code());
|
||||||
|
arr.add(json1);
|
||||||
|
JSONObject json2 = new JSONObject();
|
||||||
|
json2.put("Key", "VehicleNo");
|
||||||
|
json2.put("Value", "3");
|
||||||
|
arr.add(json2);
|
||||||
|
JSONObject json3 = new JSONObject();
|
||||||
|
json3.put("Key", "point1");
|
||||||
|
json3.put("Value", inst.getStart_device_code());
|
||||||
|
arr.add(json3);
|
||||||
|
JSONObject json4 = new JSONObject();
|
||||||
|
json4.put("Key", "point2");
|
||||||
|
json4.put("Value", inst.getNext_device_code());
|
||||||
|
arr.add(json4);
|
||||||
|
if ("任务1" .equals(inst.getInstruction_type())) {
|
||||||
|
JSONObject json5 = new JSONObject();
|
||||||
|
json5.put("Key", "point3");
|
||||||
|
json5.put("Value", inst.getStart_device_code2());
|
||||||
|
arr.add(json5);
|
||||||
|
JSONObject json6 = new JSONObject();
|
||||||
|
json6.put("Key", "point4");
|
||||||
|
json6.put("Value", inst.getNext_device_code2());
|
||||||
|
arr.add(json6);
|
||||||
|
} else if ("任务11" .equals(inst.getInstruction_type())) {
|
||||||
|
JSONObject json5 = new JSONObject();
|
||||||
|
json5.put("Key", "isget");
|
||||||
|
json5.put("Value", "0");
|
||||||
|
arr.add(json5);
|
||||||
|
} else if ("任务12" .equals(inst.getInstruction_type())) {
|
||||||
|
JSONObject json6 = new JSONObject();
|
||||||
|
json6.put("Key", "isput");
|
||||||
|
json6.put("Value", "0");
|
||||||
|
arr.add(json6);
|
||||||
|
} else if ("任务13" .equals(inst.getInstruction_type())) {
|
||||||
|
JSONObject json5 = new JSONObject();
|
||||||
|
json5.put("Key", "isget");
|
||||||
|
json5.put("Value", "0");
|
||||||
|
arr.add(json5);
|
||||||
|
JSONObject json6 = new JSONObject();
|
||||||
|
json6.put("Key", "isput");
|
||||||
|
json6.put("Value", "0");
|
||||||
|
arr.add(json6);
|
||||||
|
}
|
||||||
|
jo.put("Params", arr);
|
||||||
|
System.out.println(jo);
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code("下发科聪任务")
|
||||||
|
.content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发agv任务序列参数:" + jo)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(4);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
log.info("任务号:{},指令号{},下发科聪任务序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo);
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).
|
||||||
|
|
||||||
|
getValue(), CommonFinalParam.ONE)) {
|
||||||
|
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
|
|
||||||
|
agvurl = agvurl + ":" + agvport + "/api/fms/addTaskV2";
|
||||||
|
|
||||||
|
log.info(agvurl);
|
||||||
|
HttpResponse result = HttpRequest.post(agvurl)
|
||||||
|
//表单内容
|
||||||
|
.body(String.valueOf(jo))
|
||||||
|
//超时,毫秒
|
||||||
|
.timeout(20000)
|
||||||
|
.execute();
|
||||||
|
LuceneLogDto logDto1 = LuceneLogDto.builder()
|
||||||
|
.device_code("下发科聪任务")
|
||||||
|
.content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发科聪任务序列反馈参数:" + jo)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(4);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
||||||
|
log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResponse queryKZAgvInstStatus(String instCode) {
|
||||||
|
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
|
||||||
|
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
|
|
||||||
|
agvurl = agvurl + ":" + agvport + "/api/fms/taskStatus/" + instCode;
|
||||||
|
|
||||||
|
HttpResponse result = HttpRequest.get(agvurl)
|
||||||
|
//超时,毫秒
|
||||||
|
.timeout(20000)
|
||||||
|
.execute();
|
||||||
|
System.out.println("查询agv指令数据:" + result.body());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResponse queryKZAgvStatus(String vehicleCode) {
|
||||||
|
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
|
||||||
|
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
|
|
||||||
|
agvurl = agvurl + ":" + agvport + "/api/fms/vehicleStatus/" + vehicleCode;
|
||||||
|
|
||||||
|
HttpResponse result = HttpRequest.get(agvurl)
|
||||||
|
//超时,毫秒
|
||||||
|
.timeout(20000)
|
||||||
|
.execute();
|
||||||
|
System.out.println("查询agv数据:" + result.body());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AgvResponse xgAGVWaitPointRequest(JSONObject requestParam) {
|
||||||
|
System.out.println("请求kc参数:" + requestParam);
|
||||||
|
String taskId = requestParam.getString("TaskId");
|
||||||
|
String type = requestParam.getString("type"); // 1 取货点等待 2 放货点等待
|
||||||
|
Instruction inst = instructionService.findByCodeFromCache(taskId);
|
||||||
|
if (ObjectUtil.isEmpty(inst)) {
|
||||||
|
throw new BadRequestException("请求失败,未找到指令!");
|
||||||
|
}
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
jo.put("TaskNo", taskId);
|
||||||
|
if ("任务11" .equals(inst.getInstruction_type())) {
|
||||||
|
//todo :需要跟上位申请新的点位
|
||||||
|
JSONObject json1 = new JSONObject();
|
||||||
|
json1.put("Name", "point1");
|
||||||
|
json1.put("Value", "3");
|
||||||
|
arr.add(json1);
|
||||||
|
} else if ("任务12" .equals(inst.getInstruction_type())) {
|
||||||
|
//todo :需要跟上位申请新的点位
|
||||||
|
JSONObject json1 = new JSONObject();
|
||||||
|
json1.put("Name", "point2");
|
||||||
|
json1.put("Value", "4");
|
||||||
|
arr.add(json1);
|
||||||
|
} else if ("任务13" .equals(inst.getInstruction_type())) {
|
||||||
|
if ("1" .equals(type)) {
|
||||||
|
//todo :需要跟上位申请新的点位
|
||||||
|
JSONObject json1 = new JSONObject();
|
||||||
|
json1.put("Name", "point1");
|
||||||
|
json1.put("Value", "1");
|
||||||
|
arr.add(json1);
|
||||||
|
} else if ("2" .equals(type)) {
|
||||||
|
//todo :需要跟上位申请新的点位
|
||||||
|
JSONObject json1 = new JSONObject();
|
||||||
|
json1.put("Name", "point2");
|
||||||
|
json1.put("Value", "1");
|
||||||
|
arr.add(json1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("任务11" .equals(inst.getInstruction_type())) {
|
||||||
|
JSONObject json2 = new JSONObject();
|
||||||
|
json2.put("Name", "isget");
|
||||||
|
json2.put("Value", "1");
|
||||||
|
arr.add(json2);
|
||||||
|
} else if ("任务12" .equals(inst.getInstruction_type())) {
|
||||||
|
JSONObject json2 = new JSONObject();
|
||||||
|
json2.put("Name", "isput");
|
||||||
|
json2.put("Value", "1");
|
||||||
|
arr.add(json2);
|
||||||
|
} else if ("任务13" .equals(inst.getInstruction_type())) {
|
||||||
|
if ("1" .equals(type)) {
|
||||||
|
JSONObject json3 = new JSONObject();
|
||||||
|
json3.put("Name", "isget");
|
||||||
|
json3.put("Value", "1");
|
||||||
|
arr.add(json3);
|
||||||
|
} else if ("2" .equals(type)) {
|
||||||
|
JSONObject json2 = new JSONObject();
|
||||||
|
json2.put("Name", "isput");
|
||||||
|
json2.put("Value", "1");
|
||||||
|
arr.add(json2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jo.put("Params", arr);
|
||||||
|
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
|
|
||||||
|
//更新任务参数
|
||||||
|
agvurl = agvurl + ":" + agvport + "/api/fms/updateTaskParam";
|
||||||
|
|
||||||
|
log.info(agvurl);
|
||||||
|
HttpResponse result = HttpRequest.post(agvurl)
|
||||||
|
//表单内容
|
||||||
|
.body(String.valueOf(jo))
|
||||||
|
//超时,毫秒
|
||||||
|
.timeout(20000)
|
||||||
|
.execute();
|
||||||
|
LuceneLogDto logDto1 = LuceneLogDto.builder()
|
||||||
|
.device_code("下发科聪任务")
|
||||||
|
.content("任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + ",下发科聪任务序列反馈参数:" + jo)
|
||||||
|
.build();
|
||||||
|
logDto1.setLog_level(4);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
||||||
|
log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body());
|
||||||
|
JSONObject jsonObject = null;
|
||||||
|
if (ObjectUtil.isNotEmpty(result)) {
|
||||||
|
String body = result.body();
|
||||||
|
jsonObject = JSONObject.parseObject(body);
|
||||||
|
if (ObjectUtil.isNotNull(jsonObject) && "true" .equals(jsonObject.getString("Result"))) {
|
||||||
|
AgvResponse agvResponse = new AgvResponse();
|
||||||
|
agvResponse.setResult("true");
|
||||||
|
agvResponse.setErrMsg("");
|
||||||
|
return agvResponse;
|
||||||
|
} else {
|
||||||
|
AgvResponse agvResponse = new AgvResponse();
|
||||||
|
agvResponse.setResult("false");
|
||||||
|
agvResponse.setErrMsg("");
|
||||||
|
return agvResponse;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AgvResponse agvResponse = new AgvResponse();
|
||||||
|
agvResponse.setResult("false");
|
||||||
|
agvResponse.setErrMsg("");
|
||||||
|
return agvResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AgvResponse updateKZAgvInst(JSONObject requestParam) {
|
||||||
|
// JSONObject ja = new JSONObject();
|
||||||
|
// ja.put("Key","Result");
|
||||||
|
// ja.put("Value","true");
|
||||||
|
|
||||||
|
AgvResponse agvResponse = new AgvResponse();
|
||||||
|
agvResponse.setResult("true");
|
||||||
|
agvResponse.setErrMsg("");
|
||||||
|
return agvResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AgvResponse requestResource(JSONObject requestParam) {
|
||||||
|
//todo: 延迟十秒
|
||||||
|
AgvResponse agvResponse = new AgvResponse();
|
||||||
|
agvResponse.setResult("true");
|
||||||
|
agvResponse.setErrMsg("请求失败");
|
||||||
|
return agvResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AgvResponse releaseResource(JSONObject requestParam) {
|
||||||
|
AgvResponse agvResponse = new AgvResponse();
|
||||||
|
agvResponse.setResult("true");
|
||||||
|
agvResponse.setErrMsg("请求失败");
|
||||||
|
return agvResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResponse getRobotInfo(String robotCode) {
|
||||||
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||||
|
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
|
|
||||||
|
agvurl = agvurl + ":" + agvport + "/" + "robotsStatus?vehicles=" + robotCode;
|
||||||
|
log.info("根据指定机器人查询状态的请求:{}", agvurl);
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("VehicleNo", robotCode);
|
||||||
|
HttpResponse result = HttpRequest.get(agvurl)
|
||||||
|
.body(String.valueOf(param))
|
||||||
|
.timeout(20000)//超时,毫秒
|
||||||
|
.execute();
|
||||||
|
log.info("根据指定机器人查询状态的请求反馈:{}", result);
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public JSONObject updateKZAgvInstStatus(String instCode) {
|
||||||
|
// if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
|
||||||
|
// String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
// String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||||
|
//
|
||||||
|
// agvurl = agvurl + ":" + agvport + "/api/fms/updateTaskParam";
|
||||||
|
//
|
||||||
|
// HttpResponse result = HttpRequest.get(agvurl)
|
||||||
|
// //超时,毫秒
|
||||||
|
// .timeout(20000)
|
||||||
|
// .execute();
|
||||||
|
// System.out.println("查询agv数据:" + result.body());
|
||||||
|
//
|
||||||
|
// return result;
|
||||||
|
// } else {
|
||||||
|
//
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.nl.acs.device_driver.agv.kc_agv;
|
||||||
|
|
||||||
|
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.DeviceDriverDefination;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class KcagvDefination implements DeviceDriverDefination {
|
||||||
|
@Override
|
||||||
|
public String getDriverCode() {
|
||||||
|
return "kc_agv";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverName() {
|
||||||
|
return "科聪AGV车";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDriverDescription() {
|
||||||
|
return "科聪AGV车";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceDriver getDriverInstance(Device device) {
|
||||||
|
return (new KcagvDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||||
|
return KcagvDeviceDriver.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceType> getFitDeviceTypes() {
|
||||||
|
List<DeviceType> types = new LinkedList();
|
||||||
|
types.add(DeviceType.agv);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
package org.nl.acs.device_driver.agv.kc_agv;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
|
import org.nl.acs.common.base.CommonFinalParam;
|
||||||
|
import org.nl.acs.device.service.DeviceService;
|
||||||
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||||
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||||
|
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.route.service.RouteLineService;
|
||||||
|
import org.nl.acs.task.service.TaskService;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class KcagvDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||||
|
@Autowired
|
||||||
|
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
|
@Autowired
|
||||||
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||||
|
@Autowired
|
||||||
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||||
|
@Autowired
|
||||||
|
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
|
|
||||||
|
Integer hasGoods = 0;
|
||||||
|
int error = 0;
|
||||||
|
Boolean iserror = false;
|
||||||
|
Boolean islock = false;
|
||||||
|
|
||||||
|
int branchProtocol = 0;
|
||||||
|
int last_branchProtocol = 0;
|
||||||
|
/**
|
||||||
|
* 是否需要输入物料
|
||||||
|
*/
|
||||||
|
String input_material = "0";
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
String remark = "";
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
String qty = "";
|
||||||
|
/**
|
||||||
|
* 批次
|
||||||
|
*/
|
||||||
|
String batch = "";
|
||||||
|
/**
|
||||||
|
* 物料
|
||||||
|
*/
|
||||||
|
String material = "";
|
||||||
|
/**
|
||||||
|
* 目标点位
|
||||||
|
*/
|
||||||
|
String purpose = "";
|
||||||
|
/**
|
||||||
|
* 当前指令
|
||||||
|
*/
|
||||||
|
Instruction inst = null;
|
||||||
|
/**
|
||||||
|
* 上次指令
|
||||||
|
*/
|
||||||
|
Instruction last_inst = null;
|
||||||
|
|
||||||
|
boolean requireSucess = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 触摸屏手动触发任务
|
||||||
|
*/
|
||||||
|
private Boolean is_has_task = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请搬运任务
|
||||||
|
*/
|
||||||
|
private Boolean apply_handling = false;
|
||||||
|
/**
|
||||||
|
* 申请物料
|
||||||
|
*/
|
||||||
|
private Boolean apply_material = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1取货完成 2放货完成 3进入区域 4离开区域
|
||||||
|
*/
|
||||||
|
private int flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
|
||||||
|
*/
|
||||||
|
private int manua_confirm = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
|
||||||
|
*/
|
||||||
|
private String upload_scene_status = "";
|
||||||
|
/**
|
||||||
|
* 机器人当前运单
|
||||||
|
*/
|
||||||
|
private String current_order = "";
|
||||||
|
/**
|
||||||
|
* 机器人连接状态 0表示断连 1表示连接上
|
||||||
|
*/
|
||||||
|
private String connection_status = "";
|
||||||
|
/**
|
||||||
|
* 机器人可接单状态 true=可接单 false=不可接单
|
||||||
|
*/
|
||||||
|
private boolean dispatchable = false;
|
||||||
|
/**
|
||||||
|
* core出错标识
|
||||||
|
*/
|
||||||
|
private boolean is_error = false;
|
||||||
|
/**
|
||||||
|
* 是否正在执行用户下发的运单
|
||||||
|
*/
|
||||||
|
private boolean procBusiness = false;
|
||||||
|
/**
|
||||||
|
* 机器人当前地图不在场景中
|
||||||
|
*/
|
||||||
|
private boolean current_map_invalid = false;
|
||||||
|
/**
|
||||||
|
* 机器人是否断连
|
||||||
|
*/
|
||||||
|
private boolean disconnect = false;
|
||||||
|
/**
|
||||||
|
* 1 = api 设置可接单,2 = api 设置不可接单(小车占用资源), 3 = api 设置不可接单(小车不占用资源)
|
||||||
|
*/
|
||||||
|
private int dispatchable_status = 0;
|
||||||
|
/**
|
||||||
|
* 低电量
|
||||||
|
*/
|
||||||
|
private boolean low_battery = false;
|
||||||
|
/**
|
||||||
|
* 暂停运单
|
||||||
|
*/
|
||||||
|
private boolean suspended = false;
|
||||||
|
/**
|
||||||
|
* 未确认定位
|
||||||
|
*/
|
||||||
|
private boolean unconfirmed_reloc = false;
|
||||||
|
/**
|
||||||
|
* 0: 控制权在core手上 1; 控制权被其他人抢走; 2: 控制权没有被抢占
|
||||||
|
*/
|
||||||
|
private int unlock = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* agv二次分配类型(1、普通任务 2、取货二次分配 3、防货二次分配 4、取放货二次分配)
|
||||||
|
*/
|
||||||
|
private String taskType = "";
|
||||||
|
|
||||||
|
|
||||||
|
String device_code = null;
|
||||||
|
String container;
|
||||||
|
String container_type_desc;
|
||||||
|
String last_container_type_desc;
|
||||||
|
String last_container;
|
||||||
|
private Date instruction_require_time = new Date();
|
||||||
|
private Date instruction_finished_time = new Date();
|
||||||
|
|
||||||
|
private int instruction_require_time_out;
|
||||||
|
|
||||||
|
String message;
|
||||||
|
|
||||||
|
// 1 上位系统允许进入 2 上位系统允许离开
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
int agvphase = 0;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
int mode = 2;
|
||||||
|
|
||||||
|
int move;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
// getAgvStatus();
|
||||||
|
} catch (Exception e) {
|
||||||
|
message = "获取机器人状态报错";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getDeviceStatusName() {
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
// try {
|
||||||
|
// getAgvStatus();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// message = "获取机器人状态报错";
|
||||||
|
// }
|
||||||
|
String isError;
|
||||||
|
if (is_error) {
|
||||||
|
isError = "出错,不执行任何运单";
|
||||||
|
} else {
|
||||||
|
isError = "正常";
|
||||||
|
}
|
||||||
|
if (CommonFinalParam.ONE.equals(upload_scene_status)) {
|
||||||
|
upload_scene_status = "正在更新场景";
|
||||||
|
} else if (CommonFinalParam.TWO.equals(upload_scene_status)) {
|
||||||
|
upload_scene_status = "正在执行运单";
|
||||||
|
} else if (CommonFinalParam.DELETE.equals(upload_scene_status)) {
|
||||||
|
upload_scene_status = "可推送";
|
||||||
|
}
|
||||||
|
map.put("errors", isError);
|
||||||
|
map.put("upload_scene_status", upload_scene_status);
|
||||||
|
map.put("procBusiness", procBusiness ? "是": "否");
|
||||||
|
// map.put("current_order", current_order);
|
||||||
|
map.put("connection_status", "1".equals(connection_status) ? "连接上" : "断连");
|
||||||
|
map.put("dispatchable", dispatchable ? "可接单" : "不可接单");
|
||||||
|
map.put("dispatchable_status", dispatchable_status == 1?"设置可接单" : dispatchable_status == 2?"设置不可接单(小车占用资源)" : dispatchable_status == 3?"设置不可接单(小车不占用资源)" : "未知");
|
||||||
|
map.put("current_map_invalid", current_map_invalid ? "机器人不在地图场景中": "机器人在地图场景中");
|
||||||
|
map.put("disconnect", disconnect ? "机器人断连" : "机器人连接上");
|
||||||
|
map.put("low_battery", low_battery ? "低电量": "正常");
|
||||||
|
map.put("suspended", suspended ? "订单被暂停,需要人工手动恢复": "正常");
|
||||||
|
map.put("message", message);
|
||||||
|
map.put("agv_task_type", taskType);
|
||||||
|
map.put("unconfirmed_reloc", unconfirmed_reloc ? "未确认定位" : "正常");
|
||||||
|
map.put("unlock", unlock == 0 ? "控制权在core手上" : unlock == 1 ? "控制权被其他人抢走" : unlock == 2 ? "控制权没有被抢占" : "未知");
|
||||||
|
map.put("move_2","有货");
|
||||||
|
JSONObject jo = new JSONObject(map);
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDeviceStatus(JSONObject data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.nl.acs.AcsConfig;
|
import org.nl.acs.AcsConfig;
|
||||||
|
import org.nl.acs.agv.server.KeCongAgvService;
|
||||||
import org.nl.acs.agv.server.MagicAgvService;
|
import org.nl.acs.agv.server.MagicAgvService;
|
||||||
import org.nl.acs.agv.server.NDCAgvService;
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
import org.nl.acs.agv.server.XianGongAgvService;
|
import org.nl.acs.agv.server.XianGongAgvService;
|
||||||
@@ -121,6 +122,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
private LimitRegionalService limitRegionalService;
|
private LimitRegionalService limitRegionalService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private LuceneExecuteLogService luceneExecuteLogService;
|
private LuceneExecuteLogService luceneExecuteLogService;
|
||||||
|
@Autowired
|
||||||
|
private KeCongAgvService keCongAgvService;
|
||||||
|
|
||||||
private List<Instruction> instructions = new CopyOnWriteArrayList();
|
private List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||||
|
|
||||||
@@ -456,37 +459,24 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
||||||
}
|
}
|
||||||
if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
// if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
||||||
throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型");
|
// throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型");
|
||||||
}
|
// }
|
||||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||||
}
|
}
|
||||||
//判断是否是仙工AGV
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "5")) {
|
||||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
|
HttpResponse response = keCongAgvService.addTask(dto);
|
||||||
|
JSONObject jsonObject = null;
|
||||||
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
|
if (ObjectUtil.isNotEmpty(response)) {
|
||||||
String interactionJson = task.getInteraction_json();
|
String body = response.body();
|
||||||
if (StrUtil.isEmpty(interactionJson)) {
|
jsonObject = JSONObject.parseObject(body);
|
||||||
throw new BadRequestException("agv叉车调整长宽参数为空");
|
}
|
||||||
}
|
if (ObjectUtil.isNotNull(jsonObject) && "true" .equals(jsonObject.getString("Result"))) {
|
||||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
dto.setSend_status("1");
|
||||||
//仙工叉车
|
} else {
|
||||||
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto, interactionJsonDTO);
|
dto.setSend_status("2");
|
||||||
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
|
|
||||||
dto.setSend_status("2");
|
|
||||||
} else {
|
|
||||||
dto.setSend_status("1");
|
|
||||||
}
|
|
||||||
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
|
|
||||||
//一楼agv任务创建运单序列
|
|
||||||
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto);
|
|
||||||
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
|
|
||||||
dto.setSend_status("2");
|
|
||||||
} else {
|
|
||||||
dto.setSend_status("1");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -620,47 +610,17 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//判断是否是仙工AGV
|
//判断是否是仙工AGV
|
||||||
if (shortPathsList.size() > 0 && StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "5")) {
|
||||||
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getStart_device_code());
|
HttpResponse response = keCongAgvService.addTask(dto);
|
||||||
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
|
JSONObject jsonObject = null;
|
||||||
String interactionJson = task.getInteraction_json();
|
if(ObjectUtil.isNotEmpty(response)){
|
||||||
if (StrUtil.isEmpty(interactionJson)) {
|
String body = response.body();
|
||||||
throw new BadRequestException("agv叉车调整长宽参数为空");
|
jsonObject = JSONObject.parseObject(body);
|
||||||
}
|
}
|
||||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
if (ObjectUtil.isNotNull(jsonObject) && "true".equals(jsonObject.getString("Result"))) {
|
||||||
//仙工叉车
|
dto.setSend_status("1");
|
||||||
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto, interactionJsonDTO);
|
} else {
|
||||||
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
|
dto.setSend_status("2");
|
||||||
dto.setSend_status("2");
|
|
||||||
} else {
|
|
||||||
dto.setSend_status("1");
|
|
||||||
}
|
|
||||||
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
|
|
||||||
//一楼agv任务创建运单序列
|
|
||||||
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto);
|
|
||||||
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
|
|
||||||
dto.setSend_status("2");
|
|
||||||
} else {
|
|
||||||
dto.setSend_status("1");
|
|
||||||
}
|
|
||||||
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex())) {
|
|
||||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
|
||||||
log.warn("下发AGV指令数据," + "指令号:" + dto.getInstruction_code() + ",AGV系统类型:" + dto.getAgv_system_type());
|
|
||||||
try {
|
|
||||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
|
||||||
dto.setSend_status("1");
|
|
||||||
} catch (Exception e) {
|
|
||||||
dto.setSend_status("2");
|
|
||||||
dto.setRemark(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
log.warn("下发AGV指令异常:" + e);
|
|
||||||
LuceneLogDto logDto1 = LuceneLogDto.builder()
|
|
||||||
.device_code(start_device_code)
|
|
||||||
.content("下发AGV指令异常")
|
|
||||||
.build();
|
|
||||||
logDto1.setLog_level(4);
|
|
||||||
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -101,47 +101,47 @@ public class AutoCreateInst {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//校验路由关系
|
//校验路由关系
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
// List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
// if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
acsTask.setRemark("路由不通无法生成指令");
|
// acsTask.setRemark("路由不通无法生成指令");
|
||||||
taskserver.updateByCodeFromCache(acsTask);
|
// taskserver.updateByCodeFromCache(acsTask);
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
// RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||||
continue;
|
// String path = routeLineDto.getPath();
|
||||||
}
|
// String type = routeLineDto.getType();
|
||||||
|
// String[] str = path.split("->");
|
||||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
// List<String> pathlist = Arrays.asList(str);
|
||||||
String path = routeLineDto.getPath();
|
// int index = 0;
|
||||||
String type = routeLineDto.getType();
|
// boolean flag = false;
|
||||||
String[] str = path.split("->");
|
// for (int m = 0; m < pathlist.size(); m++) {
|
||||||
List<String> pathlist = Arrays.asList(str);
|
// if (pathlist.get(m).equals(start_device_code)) {
|
||||||
int index = 0;
|
// if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
|
||||||
boolean flag = false;
|
// flag = true;
|
||||||
for (int m = 0; m < pathlist.size(); m++) {
|
// break;
|
||||||
if (pathlist.get(m).equals(start_device_code)) {
|
// }
|
||||||
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
|
// index = m + 1;
|
||||||
flag = true;
|
// break;
|
||||||
break;
|
// }
|
||||||
}
|
// }
|
||||||
index = m + 1;
|
// if (flag) {
|
||||||
break;
|
// acsTask.setRemark("路由不通无法生成指令");
|
||||||
}
|
// taskserver.update(acsTask);
|
||||||
}
|
// taskserver.updateByCodeFromCache(acsTask);
|
||||||
if (flag) {
|
// continue;
|
||||||
acsTask.setRemark("路由不通无法生成指令");
|
// }
|
||||||
taskserver.update(acsTask);
|
// next_device_code = pathlist.get(index);
|
||||||
taskserver.updateByCodeFromCache(acsTask);
|
//
|
||||||
continue;
|
// if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||||
}
|
// next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
||||||
next_device_code = pathlist.get(index);
|
// } else {
|
||||||
|
// next_point_code = next_device_code;
|
||||||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
// }
|
||||||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
|
||||||
} else {
|
|
||||||
next_point_code = next_device_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Instruction instdto = new Instruction();
|
Instruction instdto = new Instruction();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ spring:
|
|||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:ynfj_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:ynfj_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||||
|
|
||||||
username: ${DB_USER:root}
|
username: ${DB_USER:root}
|
||||||
# password: ${DB_PWD:Root.123456}
|
# password: ${DB_PWD:Root.123456}
|
||||||
@@ -76,7 +76,7 @@ spring:
|
|||||||
redis:
|
redis:
|
||||||
#数据库索引
|
#数据库索引
|
||||||
database: ${REDIS_DB:2}
|
database: ${REDIS_DB:2}
|
||||||
host: ${REDIS_HOST:127.0.0.1}
|
host: ${REDIS_HOST:localhost}
|
||||||
port: ${REDIS_PORT:6379}
|
port: ${REDIS_PORT:6379}
|
||||||
# password: ${REDIS_PWD:}
|
# password: ${REDIS_PWD:}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ import belt_conveyor from '@/views/acs/device/driver/belt_conveyor'
|
|||||||
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one'
|
import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one'
|
||||||
import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
|
import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two'
|
||||||
import xg_agv from '@/views/acs/device/driver/agv/xg_agv'
|
import xg_agv from '@/views/acs/device/driver/agv/xg_agv'
|
||||||
|
import kc_agv from '@/views/acs/device/driver/agv/kc_agv'
|
||||||
import xg_agv_car from '@/views/acs/device/driver/agv/xg_agv_car.vue'
|
import xg_agv_car from '@/views/acs/device/driver/agv/xg_agv_car.vue'
|
||||||
import standard_manipulator from '@/views/acs/device/driver/one_manipulator/standard_manipulator.vue'
|
import standard_manipulator from '@/views/acs/device/driver/one_manipulator/standard_manipulator.vue'
|
||||||
import standard_storage from '@/views/acs/device/driver/standard_storage'
|
import standard_storage from '@/views/acs/device/driver/standard_storage'
|
||||||
@@ -95,7 +96,8 @@ export default {
|
|||||||
belt_conveyor,
|
belt_conveyor,
|
||||||
standard_manipulator,
|
standard_manipulator,
|
||||||
xg_agv_car,
|
xg_agv_car,
|
||||||
standard_storage
|
standard_storage,
|
||||||
|
kc_agv
|
||||||
},
|
},
|
||||||
dicts: ['device_type'],
|
dicts: ['device_type'],
|
||||||
mixins: [crud],
|
mixins: [crud],
|
||||||
|
|||||||
423
acs2/nladmin-ui/src/views/acs/device/driver/agv/kc_agv.vue
Normal file
423
acs2/nladmin-ui/src/views/acs/device/driver/agv/kc_agv.vue
Normal file
@@ -0,0 +1,423 @@
|
|||||||
|
<template>
|
||||||
|
<!--自动门-->
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<el-card class="box-card" shadow="never">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span class="role-span">设备协议:</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
OpcServer:
|
||||||
|
<el-select
|
||||||
|
v-model="opc_id"
|
||||||
|
placeholder="无"
|
||||||
|
clearable
|
||||||
|
@change="changeOpc"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in dataOpcservers"
|
||||||
|
:key="item.opc_id"
|
||||||
|
:label="item.opc_name"
|
||||||
|
:value="item.opc_id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
PLC:
|
||||||
|
<el-select
|
||||||
|
v-model="plc_id"
|
||||||
|
placeholder="无"
|
||||||
|
clearable
|
||||||
|
@change="changePlc"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in dataOpcPlcs"
|
||||||
|
:key="item.plc_id"
|
||||||
|
:label="item.plc_name"
|
||||||
|
:value="item.plc_id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card class="box-card" shadow="never">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span class="role-span">输送系统:</span>
|
||||||
|
</div>
|
||||||
|
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="车辆ip" label-width="150px">
|
||||||
|
<el-input v-model="form.agv_ip" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="休息点" prop="next_point_code" label-width="150px">
|
||||||
|
<el-select
|
||||||
|
v-model="form.relax_point"
|
||||||
|
style="width: 190px;"
|
||||||
|
filterable
|
||||||
|
placeholder="请选择"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in deviceList"
|
||||||
|
:key="item.device_code"
|
||||||
|
:label="item.device_code"
|
||||||
|
:value="item.device_code"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="充电点" prop="charge_point" label-width="150px">
|
||||||
|
<el-select
|
||||||
|
v-model="form.charge_point"
|
||||||
|
style="width: 190px;"
|
||||||
|
filterable
|
||||||
|
placeholder="请选择"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in deviceList"
|
||||||
|
:key="item.device_code"
|
||||||
|
:label="item.device_code"
|
||||||
|
:value="item.device_code"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="最小电量" label-width="150px">
|
||||||
|
<el-input v-model="form.min_electric" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="最大电量" label-width="150px">
|
||||||
|
<el-input v-model="form.cancle_electric" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="可执行任务电量" label-width="150px">
|
||||||
|
<el-input v-model="form.task_electric" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- <el-card class="box-card" shadow="never">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span class="role-span">PLC读取字段:</span>
|
||||||
|
</div>
|
||||||
|
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||||
|
<el-table
|
||||||
|
v-loading="false"
|
||||||
|
:data="data1"
|
||||||
|
:max-height="550"
|
||||||
|
size="small"
|
||||||
|
style="width: 100%;margin-bottom: 15px"
|
||||||
|
>
|
||||||
|
|
||||||
|
<el-table-column prop="name" label="用途" />
|
||||||
|
<el-table-column prop="code" label="别名要求" />
|
||||||
|
<el-table-column prop="db" label="DB块">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input
|
||||||
|
v-model="data1[scope.$index].db"
|
||||||
|
size="mini"
|
||||||
|
class="edit-input"
|
||||||
|
@input="finishReadEdit(data1[scope.$index])"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="dbr_value">
|
||||||
|
<template slot="header">
|
||||||
|
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
|
||||||
|
</template>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-form>
|
||||||
|
</el-card> -->
|
||||||
|
|
||||||
|
<!-- <el-card class="box-card" shadow="never">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span class="role-span">PLC写入字段:</span>
|
||||||
|
</div>
|
||||||
|
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
|
||||||
|
<el-table
|
||||||
|
v-loading="false"
|
||||||
|
:data="data2"
|
||||||
|
:max-height="550"
|
||||||
|
size="small"
|
||||||
|
style="width: 100%;margin-bottom: 15px"
|
||||||
|
>
|
||||||
|
|
||||||
|
<el-table-column prop="name" label="用途" />
|
||||||
|
<el-table-column prop="code" label="别名要求" />
|
||||||
|
<el-table-column prop="db" label="DB块">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input
|
||||||
|
v-model="data2[scope.$index].db"
|
||||||
|
size="mini"
|
||||||
|
class="edit-input"
|
||||||
|
@input="finishWriteEdit(data2[scope.$index])"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="dbr_value2">
|
||||||
|
<template slot="header">
|
||||||
|
<el-link type="primary" :underline="false" @click.native="test_read2()">测试读</el-link>
|
||||||
|
</template>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input v-model="data2[scope.$index].dbr_value" size="mini" class="edit-input" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="dbw_value">
|
||||||
|
<template slot="header">
|
||||||
|
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
|
||||||
|
</template>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-form>
|
||||||
|
</el-card> -->
|
||||||
|
|
||||||
|
<el-card class="box-card" shadow="never">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span class="role-span" />
|
||||||
|
<el-button
|
||||||
|
:loading="false"
|
||||||
|
icon="el-icon-check"
|
||||||
|
size="mini"
|
||||||
|
style="float: right; padding: 6px 9px"
|
||||||
|
type="primary"
|
||||||
|
@click="doSubmit"
|
||||||
|
>保存
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
queryDriverConfig,
|
||||||
|
updateConfig,
|
||||||
|
testRead,
|
||||||
|
testwrite
|
||||||
|
} from '@/api/acs/device/driverConfig'
|
||||||
|
import { selectOpcList } from '@/api/acs/device/opc'
|
||||||
|
import { selectPlcList } from '@/api/acs/device/opcPlc'
|
||||||
|
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
|
||||||
|
import crud from '@/mixins/crud'
|
||||||
|
import deviceCrud from '@/api/acs/device/device'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'StandardAutodoor',
|
||||||
|
mixins: [crud],
|
||||||
|
props: {
|
||||||
|
parentForm: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
device_code: '',
|
||||||
|
device_id: '',
|
||||||
|
plc_id: '',
|
||||||
|
plc_code: '',
|
||||||
|
opc_id: '',
|
||||||
|
opc_code: '',
|
||||||
|
configLoading: false,
|
||||||
|
dataOpcservers: [],
|
||||||
|
dataOpcPlcs: [],
|
||||||
|
data1: [],
|
||||||
|
data2: [],
|
||||||
|
form: {
|
||||||
|
inspect_in_stocck: true,
|
||||||
|
ignore_pickup_check: true,
|
||||||
|
ignore_release_check: true,
|
||||||
|
apply_task: true,
|
||||||
|
manual_create_task: true,
|
||||||
|
is_pickup: true,
|
||||||
|
is_release: true
|
||||||
|
},
|
||||||
|
rules: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
// 从父表单获取设备编码
|
||||||
|
this.device_id = this.$props.parentForm.device_id
|
||||||
|
this.device_code = this.$props.parentForm.device_code
|
||||||
|
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||||
|
// 给表单赋值,并且属性不能为空
|
||||||
|
if (data.form) {
|
||||||
|
const arr = Object.keys(data.form)
|
||||||
|
// 不为空
|
||||||
|
if (arr.length > 0) {
|
||||||
|
this.form = data.form
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 给表单赋值,并且属性不能为空
|
||||||
|
if (data.parentForm) {
|
||||||
|
const arr = Object.keys(data.parentForm)
|
||||||
|
// 不为空
|
||||||
|
if (arr.length > 0) {
|
||||||
|
this.opc_code = data.parentForm.opc_code
|
||||||
|
this.plc_code = data.parentForm.plc_code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.data1 = data.rs
|
||||||
|
this.data2 = data.ws
|
||||||
|
this.sliceItem()
|
||||||
|
})
|
||||||
|
selectPlcList().then(data => {
|
||||||
|
this.dataOpcPlcs = data
|
||||||
|
this.plc_id = this.$props.parentForm.opc_plc_id
|
||||||
|
})
|
||||||
|
selectOpcList().then(data => {
|
||||||
|
this.dataOpcservers = data
|
||||||
|
this.opc_id = this.$props.parentForm.opc_server_id
|
||||||
|
})
|
||||||
|
deviceCrud.selectDeviceList().then(data => {
|
||||||
|
this.deviceList = data
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
changeOpc(val) {
|
||||||
|
this.dataOpcservers.forEach(item => {
|
||||||
|
if (item.opc_id === val) {
|
||||||
|
this.opc_code = item.opc_code
|
||||||
|
}
|
||||||
|
})
|
||||||
|
selectListByOpcID(val).then(data => {
|
||||||
|
this.dataOpcPlcs = data
|
||||||
|
this.plc_id = ''
|
||||||
|
this.plc_code = ''
|
||||||
|
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
|
||||||
|
this.plc_id = this.dataOpcPlcs[0].plc_id
|
||||||
|
this.plc_code = this.dataOpcPlcs[0].plc_code
|
||||||
|
}
|
||||||
|
this.sliceItem()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
finishReadEdit(data) {
|
||||||
|
// 编辑的是code列,并且值包含mode
|
||||||
|
if (data.code.indexOf('mode') !== -1) {
|
||||||
|
const dbValue = data.db
|
||||||
|
// .之前的字符串
|
||||||
|
const beforeStr = dbValue.match(/(\S*)\./)[1]
|
||||||
|
// .之后的字符串
|
||||||
|
const afterStr = dbValue.match(/\.(\S*)/)[1]
|
||||||
|
// 取最后数字
|
||||||
|
const endNumber = afterStr.substring(1)
|
||||||
|
// 最后为非数字
|
||||||
|
if (isNaN(parseInt(endNumber))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (const val in this.data1) {
|
||||||
|
if (this.data1[val].code.indexOf('action') !== -1) {
|
||||||
|
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
|
||||||
|
}
|
||||||
|
if (this.data1[val].code.indexOf('error') !== -1) {
|
||||||
|
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changePlc(val) {
|
||||||
|
this.dataOpcPlcs.forEach(item => {
|
||||||
|
if (item.plc_id === val) {
|
||||||
|
this.plc_code = item.plc_code
|
||||||
|
this.sliceItem()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
test_read1() {
|
||||||
|
testRead(this.data1, this.opc_id).then(data => {
|
||||||
|
this.data1 = data
|
||||||
|
this.notify('操作成功!', 'success')
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err.response.data.message)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
test_read2() {
|
||||||
|
testRead(this.data2, this.opc_id).then(data => {
|
||||||
|
this.data2 = data
|
||||||
|
console.log(this.data2)
|
||||||
|
this.notify('操作成功!', 'success')
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err.response.data.message)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
test_write1() {
|
||||||
|
testwrite(this.data2, this.opc_id).then(data => {
|
||||||
|
this.notify('操作成功!', 'success')
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err.response.data.message)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
doSubmit() {
|
||||||
|
this.$refs['form'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.configLoading = true
|
||||||
|
// 根据驱动类型判断是否为路由设备
|
||||||
|
const parentForm = this.parentForm
|
||||||
|
parentForm.is_route = true
|
||||||
|
parentForm.plc_id = this.plc_id
|
||||||
|
parentForm.opc_id = this.opc_id
|
||||||
|
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
|
||||||
|
this.notify('保存成功', 'success')
|
||||||
|
this.configLoading = false
|
||||||
|
}).catch(err => {
|
||||||
|
this.configLoading = false
|
||||||
|
console.log(err.response.data.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
sliceItem() { // 拼接DB的Item值
|
||||||
|
this.data1.forEach(item => {
|
||||||
|
const str = item.code
|
||||||
|
// 是否包含.
|
||||||
|
if (str.search('.') !== -1) {
|
||||||
|
// 截取最后一位
|
||||||
|
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||||
|
} else {
|
||||||
|
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.data2.forEach(item => {
|
||||||
|
const str = item.code
|
||||||
|
// 是否包含.
|
||||||
|
if (str.search('.') !== -1) {
|
||||||
|
// 截取最后一位
|
||||||
|
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
|
||||||
|
} else {
|
||||||
|
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user