diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index 5f6fad9..9093448 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -151,10 +151,10 @@ - - org.springframework.boot - spring-boot-starter-websocket - + + org.springframework.boot + spring-boot-starter-websocket + @@ -180,16 +180,16 @@ - - ch.ethz.ganymed - ganymed-ssh2 - build210 - - - com.jcraft - jsch - 0.1.55 - + + ch.ethz.ganymed + ganymed-ssh2 + build210 + + + com.jcraft + jsch + 0.1.55 + @@ -347,16 +347,16 @@ - - - - - - - - - - + + + + + + + + + + xerces xercesImpl diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/rest/XianGongAgvController.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/rest/XianGongAgvController.java index 1542462..bd51ec6 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/rest/XianGongAgvController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/rest/XianGongAgvController.java @@ -1,5 +1,8 @@ package org.nl.acs.agv.rest; + +import cn.dev33.satoken.annotation.SaIgnore; +import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; @@ -22,14 +27,12 @@ import javax.servlet.http.HttpServletRequest; public class XianGongAgvController { @Autowired XianGongAgvService xianGongAgvService; - @GetMapping("/waitPointRequest") - @Log("agv等待点请求") - @ApiOperation("下发agv任务") - //@PreAuthorize("@el.check('routePlan:list')") - public ResponseEntity waitPointRequest(HttpServletRequest req) throws Exception { - String serviceName = req.getRequestURI(); - String param = StringUtils.substringAfterLast(serviceName, "/"); - return new ResponseEntity<>(xianGongAgvService.waitPointRequest(param), HttpStatus.OK); + @PostMapping("/api/agv/xg/waitPointRequest") + @Log("仙工AGV请求取放货") + @ApiOperation("仙工AGV请求取放货") + @SaIgnore + public ResponseEntity xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) { + return new ResponseEntity<>(xianGongAgvService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/XianGongAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/XianGongAgvService.java index 950d49d..7dd853f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/XianGongAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/XianGongAgvService.java @@ -28,7 +28,7 @@ public interface XianGongAgvService { * @param * @return */ - public String waitPointRequest(String param); + JSONObject xgAGVWaitPointRequest(JSONObject requestParam); /** * acs->agv diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java index eff539d..5beb551 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java @@ -57,34 +57,116 @@ public class AgvDto implements Serializable { /** * 角度 */ - private String positionAngle; + private float positionAngle; /** * X坐标 */ - private String positionX; + private float positionX; /** * Y坐标 */ - private String positionY; + private float positionY; /** * 当前任务号 */ private String transportOrder; + + /** + * 电池温度 + */ + private String battery_temp; + + /** + * 电池电量 + */ + private float battery_level; + + /** + * 是否阻挡 + */ + private String blocked; + + /** + * 是否刹车 + */ + private String brake; + + /** + * 是否充电 + */ + private Boolean charging; + + /** + * 机器人连接状态,0表示断连,1表示连接上 + */ + private Integer connection_status; + + /** + * 控制器温度 + */ + private String controller_temp; + + /** + * 当前地图 + */ + private String current_map; + /** - * 状态码 + * 当前位置 */ - private Integer status; + private String current_station; + /** - * 状态描述 + * 急停 */ - private String statusDescription; + private String emergency; + /** - * 当前车号 + * 里程 */ - private String vehicle; + private String odo; + /** + * 请求电流 + */ + private String requestCurrent; + + /** + * 请求电压 + */ + private String requestVoltage; + + /** + * 软急停 + */ + private String soft_emc; + + /** + * 今天运行的里程 + */ + private String today_odo; + + /** + * 电压 + */ + private String voltage; + + /** + * x方向的速度 + */ + private String vx; + + /** + * y方向的速度 + */ + private String vy; + + /** + * 加速度 + */ + private String w; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java index 20b39e9..dca414f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java @@ -287,48 +287,7 @@ public class MagicAgvServiceImpl implements MagicAgvService { @LokiLog(type = LokiLogType.AGV) @Override public HttpResponse queryMagicAgvDeviceStatus() { - 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 + "/v1/vehicles"; - HttpResponse result = HttpRequest.get(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("查询agv状态数据:{}", result.body()); - if (result.getStatus() == 200) { - JSONArray ja = (JSONArray) JSONArray.parse(result.body()); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - String name = jo.getString("name"); - String state = jo.getString("state"); - String energyLevel = jo.getString("energyLevel"); - String transportOrder = jo.getString("transportOrder"); - String positionAngle = jo.getString("positionAngle"); - String positionX = jo.getString("positionX"); - String positionY = jo.getString("positionY"); - AgvDto dto = new AgvDto(); - dto.setName(name); - dto.setEnergyLevel(energyLevel); - dto.setState(state); - dto.setPositionAngle(positionAngle); - dto.setPositionX(positionX); - dto.setPositionY(positionY); - dto.setTransportOrder(transportOrder); - - if (AGVDeviceStatus.containsKey(name)) { - AGVDeviceStatus.remove(name); - AGVDeviceStatus.put(name, dto); - } else { - AGVDeviceStatus.put(name, dto); - } - } - } - return result; - } else { - return null; - } - - + return null; } @LokiLog(type = LokiLogType.AGV) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index 5f1d4a1..a92c0c4 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -47,136 +47,123 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { @Autowired private ParamService paramService; @Autowired + TaskService taskService; + @Autowired private AcsToWmsService acsToWmsService; @Autowired InstructionService instructionService; @Autowired + AcsToWmsZDService acsToWmsZDService; + @Autowired AcsConfigService acsConfigService; + Map AGVDeviceStatus = new HashMap(); + @Value("${agvToAcs.addr}") private String addr; @LokiLog(type = LokiLogType.AGV) @Override - public String waitPointRequest(String param) { - log.info("收到AGV请求参数:{}", param); - String[] strs = param.split("-"); - String address = strs[0]; - String inst_code = strs[1]; - String type = strs[2]; - String newaddress = null; - // 前置点会加上p - if (address.endsWith("IN")) { - newaddress = address.substring(0, address.length() - 2); - } else if (address.endsWith("OUT")) { - newaddress = address.substring(0, address.length() - 3); - } else if (address.endsWith("P") || address.endsWith("L") || address.endsWith("R")) { - newaddress = address.substring(0, address.length() - 1); - } else if (address.endsWith("CZ")) { - newaddress = address.substring(0, address.length() - 2); - } else if (address.endsWith("IQ") || address.endsWith("OQ")) { - newaddress = address.substring(0, address.length() - 2); - } else { - newaddress = address; + public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) { + log.info("仙工AGV请求取放货,请求参数 - {}", requestParam); + String instCode = requestParam.getString("task_code"); + Instruction inst = instructionService.findByCodeFromCache(instCode); + if (ObjectUtil.isEmpty(inst)) { + throw new BadRequestException("请求失败,未找到指令!"); + } + TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + if (ObjectUtil.isEmpty(task)) { + throw new BadRequestException("请求失败,未找到指令对应任务!"); + } + String address = requestParam.getString("address"); + if (StrUtil.isBlank(address)) { + throw new BadRequestException("请求失败,地址为空!"); } - boolean is_feedback = false; - Device device = deviceAppService.findDeviceByCode(newaddress); - Instruction inst = instructionService.findByCodeFromCache(inst_code); - TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); - AcsToWmsZDService acsToWmsZDService = SpringContextHolder.getBean("acsToWmsZDServiceImpl"); - TaskDto task = taskService.findByCode(inst.getTask_code()); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); //请求取货 - if (StrUtil.equals(type, "01") && address.endsWith("IN")) { + if (address.contains("INGET")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", inst.getCarno()); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "applyTake"); - log.info("请求参数:{}", jo); + log.info("请求取货请求参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + return jo2; + }else{ + throw new BadRequestException("上位系统不允许取货"); } } //取货完成 - else if (StrUtil.equals(type, "02")) { + if (address.contains("OUTGET")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", inst.getCarno()); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "takeFinish"); - log.info("请求参数:{}", jo); + log.info("取货完成请求参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + return jo2; + }else{ + throw new BadRequestException("上位系统不允许取货完成离开"); } } - //取货完成离开 - else if (StrUtil.equals(type, "05") && address.endsWith("OUT")) { - is_feedback = true; - } +// //取货完成离开 +// else if (StrUtil.equals(type, "05") && address.endsWith("OUT")) { +// is_feedback = true; +// } //请求放货 - else if (StrUtil.equals(type, "03") && address.endsWith("IN")) { + if (address.contains("INPUT")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", inst.getCarno()); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "applyPut"); - log.info("请求参数:{}", jo); + log.info("请求放货请求参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + return jo2; + }else{ + throw new BadRequestException("上位系统不允许请求放货"); } } //放货完成 - else if (StrUtil.equals(type, "04")) { + if (address.contains("OUTPUT")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", inst.getCarno()); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "putFinish"); - log.info("请求参数:{}", jo); + log.info("放货完成请求参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + return jo2; + }else{ + throw new BadRequestException("上位系统不允许放货完成离开"); } } - //放货完成离开 - else if (StrUtil.equals(type, "06") && address.endsWith("OUT") - && standardOrdinarySiteDeviceDriver.getMove() != 0) { - is_feedback = true; - } - } - JSONObject jo = new JSONObject(); - if (is_feedback) { - jo.put("name", param); - jo.put("lastAction", "wait"); - jo.put("lastActionStatus", "DONE"); - jo.put("status", "IDLE"); - } else { - jo.put("name", param); - jo.put("lastAction", "wait"); - jo.put("lastActionStatus", "FAILED"); - jo.put("status", "IDLE"); - } - is_feedback = false; - log.info("反馈AGV请求参数:{}", jo.toString()); - return jo.toString(); + throw new BadRequestException("请求失败,IN OUT 站点错误!"); } @LokiLog(type = LokiLogType.AGV) @@ -208,53 +195,80 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { @Override public HttpResponse queryXZAgvDeviceStatus() { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { + if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue().toString(), "1")) { String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - String agvurl1 = agvurl + ":" + agvport + "/api/route/vehicles"; - String agvurl2 = agvurl + ":" + agvport + "/api/route/vehicleDetails"; - - HttpResponse result = HttpRequest.get(agvurl1) - .timeout(20000)//超时,毫秒 - .execute(); - + agvurl = agvurl + ":" + agvport + "/robotsStatus"; - HttpResponse result2 = HttpRequest.get(agvurl2) + HttpResponse result = HttpRequest.get(agvurl) .timeout(20000)//超时,毫秒 .execute(); System.out.println("查询agv状态数据:" + result.body()); if (result.getStatus() == 200) { - JSONArray ja = (JSONArray) JSONArray.parse(result.body()); - + com.alibaba.fastjson.JSONObject body = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + com.alibaba.fastjson.JSONArray ja = body.getJSONArray("report"); for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - String name = jo.getString("name"); - String state = jo.getString("state"); - String energyLevel = jo.getString("energyLevel"); - String transportOrder = jo.getString("transportOrder"); - String vehicle=jo.getString("getString"); - JSONObject detailjo = (JSONObject) JSONObject.parse(result2.body()); - JSONObject item = (JSONObject) detailjo.get(name); - String x = item.getString("x"); - String y = item.getString("y"); - String angle = item.getString("angle"); + com.alibaba.fastjson.JSONObject jo = ja.getJSONObject(i); + //机器人编码 + String agv_code = jo.getString("uuid"); + //机器人详细状态信息 + com.alibaba.fastjson.JSONObject rbk_report = jo.getJSONObject("rbk_report"); + //是否正在充电 + Boolean charging = rbk_report.getBoolean("charging"); + //电池电量 + float battery_level1 = rbk_report.getFloatValue("battery_level"); + float battery_level=battery_level1*100; + //当前地图 + String current_map = rbk_report.getString("current_map"); + //角度 + float angle = rbk_report.getFloatValue("angle"); + //执行运单信息 + com.alibaba.fastjson.JSONObject current_order = jo.getJSONObject("current_order"); + int task_status=rbk_report.getInteger("task_status"); + String state=null; + if(task_status==0){ + state="NONE"; + }if(task_status==1){ + state="WAITING"; + }if(task_status==2){ + state="RUNNING"; + }if(task_status==3){ + state="SUSPENDED"; + }if(task_status==4){ + state="COMPLETED"; + }if(task_status==5){ + state="FAILED"; + }if(task_status==6){ + state="CANCELED"; + } + Integer connectionStatus = jo.getInteger("connection_status"); + String inst_code = current_order.getString("id"); + String taskNo= "0"; + if (StrUtil.isNotEmpty(inst_code)) { + Instruction inst = instructionService.findByCodeFromCache(inst_code); + if (ObjectUtil.isNotEmpty(inst)) { + //任务号 + taskNo = inst.getTask_code(); + } + } + //x坐标 + float x = rbk_report.getFloatValue("x"); + //y坐标 + float y = rbk_report.getFloatValue("y"); AgvDto dto = new AgvDto(); - dto.setName(name); - dto.setEnergyLevel(energyLevel); - dto.setState(state); - dto.setTransportOrder(transportOrder); - dto.setVehicle(vehicle); - dto.setPositionAngle(angle); + dto.setName(agv_code); + dto.setCurrent_map(current_map); + dto.setCharging(charging); + dto.setBattery_level(battery_level); + dto.setTransportOrder(taskNo); dto.setPositionX(x); dto.setPositionY(y); - if (AGVDeviceStatus.containsKey(name)) { - AGVDeviceStatus.remove(name); - AGVDeviceStatus.put(name, dto); - } else { - AGVDeviceStatus.put(name, dto); - } + dto.setPositionAngle(angle); + dto.setConnection_status(connectionStatus); + dto.setState(state); + AGVDeviceStatus.put(agv_code, dto); } } return result; @@ -268,9 +282,9 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { @LokiLog(type = LokiLogType.AGV) @Override public HttpResponse queryXZAgvInstStatus() { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); + 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 + "/orders?page=1&size=9999"; List insts = instructionService.findAllInstFromCache(); @@ -307,9 +321,13 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode + "/withdrawal"; + com.alibaba.fastjson.JSONObject param = new com.alibaba.fastjson.JSONObject(); + param.put("id", instCode); + param.put("disableVehicle", false); + agvurl = agvurl + ":" + agvport + "/terminate"; log.info("删除agv指令请求agvurl:{}", agvurl); HttpResponse result = HttpRequest.post(agvurl) + .body(param.toJSONString()) .timeout(20000)//超时,毫秒 .execute(); log.info("删除agv指令请求反馈:{}", result); @@ -322,18 +340,19 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { @LokiLog(type = LokiLogType.AGV) @Override public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception { + com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject(); jo.put("id", inst.getInstruction_code()); jo.put("complete", true); jo.put("blocks", createBlocksData(inst)); jo.put("priority", inst.getPriority()); log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString()); - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); + if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { + log.info("准备下发"); + String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); + String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); agvurl = agvurl + ":" + agvport + "/setOrder"; - + log.info("下发地址为{}",agvurl); HttpResponse result = HttpRequest.post(agvurl) .body(String.valueOf(jo))//表单内容 .timeout(20000)//超时,毫秒 @@ -347,6 +366,11 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } public com.alibaba.fastjson.JSONArray createBlocksData(Instruction inst) { com.alibaba.fastjson.JSONArray ja = new com.alibaba.fastjson.JSONArray(); + com.alibaba.fastjson.JSONObject jo9 = new com.alibaba.fastjson.JSONObject(); + jo9.put("blockId", IdUtil.simpleUUID()); + jo9.put("location", inst.getStart_point_code() + "INGET"); + jo9.put("binTask", "ForkLoad"); + ja.add(jo9); Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code()); if ("true".equals(startDevice.getExtraValue().get("ignore_pickup_check"))) { //取货前等待 @@ -355,7 +379,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo.put("location", inst.getStart_point_code() + "INGET"); jo.put("operation", "script"); jo.put("id", inst.getStart_point_code() + "INGET"); - jo.put("script_name", "userpy/interact.py"); + jo.put("script_name", "userpy/interact1.py"); com.alibaba.fastjson.JSONObject script_args = new com.alibaba.fastjson.JSONObject(); script_args.put("addr", addr); com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject(); @@ -368,11 +392,10 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo.put("script_args", script_args); ja.add(jo); } - com.alibaba.fastjson.JSONObject jo1 = new com.alibaba.fastjson.JSONObject(); jo1.put("blockId", IdUtil.simpleUUID()); jo1.put("location", inst.getStart_point_code()); - jo1.put("operation", "JackLoad"); + jo1.put("binTask", "ForkLoad"); ja.add(jo1); //取货完成等待 @@ -381,7 +404,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo2.put("location", inst.getStart_point_code() + "OUTGET"); jo2.put("operation", "script"); jo2.put("id", inst.getStart_point_code() + "OUTGET"); - jo2.put("script_name", "userpy/interact.py"); + jo2.put("script_name", "userpy/interact1.py"); com.alibaba.fastjson.JSONObject script_args2 = new com.alibaba.fastjson.JSONObject(); script_args2.put("addr", addr); com.alibaba.fastjson.JSONObject data2 = new com.alibaba.fastjson.JSONObject(); @@ -393,7 +416,16 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { script_args2.put("protocol", "HTTP"); jo2.put("script_args", script_args2); ja.add(jo2); - + com.alibaba.fastjson.JSONObject jo6 = new com.alibaba.fastjson.JSONObject(); + jo6.put("blockId", IdUtil.simpleUUID()); + jo6.put("location", inst.getStart_point_code() + "OUTGET"); + jo6.put("binTask", "ForkUnload"); + ja.add(jo6); + com.alibaba.fastjson.JSONObject jo7 = new com.alibaba.fastjson.JSONObject(); + jo7.put("blockId", IdUtil.simpleUUID()); + jo7.put("location", inst.getNext_point_code() + "INPUT"); + jo7.put("binTask", "ForkLoad"); + ja.add(jo7); Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { //放货前等待 @@ -402,7 +434,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo3.put("location", inst.getNext_point_code() + "INPUT"); jo3.put("operation", "script"); jo3.put("id", inst.getNext_point_code() + "INPUT"); - jo3.put("script_name", "userpy/interact.py"); + jo3.put("script_name", "userpy/interact1.py"); com.alibaba.fastjson.JSONObject script_args3 = new com.alibaba.fastjson.JSONObject(); script_args3.put("addr", addr); com.alibaba.fastjson.JSONObject data3 = new com.alibaba.fastjson.JSONObject(); @@ -415,26 +447,10 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo3.put("script_args", script_args3); ja.add(jo3); } - -// //放货前下发旋转角度 -// com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(); -// AcsPointAngleDto acsPointAngleDto = acsPointAngleService.findByCode(inst.getStart_device_code(),inst.getNext_device_code()); -// if (ObjectUtil.isNotEmpty(acsPointAngleDto)){ -// log.info("acsPointAngleDto----參數,{}", acsPointAngleDto.toString()); -// com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); -// BigDecimal next_point_angle = acsPointAngleDto.getNext_point_angle(); -// operation_args.put("increase_spin_angle",next_point_angle);//弧度值,如3.14 -// operation_args.put("skill_name","GoByOdometer"); -// json1.put("blockId", IdUtil.simpleUUID()); -// json1.put("location", inst.getNext_point_code() + "INPUT"); -// json1.put("operation_args",operation_args); -// ja.add(json1); -// } - com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject(); jo4.put("blockId", IdUtil.simpleUUID()); jo4.put("location", inst.getNext_point_code()); - jo4.put("operation", "JackUnload"); + jo4.put("binTask", "ForkUnload"); ja.add(jo4); if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { @@ -444,7 +460,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo5.put("location", inst.getNext_point_code() + "OUTPUT"); jo5.put("operation", "script"); jo5.put("id", inst.getNext_point_code() + "OUTPUT"); - jo5.put("script_name", "userpy/interact.py"); + jo5.put("script_name", "userpy/interact1.py"); com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject(); script_args5.put("addr", addr); com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject(); @@ -457,6 +473,11 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { jo5.put("script_args", script_args5); ja.add(jo5); } + com.alibaba.fastjson.JSONObject jo8 = new com.alibaba.fastjson.JSONObject(); + jo8.put("blockId", IdUtil.simpleUUID()); + jo8.put("location", inst.getNext_point_code() + "OUTPUT"); + jo8.put("binTask", "ForkUnload"); + ja.add(jo8); return ja; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java index 69e7907..3f58ecf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java @@ -21,21 +21,20 @@ import java.util.Map; @RestController @RequiredArgsConstructor @Api(tags = "wms接口") -@RequestMapping("/restful/api/v3/system_car") @Slf4j @Lazy @SaIgnore public class AcsToWmsZDController { private final AcsToWmsZDService acsToWmsZDService; - @PostMapping("/feedbackTask") + @PostMapping("/wcs/restful/api/v3/system_ca/feedbackTask") @Log("任务反馈") @ApiOperation("任务反馈") public ResponseEntity taskFeedback(@RequestBody JSONObject whereJson) throws Exception { return new ResponseEntity<>(acsToWmsZDService.taskFeedback(whereJson), HttpStatus.OK); } - @PostMapping("/deprecateTask") + @PostMapping("/restful/api/v3/system_car/deprecateTask") @Log("任务取消") @ApiOperation("任务取消") public ResponseEntity taskDeprecate(@RequestBody JSONObject whereJson) throws Exception { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java index 69d339a..a0f7eaf 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java @@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequiredArgsConstructor @Api(tags = "wms接口") -@RequestMapping("/restful/API/V3") +@RequestMapping("/restful/api/v3") @Slf4j @Service @Lazy diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java index 3296358..b018c7a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java @@ -134,6 +134,7 @@ public class WmsZDToAcsServiceImpl implements WmsZDToAcsService { e.printStackTrace(); map.put("responseCode", 1); map.put("responseMessage", e.getMessage()); + log.info("报错信息为{}",map); return map; } map.put("responseCode", 0); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index fe2647d..adc2cb5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -357,6 +357,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; try { + log.info("仙工订单准备下发"); String start_device_code = dto.getStart_device_code(); String next_device_code = dto.getNext_device_code(); String route_plan_code = task.getRoute_plan_code(); @@ -392,7 +393,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu ndcAgvService.sendAgvInstToNDC("1", dto); dto.setSend_status("1"); - } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).toString(), String.valueOf(AgvSystemEnum.XianGong.getIndex()))) { + } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue().toString(), String.valueOf(AgvSystemEnum.XianGong.getIndex()))) { if (StrUtil.equals(task.getRequest_again_success(), "1")) { //追加订单 HttpResponse result = xianGongAgvService.sendOrderSequencesToXZ(dto); @@ -945,37 +946,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu if (flag) { com.alibaba.fastjson.JSONObject requestjo = new com.alibaba.fastjson.JSONObject(); requestjo.put("task_code", entity.getInstruction_code()); - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - String taskcode=entity.getInstruction_code(); - agvurl = agvurl + ":" + agvport + "/rmds/v1/transportOrders/" + taskcode + "/withdrawal"; - HttpResponse result = HttpRequest.post(agvurl) - .body(String.valueOf(requestjo)) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("请求地址agvurl{},请求结果{}",agvurl,result.body()); - if (StrUtil.equals(entity.getInstruction_type(), "7")) { - CancelTaskRequest cancelTaskRequest = new CancelTaskRequest(); - cancelTaskRequest.setOrderId(entity.getInstruction_code()); - cancelTaskRequest.setPalletCode(entity.getVehicle_code()); - cancelTaskRequest.setSrcLocation(entity.getStart_point_code()); - cancelTaskRequest.setDestLocation(entity.getNext_point_code()); - // 1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库 - int type = 0; - if (StrUtil.equals(task.getStorage_task_type(), "1")) { - type = 1; - } else if (StrUtil.equals(task.getStorage_task_type(), "2")) { - type = 4; - } else if (StrUtil.equals(task.getStorage_task_type(), "3")) { - type = 2; - } else if (StrUtil.equals(task.getStorage_task_type(), "4")) { - type = 5; - } else if (StrUtil.equals(task.getStorage_task_type(), "5")) { - type = 3; - } - cancelTaskRequest.setTaskType(type); - acsToLiKuService.cancelTask(cancelTaskRequest); - } + String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java index 4a54fb8..39599fd 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/route/service/impl/RouteLineServiceImpl.java @@ -261,7 +261,7 @@ public class RouteLineServiceImpl implements RouteLineService, ApplicationAutoIn } } } -// reload(); + reload(); } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 9251579..1874830 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -851,30 +851,21 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { WQLObject wo = WQLObject.getWQLObject("acs_task"); JSONObject json = (JSONObject) JSONObject.toJSON(entity); wo.update(json); - -// synchronized (TaskServiceImpl.class){ -// Iterator it = tasks.iterator(); -// // 清理缓存 -// while (it.hasNext()) { -// TaskDto taskDto = it.next(); -// if (taskDto.getTask_id().equals(id)) { -// tasks.remove(taskDto); -// } -// }} - removeByCodeFromCache(entity.getTask_code()); - // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); String Type1=entity.getTask_type(); if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + log.info("取消中鼎任务"); JSONObject feed_jo = new JSONObject(); + Instruction instCode=instructionservice.findByTaskcode(entity.getTask_code()); feed_jo.put("taskCode", entity.getTask_code()); -// JSONArray ja = new JSONArray(); -// ja.add(feed_jo); -// acstowmsService.feedbackTaskStatusToWms(ja); - HttpResponse result=acsToWmsZDService.taskDeprecate(feed_jo); + feed_jo.put("carId", instCode.getCarno()); + feed_jo.put("taskType ", entity.getTask_type()); + feed_jo.put("feedbackStatus", "deprecate"); + HttpResponse result=acsToWmsZDService.taskFeedback(feed_jo); JSONObject response=JSONObject.parseObject(result.body()); + log.info("任务取消 返回参数{}",response); int responseCode= response.getInteger("responseCode"); if(responseCode == 0) { log.info("请求ZDwcs成功,任务取消 请求结果{}",responseCode); @@ -887,11 +878,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { entity.getRoute_plan_code()); String type = shortPathsList.get(0).getType(); // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - agvService.markComplete(entity.getTask_code()); - } - } +// if (!StrUtil.equals(type, "0")) { +// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { +// agvService.markComplete(entity.getTask_code()); +// } +// } } @Override diff --git a/acs/nladmin-system/src/main/resources/log/ZheDaAgv.xml b/acs/nladmin-system/src/main/resources/log/XianGongAgvServiceImpl.xml similarity index 93% rename from acs/nladmin-system/src/main/resources/log/ZheDaAgv.xml rename to acs/nladmin-system/src/main/resources/log/XianGongAgvServiceImpl.xml index 0f68c1f..73f7c24 100644 --- a/acs/nladmin-system/src/main/resources/log/ZheDaAgv.xml +++ b/acs/nladmin-system/src/main/resources/log/XianGongAgvServiceImpl.xml @@ -27,7 +27,7 @@ --> - + diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 84ea520..a3765c5 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -27,7 +27,7 @@ https://juejin.cn/post/6844903775631572999 - +