更新指令

This commit is contained in:
2022-11-25 17:56:19 +08:00
parent b1514d5793
commit 82756f4cec
6 changed files with 105 additions and 3 deletions

View File

@@ -108,6 +108,14 @@ public class InstructionController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("强制取消指令")
@ApiOperation("强制取消指令")
@PostMapping(value = "/forceCancel/{id}")
public ResponseEntity<Object> forceCancel(@RequestBody String id) throws Exception {
instructionService.forceCancel(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导出指令")
@ApiOperation("导出指令")
@GetMapping(value = "/download")

View File

@@ -162,6 +162,13 @@ public interface InstructionService {
*/
void cancel(String id) throws Exception;
/**
* 强制取消指令
*
* @param id
*/
void forceCancel(String id) throws Exception;
/**
* 取消指令不下发agv
*

View File

@@ -950,6 +950,48 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
}
@Override
public void forceCancel(String id) throws Exception {
//flag= true时取消指令
boolean flag = false;
Instruction entity = this.findById(id);
if (entity == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
TaskDto task = taskService.findByCodeFromCache(entity.getTask_code());
if (StrUtil.isEmpty(entity.getRoute_plan_code())) {
entity.setRoute_plan_code(task.getRoute_plan_code());
}
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
entity.setUpdate_time(now);
entity.setUpdate_by(currentUsername);
entity.setInstruction_status("3");
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
JSONObject json = JSONObject.fromObject(entity);
wo.update(json);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
String instnextdevice = entity.getNext_device_code();
Device device = appService.findDeviceByCode(instnextdevice);
if (device == null) {
log.debug("地址对应设备未找到");
return;
}
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
//变更三色灯状态
if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) {
String lamd_device = device.getExtraValue().get("link_three_lamp").toString();
Device lamddevice = appService.findDeviceByCode(lamd_device);
if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver();
lampThreecolorDeviceDriver.writing(0);
}
}
removeByCodeFromCache(entity.getInstruction_code());
}
@Override
public void cancelNOSendAgv(String id) throws Exception {
//flag= true时取消指令