75 changed files with 2616 additions and 893 deletions
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<parent> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-service-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
</parent> |
||||
|
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-data-sharing-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,26 @@
|
||||
package com.logpm.datasharing.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @see com.logpm.datasharing.vo.WarehouseNumberVO |
||||
* 仓库数据 |
||||
* <li>始发仓</li> |
||||
* <li>中转仓</li> |
||||
* <li>目的仓</li> |
||||
*/ |
||||
@Data |
||||
public class WarehouseNumberVO { |
||||
|
||||
/** |
||||
* 仓库名称 |
||||
*/ |
||||
private String warehouseName; |
||||
|
||||
/** |
||||
* 数量 |
||||
*/ |
||||
private Integer number; |
||||
|
||||
|
||||
} |
@ -0,0 +1,137 @@
|
||||
package com.logpm.datasharing.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 开放模块 |
||||
* 运单返回诗句 |
||||
*/ |
||||
@Data |
||||
public class WaybillInfoVO implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
|
||||
/** |
||||
* 运单状态 10部分入库 |
||||
* |
||||
* 20入库 |
||||
* |
||||
* 30部分中转 |
||||
* |
||||
* 40 中转 |
||||
* |
||||
* 50 目的仓部分到达 |
||||
* |
||||
* 60 目的仓到达 |
||||
* |
||||
* 70 配送部分装车 |
||||
* |
||||
* 80 配送装车 |
||||
* |
||||
* 90 部分签收 |
||||
* |
||||
* 100 已签收 |
||||
*/ |
||||
@ApiModelProperty(value = "运单状态") |
||||
private String statusName; |
||||
|
||||
|
||||
/** |
||||
* 运单号 |
||||
*/ |
||||
@ApiModelProperty(value = "运单号") |
||||
private String waybillNo; |
||||
|
||||
/** |
||||
* 目的仓 |
||||
*/ |
||||
@ApiModelProperty(value = "目的仓") |
||||
private String destinationWarehouseName; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 发站仓 |
||||
*/ |
||||
@ApiModelProperty(value = "发站仓") |
||||
private String departureWarehouseName; |
||||
|
||||
|
||||
/** |
||||
* 发货单位 |
||||
*/ |
||||
@ApiModelProperty(value = "发货单位") |
||||
private String shipper; |
||||
|
||||
/** |
||||
* 发货人 |
||||
*/ |
||||
@ApiModelProperty(value = "发货人") |
||||
private String shipperName; |
||||
|
||||
/** |
||||
* 总数 |
||||
*/ |
||||
@ApiModelProperty(value = "总数") |
||||
private Integer totalCount; |
||||
|
||||
|
||||
/** |
||||
* 在途数量 |
||||
*/ |
||||
@ApiModelProperty(value = "总数") |
||||
private Integer onWayCount; |
||||
|
||||
|
||||
/** |
||||
* 收货单位 |
||||
*/ |
||||
@ApiModelProperty(value = "收货单位") |
||||
private String consignee; |
||||
|
||||
/** |
||||
* 收货人 |
||||
*/ |
||||
@ApiModelProperty(value = "收货人") |
||||
private String consigneeName; |
||||
|
||||
|
||||
/** |
||||
* 始发仓数量信息 |
||||
*/ |
||||
@ApiModelProperty(value = "始发仓数量信息") |
||||
private WarehouseNumberVO startWarehouseNumber; |
||||
|
||||
|
||||
/** |
||||
* 中转仓数量信息 |
||||
*/ |
||||
@ApiModelProperty(value = "中转仓数量信息") |
||||
private List<WarehouseNumberVO> middleWarehouseNumber; |
||||
|
||||
/** |
||||
* 目的仓数量信息 |
||||
*/ |
||||
@ApiModelProperty(value = "目的仓数量信息") |
||||
private WarehouseNumberVO endWarehouseNumber; |
||||
|
||||
/** |
||||
* 配送数量 |
||||
*/ |
||||
@ApiModelProperty(value = "配送数量") |
||||
private Integer deliveryNum ; |
||||
|
||||
/** |
||||
* 签收数量 |
||||
*/ |
||||
@ApiModelProperty(value = "签收数量") |
||||
private Integer signNum; |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.logpm.datasharing.config; |
||||
|
||||
|
||||
import com.logpm.datasharing.interceptor.LocalServerLoginAccountsInterceptor; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.common.component.MockLoginService; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.redis.lock.RedisLockClient; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
/** |
||||
* 为所有的的 |
||||
*/ |
||||
@Configuration |
||||
@AllArgsConstructor |
||||
public class InterceptorAdapterConfig implements WebMvcConfigurer { |
||||
|
||||
|
||||
private final BladeRedis redis; |
||||
|
||||
private final RedisLockClient redisLockClient; |
||||
private final MockLoginService mockLoginService; |
||||
|
||||
|
||||
@Override |
||||
public void addInterceptors(InterceptorRegistry interceptorRegistry) { |
||||
|
||||
interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis,redisLockClient,mockLoginService)).addPathPatterns("/search/**").order(1); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,100 @@
|
||||
package com.logpm.datasharing.interceptor; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.log4j.Log4j2; |
||||
import org.springblade.common.cache.CacheNames; |
||||
import org.springblade.common.component.MockLoginService; |
||||
import org.springblade.common.exception.CustomerException; |
||||
import org.springblade.common.wrapper.CustomHttpServletRequestWrapper; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.redis.lock.LockType; |
||||
import org.springblade.core.redis.lock.RedisLockClient; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.core.tool.utils.ThreadLocalUtil; |
||||
import org.springframework.http.HttpHeaders; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.io.PrintWriter; |
||||
import java.util.Objects; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
@Log4j2 |
||||
@AllArgsConstructor |
||||
public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapter { |
||||
|
||||
private final BladeRedis bladeRedis; |
||||
private final RedisLockClient redisLockClient; |
||||
private final MockLoginService mockLoginService; |
||||
|
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { |
||||
|
||||
|
||||
try { |
||||
CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); |
||||
String account ="shujutongbu"; |
||||
String tenantId = request.getHeader("tenantId"); |
||||
tenantId = StringUtil.isBlank(tenantId)?"627683":tenantId; |
||||
String key =CacheNames.LOCAL_SERVER_USER+tenantId+":"+account; |
||||
String lockKey =key+":lock"; |
||||
JSONObject data =bladeRedis.get(key); |
||||
if(Objects.isNull(data)){ |
||||
boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); |
||||
if(flag){ |
||||
data =bladeRedis.get(key); |
||||
if(Objects.isNull(data)){ |
||||
data = mockLoginService.mockToken(tenantId,account); |
||||
bladeRedis.setEx(key,data,2591990L); |
||||
redisLockClient.unLock(lockKey, LockType.FAIR); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// 修改或添加header
|
||||
|
||||
// 发送登录请求
|
||||
log.info("##########preHandle: request={}", request); |
||||
|
||||
wrappedRequest.addHeader("Blade-Auth", "bearer "+data.getString("access_token")); |
||||
HttpHeaders httpHeaders = new HttpHeaders(); |
||||
httpHeaders.add("Blade-Auth","bearer "+data.get("access_token") ); |
||||
httpHeaders.add( "Authorization", "Basic bG9jYWw6bG9jYWxfc2VjcmV0"); |
||||
ThreadLocalUtil.put("bladeContext", httpHeaders); |
||||
|
||||
|
||||
// 用包装后的request替换原始request
|
||||
request = wrappedRequest; |
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); |
||||
return true; |
||||
} catch (Exception e) { |
||||
returnJson(response, JSONObject.toJSONString(R.fail(500, "服务异常,请联系管理员"))); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
private void returnJson(HttpServletResponse response, String json) { |
||||
PrintWriter writer = null; |
||||
response.setCharacterEncoding("UTF-8"); |
||||
response.setContentType("application/json"); |
||||
try { |
||||
writer = response.getWriter(); |
||||
writer.print(json); |
||||
|
||||
} catch (IOException e) { |
||||
System.out.println(e.getMessage()); |
||||
} finally { |
||||
if (writer != null) { |
||||
writer.close(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,445 @@
|
||||
package com.logpm.distribution.receiver.report; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.logpm.distribution.pros.DistributionProperties; |
||||
import com.logpm.distribution.service.IQualityDeliverService; |
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.broadcast.FanoutConstants; |
||||
import org.springblade.common.constant.report.ReportConstants; |
||||
import org.springblade.common.model.workNode.FinishDistributionTrainVO; |
||||
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.List; |
||||
|
||||
/** |
||||
* 配送明细报表作业节点监听器 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 0:02 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class ReportListener { |
||||
|
||||
private final DistributionProperties destinationProperties; |
||||
private final List<ReportService> reportServices; |
||||
private final IQualityDeliverService qualityDeliverService; |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillPlan.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillPlan.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void billPlanReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getBillPlanReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("自提任务生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(BillPlanReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("自提任务生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillSignReview.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillSignReview.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void billReViewReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getBillReviewReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("自提复核生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(BillReViewReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("自提复核生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillSign.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillSign.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void billSignforReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getBillSignforReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("自提签收扫描生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(BillSignforReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("自提签收扫描生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndCarStart.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndCarStart.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void carStartReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getCarStartReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("发车生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(CarStartReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("发车生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndConsigneeArrive.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndConsigneeArrive.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void consigneeArriveReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getConsigneeArriveReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("配送到达生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(ConsigneeArriveReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("配送到达生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndFinish.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndFinish.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void deliverFinishReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getDeliverFinishReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("车次完成生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(DeliverFinishReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("车次完成生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndLoading.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndLoading.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void loadingReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getLoadingReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("装车生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(LoadingReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("装车生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndPlan.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndPlan.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void planReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getPlanReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("配送计划生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(PlanReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("配送计划生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.reservation.OwnReservation.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.reservation.OwnReservation.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void reservationPlanReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getReservationPlanReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("预约计划生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(ReservationPlanReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("预约计划生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void returnWarehouseReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getReturnWarehouseReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("回库生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(ReturnWarehouseReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("回库生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndrecheck.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndrecheck.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void reViewReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getReViewReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("文员复核生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(ReViewReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("文员复核生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.DeliveryAndSignfor.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndSignfor.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void signforReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getSignforReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("签收扫描生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(SignforReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("签收扫描生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.distribution.stock.QUEUE.REPORT, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.distribution.stock.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
), ackMode = "MANUAL") |
||||
public void stockReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getStockReport()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("备货生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(StockReportListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("备货生成明细报表失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = ReportConstants.REPORT_QUALITY_DELIVER_QUEUE, durable = "true"), |
||||
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC), |
||||
key = ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY |
||||
), ackMode = "MANUAL") |
||||
public void qualityDeliverListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
Boolean flag = Boolean.TRUE; |
||||
if (!destinationProperties.getReport().getQualityDeliver()) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
log.info("配送明细基础表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
flag = Boolean.FALSE; |
||||
} |
||||
if (flag) { |
||||
try { |
||||
selectReportService(QualityDeliverListener.class).buildReport(msg); |
||||
} catch (Exception e) { |
||||
log.error("配送明细基础表处理失败: {}", e.getMessage()); |
||||
} |
||||
} |
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = ReportConstants.REPORT_QUALITY_CAR_FINAL_QUEUE, durable = "true"), |
||||
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_CAR_FINAL_EXCHANGE, type = ExchangeTypes.TOPIC), |
||||
key = ReportConstants.REPORT_QUALITY_CAR_FINAL_ROUTINGKEY |
||||
), ackMode = "MANUAL") |
||||
public void carExpenseDispatchDetailFinal(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { |
||||
log.info("生成车辆车次成本报表: {}", msg); |
||||
try { |
||||
FinishDistributionTrainVO vo = JSONUtil.toBean(msg, FinishDistributionTrainVO.class); |
||||
String trainNumber = vo.getTrainNumber(); |
||||
qualityDeliverService.carExpenseDispatchDetailFinal(trainNumber); |
||||
} catch (Exception e) { |
||||
log.error("生成车辆车次成本报表失败: {}", e.getMessage()); |
||||
} |
||||
|
||||
try { |
||||
channel.basicAck(tag, false); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
private ReportService selectReportService(Class<? extends ReportService> clazz) { |
||||
// 根据某些条件选择具体的实现类
|
||||
for (ReportService reportService : reportServices) { |
||||
if (clazz.isInstance(reportService)) { |
||||
return reportService; |
||||
} |
||||
} |
||||
// 默认返回第一个实现类
|
||||
return reportServices.get(0); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.logpm.distribution.receiver.report; |
||||
|
||||
/** |
||||
* @Author: zqb |
||||
* @Date: 2024/12/10 |
||||
*/ |
||||
public interface ReportService { |
||||
|
||||
void buildReport(String msg); |
||||
|
||||
} |
Loading…
Reference in new issue