StatisticsMapper.xml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.demo.mapper.StatisticsMapper">
  6. <select id="selectTotal" resultType="java.lang.Integer">
  7. SELECT
  8. COUNT(*)
  9. FROM
  10. `dl_statistics`
  11. WHERE behavior = 0
  12. AND deleted = 0;
  13. </select>
  14. <select id="selectUserIdsByEquipmentCode" resultType="java.lang.String">
  15. SELECT DISTINCT
  16. user_id
  17. FROM
  18. `dl_statistics`
  19. WHERE
  20. equipment_code = #{equipmentCode};
  21. </select>
  22. <select id="selectScanByEquipmentCode" resultType="java.lang.Integer">
  23. SELECT
  24. COUNT(*)
  25. FROM
  26. `dl_statistics`
  27. WHERE
  28. equipment_code = #{equipmentCode}
  29. AND behavior = 0;
  30. </select>
  31. <select id="selectDealCountByEquipmentCode" resultType="java.lang.Integer">
  32. SELECT
  33. SUM(deal_tool_count)
  34. FROM
  35. `dl_statistics`
  36. WHERE
  37. equipment_code = #{equipmentCode}
  38. AND behavior = 1;
  39. </select>
  40. <select id="selectTimeDisByMonth" resultType="java.lang.Integer">
  41. SELECT
  42. COUNT(*) count
  43. FROM
  44. `dl_statistics`
  45. WHERE behavior = 0
  46. <if test="month != null">
  47. AND DATE_FORMAT(`time`,'%Y-%m') = #{month}
  48. </if>;
  49. </select>
  50. <select id="selectTimeDisByDay" resultType="java.lang.Integer">
  51. SELECT
  52. COUNT(*) count
  53. FROM
  54. `dl_statistics`
  55. WHERE behavior = 0
  56. <if test="day != null">
  57. AND DATE_FORMAT(`time`,'%Y-%m-%d') = #{day}
  58. </if>;
  59. </select>
  60. <select id="selectTimeDisByYear" resultType="java.lang.Integer">
  61. SELECT
  62. COUNT(*) count
  63. FROM
  64. `dl_statistics`
  65. WHERE behavior = 0
  66. <if test="year != null">
  67. AND DATE_FORMAT(`time`,'%Y') = #{year}
  68. </if>;
  69. </select>
  70. <select id="selectTotalPriceByEquipmentCode" resultType="java.math.BigDecimal">
  71. SELECT
  72. SUM(
  73. CONVERT (
  74. deal_tool_price,
  75. DECIMAL (16, 2)
  76. )
  77. )
  78. FROM
  79. `dl_statistics`
  80. WHERE
  81. equipment_code = #{equipmentCode}
  82. AND behavior = 1;
  83. </select>
  84. </mapper>