StationOilPriceMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.yijia.station.mapper.StationOilPriceMapper">
  6. <resultMap type="StationOilPrice" id="StationOilPriceResult">
  7. <result property="oilPriceId" column="oil_price_id" />
  8. <result property="oilName" column="oil_name" />
  9. <result property="oilPrice" column="oil_price" />
  10. <result property="stationId" column="station_id" />
  11. <result property="stationName" column="station_name" />
  12. <result property="oilType" column="oil_type" />
  13. <result property="date" column="date" />
  14. </resultMap>
  15. <select id="selectStationOilPriceList" parameterType="StationOilPrice" resultMap="StationOilPriceResult">
  16. select oil_price_id, oil_name, oil_price, station_id, d.dept_name as station_name, date
  17. from station_oil_price p join sys_dept d
  18. on p.station_id = d.dept_id
  19. <where>
  20. <if test="oilName != null and oilName != ''"> and p.oil_name like concat('%', #{oilName}, '%')</if>
  21. <if test="oilPrice != null and oilPrice != ''"> and p.oil_price = #{oilPrice}</if>
  22. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  23. <if test="stationIdList != null ">
  24. and p.station_id in
  25. <foreach item="item" index="index" collection="stationIdList"
  26. open="(" separator="," close=")">
  27. #{item}
  28. </foreach>
  29. </if>
  30. </where>
  31. </select>
  32. <select id="oilNameInfo" parameterType="StationOilPrice" resultMap="StationOilPriceResult">
  33. select oil_price_id, oil_name, oil_price, station_id, d.dept_name as station_name, date
  34. from station_oil_price p join sys_dept d
  35. on p.station_id = d.dept_id
  36. <where>
  37. <if test="oilName != null and oilName != ''"> and p.oil_name like concat('%', #{oilName}, '%')</if>
  38. <if test="oilPrice != null and oilPrice != ''"> and p.oil_price = #{oilPrice}</if>
  39. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  40. <if test="stationIdList != null ">
  41. and p.station_id in
  42. <foreach item="item" index="index" collection="stationIdList"
  43. open="(" separator="," close=")">
  44. #{item}
  45. </foreach>
  46. </if>
  47. and oil_name!="非油品"
  48. </where>
  49. </select>
  50. <select id="selectOilPriceList" parameterType="StationOilPrice" resultMap="StationOilPriceResult">
  51. -- select oil_price_id, oil_name, oil_price, station_id, d.dept_name as station_name, s.dict_value as oil_type
  52. -- from station_oil_price p
  53. -- join sys_dept d on p.station_id = d.dept_id
  54. -- join sys_dict_data s on s.dict_label = p.oil_name and s.dict_type = "oil_name"
  55. select DISTINCT oil_name,s.dict_value as oil_type
  56. from station_oil_price p
  57. join sys_dept d on p.station_id = d.dept_id
  58. join sys_dict_data s on s.dict_label = p.oil_name and s.dict_type = "oil_name"
  59. <where>
  60. <if test="oilName != null and oilName != ''"> and p.oil_name like concat('%', #{oilName}, '%')</if>
  61. <if test="oilPrice != null and oilPrice != ''"> and p.oil_price = #{oilPrice}</if>
  62. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  63. <if test="stationIdList != null ">
  64. and p.station_id in
  65. <foreach item="item" index="index" collection="stationIdList"
  66. open="(" separator="," close=")">
  67. #{item}
  68. </foreach>
  69. </if>
  70. </where>
  71. </select>
  72. <select id="selectStationOilPriceById" parameterType="Long" resultMap="StationOilPriceResult">
  73. select oil_price_id, oil_name, oil_price, station_id, d.dept_name as station_name, date
  74. from station_oil_price p join sys_dept d
  75. on p.station_id = d.dept_id
  76. where p.oil_price_id = #{oilPriceId}
  77. </select>
  78. <insert id="insertStationOilPrice" parameterType="StationOilPrice" useGeneratedKeys="true" keyProperty="oilPriceId">
  79. insert into station_oil_price
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="oilName != null">oil_name,</if>
  82. <if test="oilPrice != null">oil_price,</if>
  83. <if test="stationId != null">station_id,</if>
  84. <if test="date != null">date,</if>
  85. </trim>
  86. <trim prefix="values (" suffix=")" suffixOverrides=",">
  87. <if test="oilName != null">#{oilName},</if>
  88. <if test="oilPrice != null">#{oilPrice},</if>
  89. <if test="stationId != null">#{stationId},</if>
  90. <if test="date != null">#{date},</if>
  91. </trim>
  92. </insert>
  93. <update id="updateStationOilPrice" parameterType="StationOilPrice">
  94. update station_oil_price
  95. <trim prefix="SET" suffixOverrides=",">
  96. <if test="oilName != null">oil_name = #{oilName},</if>
  97. <if test="oilPrice != null">oil_price = #{oilPrice},</if>
  98. <if test="stationId != null">station_id = #{stationId},</if>
  99. <if test="date != null">date = #{date},</if>
  100. </trim>
  101. where oil_price_id = #{oilPriceId}
  102. </update>
  103. <delete id="deleteStationOilPriceById" parameterType="Long">
  104. delete from station_oil_price where oil_price_id = #{oilPriceId}
  105. </delete>
  106. <delete id="deleteStationOilPriceByIds" parameterType="String">
  107. delete from station_oil_price where oil_price_id in
  108. <foreach item="oilPriceId" collection="array" open="(" separator="," close=")">
  109. #{oilPriceId}
  110. </foreach>
  111. </delete>
  112. </mapper>