TD服务bug修改,新增根据设备获取坐标接口

breach-zhy
马雪伟 2 weeks ago
parent 24af04b9d5
commit de20216b43

@ -53,6 +53,7 @@ public class HwDeviceController extends BaseController {
@Autowired
private IHwSceneService hwSceneService;
/**
*
*/
@ -251,4 +252,10 @@ public class HwDeviceController extends BaseController {
return AjaxResult.success(hwDeviceModeService.getDeviceByModel(modelId));
}
@GetMapping("/getDeviceLocation")
private AjaxResult getDeviceLocation(Long deviceId){
Map deviceLocation = hwDeviceService.getDeviceLocation(deviceId);
return AjaxResult.success(deviceLocation);
}
}

@ -329,6 +329,25 @@ public class TdEngineController {
return R.fail(e.getMessage());
}
}
@InnerAuth
@PostMapping("/getDeviceLocation")
public R<?> getDeviceLocation(@Validated @RequestBody TdSelectDto tdSelectDto) {
try {
return R.ok(this.tdEngineService.getDeviceLocation(tdSelectDto));
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
try {
message = message.substring(message.lastIndexOf("invalid operation"));
} catch (Exception ex) {
}
log.error(message);
return R.fail(message);
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
/**
* @return R<Map < String, Map < String, Object>>>

@ -163,6 +163,8 @@ public interface TdEngineMapper {
void dropTable(@Param("databaseName") String databaseName,
@Param("tableName") String tableName);
Map<String, Object> getDeviceLocation(TdSelectDto tdSelectDto);
// /**
// * 检查表是否存在
// * @param dataBaseName

@ -141,6 +141,8 @@ public interface ITdEngineService {
* @date 2024-04-20 11:08
*/
public void dropTable(String databaseName, String tableName) throws Exception;
Map<String,Object> getDeviceLocation(TdSelectDto tdSelectDto);
// void initSTableFrame(String msg) throws Exception;
// List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);

@ -242,6 +242,10 @@ public class TdEngineServiceImpl implements ITdEngineService {
}
@Override
public Map<String, Object> getDeviceLocation(TdSelectDto tdSelectDto) {
return this.tdEngineMapper.getDeviceLocation(tdSelectDto);
}
/**
* @param: databaseName

@ -309,6 +309,10 @@
group by timetruncate(ts,1d),devicetype,onlinestatus,devicecode
order by ts
</select>
<select id="getDeviceLocation" resultType="java.util.Map"
parameterType="com.ruoyi.tdengine.api.domain.TdSelectDto">
SELECT last(longitude),last(latitude) FROM #{databaseName}.#{tableName}
</select>
<update id="dropTable">

Loading…
Cancel
Save