|
...
|
...
|
@@ -2,6 +2,7 @@ package com.zhonglai.luhui.admin.controller.data; |
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.zhonglai.luhui.dao.service.PublicService;
|
|
|
|
import com.zhonglai.luhui.device.analysis.comm.util.StringUtils;
|
|
|
|
import com.zhonglai.luhui.device.analysis.comm.util.TableUtil;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
...
|
...
|
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
...
|
...
|
@@ -32,11 +34,44 @@ public class AtlasTrajectoryController { |
|
|
|
@ApiImplicitParam(value = "开始时间(时间戳)",name = "startTime"),
|
|
|
|
@ApiImplicitParam(value = "结束时间(时间戳)",name = "endTime")
|
|
|
|
})
|
|
|
|
@GetMapping(value = "/oneDay/{deviceInfiId}/{day}")
|
|
|
|
public AjaxResult oneDay(@PathVariable String deviceInfoId,@PathVariable String day,String latType,String lngType,Integer startTime,Integer endTime)
|
|
|
|
@GetMapping(value = "/oneDay")
|
|
|
|
public AjaxResult oneDay( String deviceInfoId, String day,String latType,String lngType,Integer startTime,Integer endTime)
|
|
|
|
{
|
|
|
|
String table = TableUtil.getTableName(day,"ly_sensor_data","device_sensor_data",3);
|
|
|
|
List<Map<String,Object>> list = publicService.getObjectListBySQL("select creat_time,data_value from `"+table+"` where device_info_id='"+deviceInfoId+"' and data_type='"+latType+"'");
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT\n" +
|
|
|
|
// " FROM_UNIXTIME(creat_time) tm,\n" +
|
|
|
|
" CONCAT_WS(',',\n" +
|
|
|
|
" MAX(CASE WHEN data_type = '"+latType+"' THEN data_value ELSE NULL END),\n" +
|
|
|
|
" MAX(CASE WHEN data_type = '"+lngType+"' THEN data_value ELSE NULL END)\n" +
|
|
|
|
" ) AS location\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
" "+table+"\n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
" device_info_id = '"+deviceInfoId+"' AND\n" +
|
|
|
|
" data_type IN ('lat', 'lng')\n" );
|
|
|
|
if(null != startTime && null != endTime)
|
|
|
|
{
|
|
|
|
sql.append(" and creat_time>="+startTime);
|
|
|
|
sql.append(" and creat_time<="+endTime);
|
|
|
|
}
|
|
|
|
sql.append(" GROUP BY\n" +
|
|
|
|
" creat_time\n" +
|
|
|
|
" ORDER BY creat_time ASC");
|
|
|
|
List<Map<String,Object>> list = publicService.getObjectListBySQL(sql.toString());
|
|
|
|
if (null != list && list.size() != 0)
|
|
|
|
{
|
|
|
|
List<Double[]> rlist = new ArrayList<>();
|
|
|
|
for (Map<String,Object> map:list)
|
|
|
|
{
|
|
|
|
Object object = map.get("location");
|
|
|
|
if(StringUtils.isNotNull(object))
|
|
|
|
{
|
|
|
|
String[] ss = String.valueOf(map.get("location")).split(",");
|
|
|
|
rlist.add(new Double[]{Double.valueOf(ss[0]),Double.valueOf(ss[1])});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return AjaxResult.success(rlist);
|
|
|
|
}
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|