ProductInfoMapper.xml 5.0 KB

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