ProductInfoMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. <select id="getPage" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  5. SELECT
  6. pi.id,
  7. pi.definition,
  8. pi.product_classify_id,
  9. pi.CODE,
  10. pi.type,
  11. pi.NAME,
  12. pi.spec,
  13. pi.unit,
  14. pi.remark,
  15. pi.custom_code,
  16. pi.create_user,
  17. pi.create_time,
  18. pi.update_user,
  19. pi.update_time,
  20. pi.victoriatourist_json,
  21. pi.bar_code,
  22. IF(DATEDIFF(now(),pi.create_time)> json_unquote( victoriatourist_json -> '$.growUpDay' ),3,IF( DATEDIFF(now(),pi.create_time)> json_unquote( victoriatourist_json -> '$.newProductsDay' ), 2, 1 )) AS lifeCycle,
  23. pi.unit_price,
  24. pi.standard_json
  25. FROM
  26. product_info pi
  27. LEFT JOIN bytesailing_mes.applicable_products aps ON aps.product_id = pi.id
  28. AND aps.del_flag = 0
  29. ${ew.customSqlSegment}
  30. </select>
  31. <select id="getListByProductIds" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  32. SELECT
  33. t1.*,
  34. t2.`name` AS classifyName
  35. FROM
  36. product_info t1
  37. LEFT JOIN product_classify t2 ON t1.product_classify_id = t2.id
  38. <where>
  39. <if test="productIds neq null and productIds.size() > 0">
  40. <foreach collection="productIds" item="productId" open="t1.id IN (" separator="," close=")">
  41. #{productId}
  42. </foreach>
  43. </if>
  44. </where>
  45. </select>
  46. <select id="getListByProductType" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  47. SELECT
  48. t1.*,
  49. t2.`name` AS classifyName
  50. FROM
  51. product_info t1
  52. LEFT JOIN product_classify t2 ON t1.product_classify_id = t2.id
  53. <where>
  54. <if test="productType neq null ">
  55. t1.type = #{productType}
  56. </if>
  57. <if test="definition neq null">
  58. and t1.definition = #{definition}
  59. </if>
  60. <if test="productName neq null and productName neq '' ">
  61. and t1.name = #{productName}
  62. </if>
  63. <if test="productCode neq null and productName neq ''">
  64. and t1.code = #{productCode}
  65. </if>
  66. </where>
  67. </select>
  68. <select id="productTypeRanking" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  69. SELECT pi.type type,
  70. pi.product_classify_id,
  71. pic.parent_id_set,
  72. ifnull(SUM(pc.amount * bc.rate), 0) contractAmount,
  73. ifnull(SUM(pc.quantity), 0) contractQuantity,
  74. ifnull(sum(pd.amount), 0) purchaseAmount,
  75. IFNULL(SUM(pd.count), 0) purchaseQuantity
  76. FROM product_info pi
  77. LEFT JOIN bytesailing_sale.contract_product pc ON pi.id = pc.product_id
  78. LEFT JOIN bytesailing_sale.contract bc ON pc.contract_id = bc.id
  79. LEFT JOIN bytesailing_purchase.purchase_detail pd ON pi.id = pd.bussiness_id
  80. LEFT JOIN product_classify pic ON pi.product_classify_id = pic.id
  81. ${ew.customSqlSegment}
  82. </select>
  83. <select id="productRanking" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  84. SELECT
  85. pi.name name,
  86. ifnull(SUM(pc.amount),0) contractAmount,
  87. ifnull(SUM(pc.quantity),0) contractQuantity,
  88. ifnull(sum(pd.amount),0) purchaseAmount,
  89. IFNULL(SUM(pd.count),0) purchaseQuantity
  90. FROM
  91. product_info pi
  92. LEFT JOIN bytesailing_sale.contract_product pc ON pi.id = pc.product_id
  93. left join bytesailing_sale.contract bc on pc.contract_id = bc.id
  94. left join bytesailing_purchase.purchase_detail pd on pi.id = pd.bussiness_id
  95. ${ew.customSqlSegment}
  96. </select>
  97. <select id="getCustomerProductList" resultType="com.fjhx.item.entity.product.vo.ProductInfoVo">
  98. SELECT pi.id,
  99. pi.definition,
  100. pi.product_classify_id,
  101. pi.CODE,
  102. pi.type,
  103. pi.NAME,
  104. pi.spec,
  105. pi.unit,
  106. pi.remark,
  107. pi.custom_code,
  108. pi.create_user,
  109. pi.create_time,
  110. pi.update_user,
  111. pi.update_time,
  112. pi.ehsd_json,
  113. pi.bar_code,
  114. c.`name` customerName
  115. FROM product_info pi
  116. LEFT JOIN product_classify pc ON pi.product_classify_id = pc.id
  117. LEFT JOIN bytesailing_customer.customer c ON json_unquote(pi.ehsd_json -> '$.customerId') = c.id
  118. ${ew.customSqlSegment}
  119. </select>
  120. <select id="statisticsProduct" resultType="java.util.Map">
  121. SELECT
  122. `type` AS `type`,
  123. count( 1 ) AS count
  124. FROM
  125. product_info
  126. WHERE `type` IS NOT NULL
  127. AND `type` != "null"
  128. AND `type` != ""
  129. AND definition = 1
  130. GROUP BY
  131. `type`
  132. </select>
  133. </mapper>