StationClassStructureMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.StationClassStructureMapper">
  6. <resultMap type="StationClassStructure" id="StationClassStructureResult">
  7. <result property="id" column="id" />
  8. <result property="stationId" column="station_id" />
  9. <result property="orderNo" column="order_no" />
  10. <result property="oilGun" column="oil_gun" />
  11. <result property="oilName" column="oil_name" />
  12. <result property="consumerId" column="consumer_id" />
  13. <result property="consumer" column="consumer" />
  14. <result property="amt" column="amt" />
  15. <result property="stationName" column="station_name" />
  16. <result property="orderLiters" column="order_liters" />
  17. <result property="payType" column="pay_type" />
  18. <result property="payWay" column="pay_way" />
  19. <result property="payDate" column="pay_date" />
  20. <result property="oilPersonnel" column="oil_personnel" />
  21. <result property="orderType" column="order_type" />
  22. <result property="oilType" column="oil_type" />
  23. <result property="printNum" column="print_num" />
  24. <result property="classStructureNo" column="class_structure_no" />
  25. <result property="classStartDate" column="class_start_date" />
  26. <result property="classStructureDate" column="class_structure_date" />
  27. <result property="classStructureMan" column="class_structure_man" />
  28. <result property="oils" column="oils" />
  29. <result property="num" column="num" />
  30. </resultMap>
  31. <sql id="selectStationClassStructureVo">
  32. select id, station_id, order_no, oil_gun, oil_name, consumer_id, consumer, amt, station_name, order_liters, pay_type, pay_way, pay_date, oil_personnel, order_type, oil_type, print_num, class_structure_no, class_start_date, class_structure_date, class_structure_man, oils from station_class_structure
  33. </sql>
  34. <select id="selectStationClassStructureList" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  35. <include refid="selectStationClassStructureVo"/>
  36. <where>
  37. <if test="stationId != null "> and station_id = #{stationId}</if>
  38. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  39. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  40. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  41. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  42. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  43. <if test="amt != null and amt != ''"> and amt = #{amt}</if>
  44. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  45. <if test="orderLiters != null and orderLiters != ''"> and order_liters = #{orderLiters}</if>
  46. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  47. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  48. <if test="payDate != null "> and pay_date = #{payDate}</if>
  49. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  50. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  51. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  52. <if test="printNum != null "> and print_num = #{printNum}</if>
  53. <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
  54. <if test="classStartDate != null "> and class_start_date = #{classStartDate}</if>
  55. <if test="classStructureDate != null "> and class_structure_date = #{classStructureDate}</if>
  56. <if test="classStructureMan != null and classStructureMan != ''"> and class_structure_man = #{classStructureMan}</if>
  57. <if test="oils != null and oils != ''"> and oils = #{oils}</if>
  58. </where>
  59. </select>
  60. <select id="listPersonnelStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  61. SELECT a.oil_personnel,b.gun_no as oil_gun,ROUND(SUM(a.amt),2) as amt,ROUND(SUM(order_liters),2) as order_liters,COUNT(order_no) as order_no
  62. from station_class_structure a JOIN station_personnel b on a.oil_personnel =b.personnel_name
  63. and a.station_id = b.station_id
  64. <where>
  65. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  66. </where>
  67. GROUP BY a.oil_personnel,b.gun_no
  68. </select>
  69. <select id="listOilStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  70. SELECT a.oil_name,GROUP_CONCAT(DISTINCT oil_gun) as oil_gun,ROUND(SUM(a.amt),2) as amt,ROUND(SUM(order_liters),2) as order_liters,COUNT(order_no) as order_no
  71. from station_class_structure a
  72. <where>
  73. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  74. </where>
  75. GROUP BY a.oil_name
  76. </select>
  77. <select id="selectStationClassStructureMax" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  78. select id, station_id, order_no, oil_gun, oil_name, consumer_id, consumer, amt, station_name, order_liters, pay_type, pay_way, pay_date, oil_personnel, order_type, oil_type, print_num, class_structure_no, class_structure_date, class_structure_man, oils
  79. from station_class_structure
  80. where id = (
  81. SELECT MAX(id) from station_class_structurew
  82. <where>
  83. <if test="stationId != null "> and station_id = #{stationId}</if>
  84. </where>
  85. )
  86. </select>
  87. <select id="selectStationClassStructureById" parameterType="Long" resultMap="StationClassStructureResult">
  88. <include refid="selectStationClassStructureVo"/>
  89. where id = #{id}
  90. </select>
  91. <select id="selectDistnctClassStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  92. select countselect count(DISTINCT class_structure_no) as num
  93. from station_class_structure
  94. <where>
  95. <if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
  96. <if test="likeClassStructureNo != null and likeClassStructureNo != ''"> class_structure_no like concat( #{likeClassStructureNo}, '%') </if>
  97. </where>
  98. </select>
  99. <!--根据班次号汇总班结数据-->
  100. <select id="selectSummyClassStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  101. SELECT class_structure_no,class_start_date,class_structure_date,station_id,station_name,count(order_no) as num,
  102. sum(order_liters) as order_liters,sum(amt) as amt,class_structure_man
  103. from station_class_structure
  104. <where>
  105. <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
  106. </where>
  107. GROUP BY class_structure_no,class_start_date,station_id,station_name,class_structure_date,class_structure_man
  108. </select>
  109. <insert id="insertStationClassStructure" parameterType="StationClassStructure" useGeneratedKeys="true" keyProperty="id">
  110. insert into station_class_structure
  111. <trim prefix="(" suffix=")" suffixOverrides=",">
  112. <if test="stationId != null">station_id,</if>
  113. <if test="orderNo != null">order_no,</if>
  114. <if test="oilGun != null">oil_gun,</if>
  115. <if test="oilName != null">oil_name,</if>
  116. <if test="consumerId != null">consumer_id,</if>
  117. <if test="consumer != null">consumer,</if>
  118. <if test="amt != null">amt,</if>
  119. <if test="stationName != null">station_name,</if>
  120. <if test="orderLiters != null">order_liters,</if>
  121. <if test="payType != null">pay_type,</if>
  122. <if test="payWay != null">pay_way,</if>
  123. <if test="payDate != null">pay_date,</if>
  124. <if test="oilPersonnel != null">oil_personnel,</if>
  125. <if test="orderType != null">order_type,</if>
  126. <if test="oilType != null">oil_type,</if>
  127. <if test="printNum != null">print_num,</if>
  128. <if test="classStructureNo != null">class_structure_no,</if>
  129. <if test="classStartDate != null">class_start_date,</if>
  130. <if test="classStructureDate != null">class_structure_date,</if>
  131. <if test="classStructureMan != null">class_structure_man,</if>
  132. <if test="oils != null">oils,</if>
  133. </trim>
  134. <trim prefix="values (" suffix=")" suffixOverrides=",">
  135. <if test="stationId != null">#{stationId},</if>
  136. <if test="orderNo != null">#{orderNo},</if>
  137. <if test="oilGun != null">#{oilGun},</if>
  138. <if test="oilName != null">#{oilName},</if>
  139. <if test="consumerId != null">#{consumerId},</if>
  140. <if test="consumer != null">#{consumer},</if>
  141. <if test="amt != null">#{amt},</if>
  142. <if test="stationName != null">#{stationName},</if>
  143. <if test="orderLiters != null">#{orderLiters},</if>
  144. <if test="payType != null">#{payType},</if>
  145. <if test="payWay != null">#{payWay},</if>
  146. <if test="payDate != null">#{payDate},</if>
  147. <if test="oilPersonnel != null">#{oilPersonnel},</if>
  148. <if test="orderType != null">#{orderType},</if>
  149. <if test="oilType != null">#{oilType},</if>
  150. <if test="printNum != null">#{printNum},</if>
  151. <if test="classStructureNo != null">#{classStructureNo},</if>
  152. <if test="classStartDate != null">#{classStartDate},</if>
  153. <if test="classStructureDate != null">#{classStructureDate},</if>
  154. <if test="classStructureMan != null">#{classStructureMan},</if>
  155. <if test="oils != null">#{oils},</if>
  156. </trim>
  157. </insert>
  158. <update id="updateStationClassStructure" parameterType="StationClassStructure">
  159. update station_class_structure
  160. <trim prefix="SET" suffixOverrides=",">
  161. <if test="stationId != null">station_id = #{stationId},</if>
  162. <if test="orderNo != null">order_no = #{orderNo},</if>
  163. <if test="oilGun != null">oil_gun = #{oilGun},</if>
  164. <if test="oilName != null">oil_name = #{oilName},</if>
  165. <if test="consumerId != null">consumer_id = #{consumerId},</if>
  166. <if test="consumer != null">consumer = #{consumer},</if>
  167. <if test="amt != null">amt = #{amt},</if>
  168. <if test="stationName != null">station_name = #{stationName},</if>
  169. <if test="orderLiters != null">order_liters = #{orderLiters},</if>
  170. <if test="payType != null">pay_type = #{payType},</if>
  171. <if test="payWay != null">pay_way = #{payWay},</if>
  172. <if test="payDate != null">pay_date = #{payDate},</if>
  173. <if test="oilPersonnel != null">oil_personnel = #{oilPersonnel},</if>
  174. <if test="orderType != null">order_type = #{orderType},</if>
  175. <if test="oilType != null">oil_type = #{oilType},</if>
  176. <if test="printNum != null">print_num = #{printNum},</if>
  177. <if test="classStructureNo != null">class_structure_no = #{classStructureNo},</if>
  178. <if test="classStartDate != null">class_start_date = #{classStartDate},</if>
  179. <if test="classStructureDate != null">class_structure_date = #{classStructureDate},</if>
  180. <if test="classStructureMan != null">class_structure_man = #{classStructureMan},</if>
  181. <if test="oils != null">oils = #{oils},</if>
  182. </trim>
  183. where id = #{id}
  184. </update>
  185. <delete id="deleteStationClassStructureById" parameterType="Long">
  186. delete from station_class_structure where id = #{id}
  187. </delete>
  188. <delete id="deleteStationClassStructureByIds" parameterType="String">
  189. delete from station_class_structure where id in
  190. <foreach item="id" collection="array" open="(" separator="," close=")">
  191. #{id}
  192. </foreach>
  193. </delete>
  194. </mapper>