ProductInfoMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.fjhx.item.mapper.product.ProductInfoMapper">
  4. <sql id="page">
  5. SELECT pi.id,
  6. pi.definition,
  7. pi.product_classify_id,
  8. pi.CODE,
  9. pi.type,
  10. pi.NAME,
  11. pi.spec,
  12. pi.unit,
  13. pi.remark,
  14. pi.custom_code,
  15. pi.create_user,
  16. pi.create_time,
  17. pi.update_user,
  18. pi.update_time,
  19. pi.bar_code,
  20. pi.length,
  21. pi.width,
  22. pi.height,
  23. pi.net_weight,
  24. pi.technology_id,
  25. pi.name_english,
  26. pi.technology_id,
  27. pi.hs_code,
  28. pi.material,
  29. pi.frontal_texture,
  30. pi.reverse_texture,
  31. pi.color_layer,
  32. pi.color,
  33. pi.stock_threshold,
  34. pi.price,
  35. pi.currency,
  36. pi.cost_price,
  37. pi.cost_currency,
  38. pi.raw_material_id,
  39. pi.prod_img_path,
  40. pi.prod_file_path,
  41. pi.company_id
  42. FROM product_info pi
  43. </sql>
  44. <select id="getPage" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  45. <include refid="page"/>
  46. ${ew.customSqlSegment}
  47. </select>
  48. <select id="getList" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  49. <include refid="page"/>
  50. ${ew.customSqlSegment}
  51. </select>
  52. <select id="getListByProductIds" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  53. SELECT
  54. t1.*,
  55. t2.`name` AS classifyName
  56. FROM
  57. product_info t1
  58. LEFT JOIN product_classify t2 ON t1.product_classify_id = t2.id
  59. <where>
  60. <if test="productIds neq null and productIds.size() > 0">
  61. <foreach collection="productIds" item="productId" open="t1.id IN (" separator="," close=")">
  62. #{productId}
  63. </foreach>
  64. </if>
  65. </where>
  66. </select>
  67. <select id="getListByProductType" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  68. SELECT
  69. t1.*,
  70. t2.`name` AS classifyName
  71. FROM
  72. product_info t1
  73. LEFT JOIN product_classify t2 ON t1.product_classify_id = t2.id
  74. <where>
  75. <if test="productType neq null ">
  76. t1.type = #{productType}
  77. </if>
  78. <if test="definition neq null">
  79. and t1.definition = #{definition}
  80. </if>
  81. <if test="productName neq null and productName neq '' ">
  82. and t1.name = #{productName}
  83. </if>
  84. <if test="productCode neq null and productName neq ''">
  85. and t1.code = #{productCode}
  86. </if>
  87. </where>
  88. </select>
  89. <select id="productTypeRanking" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  90. SELECT pi.type type,
  91. ifnull(SUM(pc.amount), 0) contractAmount,
  92. ifnull(SUM(pc.quantity), 0) contractQuantity,
  93. ifnull(sum(pd.amount), 0) purchaseAmount,
  94. IFNULL(SUM(pd.count), 0) purchaseQuantity
  95. FROM product_info pi
  96. LEFT JOIN contract_product pc ON pi.id = pc.product_id
  97. left join contract bc on pc.contract_id = bc.id
  98. left join purchase_detail pd on pi.id = pd.bussiness_id
  99. ${ew.customSqlSegment}
  100. </select>
  101. <select id="productRanking" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  102. SELECT pi.name name,
  103. ifnull(SUM(pc.amount), 0) contractAmount,
  104. ifnull(SUM(pc.quantity), 0) contractQuantity,
  105. ifnull(sum(pd.amount), 0) purchaseAmount,
  106. IFNULL(SUM(pd.count), 0) purchaseQuantity
  107. FROM product_info pi
  108. LEFT JOIN contract_product pc ON pi.id = pc.product_id
  109. left join contract bc on pc.contract_id = bc.id
  110. left join purchase_detail pd on pi.id = pd.bussiness_id
  111. ${ew.customSqlSegment}
  112. </select>
  113. <select id="getCustomerProductList" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  114. <include refid="page"/>
  115. LEFT JOIN product_classify pc ON pi.product_classify_id = pc.id
  116. ${ew.customSqlSegment}
  117. </select>
  118. <select id="statisticsProduct" resultType="java.util.Map">
  119. SELECT
  120. `type` AS `type`,
  121. count(1) AS count
  122. FROM
  123. product_info
  124. WHERE `type` IS NOT NULL
  125. AND `type` != "null"
  126. AND `type` != ""
  127. AND definition = 1
  128. GROUP BY
  129. `type`
  130. </select>
  131. <select id="getProductAnalysisPage" resultType="com.fjhx.item.entity.product.bo.ProductAnalysisBo">
  132. select pi.id AS productId,
  133. pi.name AS productName
  134. from product_info pi
  135. ${ew.customSqlSegment}
  136. </select>
  137. </mapper>