一公司的地图风向监测站sql业务速度优化

2024年1月24日测试
guoyuepeng 2024-02-27 16:34:20 +08:00
parent 5a810cba2f
commit cd03aabe30
5 changed files with 79 additions and 4 deletions

View File

@ -983,5 +983,27 @@ public class MapController extends BaseController {
r.put("pd", pd); r.put("pd", pd);
return r; 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;
}
} }

View File

@ -100,5 +100,8 @@ public interface MeteorologicalinfoMapper {
* @return * @return
*/ */
List<PageData> tensList(PageData pd); List<PageData> tensList(PageData pd);
PageData listbymeteorologicalByCodes(PageData pd);
} }

View File

@ -98,6 +98,9 @@ public interface MeteorologicalinfoService {
* @throws Exception * @throws Exception
*/ */
Integer updateMeteorologicalinfo(PageData pageData); Integer updateMeteorologicalinfo(PageData pageData);
/**
* @throws Exception
*/
public PageData listbymeteorologicalByCorpinfoId(PageData pd)throws Exception;
} }

View File

@ -2,6 +2,7 @@ package com.zcloud.service.map.impl;
import com.zcloud.entity.Page; import com.zcloud.entity.Page;
import com.zcloud.entity.PageData; import com.zcloud.entity.PageData;
import com.zcloud.mapper.dsno2.map.MeteorologicalMapper;
import com.zcloud.mapper.dsno2.map.MeteorologicalinfoMapper; import com.zcloud.mapper.dsno2.map.MeteorologicalinfoMapper;
import com.zcloud.service.map.DataDockingLogService; import com.zcloud.service.map.DataDockingLogService;
import com.zcloud.service.map.MeteorologicalinfoService; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -27,7 +29,8 @@ public class MeteorologicalinfoServiceImpl implements MeteorologicalinfoService
@Autowired @Autowired
private MeteorologicalinfoMapper meteorologicalinfoMapper; private MeteorologicalinfoMapper meteorologicalinfoMapper;
@Autowired
private MeteorologicalMapper meteorologicalMapper;
@Autowired @Autowired
private DataDockingLogService dataDockingLogService; private DataDockingLogService dataDockingLogService;
@ -218,5 +221,30 @@ public class MeteorologicalinfoServiceImpl implements MeteorologicalinfoService
public Integer updateMeteorologicalinfo(PageData pageData) { public Integer updateMeteorologicalinfo(PageData pageData) {
return meteorologicalinfoMapper.updateMeteorologicalinfo(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;
}
} }

View File

@ -510,5 +510,24 @@
where f.CODE = #{CODE} where f.CODE = #{CODE}
and ABS(TIMESTAMPDIFF(SECOND, f.OPERATTIME, #{OPERATTIME})) &lt; 10; and ABS(TIMESTAMPDIFF(SECOND, f.OPERATTIME, #{OPERATTIME})) &lt; 10;
</select> </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> </mapper>