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); List<BasicdataDriverArteryEntity> list = baseMapper.selectListByWarehouseId(warehouseId);
log.info("################getDriverList list:{}", list); log.info("################getDriverList list:{}", list);
if(list.isEmpty()){
return basicdataDriverArteryVOS;
}
List<Long> ids =list.stream() // 创建一个流 List<Long> ids =list.stream() // 创建一个流
.map(BasicdataDriverArteryEntity::getId) // 使用map方法获取每个对象的ID .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); distributionBusinessPreOrderService.deleteLogic(temsp);
} }
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : dataResult) {
distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId());
}
// 执行保存操作 // 执行保存操作
distributionBusinessPreOrderService.saveBatch(dataResult); distributionBusinessPreOrderService.saveBatch(dataResult);
@ -172,71 +175,71 @@ public class BusinessPreOrderDataQueueHandler {
} }
public void saveOtherDataBase(List<DistributionBusinessPreOrderEntity> dataResult, String maillName) { // public void saveOtherDataBase(List<DistributionBusinessPreOrderEntity> dataResult, String maillName) {
String method = "########################saveOtherDataBase"; // String method = "########################saveOtherDataBase";
R<Tenant> tenantByName = sysClient.getTenantByName(maillName); // R<Tenant> tenantByName = sysClient.getTenantByName(maillName);
if (tenantByName.isSuccess()) { // if (tenantByName.isSuccess()) {
Tenant tenant = tenantByName.getData(); // Tenant tenant = tenantByName.getData();
if (ObjectUtil.isEmpty(tenant)) { // if (ObjectUtil.isEmpty(tenant)) {
log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 租户不存在"); // log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 租户不存在");
return; // return;
} // }
if (dataResult.isEmpty()) { // if (dataResult.isEmpty()) {
log.info(method + "dataResult 参数错误"); // log.info(method + "dataResult 参数错误");
} // }
DynamicDataSourceContextHolder.push(tenant.getTenantId()); // DynamicDataSourceContextHolder.push(tenant.getTenantId());
Map<Integer, List<DistributionBusinessPreOrderEntity>> map = dataResult.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getInWarehouse)); // Map<Integer, List<DistributionBusinessPreOrderEntity>> map = dataResult.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getInWarehouse));
if (Func.isNotEmpty(map.get(1))) { // if (Func.isNotEmpty(map.get(1))) {
//存在需要进行删除的数据 // //存在需要进行删除的数据
List<DistributionBusinessPreOrderEntity> deleteList = map.get(0); // List<DistributionBusinessPreOrderEntity> deleteList = map.get(0);
if (!deleteList.isEmpty()) { // if (!deleteList.isEmpty()) {
Map<String, List<DistributionBusinessPreOrderEntity>> deletedMap = deleteList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode)); // Map<String, List<DistributionBusinessPreOrderEntity>> deletedMap = deleteList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
deletedMap.forEach((k, v) -> { // deletedMap.forEach((k, v) -> {
List<String> deletedPackageList = v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()); // List<String> deletedPackageList = v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList());
log.info("删除商家端数据>>>>reservationCode:{}", deletedPackageList); // log.info("删除商家端数据>>>>reservationCode:{}", deletedPackageList);
if (!deletedPackageList.isEmpty()) { // if (!deletedPackageList.isEmpty()) {
//进行删除 // //进行删除
Integer row = distributionBusinessPreOrderService.deleteBusinessPreOrder(k, deletedPackageList); // Integer row = distributionBusinessPreOrderService.deleteBusinessPreOrder(k, deletedPackageList);
log.info("删除商家端数据>>>>row:{}", row); // log.info("删除商家端数据>>>>row:{}", row);
} // }
}); // });
} // }
} // }
if (Func.isNotEmpty(map.get(0))) { // if (Func.isNotEmpty(map.get(0))) {
//存在可能变更的数据 // //存在可能变更的数据
List<DistributionBusinessPreOrderEntity> mapList = map.get(0); // List<DistributionBusinessPreOrderEntity> mapList = map.get(0);
Map<String, List<DistributionBusinessPreOrderEntity>> saveData = mapList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode)); // Map<String, List<DistributionBusinessPreOrderEntity>> saveData = mapList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
List<DistributionBusinessPreOrderEntity> existData = new ArrayList<>(); // List<DistributionBusinessPreOrderEntity> existData = new ArrayList<>();
if (!saveData.isEmpty()) { // if (!saveData.isEmpty()) {
//查询是否存在重复 // //查询是否存在重复
saveData.forEach((k, v) -> { // saveData.forEach((k, v) -> {
List<DistributionBusinessPreOrderEntity> list = distributionBusinessPreOrderService.list(Wrappers.<DistributionBusinessPreOrderEntity>query().lambda() // List<DistributionBusinessPreOrderEntity> list = distributionBusinessPreOrderService.list(Wrappers.<DistributionBusinessPreOrderEntity>query().lambda()
.eq(DistributionBusinessPreOrderEntity::getReservationCode, k) // .eq(DistributionBusinessPreOrderEntity::getReservationCode, k)
.in(DistributionBusinessPreOrderEntity::getOrderPackageCode, v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList())) // .in(DistributionBusinessPreOrderEntity::getOrderPackageCode, v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()))
); // );
if (!list.isEmpty()) { // if (!list.isEmpty()) {
//已经存在数据 // //已经存在数据
existData.addAll(list); // existData.addAll(list);
} // }
}); // });
} // }
if (!existData.isEmpty()) { // if (!existData.isEmpty()) {
//二者比较取差集 // //二者比较取差集
mapList = mapList.stream().filter(m -> !existData.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()).contains(m.getOrderPackageCode())).collect(Collectors.toList()); // mapList = mapList.stream().filter(m -> !existData.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()).contains(m.getOrderPackageCode())).collect(Collectors.toList());
} // }
if (!mapList.isEmpty()) { // if (!mapList.isEmpty()) {
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : mapList) { // for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : mapList) {
distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId()); // distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId());
} // }
distributionBusinessPreOrderService.saveBatch(mapList); // distributionBusinessPreOrderService.saveBatch(mapList);
} // }
} // }
DynamicDataSourceContextHolder.poll(); // 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("订单信息错误,请联系管理员!"); throw new ServiceException("订单信息错误,请联系管理员!");
} }
// 保存包件 // 保存包件
distributionBusinessPreOrderEntity.setWarehouseId(stockArticleEntity.getWarehouseId());
distributionBusinessPreOrderEntity.setWarehouse(stockArticleEntity.getWarehouse());
distributionBusinessPreOrderEntity.setStockArticleId(stockArticleEntity.getId()); distributionBusinessPreOrderEntity.setStockArticleId(stockArticleEntity.getId());
buildDistributionParcelListEntity(distributionBusinessPreOrderEntity); buildDistributionParcelListEntity(distributionBusinessPreOrderEntity);
@ -191,6 +193,8 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
return Resp.scanFail("操作失败", "包件数据不存在"); return Resp.scanFail("操作失败", "包件数据不存在");
} }
// 保存包件 // 保存包件
t.setWarehouseId(stockArticleEntity.getWarehouseId());
t.setWarehouse(stockArticleEntity.getWarehouse());
t.setStockArticleId(stockArticleEntity.getId()); t.setStockArticleId(stockArticleEntity.getId());
buildDistributionParcelListEntity(t); buildDistributionParcelListEntity(t);
@ -217,7 +221,6 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
distributionParcelListEntity.setOrderPackageStockupStatus("10"); distributionParcelListEntity.setOrderPackageStockupStatus("10");
distributionParcelListService.save(distributionParcelListEntity); distributionParcelListService.save(distributionParcelListEntity);
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionParcelListEntity.getStockArticleId()); DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionParcelListEntity.getStockArticleId());
//增加 //增加
@ -248,6 +251,7 @@ public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<Di
stockArticleEntity.setId(null); stockArticleEntity.setId(null);
stockArticleEntity.setTenantId(null); stockArticleEntity.setTenantId(null);
stockArticleEntity.setWarehouseId(myCurrentWarehouse.getId()); stockArticleEntity.setWarehouseId(myCurrentWarehouse.getId());
stockArticleEntity.setWarehouse(myCurrentWarehouse.getName());
stockArticleEntity.setHandQuantity(0); stockArticleEntity.setHandQuantity(0);
distributionStockArticleService.save(stockArticleEntity); distributionStockArticleService.save(stockArticleEntity);
} }

Loading…
Cancel
Save