add:增加agv充电 取消充电
This commit is contained in:
@@ -41,4 +41,19 @@ public class EXTConstant {
|
||||
* ACS下发 获取设备状态
|
||||
*/
|
||||
public final static String GET_DEVICE = "api/wms/getDevice";
|
||||
|
||||
/**
|
||||
* ACS下发 获取AGV设备状态
|
||||
*/
|
||||
public final static String GET_AGV_DEVICE = "api/wms/getAgvDevice";
|
||||
|
||||
/**
|
||||
* ACS下发 充电
|
||||
*/
|
||||
public final static String CONFIRM_CHARGE = "api/wms/sendCharge";
|
||||
|
||||
/**
|
||||
* ACS下发 取消充电
|
||||
*/
|
||||
public final static String CANCEL_CHARGE = "api/wms/cancelCharge";
|
||||
}
|
||||
|
||||
@@ -56,4 +56,31 @@ public interface WmsToAcsService {
|
||||
* @return AcsResponse
|
||||
*/
|
||||
AcsResponse getDevice(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 获取AGV设备
|
||||
* @param whereJson {
|
||||
* device_code: 车号
|
||||
* }
|
||||
* @return AcsResponse
|
||||
*/
|
||||
AcsResponse getAgvDevice(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 下发充电任务
|
||||
* @param whereJson {
|
||||
* device_code: 车号
|
||||
* }
|
||||
* @return AcsResponse
|
||||
*/
|
||||
AcsResponse confirmCharge(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 下发取消充电任务
|
||||
* @param whereJson {
|
||||
* device_code: 车号
|
||||
* }
|
||||
* @return AcsResponse
|
||||
*/
|
||||
AcsResponse cancelCharge(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -47,4 +47,19 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
public AcsResponse getDevice(JSONObject whereJson) {
|
||||
return AcsUtil.notifyAcs(EXTConstant.GET_DEVICE, whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsResponse getAgvDevice(JSONObject whereJson) {
|
||||
return AcsUtil.notifyAcs(EXTConstant.GET_AGV_DEVICE, whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsResponse confirmCharge(JSONObject whereJson) {
|
||||
return AcsUtil.notifyAcs(EXTConstant.CONFIRM_CHARGE, whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsResponse cancelCharge(JSONObject whereJson) {
|
||||
return AcsUtil.notifyAcs(EXTConstant.CANCEL_CHARGE, whereJson);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import org.nl.wms.ext.util.BaseResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: 下发acs的反馈数据*new
|
||||
@@ -21,6 +24,8 @@ public class AcsResponse extends BaseResponse {
|
||||
|
||||
private JSONObject parameters = new JSONObject();
|
||||
|
||||
private List<JSONObject> dataList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 请求失败
|
||||
* @param message 错误信息
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.pda.general_management.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -60,4 +61,25 @@ public class PdaTaskController {
|
||||
return new ResponseEntity<>(pdaTaskService.forceConfirmTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getAgvInfo")
|
||||
@Log("获取AGV设备信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getAgvInfo(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaTaskService.getAgvInfo(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/confirmCharge")
|
||||
@Log("强制充电")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> confirmCharge(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaTaskService.confirmAndCancelCharge(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/cancelCharge")
|
||||
@Log("取消充电")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> cancelCharge(@RequestBody JSONObject whereJson) {
|
||||
Assert.equals("6",whereJson.getString("status"),"车辆不在充电中不可以取消充电!");
|
||||
return new ResponseEntity<>(pdaTaskService.confirmAndCancelCharge(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,23 @@ public interface PdaTaskService {
|
||||
* @return PdaResponse
|
||||
*/
|
||||
PdaResponse forceConfirmTask(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 获取AGV设备信息
|
||||
* @param whereJson {
|
||||
* device_code: 车号
|
||||
* }
|
||||
* @return PdaResponse
|
||||
*/
|
||||
PdaResponse getAgvInfo(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 强制充电 或者 取消充电
|
||||
* @param whereJson {
|
||||
* device_code: 车号
|
||||
* ....
|
||||
* }
|
||||
* @return PdaResponse
|
||||
*/
|
||||
PdaResponse confirmAndCancelCharge(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package org.nl.wms.pda.general_management.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.ext.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.service.util.AcsResponse;
|
||||
import org.nl.wms.pda.general_management.service.PdaTaskService;
|
||||
import org.nl.wms.pda.util.PdaResponse;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
@@ -10,6 +15,13 @@ import org.nl.wms.sch_manage.service.util.TaskFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 平板任务管理 实现类
|
||||
@@ -33,6 +45,31 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
@Autowired
|
||||
private TaskFactory taskFactory;
|
||||
|
||||
/**
|
||||
* wms调用acs服务
|
||||
*/
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
|
||||
/**
|
||||
* AGV设备状态码 -> 中文描述映射
|
||||
*/
|
||||
private static final Map<String, String> AGV_STATUS_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
AGV_STATUS_MAP.put("1", "关机");
|
||||
AGV_STATUS_MAP.put("2", "AGV移动中");
|
||||
AGV_STATUS_MAP.put("3", "AGV待机中");
|
||||
AGV_STATUS_MAP.put("4", "AGV交管中");
|
||||
AGV_STATUS_MAP.put("5", "AGV货叉动作中");
|
||||
AGV_STATUS_MAP.put("6", "AGV充电中");
|
||||
AGV_STATUS_MAP.put("7", "急停按钮被人拍下");
|
||||
AGV_STATUS_MAP.put("8", "有障碍物,避障,触发");
|
||||
AGV_STATUS_MAP.put("9", "货叉防撞开关,触发");
|
||||
AGV_STATUS_MAP.put("10", "车身防撞边,触发");
|
||||
AGV_STATUS_MAP.put("11", "手动模式");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PdaResponse queryTask(JSONObject whereJson) {
|
||||
return PdaResponse.requestParamOk(schBaseTaskMapper.queryPdaTask(whereJson));
|
||||
@@ -66,4 +103,35 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PdaResponse getAgvInfo(JSONObject whereJson) {
|
||||
// 1. 获取ACS返回的AGV设备数据,做空值防御
|
||||
AcsResponse acsResponse = wmsToAcsService.getAgvDevice(whereJson);
|
||||
if (acsResponse == null || acsResponse.getDataList() == null || acsResponse.getDataList().isEmpty()) {
|
||||
return PdaResponse.requestParamOk(Collections.emptyList());
|
||||
}
|
||||
|
||||
// 2. 一次Stream完成:状态码映射 + 按device_code排序
|
||||
List<JSONObject> result = acsResponse.getDataList().stream()
|
||||
.peek(item -> {
|
||||
String statusCode = item.getString("status");
|
||||
item.put("status", AGV_STATUS_MAP.getOrDefault(statusCode, "未知状态"));
|
||||
})
|
||||
.sorted(Comparator.comparing(
|
||||
row -> row.getString("device_code"),
|
||||
Comparator.nullsLast(String::compareTo)))
|
||||
.collect(Collectors.toList());
|
||||
return PdaResponse.requestParamOk(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PdaResponse confirmAndCancelCharge (JSONObject whereJson) {
|
||||
String deviceCode = whereJson.getString("device_code");
|
||||
Assert.notEmpty(deviceCode, "车号不能为空!");
|
||||
// 下发充电
|
||||
AcsResponse resp = wmsToAcsService.confirmCharge(whereJson);
|
||||
Assert.isTrue(resp.getStatus() == 200, "操作失败:" + resp.getMessage());
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,23 @@ public class AutoZJTask {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 查询包衣/内包叫料任务
|
||||
List<SchBaseTask> byOrNbCallTaskList = taskService.list(
|
||||
new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getConfig_code, "CoatingUpTask")
|
||||
.eq(SchBaseTask::getIs_delete, IOSConstant.ZERO)
|
||||
.eq(SchBaseTask::getPoint_code1, taskDao.getPoint_code2())
|
||||
.in(SchBaseTask::getTask_status, TaskStatus.EXECUTING.getCode(),TaskStatus.ISSUED.getCode())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(byOrNbCallTaskList)) {
|
||||
// 判断是否全部取货完成
|
||||
boolean is_allGet = byOrNbCallTaskList.stream()
|
||||
.allMatch(row -> IOSConstant.ONE.equals(row.getHandle_status()));
|
||||
if (!is_allGet) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
AbstractTask task = taskFactory.getTask(taskDao.getConfig_code());
|
||||
task.sendTaskOne(taskDao.getTask_id());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user