EnginInfoReserveMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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.zfire.mall.manager.commonmapper.engin.info.EnginInfoReserveMapper">
  4. <resultMap id="listResultMap" type="com.zfire.mall.manager.bean.engin.info.EnginInfoBean">
  5. <result column="engin_info_id" jdbcType="VARCHAR" property="enginInfoId" />
  6. <result column="admin_company_id" jdbcType="VARCHAR" property="adminCompanyId" />
  7. <result column="customer_id" jdbcType="VARCHAR" property="customerId" />
  8. <result column="customer_number" jdbcType="VARCHAR" property="customerNumber" />
  9. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  10. <result column="engin_info_no" jdbcType="VARCHAR" property="enginInfoNo" />
  11. <result column="order_date" jdbcType="TIMESTAMP" property="orderDate" />
  12. <result column="main_id" jdbcType="VARCHAR" property="mainId" />
  13. <result column="main_name" jdbcType="VARCHAR" property="mainName" />
  14. <result column="project_name" jdbcType="VARCHAR" property="projectName" />
  15. <result column="project_type" jdbcType="VARCHAR" property="projectType" />
  16. <result column="project_note" jdbcType="VARCHAR" property="projectNote" />
  17. <result column="machine_type" jdbcType="VARCHAR" property="machineType" />
  18. <result column="use_unit" jdbcType="VARCHAR" property="useUnit" />
  19. <result column="install_address" jdbcType="VARCHAR" property="installAddress" />
  20. <result column="project_no" jdbcType="VARCHAR" property="projectNo" />
  21. <result column="engin_factory_no" jdbcType="VARCHAR" property="enginFactoryNo" />
  22. <result column="engin_sign_type" jdbcType="VARCHAR" property="enginSignType" />
  23. <result column="trade_category" jdbcType="VARCHAR" property="tradeCategory" />
  24. <result column="linkman" jdbcType="VARCHAR" property="linkman" />
  25. <result column="phone" jdbcType="VARCHAR" property="phone" />
  26. <result column="tel" jdbcType="VARCHAR" property="tel" />
  27. <result column="declare_no" jdbcType="VARCHAR" property="declareNo" />
  28. <result column="power_category" jdbcType="VARCHAR" property="powerCategory" />
  29. <result column="service_id" jdbcType="VARCHAR" property="serviceId" />
  30. <result column="service_name" jdbcType="VARCHAR" property="serviceName" />
  31. <result column="contract_expire_date" jdbcType="TIMESTAMP" property="contractExpireDate" />
  32. <result column="remark" jdbcType="VARCHAR" property="remark" />
  33. <result column="ge_li_note" jdbcType="VARCHAR" property="geLiNote" />
  34. <result column="ge_li_iner_note" jdbcType="VARCHAR" property="geLiInerNote" />
  35. <result column="file_no" jdbcType="VARCHAR" property="fileNo" />
  36. <result column="examine_status" jdbcType="VARCHAR" property="examineStatus" />
  37. <result column="examine_note" jdbcType="VARCHAR" property="examineNote" />
  38. <result column="create_by" jdbcType="VARCHAR" property="createBy" />
  39. <result column="create_name" jdbcType="VARCHAR" property="createName" />
  40. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  41. <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
  42. <result column="update_name" jdbcType="VARCHAR" property="updateName" />
  43. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  44. <result column="submit_by" jdbcType="VARCHAR" property="submitBy" />
  45. <result column="submit_name" jdbcType="VARCHAR" property="submitName" />
  46. <result column="submit_time" jdbcType="TIMESTAMP" property="submitTime" />
  47. <result column="confirm_by" jdbcType="VARCHAR" property="confirmBy" />
  48. <result column="confirm_name" jdbcType="VARCHAR" property="confirmName" />
  49. <result column="confirm_time" jdbcType="TIMESTAMP" property="confirmTime" />
  50. <result column="abandon_by" jdbcType="VARCHAR" property="abandonBy" />
  51. <result column="abandon_name" jdbcType="VARCHAR" property="abandonName" />
  52. <result column="abandon_time" jdbcType="TIMESTAMP" property="abandonTime" />
  53. <result column="is_plan_order" jdbcType="BOOLEAN" property="isPlanOrder" />
  54. <collection property="items" resultMap="itemResultList" />
  55. </resultMap>
  56. <resultMap id="itemResultList" type="com.zfire.mall.manager.bean.engin.info.EnginInfoItemBean">
  57. <result column="itemId" jdbcType="VARCHAR" property="id" />
  58. <result column="sale_type_id" jdbcType="VARCHAR" property="saleTypeId" />
  59. <result column="sale_type_code" jdbcType="VARCHAR" property="saleTypeCode" />
  60. <result column="sale_type_name" jdbcType="VARCHAR" property="saleTypeName" />
  61. <result column="material_id" jdbcType="VARCHAR" property="materialId" />
  62. <result column="material_number" jdbcType="VARCHAR" property="materialNumber" />
  63. <result column="material_old_number" jdbcType="VARCHAR" property="materialOldNumber" />
  64. <result column="material_name" jdbcType="VARCHAR" property="materialName" />
  65. <result column="material_old_number" jdbcType="VARCHAR" property="materialOldNumber" />
  66. <result column="specification" jdbcType="VARCHAR" property="specification" />
  67. <result column="unit" jdbcType="VARCHAR" property="unit" />
  68. <result column="price" jdbcType="DECIMAL" property="price" />
  69. <result column="qty" jdbcType="INTEGER" property="qty" />
  70. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  71. <result column="item_remark" jdbcType="VARCHAR" property="remark" />
  72. <result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
  73. <result column="has_order_qty" jdbcType="INTEGER" property="hasOrderQty" />
  74. <result column="has_deliver_qty" jdbcType="INTEGER" property="hasDeliverQty" />
  75. </resultMap>
  76. <select id="listPage" resultType="com.zfire.mall.manager.bean.engin.info.EnginInfoListBean">
  77. SELECT
  78. a.*
  79. FROM
  80. engin_info_order a, engin_info_order_item b
  81. <where>
  82. a.engin_info_id = b.engin_info_id
  83. <if test="customerId != null and customerId != ''">
  84. AND a.customer_id = #{customerId}
  85. </if>
  86. <if test="enginInfoNo != null and enginInfoNo != ''">
  87. AND a.engin_info_no LIKE CONCAT('%', #{enginInfoNo}, '%')
  88. </if>
  89. <if test="customerKeyWord != null and customerKeyWord != ''">
  90. AND (a.customer_name LIKE CONCAT('%', #{customerKeyWord}, '%')
  91. OR a.customer_number LIKE CONCAT('%', #{customerKeyWord}, '%'))
  92. </if>
  93. <if test="projectName != null and projectName != ''">
  94. AND a.project_name LIKE CONCAT('%', #{projectName}, '%')
  95. </if>
  96. <if test="machineType != null and machineType != ''">
  97. AND a.machine_type = #{machineType}
  98. </if>
  99. <if test="useUnit != null and useUnit != ''">
  100. AND a.use_unit LIKE CONCAT('%', #{useUnit}, '%')
  101. </if>
  102. <if test="installAddress != null and installAddress != ''">
  103. AND a.install_address LIKE CONCAT('%', #{installAddress}, '%')
  104. </if>
  105. <if test="projectNo != null and projectNo != ''">
  106. AND a.project_no LIKE CONCAT('%', #{projectNo}, '%')
  107. </if>
  108. <if test="enginFactoryNo != null and enginFactoryNo != ''">
  109. AND a.engin_factory_no LIKE CONCAT('%', #{enginFactoryNo}, '%')
  110. </if>
  111. <if test="enginSignType != null and enginSignType != ''">
  112. AND a.engin_sign_type LIKE CONCAT('%', #{enginSignType}, '%')
  113. </if>
  114. <if test="startContractExpireDate != null and startContractExpireDate!=''">
  115. AND a.contract_expire_date <![CDATA[ >= ]]> #{startContractExpireDate}
  116. </if>
  117. <if test="endContractExpireDate != null and endContractExpireDate!=''">
  118. AND a.contract_expire_date <![CDATA[ <= ]]> #{startContractExpireDate}
  119. </if>
  120. <if test="createName != null and createName != ''">
  121. AND a.create_name LIKE CONCAT('%', #{createName},'%')
  122. </if>
  123. <if test="confirmName != null and confirmName != ''">
  124. AND a.confirm_name LIKE CONCAT('%', #{confirmName},'%')
  125. </if>
  126. <if test="examineStatus != null and examineStatus != ''">
  127. AND a.examine_status = #{examineStatus}
  128. </if>
  129. <if test="serviceId != null and serviceId != ''">
  130. AND a.service_id = #{serviceId}
  131. </if>
  132. <if test="specification != null and specification != ''">
  133. AND b.specification LIKE CONCAT('%', #{specification},'%')
  134. </if>
  135. <if test="isClose != null">
  136. and a.is_close = #{isClose}
  137. </if>
  138. <if test="enginOrderType != null and enginOrderType != ''">
  139. AND a.engin_order_type = #{enginOrderType}
  140. </if>
  141. <if test="adminCompanyIds != null and adminCompanyIds.size > 0">
  142. AND a.admin_company_id in
  143. <foreach item="item" index="index" collection="adminCompanyIds" open="(" separator=","
  144. close=")">
  145. #{item}
  146. </foreach>
  147. </if>
  148. <if test="serviceIds != null and serviceIds.size > 0">
  149. and a.service_id in
  150. <foreach item="item" index="index" collection="serviceIds" open="(" separator=","
  151. close=")">
  152. #{item}
  153. </foreach>
  154. </if>
  155. AND a.contract_expire_date <![CDATA[ >= ]]> NOW()
  156. AND a.end_status = 0
  157. AND a.del = 0
  158. </where>
  159. GROUP BY a.engin_info_id
  160. HAVING SUM(b.qty) - SUM(b.has_deliver_qty) > 0
  161. ORDER BY a.confirm_time DESC
  162. </select>
  163. <select id="detail" resultMap="listResultMap">
  164. SELECT
  165. a.*,
  166. b.sale_type_id,
  167. b.sale_type_code,
  168. b.sale_type_name,
  169. b.material_id,
  170. b.material_number,
  171. b.material_old_number,
  172. b.material_name,
  173. b.specification,
  174. b.unit,
  175. b.qty,
  176. b.price,
  177. b.total_amount,
  178. b.remark AS item_remark,
  179. b.tax_rate,
  180. b.has_order_qty,
  181. b.has_deliver_qty
  182. FROM
  183. engin_info_order a JOIN engin_info_order_item b ON a.engin_info_id = b.engin_info_id
  184. <where>
  185. a.engin_info_id = #{id}
  186. <if test="customerId != null and customerId != ''">
  187. AND a.customer_id = #{customerId}
  188. </if>
  189. <if test="adminCompanyIds != null and adminCompanyIds.size > 0">
  190. AND a.admin_company_id in
  191. <foreach item="item" index="index" collection="adminCompanyIds" open="(" separator=","
  192. close=")">
  193. #{item}
  194. </foreach>
  195. </if>
  196. <if test="serviceIds != null and serviceIds.size > 0">
  197. and a.service_id in
  198. <foreach item="item" index="index" collection="serviceIds" open="(" separator=","
  199. close=")">
  200. #{item}
  201. </foreach>
  202. </if>
  203. AND a.del = 0
  204. </where>
  205. </select>
  206. <select id="queryDetailByRecordNo" resultMap="listResultMap">
  207. SELECT
  208. a.*,
  209. b.sale_type_id,
  210. b.sale_type_code,
  211. b.sale_type_name,
  212. b.material_id,
  213. b.material_number,
  214. b.material_old_number,
  215. b.material_name,
  216. b.specification,
  217. b.unit,
  218. b.qty,
  219. b.price,
  220. b.total_amount,
  221. b.remark AS item_remark,
  222. b.tax_rate,
  223. b.has_order_qty,
  224. b.has_deliver_qty
  225. FROM
  226. engin_info_order a JOIN engin_info_order_item b ON a.engin_info_id = b.engin_info_id
  227. <where>
  228. <if test="adminCompanyIds != null and adminCompanyIds.size > 0">
  229. AND a.admin_company_id in
  230. <foreach item="item" index="index" collection="adminCompanyIds" open="(" separator=","
  231. close=")">
  232. #{item}
  233. </foreach>
  234. </if>
  235. <if test="customerId != null and customerId != ''">
  236. AND a.customer_id = #{customerId}
  237. </if>
  238. AND a.engin_info_no = #{recordNo}
  239. AND a.contract_expire_date <![CDATA[ >= ]]> NOW()
  240. AND b.has_deliver_qty <![CDATA[ < ]]> b.qty
  241. AND a.is_close = 0
  242. AND a.del = 0
  243. </where>
  244. </select>
  245. </mapper>