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 0cae2c0..ffe37ad 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; @@ -223,4 +224,48 @@ public class NDCAgvServiceImpl implements NDCAgvService { return AGVDeviceStatus; } + @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; + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index 47c5a88..592c8be 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Map; + /** * @author ludj * @date 2021-07-21 @@ -94,4 +96,13 @@ public class WmsToAcsController { return new ResponseEntity<>(wmstoacsService.putPlusPullAction(whereJson), HttpStatus.OK); } + @PostMapping("/createChargingTask") + @Log("创建充电任务") + @ApiOperation("创建充电任务") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity createChargingTask(@RequestBody Map whereJson) { + return new ResponseEntity<>(wmstoacsService.createChargingTask(whereJson), HttpStatus.OK); + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index 056b48b..bd24e5a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -83,5 +83,12 @@ public interface WmsToAcsService { */ Map putPlusPullAction(String whereJson); + /** + * 创建充电任务 + * @param whereJson + * @return + */ + Map createChargingTask(Map whereJson); + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index b3c5f53..8543aff 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -9,6 +9,8 @@ import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; +import org.nl.acs.agv.server.NDCAgvService; +import org.nl.acs.agv.server.impl.NDCAgvServiceImpl; import org.nl.acs.common.IDriverService; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; @@ -690,5 +692,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } - + @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; + } }