rev:acs/lms优化项
1.ACS新增查询任务状态接口 2.MES取消任务接口 3.acs控制钢平台任务只能同时只有一个入库一个出库的任务 4.acs任务页面显示mes点位
This commit is contained in:
@@ -215,4 +215,17 @@ public interface XianGongAgvService {
|
||||
* }
|
||||
*/
|
||||
public JSONObject doorStateList(JSONObject requestParam);
|
||||
|
||||
/**
|
||||
* 终止仙工任务
|
||||
* @param requestParam{
|
||||
* releaseSite: 1
|
||||
* taskRecordId: 任务id
|
||||
* }
|
||||
* @return JSONObject {
|
||||
* code: 200
|
||||
* msg: ""
|
||||
* }
|
||||
*/
|
||||
public <T> UnifiedResponse<T> stopTask(JSONObject requestParam);
|
||||
}
|
||||
|
||||
@@ -1094,6 +1094,12 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> stopTask(JSONObject requestParam) {
|
||||
String path = "/stop-task";
|
||||
return xgHttpUtil.sendPostRequest(path, requestParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 叉车运单动作块
|
||||
*
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.nl.acs.ext.wms.data;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: lxy
|
||||
* @Description: 返回mes任务
|
||||
* @Date: 2024/9/24
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class ResultTaskMesDto {
|
||||
|
||||
/**
|
||||
* 任务编码
|
||||
*/
|
||||
String TaskCode;
|
||||
|
||||
/**
|
||||
* 取料货位
|
||||
*/
|
||||
String PickingLocation;
|
||||
|
||||
/**
|
||||
* 放料货位
|
||||
*/
|
||||
String PlacedLocation;
|
||||
|
||||
/**
|
||||
* 任务状态
|
||||
*/
|
||||
String TaskStatus;
|
||||
|
||||
/**
|
||||
* 执行AVG名称
|
||||
*/
|
||||
String ExecutingAGV;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
String CreateTime;
|
||||
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
String ExecuteTime;
|
||||
|
||||
}
|
||||
@@ -43,7 +43,8 @@ public class WmsToAcsController {
|
||||
|
||||
@PostMapping("/cancelTask")
|
||||
@OthersToInterfaceLog("LMS->ACS")
|
||||
public ResponseEntity<Object> cancelFromWms(@RequestBody String whereJson) throws Exception {
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> cancelFromWms(@RequestBody JSONObject whereJson) throws Exception {
|
||||
return new ResponseEntity<>(wmstoacsService.cancelFromWms(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -65,6 +66,13 @@ public class WmsToAcsController {
|
||||
return new ResponseEntity<>(wmstoacsService.todayTask(req), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping ("/SearchTasks")
|
||||
@Log("mes查询任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<JSONObject> SearchTasks() {
|
||||
return new ResponseEntity<>(wmstoacsService.SearchTasks(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/test")
|
||||
public ResponseEntity<Object> test() throws Exception {
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
|
||||
@@ -4,8 +4,6 @@ package org.nl.acs.ext.wms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface WmsToAcsService {
|
||||
/**
|
||||
* 创建任务
|
||||
@@ -21,11 +19,31 @@ public interface WmsToAcsService {
|
||||
* @param jsonObject 条件
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> cancelFromWms(String jsonObject) throws Exception;
|
||||
JSONObject cancelFromWms(JSONObject jsonObject) throws Exception;
|
||||
|
||||
JSONObject agvInfo(JSONObject req);
|
||||
|
||||
JSONObject rgvInfo(JSONObject req);
|
||||
|
||||
JSONObject todayTask(JSONObject req);
|
||||
|
||||
/**
|
||||
* mes查看任务
|
||||
* @return JSONObject : {
|
||||
* ReturnStatus: 任务下发结果
|
||||
* MsgTime: 返回时间
|
||||
* TaskLists:任务列表 [
|
||||
* {
|
||||
* TaskCode:任务编码
|
||||
* PickingLocation:取料货位
|
||||
* PlacedLocation:放料货位
|
||||
* TaskStatus:任务状态
|
||||
* ExecutingAGV:执行AVG名称
|
||||
* CreateTime:创建时间
|
||||
* ExecuteTime:执行时间
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
JSONObject SearchTasks();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.ext.wms.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -9,8 +10,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.AgvUtil;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.ext.UnifiedResponse;
|
||||
import org.nl.acs.ext.wms.data.ResultTaskMesDto;
|
||||
import org.nl.acs.ext.wms.data.wmsToAcsData.createTask.CreateTaskRequest;
|
||||
import org.nl.acs.ext.wms.data.wmsToAcsData.createTask.CreateTaskResponse;
|
||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
||||
@@ -24,18 +27,17 @@ import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
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.common.utils.SecurityUtils;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.quartz.task.DeviceStatusMonitor;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -49,6 +51,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
private final DeviceService DeviceService;
|
||||
private final RouteLineService RouteLineService;
|
||||
private final DeviceAppService deviceAppService;
|
||||
@Autowired
|
||||
private InstructionService instructionServiceTwo;
|
||||
@Autowired
|
||||
private XianGongAgvService agvService;
|
||||
@Autowired
|
||||
private XianGongAgvService xianGongAgvService;
|
||||
|
||||
private String log_file_type = "log_file_type";
|
||||
private String log_type = "WMS下发ACS";
|
||||
@@ -291,49 +299,50 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> cancelFromWms(String param) throws Exception {
|
||||
@Transactional
|
||||
public JSONObject cancelFromWms(JSONObject jsonWhere) throws Exception {
|
||||
log.info("cancelFromWms - 请求参数 {}", jsonWhere.toString());
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
Instruction instDto = instructionService.findByTaskCode(jsonWhere.getString("TaskCode"));
|
||||
|
||||
try {
|
||||
MDC.put(log_file_type, log_type);
|
||||
JSONArray tasks = JSONArray.parseArray(param);
|
||||
ParamService acsConfigService = SpringContextHolder.getBean(ParamServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
log.debug(tasks.toString());
|
||||
log.info("cancelFromWms - 请求参数 {}", tasks.toString());
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
JSONObject task = tasks.getJSONObject(i);
|
||||
String task_uuid = task.getString("task_id");
|
||||
String task_code = task.getString("task_code");
|
||||
String vehicle_code = task.getString("vehicle_code");
|
||||
String params = task.getString("params");
|
||||
|
||||
if (StrUtil.isEmpty(task_uuid)) {
|
||||
throw new WDKException("任务标识不能为空");
|
||||
}
|
||||
if (StrUtil.isEmpty(task_code)) {
|
||||
throw new WDKException("任务号不能为空");
|
||||
}
|
||||
String cancelTaskCheck = acsConfigService.findByCode(AcsConfig.CANCEL_TASK_CHECK).getValue();
|
||||
if (StrUtil.equals(cancelTaskCheck, "1")) {
|
||||
TaskService.cancel(task_uuid);
|
||||
} else if (StrUtil.equals(cancelTaskCheck, "0")) {
|
||||
Instruction inst = instructionService.findByTaskCode(task_code);
|
||||
if (inst == null) {
|
||||
TaskService.cancel(task_uuid);
|
||||
} else {
|
||||
throw new RuntimeException("指令正在执行中,操作失败!");
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(instDto)) {
|
||||
throw new BadRequestException("找不到对应任务号"+jsonWhere.getString("TaskCode"));
|
||||
}
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("status", HttpStatus.OK);
|
||||
resultJson.put("message", "操作成功");
|
||||
resultJson.put("data", new JSONObject());
|
||||
log.info("cancelFromWms - 返回参数 {}", resultJson.toString());
|
||||
return resultJson;
|
||||
} finally {
|
||||
MDC.remove(log_file_type);
|
||||
// 取消指令
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
instDto.setUpdate_time(now);
|
||||
instDto.setUpdate_by(currentUsername);
|
||||
instDto.setInstruction_status("3");
|
||||
instructionService.update(instDto);
|
||||
// 取消任务
|
||||
TaskDto taskDto = TaskService.findByCode(instDto.getTask_code());
|
||||
taskDto.setUpdate_time(now);
|
||||
taskDto.setUpdate_by(currentUsername);
|
||||
taskDto.setTask_status("3");
|
||||
TaskService.updateTwo(taskDto);
|
||||
|
||||
// 判断是否下发成功
|
||||
if (instDto.getSend_status().equals("1")) {
|
||||
// 调用XG接口通知删除
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("releaseSite",1);
|
||||
json.put("taskRecordId",instDto.getInstruction_code());
|
||||
xianGongAgvService.stopTask(json);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", e.getMessage());
|
||||
return result;
|
||||
}
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "操作成功");
|
||||
log.info("cancelFromWms - 返回参数 {}", result.toString());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -390,4 +399,61 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
resp.put("data", data);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject SearchTasks() {
|
||||
// 需返回mes集合
|
||||
List<ResultTaskMesDto> mesDtoList = new ArrayList<>();
|
||||
// 获取当前所有任务
|
||||
List<TaskDto> taskList = TaskService.findReadyAllTask();
|
||||
// 获取当前所有内存指令
|
||||
List<Instruction> instructionList = instructionServiceTwo.findAllInstFromCache();
|
||||
// 调用接口查看任务状态
|
||||
for (Instruction dto : instructionList) {
|
||||
String TaskStatus = "创建";
|
||||
String ExecutingAGV = "";
|
||||
|
||||
// 等于就绪状态就不调用接口
|
||||
if (dto.getSend_status().equals("1")) {
|
||||
UnifiedResponse<JSONObject> resp = agvService.queryXZAgvInstStatusByCode(dto.getInstruction_code(), JSONObject.class);
|
||||
// 状态
|
||||
String state = resp.getData().getString("state");
|
||||
if ("RUNNING".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
||||
TaskStatus = "执行中";
|
||||
}
|
||||
// 车号
|
||||
ExecutingAGV = resp.getData().getString("vehicle");
|
||||
}
|
||||
|
||||
// 组织数据
|
||||
TaskDto taskDto = taskList.stream()
|
||||
.filter(row -> row.getTask_code().equals(dto.getTask_code()))
|
||||
.findFirst().orElse(null);
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
continue;
|
||||
}
|
||||
// mes起点终点为空则不返回
|
||||
if (ObjectUtil.isEmpty(taskDto.getStart_parent_code()) || ObjectUtil.isEmpty(taskDto.getNext_parent_code())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ResultTaskMesDto mesDto = ResultTaskMesDto.builder()
|
||||
.TaskCode(taskDto.getTask_code())
|
||||
.PickingLocation(taskDto.getStart_parent_code())
|
||||
.PlacedLocation(taskDto.getNext_parent_code())
|
||||
.TaskStatus(TaskStatus)
|
||||
.ExecutingAGV(ExecutingAGV)
|
||||
.CreateTime(taskDto.getCreate_time())
|
||||
.ExecuteTime(taskDto.getUpdate_time())
|
||||
.build();
|
||||
mesDtoList.add(mesDto);
|
||||
}
|
||||
// 返回结果
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("ReturnStatus", 0);
|
||||
result.put("MsgTime", DateUtil.now());
|
||||
result.put("TaskList", mesDtoList);
|
||||
log.info("SearchTasks - 返回参数 {}", result.toString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,13 @@ public interface TaskService {
|
||||
*/
|
||||
void update(TaskDto dto);
|
||||
|
||||
/**
|
||||
* 编辑不回传lms
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void updateTwo(TaskDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
@@ -152,6 +159,20 @@ public interface TaskService {
|
||||
*/
|
||||
List<TaskDto> findReadyTask();
|
||||
|
||||
/**
|
||||
* 查询就绪和执行中状态下的任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TaskDto> findReadyAllTask();
|
||||
|
||||
/**
|
||||
* 查询执行中状态下的任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TaskDto> findReadyExTask();
|
||||
|
||||
|
||||
/**
|
||||
* 根据任务编码查询缓存中的任务
|
||||
|
||||
@@ -283,6 +283,25 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
this.feedWmsInfo(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTwo(TaskDto dto) {
|
||||
TaskDto entity = this.findById(dto.getTask_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_by(currentUsername);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
|
||||
wo.update(json);
|
||||
//刷新缓存内容
|
||||
this.refreshCache(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(String[] ids) throws Exception {
|
||||
@@ -523,6 +542,24 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findReadyAllTask() {
|
||||
return this.tasks
|
||||
.stream()
|
||||
.filter(taskDto -> "0".equals(taskDto.getTask_status()) || "1".equals(taskDto.getTask_status()))
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority).reversed())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> findReadyExTask() {
|
||||
return this.tasks
|
||||
.stream()
|
||||
.filter(taskDto -> "1".equals(taskDto.getTask_status()))
|
||||
.sorted(Comparator.comparing(TaskDto::getPriority).reversed())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TaskDto findByCodeFromCache(String task_code) {
|
||||
|
||||
@@ -51,6 +51,30 @@ public class AutoCreateInst {
|
||||
List<TaskDto> list = taskserver.findReadyTask();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TaskDto acsTask = list.get(i);
|
||||
// 起点或者是终点是钢平台货架的 只能同时支持一个入一个出
|
||||
String startPoint = acsTask.getStart_device_code();
|
||||
String nextPoint = acsTask.getNext_device_code();
|
||||
if (startPoint.startsWith("L")) {
|
||||
// 查询所有执行中的任务
|
||||
List<TaskDto> readyExTask = taskserver.findReadyExTask();
|
||||
// 判断执行中的任务有没有起点是钢平台的
|
||||
boolean isStart = readyExTask.stream()
|
||||
.anyMatch(row -> row.getStart_device_code().startsWith("L"));
|
||||
if (isStart) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (nextPoint.startsWith("L")) {
|
||||
// 查询所有执行中的任务
|
||||
List<TaskDto> readyExTask = taskserver.findReadyExTask();
|
||||
// 判断执行中的任务有没有终点是钢平台的
|
||||
boolean isEnd = readyExTask.stream()
|
||||
.anyMatch(row -> row.getNext_device_code().startsWith("L"));
|
||||
if (isEnd) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取任务对应的字段参数
|
||||
String taskid = acsTask.getTask_id();
|
||||
String taskcode = acsTask.getTask_code();
|
||||
|
||||
Reference in New Issue
Block a user