|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
@ -30,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
@ -75,29 +77,55 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>(); |
|
|
|
|
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>(); |
|
|
|
|
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>(); |
|
|
|
|
Integer totalNum = 0; |
|
|
|
|
for (ReservationVO reservationVO : reservationVOList) { |
|
|
|
|
List<PackageData> details = reservationVO.getPackageDataList(); |
|
|
|
|
if (CollUtil.isNotEmpty(details)) { |
|
|
|
|
totalNum = totalNum + details.size(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (CollUtil.isNotEmpty(reservationCodeSet)) { |
|
|
|
|
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery().in(QualityDeliverEntity::getPlanReservationCode, reservationCodeSet)); |
|
|
|
|
if (CollUtil.isNotEmpty(qualityDeliverEntities)) { |
|
|
|
|
if (bizOperation.equals(BizOperationEnums.ADD)) { |
|
|
|
|
if (!NumberUtil.equals(qualityDeliverEntities.size(), totalNum)) { |
|
|
|
|
// 没有查询到,延迟10秒重新推送
|
|
|
|
|
factoryDataClient.sendMessage(SendMsg.builder() |
|
|
|
|
.exchange(FanoutConstants.distribution.DeliveryAndPlan.EXCHANGE_DELAY) |
|
|
|
|
.routingKey(null) |
|
|
|
|
.message(msg) |
|
|
|
|
.delay(10000) |
|
|
|
|
.build()); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
cmpMap = qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.CMP.getCode())) |
|
|
|
|
.filter(item -> StrUtil.isNotEmpty(item.getOrderPackageCode())) |
|
|
|
|
.collect(Collectors.groupingBy(item -> item.getPlanReservationCode() + item.getOrderPackageCode())); |
|
|
|
|
ltlMap = qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.LTL.getCode())) |
|
|
|
|
.filter(item -> StrUtil.isNotEmpty(item.getCategory()) && StrUtil.isNotEmpty(item.getOrderCode())) |
|
|
|
|
.collect(Collectors.groupingBy(item -> item.getPlanReservationCode() + item.getCategory() + item.getOrderCode())); |
|
|
|
|
invMap = qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.INV.getCode())) |
|
|
|
|
.filter(item -> StrUtil.isNotEmpty(item.getPlanReservationCode()) && StrUtil.isNotEmpty(item.getMallName()) && StrUtil.isNotEmpty(item.getMaterielCode())) |
|
|
|
|
.collect(Collectors.groupingBy(item -> item.getPlanReservationCode() + item.getMallName() + item.getMaterielCode())); |
|
|
|
|
} else { |
|
|
|
|
// 没有查询到,延迟30秒重新推送
|
|
|
|
|
// 没有查询到,延迟10秒重新推送
|
|
|
|
|
factoryDataClient.sendMessage(SendMsg.builder() |
|
|
|
|
.exchange(FanoutConstants.distribution.DeliveryAndPlan.EXCHANGE_DELAY) |
|
|
|
|
.routingKey(null) |
|
|
|
|
.message(msg) |
|
|
|
|
.delay(30000) |
|
|
|
|
.delay(10000) |
|
|
|
|
.build()); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Set<String> cmpSet = new HashSet<>(); |
|
|
|
|
Set<String> ltlSet = new HashSet<>(); |
|
|
|
|
Set<String> invSet = new HashSet<>(); |
|
|
|
|
Set<Long> invedSet = new HashSet<>(); |
|
|
|
|
for (ReservationVO reservationVO : reservationVOList) { |
|
|
|
|
String reservationCode = reservationVO.getReservationCode(); |
|
|
|
|
List<PackageData> details = reservationVO.getPackageDataList(); |
|
|
|
@ -106,7 +134,6 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder() |
|
|
|
|
.warehouseName(bean.getWarehouse()) |
|
|
|
|
.warehouseId(warehouseId) |
|
|
|
|
.orderPackageCode(detail.getPackageCode()) |
|
|
|
|
.planTrainNumber(vo.getTrainNumber()) |
|
|
|
|
.deliveryTime(DateUtil.parseDate(vo.getTaskTime())) |
|
|
|
|
.deliveryType(vo.getType()) |
|
|
|
@ -114,11 +141,10 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
.vehicleName(vehicleName) |
|
|
|
|
.driverName(driverName) |
|
|
|
|
.distributionCompany(vo.getDistributionCompany()) |
|
|
|
|
.deliveryPlanTime(bean.getOperatorTime()) |
|
|
|
|
.deliveryCreateUserName(bean.getOperator()) |
|
|
|
|
.bizCode(reservationVO.getReservationCode()) |
|
|
|
|
.ynWholeVehicle(vo.getYnWholeVehicle()) |
|
|
|
|
.deliveryFee(vo.getPrice()) |
|
|
|
|
.deliveryRemark(vo.getRemark()) |
|
|
|
|
.build(); |
|
|
|
|
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { |
|
|
|
|
qualityDeliverEntity.setConditions(1); |
|
|
|
@ -127,9 +153,16 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
if (BizOperationEnums.DELETE.equals(bizOperation)) { |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE); |
|
|
|
|
} else { |
|
|
|
|
if(BizOperationEnums.ADD.equals(bizOperation)){ |
|
|
|
|
qualityDeliverEntity.setDeliveryPlanTime(bean.getOperatorTime()); |
|
|
|
|
qualityDeliverEntity.setDeliveryCreateUserName(bean.getOperator()); |
|
|
|
|
} |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isNotEmpty(detail.getPackageCode())) { |
|
|
|
|
cmpSet.add(reservationCode + detail.getPackageCode()); |
|
|
|
|
} |
|
|
|
|
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
|
|
|
|
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
|
|
|
|
qualityDeliverEntity.setCategory(detail.getProductName()); |
|
|
|
@ -139,9 +172,16 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
if (BizOperationEnums.DELETE.equals(bizOperation)) { |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE); |
|
|
|
|
} else { |
|
|
|
|
if(BizOperationEnums.ADD.equals(bizOperation)){ |
|
|
|
|
qualityDeliverEntity.setDeliveryPlanTime(bean.getOperatorTime()); |
|
|
|
|
qualityDeliverEntity.setDeliveryCreateUserName(bean.getOperator()); |
|
|
|
|
} |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isNotEmpty(detail.getProductName()) && StrUtil.isNotEmpty(detail.getOrderCode())) { |
|
|
|
|
ltlSet.add(reservationCode + detail.getProductName() + detail.getOrderCode()); |
|
|
|
|
} |
|
|
|
|
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) { |
|
|
|
|
qualityDeliverEntity.setBizCode(reservationVO.getReservationCode()); |
|
|
|
|
qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch()); |
|
|
|
@ -154,47 +194,52 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
if (CollUtil.isNotEmpty(qualityDeliverEntities)) { |
|
|
|
|
if (BizOperationEnums.DELETE.equals(bizOperation)) { |
|
|
|
|
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) { |
|
|
|
|
qualityDeliverEntity.setId(deliverEntity.getId()); |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE); |
|
|
|
|
if (!invedSet.contains(deliverEntity.getId())) { |
|
|
|
|
qualityDeliverEntity.setId(deliverEntity.getId()); |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
invedSet.add(deliverEntity.getId()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) { |
|
|
|
|
qualityDeliverEntity.setId(deliverEntity.getId()); |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY); |
|
|
|
|
if (!invedSet.contains(deliverEntity.getId())) { |
|
|
|
|
qualityDeliverEntity.setId(deliverEntity.getId()); |
|
|
|
|
if(BizOperationEnums.ADD.equals(bizOperation)){ |
|
|
|
|
qualityDeliverEntity.setDeliveryPlanTime(bean.getOperatorTime()); |
|
|
|
|
qualityDeliverEntity.setDeliveryCreateUserName(bean.getOperator()); |
|
|
|
|
} |
|
|
|
|
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY); |
|
|
|
|
} |
|
|
|
|
invedSet.add(deliverEntity.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isNotEmpty(detail.getMallName()) && StrUtil.isNotEmpty(detail.getMaterialCode())) { |
|
|
|
|
invSet.add(reservationCode + detail.getMallName() + detail.getMaterialCode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 系统中有的包件在当前不存在,则删除
|
|
|
|
|
Set<String> cmpSet = details.stream() |
|
|
|
|
.filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.CMP)) |
|
|
|
|
.map(i -> reservationCode + i.getPackageCode()).collect(Collectors.toSet()); |
|
|
|
|
for (Map.Entry<String, List<QualityDeliverEntity>> entry : cmpMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
if (!cmpSet.contains(key)) { |
|
|
|
|
sendReport(entry.getValue().get(0), BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (Map.Entry<String, List<QualityDeliverEntity>> entry : cmpMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
if (!cmpSet.contains(key)) { |
|
|
|
|
sendReport(entry.getValue().get(0), BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
Set<String> ltlSet = details.stream().filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.LTL)) |
|
|
|
|
.map(i -> reservationCode + i.getProductName() + i.getOrderCode()).collect(Collectors.toSet()); |
|
|
|
|
for (Map.Entry<String, List<QualityDeliverEntity>> entry : ltlMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
if (!ltlSet.contains(key)) { |
|
|
|
|
sendReport(entry.getValue().get(0), BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (Map.Entry<String, List<QualityDeliverEntity>> entry : ltlMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
if (!ltlSet.contains(key)) { |
|
|
|
|
sendReport(entry.getValue().get(0), BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
Set<String> invSet = details.stream().filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.INV)) |
|
|
|
|
.map(i -> reservationCode + i.getMallName() + i.getMaterialCode()).collect(Collectors.toSet()); |
|
|
|
|
for (Map.Entry<String, List<QualityDeliverEntity>> entry : invMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
if (!invSet.contains(key)) { |
|
|
|
|
List<QualityDeliverEntity> value = entry.getValue(); |
|
|
|
|
for (QualityDeliverEntity entity : value) { |
|
|
|
|
sendReport(entity, BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (Map.Entry<String, List<QualityDeliverEntity>> entry : invMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
if (!invSet.contains(key)) { |
|
|
|
|
List<QualityDeliverEntity> value = entry.getValue(); |
|
|
|
|
for (QualityDeliverEntity entity : value) { |
|
|
|
|
sendReport(entity, BizOperationEnums.DELETE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -209,10 +254,6 @@ public class PlanReportListener implements ReportService {
|
|
|
|
|
.build(); |
|
|
|
|
String exchange = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE; |
|
|
|
|
String routKey = ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY; |
|
|
|
|
if (operationEnums.equals(BizOperationEnums.ADD)) { |
|
|
|
|
exchange = ReportConstants.REPORT_QUALITY_DELIVER_ADD_EXCHANGE; |
|
|
|
|
routKey = ReportConstants.REPORT_QUALITY_DELIVER_ADD_ROUTINGKEY; |
|
|
|
|
} |
|
|
|
|
factoryDataClient.sendMessage(SendMsg.builder() |
|
|
|
|
.exchange(exchange) |
|
|
|
|
.routingKey(routKey) |
|
|
|
|