PatentMarkerDataMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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="cn.cslg.pas.mapper.PatentMarketDataMapper">
  4. <resultMap id="queryByDateMap" type="cn.cslg.pas.common.model.vo.ProductMarketDataTrendVO">
  5. <result column="market_date" property="marketDate"/>
  6. <result column="sale_total_money" property="saleTotalMoney"/>
  7. <result column="custom_license_money" property="customLicenseMoney"/>
  8. </resultMap>
  9. <!--传入了地区-->
  10. <!--按照年为单位返回查询到的营销数据-->
  11. <select id="patentQueryByYear" resultMap="queryByDateMap">
  12. SELECT CONCAT(YEAR(CONCAT(sale_time,'-02')),'年') AS market_date,
  13. sum(sale_money) AS sale_total_money,
  14. CAST(sum(custom_license_rate * sale_money) AS DECIMAL (19, 2)) AS custom_license_money
  15. FROM product_market_data a left join product b on a.product_id =b.id
  16. <where>
  17. product_id IN
  18. (
  19. SELECT product_id FROM asso_product_patent WHERE patent_no IN
  20. <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
  21. #{patentNo}
  22. </foreach>
  23. )
  24. <if test="saleArea != null and saleArea != ''">
  25. AND sale_area = #{saleArea}
  26. </if>
  27. AND b.tenant_id =#{tenantId}
  28. GROUP BY market_date
  29. </where>
  30. </select>
  31. <!--传入了地区-->
  32. <!--按照季度为单位返回查询到的营销数据-->
  33. <select id="patentQueryBySeason" resultMap="queryByDateMap">
  34. SELECT CONCAT(YEAR(CONCAT(sale_time,'-02')),'年','第',QUARTER(CONCAT(sale_time,'-02')),'季度') AS market_date,
  35. sum(sale_money) AS sale_total_money,
  36. CAST(sum(custom_license_rate * sale_money) AS DECIMAL (19, 2)) AS custom_license_money
  37. FROM product_market_data a left join product b on a.product_id =b.id
  38. WHERE product_id IN
  39. (
  40. SELECT product_id FROM asso_product_patent WHERE patent_no IN
  41. <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
  42. #{patentNo}
  43. </foreach>
  44. )
  45. <if test="saleArea != null and saleArea != ''">
  46. AND sale_area = #{saleArea}
  47. </if>
  48. AND b.tenant_id =#{tenantId}
  49. GROUP BY market_date
  50. </select>
  51. <!--传入了地区-->
  52. <!--按照月份为单位返回查询到的营销数据-->
  53. <select id="patentQueryByMonth" resultMap="queryByDateMap">
  54. SELECT CONCAT(YEAR(CONCAT(sale_time,'-02')),'-',MONTH(CONCAT(sale_time,'-02'))) AS market_date,
  55. sum(sale_money) AS sale_total_money,
  56. CAST(sum(custom_license_rate * sale_money) AS DECIMAL (19, 2)) AS custom_license_money
  57. FROM product_market_data a left join product b on a.product_id =b.id
  58. WHERE a.product_id IN
  59. (
  60. SELECT product_id FROM asso_product_patent WHERE patent_no IN
  61. <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
  62. #{patentNo}
  63. </foreach>
  64. )
  65. <if test="saleArea != null and saleArea != ''">
  66. AND sale_area = #{saleArea}
  67. </if>
  68. AND b.tenant_id =#{tenantId}
  69. GROUP BY market_date
  70. </select>
  71. <!--根据专利号集合查询许可历史的信息-->
  72. <resultMap id="PRDataQueryByDateMap" type="cn.cslg.pas.common.model.vo.PermissionRecordTrendVO">
  73. <result column="market_date" property="marketDate"/>
  74. <result column="license_fee" property="licenseFee"/>
  75. </resultMap>
  76. <!--按照年份返回查询到的信息-->
  77. <select id="PRDataQueryByYear" resultMap="PRDataQueryByDateMap">
  78. SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m-%d')) as CHAR),'年') AS market_date,
  79. SUM(license_fee) AS license_fee
  80. FROM permission_record
  81. WHERE PATENT_NO IN
  82. <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
  83. #{patentNo}
  84. </foreach>
  85. and tenant_id =#{tenantId}
  86. GROUP BY market_date
  87. </select>
  88. <!--按照季度返回查询到的信息-->
  89. <select id="PRDataQueryBySeason" resultMap="PRDataQueryByDateMap">
  90. SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m-%d')) as CHAR),'年',
  91. '第',CAST(QUARTER(STR_TO_DATE(license_time,'%Y-%m-%d')) as CHAR),'季度') AS market_date,
  92. SUM(license_fee) AS license_fee
  93. FROM permission_record
  94. WHERE PATENT_NO IN
  95. <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
  96. #{patentNo}
  97. </foreach>
  98. and tenant_id =#{tenantId}
  99. GROUP BY market_date
  100. </select>
  101. <!--按照月份返回查询到的信息-->
  102. <select id="PRDataQueryByMonth" resultMap="PRDataQueryByDateMap">
  103. SELECT CONCAT(CAST(YEAR(STR_TO_DATE(license_time,'%Y-%m-%d')) AS CHAR),'-',
  104. CAST(MONTH(STR_TO_DATE(license_time,'%Y-%m-%d')) AS CHAR)) AS market_date,
  105. SUM(license_fee) AS license_fee
  106. FROM permission_record
  107. WHERE PATENT_NO IN
  108. <foreach collection="patentNoList" item="patentNo" index="index" open="(" close=")" separator=",">
  109. #{patentNo}
  110. </foreach>
  111. and tenant_id =#{tenantId}
  112. GROUP BY market_date
  113. </select>
  114. </mapper>