Browse Source

add:acs与wms接口

master
刘先源 1 week ago
parent
commit
0db9d000a6
  1. 156
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/one/CreateTaskRequest.java
  2. 11
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java
  3. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java
  4. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java
  5. 7
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java
  6. 67
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
  7. 311
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
  8. 28
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  9. 167
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java
  10. 187
      acs2/nladmin-system/.idea/workspace.xml

156
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/one/CreateTaskRequest.java

@ -1,5 +1,6 @@
package org.nl.acs.ext.wms.data.one;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.nl.acs.common.base.CommonFinalParam;
@ -40,16 +41,22 @@ public class CreateTaskRequest extends BaseRequest {
*/
String vehicle_code;
/**
* 木箱号
*/
String vehicle_code2;
/**
* 载具类型
*/
String vehicle_type;
/**
* 任务类型
* 扩展属性
*/
String task_type;
String params2;
/**
@ -76,4 +83,147 @@ public class CreateTaskRequest extends BaseRequest {
", params=" + params +
'}';
}
/**
* 任务标识
*/
private String ext_task_id;
/**
* 取货点2
*/
String start_device_code2;
/**
* 放货点2
*/
String next_device_code2;
/**
* 烘箱对接位
*/
String put_device_code;
/**
* 路由方案
*/
String route_plan_code;
/**
* 1生箔
* 2分切
* 3普通任务
* 4叉车任务
* 5输送任务
* 6行架
* 7立库
* 任务类型
*/
String task_type;
/**
* 立库任务类型
*
*/
String dtl_type;
/**
* Agv系统类型
* 1:1楼叉车系统
* 2:2楼1区域AGV系统
* 3:2楼2区域AGV系统
*/
String agv_system_type;
/**
* 烘箱时间
*/
String oven_time;
/**
* 烘箱温度
*/
String temperature;
/**
* agv取货高度
*/
private String start_height;
/**
* agv放货高度
*/
private String next_height;
/**
* 行架任务类型
*/
private String truss_type;
/**
* 气涨轴尺寸
*/
private String size;
/**
* 空轴位
*/
private String empty_site;
/**
* 气胀轴代数
*/
private String version;
/**
* 是否套管
*/
private String is_bushing;
/**
* 套管数量
*/
private String bushing_num;
private String paper_array;
/**
* 任务扩展字段
*/
private JSONObject interaction_json;
/**
* 是否拔轴 0/1
*/
private String is_pulling;
/**
* agv二次分配类型1普通任务 2取货二次分配 3防货二次分配 4取放货二次分配
*/
private Integer agv_action_type;
/**
* 任务类型
* 12 木箱入库行架任务
* 13 装箱入库行架任务
* 14 退货入库行架任务
* 15 RGV输送任务
* 16 子卷下线行架任务
* 17 木箱堆叠行架任务
*/
private String class_type;
}

11
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java

@ -3,8 +3,6 @@ package org.nl.acs.ext.wms.rest;
import com.alibaba.fastjson.JSONArray;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.service.AcsToWmsService;
@ -30,14 +28,6 @@ import java.util.Map;
public class AcsToWmsController {
private final AcsToWmsService acstowmsService;
// @PostMapping("/applyTask")
// @Log("向WMS申请任务")
// /** 向WMS申请任务 */
// public ResponseEntity<Object> applyTaskToWms(@RequestBody String device_code, String container_code, int height, int weight) {
// return new ResponseEntity<>(acstowmsService.applyTaskToWms(device_code, container_code, height, weight), HttpStatus.OK);
// }
@PostMapping("/taskStatusFeedback")
@Log("向WMS反馈任务状态")
/** 向WMS反馈任务状态 */
@ -46,7 +36,6 @@ public class AcsToWmsController {
return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(data), HttpStatus.OK);
}
@PostMapping("/feedbackAgvStatus")
@Log("反馈AGV设备状态")
/** 反馈AGV设备状态 */

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java

@ -37,8 +37,8 @@ public class WmsToAcsController {
@Log(value = "ACS接收WMS任务")
/** 接收WMS任务 */
@SaIgnore
public ResponseEntity<Object> createFromWms(@RequestBody List<CreateTaskRequest> reqs) {
return new ResponseEntity<>(wmstoacsService.crateTask(reqs), HttpStatus.OK);
public ResponseEntity<Object> createFromWms(@RequestBody String whereJson ) {
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
}
@PostMapping("/cancelTask")

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java

@ -103,10 +103,10 @@ public interface AcsToWmsService {
/**
* ACS向WMS反馈任务状态
* @param request
* @param arr
* @return
*/
String feedTaskStatus(BaseRequest request);
HttpResponse feedTaskStatus(JSONArray arr);
/**
* ACS向WMS反馈任务状态

7
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java

@ -2,7 +2,10 @@ package org.nl.acs.ext.wms.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.ext.wms.data.one.*;
import org.nl.acs.ext.wms.data.one.CancelTaskRequest;
import org.nl.acs.ext.wms.data.one.CancelTaskResponse;
import org.nl.acs.ext.wms.data.one.CreateTaskRequest;
import org.nl.acs.ext.wms.data.one.CreateTaskResponse;
import java.util.List;
import java.util.Map;
@ -13,7 +16,7 @@ public interface WmsToAcsService {
* @param param
* @return
*/
org.nl.acs.ext.wms.data.CreateTaskResponse crateTask(String param);
CreateTaskResponse crateTask(String param);
/**
* 创建任务

67
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -1,11 +1,14 @@
package org.nl.acs.ext.wms.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yomahub.tlog.hutoolhttp.TLogHutoolhttpInterceptor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
@ -16,10 +19,15 @@ import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonRequest;
import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonResponse;
import org.nl.acs.ext.wms.data.BlankingButtonRequest;
import org.nl.acs.ext.wms.data.BlankingButtonResponse;
import org.nl.acs.ext.wms.data.one.*;
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.data.one.BaseRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.nl.system.service.param.ISysParamService;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,8 +54,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Autowired
DeviceExecuteLogService logServer;
@Autowired
private LuceneExecuteLogService luceneLogService;
public String token;
TLogHutoolhttpInterceptor tLogHutoolhttpInterceptor = new TLogHutoolhttpInterceptor();
private String log_file_type = "log_file_type";
private String log_type = "ACS请求LMS";
@ -110,8 +122,57 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public String feedTaskStatus(BaseRequest request) {
return null;
public HttpResponse feedTaskStatus(JSONArray data) {
//feedTaskStatus
try {
MDC.put(log_file_type, log_type);
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
String task_code = "";
for (int i = 0; i < data.size(); i++) {
JSONObject json = (JSONObject) data.get(i);
task_code = json.getString("task_code");
}
TaskDto taskDto = taskService.findByCode(task_code);
String vehicle_code = taskDto.getVehicle_code();
HttpResponse result2 = null;
log.info("feedbackTaskStatusToWms-----请求参数{}", data.toString());
AddressDto addressDto = addressService.findByCode("feedTaskStatus");
String methods_url = addressDto.getMethods_url();
try {
result2 = HttpRequest.post(wmsurl + methods_url)
.addInterceptor(tLogHutoolhttpInterceptor)
.header(Header.USER_AGENT, "Hutool http")
.header("Authorization", token).body(String.valueOf(data))
.execute();
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"feedTaskStatus", String.valueOf(result2.getStatus()),
String.valueOf(data), String.valueOf(result2.body()), "ACS向WMS反馈任务状态");
luceneLogService.interfaceExecuteLog(luceneLogDto);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
log.info("feedbackTaskStatusToWms-----输出参数{}", msg);
}
String type = "";
if (ObjectUtil.isNotEmpty(result2) && result2.getStatus() == 200) {
type = "info";
JSONObject jo = JSONObject.parseObject(result2.body());
log.info("feedbackTaskStatusToWms-----输出参数{}", jo.toString());
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"feedTaskStatus", String.valueOf(result2.getStatus()),
String.valueOf(data), String.valueOf(result2.body()), "ACS向WMS反馈任务状态");
luceneLogService.interfaceExecuteLog(luceneLogDto);
return result2;
} else {
type = "error";
}
return null;
} finally {
MDC.remove(log_file_type);
}
}
@Override

311
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java

@ -1,24 +1,32 @@
package org.nl.acs.ext.wms.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.conveyor.box_palletizing_manipulator.BoxPalletizingManipulatorDeviceDriver;
import org.nl.acs.device_driver.conveyor.primary_device.PrimaryDeviceConveyorDeviceDriver;
import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.BoxPackageManipulatorDeviceDriver;
import org.nl.acs.ext.wms.data.*;
import org.nl.acs.ext.wms.data.JsonUtl;
import org.nl.acs.ext.wms.data.PutActionResponse;
import org.nl.acs.ext.wms.data.one.CancelTaskRequest;
import org.nl.acs.ext.wms.data.one.CancelTaskResponse;
import org.nl.acs.ext.wms.data.one.CreateTaskRequest;
import org.nl.acs.ext.wms.data.one.CreateTaskResponse;
import org.nl.acs.ext.wms.service.WmsToAcsService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.storage_cell.domain.StorageCell;
import org.nl.acs.storage_cell.service.mapper.StorageCellMapper;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.exception.BadRequestException;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@ -40,24 +48,309 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
@Autowired
private DeviceAppService deviceAppService;
@Autowired
private LuceneExecuteLogService luceneExecuteLogService;
@Autowired
private TaskService taskserver;
private String log_file_type = "log_file_type";
private String log_type = "LMS请求ACS";
@Override
public CreateTaskResponse crateTask(String param) {
return null;
try {
MDC.put(log_file_type, log_type);
log.info("ACS接收WMS任务-----输入参数{}", param);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("ACS接收WMS任务")
.content("ACS接收WMS任务-----输入参数:" + param)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
JSONArray datas = JSONArray.parseArray(param);
CreateTaskResponse response = new CreateTaskResponse();
JSONArray errArr = new JSONArray();
for (int i = 0; i < datas.size(); i++) {
String data = datas.get(i).toString();
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
String paper_array = request.getPaper_array();
String ext_task_id = request.getExt_task_id();
String task_code = request.getTask_code();
String start_device_code = request.getStart_device_code();
String start_device_code2 = request.getStart_device_code2();
String next_device_code = request.getNext_device_code();
String next_device_code2 = request.getNext_device_code2();
String put_device_code = request.getPut_device_code();
String priority = request.getPriority();
String vehicle_code = request.getVehicle_code();
String vehicle_code2 = request.getVehicle_code2();
String vehicle_type = request.getVehicle_type();
String route_plan_code = request.getRoute_plan_code();
String task_type = request.getTask_type();
String class_type = request.getClass_type();
String truss_type = request.getTruss_type();
Integer agv_action_type = request.getAgv_action_type();
String empty_site = request.getEmpty_site();
String is_bushing = request.getIs_bushing();
String is_pulling = request.getIs_pulling();
String size = request.getSize();
String version = request.getVersion();
String bushing_num = request.getBushing_num();
String storage_task_type = request.getDtl_type();
String agv_system_type = request.getAgv_system_type();
String remark = request.getRemark();
double oven_time = 0.00d;
if (StrUtil.isNotEmpty(request.getOven_time())) {
oven_time = Double.parseDouble(request.getOven_time());
}
String temperature = request.getTemperature();
String start_height = request.getStart_height();
String next_height = request.getNext_height();
String params2 = request.getParams2();
Map<String, String> params = request.getParams();
String start_point_code = "";
String start_point_code2 = "";
String next_point_code = "";
String next_point_code2 = "";
String put_point_code = "";
if (StrUtil.isEmpty(task_code)) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", "任务号不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(start_device_code)) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", "起点不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(next_device_code)) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", "终点不能为空");
errArr.add(json);
continue;
}
if (StrUtil.equals(task_type, "8")) {
next_device_code = request.getPut_device_code();
put_device_code = request.getNext_device_code();
}
StorageCell start_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getStorage_code, start_device_code)
.one();
StorageCell next_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getStorage_code, next_device_code)
.one();
StorageCell start2_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getStorage_code, start_device_code2)
.one();
StorageCell next2_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getStorage_code, next_device_code2)
.one();
StorageCell put_storageCell = new LambdaQueryChainWrapper<>(storageCellMapper)
.eq(StorageCell::getStorage_code, put_device_code)
.one();
JSONObject start_device_json = (JSONObject) JSONObject.toJSON(start_storageCell);
if (!ObjectUtil.isEmpty(start_device_json)) {
start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code");
}
JSONObject next_device_json = (JSONObject) JSONObject.toJSON(next_storageCell);
if (!ObjectUtil.isEmpty(next_device_json)) {
next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code");
}
JSONObject start_device_json2 = (JSONObject) JSONObject.toJSON(start2_storageCell);
if (!ObjectUtil.isEmpty(start_device_json2)) {
start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json2.get("storage_code");
}
JSONObject next_device_json2 = (JSONObject) JSONObject.toJSON(next2_storageCell);
if (!ObjectUtil.isEmpty(next_device_json2)) {
next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json2.get("storage_code");
}
JSONObject put_device_json = (JSONObject) JSONObject.toJSON(put_storageCell);
if (!ObjectUtil.isEmpty(put_device_json)) {
put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) put_device_json.get("storage_code");
}
if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) {
String str[] = start_point_code.split("-");
start_device_code = str[0];
} else {
start_device_code = start_point_code;
}
if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) {
String str[] = next_point_code.split("-");
next_device_code = str[0];
} else {
next_device_code = next_point_code;
}
if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) {
String str[] = start_point_code2.split("-");
start_device_code2 = str[0];
} else {
start_device_code2 = start_point_code2;
}
if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) {
String str[] = next_point_code2.split("-");
next_device_code2 = str[0];
} else {
next_device_code2 = next_point_code2;
}
if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) {
String str[] = put_point_code.split("-");
put_device_code = str[0];
} else {
put_device_code = put_point_code;
}
if (StrUtil.isEmpty(route_plan_code)) {
route_plan_code = "normal";
}
TaskDto taskDto = taskserver.findByCodeFromCache(task_code);
if (taskDto != null) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", "存在相同的任务号:" + task_code);
errArr.add(json);
continue;
}
if (!StrUtil.isEmpty(vehicle_code)) {
TaskDto vehicle_dto = taskserver.findByContainer(vehicle_code);
if (vehicle_dto != null) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code);
errArr.add(json);
continue;
}
}
if (StrUtil.isEmpty(start_point_code)) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", request.getStart_device_code() + " 该设备号未找到对应点位");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(next_point_code)) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", request.getNext_device_code() + " 该设备号未找到对应点位");
errArr.add(json);
continue;
}
JSONObject jo = new JSONObject();
jo.put("task_id", IdUtil.simpleUUID());
jo.put("task_code", task_code);
jo.put("start_point_code", start_point_code);
jo.put("next_point_code", next_point_code);
jo.put("start_point_code2", start_point_code2);
jo.put("next_point_code2", next_point_code2);
jo.put("put_point_code", put_point_code);
jo.put("start_parent_code", start_point_code);
jo.put("next_parent_code", next_point_code);
jo.put("start_device_code", start_device_code);
jo.put("next_device_code", next_device_code);
jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2);
jo.put("put_device_code", put_device_code);
jo.put("agv_action_type", agv_action_type);
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("vehicle_code2", vehicle_code2);
jo.put("vehicle_type", vehicle_type);
jo.put("storage_task_type", storage_task_type);
jo.put("agv_system_type", agv_system_type);
jo.put("start_height", start_height);
jo.put("next_height", next_height);
jo.put("oven_time", (int) Math.ceil(oven_time));
jo.put("remark", remark);
jo.put("params", params);
jo.put("params2", params2);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
jo.put("class_type", class_type);
jo.put("route_plan_code", route_plan_code);
jo.put("paper_array", JSONUtil.toJsonStr(paper_array));
jo.put("truss_type", JSONUtil.toJsonStr(truss_type));
jo.put("empty_site", JSONUtil.toJsonStr(empty_site));
jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing));
jo.put("is_pulling", JSONUtil.toJsonStr(is_pulling));
jo.put("size", JSONUtil.toJsonStr(size));
jo.put("version", JSONUtil.toJsonStr(version));
jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num));
if (!StrUtil.isEmpty(ext_task_id)) {
jo.put("ext_task_id", ext_task_id);
}
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
try {
taskserver.create(task_dto);
} catch (Exception e) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("ext_task_id", ext_task_id);
json.put("message", e.getMessage());
errArr.add(json);
continue;
}
}
if (ObjectUtil.isEmpty(errArr)) {
response.setStatus(200);
response.setMessage("success");
} else {
response.setStatus(400);
if (ObjectUtil.isNotEmpty(errArr)) {
response.setMessage(errArr.getJSONObject(0).getString("message"));
} else {
response.setMessage("false");
}
response.setErrArr(errArr);
}
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code("ACS接收WMS任务")
.content("ACS接收WMS任务-----返回参数:" + JSON.toJSONString(response))
.build();
logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
log.info("ACS接收WMS任务--------------:输出参数:" + JSON.toJSONString(response));
return response;
} finally {
MDC.remove(log_file_type);
}
}
@Override
public org.nl.acs.ext.wms.data.one.CreateTaskResponse crateTask(List<org.nl.acs.ext.wms.data.one.CreateTaskRequest> reqs) {
public CreateTaskResponse crateTask(List<CreateTaskRequest> reqs) {
return null;
}
@Override
public org.nl.acs.ext.wms.data.one.CancelTaskResponse cancelFromWms(List<org.nl.acs.ext.wms.data.one.CancelTaskRequest> reqs) throws Exception {
public CancelTaskResponse cancelFromWms(List<CancelTaskRequest> reqs) throws Exception {
return null;
}
@Override
public Map<String, Object> updateDeviceGoodsFromWms(String jsonObject) {
return null;
@ -125,7 +418,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
@Override
public Map<String, Object> queryDevice(String jsonObject) throws Exception {
return null;
return null;
}
@Override

28
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -30,8 +30,6 @@ import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.RequestMethodEnum;
import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.domain.InstructionMybatis;
@ -70,6 +68,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -1450,16 +1449,27 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
*/
private void feedWmsTaskStatus(TaskDto taskDto) {
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
TaskDto entity = this.findById(taskDto.getTask_id());
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
if (!StrUtil.startWith(taskDto.getTask_code(), CommonFinalParam.HYPHEN_) && StrUtil.equals(hasWms, CommonFinalParam.ONE)) {
FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest();
request.setTask_id(taskDto.getExt_task_id());
request.setTask_code(taskDto.getTask_code());
request.setTask_status(taskDto.getTask_status());
request.setRequest_medthod_code(RequestMethodEnum.feedback_task_status.getCode());
request.setRequest_medthod_name(RequestMethodEnum.feedback_task_status.getName());
JSONObject feed_jo = new JSONObject();
feed_jo.put("task_id", entity.getExt_task_id());
feed_jo.put("task_code", entity.getTask_code());
feed_jo.put("task_status", entity.getTask_status());
if (ObjectUtil.isNotEmpty(entity.getWeight())) {
feed_jo.put("weight", entity.getWeight());
}
JSONArray ja = new JSONArray();
ja.add(feed_jo);
//TODO 有需要根据上位系统反馈的信息再做进一步处理
acstowmsService.feedTaskStatus(request);
CompletableFuture.runAsync(() -> {
acstowmsService.feedTaskStatus(ja);
// 异步更新任务状态
try {
} catch (Exception e) {
e.printStackTrace();
}
});
}
}

167
acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java

@ -0,0 +1,167 @@
package org.nl.system.service.quartz.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.nl.system.service.lucene.impl.LuceneExecuteLogServiceImpl;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/**
* 自动创建指令
*/
@Slf4j
@Component
public class AutoCreateInst {
/**
* 根据任务状态创建指令生成下一条指令
* 创建指令前需要判断是否条件具备起始位置是否有货目标位置是否有货
*/
public void run() throws Exception {
log.info("自动生成指令" + DateUtil.now());
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class);
List<TaskDto> list = taskserver.queryAllByStatus("0");
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String task_type = acsTask.getTask_type();
String vehiclecode = acsTask.getVehicle_code();
String priority = acsTask.getPriority();
String is_send = acsTask.getIs_send();
String start_device_code = acsTask.getStart_device_code();
String start_point_code = acsTask.getStart_point_code();
String put_device_code = acsTask.getPut_device_code();
String put_point_code = acsTask.getPut_point_code();
String next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
if (StrUtil.equals(is_send, "0")) {
continue;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask);
continue;
}
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
continue;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(acsTask.getRemark());
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setPut_device_code(put_device_code);
instdto.setPut_point_code(put_point_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("定时创建指令失败")
.content(e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
continue;
}
//创建指令后修改任务状态
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
acsTask.setUpdate_time(DateUtil.now());
taskserver.update(acsTask);
}
}
}

187
acs2/nladmin-system/.idea/workspace.xml

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BranchesTreeState">
<expand>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="a019a4eb-08e9-4982-8f64-7b4fa41c94ac" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/one/CreateTaskRequest.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/one/CreateTaskRequest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="localRepository" value="D:\JavaDevelop" />
<option name="mavenHome" value="$PROJECT_DIR$/../../../../../maven/apache-maven-3.6.1" />
<option name="userSettingsFile" value="D:\maven\apache-maven-3.6.1\conf\settings.xml" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectId" id="2yOBIGhJzTvRKwuadnnXUR9FtiT" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RequestMappingsPanelOrder0" value="0" />
<property name="RequestMappingsPanelOrder1" value="1" />
<property name="RequestMappingsPanelWidth0" value="75" />
<property name="RequestMappingsPanelWidth1" value="75" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="settings.editor.selected.configurable" value="MavenSettings" />
</component>
<component name="ReactorSettings">
<option name="notificationShown" value="true" />
</component>
<component name="RebelAgentSelection">
<selection>jr</selection>
</component>
<component name="RunManager">
<configuration name="AppRun" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="nlsso-server" />
<option name="SPRING_BOOT_MAIN_CLASS" value="org.nl.AppRun" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
<component name="SshConsoleOptionsProvider">
<option name="myEncoding" value="UTF-8" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="a019a4eb-08e9-4982-8f64-7b4fa41c94ac" name="Default Changelist" comment="" />
<created>1749695657075</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1749695657075</updated>
<workItem from="1749695660750" duration="16000" />
<workItem from="1749696388346" duration="6162000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="2" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="WindowStateProjectService">
<state x="549" y="171" key="FileChooserDialogImpl" timestamp="1749696574867">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state x="549" y="171" key="FileChooserDialogImpl/0.0.1536.834@0.0.1536.834" timestamp="1749696574867" />
<state width="1493" height="497" key="GridCell.Tab.0.bottom" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.0.bottom/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.0.center" timestamp="1749710140242">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.0.center/0.0.1536.834@0.0.1536.834" timestamp="1749710140242" />
<state width="1493" height="497" key="GridCell.Tab.0.left" timestamp="1749710140242">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.0.left/0.0.1536.834@0.0.1536.834" timestamp="1749710140242" />
<state width="1493" height="497" key="GridCell.Tab.0.right" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.0.right/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.1.bottom" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.1.bottom/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.1.center" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.1.center/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.1.left" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.1.left/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.1.right" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.1.right/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.2.bottom" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.2.bottom/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.2.center" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.2.center/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.2.left" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.2.left/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state width="1493" height="497" key="GridCell.Tab.2.right" timestamp="1749710140243">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state width="1493" height="497" key="GridCell.Tab.2.right/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" />
<state x="270" y="61" key="SettingsEditor" timestamp="1749696623589">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state x="270" y="61" key="SettingsEditor/0.0.1536.834@0.0.1536.834" timestamp="1749696623589" />
<state x="467" y="149" width="602" height="536" key="find.popup" timestamp="1749708680849">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state x="467" y="149" width="602" height="536" key="find.popup/0.0.1536.834@0.0.1536.834" timestamp="1749708680849" />
<state x="431" y="155" width="672" height="678" key="search.everywhere.popup" timestamp="1749708494721">
<screen x="0" y="0" width="1536" height="834" />
</state>
<state x="431" y="155" width="672" height="678" key="search.everywhere.popup/0.0.1536.834@0.0.1536.834" timestamp="1749708494721" />
</component>
</project>
Loading…
Cancel
Save