no message
This commit is contained in:
@@ -130,6 +130,11 @@ public class MdPbStoragevehicleinfo implements Serializable {
|
||||
*/
|
||||
private String ext_id;
|
||||
|
||||
/**
|
||||
* 库区
|
||||
*/
|
||||
private String sect_code;
|
||||
|
||||
/**
|
||||
* 料箱类型(手持返回前端使用)
|
||||
*/
|
||||
|
||||
@@ -29,13 +29,6 @@ public class NotCarToWmsController {
|
||||
@Autowired
|
||||
private NotCarToWmsService notCarToWmsService;
|
||||
|
||||
@PostMapping("/materialInfo")
|
||||
@Log(value = "无人车给WMS发送物料点位信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> materialInfo(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(notCarToWmsService.materialInfo(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/sendTask")
|
||||
@Log(value = "无人车给下发WMS搬运任务")
|
||||
@SaIgnore
|
||||
@@ -43,4 +36,11 @@ public class NotCarToWmsController {
|
||||
return new ResponseEntity<>(notCarToWmsService.sendTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/arrive")
|
||||
@Log(value = "无人车到达")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> arrive(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(notCarToWmsService.arrive(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.nl.wms.ext.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.ext.service.WmsToNotCarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* WMS调用无人车 控制层
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/wms/toCar")
|
||||
@Slf4j
|
||||
public class WmsToNotCarController {
|
||||
|
||||
@Autowired
|
||||
private WmsToNotCarService wmsToNotCarService;
|
||||
|
||||
@PostMapping("/resultUnloadTask")
|
||||
@Log(value = "卸货任务完成反馈")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> resultUnloadTask(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(wmsToNotCarService.resultUnloadTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/callNotCat")
|
||||
@Log(value = "呼叫无人车")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> callNotCat(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(wmsToNotCarService.callNotCat(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.nl.wms.ext.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext.util.BaseResponse;
|
||||
import org.nl.wms.ext.util.NoCarResponse;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -14,20 +14,35 @@ import org.nl.wms.ext.util.BaseResponse;
|
||||
public interface NotCarToWmsService {
|
||||
|
||||
/**
|
||||
* 无人车给WMS发送物料点位信息
|
||||
* @param whereJson {
|
||||
* 无人车给下发WMS搬运任务
|
||||
*
|
||||
* }
|
||||
* @return BaseResponse
|
||||
* @param whereJson {
|
||||
* "id": “111” 唯一标识id
|
||||
* "item": [
|
||||
* {
|
||||
* "point_code": "WRCCB01" 卸货点位
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* @return NoCarResponse
|
||||
*/
|
||||
BaseResponse materialInfo(JSONObject whereJson);
|
||||
NoCarResponse sendTask(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 无人车给下发WMS搬运任务
|
||||
* @param whereJson {
|
||||
* 无人车到达
|
||||
*
|
||||
* }
|
||||
* @return BaseResponse
|
||||
* @param whereJson {
|
||||
* "requestType": " WMS_204",
|
||||
* "accessId": "1",
|
||||
* "requestId": "唯一标识",
|
||||
* "data": {
|
||||
* "taskNo": "任务编号",
|
||||
* "deviceId": "车辆id",
|
||||
* "locationId": "到达点位信息",
|
||||
* "statusType": "状态类型"
|
||||
* }
|
||||
* }
|
||||
* @return NoCarResponse
|
||||
*/
|
||||
BaseResponse sendTask(JSONObject whereJson);
|
||||
NoCarResponse arrive(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.nl.wms.ext.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.ext.util.BaseResponse;
|
||||
import org.nl.wms.ext.util.NoCarResponse;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -14,12 +14,44 @@ import org.nl.wms.ext.util.BaseResponse;
|
||||
public interface WmsToNotCarService {
|
||||
|
||||
/**
|
||||
* 通知无人车下步指令
|
||||
* 卸货任务完成反馈
|
||||
*
|
||||
* @param whereJson {
|
||||
* to_command: 1-等待,2-回库
|
||||
* }
|
||||
* "requestType": "WCS_118",
|
||||
* "accessId": "1",
|
||||
* "requestId": "唯一标识",
|
||||
* "data": {
|
||||
* "id":”111“
|
||||
* "to_command":"1"
|
||||
* }
|
||||
* }
|
||||
* @return BaseResponse
|
||||
*/
|
||||
BaseResponse sendCommand(JSONObject whereJson);
|
||||
NoCarResponse resultUnloadTask(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 呼叫无人车
|
||||
*
|
||||
* @param whereJson {
|
||||
* "requestType": "WCS_101", 固定
|
||||
* "accessId": "1", 固定
|
||||
* "requestId": "唯一标识",
|
||||
* "data": {
|
||||
* "detail": [
|
||||
* {
|
||||
* "taskNo": "TASK00000001", 唯一标识
|
||||
* "taskType": "MV", 任务类型(固定)
|
||||
* "taskDate": "2023-03-13 12:00:00", 任务时间
|
||||
* "taskState": "00", 任务状态 00:创建
|
||||
* "priority": "1", 优先级 - 1-最高,2-普通+,3-普通,4-普通-,5-最低
|
||||
* "wareCode": "W02", 仓库编码(固定)
|
||||
* "toLoc": "C1", 目标点位
|
||||
* "udf02": "" 地图(固定)
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* @return NoCarResponse
|
||||
*/
|
||||
NoCarResponse callNotCat(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
package org.nl.wms.ext.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.ext.service.NotCarToWmsService;
|
||||
import org.nl.wms.ext.util.BaseResponse;
|
||||
import org.nl.wms.ext.util.NoCarResponse;
|
||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch_manage.service.util.tasks.NoCarUnloadTask;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 无人车调用WMS 实现类
|
||||
@@ -18,13 +32,104 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class NotCarToWmsServiceImpl implements NotCarToWmsService {
|
||||
|
||||
/**
|
||||
* redisson
|
||||
*/
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* 点位服务
|
||||
*/
|
||||
@Resource
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
|
||||
/**
|
||||
* 无人车卸货任务类
|
||||
*/
|
||||
@Resource
|
||||
private NoCarUnloadTask noCarUnloadTask;
|
||||
|
||||
@Override
|
||||
public BaseResponse materialInfo(JSONObject whereJson) {
|
||||
return null;
|
||||
@SneakyThrows
|
||||
public NoCarResponse sendTask(JSONObject whereJson) {
|
||||
log.info("无人车下发搬运任务输入参数:{}", whereJson);
|
||||
RLock lock = redissonClient.getLock("lock:sendTask");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
String id = whereJson.getString("id");
|
||||
List<JSONObject> itemList = whereJson.getJSONArray("item").toJavaList(JSONObject.class);
|
||||
// 数据校验
|
||||
if (ObjectUtil.isEmpty(id)) {
|
||||
log.info("无人车下发搬运任务输出参数:{}", NoCarResponse.requestError("唯一标识不能为空!").toString());
|
||||
return NoCarResponse.requestError("唯一标识不能为空!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(itemList)) {
|
||||
log.info("无人车下发搬运任务输出参数:{}", NoCarResponse.requestError("卸货点位不能为空!").toString());
|
||||
return NoCarResponse.requestError("卸货点位不能为空!");
|
||||
}
|
||||
// 查询【无人车卸货缓存区】是否有空位
|
||||
List<SchBasePoint> pointList = iSchBasePointService.list(
|
||||
new QueryWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getRegion_code, IOSEnum.SECT_CODE.code("无人车卸货缓存1区"))
|
||||
.eq(SchBasePoint::getPoint_status, IOSConstant.ONE)
|
||||
.eq(SchBasePoint::getIs_used, IOSConstant.ONE)
|
||||
.and(row -> row.isNull(SchBasePoint::getIng_task_code)
|
||||
.or().eq(SchBasePoint::getIng_task_code, "")
|
||||
)
|
||||
);
|
||||
if (ObjectUtil.isEmpty(pointList)) {
|
||||
log.info("无人车下发搬运任务输出参数:{}", NoCarResponse.requestError("当前卸货缓存点位没有空位!").toString());
|
||||
return NoCarResponse.requestError("当前卸货缓存点位没有空位!");
|
||||
}
|
||||
if (itemList.size() > pointList.size()) {
|
||||
log.info("无人车下发搬运任务输出参数:{}", NoCarResponse.requestError("当前卸货缓存点位空位不够用!当前可用点位为【" + pointList.size() + "】").toString());
|
||||
return NoCarResponse.requestError("当前卸货缓存点位空位不够用!当前可用点位为【" + pointList.size() + "】");
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemList.size(); i++) {
|
||||
JSONObject json = itemList.get(i);
|
||||
SchBasePoint schBasePoint = pointList.get(i);
|
||||
// 准备任务参数
|
||||
JSONObject jsonTask = new JSONObject();
|
||||
jsonTask.put("point_code1", json.getString("point_code"));
|
||||
jsonTask.put("point_code2", schBasePoint.getPoint_code());
|
||||
jsonTask.put("contact_task", id);
|
||||
noCarUnloadTask.create(jsonTask);
|
||||
}
|
||||
} else {
|
||||
log.info("无人车下发搬运任务输出参数:{}", NoCarResponse.requestError("当前任务正在执行中,请稍后在试...").toString());
|
||||
return NoCarResponse.requestError("当前任务正在执行中,请稍后在试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
log.info("无人车下发搬运任务输出参数:{}", NoCarResponse.responseOk().toString());
|
||||
return NoCarResponse.responseOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse sendTask(JSONObject whereJson) {
|
||||
return null;
|
||||
@SneakyThrows
|
||||
public NoCarResponse arrive(JSONObject whereJson) {
|
||||
log.info("无人车到达输入参数:{}", whereJson);
|
||||
RLock lock = redissonClient.getLock("lock:sendTask");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
|
||||
} else {
|
||||
log.info("无人车到达输出参数:{}", NoCarResponse.requestError("当前任务正在执行中,请稍后在试...").toString());
|
||||
return NoCarResponse.requestError("当前任务正在执行中,请稍后在试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
log.info("无人车到达输出参数:{}", NoCarResponse.responseOk().toString());
|
||||
return NoCarResponse.responseOk();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import org.nl.system.enums.SysParamConstant;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.service.WmsToNotCarService;
|
||||
import org.nl.wms.ext.service.util.AcsResponse;
|
||||
import org.nl.wms.ext.util.BaseResponse;
|
||||
import org.nl.wms.ext.util.NoCarResponse;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -27,42 +26,83 @@ import org.springframework.stereotype.Service;
|
||||
public class WmsToNotCarServiceImpl implements WmsToNotCarService {
|
||||
|
||||
@Override
|
||||
public BaseResponse sendCommand(JSONObject param) {
|
||||
log.info("下发无人车接口sendCommand的输入参数为:-------------------" + param.toString());
|
||||
public NoCarResponse resultUnloadTask(JSONObject param) {
|
||||
log.info("下发无人车接口resultUnloadTask的输入参数为:-------------------" + param.toString());
|
||||
// 返回参数
|
||||
BaseResponse resultCar;
|
||||
NoCarResponse resultCar;
|
||||
|
||||
// 系统参数类
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
//判断是否连接无人车系统
|
||||
Param isConnectCar = sysParamService.findByCode(SysParamConstant.IS_NOT_CAR);
|
||||
if (ObjectUtil.isEmpty(isConnectCar)) {
|
||||
return BaseResponse.requestError("系统参数表中:" + SysParamConstant.IS_NOT_CAR + "不存在");
|
||||
return NoCarResponse.requestError("系统参数表中:" + SysParamConstant.IS_NOT_CAR + "不存在");
|
||||
}
|
||||
if (isConnectCar.getValue().equals(IOSConstant.ONE)) {
|
||||
return BaseResponse.responseOk("下发成功,未连接无人车系统!");
|
||||
return NoCarResponse.responseOk("下发成功,未连接无人车系统!");
|
||||
}
|
||||
|
||||
//无人车系统地址ip
|
||||
Param acsUrlParam = sysParamService.findByCode(SysParamConstant.CAR_URL);
|
||||
if (ObjectUtil.isEmpty(acsUrlParam)) {
|
||||
return BaseResponse.requestError("系统参数表中:" + SysParamConstant.CAR_URL + "不存在");
|
||||
return NoCarResponse.requestError("系统参数表中:" + SysParamConstant.CAR_URL + "不存在");
|
||||
}
|
||||
|
||||
String url = acsUrlParam.getValue() + "sendCommand";
|
||||
String url = acsUrlParam.getValue() + "openapi/callback/externalTaskCallback";
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute().body();
|
||||
// 格式转换
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
resultCar = JSONObject.toJavaObject(result, AcsResponse.class);
|
||||
log.info("下发无人车接口sendCommand的输出参数为:-------------------" + resultMsg);
|
||||
resultCar = JSONObject.toJavaObject(result, NoCarResponse.class);
|
||||
log.info("下发无人车接口resultUnloadTask的输出参数为:-------------------" + resultMsg);
|
||||
} catch (Exception e) {
|
||||
//网络不通
|
||||
String msg = e.getMessage();
|
||||
log.error("连接失败:{}", msg);
|
||||
return AcsResponse.requestError("网络不通,操作失败!");
|
||||
return NoCarResponse.requestError("网络不通,操作失败!");
|
||||
}
|
||||
return resultCar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoCarResponse callNotCat(JSONObject param) {
|
||||
log.info("下发无人车接口callNotCat的输入参数为:-------------------" + param.toString());
|
||||
// 返回参数
|
||||
NoCarResponse resultCar;
|
||||
|
||||
// 系统参数类
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
//判断是否连接无人车系统
|
||||
Param isConnectCar = sysParamService.findByCode(SysParamConstant.IS_NOT_CAR);
|
||||
if (ObjectUtil.isEmpty(isConnectCar)) {
|
||||
return NoCarResponse.requestError("系统参数表中:" + SysParamConstant.IS_NOT_CAR + "不存在");
|
||||
}
|
||||
if (isConnectCar.getValue().equals(IOSConstant.ONE)) {
|
||||
return NoCarResponse.responseOk("下发成功,未连接无人车系统!");
|
||||
}
|
||||
|
||||
//无人车系统地址ip
|
||||
Param acsUrlParam = sysParamService.findByCode(SysParamConstant.CAR_URL);
|
||||
if (ObjectUtil.isEmpty(acsUrlParam)) {
|
||||
return NoCarResponse.requestError("系统参数表中:" + SysParamConstant.CAR_URL + "不存在");
|
||||
}
|
||||
|
||||
String url = acsUrlParam.getValue() + "openapi/wcs/task";
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute().body();
|
||||
// 格式转换
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
resultCar = JSONObject.toJavaObject(result, NoCarResponse.class);
|
||||
log.info("下发无人车接口callNotCat的输出参数为:-------------------" + resultMsg);
|
||||
} catch (Exception e) {
|
||||
//网络不通
|
||||
String msg = e.getMessage();
|
||||
log.error("连接失败:{}", msg);
|
||||
return NoCarResponse.requestError("网络不通,操作失败!");
|
||||
}
|
||||
return resultCar;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.nl.wms.ext.util;
|
||||
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: ACS 响应的基础实体
|
||||
* @Date: 2025/05/19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NoCarResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 结果 200成功
|
||||
*/
|
||||
private int status;
|
||||
|
||||
/**
|
||||
* 结果 200成功
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
private boolean success;
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
public static NoCarResponse responseOk() {
|
||||
NoCarResponse response = new NoCarResponse();
|
||||
response.setStatus(HttpStatus.HTTP_OK);
|
||||
response.setMsg("请求成功");
|
||||
response.setCode(HttpStatus.HTTP_OK);
|
||||
response.setMessage("请求成功");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static NoCarResponse responseOk(String message) {
|
||||
NoCarResponse response = new NoCarResponse();
|
||||
response.setStatus(HttpStatus.HTTP_OK);
|
||||
response.setCode(HttpStatus.HTTP_OK);
|
||||
response.setMsg(message);
|
||||
response.setMessage(message);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static NoCarResponse requestError(String message) {
|
||||
NoCarResponse response = new NoCarResponse();
|
||||
response.setStatus(HttpStatus.HTTP_BAD_REQUEST);
|
||||
response.setCode(HttpStatus.HTTP_BAD_REQUEST);
|
||||
response.setMsg(message);
|
||||
response.setMessage(message);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,20 +104,12 @@ public class NotCarServiceImpl implements NotCarService {
|
||||
@Override
|
||||
@Transactional
|
||||
public PdaResponse waiting(JSONObject whereJson) {
|
||||
BaseResponse response = wmsToNotCarService.sendCommand(JSONObjectOf.of("to_command", IOSConstant.ONE));
|
||||
if (response.getStatus() != HttpStatus.HTTP_OK) {
|
||||
throw new BadRequestException(response.getMessage());
|
||||
}
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public PdaResponse back(JSONObject whereJson) {
|
||||
BaseResponse response = wmsToNotCarService.sendCommand(JSONObjectOf.of("to_command", IOSConstant.TWO));
|
||||
if (response.getStatus() != HttpStatus.HTTP_OK) {
|
||||
throw new BadRequestException(response.getMessage());
|
||||
}
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
package org.nl.wms.sch_manage.service.util.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.IdUtil;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.util.ACSTaskTypeEnum;
|
||||
import org.nl.wms.sch_manage.service.util.AbstractTask;
|
||||
import org.nl.wms.sch_manage.service.util.AcsTaskDto;
|
||||
import org.nl.wms.sch_manage.service.util.TaskType;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 无人车卸货任务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2026-01-22
|
||||
*/
|
||||
@Component(value = "NoCarUnloadTask")
|
||||
@TaskType("NoCarUnloadTask")
|
||||
public class NoCarUnloadTask extends AbstractTask {
|
||||
|
||||
/**
|
||||
* 任务服务类
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
|
||||
/**
|
||||
* 点位服务
|
||||
*/
|
||||
@Resource
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
|
||||
@Override
|
||||
public String create(JSONObject json) {
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
task.setTask_id(IdUtil.getStringId());
|
||||
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.setTask_status(TaskStatus.CREATE.getCode());
|
||||
task.setConfig_code(NoCarUnloadTask.class.getSimpleName());
|
||||
task.setPoint_code1(json.getString("point_code1"));
|
||||
task.setPoint_code2(json.getString("point_code2"));
|
||||
task.setVehicle_code(json.getString("vehicle_code"));
|
||||
task.setMaterial_id(json.getString("material_id"));
|
||||
task.setMaterial_qty(json.getBigDecimal("material_qty"));
|
||||
task.setRequest_param(json.toString());
|
||||
task.setPriority(json.getString("Priority"));
|
||||
task.setContact_task(json.getString("contact_task"));
|
||||
task.setRemark(json.getString("remark"));
|
||||
task.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
task.setCreate_time(DateUtil.now());
|
||||
taskService.save(task);
|
||||
|
||||
// 更新终点任务号
|
||||
SchBasePoint pointDao = iSchBasePointService.getById(task.getPoint_code2());
|
||||
pointDao.setIng_task_code(task.getTask_id());
|
||||
iSchBasePointService.updateById(pointDao);
|
||||
|
||||
// 下发任务
|
||||
this.sendTaskOne(task.getTask_id());
|
||||
return task.getTask_id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsTaskDto sendAcsParam(String taskId) {
|
||||
SchBaseTask taskDao = taskService.getById(taskId);
|
||||
|
||||
// 组织下发给acs的数据
|
||||
AcsTaskDto acsTaskDto = new AcsTaskDto();
|
||||
acsTaskDto.setExt_task_id(taskDao.getTask_id());
|
||||
acsTaskDto.setTask_code(taskDao.getTask_code());
|
||||
acsTaskDto.setStart_device_code(taskDao.getPoint_code1());
|
||||
acsTaskDto.setNext_device_code(taskDao.getPoint_code2());
|
||||
acsTaskDto.setPriority(taskDao.getPriority());
|
||||
acsTaskDto.setVehicle_code(taskDao.getVehicle_code());
|
||||
|
||||
acsTaskDto.setVehicle_type(IOSConstant.ONE);
|
||||
acsTaskDto.setIs_wait(IOSConstant.ZERO);
|
||||
acsTaskDto.setTask_type(ACSTaskTypeEnum.AGV_TASK.getCode());
|
||||
|
||||
acsTaskDto.setPriority(IOSConstant.ONE);
|
||||
acsTaskDto.setAgv_system_type(IOSConstant.THREE);
|
||||
|
||||
return acsTaskDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
protected void updateStatus(String task_code, TaskStatus status) {
|
||||
// 校验任务
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
|
||||
throw new BadRequestException("该任务已完成!");
|
||||
}
|
||||
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
|
||||
throw new BadRequestException("该任务已取消!");
|
||||
}
|
||||
// 根据传来的类型去对任务进行操作
|
||||
if (status.equals(TaskStatus.EXECUTING)) {
|
||||
// 更新明细状态
|
||||
this.executing(taskObj);
|
||||
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
|
||||
taskObj.setRemark("执行中");
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
if (status.equals(TaskStatus.FINISHED)) {
|
||||
this.finishTask(taskObj);
|
||||
}
|
||||
if (status.equals(TaskStatus.CANCELED)) {
|
||||
this.cancelTask(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void forceFinish(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.finishTask(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancel(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
if (Integer.parseInt(taskObj.getTask_status()) > Integer.parseInt(TaskStatus.CREATE.getCode())) {
|
||||
throw new BadRequestException("只能取消生成中的任务!");
|
||||
}
|
||||
this.cancelTask(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskConfirm(String task_code) {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void finishTask(SchBaseTask taskObj) {
|
||||
// 更新起点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
|
||||
.set(SchBasePoint::getVehicle_code, "")
|
||||
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("空位"))
|
||||
.set(SchBasePoint::getIng_task_code, "")
|
||||
);
|
||||
// 更新终点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
|
||||
.set(SchBasePoint::getVehicle_code, taskObj.getVehicle_code())
|
||||
.set(SchBasePoint::getIng_task_code, "")
|
||||
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("有箱有料"))
|
||||
);
|
||||
// 更新任务
|
||||
taskObj.setRemark("已完成");
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void cancelTask(SchBaseTask taskObj) {
|
||||
// 更新起点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
|
||||
.set(SchBasePoint::getIng_task_code, "")
|
||||
);
|
||||
// 更新终点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
|
||||
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("空位"))
|
||||
.set(SchBasePoint::getIng_task_code, "")
|
||||
);
|
||||
// 更新任务
|
||||
taskObj.setRemark("已取消");
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
private void executing(SchBaseTask taskObj) {
|
||||
// 更新起点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
|
||||
.set(SchBasePoint::getIng_task_code, taskObj.getTask_id())
|
||||
);
|
||||
// 更新终点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
|
||||
.set(SchBasePoint::getIng_task_code, taskObj.getTask_id())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,8 @@ public enum IOSEnum {
|
||||
|
||||
// 库区编码
|
||||
SECT_CODE(MapOf.of("内包材区", "NBC01", "批料室区", "PZC01",
|
||||
"中间站区", "ZZC01", "物料间区", "WZC01", "辅料区", "WFL01", "原料区", "WYL01"
|
||||
"中间站区", "ZZC01", "物料间区", "WZC01", "辅料区", "WFL01", "原料区", "WYL01",
|
||||
"无人车卸货缓存1区", "WRCXHHC01"
|
||||
)),
|
||||
|
||||
// 存放载具类型
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# WMS系统
|
||||
# LMS系统
|
||||
|
||||
/api/sysMenu/build?systemType=1
|
||||
@@ -2,7 +2,7 @@ export default {
|
||||
'lang': 'zh',
|
||||
// 平台
|
||||
'platform': {
|
||||
'title': 'WMS系统',
|
||||
'title': 'LMS系统',
|
||||
'tip1': '用户名不能为空',
|
||||
'tip2': '密码不能为空',
|
||||
'tip3': '验证码不能为空'
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: 'WMS系统',
|
||||
title: '华东制药LMS系统',
|
||||
logo: Logo,
|
||||
title_param: 'platform'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user