6 changed files with 209 additions and 15 deletions
@ -0,0 +1,25 @@
|
||||
package org.springblade.common.constant.trayallocation; |
||||
|
||||
|
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
|
||||
public class TrayAllocationConstants { |
||||
|
||||
|
||||
/** |
||||
* 清除包件上的托盘信息 |
||||
*/ |
||||
public static final String WAREHOUSE_PRACL_CLEAR_TRAY_EXCHANGE = "warehouse.pracl.clear.tray.exchange" + ModuleNameConstant.DEVAUTH; |
||||
public static final String WAREHOUSE_PRACL_CLEAR_TRAY_QUEUE = "warehouse.pracl.clear.tray.queue" + ModuleNameConstant.DEVAUTH; |
||||
public static final String WAREHOUSE_PRACL_CLEAR_TRAY_ROUTINGKEY = "warehouse.pracl.clear.tray.key" + ModuleNameConstant.DEVAUTH; |
||||
|
||||
/** |
||||
* 清除包件上的库位信息 |
||||
*/ |
||||
public static final String WAREHOUSE_PRACL_CLEAR_ALLOCATION_EXCHANGE = "warehouse.pracl.clear.allocation.exchange" + ModuleNameConstant.DEVAUTH; |
||||
public static final String WAREHOUSE_PRACL_CLEAR_ALLOCATION_QUEUE = "warehouse.pracl.clear.allocation.queue" + ModuleNameConstant.DEVAUTH; |
||||
public static final String WAREHOUSE_PRACL_CLEAR_ALLOCATION_ROUTINGKEY = "warehouse.pracl.clear.allocation.key" + ModuleNameConstant.DEVAUTH; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.logpm.distribution.receiver.warehouse; |
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil; |
||||
import com.logpm.distribution.mapper.DistributionParcelListMapper; |
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.springblade.common.constant.trayallocation.TrayAllocationConstants; |
||||
import org.springframework.amqp.core.ExchangeTypes; |
||||
import org.springframework.amqp.rabbit.annotation.Exchange; |
||||
import org.springframework.amqp.rabbit.annotation.Queue; |
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.amqp.support.AmqpHeaders; |
||||
import org.springframework.messaging.handler.annotation.Header; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class AllocationInfoListener { |
||||
|
||||
private final DistributionParcelListMapper distributionParcelListMapper; |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = TrayAllocationConstants.WAREHOUSE_PRACL_CLEAR_ALLOCATION_QUEUE, durable = "true"), |
||||
exchange = @Exchange(name = TrayAllocationConstants.WAREHOUSE_PRACL_CLEAR_ALLOCATION_EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void clearPraclAllocation(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
|
||||
if(StringUtils.isNotBlank(msg)){ |
||||
|
||||
List<Long> ids = JSONUtil.toList(msg, Long.class); |
||||
//把ids每200个分组
|
||||
List<List<Long>> partitions = new ArrayList<>(); |
||||
for (int i = 0; i < ids.size(); i += 200) { |
||||
partitions.add(ids.subList(i, Math.min(i + 200, ids.size()))); |
||||
} |
||||
|
||||
partitions.forEach(clearTrayList -> { |
||||
log.info("############clearPraclAllocation: 当前处理的ids {}",clearTrayList); |
||||
|
||||
distributionParcelListMapper.clearAllocationByIds(clearTrayList); |
||||
}); |
||||
|
||||
}else{ |
||||
log.warn("#########clearPraclAllocation: 消息数据为空 msg={}",msg); |
||||
} |
||||
|
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.logpm.distribution.receiver.warehouse; |
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil; |
||||
import com.logpm.distribution.mapper.DistributionParcelListMapper; |
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.springblade.common.constant.trayallocation.TrayAllocationConstants; |
||||
import org.springframework.amqp.core.ExchangeTypes; |
||||
import org.springframework.amqp.rabbit.annotation.Exchange; |
||||
import org.springframework.amqp.rabbit.annotation.Queue; |
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.amqp.support.AmqpHeaders; |
||||
import org.springframework.messaging.handler.annotation.Header; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class TrayInfoListener { |
||||
|
||||
private final DistributionParcelListMapper distributionParcelListMapper; |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = TrayAllocationConstants.WAREHOUSE_PRACL_CLEAR_TRAY_QUEUE, durable = "true"), |
||||
exchange = @Exchange(name = TrayAllocationConstants.WAREHOUSE_PRACL_CLEAR_TRAY_EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void clearPraclTray(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
|
||||
if(StringUtils.isNotBlank(msg)){ |
||||
|
||||
List<Long> ids = JSONUtil.toList(msg, Long.class); |
||||
//把ids每200个分组
|
||||
List<List<Long>> partitions = new ArrayList<>(); |
||||
for (int i = 0; i < ids.size(); i += 200) { |
||||
partitions.add(ids.subList(i, Math.min(i + 200, ids.size()))); |
||||
} |
||||
|
||||
partitions.forEach(clearTrayList -> { |
||||
log.info("############clearPraclTray: 当前处理的ids {}",clearTrayList); |
||||
|
||||
distributionParcelListMapper.clearPalletByIds(clearTrayList); |
||||
}); |
||||
|
||||
}else{ |
||||
log.warn("#########clearPraclTray: 消息数据为空 msg={}",msg); |
||||
} |
||||
|
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue