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);
|
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;
|
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")
|
@PostMapping("/cancelTask")
|
||||||
@OthersToInterfaceLog("LMS->ACS")
|
@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);
|
return new ResponseEntity<>(wmstoacsService.cancelFromWms(whereJson), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +66,13 @@ public class WmsToAcsController {
|
|||||||
return new ResponseEntity<>(wmstoacsService.todayTask(req), HttpStatus.OK);
|
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")
|
@PostMapping("/test")
|
||||||
public ResponseEntity<Object> test() throws Exception {
|
public ResponseEntity<Object> test() throws Exception {
|
||||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ package org.nl.acs.ext.wms.service;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface WmsToAcsService {
|
public interface WmsToAcsService {
|
||||||
/**
|
/**
|
||||||
* 创建任务
|
* 创建任务
|
||||||
@@ -21,11 +19,31 @@ public interface WmsToAcsService {
|
|||||||
* @param jsonObject 条件
|
* @param jsonObject 条件
|
||||||
* @return Map<String, Object>
|
* @return Map<String, Object>
|
||||||
*/
|
*/
|
||||||
Map<String, Object> cancelFromWms(String jsonObject) throws Exception;
|
JSONObject cancelFromWms(JSONObject jsonObject) throws Exception;
|
||||||
|
|
||||||
JSONObject agvInfo(JSONObject req);
|
JSONObject agvInfo(JSONObject req);
|
||||||
|
|
||||||
JSONObject rgvInfo(JSONObject req);
|
JSONObject rgvInfo(JSONObject req);
|
||||||
|
|
||||||
JSONObject todayTask(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;
|
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.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -9,8 +10,10 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.agv.AgvUtil;
|
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.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.CreateTaskRequest;
|
||||||
import org.nl.acs.ext.wms.data.wmsToAcsData.createTask.CreateTaskResponse;
|
import org.nl.acs.ext.wms.data.wmsToAcsData.createTask.CreateTaskResponse;
|
||||||
import org.nl.acs.ext.wms.service.WmsToAcsService;
|
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.route.service.dto.RouteLineDto;
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
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.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.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
import org.nl.modules.wql.exception.WDKException;
|
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -49,6 +51,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
private final DeviceService DeviceService;
|
private final DeviceService DeviceService;
|
||||||
private final RouteLineService RouteLineService;
|
private final RouteLineService RouteLineService;
|
||||||
private final DeviceAppService deviceAppService;
|
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_file_type = "log_file_type";
|
||||||
private String log_type = "WMS下发ACS";
|
private String log_type = "WMS下发ACS";
|
||||||
@@ -291,49 +299,50 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@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 {
|
try {
|
||||||
MDC.put(log_file_type, log_type);
|
if (ObjectUtil.isEmpty(instDto)) {
|
||||||
JSONArray tasks = JSONArray.parseArray(param);
|
throw new BadRequestException("找不到对应任务号"+jsonWhere.getString("TaskCode"));
|
||||||
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("指令正在执行中,操作失败!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
JSONObject resultJson = new JSONObject();
|
// 取消指令
|
||||||
resultJson.put("status", HttpStatus.OK);
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
resultJson.put("message", "操作成功");
|
String now = DateUtil.now();
|
||||||
resultJson.put("data", new JSONObject());
|
instDto.setUpdate_time(now);
|
||||||
log.info("cancelFromWms - 返回参数 {}", resultJson.toString());
|
instDto.setUpdate_by(currentUsername);
|
||||||
return resultJson;
|
instDto.setInstruction_status("3");
|
||||||
} finally {
|
instructionService.update(instDto);
|
||||||
MDC.remove(log_file_type);
|
// 取消任务
|
||||||
|
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
|
@Override
|
||||||
@@ -390,4 +399,61 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
resp.put("data", data);
|
resp.put("data", data);
|
||||||
return resp;
|
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);
|
void update(TaskDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑不回传lms
|
||||||
|
*
|
||||||
|
* @param dto /
|
||||||
|
*/
|
||||||
|
void updateTwo(TaskDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
*
|
*
|
||||||
@@ -152,6 +159,20 @@ public interface TaskService {
|
|||||||
*/
|
*/
|
||||||
List<TaskDto> findReadyTask();
|
List<TaskDto> findReadyTask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询就绪和执行中状态下的任务
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TaskDto> findReadyAllTask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询执行中状态下的任务
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TaskDto> findReadyExTask();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务编码查询缓存中的任务
|
* 根据任务编码查询缓存中的任务
|
||||||
|
|||||||
@@ -283,6 +283,25 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
this.feedWmsInfo(dto);
|
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
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAll(String[] ids) throws Exception {
|
public void deleteAll(String[] ids) throws Exception {
|
||||||
@@ -523,6 +542,24 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
.collect(Collectors.toList());
|
.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
|
@Override
|
||||||
public TaskDto findByCodeFromCache(String task_code) {
|
public TaskDto findByCodeFromCache(String task_code) {
|
||||||
|
|||||||
@@ -51,6 +51,30 @@ public class AutoCreateInst {
|
|||||||
List<TaskDto> list = taskserver.findReadyTask();
|
List<TaskDto> list = taskserver.findReadyTask();
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TaskDto acsTask = list.get(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 taskid = acsTask.getTask_id();
|
||||||
String taskcode = acsTask.getTask_code();
|
String taskcode = acsTask.getTask_code();
|
||||||
|
|||||||
@@ -290,10 +290,10 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="priority" label="任务优先级" min-width="100" show-overflow-tooltip />
|
<el-table-column prop="priority" label="任务优先级" min-width="100" show-overflow-tooltip />
|
||||||
<el-table-column prop="start_point_code" label="起点" min-width="100" show-overflow-tooltip />
|
<el-table-column prop="start_point_code" label="AGV起点" min-width="100" show-overflow-tooltip />
|
||||||
<el-table-column prop="next_point_code" label="终点" min-width="100" show-overflow-tooltip />
|
<el-table-column prop="next_point_code" label="AGV终点" min-width="100" show-overflow-tooltip />
|
||||||
<!-- <el-table-column prop="start_point_code2" label="起点2" min-width="100" show-overflow-tooltip />-->
|
<el-table-column prop="start_parent_code" label="MES起点" min-width="100" show-overflow-tooltip />
|
||||||
<!-- <el-table-column prop="next_point_code2" label="终点2" min-width="100" show-overflow-tooltip />-->
|
<el-table-column prop="next_parent_code" label="MES终点" min-width="100" show-overflow-tooltip />
|
||||||
<!-- <el-table-column prop="put_device_code" label="放货位" min-width="100" show-overflow-tooltip />-->
|
<!-- <el-table-column prop="put_device_code" label="放货位" min-width="100" show-overflow-tooltip />-->
|
||||||
|
|
||||||
<!--<el-table-column prop="compound_task" label="复合任务">
|
<!--<el-table-column prop="compound_task" label="复合任务">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.wms.ext.acs.service;
|
package org.nl.wms.ext.acs.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
|
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
|
||||||
import org.nl.wms.ext.acs.service.dto.to.acs.DeviceInfoDto;
|
import org.nl.wms.ext.acs.service.dto.to.acs.DeviceInfoDto;
|
||||||
import org.nl.wms.ext.acs.service.dto.to.acs.PutActionRequest;
|
import org.nl.wms.ext.acs.service.dto.to.acs.PutActionRequest;
|
||||||
@@ -39,4 +40,12 @@ public interface WmsToAcsService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AcsResponse getDeviceStatusByCode(List<DeviceInfoDto> list);
|
AcsResponse getDeviceStatusByCode(List<DeviceInfoDto> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务
|
||||||
|
*
|
||||||
|
* @param taskCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JSONObject cancelTask(JSONObject taskCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.wms.ext.acs.service.impl;
|
package org.nl.wms.ext.acs.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||||
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
|
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
|
||||||
@@ -9,7 +10,6 @@ import org.nl.wms.ext.acs.service.dto.to.acs.PutActionRequest;
|
|||||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||||
import org.nl.wms.ext.record.service.ISysInteractRecordService;
|
import org.nl.wms.ext.record.service.ISysInteractRecordService;
|
||||||
import org.nl.wms.sch.task_manage.AcsTaskDto;
|
import org.nl.wms.sch.task_manage.AcsTaskDto;
|
||||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
|
||||||
import org.nl.wms.sch.task_manage.task.AcsUtil;
|
import org.nl.wms.sch.task_manage.task.AcsUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -53,4 +53,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
// interactRecordService.saveRecord("获取设备信息", list, resultForAcs, GeneralDefinition.LMS_ACS);
|
// interactRecordService.saveRecord("获取设备信息", list, resultForAcs, GeneralDefinition.LMS_ACS);
|
||||||
return resultForAcs;
|
return resultForAcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject cancelTask(JSONObject taskCode) {
|
||||||
|
String api = "/api/wms/cancelTask";
|
||||||
|
JSONObject acsResponse = AcsUtil.cancelTask(api, taskCode);
|
||||||
|
return acsResponse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,10 +211,11 @@ public class MesToWmsServiceImpl implements MesToWmsService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断此任务的状态是否能删除
|
// 调用ACS删除任务
|
||||||
if (Integer.parseInt(taskDao.getTask_status()) > Integer.parseInt(TaskStatus.ISSUED.getCode())) {
|
JSONObject json = wmsToAcsService.cancelTask(jo);
|
||||||
|
if (json.getIntValue("status") == HttpStatus.HTTP_BAD_REQUEST) {
|
||||||
result.put("ReturnStatus", 1);
|
result.put("ReturnStatus", 1);
|
||||||
result.put("ReturnInfo", "任务号为【"+jo.getString("TaskCode")+"】的任务正在执行中或者已完成,不能取消任务!");
|
result.put("ReturnInfo", "任务号为【"+jo.getString("TaskCode")+"】删除失败!"+ json.getString("message"));
|
||||||
result.put("MsgTime", DateUtil.now());
|
result.put("MsgTime", DateUtil.now());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.hutool.http.HttpRequest;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.nl.system.service.param.dao.Param;
|
import org.nl.system.service.param.dao.Param;
|
||||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||||
@@ -111,4 +112,43 @@ public class AcsUtil {
|
|||||||
}
|
}
|
||||||
return resultForAcs;
|
return resultForAcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JSONObject cancelTask(String api, JSONObject taskCode) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
|
||||||
|
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||||
|
//判断是否连接ACS系统
|
||||||
|
Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS);
|
||||||
|
if (ObjectUtil.isEmpty(isConnectAcs)) {
|
||||||
|
result.put("status", "400");
|
||||||
|
result.put("message", "参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
String isConnect = isConnectAcs.getValue();
|
||||||
|
//ACS地址:127.0.0.1:8010
|
||||||
|
Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL);
|
||||||
|
if (ObjectUtil.isEmpty(acsUrlObj)) {
|
||||||
|
result.put("status", "400");
|
||||||
|
result.put("message", "参数表中:" + GeneralDefinition.ACS_URL + "不存在");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
String acsUrl = acsUrlObj.getValue();
|
||||||
|
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
|
||||||
|
result.put("status", "200");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
String url = acsUrl + api;
|
||||||
|
log.info("删除acs任务的输入参数为:{}", taskCode);
|
||||||
|
try {
|
||||||
|
String resultMsg = HttpRequest.post(url)
|
||||||
|
.body(String.valueOf(taskCode))
|
||||||
|
.execute().body();
|
||||||
|
result = JSONObject.parseObject(resultMsg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
result.put("status", "400");
|
||||||
|
result.put("message", "ACS网络不通");
|
||||||
|
}
|
||||||
|
log.info("删除acs任务的输出参数为:{}", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user