GroupMapper.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.jt.cloud.module.system.dal.mysql.group.GroupMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="getWeather" resultType="com.jt.cloud.module.system.controller.admin.weather.vo.WeatherVO">
  11. SELECT
  12. id,
  13. city,
  14. adcode,
  15. weather,
  16. temperature,
  17. windpower,
  18. winddirection,
  19. latitude,
  20. longitude,
  21. weather_code as weatherCode
  22. <if test="lon != null and lon != '' ">
  23. , ST_Distance_Sphere(POINT(longitude, latitude), POINT(#{lon}, #{lat})) AS distance
  24. </if>
  25. FROM system_weather
  26. <where>
  27. <![CDATA[ create_time >= CURDATE() ]]> AND <![CDATA[create_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)]]>
  28. <if test="weatherCode != null and weatherCode != '' ">
  29. weather_code = #{weatherCode}
  30. </if>
  31. </where>
  32. <!-- 如果传了经纬度,才加距离过滤和排序100公里范围 -->
  33. <if test="lon != null and lon != ''">
  34. HAVING distance &lt;= 100000
  35. ORDER BY distance
  36. </if>
  37. LIMIT 1
  38. </select>
  39. <insert id="insertWeather">
  40. INSERT INTO system_weather (
  41. id,
  42. city,
  43. adcode,
  44. weather,
  45. temperature,
  46. windpower,
  47. winddirection,
  48. latitude,
  49. longitude,
  50. weather_code
  51. ) VALUES (
  52. #{id},
  53. #{city},
  54. #{adcode},
  55. #{weather},
  56. #{temperature},
  57. #{windpower},
  58. #{winddirection},
  59. #{latitude},
  60. #{longitude},
  61. #{weatherCode}
  62. )
  63. </insert>
  64. <!-- <select id="queryUserByHr" resultType="java.util.Map">-->
  65. <!-- SELECT-->
  66. <!-- *-->
  67. <!-- FROM-->
  68. <!-- hr_employee-->
  69. <!-- </select>-->
  70. </mapper>