|
|
|
@ -33,10 +33,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -54,7 +56,7 @@ public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushM
|
|
|
|
|
private final PackageInfoService packageInfoService; |
|
|
|
|
private final LinsyProperties linsyProperties; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public void dataPush(String msg) { |
|
|
|
|
log.info("接收到节点数据推送:{}", msg); |
|
|
|
@ -145,6 +147,7 @@ public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushM
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
List<PackageInfoEntity> updateList = new ArrayList<>(); |
|
|
|
|
Set<String> billCodeSet = new HashSet<>(); |
|
|
|
|
for (Map.Entry<String, List<PushData>> entry : groupByOrder.entrySet()) { |
|
|
|
|
String orderCode = entry.getKey(); |
|
|
|
|
Integer code = NodeMappingEnums.getFactoryByNodeAndStatus(workNodeEnums).getCode(); |
|
|
|
@ -206,15 +209,16 @@ public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushM
|
|
|
|
|
if (StrUtil.isNotEmpty(destinationWarehouseName) && StrUtil.isNotEmpty(departureWarehouseName)) { |
|
|
|
|
if (StrUtil.equals(departureWarehouseName, destinationWarehouseName)) { |
|
|
|
|
sendFactory(billCode, FactoryNodeEnums.END_WAREHOUSE_UNLOADING, entities, orderCode); |
|
|
|
|
updateList.addAll(entities.stream() |
|
|
|
|
.filter(data -> collect.contains(data.getBarcode())) |
|
|
|
|
.map(packageInfoEntity -> { |
|
|
|
|
PackageInfoEntity entity = new PackageInfoEntity(); |
|
|
|
|
entity.setId(packageInfoEntity.getId()); |
|
|
|
|
entity.setWorkedNodeCode(FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode()); |
|
|
|
|
return entity; |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
billCodeSet.add(orderCode); |
|
|
|
|
// updateList.addAll(entities.stream()
|
|
|
|
|
// .filter(data -> collect.contains(data.getBarcode()))
|
|
|
|
|
// .map(packageInfoEntity -> {
|
|
|
|
|
// PackageInfoEntity entity = new PackageInfoEntity();
|
|
|
|
|
// entity.setId(packageInfoEntity.getId());
|
|
|
|
|
// entity.setWorkedNodeCode(FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode());
|
|
|
|
|
// return entity;
|
|
|
|
|
// })
|
|
|
|
|
// .collect(Collectors.toList()));
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -222,7 +226,8 @@ public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushM
|
|
|
|
|
} |
|
|
|
|
// 封装需要修改作业节点状态的数据
|
|
|
|
|
FactoryNodeEnums finalFactoryByNodeAndStatus = factoryByNodeAndStatus; |
|
|
|
|
updateList.addAll(entities.stream() |
|
|
|
|
List<PackageInfoEntity> collect1 = entities.stream() |
|
|
|
|
.filter(packageInfoEntity -> !CollUtil.contains(billCodeSet, packageInfoEntity.getOrderCode())) |
|
|
|
|
.filter(data -> collect.contains(data.getBarcode())) |
|
|
|
|
.map(packageInfoEntity -> { |
|
|
|
|
PackageInfoEntity entity = new PackageInfoEntity(); |
|
|
|
@ -230,21 +235,20 @@ public class FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushM
|
|
|
|
|
entity.setWorkedNodeCode(finalFactoryByNodeAndStatus.getCode()); |
|
|
|
|
return entity; |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
if (CollUtil.isNotEmpty(collect1)) { |
|
|
|
|
updateList.addAll(collect1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (CollUtil.isNotEmpty(updateList)) { |
|
|
|
|
// id相同时,更新 workedNodeCode 最大的那一条数据
|
|
|
|
|
updateList = updateList.stream() |
|
|
|
|
.collect(Collectors.groupingBy(PackageInfoEntity::getId)) |
|
|
|
|
.values().stream() |
|
|
|
|
.map(data -> data.stream() |
|
|
|
|
.max(Comparator.comparing(PackageInfoEntity::getWorkedNodeCode)) |
|
|
|
|
.orElse(null)) |
|
|
|
|
.filter(Objects::nonNull) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
packageInfoService.updateBatchById(updateList); |
|
|
|
|
} |
|
|
|
|
if (CollUtil.isNotEmpty(billCodeSet)) { |
|
|
|
|
packageInfoService.update(Wrappers.<PackageInfoEntity>lambdaUpdate().set(PackageInfoEntity::getWorkedNodeCode, FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode()) |
|
|
|
|
.in(PackageInfoEntity::getOrderCode, billCodeSet) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|