InStoreDetailMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.platform.dao.mapper.store.InStoreDetailMapper">
  4. <sql id="Base_Column_List">
  5. instoredetail.id,
  6. instoredetail.in_id, instoredetail.type,
  7. instoredetail.in_no,
  8. instoredetail.store_id,
  9. instoredetail.spare_id,
  10. instoredetail.num,
  11. instoredetail.purchase_num,
  12. instoredetail.price,
  13. instoredetail.total_price,
  14. instoredetail.purchase_price,
  15. instoredetail.purchase_total_price,
  16. instoredetail.created_user_id,
  17. instoredetail.update_user_id,
  18. instoredetail.created_time,
  19. instoredetail.purchase_detail_id,
  20. instoredetail.update_time
  21. </sql>
  22. <sql id="Ref_Column_List">
  23. instoredetail.in_id,
  24. instoredetail.in_no,instoredetail.type,
  25. instoredetail.purchase_detail_id,
  26. instoredetail.store_id,
  27. instoredetail.spare_id,
  28. instoredetail.num,
  29. instoredetail.purchase_num,
  30. instoredetail.price,
  31. instoredetail.total_price,
  32. instoredetail.purchase_price,
  33. instoredetail.purchase_total_price, </sql>
  34. <sql id="List_Condition">
  35. <if test="id != null and id != ''">
  36. and instoredetail.id = #{id}
  37. </if>
  38. <if test="type != null and type != ''">
  39. and instoredetail.type = #{type}
  40. </if>
  41. <if test="purchaseDetailId != null and purchaseDetailId != ''">
  42. and instoredetail.purchase_detail_id = #{purchaseDetailId}
  43. </if>
  44. <if test="inId != null and inId != ''">
  45. and instoredetail.in_id = #{inId}
  46. </if>
  47. <if test="inNo != null and inNo != ''">
  48. and instoredetail.in_no = #{inNo}
  49. </if>
  50. <if test="storeId != null and storeId != ''">
  51. and instoredetail.store_id = #{storeId}
  52. </if>
  53. <if test="spareId != null and spareId != ''">
  54. and instoredetail.spare_id = #{spareId}
  55. </if>
  56. <if test="num != null">
  57. and instoredetail.num = #{num}
  58. </if>
  59. <if test="price != null">
  60. and instoredetail.price = #{price}
  61. </if>
  62. <if test="totalPrice != null">
  63. and instoredetail.total_price = #{totalPrice}
  64. </if>
  65. <if test="createdUserId != null and createdUserId != ''">
  66. and instoredetail.created_user_id = #{createdUserId}
  67. </if>
  68. <if test="updateUserId != null and updateUserId != ''">
  69. and instoredetail.update_user_id = #{updateUserId}
  70. </if>
  71. <if test="createdTimeStart != null">
  72. and instoredetail.created_time <![CDATA[>=]]>; #{createdTimeStart}
  73. </if>
  74. <if test="createdTimeEnd != null">
  75. and instoredetail.created_time <![CDATA[<=]]> #{createdTimeEnd}
  76. </if>
  77. <if test="createdTime != null">
  78. and instoredetail.created_time = #{createdTime}
  79. </if>
  80. <if test="updateTimeStart != null">
  81. and instoredetail.update_time <![CDATA[>=]]>; #{updateTimeStart}
  82. </if>
  83. <if test="updateTimeEnd != null">
  84. and instoredetail.update_time <![CDATA[<=]]> #{updateTimeEnd}
  85. </if>
  86. <if test="updateTime != null">
  87. and instoredetail.update_time = #{updateTime}
  88. </if>
  89. <if test="keyword != null and keyword != ''">
  90. and instoredetail.id like concat('%',#{keyword},'%')
  91. </if>
  92. <if test="searchStartTime != null">
  93. and instoredetail.created_time <![CDATA[ >= ]]> #{searchStartTime}
  94. </if>
  95. <if test="searchEndTime != null">
  96. and instoredetail.created_time <![CDATA[ <= ]]> #{searchEndTime}
  97. </if>
  98. </sql>
  99. <select id="selectList" parameterType="com.platform.dao.dto.store.InStoreDetailDTO"
  100. resultType="com.platform.dao.vo.query.store.InStoreDetailVO">
  101. select instoredetail.*, store.name storeName, spareinfo.name spareName, spareinfo.no spareNo
  102. from t_in_store_detail as instoredetail
  103. left join t_store store on store.id = instoredetail.store_id
  104. left join t_spare_part_info spareinfo on spareinfo.id = instoredetail.spare_id
  105. <where>
  106. <include refid="List_Condition"/>
  107. <if test="useCompany != null and useCompany != ''">
  108. and store.use_company = #{useCompany}
  109. </if>
  110. <if test="useProject != null and useProject != ''">
  111. and store.use_project = #{useProject}
  112. </if>
  113. <if test="userId != null and userId != ''">
  114. and store.user_id = #{userId}
  115. </if>
  116. <if test="spareNo != null and spareNo != ''">
  117. and spareinfo.no = #{spareNo}
  118. </if>
  119. </where>
  120. </select>
  121. <select id="selectReportList" parameterType="com.platform.dao.dto.store.InStoreDetailDTO"
  122. resultType="com.platform.dao.vo.query.store.InStoreDetailVO">
  123. select
  124. sum(instoredetail.num) as totalNum,
  125. sum(instoredetail.total_price) as totalPrice,
  126. spareinfo.name spareName,
  127. store.name storeName,
  128. store.id storeId,
  129. spareinfo.id spareId,
  130. sparetype.name typeName
  131. from t_in_store_detail instoredetail,t_spare_part_info spareinfo ,t_spare_type sparetype,t_store store
  132. <where>
  133. spareinfo.id = instoredetail.spare_id
  134. and spareinfo.type_id = sparetype.id
  135. and store.id = instoredetail.store_id
  136. <include refid="List_Condition"/>
  137. </where>
  138. GROUP BY
  139. spareinfo.id
  140. </select>
  141. <update id="updateBatch" parameterType="java.util.List">
  142. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  143. update t_in_store_detail
  144. <set>
  145. num=#{item.num},
  146. total_price = #{item.totalPrice}
  147. </set>
  148. where id = #{item.id}
  149. </foreach>
  150. </update>
  151. <select id="selectReportByInStoreFormVO" parameterType="com.platform.dao.vo.query.store.InStoreFormVO"
  152. resultType="com.platform.dao.vo.query.store.InStoreDetailVO">
  153. </select>
  154. <select id="getCurrentlyList" parameterType="com.platform.dao.vo.query.store.InStoreFormVO"
  155. resultType="com.platform.dao.vo.query.store.InStoreDetailVO">
  156. select * from t_in_store_detail left join
  157. t_in_store_form
  158. on t_in_store_form.id = t_in_store_detail.in_id
  159. left join
  160. t_store
  161. on t_in_store_form.store_id=t_store.id
  162. <where>
  163. <if test="userId!=null">
  164. and user_id=#{userId}
  165. </if>
  166. <if test="searchStartTime != null">
  167. and t_in_store_detail.created_time <![CDATA[ > ]]> #{searchStartTime}
  168. </if>
  169. <if test="searchEndTime != null">
  170. and t_in_store_detail.created_time <![CDATA[ < ]]> #{searchEndTime}
  171. </if>
  172. <if test="status != null">
  173. and status = #{status}
  174. </if>
  175. </where>
  176. </select>
  177. </mapper>