StationClassStructureMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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="classStructureDate" column="class_structure_date" />
  26. <result property="classStructureMan" column="class_structure_man" />
  27. <result property="oils" column="oils" />
  28. </resultMap>
  29. <sql id="selectStationClassStructureVo">
  30. 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 from station_class_structure
  31. </sql>
  32. <select id="selectStationClassStructureList" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
  33. <include refid="selectStationClassStructureVo"/>
  34. <where>
  35. <if test="stationId != null "> and station_id = #{stationId}</if>
  36. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  37. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  38. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  39. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  40. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  41. <if test="amt != null and amt != ''"> and amt = #{amt}</if>
  42. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  43. <if test="orderLiters != null and orderLiters != ''"> and order_liters = #{orderLiters}</if>
  44. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  45. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  46. <if test="payDate != null "> and pay_date = #{payDate}</if>
  47. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  48. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  49. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  50. <if test="printNum != null "> and print_num = #{printNum}</if>
  51. <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
  52. <if test="classStructureDate != null "> and class_structure_date = #{classStructureDate}</if>
  53. <if test="classStructureMan != null and classStructureMan != ''"> and class_structure_man = #{classStructureMan}</if>
  54. <if test="oils != null and oils != ''"> and oils = #{oils}</if>
  55. </where>
  56. </select>
  57. <select id="selectStationClassStructureMax" parameterType="Long" resultMap="StationClassStructureResult">
  58. 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 from station_class_structure
  59. where id = (select max(id)
  60. from station_class_structure where station_id = #{stationId});
  61. </select>
  62. <select id="selectStationClassStructureById" parameterType="Long" resultMap="StationClassStructureResult">
  63. <include refid="selectStationClassStructureVo"/>
  64. where id = #{id}
  65. </select>
  66. <!--根据盐工汇总班结数据-->
  67. <select id="listPersonnelStructure" parameterType="Long" resultMap="StationClassStructureResult">
  68. SELECT a.oil_personnel,b.gun_no,ROUND(sum(a.order_liters),2) as order_liters,ROUND(SUM(a.amt),2) as amt,COUNT(a.order_no) counts
  69. from station_class_structure a
  70. join station_personnel b on a.oil_personnel=b.personnel_name and a.station_id = b.station_id
  71. where a.station_id = #{stationId}
  72. GROUP BY a.oil_personnel,b.gun_no
  73. </select>
  74. <insert id="insertStationClassStructure" parameterType="StationClassStructure" useGeneratedKeys="true" keyProperty="id">
  75. insert into station_class_structure
  76. <trim prefix="(" suffix=")" suffixOverrides=",">
  77. <if test="stationId != null">station_id,</if>
  78. <if test="orderNo != null">order_no,</if>
  79. <if test="oilGun != null">oil_gun,</if>
  80. <if test="oilName != null">oil_name,</if>
  81. <if test="consumerId != null">consumer_id,</if>
  82. <if test="consumer != null">consumer,</if>
  83. <if test="amt != null">amt,</if>
  84. <if test="stationName != null">station_name,</if>
  85. <if test="orderLiters != null">order_liters,</if>
  86. <if test="payType != null">pay_type,</if>
  87. <if test="payWay != null">pay_way,</if>
  88. <if test="payDate != null">pay_date,</if>
  89. <if test="oilPersonnel != null">oil_personnel,</if>
  90. <if test="orderType != null">order_type,</if>
  91. <if test="oilType != null">oil_type,</if>
  92. <if test="printNum != null">print_num,</if>
  93. <if test="classStructureNo != null">class_structure_no,</if>
  94. <if test="classStructureDate != null">class_structure_date,</if>
  95. <if test="classStructureMan != null">class_structure_man,</if>
  96. <if test="oils != null">oils,</if>
  97. </trim>
  98. <trim prefix="values (" suffix=")" suffixOverrides=",">
  99. <if test="stationId != null">#{stationId},</if>
  100. <if test="orderNo != null">#{orderNo},</if>
  101. <if test="oilGun != null">#{oilGun},</if>
  102. <if test="oilName != null">#{oilName},</if>
  103. <if test="consumerId != null">#{consumerId},</if>
  104. <if test="consumer != null">#{consumer},</if>
  105. <if test="amt != null">#{amt},</if>
  106. <if test="stationName != null">#{stationName},</if>
  107. <if test="orderLiters != null">#{orderLiters},</if>
  108. <if test="payType != null">#{payType},</if>
  109. <if test="payWay != null">#{payWay},</if>
  110. <if test="payDate != null">#{payDate},</if>
  111. <if test="oilPersonnel != null">#{oilPersonnel},</if>
  112. <if test="orderType != null">#{orderType},</if>
  113. <if test="oilType != null">#{oilType},</if>
  114. <if test="printNum != null">#{printNum},</if>
  115. <if test="classStructureNo != null">#{classStructureNo},</if>
  116. <if test="classStructureDate != null">#{classStructureDate},</if>
  117. <if test="classStructureMan != null">#{classStructureMan},</if>
  118. <if test="oils != null">#{oils},</if>
  119. </trim>
  120. </insert>
  121. <update id="updateStationClassStructure" parameterType="StationClassStructure">
  122. update station_class_structure
  123. <trim prefix="SET" suffixOverrides=",">
  124. <if test="stationId != null">station_id = #{stationId},</if>
  125. <if test="orderNo != null">order_no = #{orderNo},</if>
  126. <if test="oilGun != null">oil_gun = #{oilGun},</if>
  127. <if test="oilName != null">oil_name = #{oilName},</if>
  128. <if test="consumerId != null">consumer_id = #{consumerId},</if>
  129. <if test="consumer != null">consumer = #{consumer},</if>
  130. <if test="amt != null">amt = #{amt},</if>
  131. <if test="stationName != null">station_name = #{stationName},</if>
  132. <if test="orderLiters != null">order_liters = #{orderLiters},</if>
  133. <if test="payType != null">pay_type = #{payType},</if>
  134. <if test="payWay != null">pay_way = #{payWay},</if>
  135. <if test="payDate != null">pay_date = #{payDate},</if>
  136. <if test="oilPersonnel != null">oil_personnel = #{oilPersonnel},</if>
  137. <if test="orderType != null">order_type = #{orderType},</if>
  138. <if test="oilType != null">oil_type = #{oilType},</if>
  139. <if test="printNum != null">print_num = #{printNum},</if>
  140. <if test="classStructureNo != null">class_structure_no = #{classStructureNo},</if>
  141. <if test="classStructureDate != null">class_structure_date = #{classStructureDate},</if>
  142. <if test="classStructureMan != null">class_structure_man = #{classStructureMan},</if>
  143. <if test="oils != null">oils = #{oils},</if>
  144. </trim>
  145. where id = #{id}
  146. </update>
  147. <delete id="deleteStationClassStructureById" parameterType="Long">
  148. delete from station_class_structure where id = #{id}
  149. </delete>
  150. <delete id="deleteStationClassStructureByIds" parameterType="String">
  151. delete from station_class_structure where id in
  152. <foreach item="id" collection="array" open="(" separator="," close=")">
  153. #{id}
  154. </foreach>
  155. </delete>
  156. </mapper>