一公司的地图风向监测站sql业务速度优化
parent
5a810cba2f
commit
cd03aabe30
|
@ -983,5 +983,27 @@ public class MapController extends BaseController {
|
|||
r.put("pd", pd);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业端地图优化
|
||||
* 原有的地图查询速度太慢,达到5s以上,通过索引的方式暂时无法解决,所有使用业务优化sql,提升速度
|
||||
*
|
||||
* @param
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/listbymeteorologicalByCorpinfo")
|
||||
@ResponseBody
|
||||
public Object listbymeteorologicalByCorpinfo() throws Exception {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String errInfo = "success";
|
||||
PageData pd = this.getPageData();
|
||||
//根据条件增加参数或减少参数 都没有 直接返回空
|
||||
if (StringUtils.isBlank(pd.getString("CORPINFO_ID"))) {
|
||||
map.put("result", errInfo);
|
||||
return map;
|
||||
}
|
||||
pd = meteorologicalinfoService.listbymeteorologicalByCorpinfoId(pd); //列出meteorological列表
|
||||
map.put("pd", pd);
|
||||
map.put("result", errInfo);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,5 +100,8 @@ public interface MeteorologicalinfoMapper {
|
|||
* @return
|
||||
*/
|
||||
List<PageData> tensList(PageData pd);
|
||||
|
||||
PageData listbymeteorologicalByCodes(PageData pd);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,9 @@ public interface MeteorologicalinfoService {
|
|||
* @throws Exception
|
||||
*/
|
||||
Integer updateMeteorologicalinfo(PageData pageData);
|
||||
|
||||
/**列表
|
||||
* @throws Exception
|
||||
*/
|
||||
public PageData listbymeteorologicalByCorpinfoId(PageData pd)throws Exception;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zcloud.service.map.impl;
|
|||
|
||||
import com.zcloud.entity.Page;
|
||||
import com.zcloud.entity.PageData;
|
||||
import com.zcloud.mapper.dsno2.map.MeteorologicalMapper;
|
||||
import com.zcloud.mapper.dsno2.map.MeteorologicalinfoMapper;
|
||||
import com.zcloud.service.map.DataDockingLogService;
|
||||
import com.zcloud.service.map.MeteorologicalinfoService;
|
||||
|
@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -27,7 +29,8 @@ public class MeteorologicalinfoServiceImpl implements MeteorologicalinfoService
|
|||
|
||||
@Autowired
|
||||
private MeteorologicalinfoMapper meteorologicalinfoMapper;
|
||||
|
||||
@Autowired
|
||||
private MeteorologicalMapper meteorologicalMapper;
|
||||
@Autowired
|
||||
private DataDockingLogService dataDockingLogService;
|
||||
|
||||
|
@ -218,5 +221,30 @@ public class MeteorologicalinfoServiceImpl implements MeteorologicalinfoService
|
|||
public Integer updateMeteorologicalinfo(PageData pageData) {
|
||||
return meteorologicalinfoMapper.updateMeteorologicalinfo(pageData);
|
||||
}
|
||||
|
||||
/**列表
|
||||
* @throws Exception
|
||||
*/
|
||||
public PageData listbymeteorologicalByCorpinfoId(PageData pd)throws Exception{
|
||||
/**
|
||||
* 暂时使用in优化速度
|
||||
* 1.获取这个企业下的所有天气站信息
|
||||
* 2.根据这些天气站的信息,获取最新的数据
|
||||
*/
|
||||
pd.put("OUTSOURCED_ID",pd.getString("CORPINFO_ID"));
|
||||
List<PageData> getListByCorpinfoId = meteorologicalMapper.listAll(pd);
|
||||
if(getListByCorpinfoId.size() > 0){
|
||||
String codes = "";
|
||||
for (PageData met : getListByCorpinfoId){
|
||||
codes += "'" + met.getString("CODE")+"',";
|
||||
}
|
||||
System.out.println();
|
||||
codes = codes.substring(0,codes.length()-1);
|
||||
pd.put("codes",codes);
|
||||
return meteorologicalinfoMapper.listbymeteorologicalByCodes(pd);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -510,5 +510,24 @@
|
|||
where f.CODE = #{CODE}
|
||||
and ABS(TIMESTAMPDIFF(SECOND, f.OPERATTIME, #{OPERATTIME})) < 10;
|
||||
</select>
|
||||
|
||||
<select id="listbymeteorologicalByCodes" resultType="pd" parameterType="pd">
|
||||
SELECT
|
||||
f.TEMPERATURE,
|
||||
f.HUMIDITY,
|
||||
f.WINDDIRECTION,
|
||||
f.WINDSPEED,
|
||||
f.ISDELETE,
|
||||
f.OPERATTIME,
|
||||
f.METEOROLOGICAL_ID,
|
||||
f.METEOROLOGICALINFO_ID,
|
||||
f.OPERATOR,
|
||||
f.CODE
|
||||
FROM
|
||||
bus_meteorologicalinfo f
|
||||
WHERE 1=1
|
||||
and f.code in ( #{codes})
|
||||
ORDER BY
|
||||
f.OPERATTIME DESC
|
||||
LIMIT 1 ;
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue