no message

main
HUOJIN\92525 2025-02-18 20:03:18 +08:00
parent 7d778fa2a2
commit 9ebba40069
5 changed files with 40 additions and 12 deletions

View File

@ -35,19 +35,19 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, Jpa
*
*
* @param stockId
* @param itemId
* @param itemCode
* @param pointId
* @param areaName
* @param deptId
*/
@Query(" from Inventory inv where inv.quantity-inv.queuedQty>0 " +
"and (:stockId is null or inv.stock.id=:stockId) " +
"and (:itemId is null or inv.itemKey.item.id=:itemId)" +
"and (:itemCode is null or inv.itemKey.item.code=:itemCode)" +
"and (:pointId is null or inv.point.id=:pointId)" +
"and (:areaName is null or inv.point.area.name=:areaName)" +
"and (:deptId is null or inv.dept.id=:deptId)" +
"order by inv.createTime ")
List<Inventory> queryInventory(Long stockId, Long itemId, Long pointId, String areaName, Long deptId);
List<Inventory> queryInventory(Long stockId, String itemCode, Long pointId, String areaName, Long deptId);
/**
*

View File

@ -122,12 +122,12 @@ public interface InventoryService {
*
*
* @param stockId Id
* @param itemId Id
* @param itemCode Id
* @param pointId Id
* @param areaName
* @param deptId Id
*/
List<Inventory> queryInventory(Long stockId, Long itemId, Long pointId, String areaName, Long deptId);
List<Inventory> queryInventory(Long stockId, String itemCode, Long pointId, String areaName, Long deptId);
/**
*

View File

@ -172,8 +172,8 @@ public class InventoryServiceImpl implements InventoryService {
}
@Override
public List<Inventory> queryInventory(Long stockId, Long itemId, Long pointId, String areaName, Long deptId) {
return inventoryRepository.queryInventory(stockId, itemId, pointId, areaName, deptId);
public List<Inventory> queryInventory(Long stockId, String itemCode, Long pointId, String areaName, Long deptId) {
return inventoryRepository.queryInventory(stockId, itemCode, pointId, areaName, deptId);
}
@Override

View File

@ -417,6 +417,10 @@ public class MesServiceImpl implements MesService {
private void moveJLBack(TransTask transTask) {
//起点
Point srcPoint = pointService.validatePoint(transTask.getPointCode());
Stock stock = stockService.findByPointCode(srcPoint.getCode());
if (stock == null) {
throw new BadRequestException(srcPoint.getCode() + "点位没有货架!");
}
String dstAreaCode = AreaNameDic.XJJLQ.equals(srcPoint.getArea().getName()) ? AreaNameDic.XJFBCQ : AreaNameDic.DJFBCQ;
List<Point> endPointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, dstAreaCode);
@ -432,7 +436,7 @@ public class MesServiceImpl implements MesService {
}
// 生成任务
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.CALL_RETURN, null, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.CALL_RETURN, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
}

View File

@ -361,10 +361,19 @@ public class TaskServiceImpl implements TaskService {
return pick.getCode() + "出库单;" + item.getCode() + "数量已分配!";
}
String areaName = stockTypeToAreaMap.getValueByKey(item.getGoodType());
List<Inventory> inventoryList = inventoryService.queryInventory(null, item.getId(), null, areaName, item.getDept().getId());
List<Inventory> inventoryList = inventoryService.queryInventory(null, item.getCode(), null, areaName, item.getDept().getId());
if (inventoryList.isEmpty()) {
if (isReplaceableMaterial(item.getCode())) {
// 定义互替物料关系
String alternativeMaterial = getAlternativeMaterial(item.getCode());
inventoryList = inventoryService.queryInventory(null, alternativeMaterial, null, areaName, item.getDept().getId());
if (inventoryList.isEmpty()) {
return pick.getCode() + "出库单;" + item.getCode() + "的替换物料" + alternativeMaterial + "库存不足,请先补充库存!";
}
} else {
return pick.getCode() + "出库单;" + item.getCode() + "物料库存不足,请先补充库存!";
}
}
double allocateQty = 0;
//未分配数量
double unQty = quantity;
@ -399,7 +408,6 @@ public class TaskServiceImpl implements TaskService {
//生成Task任务
Task task = this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), startPoint, endPoint, null);
System.out.println(task.getId());
}
}
@ -409,6 +417,22 @@ public class TaskServiceImpl implements TaskService {
return tps + "托盘有任务!";
}
// 增加物料可替代性判断
private boolean isReplaceableMaterial(String material) {
return material.equals("17300653-00") || material.equals("17213913-00");
}
private String getAlternativeMaterial(String material) {
switch (material) {
case "17300653-00":
return "17213913-00";
case "17213913-00":
return "17300653-00";
default:
return null; //非替代物料返回null
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelAllocate(long id, double quantity) {
@ -599,7 +623,7 @@ public class TaskServiceImpl implements TaskService {
if (pick.getStock() == null || pick.getStock().length() <= 0) {
pick.setStock(dstStock.getCode());
} else if (dstStock.getCode().equals(pick.getStock())) {
} else if (!dstStock.getCode().equals(pick.getStock())) {
pick.setStock(pick.getStock() + "," + dstStock.getCode());
}
pickService.update(pick);