opt:1.手持功能修改

This commit is contained in:
2025-11-07 17:15:53 +08:00
parent eeb0b6b66f
commit 02a82ca02e
2 changed files with 76 additions and 63 deletions

View File

@@ -18,7 +18,8 @@ public enum TaskStatusEnum {
BUSY("1", "BUSY", "执行中"), BUSY("1", "BUSY", "执行中"),
FINISHED("2", "FINISHED", "完成"), FINISHED("2", "FINISHED", "完成"),
CANCEL("3", "CANCEL", "取消"), CANCEL("3", "CANCEL", "取消"),
FORCED_COMPLETION("4", "", "强制完成"), WAITING_FOR_EXECUTION("4", "", "等待执行中"),
FORCED_COMPLETION("5", "", "强制完成"),
ERROR("99", "ERROR", "异常"); ERROR("99", "ERROR", "异常");
/** /**

View File

@@ -84,8 +84,8 @@ public class HandServiceImpl implements HandService {
String device_name = device.getDevice_name(); String device_name = device.getDevice_name();
BigDecimal seq_num = device.getSeq_num(); BigDecimal seq_num = device.getSeq_num();
jo.put("device_id", device_id); jo.put("device_id", device_id);
jo.put("device_code", device_code); jo.put("value", device_code);
jo.put("device_name", device_name); jo.put("text", device_name);
jo.put("seq_num", seq_num); jo.put("seq_num", seq_num);
data.add(jo); data.add(jo);
} }
@@ -115,39 +115,39 @@ public class HandServiceImpl implements HandService {
String start_device_code2 = ""; String start_device_code2 = "";
String next_device_code2 = ""; String next_device_code2 = "";
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
if (StrUtil.equals(task_type, CommonFinalParam.TYPE_ONE)) { // if (StrUtil.equals(task_type, CommonFinalParam.TYPE_ONE)) {
String s = start_device_code.substring(start_device_code.length() - 1); // String s = start_device_code.substring(start_device_code.length() - 1);
if (StrUtil.equals("K", s)) { // if (StrUtil.equals("K", s)) {
start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "M"; // start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "M";
next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "M"; // next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "M";
jo.put("start_device_code2", start_device_code2); // jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2); // jo.put("next_device_code2", next_device_code2);
jo.put("start_point_code2", start_device_code2); // jo.put("start_point_code2", start_device_code2);
jo.put("next_point_code2", next_device_code2); // jo.put("next_point_code2", next_device_code2);
}else{ // }else{
throw new BadRequestException("起点设备名称不符"); // throw new BadRequestException("起点设备名称不符");
} // }
} else if (StrUtil.equals(task_type, CommonFinalParam.TYPE_TWO)) { // } else if (StrUtil.equals(task_type, CommonFinalParam.TYPE_TWO)) {
String s = start_device_code.substring(start_device_code.length() - 1); // String s = start_device_code.substring(start_device_code.length() - 1);
String n = next_device_code.substring(next_device_code.length() - 1); // String n = next_device_code.substring(next_device_code.length() - 1);
if (StrUtil.equals("M", s) && StrUtil.equals("M", n)) { // if (StrUtil.equals("M", s) && StrUtil.equals("M", n)) {
start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "K"; // start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "K";
next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "K"; // next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "K";
jo.put("start_device_code2", start_device_code2); // jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2); // jo.put("next_device_code2", next_device_code2);
jo.put("start_point_code2", start_device_code2); // jo.put("start_point_code2", start_device_code2);
jo.put("next_point_code2", next_device_code2); // jo.put("next_point_code2", next_device_code2);
}else if(StrUtil.equals("S", n) && StrUtil.equals("M", s)){ // }else if(StrUtil.equals("S", n) && StrUtil.equals("M", s)){
start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "X"; // start_device_code2 = next_device_code.substring(0, next_device_code.length() - 1) + "X";
next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "K"; // next_device_code2 = start_device_code.substring(0, start_device_code.length() - 1) + "K";
jo.put("start_device_code2", start_device_code2); // jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2); // jo.put("next_device_code2", next_device_code2);
jo.put("start_point_code2", start_device_code2); // jo.put("start_point_code2", start_device_code2);
jo.put("next_point_code2", next_device_code2); // jo.put("next_point_code2", next_device_code2);
}else{ // }else{
throw new BadRequestException("起点设备名称不符"); // throw new BadRequestException("起点设备名称不符");
} // }
} // }
Device startDevice = deviceAppService.findDeviceByCode(start_device_code2); Device startDevice = deviceAppService.findDeviceByCode(start_device_code2);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code2); Device nextDevice = deviceAppService.findDeviceByCode(next_device_code2);
if(StrUtil.isAllNotEmpty(start_device_code2,next_device_code2) && ObjectUtil.isAllEmpty(startDevice,nextDevice)){ if(StrUtil.isAllNotEmpty(start_device_code2,next_device_code2) && ObjectUtil.isAllEmpty(startDevice,nextDevice)){
@@ -199,8 +199,8 @@ public class HandServiceImpl implements HandService {
String region_code = dict.getValue(); String region_code = dict.getValue();
String region_name = dict.getLabel(); String region_name = dict.getLabel();
jo.put("region_id", region_id); jo.put("region_id", region_id);
jo.put("region_code", region_code); jo.put("value", region_code);
jo.put("region_name", region_name); jo.put("text", region_name);
data.add(jo); data.add(jo);
} }
JSONObject resultJson = new JSONObject(); JSONObject resultJson = new JSONObject();
@@ -327,24 +327,30 @@ public class HandServiceImpl implements HandService {
String next_point = dto.getNext_devicecode(); String next_point = dto.getNext_devicecode();
List<Task> list; List<Task> list;
if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){ list = taskserver.lambdaQuery()
list = taskserver.lambdaQuery() .orderByDesc(Task::getCreate_time)
.orderByDesc(Task::getCreate_time) .eq(Task::getTask_status, "1")
.lt(Task::getTask_status, "2") .or()
.list(); .eq(Task::getTask_status, "4")
}else { .list();
list = taskserver.lambdaQuery() // if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){
.like(Task::getStart_device_code, start_point) // list = taskserver.lambdaQuery()
.like(Task::getNext_device_code, next_point) // .orderByDesc(Task::getCreate_time)
.lt(Task::getTask_status, "2") // .lt(Task::getTask_status, "2")
.eq(Task::getTask_code, key) // .list();
.or() // }else {
.eq(Task::getVehicle_code, key) // list = taskserver.lambdaQuery()
.or() // .like(Task::getStart_device_code, start_point)
.eq(Task::getTask_id, key) // .like(Task::getNext_device_code, next_point)
.orderByDesc(Task::getCreate_time) // .lt(Task::getTask_status, "2")
.list(); // .eq(Task::getTask_code, key)
} // .or()
// .eq(Task::getVehicle_code, key)
// .or()
// .eq(Task::getTask_id, key)
// .orderByDesc(Task::getCreate_time)
// .list();
// }
// if (CollectionUtil.isEmpty(list)){ // if (CollectionUtil.isEmpty(list)){
// throw new BadRequestException("没有指令存在!"); // throw new BadRequestException("没有指令存在!");
// } // }
@@ -435,14 +441,20 @@ public class HandServiceImpl implements HandService {
//强制完成 //强制完成
Instruction instruction = instructionService.findByTaskid(task_uuid, "instruction_status <2 "); Instruction instruction = instructionService.findByTaskid(task_uuid, "instruction_status <2 ");
if (instruction!=null){ if (instruction!=null){
resultJson.put("message", "有指令未完成!"); try {
resultJson.put("data", data); instructionService.finish(instruction.getInstruction_id());
return resultJson; } catch (Exception e) {
// throw new RuntimeException(e);
resultJson.put("message", "完成任务失败:"+e);
resultJson.put("data", data);
return resultJson;
}
}else {
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task_uuid);
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskserver.finish(task_uuid);
} }
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task_uuid);
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskserver.finish(task_uuid);
} }
resultJson.put("message", "操作成功"); resultJson.put("message", "操作成功");
resultJson.put("data", data); resultJson.put("data", data);