Commit 2561b87d by levphon

线上bug修复

1 parent 2e20c4ab
......@@ -32,7 +32,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
......@@ -383,13 +385,16 @@ public class ElectricFenceService {
}
@Transactional(rollbackFor = Exception.class)
public List<ElectricFenceSns> linkDevice(ElectricFence fence, List<ElectricFenceSnsModel> snList) {
public List<ElectricFenceSns> linkDevice(ElectricFence fence, List<ElectricFenceSnsModel> snModelList) {
List<ElectricFenceSns> snsList = Lists.newArrayList();
Date now = new Date();
if (CollectionUtils.isNotEmpty(snList)) {
if (CollectionUtils.isNotEmpty(snModelList)) {
//前端目前有bug,会重复提交关联设备,换成这种方式去重 add by liuyf on 20220209
Map<String, ElectricFenceSnsModel> snsModelMap = snModelList.stream()
.collect(Collectors.toMap(ElectricFenceSnsModel::getSn, Function.identity(), (o, n) -> n));
//手动关联
snList.forEach(efsm -> {
snsModelMap.forEach((k, efsm) -> {
ElectricFenceSns fenceSns = new ElectricFenceSns();
fenceSns.setFenceId(fence.getId());
fenceSns.setSn(efsm.getSn());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!