113 lines
3.7 KiB
Java
113 lines
3.7 KiB
Java
package com.cdzy.ebikemaintenance;
|
|
|
|
|
|
import com.cdzy.ebikemaintenance.mapper.EbikeCmdMapper;
|
|
import com.cdzy.ebikemaintenance.mapper.EbikeParamMapper;
|
|
import com.cdzy.ebikemaintenance.mapper.EbikeParamValueMapper;
|
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeCmd;
|
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeParam;
|
|
import com.cdzy.ebikemaintenance.model.pojo.EbikeParamValue;
|
|
import com.cdzy.ebikemaintenance.utils.EmqxApiClient;
|
|
import com.cdzy.ebikemaintenance.utils.RedisUtil;
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
import jakarta.annotation.Resource;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.data.geo.Point;
|
|
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import static com.cdzy.ebikemaintenance.model.pojo.table.EbikeParamTableDef.EBIKE_PARAM;
|
|
|
|
@SpringBootTest
|
|
class EbikeSeversetestApplicationTests {
|
|
|
|
@Resource
|
|
EbikeCmdMapper cmdMapper;
|
|
|
|
@Resource
|
|
EbikeParamMapper ebikeParamMapper;
|
|
|
|
@Resource
|
|
EbikeParamValueMapper ebikeParamValueMapper;
|
|
|
|
@Resource
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
@Test
|
|
void contextLoads() {
|
|
EbikeCmd cmd = new EbikeCmd();
|
|
cmd.setCmdCode("continue_cycling");
|
|
cmd.setCmdName("继续骑行");
|
|
cmd.setDescribe("继续骑行");
|
|
cmdMapper.insert(cmd);
|
|
System.out.println(cmd.getCmdId());
|
|
}
|
|
|
|
@Test
|
|
void addParam() {
|
|
EbikeParam param = new EbikeParam();
|
|
param.setParamName("idx");
|
|
param.setCmdId("271826173502169088");
|
|
param.setLevel(2);
|
|
param.setValueType(3);
|
|
param.setParentId(271827039835688960L);
|
|
ebikeParamMapper.insert(param);
|
|
System.out.println(param.getParamId());
|
|
}
|
|
|
|
@Test
|
|
void addParamValue() {
|
|
EbikeParamValue paramValue = new EbikeParamValue();
|
|
paramValue.setParamValue("8");
|
|
paramValue.setParamId(271827551599529984L);
|
|
ebikeParamValueMapper.insert(paramValue);
|
|
}
|
|
|
|
@Test
|
|
void del() {
|
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
|
.where(EBIKE_PARAM.CMD_ID.eq("260213078161948672"));
|
|
ebikeParamMapper.deleteByQuery(queryWrapper);
|
|
// List<String> list = ebikeParamMapper.selectListByQueryAs(queryWrapper, String.class);
|
|
// queryWrapper.clear();
|
|
// queryWrapper.where(EBIKE_PARAM_VALUE.PARAM_ID.in(list));
|
|
// ebikeParamValueMapper.deleteByQuery(queryWrapper);
|
|
}
|
|
|
|
@Test
|
|
void emax() throws IOException {
|
|
boolean online = EmqxApiClient.isClientOnline("2370171016");
|
|
System.out.println("设备在线:" + online);
|
|
}
|
|
|
|
@Test
|
|
public void geo() {
|
|
|
|
|
|
// 添加地理位置
|
|
// redisUtil.addLocation(new Point(104.1612, 30.6658), "ChengDu");
|
|
// redisUtil.addLocation(new Point(121.47, 31.23), "Shanghai");
|
|
// redisUtil.addLocation(new Point(113.2644, 23.1291), "Guangzhou");
|
|
|
|
// List<Point> list = new ArrayList<>();
|
|
// list.add(new Point(103.47793700075658, 30.550505073485386));
|
|
// list.add(new Point(104.34844975960834, 30.32636994336589));
|
|
// list.add(new Point(104.71091584174496, 30.74604027923401));
|
|
// list.add(new Point(104.1077960688483, 31.040509054919152));
|
|
// list.add(new Point(103.47793700075658, 30.550505073485386));
|
|
|
|
// 查询范围内的成员
|
|
Point center = new Point(113.2644, 23.1291); // 北京为中心
|
|
double radius = 1000; // 1000 公里
|
|
List<String> nearbyMembers = redisUtil.findNearbyMembers(center, radius);
|
|
// List<String> nearbyMembers = redisUtil.searchByPolygon(list);
|
|
// System.out.println("Cities within " + radius + "km of Beijing:");
|
|
nearbyMembers.forEach(name -> System.out.println("Name: " + name));
|
|
|
|
}
|
|
}
|