package com.benyun.core.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.benyun.core.dao.WdInfoDao;
import com.benyun.core.entity.WdInfo;
import com.benyun.core.entity.WdTopological;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class WdTopologicalServiceImplTest {
    @Autowired
    WdTopologicalService wdTopologicalService;

    @Autowired
    WdInfoDao wdInfoDao;

    @Test
    public void insertListTest(){
        QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("wd_type_code","2");
        List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
        List<WdTopological> list = new ArrayList<>();
        for (WdInfo wdInfo : wdInfos) {
            WdTopological wdTopological = new WdTopological();
            wdTopological.setCenterWdId(wdInfo.getWdId());
            wdTopological.setCenterWdName(wdInfo.getWdName());
            wdTopological.setAddrCode(wdInfo.getAddrCode());
            wdTopological.setAddrInfo(wdInfo.getAddrInfo());
            wdTopological.setAddrCodeInfo("1232");
            wdTopological.setDistance(13);
            wdTopological.setRadius(0);
            wdTopological.setLng(BigDecimal.valueOf(2));
            wdTopological.setLat(BigDecimal.valueOf(2));
            wdTopological.setGeoHash("123");
            wdTopological.setAroundTypeCodeBy("123");
            wdTopological.setAroundWdTypeCode("123");
            wdTopological.setAroundWdName("123");
            wdTopological.setAroundWdId("123");
            list.add(wdTopological);
        }
        wdTopologicalService.insertList(list);
    }

    @Test
    public void selectWdToplogicalListByIdTest(){
        String centerWdId = "0040cf53ac454b678e6c9faa50eb224e";
        List<WdTopological> list = wdTopologicalService.selectWdTopologicalListById(centerWdId);
        for (WdTopological wdTopological : list) {
            System.out.println(wdTopological);
        }

    }
}
