Browse Source

修改租户数据没有tenanId无效的问题

master
pref_mail@163.com 8 months ago
parent
commit
8665f1c5e7
  1. 3
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataDriverArteryServiceImpl.java
  2. 133
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/BusinessPreOrderDataQueueHandler.java
  3. 6
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/IDistributionBusinessPreOrderServiceImpl.java

3
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataDriverArteryServiceImpl.java

@ -143,6 +143,9 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
List<BasicdataDriverArteryEntity> list = baseMapper.selectListByWarehouseId(warehouseId);
log.info("################getDriverList list:{}", list);
if(list.isEmpty()){
return basicdataDriverArteryVOS;
}
List<Long> ids =list.stream() // 创建一个流
.map(BasicdataDriverArteryEntity::getId) // 使用map方法获取每个对象的ID

133
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/BusinessPreOrderDataQueueHandler.java

@ -162,6 +162,9 @@ public class BusinessPreOrderDataQueueHandler {
// 更新删除状态
distributionBusinessPreOrderService.deleteLogic(temsp);
}
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : dataResult) {
distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId());
}
// 执行保存操作
distributionBusinessPreOrderService.saveBatch(dataResult);
@ -172,71 +175,71 @@ public class BusinessPreOrderDataQueueHandler {
}
public void saveOtherDataBase(List<DistributionBusinessPreOrderEntity> dataResult, String maillName) {
String method = "########################saveOtherDataBase";
R<Tenant> tenantByName = sysClient.getTenantByName(maillName);
if (tenantByName.isSuccess()) {
Tenant tenant = tenantByName.getData();
if (ObjectUtil.isEmpty(tenant)) {
log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 租户不存在");
return;
}
if (dataResult.isEmpty()) {
log.info(method + "dataResult 参数错误");
}
DynamicDataSourceContextHolder.push(tenant.getTenantId());
Map<Integer, List<DistributionBusinessPreOrderEntity>> map = dataResult.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getInWarehouse));
if (Func.isNotEmpty(map.get(1))) {
//存在需要进行删除的数据
List<DistributionBusinessPreOrderEntity> deleteList = map.get(0);
if (!deleteList.isEmpty()) {
Map<String, List<DistributionBusinessPreOrderEntity>> deletedMap = deleteList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
deletedMap.forEach((k, v) -> {
List<String> deletedPackageList = v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList());
log.info("删除商家端数据>>>>reservationCode:{}", deletedPackageList);
if (!deletedPackageList.isEmpty()) {
//进行删除
Integer row = distributionBusinessPreOrderService.deleteBusinessPreOrder(k, deletedPackageList);
log.info("删除商家端数据>>>>row:{}", row);
}
});
}
}
if (Func.isNotEmpty(map.get(0))) {
//存在可能变更的数据
List<DistributionBusinessPreOrderEntity> mapList = map.get(0);
Map<String, List<DistributionBusinessPreOrderEntity>> saveData = mapList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
List<DistributionBusinessPreOrderEntity> existData = new ArrayList<>();
if (!saveData.isEmpty()) {
//查询是否存在重复
saveData.forEach((k, v) -> {
List<DistributionBusinessPreOrderEntity> list = distributionBusinessPreOrderService.list(Wrappers.<DistributionBusinessPreOrderEntity>query().lambda()
.eq(DistributionBusinessPreOrderEntity::getReservationCode, k)
.in(DistributionBusinessPreOrderEntity::getOrderPackageCode, v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()))
);
if (!list.isEmpty()) {
//已经存在数据
existData.addAll(list);
}
});
}
if (!existData.isEmpty()) {
//二者比较取差集
mapList = mapList.stream().filter(m -> !existData.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()).contains(m.getOrderPackageCode())).collect(Collectors.toList());
}
if (!mapList.isEmpty()) {
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : mapList) {
distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId());
}
distributionBusinessPreOrderService.saveBatch(mapList);
}
}
DynamicDataSourceContextHolder.poll();
}
}
// public void saveOtherDataBase(List<DistributionBusinessPreOrderEntity> dataResult, String maillName) {
// String method = "########################saveOtherDataBase";
// R<Tenant> tenantByName = sysClient.getTenantByName(maillName);
// if (tenantByName.isSuccess()) {
// Tenant tenant = tenantByName.getData();
// if (ObjectUtil.isEmpty(tenant)) {
// log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 租户不存在");
// return;
// }
// if (dataResult.isEmpty()) {
// log.info(method + "dataResult 参数错误");
// }
// DynamicDataSourceContextHolder.push(tenant.getTenantId());
// Map<Integer, List<DistributionBusinessPreOrderEntity>> map = dataResult.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getInWarehouse));
// if (Func.isNotEmpty(map.get(1))) {
// //存在需要进行删除的数据
// List<DistributionBusinessPreOrderEntity> deleteList = map.get(0);
// if (!deleteList.isEmpty()) {
// Map<String, List<DistributionBusinessPreOrderEntity>> deletedMap = deleteList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
// deletedMap.forEach((k, v) -> {
// List<String> deletedPackageList = v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList());
// log.info("删除商家端数据>>>>reservationCode:{}", deletedPackageList);
// if (!deletedPackageList.isEmpty()) {
// //进行删除
// Integer row = distributionBusinessPreOrderService.deleteBusinessPreOrder(k, deletedPackageList);
// log.info("删除商家端数据>>>>row:{}", row);
// }
// });
// }
// }
// if (Func.isNotEmpty(map.get(0))) {
// //存在可能变更的数据
// List<DistributionBusinessPreOrderEntity> mapList = map.get(0);
// Map<String, List<DistributionBusinessPreOrderEntity>> saveData = mapList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
// List<DistributionBusinessPreOrderEntity> existData = new ArrayList<>();
// if (!saveData.isEmpty()) {
// //查询是否存在重复
// saveData.forEach((k, v) -> {
// List<DistributionBusinessPreOrderEntity> list = distributionBusinessPreOrderService.list(Wrappers.<DistributionBusinessPreOrderEntity>query().lambda()
// .eq(DistributionBusinessPreOrderEntity::getReservationCode, k)
// .in(DistributionBusinessPreOrderEntity::getOrderPackageCode, v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()))
// );
// if (!list.isEmpty()) {
// //已经存在数据
// existData.addAll(list);
// }
// });
// }
// if (!existData.isEmpty()) {
// //二者比较取差集
// mapList = mapList.stream().filter(m -> !existData.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()).contains(m.getOrderPackageCode())).collect(Collectors.toList());
// }
// if (!mapList.isEmpty()) {
// for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : mapList) {
// distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId());
// }
// distributionBusinessPreOrderService.saveBatch(mapList);
// }
// }
// DynamicDataSourceContextHolder.poll();
//
// }
//
//
// }
}

6
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/IDistributionBusinessPreOrderServiceImpl.java

@ -71,6 +71,8 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
throw new ServiceException("订单信息错误,请联系管理员!");
}
// 保存包件
distributionBusinessPreOrderEntity.setWarehouseId(stockArticleEntity.getWarehouseId());
distributionBusinessPreOrderEntity.setWarehouse(stockArticleEntity.getWarehouse());
distributionBusinessPreOrderEntity.setStockArticleId(stockArticleEntity.getId());
buildDistributionParcelListEntity(distributionBusinessPreOrderEntity);
@ -191,6 +193,8 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
return Resp.scanFail("操作失败", "包件数据不存在");
}
// 保存包件
t.setWarehouseId(stockArticleEntity.getWarehouseId());
t.setWarehouse(stockArticleEntity.getWarehouse());
t.setStockArticleId(stockArticleEntity.getId());
buildDistributionParcelListEntity(t);
@ -217,7 +221,6 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
distributionParcelListEntity.setOrderPackageStockupStatus("10");
distributionParcelListService.save(distributionParcelListEntity);
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionParcelListEntity.getStockArticleId());
//增加
@ -248,6 +251,7 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
stockArticleEntity.setId(null);
stockArticleEntity.setTenantId(null);
stockArticleEntity.setWarehouseId(myCurrentWarehouse.getId());
stockArticleEntity.setWarehouse(myCurrentWarehouse.getName());
stockArticleEntity.setHandQuantity(0);
distributionStockArticleService.save(stockArticleEntity);
}

Loading…
Cancel
Save