From 8c560a9c956d39dad0512ba85112475c0ed51131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E4=BF=8A=E6=9D=B0?= <9463626+zhou-junjiezjj@user.noreply.gitee.com> Date: Wed, 16 Oct 2024 14:02:07 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=A2=9E=E5=8A=A0=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E6=97=8B=E8=BD=AC=E5=92=8C=E6=98=AF=E5=90=A6=E8=83=BD=E5=A4=9F?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E7=A6=BB=E5=BC=80=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/agv/rest/AgvController.java | 13 +- .../org/nl/acs/agv/server/AgvService.java | 20 +- .../org/nl/acs/agv/server/dto/AgvDto.java | 20 +- .../acs/agv/server/impl/AgvServiceImpl.java | 598 +++++++++++++----- .../wms/service/impl/AcsToWmsServiceImpl.java | 6 +- .../task/service/impl/TaskServiceImpl.java | 7 - .../quartz/task/QueryXZAgvTaskStatus.java | 111 ++-- .../nl/modules/quartz/task/ToAgvDevice.java | 5 +- .../auto/run/NDCSocketConnectionAutoRun.java | 40 +- .../src/main/resources/log/ToAgvDevice.xml | 14 + .../src/main/resources/logback-spring.xml | 1 + 11 files changed, 576 insertions(+), 259 deletions(-) create mode 100644 hd/nladmin-system/src/main/resources/log/ToAgvDevice.xml diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java index dd6ef7b..1473d7f 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java @@ -94,5 +94,16 @@ public class AgvController { return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK); } - + @PostMapping ("/releaseBlockGroup") + @Log("释放互斥组") + @ApiOperation("释放互斥组") + public ResponseEntity releaseBlockGroup(@RequestBody JSONObject requestParam) { + return new ResponseEntity<>(agvService.releaseBlockGroup(requestParam), HttpStatus.OK); + } + @PostMapping ("/acquireBlockGroup") + @Log("占用互斥组") + @ApiOperation("占用互斥组") + public ResponseEntity getBlockGroup(@RequestBody JSONObject requestParam) { + return new ResponseEntity<>(agvService.getBlockGroup(requestParam), HttpStatus.OK); + } } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java index 002dab8..3e028c9 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java @@ -33,7 +33,7 @@ public interface AgvService { public HttpResponse queryXZAgvDeviceStatus(); - public HttpResponse queryXZAgvInstStatus(String instCode); + public HttpResponse queryXZAgvInstStatus(); Map findAllAgvFromCache(); @@ -122,7 +122,7 @@ public interface AgvService { public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2); /** - * 下发agv单工动作指令 + * agv单工动作指令 * * @param phase * @param index @@ -182,4 +182,20 @@ public interface AgvService { String queryDeviceStation(); + + /** + * 释放互斥组 + * + * @param + * @return + */ + JSONObject releaseBlockGroup(JSONObject requestParam); + + /** + * 占用互斥组 + * + * @param + * @return + */ + JSONObject getBlockGroup(JSONObject requestParam); } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java index eb2eec1..a7226d3 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java @@ -27,7 +27,7 @@ public class AgvDto implements Serializable { /** * 机器人的剩余电量值(单位:整数百分比) */ - private String energyLevel; + private Float energyLevel; /** * @@ -57,17 +57,17 @@ 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; /** * 当前任务号 @@ -79,6 +79,11 @@ public class AgvDto implements Serializable { */ private String battery_temp; + /** + * 电池电量 + */ + private float battery_level; + /** * 是否阻挡 */ @@ -92,7 +97,12 @@ public class AgvDto implements Serializable { /** * 是否充电 */ - private String charging; + private Boolean charging; + + /** + * 机器人连接状态,0表示断连,1表示连接上 + */ + private Integer connection_status; /** * 控制器温度 diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index 503702e..9d6138b 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -511,48 +511,7 @@ public class AgvServiceImpl implements AgvService { @Override public HttpResponse queryMagicAgvDeviceStatus() { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles"; - - HttpResponse result = HttpRequest.get(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - System.out.println("查询agv状态数据:" + result.body()); - if (result.getStatus() == 200) { - JSONArray ja = JSONArray.fromObject(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; } @Override @@ -591,9 +550,10 @@ public class AgvServiceImpl implements AgvService { @Override public HttpResponse queryXZAgvDeviceStatus() { - 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(acsConfigService.findByCode(AcsConfig.FORKAGV).getValue().toString(), "1")) { + String agvurl = acsConfigService.findByCode(AcsConfig.AGVURL).getValue(); + String agvport = acsConfigService.findByCode(AcsConfig.AGVPORT).getValue(); agvurl = agvurl + ":" + agvport + "/robotsStatus"; @@ -603,99 +563,110 @@ public class AgvServiceImpl implements AgvService { System.out.println("查询agv状态数据:" + result.body()); if (result.getStatus() == 200) { - JSONArray ja = JSONArray.fromObject(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"); - JSONObject detailjo = JSONObject.fromObject(result.body()); - JSONObject item = (JSONObject) detailjo.get(name); - if(ObjectUtil.isEmpty(detailjo.get(name))){ - continue; + 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"; } - String x = item.getString("x"); - String y = item.getString("y"); - String angle = item.getString("angle"); - String battery_temp = item.getString("battery_temp"); - String blocked = item.getString("blocked"); - String brake = item.getString("brake"); - String charging = item.getString("charging"); - String controller_temp = item.getString("controller_temp"); - String current_map = item.getString("current_map"); - String current_station = item.getString("current_station"); - String emergency = item.getString("emergency"); - String odo = item.getString("odo"); - String requestCurrent = item.getString("requestCurrent"); - String requestVoltage = item.getString("requestVoltage"); - String soft_emc = item.getString("soft_emc"); - String today_odo = item.getString("today_odo"); - String voltage = item.getString("voltage"); - String vx = item.getString("vx"); - String vy = item.getString("vy"); - String w = item.getString("w"); - - + 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.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); - dto.setBattery_temp(battery_temp); - dto.setBlocked(blocked); - dto.setBrake(brake); - dto.setCharging(charging); - dto.setController_temp(controller_temp); - dto.setCurrent_station(current_station); - dto.setEmergency(emergency); - dto.setOdo(odo); - dto.setRequestCurrent(requestCurrent); - dto.setRequestVoltage(requestVoltage); - dto.setVoltage(voltage); - dto.setSoft_emc(soft_emc); - dto.setVx(vx); - dto.setVy(vy); - dto.setW(w); - 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; } else { return null; } + + } @Override - public HttpResponse queryXZAgvInstStatus(String instCode) { - + 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); - agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode; + agvurl = agvurl + ":" + agvport + "/orders?page=1&size=9999"; + List insts = instructionService.findAllInstFromCache(); + if (!insts.isEmpty()) { + JSONObject where = new JSONObject(); + where.put("relation", "OR"); + JSONArray predicates = new JSONArray(); + where.put("predicates", predicates); + for (Instruction instruction : insts) { + JSONArray row = new JSONArray(); + row.add("id"); + row.add("EQ"); + row.add(instruction.getInstruction_code()); + predicates.add(row); + } + agvurl = agvurl+ "&where=" + where; + } HttpResponse result = HttpRequest.get(agvurl) .timeout(20000)//超时,毫秒 .execute(); - System.out.println("查询agv指令数据:" + result.body()); - return result; } else { return null; } - - } @Override @@ -742,25 +713,24 @@ public class AgvServiceImpl implements AgvService { @Override public HttpResponse deleteXZAgvInst(String instCode) { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV), "1")) { String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - 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); - return result; - } else { - return null; } - } @Override @@ -1081,24 +1051,26 @@ public class AgvServiceImpl implements AgvService { if (StrUtil.isBlank(address)) { throw new BadRequestException("请求失败,地址为空!"); } - + String startcode=inst.getStart_device_code(); //请求取货 if (address.contains("INGET")) { JSONObject jo=new JSONObject(); jo.put("device_code",inst.getStart_device_code()); - jo.put("device_status","enter"); - log.info("请求参数:{}", jo); + jo.put("task_code",inst.getTask_code()); + jo.put("status","1"); + jo.put("vehicle_code",inst.getVehicle_code()); JSONArray ja=new JSONArray(); - for(Object key:jo.keySet()){ - JSONObject jo1=new JSONObject(); - jo1.put(key,jo.get(key)); - ja.add(jo1); - } + ja.add(jo); HttpResponse result=acsToWmsService.vehicle(ja); + log.info("请求取货请求参数:{}", ja); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + log.info("上位反馈请求取货请求参数:{}",response); int responseCode = response.getInteger("status"); if (responseCode == 200) { + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("上位允许取货 请求结果{}", responseCode); + return jo2; }else{ throw new BadRequestException("上位系统不允许取货"); } @@ -1106,41 +1078,46 @@ public class AgvServiceImpl implements AgvService { //取货完成离开 if (address.contains("OUTGET")) { JSONObject jo=new JSONObject(); - jo.put("device_code",inst.getStart_device_code()); - jo.put("device_status","left"); - log.info("请求参数:{}", jo); + jo.put("device_code",inst.getStart_device_code()); + jo.put("task_code",inst.getTask_code()); + jo.put("status","2"); + jo.put("vehicle_code",inst.getVehicle_code()); JSONArray ja=new JSONArray(); - for(Object key:jo.keySet()){ - JSONObject jo1=new JSONObject(); - jo1.put(key,jo.get(key)); - ja.add(jo1); - } + ja.add(jo); + log.info("取货完成离开请求参数:{}", ja); HttpResponse result=acsToWmsService.vehicle(ja); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + log.info("上位反馈取货完成离开请求参数:{}",response); int responseCode = response.getInteger("status"); if (responseCode == 200) { + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("上位允许取货离开 请求结果{}", responseCode); + return jo2; }else{ throw new BadRequestException("上位系统不允许取货完成离开"); } + } //请求放货 if (address.contains("INPUT")) { JSONObject jo=new JSONObject(); - jo.put("device_code",inst.getNext_device_code()); - jo.put("device_status","enter"); - log.info("请求参数:{}", jo); + jo.put("device_code",inst.getNext_device_code()); + jo.put("task_code",inst.getTask_code()); + jo.put("status","3"); + jo.put("vehicle_code",inst.getVehicle_code()); JSONArray ja=new JSONArray(); - for(Object key:jo.keySet()){ - JSONObject jo1=new JSONObject(); - jo1.put(key,jo.get(key)); - ja.add(jo1); - } + ja.add(jo); + log.info("请求放货请求参数:{}", ja); HttpResponse result=acsToWmsService.vehicle(ja); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + log.info("上位反馈请求放货请求参数:{}",response); int responseCode = response.getInteger("status"); if (responseCode == 200) { + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("上位允许放货 请求结果{}", responseCode); + return jo2; }else{ throw new BadRequestException("上位系统不允许请求放货"); } @@ -1149,20 +1126,22 @@ public class AgvServiceImpl implements AgvService { //放货完成离开 if (address.contains("OUTPUT")) { JSONObject jo=new JSONObject(); - jo.put("device_code",inst.getNext_device_code()); - jo.put("device_status","left"); - log.info("请求参数:{}", jo); + jo.put("device_code",inst.getNext_device_code()); + jo.put("task_code",inst.getTask_code()); + jo.put("status","4"); + jo.put("vehicle_code",inst.getVehicle_code()); JSONArray ja=new JSONArray(); - for(Object key:jo.keySet()){ - JSONObject jo1=new JSONObject(); - jo1.put(key,jo.get(key)); - ja.add(jo1); - } + ja.add(jo); + log.info("放货完成离开:{}", ja); HttpResponse result=acsToWmsService.vehicle(ja); com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + log.info("上位反馈放货完成离开请求参数:{}",response); int responseCode = response.getInteger("status"); if (responseCode == 200) { + JSONObject jo2 = new JSONObject(); + jo2.put("status",200); log.info("上位允许放货离开 请求结果{}", responseCode); + return jo2; }else{ throw new BadRequestException("上位系统不允许放货完成离开"); } @@ -1540,7 +1519,6 @@ public class AgvServiceImpl implements AgvService { 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); @@ -1568,7 +1546,7 @@ public class AgvServiceImpl implements AgvService { 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(); @@ -1594,7 +1572,7 @@ public class AgvServiceImpl implements AgvService { 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(); @@ -1615,7 +1593,7 @@ public class AgvServiceImpl implements AgvService { 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(); @@ -1628,22 +1606,249 @@ public class AgvServiceImpl implements AgvService { 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 json1 = new com.alibaba.fastjson.JSONObject(); + if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4031")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3031")&&inst.getNext_device_code().equals("4010")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3012")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4012")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3001")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4001")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4027")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3027")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3027")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4028")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3028")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4017")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3017")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3019")&&inst.getNext_device_code().equals("4036")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3036")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3036")&&inst.getNext_device_code().equals("4019")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4032")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3032")&&inst.getNext_device_code().equals("4010")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4033")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3033")&&inst.getNext_device_code().equals("4010")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4034")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3034")&&inst.getNext_device_code().equals("4010")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4015")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3035")&&inst.getNext_device_code().equals("4010")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3010")&&inst.getNext_device_code().equals("4003")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3003")&&inst.getNext_device_code().equals("4010")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3034")&&inst.getNext_device_code().equals("4018")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3035")&&inst.getNext_device_code().equals("4018")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3018")&&inst.getNext_device_code().equals("4034")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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); + }else if(inst.getStart_device_code().equals("3018")&&inst.getNext_device_code().equals("4035")){ + com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject(); + operation_args.put("increase_spin_angle",3.14);//弧度值,如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()); @@ -1657,7 +1862,7 @@ public class AgvServiceImpl implements AgvService { 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(); @@ -1987,6 +2192,58 @@ public class AgvServiceImpl implements AgvService { return null; } + @Override + public JSONObject releaseBlockGroup(JSONObject requestParam) { + JSONArray datas = JSONArray.fromObject(requestParam); + log.info("仙工AGV离开进入管制区域,请求参数 - {}", requestParam); + for (int i = 0; i < requestParam.size(); i++) { + JSONObject jo = datas.getJSONObject(i); +// String robot_name = jo.optString("robot_name"); +// jo.put("device code", robot_name); + jo.put("status", 6); + log.info("请求参数:{}", jo); + JSONArray ja = new JSONArray(); + ja.add(jo); + HttpResponse result = acsToWmsService.vehicle(ja); + com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("status"); + JSONObject jo2 = new JSONObject(); + jo2.put("message","ok"); + jo2.put("code",200); + log.info("上位允许仙工AGV请求离开管制区 请求结果{}", responseCode); + return jo2; + } + throw new BadRequestException("请求失败,参数错误!"); + } + + @Override + public JSONObject getBlockGroup(JSONObject requestParam) { + JSONArray datas = JSONArray.fromObject(requestParam); + log.info("仙工AGV请求进入管制区域,请求参数 - {}", requestParam); + for (int i = 0; i < requestParam.size(); i++) { + JSONObject jo = datas.getJSONObject(i); +// String robot_name = jo.optString("robot_name"); +// jo.put("device code",robot_name); + jo.put("status", "5"); + log.info("请求参数:{}", jo); + JSONArray ja = new JSONArray(); + ja.add(jo); + HttpResponse result = acsToWmsService.vehicle(ja); + com.alibaba.fastjson.JSONObject response = com.alibaba.fastjson.JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("status"); + if (responseCode == 200) { + JSONObject jo2 = new JSONObject(); + jo2.put("message","ok"); + jo2.put("code",200); + log.info("上位允许仙工AGV请求进入管制区域 请求结果{}", responseCode); + return jo2; + } else { + throw new BadRequestException("上位不允许仙工AGV请求进入管制区域"); + } + } + throw new BadRequestException("请求失败,参数错误!"); + } + String hexToString(int i) { return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase(); } @@ -2023,4 +2280,5 @@ public class AgvServiceImpl implements AgvService { System.out.println(address); } } + } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 49f2a62..1677c95 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -454,19 +454,19 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; HttpResponse result = null; - log.info("feedbackAgv----请求参数{}", from); + log.info("vehicle----请求参数{}", from); try { result = HttpRequest.post(url) .body(String.valueOf(from)) .execute(); System.out.println(result); - log.info("feedbackAgv----返回参数{}", result); + log.info("vehicle----返回参数{}", result); } catch (Exception e) { String msg = e.getMessage(); //网络不通 System.out.println(msg); - log.info("feedbackAgv----异常{}", msg); + log.info("vehicle----异常{}", msg); } return result; } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 5e56904..a5e205a 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -1121,13 +1121,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } List shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code()); String type = shortPathsList.get(0).getType(); - // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - AgvServiceImpl xianGongAgv = SpringContextHolder.getBean(AgvServiceImpl.class); - xianGongAgv.markComplete(entity.getTask_code()); - } - } } @Override diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java index 1ee2a61..91fc20d 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java @@ -1,23 +1,24 @@ package org.nl.modules.quartz.task; -import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; -import net.sf.json.JSONObject; import org.nl.acs.agv.server.AgvService; +import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.task.service.TaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.List; - /** * 查询AGV任务状态 */ @Slf4j -@Component +@Component("queryXZAgvTaskStatus") public class QueryXZAgvTaskStatus { @Autowired @@ -26,59 +27,69 @@ public class QueryXZAgvTaskStatus { @Autowired AgvService agvService; + @Autowired + AcsToWmsService acsToWmsService; + + @Autowired + TaskService taskService; + + private volatile boolean lock = false; public void run() throws Exception { - List instList = instructionService.findAllInstFromCache(); - if (instList.size() > 0) { - for (int i = 0; i < instList.size(); i++) { - Instruction inst = instList.get(i); - if (!StrUtil.equals(inst.getSend_status(), "1")) continue; - String instcode = inst.getInstruction_code(); - HttpResponse response = agvService.queryXZAgvInstStatus(instcode); - JSONObject jo = JSONObject.fromObject(response.body()); - if (MapUtil.isEmpty(jo)) continue; - //反馈结果状态 - log.info("instcode:" + instcode + "," + jo.toString()); - //指令执行状态 - String state = jo.getString("state"); - String processingVehicle = ""; - //正在执行指令agv车号 - if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) { - processingVehicle = jo.getString("processingVehicle"); - inst.setCarno(processingVehicle); - } + if (!lock) { + lock = true; + try { -// RAW:初始状态 -// ACTIVE:业务订单已激活 -// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行 -// BEING_PROCESSED:业务订单正在被执行 -// WITHDRAWN:业务订单已被撤销 -// FINISHED:业务订单已完成 -// FAILED:业务订单已失败 -// UNROUTABLE:无法规划该业务订单的执行路线 + HttpResponse response = agvService.queryXZAgvInstStatus(); + JSONObject jo = JSONArray.parseObject(response.body()); - //执行中 - if ("BEING_PROCESSED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - } else if ("FINISHED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } - } else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("4"); - instructionService.update(inst); - //instructionService.removeByCodeFromCache(instcode); + JSONArray ja = JSONArray.parseArray(jo.getString("list")); + for (int i = 0; i < ja.size(); i++) { + JSONObject one = (JSONObject) ja.get(i); + String inst_code = one.getString("id"); + Instruction inst = instructionService.findByCodeFromCache(inst_code); + if (ObjectUtil.isEmpty(inst)) + continue; + + String state = one.getString("state"); + if (!StrUtil.isEmpty(one.getString("vehicle"))) { + String carno = one.getString("vehicle"); + inst.setCarno(carno); } - } else { - } +// 已创建=CREATED, +// 待分配=TOBEDISPATCHED, +// 正在执行=RUNNING, +// 完成=FINISHED, +// 失败=FAILED(主动失败), +// 终止=STOPPED(被人为终止), +// 无法执行=Error(参数错误), +// 等待=WAITING + //执行中 + if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) { + if (inst != null) { + inst.setInstruction_status("1"); + instructionService.update(inst); + } + } else if ("FINISHED".equals(state)) { + if (inst != null) { + inst.setInstruction_status("2"); + instructionService.finish(inst); + } + } else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) { + if (inst != null) { + inst.setInstruction_status("1"); + instructionService.update(inst); + } + } + } + } finally { + if (lock) { + lock = false; + } } + } } } diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java index 72fa923..988b73e 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java @@ -30,6 +30,7 @@ public class ToAgvDevice { public void run() throws Exception { JSONObject json = new JSONObject(); Map agv_map = agvService.findAllAgvFromCache(); + log.info("AGV设备数据为{}",agv_map); if(ObjectUtil.isEmpty(agv_map)){ System.out.println("AGV设备数据为空,无法反馈"); return; @@ -39,7 +40,7 @@ public class ToAgvDevice { for (AgvDto agvDto : agv_map.values()) { row.put("device_code", agvDto.getName()); - row.put("energyLevel", agvDto.getEnergyLevel()); + row.put("energyLevel", agvDto.getBattery_level()); row.put("device_status",agvDto.getState()); row.put("transportOrder", agvDto.getTransportOrder()); row.put("positionX", agvDto.getPositionX()); @@ -48,7 +49,9 @@ public class ToAgvDevice { agv_rows.add(row); } // json.put("agv_rows", agv_rows); + log.info("向集控中心反馈设备状态为{}",agv_rows); acsToWmsService.feedbackAgv(agv_rows); + } } diff --git a/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java index a679fd5..29f381f 100644 --- a/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ b/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java @@ -780,7 +780,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); + dto.setPositionX(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //Y坐标 @@ -794,7 +794,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); + dto.setPositionY(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //角度 @@ -808,7 +808,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); + dto.setPositionAngle(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //电量 @@ -822,7 +822,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); + dto.setEnergyLevel(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } break; @@ -1407,7 +1407,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); + dto.setPositionX(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //Y坐标 @@ -1420,7 +1420,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); + dto.setPositionY(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //角度 @@ -1434,7 +1434,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); + dto.setPositionAngle(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } @@ -1448,7 +1448,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); + dto.setEnergyLevel(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } @@ -1826,7 +1826,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); + dto.setPositionX(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //Y坐标 @@ -1839,7 +1839,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); + dto.setPositionY(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //角度 @@ -1853,7 +1853,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); + dto.setPositionAngle(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } @@ -1867,7 +1867,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); + dto.setEnergyLevel(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } else { @@ -2946,7 +2946,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); + dto.setPositionX(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //Y坐标 @@ -2959,7 +2959,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); + dto.setPositionY(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //角度 @@ -2973,7 +2973,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); + dto.setPositionAngle(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } @@ -2987,7 +2987,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); + dto.setEnergyLevel(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } break; @@ -3596,7 +3596,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); + dto.setPositionX(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //Y坐标 @@ -3610,7 +3610,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); + dto.setPositionY(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //角度 @@ -3624,7 +3624,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); + dto.setPositionAngle(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } //电量 @@ -3638,7 +3638,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { dto = new AgvDto(); } dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); + dto.setEnergyLevel(Float.valueOf(ikey)); AgvService.updateAgvFromCache(dto); } break; diff --git a/hd/nladmin-system/src/main/resources/log/ToAgvDevice.xml b/hd/nladmin-system/src/main/resources/log/ToAgvDevice.xml new file mode 100644 index 0000000..76e6024 --- /dev/null +++ b/hd/nladmin-system/src/main/resources/log/ToAgvDevice.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/hd/nladmin-system/src/main/resources/logback-spring.xml b/hd/nladmin-system/src/main/resources/logback-spring.xml index eff5efc..8876ab8 100644 --- a/hd/nladmin-system/src/main/resources/logback-spring.xml +++ b/hd/nladmin-system/src/main/resources/logback-spring.xml @@ -27,6 +27,7 @@ https://juejin.cn/post/6844903775631572999 +