add:驱动优化
This commit is contained in:
@@ -242,7 +242,7 @@ public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
log.info("运行中");
|
||||
break;
|
||||
case 5:
|
||||
if (move == 1 && !requireSucess && task > 0 && task1 > 0) {
|
||||
if (move == 1 && !requireSucess && task1 > 0) {
|
||||
//申请套管校验
|
||||
bushingSucess();
|
||||
} else if (move != 1) {
|
||||
@@ -326,11 +326,12 @@ public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
private synchronized void bushingSucess() {
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
Instruction inst1 = instructionService.findByCode(String.valueOf(task));
|
||||
// Instruction inst1 = instructionService.findByCode(String.valueOf(task));
|
||||
Instruction inst2 = instructionService.findByCode(String.valueOf(task1));
|
||||
String task_code1 = inst1.getTask_code();
|
||||
// String task_code1 = inst1.getTask_code();
|
||||
String task_code1 = String.valueOf(task);
|
||||
String task_code2 = inst2.getTask_code();
|
||||
if (Long.parseLong(task_code1) < 1 && Long.parseLong(task_code2) < 1) {
|
||||
if (Long.parseLong(task_code1) < 0 && Long.parseLong(task_code2) < 0) {
|
||||
message = "任务ACS创建,不反馈LMS套轴完成";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.plugging_unplugging_machine.PluggingUnpluggingMachineDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.rgv.RgvDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
@@ -489,6 +490,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
if (applyManipulatorActionResponse.getstatus() == 200) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请放货点请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
String put_device_code = applyManipulatorActionResponse.getDevice_code();
|
||||
// updateData(put_device_code);
|
||||
Device device = deviceAppService.findDeviceByCode(put_device_code);
|
||||
String to_putpoint = device.getExtraValue().get("address").toString();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
@@ -517,6 +519,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
if (applyManipulatorActionResponse.getstatus() == 200) {
|
||||
String get_device_code = applyManipulatorActionResponse.getDevice_code();
|
||||
// updateData1(get_device_code);
|
||||
Device device = deviceAppService.findDeviceByCode(get_device_code);
|
||||
String to_new_getpoint = device.getExtraValue().get("address").toString();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
@@ -646,11 +649,11 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
if (mode == 3 && action == 8 && move == 0) {
|
||||
if (inst1 != null) {
|
||||
try {
|
||||
feedbackSucess = true;
|
||||
finish_instruction(inst1);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", "8");
|
||||
this.writing(map);
|
||||
feedbackSucess = true;
|
||||
message = "放货完成";
|
||||
} catch (Exception e) {
|
||||
message = "放货失败";
|
||||
@@ -680,6 +683,34 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
}
|
||||
}
|
||||
|
||||
private void updateData(String poinCode) {
|
||||
Instruction instructionUpdate = checkInst();
|
||||
TaskDto taskUpdate = new TaskDto();
|
||||
instructionUpdate.setNext_point_code(poinCode);
|
||||
instructionUpdate.setNext_device_code(poinCode);
|
||||
instructionUpdate.setRemark("申请新放货点");
|
||||
taskUpdate.setNext_point_code(poinCode);
|
||||
taskUpdate.setNext_device_code(poinCode);
|
||||
taskUpdate.setTask_id(instructionUpdate.getTask_id());
|
||||
taskUpdate.setRemark("申请新放货点");
|
||||
instructionService.update(instructionUpdate);
|
||||
taskserver.update(taskUpdate);
|
||||
}
|
||||
|
||||
private void updateData1(String poinCode) {
|
||||
Instruction instructionUpdate = checkInst();
|
||||
TaskDto taskUpdate = new TaskDto();
|
||||
instructionUpdate.setStart_point_code(poinCode);
|
||||
instructionUpdate.setStart_device_code(poinCode);
|
||||
instructionUpdate.setRemark("申请新取货点");
|
||||
taskUpdate.setStart_point_code(poinCode);
|
||||
taskUpdate.setStart_device_code(poinCode);
|
||||
taskUpdate.setTask_id(instructionUpdate.getTask_id());
|
||||
taskUpdate.setRemark("申请新取货点");
|
||||
instructionService.update(instructionUpdate);
|
||||
taskserver.update(taskUpdate);
|
||||
}
|
||||
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
@@ -955,6 +986,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code());
|
||||
Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code());
|
||||
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
|
||||
PluggingUnpluggingMachineDeviceDriver pluggingUnpluggingMachineDeviceDriver;
|
||||
if (startdevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
|
||||
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
if (siemensConveyorDeviceDriver.getMove() != 1) {
|
||||
@@ -968,6 +1000,13 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (nextdevice.getDeviceDriver() instanceof PluggingUnpluggingMachineDeviceDriver ){
|
||||
pluggingUnpluggingMachineDeviceDriver = (PluggingUnpluggingMachineDeviceDriver) nextdevice.getDeviceDriver();
|
||||
if (pluggingUnpluggingMachineDeviceDriver.getMove() != 0) {
|
||||
notCreateInstMessage = "就绪任务未创建指令原因->pluggingUnpluggingMachineDeviceDriver:" + pluggingUnpluggingMachineDeviceDriver.getDevice_code() + "光电有货,无法生成指令!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String taskid = task.getTask_id();
|
||||
String taskcode = task.getTask_code();
|
||||
|
||||
@@ -322,7 +322,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(var17.getStackTrace()));
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -511,6 +511,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
//按照优先级排序 优先级相等按照创建时间排序
|
||||
taskDtos = this.sortTask(taskDtos);
|
||||
taskDto = taskDtos.get(0);
|
||||
if (getDeviceCode.endsWith("X")) {
|
||||
Boolean result = this.checkIsSafe(getDeviceCode, taskDto);
|
||||
if (!result) {
|
||||
taskDto = null;
|
||||
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||
return flag;
|
||||
} else {
|
||||
@@ -542,11 +550,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
//按照优先级排序 优先级相等按照创建时间排序
|
||||
taskDtos = this.sortTask(taskDtos);
|
||||
taskDto = taskDtos.get(0);
|
||||
if (backGetDeviceCode.endsWith("X")) {
|
||||
Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
|
||||
if (taskDto.getNext_device_code().endsWith("S")) {
|
||||
Boolean result = this.checkIsSafe2(taskDto.getNext_device_code(), taskDto);
|
||||
if (!result) {
|
||||
taskDto = null;
|
||||
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
|
||||
notCreateInstMessage = "该设备存在下工位任务,此任务无法执行!";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -559,11 +567,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
//按照优先级排序 优先级相等按照创建时间排序
|
||||
taskDtos = this.sortTask(taskDtos);
|
||||
taskDto = taskDtos.get(0);
|
||||
if (backGetDeviceCode.endsWith("X")) {
|
||||
Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
|
||||
if (taskDto.getNext_device_code().endsWith("S")) {
|
||||
Boolean result = this.checkIsSafe2(taskDto.getNext_device_code(), taskDto);
|
||||
if (!result) {
|
||||
taskDto = null;
|
||||
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
|
||||
notCreateInstMessage = "该设备存在下工位任务,此任务无法执行!";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -647,11 +655,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
//按照优先级排序 优先级相等按照创建时间排序
|
||||
taskDtos = this.sortTask(taskDtos);
|
||||
taskDto = taskDtos.get(0);
|
||||
if (backGetDeviceCode.endsWith("X")) {
|
||||
Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
|
||||
if (taskDto.getNext_device_code().endsWith("S")) {
|
||||
Boolean result = this.checkIsSafe2(taskDto.getNext_device_code(), taskDto);
|
||||
if (!result) {
|
||||
taskDto = null;
|
||||
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
|
||||
notCreateInstMessage = "该设备存在下工位任务,此任务无法执行!";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -664,11 +672,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
//按照优先级排序 优先级相等按照创建时间排序
|
||||
taskDtos = this.sortTask(taskDtos);
|
||||
taskDto = taskDtos.get(0);
|
||||
if (backGetDeviceCode.endsWith("X")) {
|
||||
Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto);
|
||||
if (taskDto.getNext_device_code().endsWith("S")) {
|
||||
Boolean result = this.checkIsSafe2(taskDto.getNext_device_code(), taskDto);
|
||||
if (!result) {
|
||||
taskDto = null;
|
||||
notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!";
|
||||
notCreateInstMessage = "该设备存在下工位任务,此任务无法执行!";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -686,6 +694,13 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (taskDto.getNext_device_code().endsWith("S")) {
|
||||
Boolean result = this.checkIsSafe2(taskDto.getNext_device_code(), taskDto);
|
||||
if (!result) {
|
||||
notCreateInstMessage = "该设备存在下工位任务,此任务无法执行!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
flag = this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList);
|
||||
if (flag) {
|
||||
notCreateInstMessage = "";
|
||||
@@ -1632,10 +1647,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
//双任务 后工位反馈任务完成 并反馈
|
||||
if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && task2 > 0 && type == 3) {
|
||||
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task1));
|
||||
if (to_command1 != 5) {
|
||||
this.writing("to_command1", "5");
|
||||
}
|
||||
this.setNow_steps_type3(8);
|
||||
this.setNow_steps_type3(10);
|
||||
this.setNow_steps_type3(0);
|
||||
this.finish_instruction(instruction);
|
||||
|
||||
} else {
|
||||
if (this.getNow_steps_type3() == 7) {
|
||||
feedMessage = "双任务后工位放货完成后未反馈原因-->";
|
||||
@@ -1774,9 +1793,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
if (to_command2 != 5) {
|
||||
this.writing("to_command2", "5");
|
||||
}
|
||||
this.setNow_steps_type3(10);
|
||||
this.setNow_steps_type3(0);
|
||||
this.finish_instruction(inst1);
|
||||
this.setNow_steps_type3(8);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1807,7 +1824,15 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
|
||||
public boolean checkIsSafe(String device_code, TaskDto dto) {
|
||||
String newDevice_code = forametDevice_code(device_code);
|
||||
List<TaskDto> list = taskserver.queryTaskByDeviceCode(newDevice_code);
|
||||
List<TaskDto> list = taskserver.queryUnfinishTaskByDeviceCode(newDevice_code);
|
||||
if (list.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkIsSafe2(String device_code, TaskDto dto) {
|
||||
String newDevice_code = forametDevice_code2(device_code);
|
||||
List<TaskDto> list = taskserver.queryUnfinishTaskByDeviceCode2(newDevice_code);
|
||||
if (list.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -1821,5 +1846,12 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
return device_code;
|
||||
}
|
||||
|
||||
public String forametDevice_code2(String device_code) {
|
||||
if (device_code.endsWith("S")) {
|
||||
return device_code.substring(0, device_code.length() - 1) + "X";
|
||||
}
|
||||
return device_code;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -159,4 +159,12 @@ public class WmsToAcsController {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
return new ResponseEntity<>(wmstoacsService.queryRGVStatus(jsonObject),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/toNoticeACSFinishTask")
|
||||
@Log(value = "上位下发完成任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS)
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> toNoticeACSFinishTask(@RequestBody JSONArray jsonArray) throws Exception {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
return new ResponseEntity<>(wmstoacsService.finishTask(jsonObject),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,10 @@ public interface WmsToAcsService {
|
||||
Map<String, Object> queryRGVStatus(JSONObject jsonObject);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* LMS下发任务完成
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> finishTask(JSONObject jsonObject) throws Exception;
|
||||
}
|
||||
|
||||
@@ -60,8 +60,10 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceExtraManageDto;
|
||||
import org.nl.acs.opc.DeviceType;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.enums.TaskStatusEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.domain.Dict;
|
||||
import org.nl.modules.system.service.DictDetailService;
|
||||
@@ -1494,4 +1496,47 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> finishTask(JSONObject jsonObject) {
|
||||
log.info("finishTask--------------:输入参数" + jsonObject.toString());
|
||||
JSONObject resp = new JSONObject();
|
||||
if (StrUtil.isEmpty(jsonObject.getString("task_code"))) {
|
||||
resp.put("status", 400);
|
||||
resp.put("message", "未传递任务号:" + jsonObject.getString("task_code") + "无法查询任务信息");
|
||||
log.info("finishTask--------------:输出参数" + resp.toString());
|
||||
return resp;
|
||||
}
|
||||
String task_code = jsonObject.getString("task_code");
|
||||
TaskDto taskDto = taskService.findUnfinishByTaskCode(task_code);
|
||||
//没有执行中或者就绪的任务
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
resp.put("status", 200);
|
||||
resp.put("message", "任务已成功");
|
||||
log.info("finishTask--------------:输出参数1" + resp.toString());
|
||||
return resp;
|
||||
}
|
||||
Instruction instruction = instructionService.findUnFinishByTaskcode(task_code);
|
||||
//只有任务没有指令
|
||||
if (ObjectUtil.isEmpty(instruction)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(taskDto.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
|
||||
taskService.forcefinish(taskIdAndStatusDTO);
|
||||
resp.put("status", 200);
|
||||
resp.put("message", "任务已成功");
|
||||
log.info("finishTask--------------:输出参数2" + resp.toString());
|
||||
return resp;
|
||||
}
|
||||
//指令和任务都存在
|
||||
try {
|
||||
instructionService.forceFinish(instruction);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
resp.put("status", 200);
|
||||
resp.put("message", "完成任务成功");
|
||||
log.info("finishTask--------------:输出参数3" + resp.toString());
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +86,14 @@ public interface InstructionService {
|
||||
*/
|
||||
Instruction findByTaskcode(String code);
|
||||
|
||||
/**
|
||||
* 根据任务code查询
|
||||
*
|
||||
* @param code code
|
||||
* @return Instruction
|
||||
*/
|
||||
Instruction findUnFinishByTaskcode(String code);
|
||||
|
||||
/**
|
||||
* 根据指令号查询
|
||||
* @param code
|
||||
@@ -170,6 +178,13 @@ public interface InstructionService {
|
||||
*/
|
||||
void finish(Instruction dto) throws Exception;
|
||||
|
||||
/**
|
||||
* 强制完成指令
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
void forceFinish(Instruction dto) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 完成并创建下一条指令
|
||||
|
||||
@@ -260,6 +260,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Instruction findByInsructionCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
@@ -281,6 +282,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction findUnFinishByTaskcode(String code) {
|
||||
Iterator var3 = instructions.iterator();
|
||||
while (var3.hasNext()) {
|
||||
Instruction instruction = (Instruction) var3.next();
|
||||
if (StrUtil.equals(instruction.getTask_code(), code)
|
||||
&& (StrUtil.equals(instruction.getInstruction_status(), "0") || (StrUtil.equals(instruction.getInstruction_status(), "1")))) {
|
||||
return instruction;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Instruction findByTaskcodeCache(String code) {
|
||||
Iterator var3 = instructions.iterator();
|
||||
while (var3.hasNext()) {
|
||||
@@ -452,6 +466,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
+",inst_system_type:" + dto.getAgv_system_type());
|
||||
}
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
dto.setSend_status("2");
|
||||
} catch (Exception e){
|
||||
dto.setSend_status("2");
|
||||
dto.setRemark(e.getMessage());
|
||||
@@ -847,7 +862,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
removeByCodeFromCache(dto.getInstruction_code());
|
||||
try{
|
||||
instructions.add(dto);
|
||||
log.warn("指令添加到指令列表5:"+dto.toString());
|
||||
log.warn(":"+dto.toString());
|
||||
} catch (Exception e){
|
||||
log.warn("指令添加到指令列表异常:" + dto.toString() +e.getMessage());
|
||||
}
|
||||
@@ -1111,6 +1126,92 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
// this.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forceFinish(Instruction dto) {
|
||||
String now = DateUtil.now();
|
||||
dto.setInstruction_status("2");
|
||||
dto.setUpdate_time(now);
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.update(json);
|
||||
String instnextdevice = dto.getNext_device_code();
|
||||
String insttaskid = dto.getTask_id();
|
||||
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0);
|
||||
TaskDto obj = taskjson.toJavaObject(TaskDto.class);
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(obj.getRequest_again(), "0")) {
|
||||
if(StrUtil.equals(obj.getTask_type(),"8")){
|
||||
//中转为空
|
||||
if(StrUtil.isEmpty(obj.getPut_device_code())){
|
||||
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
|
||||
taskService.finish(taskIdAndStatusDTO);
|
||||
} else {
|
||||
finishAndCreateNextInst(dto);
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
|
||||
finishAndCreateHXInst(dto);
|
||||
} else if (StrUtil.equals(obj.getPut_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
|
||||
taskService.finish(taskIdAndStatusDTO);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(obj.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(String.valueOf(TaskStatusEnum.FINISHED.getIndex()));
|
||||
taskService.forcefinish(taskIdAndStatusDTO);
|
||||
} else {
|
||||
finishAndCreateNextInst(dto);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
log.debug("地址对应设备未找到");
|
||||
return;
|
||||
}
|
||||
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
|
||||
// device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||
// }
|
||||
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", dto.getStart_point_code());
|
||||
jo.put("hasGoodStatus", "0");
|
||||
jo.put("material_type", "");
|
||||
jo.put("batch", "");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("device_code", dto.getNext_point_code());
|
||||
jo1.put("hasGoodStatus", "1");
|
||||
jo1.put("material_type", dto.getMaterial());
|
||||
jo1.put("batch", dto.getBatch());
|
||||
deviceService.changeDeviceStatus(jo1);
|
||||
|
||||
removeByCodeFromCache(dto.getInstruction_code());
|
||||
// this.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishAndCreateNextInst(Instruction dto) {
|
||||
|
||||
@@ -85,6 +85,14 @@ public interface TaskService {
|
||||
*/
|
||||
TaskDto findByTaskCode(String task_code);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param task_code
|
||||
* @return AcsTask
|
||||
*/
|
||||
TaskDto findUnfinishByTaskCode(String task_code);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有未完成任务
|
||||
@@ -115,6 +123,16 @@ public interface TaskService {
|
||||
*/
|
||||
List<TaskDto> queryTaskByDeviceCode(String device_code);
|
||||
|
||||
/**
|
||||
* 根据设备号查询未完成的任务
|
||||
*/
|
||||
List<TaskDto> queryUnfinishTaskByDeviceCode(String device_code);
|
||||
|
||||
/**
|
||||
* 根据设备号查询未完成的任务
|
||||
*/
|
||||
List<TaskDto> queryUnfinishTaskByDeviceCode2(String device_code);
|
||||
|
||||
/**
|
||||
* 根据设备号查询未执行的任务
|
||||
*/
|
||||
@@ -205,6 +223,13 @@ public interface TaskService {
|
||||
*/
|
||||
void finish(TaskIdAndStatusDTO taskIdAndStatus);
|
||||
|
||||
/**
|
||||
* 强制完成任务
|
||||
*
|
||||
* @param taskIdAndStatus
|
||||
*/
|
||||
void forcefinish(TaskIdAndStatusDTO taskIdAndStatus);
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
*
|
||||
|
||||
@@ -3,7 +3,9 @@ package org.nl.acs.task.service.dto;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.jinterop.dcom.core.JIUnsignedFactory;
|
||||
import org.jinterop.dcom.core.JIUnsignedInteger;
|
||||
import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
|
||||
@@ -19,6 +21,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
* @date 2021-03-18
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaskDto implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -318,6 +322,7 @@ public class TaskDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 行架任务类型
|
||||
* 6
|
||||
*/
|
||||
private String truss_type;
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
Integer currentPageNumber = page.getPageNumber() + 1;
|
||||
Integer pageMaxSize = page.getPageSize();
|
||||
for (TaskDto taskDto : taskList) {
|
||||
if("10".equals(taskDto.getTask_type())){
|
||||
if ("10".equals(taskDto.getTask_type())) {
|
||||
cn.hutool.json.JSONArray jsonArray = JSONUtil.parseArray(taskDto.getPaper_array());
|
||||
List<Paper> papers = JSONUtil.toList(jsonArray, Paper.class);
|
||||
StringBuilder task_paper = new StringBuilder();
|
||||
@@ -333,6 +333,20 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findUnfinishByTaskCode(String task_code) {
|
||||
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (StrUtil.equals(task.getTask_code(), task_code) && (StrUtil.equals(task.getTask_status(), "0") || (StrUtil.equals(task.getTask_status(), "1")))) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryAllUnfinished(Map whereJson) {
|
||||
@@ -364,6 +378,34 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryUnfinishTaskByDeviceCode(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getStart_device_code().equals(device_code)
|
||||
&& (StrUtil.equals(task.getTask_status(), "0") || (StrUtil.equals(task.getTask_status(), "1")))) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryUnfinishTaskByDeviceCode2(String device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto task = iterator.next();
|
||||
if (task.getNext_device_code().equals(device_code)
|
||||
&& (StrUtil.equals(task.getTask_status(), "0") || (StrUtil.equals(task.getTask_status(), "1")))) {
|
||||
list.add(task);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByStartDeviceCode(String start_device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
@@ -472,6 +514,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code) {
|
||||
List<TaskDto> list = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
@@ -840,6 +883,22 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forcefinish(TaskIdAndStatusDTO taskIdAndStatus) {
|
||||
TaskDto entity = this.findById(taskIdAndStatus.getTask_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setTask_status("2");
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
|
||||
wo.update(json);
|
||||
removeByCodeFromCache(entity.getTask_code());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancel(String id) throws Exception {
|
||||
@@ -1536,12 +1595,12 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByTaskType(String taskType,String taskStatus) {
|
||||
public List<TaskDto> queryTaskByTaskType(String taskType, String taskStatus) {
|
||||
List<TaskDto> taskDtoList = new ArrayList<>();
|
||||
Iterator<TaskDto> iterator = tasks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TaskDto taskDto = iterator.next();
|
||||
if(taskDto.getTask_type().equals(taskType) && taskStatus.equals(taskDto.getTask_status())){
|
||||
if (taskDto.getTask_type().equals(taskType) && taskStatus.equals(taskDto.getTask_status())) {
|
||||
taskDtoList.add(taskDto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user