no message
parent
04d53dcdbf
commit
786dc1a9b9
|
|
@ -3,13 +3,18 @@ package org.cpte.modules.quartz.job;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.cpte.modules.agvTask.entity.AgvTask;
|
||||
import org.cpte.modules.agvTask.mapper.AgvTaskMapper;
|
||||
import org.cpte.modules.shipping.entity.Pick;
|
||||
import org.cpte.modules.shipping.entity.PickDetail;
|
||||
import org.cpte.modules.shipping.mapper.PickDetailMapper;
|
||||
import org.cpte.modules.shipping.service.IPickDetailService;
|
||||
import org.cpte.modules.shipping.service.IPickService;
|
||||
import org.cpte.modules.utils.RedisDistributedLockUtil;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
|
@ -22,9 +27,15 @@ public class AllocatePickDetailJob implements Job {
|
|||
@Autowired
|
||||
private PickDetailMapper pickDetailMapper;
|
||||
|
||||
@Autowired
|
||||
private AgvTaskMapper agvTaskMapper;
|
||||
|
||||
@Autowired
|
||||
private IPickService pickService;
|
||||
|
||||
@Autowired
|
||||
private IPickDetailService pickDetailService;
|
||||
|
||||
@Autowired
|
||||
private RedisDistributedLockUtil redissonLock;
|
||||
|
||||
|
|
@ -56,21 +67,72 @@ public class AllocatePickDetailJob implements Job {
|
|||
}
|
||||
|
||||
private void allocate(List<PickDetail> pickDetails) {
|
||||
List<Long> pickIds = pickDetails.stream().map(PickDetail::getPickId).distinct().toList();
|
||||
Map<Long, Pick> pickMap = pickDetailService.queryByPickIdsToMap(pickIds);
|
||||
Map<String, String> workStationTaskMap = queryPointTaskMap();
|
||||
for (PickDetail detail : pickDetails) {
|
||||
boolean allocated = allocatePickDetail(detail);
|
||||
boolean allocated = allocatePickDetail(detail, pickMap, workStationTaskMap);
|
||||
if (allocated) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allocatePickDetail(PickDetail pickDetail) {
|
||||
private boolean allocatePickDetail(PickDetail pickDetail, Map<Long, Pick> pickMap, Map<String, String> workStationTaskMap) {
|
||||
try {
|
||||
return pickService.allocatePickDetail(pickDetail);
|
||||
boolean allocated = izAllocateTask(pickDetail, pickMap, workStationTaskMap);
|
||||
if (allocated) {
|
||||
return pickService.allocatePickDetail(pickDetail);
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.error("分配出库明细失败,ID: {}, 错误: {}", pickDetail.getId(), e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> queryPointTaskMap() {
|
||||
// 从数据库查询每个工作站当前的任务列表
|
||||
List<Map<String, Object>> result = agvTaskMapper.pointTaskMap();
|
||||
Map<String, String> pointTaskMap = new HashMap<>();
|
||||
for (Map<String, Object> map : result) {
|
||||
String key = map.get("point_code").toString();
|
||||
String no_item = map.get("no_item") == null ? "" : map.get("no_item").toString();
|
||||
pointTaskMap.put(key, no_item);
|
||||
}
|
||||
return pointTaskMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试分配
|
||||
*
|
||||
* @param pickDetail 出库明细
|
||||
* @param pickMap 出库单
|
||||
* @param workStationTaskMap 工作站任务
|
||||
* @return 是否分允许分配任务
|
||||
*/
|
||||
private boolean izAllocateTask(PickDetail pickDetail, Map<Long, Pick> pickMap, Map<String, String> workStationTaskMap) {
|
||||
|
||||
// 标记当前任务的key
|
||||
Pick pick = pickMap.get(pickDetail.getPickId());
|
||||
String currKey = pick.getConNo() + "_" + pickDetail.getItemId();
|
||||
|
||||
for (Map.Entry<String, String> entry : workStationTaskMap.entrySet()) {
|
||||
String executeKey = entry.getValue();
|
||||
|
||||
// 当前工作站空闲, 允许分配
|
||||
if (StringUtils.isEmpty(entry.getValue())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//匹配当前工作站任务
|
||||
if (currKey.equals(executeKey)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.cpte.modules.agvTask.entity.AgvTask;
|
||||
import org.cpte.modules.constant.GeneralConstant;
|
||||
import org.cpte.modules.tesAgv.request.CancelTaskRequest;
|
||||
import org.cpte.modules.tesAgv.request.ContainerUpRequest;
|
||||
import org.cpte.modules.tesAgv.request.NewMovePodTaskRequest;
|
||||
import org.cpte.modules.tesAgv.request.TesCallbackRequest;
|
||||
import org.cpte.modules.tesAgv.service.ITesAgvService;
|
||||
|
|
@ -74,6 +75,7 @@ public class TesAgvController {
|
|||
@AutoLog(value = "TES-重送任务")
|
||||
@Operation(summary = "TES-重送任务")
|
||||
@PostMapping(value = "/resendTes")
|
||||
@IgnoreAuth
|
||||
public TesResult resendTes(@RequestBody AgvTask agvTask) {
|
||||
try {
|
||||
iTesAgvService.resendTes(agvTask);
|
||||
|
|
@ -83,5 +85,18 @@ public class TesAgvController {
|
|||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "TES-容器顶升")
|
||||
@Operation(summary = "TES-容器顶升")
|
||||
@PostMapping(value = "/containerUp")
|
||||
@IgnoreAuth
|
||||
public TesResult containerUp(@RequestBody ContainerUpRequest containerUpRequest) {
|
||||
try {
|
||||
iTesAgvService.containerUp(containerUpRequest);
|
||||
return TesResult.success();
|
||||
} catch (Exception e) {
|
||||
return TesResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
package org.cpte.modules.tesAgv.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ContainerUpRequest {
|
||||
/**
|
||||
* 消息号,唯一幂等校验
|
||||
*/
|
||||
@JsonProperty("messageID")
|
||||
private String messageID;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@JsonProperty("messageType")
|
||||
private Integer messageType;
|
||||
|
||||
/**
|
||||
* 仓库ID
|
||||
*/
|
||||
@JsonProperty("warehouseID")
|
||||
private String warehouseID;
|
||||
|
||||
//创建时间
|
||||
@JsonProperty("createTime")
|
||||
private String createTime;
|
||||
|
||||
// 内容
|
||||
@JsonProperty("content")
|
||||
private Content content;
|
||||
|
||||
|
||||
/**
|
||||
* 容器位置信息
|
||||
*/
|
||||
@Data
|
||||
public static class Content {
|
||||
//业务ID
|
||||
@JsonProperty("bizID")
|
||||
private String bizID;
|
||||
|
||||
//储位号
|
||||
@JsonProperty("nodeCode")
|
||||
private String nodeCode;
|
||||
|
||||
//容器号
|
||||
@JsonProperty("podID")
|
||||
private String podID;
|
||||
|
||||
//小车号
|
||||
@JsonProperty("robotID")
|
||||
private String robotID;
|
||||
|
||||
//站点号
|
||||
@JsonProperty("stationCode")
|
||||
private String stationCode;
|
||||
|
||||
//任务ID
|
||||
@JsonProperty("taskID")
|
||||
private String taskID;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package org.cpte.modules.tesAgv.service;
|
|||
|
||||
import org.cpte.modules.agvTask.entity.AgvTask;
|
||||
import org.cpte.modules.tesAgv.request.CancelTaskRequest;
|
||||
import org.cpte.modules.tesAgv.request.ContainerUpRequest;
|
||||
import org.cpte.modules.tesAgv.request.TesCallbackRequest;
|
||||
|
||||
public interface ITesAgvService {
|
||||
|
|
@ -41,4 +42,11 @@ public interface ITesAgvService {
|
|||
* @param agvTask 待下发任务
|
||||
*/
|
||||
void resendTes(AgvTask agvTask);
|
||||
|
||||
/**
|
||||
* 容器顶升
|
||||
*
|
||||
* @param containerUpRequest 顶升参数
|
||||
*/
|
||||
void containerUp(ContainerUpRequest containerUpRequest);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.cpte.modules.shipping.entity.Task;
|
|||
import org.cpte.modules.shipping.mapper.TaskMapper;
|
||||
import org.cpte.modules.shipping.service.IPickService;
|
||||
import org.cpte.modules.tesAgv.request.CancelTaskRequest;
|
||||
import org.cpte.modules.tesAgv.request.ContainerUpRequest;
|
||||
import org.cpte.modules.tesAgv.request.NewMovePodTaskRequest;
|
||||
import org.cpte.modules.tesAgv.request.TesCallbackRequest;
|
||||
import org.cpte.modules.tesAgv.service.ITesAgvService;
|
||||
|
|
@ -210,6 +211,15 @@ public class ITesAgvServiceImpl implements ITesAgvService {
|
|||
handleResend(agvTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void containerUp(ContainerUpRequest containerUpRequest) {
|
||||
String id = containerUpRequest.getContent().getBizID();
|
||||
AgvTask agvTask = agvTaskMapper.selectById(Long.parseLong(id));
|
||||
agvTask.setOutBinTime(new Date());
|
||||
agvTaskMapper.updateById(agvTask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 任务完成
|
||||
|
|
|
|||
Loading…
Reference in New Issue