opt:1.添加多任务 2.修复自动取货、自动放货 无法发送升降叉问题。

This commit is contained in:
2025-02-28 18:00:14 +08:00
parent 60b7af1de0
commit a3e8ebd110
7 changed files with 161 additions and 10 deletions

View File

@@ -0,0 +1,83 @@
package org.nl.agv.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author liejiu
*/
@Data
@TableName("st_task_info")
public class TaskInfo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("task_uuid")
private String taskUuid;
@TableField("task_code")
private String taskCode;
@TableField("task_type")
private String taskType;
@TableField("task_type_name")
private String taskTypeName;
@TableField("en_task_type_name")
private String enTaskTypeName;
@TableField("zh_task_type_name")
private String zhTaskTypeName;
@TableField("task_status")
private String taskStatus;
@TableField("task_status_name")
private String taskStatusName;
@TableField("en_task_status_name")
private String enTaskStatusName;
@TableField("zh_task_status_name")
private String zhTaskStatusName;
@TableField("next_point_code")
private String nextPointCode;
@TableField("next_point_code2")
private String nextPointCode2;
@TableField("is_delete")
private String isDelete;
@TableField("seq_num")
private BigDecimal seqNum;
@TableField("date")
private String date;
@TableField("create_by")
private String createBy;
@TableField("create_time")
private String createTime;
@TableField("is_manualfinished")
private String isManualfinished;
@TableField("update_by")
private String updateBy;
@TableField("update_time")
private String updateTime;
@TableField("step")
private String step;
}

View File

@@ -88,4 +88,11 @@ public class TaskController {
public ResponseEntity<Object> check(@RequestBody Map<String, String> whereJson) { public ResponseEntity<Object> check(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(taskService.check(whereJson), HttpStatus.OK); return new ResponseEntity<>(taskService.check(whereJson), HttpStatus.OK);
} }
@PostMapping("/queryTaskStatus")
@Log("根据任务编号查询任务状态")
@ApiOperation("根据任务编号查询任务状态")
public ResponseEntity<Object> findTaskStatusByCode(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(taskService.findTaskStatusByCode(whereJson), HttpStatus.OK);
}
} }

View File

@@ -2,6 +2,9 @@
package org.nl.agv.service; package org.nl.agv.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.agv.entity.TaskInfo;
import java.util.Map; import java.util.Map;
/** /**
@@ -9,7 +12,7 @@ import java.util.Map;
* @description 服务接口 * @description 服务接口
* @date 2021-09-02 * @date 2021-09-02
**/ **/
public interface TaskService { public interface TaskService extends IService<TaskInfo> {
/** /**
* 查询头部agv状态 * 查询头部agv状态
* *
@@ -76,4 +79,12 @@ public interface TaskService {
*/ */
Map<String, Object> check( Map<String, String> jsonObject); Map<String, Object> check( Map<String, String> jsonObject);
/**
* 根据任务编号查询任务状态
*
* @param
* @return Map<String, Object>
*/
Map<String, Object> findTaskStatusByCode(Map<String, String> jsonObject);
} }

View File

@@ -25,6 +25,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.mchange.lang.LongUtils; import com.mchange.lang.LongUtils;
import edu.wpi.rail.jrosbridge.services.ServiceResponse; import edu.wpi.rail.jrosbridge.services.ServiceResponse;
import javafx.concurrent.Task;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -41,6 +42,7 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.system.util.CodeUtil; import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -586,7 +588,7 @@ public class HomeServiceImpl implements HomeService {
JSONObject currentTask = (JSONObject)redisUtils.get("currentTask"); JSONObject currentTask = (JSONObject)redisUtils.get("currentTask");
boolean bo = false; boolean bo = false;
if (TaskTypeEnum.TAKE.getCode().equals(currentTask.getString("task_type")) || TaskTypeEnum.PUT.getCode().equals(currentTask.getString("task_type"))){ if (TaskTypeEnum.TAKE.getCode().equals(currentTask.getString("task_type")) || TaskTypeEnum.PUT.getCode().equals(currentTask.getString("task_type"))){
if ("0".equals(debugInfoJson.get("PathFollow_Enable")) && debugInfoJson.get("CurNodeID").equals(currentTask.getString("next_point_code2")) && taskjo.getString("step") != null){ if ("0".equals(debugInfoJson.get("PathFollow_Enable")) && debugInfoJson.get("CurNodeID").equals(currentTask.getString("next_point_code2")) && StringUtils.isNotBlank(taskjo.getString("step"))){
bo = true; bo = true;
} }
}else{ }else{

View File

@@ -22,15 +22,19 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import edu.wpi.rail.jrosbridge.services.ServiceResponse; import edu.wpi.rail.jrosbridge.services.ServiceResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.nl.agv.entity.TaskInfo;
import org.nl.agv.enu.TaskSendBackStatusEnum; import org.nl.agv.enu.TaskSendBackStatusEnum;
import org.nl.agv.enu.TaskStatusEnum; import org.nl.agv.enu.TaskStatusEnum;
import org.nl.agv.enu.TaskTypeEnum; import org.nl.agv.enu.TaskTypeEnum;
import org.nl.agv.service.TaskService; import org.nl.agv.service.TaskService;
import org.nl.agv.service.mapper.TaskInfoMapper;
import org.nl.agv.unit.sendToAgvUtil; import org.nl.agv.unit.sendToAgvUtil;
import org.nl.common.utils.LangUtils; import org.nl.common.utils.LangUtils;
import org.nl.common.utils.SecurityUtils; import org.nl.common.utils.SecurityUtils;
@@ -41,6 +45,7 @@ import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -61,13 +66,16 @@ import static org.nl.common.utils.LangUtils.getLanguage;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@EnableScheduling @EnableScheduling
public class TaskServiceServiceImpl implements TaskService { public class TaskServiceServiceImpl extends ServiceImpl<TaskInfoMapper, TaskInfo> implements TaskService {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Value("${spring.profiles.active}") @Value("${spring.profiles.active}")
private String isProd; private String isProd;
@Autowired
private TaskInfoMapper taskInfoMapper;
public static JSONObject pointJson = new JSONObject(); public static JSONObject pointJson = new JSONObject();
/** /**
@@ -281,9 +289,11 @@ public class TaskServiceServiceImpl implements TaskService {
* 下发任务 * 下发任务
*/ */
@Override @Override
public Map<String, Object> confirmSinglePoint(Map<String, String> jsonObject) { @Transactional(rollbackFor = Exception.class)
public synchronized Map<String, Object> confirmSinglePoint(Map<String, String> jsonObject) {
String point_code = jsonObject.get("point_code"); String point_code = jsonObject.get("point_code");
String type = jsonObject.get("type"); String type = jsonObject.get("type");
String taskName = jsonObject.get("taskName");
JSONObject returnjo = new JSONObject(); JSONObject returnjo = new JSONObject();
JSONObject taskjo = new JSONObject(); JSONObject taskjo = new JSONObject();
if (StringUtils.isBlank(point_code) || StringUtils.isBlank((type))) { if (StringUtils.isBlank(point_code) || StringUtils.isBlank((type))) {
@@ -356,7 +366,7 @@ public class TaskServiceServiceImpl implements TaskService {
taskjo.put("task_type", type); taskjo.put("task_type", type);
taskjo.put("seq_num", type.equals(TaskTypeEnum.RETURN.getCode()) ? getSeqNum() : seq_num); taskjo.put("seq_num", type.equals(TaskTypeEnum.RETURN.getCode()) ? getSeqNum() : seq_num);
taskjo.put("task_uuid", IdUtil.simpleUUID()); taskjo.put("task_uuid", IdUtil.simpleUUID());
taskjo.put("task_code", CodeUtil.getNewCode("TASK_NO")); taskjo.put("task_code", StringUtils.isNotBlank(taskName) ? taskName : CodeUtil.getNewCode("TASK_NO"));
taskjo.put("next_point_code", point_code); taskjo.put("next_point_code", point_code);
taskjo.put("is_delete", "0"); taskjo.put("is_delete", "0");
taskjo.put("date", DateUtil.today()); taskjo.put("date", DateUtil.today());
@@ -401,11 +411,13 @@ public class TaskServiceServiceImpl implements TaskService {
returnjo.put("code", "1"); returnjo.put("code", "1");
returnjo.put("desc", LangUtils.getMsgLanguage("OperationSuccess", null)); returnjo.put("desc", LangUtils.getMsgLanguage("OperationSuccess", null));
redisUtils.set("currentTask",taskjo); redisUtils.set("currentTask",taskjo);
return returnjo;
} catch (Exception e) { } catch (Exception e) {
log.error("confirmPoint-下发任务失败:{}", e.getMessage()); log.error("confirmPoint-下发任务失败:{}", e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "confirmPoint:" + LangUtils.getMsgLanguage("CommunicationFail", null) : "confirmPoint:" + e.getMessage()); returnjo.put("code", "0");
returnjo.put("desc", LangUtils.getMsgLanguage("CommunicationFail", null));
// throw new BadRequestException(HttpStatus.OK,e.getMessage() == null ? "confirmPoint:" + LangUtils.getMsgLanguage("CommunicationFail", null) : "confirmPoint:" + e.getMessage());
} }
return returnjo;
} }
private static Integer getSeqNum() { private static Integer getSeqNum() {
@@ -477,8 +489,10 @@ public class TaskServiceServiceImpl implements TaskService {
if (redisUtils.hasKey("currentTask")){ if (redisUtils.hasKey("currentTask")){
JSONObject currentTask = (JSONObject)redisUtils.get("currentTask"); JSONObject currentTask = (JSONObject)redisUtils.get("currentTask");
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO"); WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
String sqlWhere = "task_code in (" + currentTask.getString("task_code") + ")"; JSONObject taskjo = taskTable.query("task_code='" + currentTask.getString("task_code") + "'").uniqueResult(0);
taskTable.delete(sqlWhere); taskjo.put("is_delete", "1");
taskjo.put("update_by", SecurityUtils.getCurrentNickName());
taskTable.update(taskjo);
//清除车辆上的任务 //清除车辆上的任务
ServiceResponse response = sendToAgvUtil.send("HMIRebornInitNow"); ServiceResponse response = sendToAgvUtil.send("HMIRebornInitNow");
// String code = "0".equals(response.toJsonObject().get("result").toString()) ? "1" : "0"; // String code = "0".equals(response.toJsonObject().get("result").toString()) ? "1" : "0";
@@ -564,6 +578,28 @@ public class TaskServiceServiceImpl implements TaskService {
return returnjo; return returnjo;
} }
@Override
public Map<String, Object> findTaskStatusByCode(Map<String, String> jsonObject) {
JSONObject returnjo = new JSONObject();
String taskCode = jsonObject.get("taskName");
if (StringUtils.isBlank(taskCode)) {
returnjo.put("result", "任务号不能为空");
returnjo.put("code", "0");
return returnjo;
}
TaskInfo taskInfo = taskInfoMapper.selectOne( new LambdaQueryWrapper<>(TaskInfo.class)
.eq(TaskInfo::getTaskCode, taskCode)
);
if (ObjectUtil.isEmpty(taskInfo)){
returnjo.put("result", "未找到任务号对应的任务");
returnjo.put("code", "0");
return returnjo;
}
returnjo.put("result", taskInfo);
returnjo.put("code", "200");
return returnjo;
}
// @Override // @Override
// public Map<String, Object> confirmPoint1(Map<String, String> jsonObject) { // public Map<String, Object> confirmPoint1(Map<String, String> jsonObject) {
// String pointCode = jsonObject.get("point_code"); // String pointCode = jsonObject.get("point_code");

View File

@@ -0,0 +1,12 @@
package org.nl.agv.service.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.nl.agv.entity.TaskInfo;
/**
* @author liejiu
*/
@Mapper
public interface TaskInfoMapper extends BaseMapper<TaskInfo> {
}

View File

@@ -89,7 +89,7 @@ security:
- /api/users - /api/users
mybatis-plus: mybatis-plus:
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: mapper-locations:
- classpath:org.nl.**.mapper/*.xml - classpath:org.nl.**.mapper/*.xml