diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index abe545203..108868c9f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -162,7 +163,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme inst_message = null; this.clearWrite(); } - if (move == 0 && last_move == 1 && mode != 0) { + if (move == 0 && last_move == 1) { this.requiresShipDeviceUpdate = false; } logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); @@ -268,8 +269,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme if (move > 0 && !requireSucess) { instruction_require(); } - if (!requiresShipDeviceUpdate) { + if (!requiresShipDeviceUpdate && move == 0) { this.shipDeviceUpdate(); + } else { + this.requiresShipDeviceUpdate = true; } break; case 4: @@ -321,9 +324,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme put("device_code", device_code); }}; - acsToWmsService.shipDeviceUpdate(param); - - this.requiresShipDeviceUpdate = true; + HttpResponse response = acsToWmsService.shipDeviceUpdate(param); + if (response == null || response.getStatus() == 200) { + this.requiresShipDeviceUpdate = true; + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 84bc2c458..b30190077 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.nl.acs.ext.wms.data.*; -import java.util.Map; - public interface AcsToWmsService { /** @@ -105,5 +103,5 @@ public interface AcsToWmsService { UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest updateLKTaskRequest); // 输送线有货变成无货时向lms请求 - void shipDeviceUpdate(JSONObject param); + HttpResponse shipDeviceUpdate(JSONObject param); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index c84b1e13e..9970c09fa 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -18,15 +18,11 @@ import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import java.util.Map; - @Service @RequiredArgsConstructor @Slf4j @@ -502,7 +498,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } @Override - public void shipDeviceUpdate(JSONObject param) { + public HttpResponse shipDeviceUpdate(JSONObject param) { try { MDC.put(log_file_type, log_type); log.info("shipDeviceUpdate-----输入参数{}", param); @@ -511,7 +507,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { AddressDto addressDto = addressService.findByCode("shipDeviceUpdate"); String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; - HttpRequest + return HttpRequest .post(url) .body(param.toString()) .execute(); @@ -521,5 +517,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } finally { MDC.remove(log_file_type); } + return null; } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java index 841741cf1..a6466fea3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java @@ -145,4 +145,12 @@ public class InstructionController { public ResponseEntity queryByTaskId(@RequestBody String taskId) { return new ResponseEntity<>(instructionService.getByTaskId(taskId), HttpStatus.OK); } + + @Log("初始化") + @ApiOperation("初始化") + @PostMapping(value = "/init/{id}") + public ResponseEntity init(@RequestBody String id) throws Exception { + instructionService.init(id); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 107f5c395..62e5583a8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -275,4 +275,5 @@ public interface InstructionService { boolean createLkInst(String type,Instruction inst); + void init(String id); } 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 34198859d..2aeacc557 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 @@ -17,8 +17,10 @@ import org.nl.acs.agv.server.*; import org.nl.acs.auto.initial.ApplicationAutoInitial; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; @@ -1361,4 +1363,36 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); return pattern.matcher(str).matches(); } + + @Override + public void init(String id) { + Instruction inst = this.findById(id); + if (inst == null) { + throw new BadRequestException("指令不存在或已删除"); + } + if ("2".equals(inst.getInstruction_status())) { + throw new BadRequestException("指令已经完成"); + } + + Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + DeviceDriver startDeviceDriver = startDevice.getDeviceDriver(); + if (startDeviceDriver instanceof SiemensConveyorDeviceDriver) { + Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + + List> list = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("code", "to_target"); + map.put("value", nextDevice.getExtraValue().get("address").toString()); + list.add(map); + Map map2 = new HashMap<>(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap<>(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + ((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list); + } + } } diff --git a/acs/nladmin-ui/src/api/acs/instruction/instruction.js b/acs/nladmin-ui/src/api/acs/instruction/instruction.js index 5d8bec045..df0cda541 100644 --- a/acs/nladmin-ui/src/api/acs/instruction/instruction.js +++ b/acs/nladmin-ui/src/api/acs/instruction/instruction.js @@ -70,4 +70,12 @@ export function reload() { }) } -export default { add, edit, del, finish, cancel, forceCancel, queryUnFinish, queryByTaskId, reload } +export function init(instruction_id) { + return request({ + url: 'api/instruction/init/' + instruction_id, + method: 'post', + data: instruction_id + }) +} + +export default { add, edit, del, finish, cancel, forceCancel, queryUnFinish, queryByTaskId, reload, init } diff --git a/acs/nladmin-ui/src/views/acs/instruction/index.vue b/acs/nladmin-ui/src/views/acs/instruction/index.vue index d3af064a9..92eb8a07f 100644 --- a/acs/nladmin-ui/src/views/acs/instruction/index.vue +++ b/acs/nladmin-ui/src/views/acs/instruction/index.vue @@ -180,6 +180,7 @@ 完成 取消 强制取消 + 初始化 @@ -320,6 +321,14 @@ export default { console.log(err.response.data.message) }) }, + init(index, row) { + crudInstruction.init(row.instruction_id).then(res => { + this.crud.toQuery() + this.crud.notify('初始化成功', CRUD.NOTIFICATION_TYPE.SUCCESS) + }).catch(err => { + console.log(err.response.data.message) + }) + }, reload() { crudInstruction.reload().then(res => { this.crud.toQuery() @@ -346,6 +355,9 @@ export default { case 'c':// 强制取消 this.forceCancel(command.index, command.row) break + case 'd':// 初始化 + this.init(command.index, command.row) + break } }