Browse Source

add:任务表添加job字段,添加状态反馈功能;todo:请求取货申请

master
zhangzq 4 months ago
parent
commit
6785fc7014
  1. 43
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  2. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/sorting/service/impl/SortingServiceImpl.java
  3. 41
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/sorting/service/impl/WmsToSortingService.java
  4. 1
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java
  5. 1
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java
  6. 37
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/ConnectorUtil.java

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

@ -9,8 +9,11 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpStatus; import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.enums.GoodsEnum; import org.nl.common.enums.GoodsEnum;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.system.service.notice.ISysNoticeService; import org.nl.system.service.notice.ISysNoticeService;
@ -26,6 +29,7 @@ import org.nl.wms.ext.acs.service.dto.to.wms.FeedBackTaskStatusRequest;
import org.nl.wms.ext.connector.service.WmsToConnectorService; import org.nl.wms.ext.connector.service.WmsToConnectorService;
import org.nl.wms.ext.connector.service.dto.ConnectorDto; import org.nl.wms.ext.connector.service.dto.ConnectorDto;
import org.nl.wms.ext.record.service.ISysInteractRecordService; import org.nl.wms.ext.record.service.ISysInteractRecordService;
import org.nl.wms.ext.sorting.service.impl.WmsToSortingService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.nl.wms.sch.point.service.ISchBasePointService; import org.nl.wms.sch.point.service.ISchBasePointService;
@ -43,6 +47,7 @@ import org.nl.wms.sch.task_manage.task.core.TaskType;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper; import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -87,7 +92,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Autowired @Autowired
private WmsToConnectorService connectorService; private WmsToConnectorService connectorService;
@Autowired @Autowired
private ISchBaseTaskconfigService taskConfigService; private WmsToSortingService sortingService;
@Autowired @Autowired
private IMdBaseVehicleService iMdBaseVehicleService; private IMdBaseVehicleService iMdBaseVehicleService;
@ -339,17 +344,27 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
*/ */
private void releaseComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType, boolean is_empty) { private void releaseComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType, boolean is_empty) {
//TODO:空料容放货完成反馈给Connector //TODO:空料容放货完成反馈给Connector
if ("1".equals(is_connector)) {
if (!is_empty) { if (!is_empty) {
finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code2()); finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code2());
} else { }else {
finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code1());
if ("1".equals(is_connector)) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("vehicle_code", schBaseTask.getVehicle_code()); json.put("vehicle_code", schBaseTask.getVehicle_code());
json.put("status", status); json.put("status", status);
json.put("device_code", schBaseTask.getPoint_code2()); json.put("device_code", schBaseTask.getPoint_code2());
json.put("task_code", schBaseTask.getTask_code()); json.put("task_code", schBaseTask.getTask_code());
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json);
finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code1());
}
if ("2".equals(is_connector)) {
JSONObject json = new JSONObject();
json.put("vehicle_code", schBaseTask.getVehicle_code());
json.put("status", status);
json.put("device_code", schBaseTask.getPoint_code2());
json.put("task_code", schBaseTask.getTask_code());
AcsResponse acsResponse = sortingService.feedAgvTaskStatus(json);
} }
} }
} }
@ -369,30 +384,38 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
*/ */
private void pickupComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType) { private void pickupComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType) {
//TODO:取货完成创建第二条任务:补空托盘 //TODO:取货完成创建第二条任务:补空托盘
String vehicle_code = schBaseTask.getVehicle_code();
if ("1".equals(is_connector)) { if ("1".equals(is_connector)) {
List<SchBaseTask> list = taskService.list(Wrappers.lambdaQuery(SchBaseTask.class).eq(SchBaseTask::getPoint_code2, schBaseTask.getPoint_code1()) List<SchBaseTask> list = taskService.list(Wrappers.lambdaQuery(SchBaseTask.class).eq(SchBaseTask::getPoint_code2, schBaseTask.getPoint_code1())
.in(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(), TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode())); .in(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(), TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode()));
if (CollUtil.isNotEmpty(list) || list.size() > 0) { if (CollectionUtils.isEmpty(list)) {
throw new BadRequestException("该点位已有任务,请等待任务完成"); MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getOne(new QueryWrapper<MdBaseVehicle>().eq("vehicle_code", vehicle_code));
}
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getById(schBaseTask.getVehicle_code());
AbstractTask connectorTask = taskFactory.getTask("FTGTask"); AbstractTask connectorTask = taskFactory.getTask("FTGTask");
// 准备参数:设备编码 // 准备参数:设备编码
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("device_code", schBaseTask.getPoint_code1()); param.put("device_code", schBaseTask.getPoint_code1());
param.put("config_code", "FTGTask"); param.put("config_code", "FTGTask");
param.put("create_mode", GeneralDefinition.AUTO_CREATION); param.put("create_mode", GeneralDefinition.AUTO_CREATION);
param.put("vehicle_type", StrUtil.isNotEmpty(mdBaseVehicle.getVehicle_type()) ? mdBaseVehicle.getVehicle_type() : ""); param.put("vehicle_type", mdBaseVehicle.getVehicle_type());
connectorTask.apply(param); connectorTask.apply(param);
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
.eq(SchBasePoint::getPoint_code, schBaseTask.getPoint_code1()).set(SchBasePoint::getIs_lock, true)); .eq(SchBasePoint::getPoint_code, schBaseTask.getPoint_code1()).set(SchBasePoint::getIs_lock, true));
}
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("vehicle_code", schBaseTask.getVehicle_code()); json.put("vehicle_code", vehicle_code);
json.put("status", status); json.put("status", status);
json.put("device_code", schBaseTask.getPoint_code1()); json.put("device_code", schBaseTask.getPoint_code1());
json.put("task_code", schBaseTask.getTask_code()); json.put("task_code", schBaseTask.getTask_code());
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json);
} }
if ("2".equals(is_connector)) {
JSONObject json = new JSONObject();
json.put("vehicle_code", vehicle_code);
json.put("status", status);
json.put("device_code", schBaseTask.getPoint_code1());
json.put("task_code", schBaseTask.getTask_code());
AcsResponse acsResponse = sortingService.feedAgvTaskStatus(json);
}
} }
/** /**

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/sorting/service/impl/SortingServiceImpl.java

@ -58,7 +58,7 @@ public class SortingServiceImpl implements SortingService {
//托盘上的堆垛信息 //托盘上的堆垛信息
JSONArray jsonArray = JSONUtil.parseArray(jsonObject.get("pallet_detail")); JSONArray jsonArray = JSONUtil.parseArray(jsonObject.get("pallet_detail"));
// TODO:呼叫空托 // TODO:呼叫空托
JSONObject taskParam = new JSONObject(MapOf.of("device_code",pointCode,"requestNo", "sorting_"+IdUtil.getStringId(),"ext_data",jsonObject)); JSONObject taskParam = new JSONObject(MapOf.of("task_code",task_code,"job_name",jobname,"device_code",pointCode,"requestNo", "sorting_"+IdUtil.getStringId(),"ext_data",jsonObject));
if(SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)){ if(SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)){
taskParam.put("config_code","sortingCNTTask"); taskParam.put("config_code","sortingCNTTask");
sortingCNTTask.apply(taskParam); sortingCNTTask.apply(taskParam);

41
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/sorting/service/impl/WmsToSortingService.java

@ -0,0 +1,41 @@
package org.nl.wms.ext.sorting.service.impl;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.config.MapOf;
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
import org.nl.wms.ext.connector.service.WmsToConnectorService;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.task.ConnectorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author LENOVO
*/
@Slf4j
@Service
public class WmsToSortingService {
@Autowired
private ISchBaseTaskService iSchBaseTaskService;
public AcsResponse feedAgvTaskStatus(JSONObject json) {
String task_code = json.getString("task_code");
SchBaseTask task = iSchBaseTaskService.getByCode(task_code);
String request_param = task.getRequest_param();
JSONObject toJSON = (JSONObject)JSONObject.toJSON(request_param);
String ext_data = toJSON.getString("ext_data");
if (StringUtils.isEmpty(ext_data)){
throw new BadRequestException("WmsToSortingService反馈异常,sorting对接数据ext_data为空");
}
AcsResponse acsResponse = ConnectorUtil.notifyEextSystem("api/external/wms/agv", ext_data, GeneralDefinition.SORTING_URL);
return acsResponse;
}
}

1
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java

@ -267,6 +267,7 @@ public abstract class AbstractTask {
task.setVehicle_code(param.getString("vehicle_code")); task.setVehicle_code(param.getString("vehicle_code"));
task.setVehicle_qty(param.getInteger("vehicle_qty")); task.setVehicle_qty(param.getInteger("vehicle_qty"));
task.setVehicle_type(param.getString("vehicle_type")); task.setVehicle_type(param.getString("vehicle_type"));
task.setJob_name(param.getString("job_name"));
task.setTask_status(TaskStatus.APPLY.getCode()); task.setTask_status(TaskStatus.APPLY.getCode());
task.setTask_type(StrUtil.isNotEmpty(param.getString("task_type")) ? param.getString("task_type") : taskConfig.getTask_type()); task.setTask_type(StrUtil.isNotEmpty(param.getString("task_type")) ? param.getString("task_type") : taskConfig.getTask_type());
task.setWorkshop_code(taskConfig.getWorkshop_code()); task.setWorkshop_code(taskConfig.getWorkshop_code());

1
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java

@ -65,6 +65,7 @@ public class GeneralDefinition {
* CONNECTOR路径 * CONNECTOR路径
*/ */
public static final String CONNECTOR_URL = "connector_url"; public static final String CONNECTOR_URL = "connector_url";
public static final String SORTING_URL = "sorting_url";
/** 是否连接 */ /** 是否连接 */
public static final String IS_CONNECT_MES = "is_connect_mes"; public static final String IS_CONNECT_MES = "is_connect_mes";
/** MES路径 */ /** MES路径 */

37
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/ConnectorUtil.java

@ -86,7 +86,42 @@ public class ConnectorUtil {
return AcsResponse.requestRefuse("未连接ACS!"); return AcsResponse.requestRefuse("未连接ACS!");
} }
String url = connectorUrl + api; String url = connectorUrl + api;
log.info("下发acs任务的参数为:{}", object.toString()); log.info("下发acs任务的参数为:{}", JSON.toJSONString(object));
AcsResponse resultForAcs;
try {
String resultMsg = HttpRequest.post(url)
.body(JSON.toJSONString(object))
.execute().body();
result = JSONObject.parseObject(resultMsg);
resultForAcs = JSONObject.toJavaObject(result, AcsResponse.class);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
log.error("连接失败:{}", msg);
return AcsResponse.requestRefuse("网络不通,操作失败!");
}
return resultForAcs;
}
public static <T> AcsResponse notifyEextSystem(String api, T object,String urlConfig) {
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
//判断是否连接ACS系统
Param isConnectConnector = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_CONNECTOR);
if (ObjectUtil.isEmpty(isConnectConnector)) {
return AcsResponse.requestRefuse("参数表中:" + GeneralDefinition.IS_CONNECT_CONNECTOR + "不存在");
}
String isConnect = isConnectConnector.getValue();
//ACS地址:127.0.0.1:8010
Param connectorUrlObj = sysParamService.findByCode(urlConfig);
if (ObjectUtil.isEmpty(connectorUrlObj)) {
return AcsResponse.requestRefuse("参数表中:" + urlConfig + "不存在");
}
String connectorUrl = connectorUrlObj.getValue();
JSONObject result;
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
return AcsResponse.requestRefuse("未连接ACS!");
}
String url = connectorUrl + api;
log.info("下发acs任务的参数为:{}", JSON.toJSONString(object));
AcsResponse resultForAcs; AcsResponse resultForAcs;
try { try {
String resultMsg = HttpRequest.post(url) String resultMsg = HttpRequest.post(url)

Loading…
Cancel
Save