add:添加connector下发任务,LMS反馈任务状态接口
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package org.nl.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 货物状态枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum GoodsEnum {
|
||||
|
||||
|
||||
OUT_OF_STOCK("无货","0"),
|
||||
|
||||
IN_STOCK("有货","1"),
|
||||
|
||||
PICK_UP("取货","1"),
|
||||
|
||||
DELIVER_GOODS("送货","2");
|
||||
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.common.enums.region;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RegionEnum {
|
||||
|
||||
STAMPING_AND_BLANKING("Amada 80T冲床(手动加工)","111-06"),
|
||||
TRUBEND_SHELVES_3_1_1("TruBend 7036货架03-01-01","111-07");
|
||||
|
||||
private final String region_name;
|
||||
private final String region_code;
|
||||
|
||||
}
|
||||
@@ -88,4 +88,14 @@ public class AcsToWmsController {
|
||||
// public ResponseEntity<Object> notify(@RequestBody JSONObject param) {
|
||||
// return new ResponseEntity<>(acsToWmsService.notify(param), HttpStatus.OK);
|
||||
// }
|
||||
|
||||
|
||||
@PostMapping("/feedAgvTaskStatus")
|
||||
@Log("acs通知wms")
|
||||
@ApiOperation("acs通知wms")
|
||||
@SaIgnore
|
||||
@Deprecated
|
||||
public ResponseEntity<Object> feedAgvTaskStatus(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acsToWmsService.feedAgvTaskStatus(param), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,11 @@ public interface AcsToWmsService {
|
||||
* @return
|
||||
*/
|
||||
AgainApplyResponse againApply(JSONObject task);
|
||||
|
||||
/**
|
||||
*反馈agv取放货状态
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Object feedAgvTaskStatus(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.ext.acs.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
@@ -18,4 +19,9 @@ public interface WmsToAcsService {
|
||||
*/
|
||||
AcsResponse notifyAcs(JSONObject map);
|
||||
|
||||
/**
|
||||
* 下发acs任务
|
||||
* @param schBaseTask
|
||||
*/
|
||||
void createTask(SchBaseTask schBaseTask);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,15 @@ public class BaseResponse implements Serializable {
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private int status;
|
||||
|
||||
/**
|
||||
* 响应体
|
||||
*/
|
||||
private String data;
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package org.nl.wms.ext.acs.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.GoodsEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.wms.cockpit.service.dao.DasDeviceFault;
|
||||
@@ -13,13 +17,18 @@ import org.nl.wms.cockpit.service.mapper.CockpitMapper;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
|
||||
import org.nl.wms.ext.acs.service.dto.to.acs.AgainApplyResponse;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
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.dto.ConnectorDto;
|
||||
import org.nl.wms.ext.record.service.ISysInteractRecordService;
|
||||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
|
||||
@@ -69,6 +78,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
private ISysInteractRecordService interactRecordService;
|
||||
@Autowired
|
||||
private CockpitMapper cockpitMapper;
|
||||
@Autowired
|
||||
private WmsToConnectorService connectorService;
|
||||
@Autowired
|
||||
private ISchBaseTaskconfigService taskConfigService;
|
||||
|
||||
/**
|
||||
* 初始化反射方法
|
||||
@@ -199,8 +212,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
case 3:
|
||||
//设备反馈故障
|
||||
try {
|
||||
SchBasePoint schBasePoint=pointService.getById(device_code);
|
||||
if(ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
SchBasePoint schBasePoint = pointService.getById(device_code);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
if ("0".equals(state)) {
|
||||
schBasePoint.setIs_used(true);
|
||||
pointService.update(schBasePoint);
|
||||
@@ -211,7 +224,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
dasDeviceFault.setRegion_code(pointService.getById(device_code).getRegion_code());
|
||||
dasDeviceFault.setData_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dasDeviceFault.setFailure_time(now);
|
||||
dasDeviceFault.setFailure_info(state+"故障");
|
||||
dasDeviceFault.setFailure_info(state + "故障");
|
||||
cockpitMapper.insertDeviceFault(dasDeviceFault);
|
||||
schBasePoint.setIs_used(false);
|
||||
pointService.update(schBasePoint);
|
||||
@@ -251,6 +264,79 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object feedAgvTaskStatus(JSONObject param) {
|
||||
if (ObjectUtil.isNotEmpty(param)) {
|
||||
String status = param.getString("status");
|
||||
String task_code = param.getString("task_code");
|
||||
if (StrUtil.isEmpty(status) || StrUtil.isEmpty(task_code)) {
|
||||
throw new BadRequestException("状态或任务号为空!");
|
||||
}
|
||||
SchBaseTask schBaseTask = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(schBaseTask)) {
|
||||
throw new BadRequestException("任务不存在!taskCode:" + task_code);
|
||||
}
|
||||
switch (status) {
|
||||
case "1":
|
||||
//申请取货
|
||||
requestPickup(schBaseTask, status);
|
||||
break;
|
||||
case "2":
|
||||
//取货完成
|
||||
requestDeliver(schBaseTask, status);
|
||||
break;
|
||||
case "4":
|
||||
//放货完成
|
||||
requestDeliver(schBaseTask, status);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取货完成
|
||||
*
|
||||
* @param schBaseTask
|
||||
* @param status
|
||||
*/
|
||||
private void requestDeliver(SchBaseTask schBaseTask, String status) {
|
||||
//TODO:取货完成创建第二条任务:补空托盘
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请取货
|
||||
*
|
||||
* @param schBaseTask
|
||||
*/
|
||||
private void requestPickup(SchBaseTask schBaseTask, String status) {
|
||||
//反馈connector申请取货
|
||||
SchBaseTaskconfig schBaseTaskconfig = taskConfigService.selectByConfigCode(schBaseTask.getConfig_code());
|
||||
JSONObject json = new JSONObject();
|
||||
if (GoodsEnum.PICK_UP.getValue().equals(schBaseTaskconfig.getTask_qf_type())) {
|
||||
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());
|
||||
} else if (GoodsEnum.DELIVER_GOODS.getValue().equals(schBaseTaskconfig.getTask_qf_type())) {
|
||||
json.put("vehicle_code", schBaseTask.getVehicle_code());
|
||||
json.put("status", status);
|
||||
json.put("device_code", schBaseTask.getPoint_code1());
|
||||
json.put("task_code", schBaseTask.getTask_code());
|
||||
}
|
||||
boolean flag = true;
|
||||
while (flag) {
|
||||
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json);
|
||||
if (acsResponse.getStatus() == 200 && StrUtil.isNotEmpty(acsResponse.getData())) {
|
||||
vehiclematerialgroupService.updateByVehicleCode(schBaseTask.getVehicle_code(),acsResponse.getData());
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务阶段反馈最新点位
|
||||
* todo
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.task.AcsUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -27,4 +28,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void createTask(SchBaseTask schBaseTask) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nl.wms.ext.connector.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.ext.connector.service.ConnectorToWmsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "connector请求lms")
|
||||
@RequestMapping("/api/")
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class ConnectorToWmsController {
|
||||
|
||||
@Autowired
|
||||
private ConnectorToWmsService connectorService;
|
||||
|
||||
|
||||
@Log("connector下发agv任务")
|
||||
@ApiOperation("connector下发agv任务")
|
||||
@SaIgnore
|
||||
@PostMapping("/wms/task")
|
||||
public Object createTaskByConnector(@RequestBody JSONArray jsonArray){
|
||||
Object taskByConnector = connectorService.createTaskByConnector(jsonArray);
|
||||
return taskByConnector;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.wms.ext.connector.service;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ConnectorToWmsService {
|
||||
|
||||
|
||||
/**
|
||||
* connector下发agv任务
|
||||
* @param jsonArray
|
||||
* @return
|
||||
*/
|
||||
Object createTaskByConnector(JSONArray jsonArray);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.wms.ext.connector.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
|
||||
/**
|
||||
* @author LENOVO
|
||||
*/
|
||||
public interface WmsToConnectorService {
|
||||
/**
|
||||
* 反馈agv任务取放货状态
|
||||
* @param json
|
||||
*/
|
||||
AcsResponse feedAgvTaskStatus(JSONObject json);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.nl.wms.ext.connector.service.dto;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ConnectorDto {
|
||||
|
||||
/**
|
||||
* 数据ID
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
private String Jobname;
|
||||
|
||||
/**
|
||||
* 下料小车托盘号
|
||||
*/
|
||||
private String PalletID;
|
||||
|
||||
/**
|
||||
* 物料号
|
||||
*/
|
||||
private String ProductID;
|
||||
/**
|
||||
* 装载数量
|
||||
*/
|
||||
private String Currentqty;
|
||||
/**
|
||||
* X尺寸
|
||||
*/
|
||||
private String SizeX;
|
||||
/**
|
||||
* Y尺寸
|
||||
*/
|
||||
private String SizeY;
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private String Angle;
|
||||
/**
|
||||
* 厚度
|
||||
*/
|
||||
private String Thickness;
|
||||
/**
|
||||
* X坐标
|
||||
*/
|
||||
private String PositionX;
|
||||
/**
|
||||
* Y坐标
|
||||
*/
|
||||
private String PositionY;
|
||||
/**
|
||||
* 载具号
|
||||
*/
|
||||
private String vehicle_code;
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
private String ProductionOrder;
|
||||
/**
|
||||
* JOBFinishFlag
|
||||
*/
|
||||
private String Finished;
|
||||
/**
|
||||
* 下一道工序
|
||||
*/
|
||||
private String NextOperation;
|
||||
/**
|
||||
* 截至时间
|
||||
*/
|
||||
private String DueDate;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package org.nl.wms.ext.connector.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.connector.service.ConnectorToWmsService;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.task.TaskFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ConnectorToWmsServiceImpl implements ConnectorToWmsService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISchBasePointService schBasePointService;
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskService schBaseTaskService;
|
||||
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
|
||||
@Autowired
|
||||
private TaskFactory taskFactory;
|
||||
|
||||
@Override
|
||||
public Object createTaskByConnector(JSONArray jsonArray) {
|
||||
log.info("connector下发agv任务请求参数:{}", jsonArray);
|
||||
Map map = new HashMap();
|
||||
com.alibaba.fastjson.JSONArray objects = new com.alibaba.fastjson.JSONArray();
|
||||
if (CollUtil.isEmpty(jsonArray) || jsonArray.size() == 0) {
|
||||
map.put("status", HttpStatus.HTTP_INTERNAL_ERROR);
|
||||
map.put("message", "请求参数为空!");
|
||||
objects.add(map);
|
||||
return objects;
|
||||
}
|
||||
try {
|
||||
for (Object jsonObject : jsonArray) {
|
||||
Map map1 = new HashMap();
|
||||
JSONObject data = JSONObject.parseObject(jsonObject.toString());
|
||||
String task_code = data.getString("task_code");
|
||||
String start_device_code = data.getString("start_device_code");
|
||||
String vehicle_code = data.getString("vehicle_code");
|
||||
if (StrUtil.isEmpty(task_code) || StrUtil.isEmpty(start_device_code) || StrUtil.isEmpty(vehicle_code)) {
|
||||
map1.put("task_code", task_code);
|
||||
map1.put("status", HttpStatus.HTTP_INTERNAL_ERROR);
|
||||
map1.put("message",StrUtil.isEmpty(task_code) ? "任务号不能为空!"
|
||||
: StrUtil.isEmpty(start_device_code) ? "起点参数不能为空!" : StrUtil.isEmpty(vehicle_code) ? "载具号不能为空!" : "未知");
|
||||
objects.add(map1);
|
||||
continue;
|
||||
}
|
||||
SchBasePoint schBasePoint = schBasePointService.selectByPointCode(start_device_code);
|
||||
if(ObjectUtil.isEmpty(schBasePoint) || StrUtil.isNotEmpty(schBasePoint.getIng_task_code())){
|
||||
map1.put("task_code", task_code);
|
||||
map1.put("status", HttpStatus.HTTP_INTERNAL_ERROR);
|
||||
map1.put("message",ObjectUtil.isEmpty(schBasePoint)
|
||||
? start_device_code + "起点设备不存在!" : start_device_code + "该设备正在执行任务!");
|
||||
objects.add(map1);
|
||||
continue;
|
||||
}
|
||||
//TODO:固定的载具类型,根据载具类型来决定终点
|
||||
String task_type = data.getString("task_type");
|
||||
String is_empty = data.getString("is_empty");
|
||||
String remark = data.getString("remark");
|
||||
String params = data.getString("params");
|
||||
task_type = "1".equals(task_type) ? "1" : "2";
|
||||
AbstractTask connectorTask = taskFactory.getTask("CNTTask");
|
||||
// 准备参数:设备编码
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("device_code", start_device_code);
|
||||
param.put("config_code", "CNTTask");
|
||||
param.put("create_mode", GeneralDefinition.AUTO_CREATION);
|
||||
param.put("vehicle_code", vehicle_code);
|
||||
param.put("task_type", task_type);
|
||||
param.put("task_code", task_code);
|
||||
param.put("remark",remark);
|
||||
connectorTask.apply(param);
|
||||
schBasePoint.setIng_task_code(task_code);
|
||||
schBasePointService.updateById(schBasePoint);
|
||||
map1.put("task_code", task_code);
|
||||
map1.put("status", HttpStatus.HTTP_OK);
|
||||
map1.put("message", "操作成功!");
|
||||
objects.add(map1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
map.put("status", HttpStatus.HTTP_INTERNAL_ERROR);
|
||||
map.put("message", e.getMessage());
|
||||
objects.add(map);
|
||||
return objects;
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.wms.ext.connector.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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_manage.task.AcsUtil;
|
||||
import org.nl.wms.sch.task_manage.task.ConnectorUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author LENOVO
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WmsToConnectorServiceImpl implements WmsToConnectorService {
|
||||
|
||||
|
||||
@Override
|
||||
public AcsResponse feedAgvTaskStatus(JSONObject json) {
|
||||
String api = "api/iot/agvtask";
|
||||
AcsResponse acsResponse = ConnectorUtil.notifyConnector2(api, json);
|
||||
return acsResponse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.wms.ext.sorting.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.ext.sorting.service.SortingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "acs请求lms")
|
||||
@RequestMapping("/api/wms")
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class SortingController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SortingService sortingService;
|
||||
|
||||
@PostMapping("/agv")
|
||||
@Log("sorting下发agv任务")
|
||||
@ApiOperation("sorting下发agv任务")
|
||||
@SaIgnore
|
||||
public Map createAgvTaskBySorting(@RequestBody JSONObject jsonObject){
|
||||
Map map = sortingService.createAgvTask(jsonObject);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.wms.ext.sorting.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SortingEnum {
|
||||
|
||||
TASK_TYPE_ONE("运送托盘到sortinga站","1"),
|
||||
|
||||
TASK_TYPE_TWO("从sorting站取托盘给线边库","2"),
|
||||
|
||||
IS_EMPTY("托盘为空","1"),
|
||||
|
||||
NOT_EMPTY("托盘不为空","0");
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.wms.ext.sorting.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author LENOVO
|
||||
*/
|
||||
public interface SortingService {
|
||||
|
||||
/**
|
||||
* sorting下发agv任务
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
Map createAgvTask(JSONObject jsonObject);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.nl.wms.ext.sorting.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext.sorting.enums.SortingEnum;
|
||||
import org.nl.wms.ext.sorting.service.SortingService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author LENOVO
|
||||
*/
|
||||
@Service
|
||||
public class SortingServiceImpl implements SortingService {
|
||||
|
||||
|
||||
@Override
|
||||
public Map createAgvTask(JSONObject jsonObject) {
|
||||
Map map = new HashMap();
|
||||
if(ObjectUtil.isEmpty(jsonObject)){
|
||||
map.put("status", 200);
|
||||
map.put("msg", "操作失败");
|
||||
map.put("errMsg","参数对象为空");
|
||||
map.put("data", null);
|
||||
return map;
|
||||
}
|
||||
//任务号
|
||||
String task_code = jsonObject.getString("task_code");
|
||||
//任务类型:1.运送托盘到sorting;2.从sorting运送托盘给线边库
|
||||
String task_type = jsonObject.getString("task_type");
|
||||
//是否空托盘; 1.是 0.否
|
||||
String is_empty = jsonObject.getString("is_empty");
|
||||
String task_time = jsonObject.getString("task_time");
|
||||
//冲床工作号
|
||||
String jobname = jsonObject.getString("jobname");
|
||||
//载具托盘号
|
||||
String vehicle_code = jsonObject.getString("vehicle_code");
|
||||
//托盘上的堆垛信息
|
||||
JSONArray jsonArray = JSONUtil.parseArray(jsonObject.get("pallet_detail"));
|
||||
// TODO:呼叫空托
|
||||
if(SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)){
|
||||
|
||||
//TODO:叫料
|
||||
}else if(SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)){
|
||||
|
||||
//TODO:将空托盘放到线边库
|
||||
}else if(SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)){
|
||||
|
||||
//TODO:将满料放到线边库
|
||||
}else if(SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)){
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -57,4 +57,11 @@ public interface ISchBaseVehiclematerialgroupService extends IService<SchBaseVeh
|
||||
* @return
|
||||
*/
|
||||
SchBaseVehiclematerialgroup getVehicleGroupInfo(String vehicleCode, String vehicleType, String status);
|
||||
|
||||
/**
|
||||
* 根据载具号更新阻盘信息
|
||||
* @param vehicle_code
|
||||
* @param data
|
||||
*/
|
||||
void updateByVehicleCode(String vehicle_code, String data);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,9 @@ public class SchBaseVehiclematerialgroup implements Serializable {
|
||||
@ApiModelProperty(value = "下一任务编码")
|
||||
private String next_task_code;
|
||||
|
||||
@ApiModelProperty(value = "扩展")
|
||||
private String extend;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -100,4 +101,10 @@ public class SchBaseVehiclematerialgroupServiceImpl extends ServiceImpl<SchBaseV
|
||||
return selectOne.size() > 0 ? selectOne.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVehicleCode(String vehicle_code, String data) {
|
||||
update(Wrappers.lambdaUpdate(SchBaseVehiclematerialgroup.class).eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code)
|
||||
.set(SchBaseVehiclematerialgroup::getExtend, data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,4 +73,17 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
|
||||
* @return
|
||||
*/
|
||||
SchBasePoint selectByIdLock(String id);
|
||||
|
||||
/**
|
||||
* 根据工序查询区域存放位置
|
||||
* @param region_code
|
||||
*/
|
||||
SchBasePoint selectByRegionCode(String region_code);
|
||||
|
||||
/**
|
||||
* 根据点位编码查询
|
||||
* @param start_device_code
|
||||
* @return
|
||||
*/
|
||||
SchBasePoint selectByPointCode(String start_device_code);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,9 @@ public class SchBasePoint implements Serializable {
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean is_used;
|
||||
|
||||
@ApiModelProperty(value = "是否货")
|
||||
private String is_goods;
|
||||
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String create_id;
|
||||
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package org.nl.wms.sch.point.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.enums.GoodsEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.point.service.dao.mapper.SchBasePointMapper;
|
||||
@@ -30,6 +33,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -216,4 +220,33 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
return pointMapper.selectByIdLock(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SchBasePoint selectByRegionCode(String region_code) {
|
||||
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getRegion_code, region_code)
|
||||
.eq(SchBasePoint::getIs_used, true).isNull(SchBasePoint::getIng_task_code));
|
||||
if(CollUtil.isEmpty(schBasePoints)) return null;
|
||||
//TODO:货位有无货的三种状态: 无货,空料容,有货
|
||||
List<SchBasePoint> collect = schBasePoints.stream().filter(schBasePoint -> GoodsEnum.OUT_OF_STOCK.getValue().equals(schBasePoint.getIs_goods())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(collect) && collect.size() > 0){
|
||||
return collect.get(0);
|
||||
}
|
||||
String can_vehicle_type = null;
|
||||
for (SchBasePoint schBasePoint : schBasePoints) {
|
||||
can_vehicle_type = schBasePoint.getCan_vehicle_type();
|
||||
if(StrUtil.isNotEmpty(can_vehicle_type)) break;
|
||||
}
|
||||
if(ObjectUtil.isEmpty(can_vehicle_type)) return null;
|
||||
List<SchBasePoint> schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getCan_vehicle_type, can_vehicle_type)
|
||||
.eq(SchBasePoint::getIs_used, true).eq(SchBasePoint::getIs_goods, true).isNull(SchBasePoint::getIng_task_code));
|
||||
if(ObjectUtil.isEmpty(schBasePoints1) || schBasePoints1.size() == 0) return null;
|
||||
return schBasePoints1.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchBasePoint selectByPointCode(String start_device_code) {
|
||||
return getById(start_device_code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,4 +40,9 @@ public interface ISchBaseTaskconfigService extends IService<SchBaseTaskconfig> {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 根据配置编码查询
|
||||
*/
|
||||
SchBaseTaskconfig selectByConfigCode(String configCode);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public class SchBaseTask implements Serializable {
|
||||
@ApiModelProperty(value = "任务状态")
|
||||
private String task_status;
|
||||
|
||||
@ApiModelProperty(value = "任务类型")
|
||||
private String task_type;
|
||||
|
||||
@ApiModelProperty(value = "配置编码")
|
||||
private String config_code;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
String begin_time = ObjectUtil.isNotEmpty(whereJson.get("begin_time")) ? whereJson.get("begin_time").toString() : null;
|
||||
String end_time = ObjectUtil.isNotEmpty(whereJson.get("end_time")) ? whereJson.get("end_time").toString() : null;
|
||||
String more_task_status = ObjectUtil.isNotEmpty(whereJson.get("more_task_status")) ? whereJson.get("more_task_status").toString() : null;
|
||||
List<String> collect = ObjectUtil.isNotEmpty(more_task_status)?Arrays.stream(more_task_status.split(",")).collect(Collectors.toList()):null;
|
||||
List<String> collect = ObjectUtil.isNotEmpty(more_task_status) ? Arrays.stream(more_task_status.split(",")).collect(Collectors.toList()) : null;
|
||||
String unFinished = null;
|
||||
if (collect != null) {
|
||||
if (collect.contains(TaskStatus.UNFINISHED.getCode())) {
|
||||
@@ -70,9 +70,13 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
.eq(ObjectUtil.isNotEmpty(point_code), SchBaseTask::getPoint_code1, point_code)
|
||||
.ge(ObjectUtil.isNotEmpty(begin_time), SchBaseTask::getCreate_time, begin_time)
|
||||
.le(ObjectUtil.isNotEmpty(end_time), SchBaseTask::getCreate_time, end_time)
|
||||
.in(ObjectUtil.isNotEmpty(collect), SchBaseTask::getTask_status, collect)
|
||||
.le(ObjectUtil.isNotEmpty(unFinished), SchBaseTask::getTask_status, unFinished)
|
||||
.orderByDesc(SchBaseTask::getUpdate_time);
|
||||
if (ObjectUtil.isNotEmpty(collect)) {
|
||||
lam.in(SchBaseTask::getTask_status, collect);
|
||||
} else {
|
||||
lam.in(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(), TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode());
|
||||
}
|
||||
IPage<SchBaseTask> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
schBaseTaskMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
@@ -179,30 +183,30 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
String vehicle_code = ObjectUtil.isNotEmpty(param.getString("vehicle_code")) ? param.getString("vehicle_code") : null;
|
||||
String config_code = param.getString("config_code");
|
||||
|
||||
if("4".equals(type)){
|
||||
//4-叫料
|
||||
if ("4".equals(type)) {
|
||||
//4-叫料
|
||||
|
||||
}else if("5".equals(type)){
|
||||
//5-满料出库
|
||||
if(device_code.startsWith("TBX")){
|
||||
config_code="MJXLTask";
|
||||
param.put("config_code",config_code);
|
||||
}
|
||||
} else if ("5".equals(type)) {
|
||||
//5-满料出库
|
||||
if (device_code.startsWith("TBX")) {
|
||||
config_code = "MJXLTask";
|
||||
param.put("config_code", config_code);
|
||||
}
|
||||
|
||||
}else if("6".equals(type)){
|
||||
//6-申请空盘
|
||||
} else if ("6".equals(type)) {
|
||||
//6-申请空盘
|
||||
|
||||
}else if("7".equals(type)){
|
||||
//7-空托盘出库
|
||||
} else if ("7".equals(type)) {
|
||||
//7-空托盘出库
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(ObjectUtil.isEmpty(config_code)){
|
||||
throw new BadRequestException("任务类型不正确!device_code:"+device_code+",type:"+type);
|
||||
}
|
||||
AbstractTask task = taskFactory.getTask(config_code);
|
||||
// 执行创建任务
|
||||
task.apply(param);
|
||||
if (ObjectUtil.isEmpty(config_code)) {
|
||||
throw new BadRequestException("任务类型不正确!device_code:" + device_code + ",type:" + type);
|
||||
}
|
||||
AbstractTask task = taskFactory.getTask(config_code);
|
||||
// 执行创建任务
|
||||
task.apply(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -63,8 +64,8 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs()))
|
||||
throw new BadRequestException("起点区域和终点区域不能同时为空!");
|
||||
/*if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs()))
|
||||
throw new BadRequestException("起点区域和终点区域不能同时为空!");*/
|
||||
|
||||
if (ObjectUtil.isNotEmpty(entity.getStart_region_strs())) {
|
||||
// 起点区域配置
|
||||
@@ -92,8 +93,8 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
|
||||
public void update(SchBaseTaskconfig entity) {
|
||||
SchBaseTaskconfig dto = schBaseTaskconfigMapper.selectById(entity.getConfig_id());
|
||||
if (dto == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs()))
|
||||
throw new BadRequestException("起点区域和终点区域不能同时为空!");
|
||||
/*if (ObjectUtil.isAllEmpty(entity.getStart_region_strs(), entity.getNext_region_strs()))
|
||||
throw new BadRequestException("起点区域和终点区域不能同时为空!");*/
|
||||
|
||||
if (ObjectUtil.isNotEmpty(entity.getStart_region_strs())) {
|
||||
// 起点区域配置
|
||||
@@ -122,4 +123,9 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
|
||||
schBaseTaskconfigMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchBaseTaskconfig selectByConfigCode(String configCode) {
|
||||
return getOne(Wrappers.lambdaQuery(SchBaseTaskconfig.class).eq(SchBaseTaskconfig::getConfig_code, configCode));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.sch.task_manage;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -106,7 +107,7 @@ public abstract class AbstractTask {
|
||||
// taskDto.setStart_wait_code(task.getStart_wait_point());
|
||||
// taskDto.setNext_wait_code(task.getNext_wait_point());
|
||||
taskDto.setVehicle_code(task.getVehicle_code());
|
||||
this.setTask(task.getConfig_code(), taskDto);
|
||||
this.setTask(task.getConfig_code(), taskDto,task);
|
||||
list.add(taskDto);
|
||||
JSONObject result = AcsUtil.notifyAcs("api/wms/task", list);
|
||||
if (HttpStatus.OK.value() == result.getInteger("status")) {
|
||||
@@ -114,15 +115,18 @@ public abstract class AbstractTask {
|
||||
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode());
|
||||
taskService.update(schBaseTask);
|
||||
}
|
||||
} else if (HttpStatus.BAD_REQUEST.value() == result.getInteger("status")) {
|
||||
task.setRemark(result.getString("message"));
|
||||
taskService.update(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private AcsTaskDto setTask(String config_code, AcsTaskDto taskDto) {
|
||||
private AcsTaskDto setTask(String config_code, AcsTaskDto taskDto,SchBaseTask task) {
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, config_code));
|
||||
taskDto.setPriority(taskConfig.getPriority());
|
||||
taskDto.setTask_type(taskConfig.getTask_type());
|
||||
taskDto.setTask_type(StrUtil.isNotEmpty(task.getTask_type()) ? task.getTask_type() : taskConfig.getTask_type());
|
||||
taskDto.setAgv_task_type(taskConfig.getAcs_task_type());
|
||||
taskDto.setRoute_plan_code(taskConfig.getRoute_plan_code());
|
||||
return taskDto;
|
||||
@@ -215,6 +219,7 @@ public abstract class AbstractTask {
|
||||
String apply_point_code = param.getString("device_code");
|
||||
String config_code = param.getString("config_code");
|
||||
String requestNo = param.getString("requestNo");
|
||||
String task_code = param.getString("task_code");
|
||||
// 1、校验数据
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, config_code));
|
||||
@@ -255,14 +260,16 @@ public abstract class AbstractTask {
|
||||
// 2、创建申请任务
|
||||
task.setAcs_trace_id(requestNo);
|
||||
task.setTask_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
task.setTask_code(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
task.setTask_code(StrUtil.isNotEmpty(param.getString("task_code")) ? task_code : IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
task.setConfig_code(config_code);
|
||||
task.setCreate_mode(ObjectUtil.isNotEmpty(param.getString("create_mode"))
|
||||
? param.getString("create_mode") : GeneralDefinition.ACS_CREATION);
|
||||
task.setVehicle_code(param.getString("vehicle_code"));
|
||||
task.setVehicle_qty(param.getInteger("vehicle_qty"));
|
||||
task.setTask_status(TaskStatus.APPLY.getCode());
|
||||
task.setTask_type(param.getString("task_type"));
|
||||
task.setWorkshop_code(taskConfig.getWorkshop_code());
|
||||
task.setRemark(param.getString("remark"));
|
||||
// 设置起/终点
|
||||
this.setTaskPoint(taskConfig, task, apply_point_code);
|
||||
task.setRequest_param(JSONObject.toJSONString(param));
|
||||
|
||||
@@ -58,8 +58,13 @@ public class GeneralDefinition {
|
||||
// 参数名称
|
||||
/** 是否连接 */
|
||||
public static final String IS_CONNECT_ACS = "is_connect_acs";
|
||||
public static final String IS_CONNECT_CONNECTOR = "is_connect_connector";
|
||||
/** ACS路径 */
|
||||
public static final String ACS_URL = "acs_url";
|
||||
/**
|
||||
* CONNECTOR路径
|
||||
*/
|
||||
public static final String CONNECTOR_URL = "connector_url";
|
||||
/** 是否连接 */
|
||||
public static final String IS_CONNECT_MES = "is_connect_mes";
|
||||
/** MES路径 */
|
||||
|
||||
@@ -14,7 +14,8 @@ public enum TaskFinishedTypeEnum {
|
||||
|
||||
AUTO_ACS("1", "ACS自动完成"),
|
||||
MANUAL_PC("2", "PC手完成"),
|
||||
MANUAL_PDA("3", "PDA手持");
|
||||
MANUAL_PDA("3", "PDA手持"),
|
||||
MANUAL_CONNECTOR("4","connector任务完成");
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
|
||||
package org.nl.wms.sch.task_manage.task;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
import org.nl.wms.sch.task_manage.AcsTaskDto;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ACS连接工具类:
|
||||
*/
|
||||
@Slf4j
|
||||
public class ConnectorUtil {
|
||||
public static JSONObject notifyAcs(String api, List<AcsTaskDto> list) {
|
||||
//判断是否连接ACS系统
|
||||
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
|
||||
// list转JSONArray
|
||||
String s = JSON.toJSONString(list);
|
||||
JSONObject result = new JSONObject();
|
||||
if (StrUtil.equals("0", isConnect)) {
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", "未连接ACS!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
}
|
||||
//ACS地址:127.0.0.1:8010
|
||||
String acsUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("acs_url").getValue();
|
||||
|
||||
String url = acsUrl + api;
|
||||
log.info("下发acs任务的参数为:{}", list.toString());
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(s)
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//ConnectException: Connection refused: connect
|
||||
//网络不通
|
||||
log.error("连接失败:{}", msg);
|
||||
result.put("status", HttpStatus.BAD_REQUEST);
|
||||
result.put("message", "网络不通,操作失败!");
|
||||
result.put("data", new JSONObject());
|
||||
}
|
||||
//acs抛异常这里
|
||||
/* if (result.getString("status").equals(String.valueOf(HttpStatus.BAD_REQUEST.value())))
|
||||
throw new BadRequestException(result.getString("message"));*/
|
||||
// 如果下发完毕,就修改状态
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新的请求方式:对象中包含数组
|
||||
* @param api
|
||||
* @param object
|
||||
* @return
|
||||
* @param <T>
|
||||
*/
|
||||
public static <T> AcsResponse notifyConnector2(String api, T object) {
|
||||
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(GeneralDefinition.CONNECTOR_URL);
|
||||
if (ObjectUtil.isEmpty(connectorUrlObj)) {
|
||||
return AcsResponse.requestRefuse("参数表中:" + GeneralDefinition.CONNECTOR_URL + "不存在");
|
||||
}
|
||||
String connectorUrl = connectorUrlObj.getValue();
|
||||
JSONObject result;
|
||||
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
|
||||
return AcsResponse.requestRefuse("未连接ACS!");
|
||||
}
|
||||
String url = connectorUrl + api;
|
||||
log.info("下发acs任务的参数为:{}", object.toString());
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package org.nl.wms.sch.task_manage.task.tasks.cnt;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.region.RegionEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
|
||||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
|
||||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
||||
import org.nl.wms.util.PointUtils;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component(value = "CNTTask")
|
||||
public class CNTTask extends AbstractTask {
|
||||
|
||||
|
||||
private static final String TASK_CONFIG_CODE = "CNTTask";
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private ISchBaseTaskconfigService taskConfigService;
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
@Autowired
|
||||
private ISchBasePointService schBasePointService;
|
||||
@Autowired
|
||||
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService;
|
||||
|
||||
@Override
|
||||
protected void create() throws BadRequestException {
|
||||
// 获取任务
|
||||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
|
||||
// 配置信息
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
||||
for (SchBaseTask task : tasks) {
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
// 找起点
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject jsonObject = JSONObject.parseObject(requestParam);
|
||||
// 根据对接位查找对应的载具类型
|
||||
SchBasePoint schBasePoint = schBasePointService.selectByRegionCode(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code());
|
||||
if(ObjectUtil.isEmpty(schBasePoint)) continue;
|
||||
jsonObject.put("vehicle_type", schBasePoint.getCan_vehicle_type());
|
||||
if (ObjectUtil.isEmpty(schBasePoint)) {
|
||||
task.setRemark("未找到所需点位!");
|
||||
taskService.updateById(task);
|
||||
// 消息通知
|
||||
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(),
|
||||
NoticeTypeEnum.WARN.getCode());
|
||||
continue;
|
||||
}
|
||||
|
||||
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup();
|
||||
schBaseVehiclematerialgroup.setVehicle_code(task.getVehicle_code());
|
||||
schBaseVehiclematerialgroup.setPoint_code(schBasePoint.getPoint_code());
|
||||
schBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup);
|
||||
|
||||
// 设置终点并修改创建成功状态
|
||||
task.setPoint_code2(schBasePoint.getPoint_code());
|
||||
task.setVehicle_type(schBasePoint.getCan_vehicle_type());
|
||||
task.setRemark("");
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
taskService.updateById(task);
|
||||
|
||||
schBasePoint.setIng_task_code(task.getTask_code());
|
||||
PointUtils.setUpdateByAcs(schBasePoint);
|
||||
pointService.updateById(schBasePoint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStatus(String task_code, TaskStatus status) {
|
||||
//TODO:完成任务的时候将int_task_code的清除
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceFinish(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_code) {
|
||||
//TODO:取消任务的时候将int_task_code的清除
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
|
||||
|
||||
}
|
||||
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 获取参数
|
||||
String startPoint = taskObj.getPoint_code1();
|
||||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint);
|
||||
// 起点清空
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint);
|
||||
pointService.updateById(schBasePoint);
|
||||
}
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint2);
|
||||
pointService.updateById(schBasePoint2);
|
||||
}
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_FINISH);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 获取参数
|
||||
String startPoint = taskObj.getPoint_code1();
|
||||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint);
|
||||
// 起点清空
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint);
|
||||
pointService.updateById(schBasePoint);
|
||||
}
|
||||
String point_code2 = taskObj.getPoint_code2();
|
||||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2);
|
||||
if (ObjectUtil.isNotEmpty(schBasePoint2)) {
|
||||
PointUtils.updateByIngTaskCode(schBasePoint2);
|
||||
pointService.updateById(schBasePoint2);
|
||||
}
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,11 +2,13 @@ package org.nl.wms.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.point.service.impl.SchBasePointServiceImpl;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
|
||||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum;
|
||||
@@ -107,4 +109,18 @@ public class PointUtils {
|
||||
setUpdateByPC(pointObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 点位修改在执行的任务标识
|
||||
* @param schBasePoint
|
||||
*/
|
||||
public static void updateByIngTaskCode(SchBasePoint schBasePoint) {
|
||||
schBasePoint.setIng_task_code(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user