From c40dad714213ed1a2364723ca2d667c0303f1990 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Sat, 11 Feb 2023 13:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=85=E7=94=B5=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/agv/server/NDCAgvService.java | 7 +++ .../agv/server/impl/NDCAgvServiceImpl.java | 51 +++++++++++++++++-- .../acs/hand/amb/rest/AMHandController.java | 9 ++++ .../acs/hand/amb/service/AMHandService.java | 7 +++ .../amb/service/impl/AMHandServiceImpl.java | 21 ++++++-- .../service/dto/InstructionDto.java | 4 +- 6 files changed, 91 insertions(+), 8 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index 42960b7..cac9670 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -32,4 +32,11 @@ public interface NDCAgvService { public byte[] sendAgvOneModeInst(int phase, int index,int result); public byte[] sendAgvTwoModeInst(int phase, int index,int result); + + /** + * 下发充电任务 + * @param carno + * @return + */ + public boolean createChargingTaskToNDC(String carno); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 7306756..a2c364f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -17,6 +17,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.util.CodeUtil; import org.nl.modules.wql.util.SpringContextHolder; import org.springframework.stereotype.Service; @@ -62,7 +63,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { }; log.info("下发删除AGV指令--{}", Bytes2HexString(b)); -// NDCSocketConnectionAutoRun.write(b); + OneNDCSocketConnectionAutoRun.write(b); System.out.println("下发删除agv指令数据:" + Bytes2HexString(b)); } @@ -174,9 +175,9 @@ public class NDCAgvServiceImpl implements NDCAgvService { }; } log.info("下发AGV作业指令--{}", str1); - if (StrUtil.equals(agv_system_type,"2")){ + if (StrUtil.equals(agv_system_type, "2")) { //TwoNDCSocketConnectionAutoRun.write(b); - } else if (StrUtil.equals(agv_system_type,"3")){ + } else if (StrUtil.equals(agv_system_type, "3")) { //TwoNDC2SocketConnectionAutoRun.write(b); } System.out.println("下发agv指令数据:" + Bytes2HexString(b)); @@ -297,6 +298,50 @@ public class NDCAgvServiceImpl implements NDCAgvService { return b; } + @Override + public boolean createChargingTaskToNDC(String carno) { + + byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno)); + byte carlow = (byte) IntToHexLow(Integer.parseInt(carno)); + + String instcode = CodeUtil.getNewCode("INSTRUCT_NO"); + byte instcodehigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); + byte instcodelow = (byte) IntToHexLow(Integer.parseInt(instcode)); + + String str = "十进制下发:"; + String str1 = "十六进制下发:"; + str += "carno:" + (Integer.parseInt(carno)); + str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF); + + str += "/instcode:" + (instcode); + str1 += "/instcode:" + hexToString(instcodehigh & 0xFF) + hexToString(instcodelow & 0xFF); + + System.out.println(str); + System.out.println(str1); + + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0C, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X08, + (byte) 0X64, (byte) 0X80, + (byte) 0X00, (byte) 0X01, + (byte) instcodehigh, (byte) instcodelow, + (byte) carhigh, (byte) carlow + }; + log.info("下发AGV充电任务--{}", str1); + + try{ + OneNDCSocketConnectionAutoRun.write(b); + } catch (Exception e){ + e.getMessage(); + return false; + } + System.out.println("下发agv充电任务数据:" + Bytes2HexString(b)); + return true; + } + String hexToString(int i) { return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase(); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/rest/AMHandController.java b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/rest/AMHandController.java index fd21118..c556ccb 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/rest/AMHandController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/rest/AMHandController.java @@ -196,4 +196,13 @@ public class AMHandController { return new ResponseEntity<>(HandService.callTask(whereJson), HttpStatus.OK); } + @PostMapping("/createChargingTask") + @Log("创建充电任务") + @ApiOperation("创建充电任务") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity createChargingTask(@RequestBody Map whereJson) { + return new ResponseEntity<>(HandService.createChargingTask(whereJson), HttpStatus.OK); + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/AMHandService.java b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/AMHandService.java index f804aac..c7d690d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/AMHandService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/AMHandService.java @@ -130,4 +130,11 @@ public interface AMHandService { * @return json */ JSONObject queryPoint(); + + /** + * 创建充电任务 + * @param whereJson + * @return + */ + Map createChargingTask(Map whereJson); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java index b804084..baf1967 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java @@ -13,8 +13,12 @@ import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.AgvService; import org.nl.acs.agv.server.MagicAgvService; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.agv.server.impl.AgvServiceImpl; import org.nl.acs.agv.server.impl.MagicAgvServiceImpl; +import org.nl.acs.agv.server.impl.NDCAgvServiceImpl; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.dto.DeviceDto; import org.nl.acs.device.service.impl.DeviceServiceImpl; @@ -157,6 +161,17 @@ public class AMHandServiceImpl implements AMHandService { return result; } + @Override + public Map createChargingTask(Map whereJson) { + String type = whereJson.get("type"); + NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class); + agvService.createChargingTaskToNDC(type); + JSONObject jo = new JSONObject(); + jo.put("code", "1"); + jo.put("desc", "创建成功"); + return jo; + } + @Override public Map queryPointByArea(String areaCode) { JSONArray respArr = new JSONArray(); @@ -581,7 +596,7 @@ public class AMHandServiceImpl implements AMHandService { } String task_id = instwo.getString("task_id"); Instruction instdto = (Instruction) instwo.toJavaObject(Instruction.class); - MagicAgvService agvService = SpringContextHolder.getBean(MagicAgvServiceImpl.class); + NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); /* 1 指令撤销 @@ -595,7 +610,7 @@ public class AMHandServiceImpl implements AMHandService { if (StrUtil.isEmpty(instdto.getAgv_jobno())) { instructionService.cancelNOSendAgv(inst_uuid); } else { - agvService.deleteAgvInst(instdto.getInstruction_code()); + instructionService.cancel(instdto.getInstruction_id()); } } catch (Exception e) { @@ -607,7 +622,7 @@ public class AMHandServiceImpl implements AMHandService { } if (type.equals("2")) { try { - agvService.sendAgvInstToMagic(instdto); + agvService.sendAgvInstToNDC(instdto.getAgv_system_type(),instdto); } catch (Exception e) { jo.put("code", "2"); jo.put("desc", "下发agv失败"); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java index 5a6f574..27b07a8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java @@ -238,12 +238,12 @@ public class InstructionDto implements Serializable { /** * 是否启用 */ - private String is_active; + private String is_active = "1"; /** * 是否删除 */ - private String is_delete; + private String is_delete = "0"; /** * 创建者