no message

main
HUOJIN\92525 2025-02-23 13:19:03 +08:00
parent 65bb9f90b5
commit e2b7594612
17 changed files with 331 additions and 57 deletions

View File

@ -0,0 +1,10 @@
package com.youchain.appupdate.inputJson;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ContainerSynchronized {
@ApiModelProperty(value = "库区编码")
String areaCode;
}

View File

@ -218,12 +218,11 @@ public class BydAppServiceImpl implements BydAppService {
//刷新出库单状态
pickService.refreshPickStatus(task.getPickDetail().getPick());
//生成叫料任务
taskService.callJlTask(pick);
//成品原托盘返库;单品不回库
if (BaseStatus.GD_TYPE_CT.equals(pick.getOrderType())) {
this.returnFBAgvTask(task);
this.returnXJFBAgvTask(task);
} else if (BaseStatus.GD_TYPE_DP.equals(pick.getOrderType())) {
this.returnDJFBAgvTask(task);
}
}
@ -456,7 +455,7 @@ public class BydAppServiceImpl implements BydAppService {
*
* @param task
*/
private void returnFBAgvTask(Task task) {
private void returnXJFBAgvTask(Task task) {
double planQty = 0;
double moveQty = 0;
List<Task> taskList = taskService.findTaskByAgvTask(task.getAgvTask().getId());
@ -483,5 +482,35 @@ public class BydAppServiceImpl implements BydAppService {
}
}
/**
* AGV
*
* @param task
*/
private void returnDJFBAgvTask(Task task) {
double planQty = 0;
double moveQty = 0;
List<Task> taskList = taskService.findTaskByAgvTask(task.getAgvTask().getId());
for (Task tasks : taskList) {
planQty += tasks.getPlanQty();
moveQty += tasks.getMoveQty();
}
if (planQty == moveQty) {
//查询大件返空区的空闲点位
List<String> areaNames = Collections.singletonList(AreaNameDic.DJFKQ);
List<Point> points = pointService.queryByAreaNames(areaNames, BaseStatus.FREE);
if (!points.isEmpty()) {
Point endPoint = points.get(0);
// 没有空车的处理逻辑
if (agvTaskService.isEndPointAvailable(endPoint.getCode(), BizStatus.FB_RETURN, "FORKLIFT_MOVE")) {
// 生成agv任务进行等待
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.FB_RETURN, task.getSrcStock(), task.getDstPointCode(), endPoint.getCode(), "FORKLIFT_MOVE");
pointService.usedPoint(endPoint);
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskCcJson(agvTask));
}
}
}
}
}

View File

@ -45,4 +45,10 @@ public interface PointRepository extends JpaRepository<Point, Long>, JpaSpecific
@Query(" from Point p where p.code in :pointCodes")
List<Point> findByCodes(Set<String> pointCodes);
@Query(" from Point point where point.enabled=true" +
" and (:status is null or point.status = :status) " +
" and (point.area.name in :areaNames ) " +
" order by point.posX,point.posY desc,point.posZ asc")
List<Point> queryByAreaNames(List<String> areaNames,String status);
}

View File

@ -127,6 +127,8 @@ public class StockController {
return new ResponseEntity<>(stockMsg, HttpStatus.OK);
}
private ResponseEntity<Object> badRequest(String message) {
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST);
}

View File

@ -127,6 +127,14 @@ public interface PointService {
*/
List<Point> queryPoints(String code, String status, String type, String areaName);
/**
*
* @param areaNames
* @param status
*/
List<Point> queryByAreaNames(List<String> areaNames,String status);
/**
*
* @param code

View File

@ -46,4 +46,8 @@ public class StockQueryCriteria{
@Query(joinName = "point>area>", propName="name",type = Query.Type.EQUAL)
private String areaName;
/** 状态1启用、0禁用 */
@Query(type = Query.Type.EQUAL)
private Boolean enabled;
}

View File

@ -164,6 +164,11 @@ public class PointServiceImpl implements PointService {
return pointRepository.queryPoints(code, status, type, areaName);
}
@Override
public List<Point> queryByAreaNames(List<String> areaNames, String status) {
return pointRepository.queryByAreaNames(areaNames, status);
}
@Override
public Point queryPoint(String code, String status, String type, String areaName) {
List<Point> pointList = pointRepository.queryPoints(code, status, type, areaName);

View File

@ -2,6 +2,7 @@ package com.youchain.businessdata.rest;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.appupdate.inputJson.ContainerSynchronized;
import com.youchain.appupdate.inputJson.MissionStateCallback;
import com.youchain.businessdata.domain.AgvTask;
import com.youchain.businessdata.service.AgvTaskService;
@ -14,10 +15,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;
import org.springframework.web.bind.annotation.*;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.OK;
@ -52,4 +50,19 @@ public class KMReSController {
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), e.getMessage(), ""), HttpStatus.BAD_REQUEST);
}
}
@PostMapping("/containerSynchronized")
@Log("同步AGV容器")
@ApiOperation("同步AGV容器")
@AnonymousAccess
public ResponseEntity<Object> containerSynchronized(@RequestBody ContainerSynchronized containerSynchronized) {
try {
kmReService.containerSynchronized(containerSynchronized.getAreaCode());
return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), e.getMessage(), ""), HttpStatus.BAD_REQUEST);
}
}
}

View File

@ -163,4 +163,22 @@ public interface AgvTaskService {
*
*/
Map<String, Object> queryWeeklyTaskCounts();
/**
*
*
* @param startSlotCode
* @return
*/
boolean isSrcPointAvailable(String startSlotCode, String type, String jobType);
/**
*
*
* @param endPointCode
* @return
*/
boolean isEndPointAvailable(String endPointCode, String type, String jobType);
}

View File

@ -32,6 +32,7 @@ public interface KMReService {
/**
*
*
* @param containerCode
*/
void containerOut(String containerCode);
@ -44,8 +45,23 @@ public interface KMReService {
*/
void sendAgvTaskToContainer(String url, String json);
/**
* JSON
*
* @param areaCode
*/
String containerQuery(String areaCode);
/**
*
*
* @param areaCode
*/
void containerSynchronized(String areaCode);
/**
* agvJSON
*
* @param agvTask
*/
String sendAgvTaskCcJson(AgvTask agvTask);
@ -53,24 +69,28 @@ public interface KMReService {
/**
* agvJSON
*
* @param agvTask
*/
String sendAgvTaskHjJson(AgvTask agvTask);
/**
* agvJSON
*
* @param agvTask
*/
String sendAgvTaskGtJson(AgvTask agvTask);
/**
* agv
*
* @param agvTasks
*/
void sendAgvTask(AgvTask agvTasks, String json);
/**
*
*
* @param agvTask
* @param status
* @param containerCode
@ -80,6 +100,7 @@ public interface KMReService {
/**
*
*
* @param srcPoint
* @param stock
* @param item
@ -89,6 +110,7 @@ public interface KMReService {
/**
* Json
*
* @param agvTask
*/
String operationFeedbackJson(AgvTask agvTask);

View File

@ -193,6 +193,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
return agvTaskRepository.findByStatus(status);
}
@Override
public Map<String, Object> queryWeeklyTaskCounts() {
List<Object[]> objectList = agvTaskRepository.queryWeeklyTaskCounts();
@ -215,4 +217,14 @@ public class AgvTaskServiceImpl implements AgvTaskService {
}
public boolean isEndPointAvailable(String endPointCode, String type, String jobType) {
return findByEndSlotCode(endPointCode, type, jobType);
}
public boolean isSrcPointAvailable(String startSlotCode, String type, String jobType) {
return findByStartSlotCode(startSlotCode, type, jobType);
}
}

View File

@ -3,6 +3,7 @@ package com.youchain.businessdata.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
@ -22,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -173,6 +175,134 @@ public class KMReServiceImpl implements KMReService {
}
/**
* @param areaCode
*/
@Override
public String containerQuery(String areaCode) {
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
//请求 id
jsonObject.put("areaCode", areaCode);
//容器类型
jsonObject.put("containerCode", "");
//容器编号
jsonObject.put("containerModelCode", "");
jsonObject.put("emptyFullStatus", "");
//容器当前位置
jsonObject.put("position", "");
return jsonObject.toJSONString();
}
@Override
public void containerSynchronized(String areaCode) {
String resultJson = HttpPostUtil.sendPostReq(UrlApi.containerQuery(), containerQuery(areaCode));
if (StringUtils.isEmpty(resultJson)) {
throw new BadRequestException("AGV返回信息:下发任务接口调用失败!");
}
JSONObject resulObject = JSON.parseObject(resultJson);
if (resulObject == null) {
throw new BadRequestException("AGV返回信息:下发任务接口返回为空!");
}
String code = resulObject.getString("code");
String message = resulObject.getString("message");
if (!"0".equals(code)) {
throw new BadRequestException("AGV返回消息:" + message);
}
//获取数据
JSONArray resultArray = resulObject.getJSONArray("data");
//获取未移动的容器和点位
Map<String, String> containerNodeMap = buildContainerNodeMap(resultArray);
//通过AGV给的库区获取WMS对应的库区
List<String> areaNames = getAreaNames(areaCode);
//根据库区查询点位
List<Point> points = pointService.queryByAreaNames(areaNames,null);
//获取点位集合
List<String> pointCodes = points.stream().map(Point::getCode).collect(Collectors.toList());
//获取需要更新的点位
List<String> updatePoints = getUpdatePoints(containerNodeMap, pointCodes);
//更新容器和点位
processContainers(containerNodeMap);
//更新点位
processPoints(updatePoints);
}
private Map<String, String> buildContainerNodeMap(JSONArray resultArray) {
Map<String, String> map = new HashMap<>();
for (int i = 0; i < resultArray.size(); i++) {
JSONObject jsonObject = resultArray.getJSONObject(i);
String isCarry = Optional.ofNullable(jsonObject.getString("isCarry")).orElse("");
String containerCode = Optional.ofNullable(jsonObject.getString("containerCode")).orElse("");
String nodeCode = Optional.ofNullable(jsonObject.getString("nodeCode")).orElse("");
if ("0".equals(isCarry)) {
map.put(containerCode, nodeCode);
}
}
return map;
}
private List<String> getAreaNames(String areaCode) {
switch (areaCode) {
case "CPSXX-CX":
return Arrays.asList(AreaNameDic.CPRKQ, AreaNameDic.CPXXQ);
case "DJBY-CS":
return Arrays.asList(AreaNameDic.DJFBCQ, AreaNameDic.DJJLQ);
default:
return Collections.emptyList();
}
}
private List<String> getUpdatePoints(Map<String, String> containerNodeMap, List<String> pointCodes) {
return pointCodes.stream()
.filter(pointCode -> !containerNodeMap.containsValue(pointCode))
.collect(Collectors.toList());
}
private void processContainers(Map<String, String> containerNodeMap) {
for (Map.Entry<String, String> entry : containerNodeMap.entrySet()) {
Stock stock = stockService.validateStock(entry.getKey());
Point point = pointService.validatePoint(entry.getValue());
stockService.usedStock(stock, point, BaseStatus.USED);
pointService.usedPoint(point);
}
}
private void processPoints(List<String> updatePoints) {
for (String pointCode : updatePoints) {
Point point = pointService.validatePoint(pointCode);
Area area = point.getArea();
String areaName = area.getName();
String bizStatus = getBizStatus(areaName);
if (agvTaskService.isEndPointAvailable(pointCode, bizStatus, "RACK_MOVE")) {
pointService.freePoint(point);
}
}
}
private String getBizStatus(String areaName) {
switch (areaName) {
case AreaNameDic.CPRKQ:
return BizStatus.Cp_Off_Line;
case AreaNameDic.CPXXQ:
return BizStatus.Cp_Off_Up;
case AreaNameDic.DJJLQ:
return BizStatus.CALL_PICK;
case AreaNameDic.DJFBCQ:
return BizStatus.JL_Back;
default:
return null;
}
}
/**
* Json
*

View File

@ -85,7 +85,6 @@ public class MesServiceImpl implements MesService {
if (item == null) {
item = itemService.createItem(itemCode, itemDate.getItemName(), itemDate.getItemQty(), BizStatus.XJ);
} else {
item.setGoodType(BizStatus.XJ);
item.setExtendD1(itemDate.getItemQty());
itemRepository.save(item);
}
@ -109,7 +108,6 @@ public class MesServiceImpl implements MesService {
if (item == null) {
item = itemService.createItem(itemDate.getItemCode(), itemDate.getItemName(), itemDate.getItemQty(), BizStatus.DJ);
} else {
item.setGoodType(BizStatus.DJ);
item.setExtendD1(itemDate.getItemQty());
itemRepository.save(item);
}
@ -252,7 +250,7 @@ public class MesServiceImpl implements MesService {
List<Stock> emptyStockList = getEmptyStockList();
if (emptyStockList.isEmpty()) {
// 没有空车的处理逻辑
if (!isEndPointAvailable(endPoint.getCode(), BizStatus.Cp_Off_Up, "RACK_MOVE")) {
if (!agvTaskService.isEndPointAvailable(endPoint.getCode(), BizStatus.Cp_Off_Up, "RACK_MOVE")) {
return pointCode + "点位有任务,请稍后再试!";
}
// 生成agv任务进行等待
@ -266,7 +264,7 @@ public class MesServiceImpl implements MesService {
Point srcPoint = emptyStock.getPoint();
// 验证终点是否有任务
if (!isEndPointAvailable(endPoint.getCode(), BizStatus.Cp_Off_Up, "RACK_MOVE")) {
if (!agvTaskService.isEndPointAvailable(endPoint.getCode(), BizStatus.Cp_Off_Up, "RACK_MOVE")) {
return pointCode + "点位有任务,请稍后再试!";
}
@ -290,25 +288,7 @@ public class MesServiceImpl implements MesService {
return emptyStockList;
}
/**
*
*
* @param endPointCode
* @return
*/
private boolean isEndPointAvailable(String endPointCode, String type, String jobType) {
return agvTaskService.findByEndSlotCode(endPointCode, type, jobType);
}
/**
*
*
* @param startSlotCode
* @return
*/
private boolean isSrcPointAvailable(String startSlotCode, String type, String jobType) {
return agvTaskService.findByStartSlotCode(startSlotCode, type, jobType);
}
private String moveCpOffLine(TransTask transTask) {
Point srcPoint = pointRepository.findByCode(transTask.getPointCode());
@ -323,7 +303,7 @@ public class MesServiceImpl implements MesService {
Point endPoint = findAvailableEndPoint();
if (endPoint == null) {
// 没有可用终点点位的处理逻辑
if (!isSrcPointAvailable(srcPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
if (!agvTaskService.isSrcPointAvailable(srcPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
return srcPoint.getCode() + "点位有任务,请稍后再试!";
}
// 生成等待任务
@ -338,7 +318,7 @@ public class MesServiceImpl implements MesService {
}
// 验证终点是否有任务
if (!isEndPointAvailable(endPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
if (!agvTaskService.isEndPointAvailable(endPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
return transTask.getPointCode() + "点位有任务,请稍后再试!";
}
@ -383,7 +363,7 @@ public class MesServiceImpl implements MesService {
}
// 验证终点是否有任务
if (!isEndPointAvailable(dstPointCode, BizStatus.Fx_Off_Line, "ROLLER_MOVE")) {
if (!agvTaskService.isEndPointAvailable(dstPointCode, BizStatus.Fx_Off_Line, "ROLLER_MOVE")) {
return dstPointCode + "点位有任务,请稍后再试!";
}
@ -427,7 +407,7 @@ public class MesServiceImpl implements MesService {
List<Point> endPointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, dstAreaCode);
if (endPointList.isEmpty()) {
// 没有空车的处理逻辑
if (!isSrcPointAvailable(srcPoint.getCode(), BizStatus.JL_Back, "RACK_MOVE")) {
if (!agvTaskService.isSrcPointAvailable(srcPoint.getCode(), BizStatus.JL_Back, "RACK_MOVE")) {
return srcPoint.getCode() + "点位有任务,请稍后再试!";
}
//生成agv任务进行等待
@ -442,7 +422,7 @@ public class MesServiceImpl implements MesService {
Point endPoint = endPointList.get(0);
if (!isEndPointAvailable(endPoint.getCode(), BizStatus.JL_Back, "RACK_MOVE")) {
if (!agvTaskService.isEndPointAvailable(endPoint.getCode(), BizStatus.JL_Back, "RACK_MOVE")) {
return endPoint.getCode() + "点位有任务,请稍后再试!";
}

View File

@ -264,10 +264,12 @@ public class TaskServiceImpl implements TaskService {
//绑定任务
List<Task> taskList = this.findByPickAllTask(pick.getId());
if (taskList.isEmpty()) {
return;
throw new BadRequestException(pick.getGdCode() + "工单没有进行翻包!");
}
//工单是否叫料
if (StringUtils.isEmpty(pick.getCallPoint())) {
throw new BadRequestException(pick.getGdCode() + "工单没有进行叫料!");
}
//终点
String[] points = pick.getCallPoint().split(",");
String endPointCode = points[points.length - 1];
@ -589,6 +591,8 @@ public class TaskServiceImpl implements TaskService {
Inventory newInventory = inventoryService.createInventory(itemKey, dstStock.getPoint(), dstStock, dept, moveQty);
//更新Task
double planQty = task.getPlanQty();
String status = task.getTaskStatus();
task.setInvId(inventory.getId());
task.setNewInvId(newInventory.getId());
task.setMoveQty(task.getMoveQty() + moveQty);
@ -602,9 +606,10 @@ public class TaskServiceImpl implements TaskService {
task.setMoveQty(moveQty);
task.setTaskStatus(BizStatus.FINISH);
// 生成Task任务
Task newTask = this.createTask(task.getItemKey().getItem(), task.getPlanQty() - moveQty, task.getItemKey(), null, BizStatus.PICK, pickDetail, task.getInvId(), task.getSrcStock(), task.getSrcPoint(), task.getDstPoint(), task.getAgvTask());
Task newTask = this.createTask(task.getItemKey().getItem(), planQty - moveQty, task.getItemKey(), null, BizStatus.PICK, pickDetail, task.getInvId(), task.getSrcStock(), task.getSrcPoint(), task.getDstPoint(), task.getAgvTask());
newTask.setDstStock(dstStock);
newTask.setDstStockCode(dstStock.getCode());
newTask.setTaskStatus(status);
taskRepository.save(newTask);
}
taskRepository.save(task);

View File

@ -70,7 +70,7 @@ public class pickTask {
*
*/
public void createJlTask() {
/* *//*查询拣货完成完成的出库单*//*
//查询拣货完成完成的出库单
List<String> statuses = Arrays.asList(BizStatus.PICKUP, BizStatus.PICK_ALL);
List<Pick> pickList = pickService.findByPickStatus(statuses, true);
if (pickList.isEmpty()) {
@ -80,7 +80,7 @@ public class pickTask {
synchronized (pick) {
taskService.callJlTask(pick);
}
}*/
}
}
}

View File

@ -83,4 +83,9 @@ public interface AreaNameDic {
*/
String DJJLQ = "大件叫料区";
/**
*
*/
String DJFKQ = "大件返空区";
}

View File

@ -22,9 +22,34 @@ public class EladminSystemApplicationTests {
}
public static void main(String[] args) {
String str = "17213913-0002";
String aa=str.substring(0,11);
System.out.println(aa);
List<String> list = new ArrayList<>();
list.add("DJ001");
list.add("DJ002");
list.add("DJ003");
list.add("DJ004");
list.add("DJ005");
list.add("DJ006");
list.add("DJ007");
Map<String, String> map = new HashMap<>();
map.put("1001","DJ001");
map.put("1003","DJ003");
map.put("1004","DJ004");
List<String> result = new ArrayList<>();
for (String element : list) {
// 检查 map 的值中是否包含当前元素
if (!map.containsValue(element)) {
// 如果不包含,则将该元素添加到结果列表中
result.add(element);
}
}
List<String> strings= list.stream()
.filter(pointCode -> !map.containsValue(pointCode))
.collect(Collectors.toList());
System.out.println(strings);
}
static Set bb(Set set1, Set set2) {