BigCompanyDao.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.hwrj.cloud.admin.dao.BigCompanyDao">
  4. <select id="bigCompanyInfo" resultType="java.util.Map">
  5. <!-- SELECT-->
  6. <!-- a.id,-->
  7. <!-- a.comp_name AS name,-->
  8. <!-- a.comp_con_person as compConPerson,-->
  9. <!-- a.comp_con_num as compConNum,-->
  10. <!-- concat(a.province_id,a.city_id,a.county_id) as address,-->
  11. <!-- a.longitude as lng,-->
  12. <!-- a.latitude as latitude,-->
  13. <!-- a.company_type as companyType-->
  14. <!-- FROM-->
  15. <!-- ums_company_info a-->
  16. <!-- WHERE-->
  17. <!-- a.comp_status =0-->
  18. <!-- <if test="key != null and key != ''">-->
  19. <!-- and a.comp_name like concat('%',#{key},'%')-->
  20. <!-- </if>-->
  21. <!-- <if test="catId != null">-->
  22. <!-- and a.id in (-->
  23. <!-- select p.ums_company_info_id from pms_product p LEFT JOIN pms_product_category pc on p.product_category_id = pc.id where pc.parent_id = #{catId} GROUP BY p.ums_company_info_id-->
  24. <!-- )-->
  25. <!-- </if>-->
  26. SELECT
  27. a.id,
  28. a.comp_name AS name,
  29. a.comp_con_person AS compConPerson,
  30. a.comp_con_num AS compConNum,
  31. concat( a.province_id, a.city_id, a.county_id ) AS address,
  32. a.longitude AS lng,
  33. a.latitude AS latitude,
  34. a.company_type AS companyType
  35. FROM
  36. ums_company_info a
  37. WHERE
  38. a.comp_status = 0
  39. <if test="key != null and key != ''">
  40. and a.comp_name like concat('%',#{key},'%')
  41. </if>
  42. <if test="catId != null">
  43. and a.id in (
  44. select p.comp_id from pms_product p LEFT JOIN pms_product_category pc on p.product_category_id =
  45. pc.id where pc.parent_id = #{catId} GROUP BY p.comp_id
  46. )
  47. </if>
  48. UNION ALL
  49. SELECT
  50. CONCAT( b.id, '9999' ) AS id,
  51. b.comp_name AS name,
  52. b.comp_con_person AS compConPerson,
  53. NULL AS compConNum,
  54. concat( b.province_id, b.city_id, b.county_id ) AS address,
  55. b.longitude AS lng,
  56. b.latitude AS latitude,
  57. b.company_type AS companyType
  58. FROM
  59. ums_company_info_ext b
  60. WHERE
  61. b.delete_status = 0
  62. <if test="key != null and key != ''">
  63. AND b.comp_name LIKE concat( '%', #{key},'%')
  64. </if>
  65. <if test="catId != null">
  66. and b.product_category_id = #{catId}
  67. </if>
  68. </select>
  69. <select id="getCat" resultType="java.lang.String">
  70. SELECT
  71. CONCAT(
  72. a.id,
  73. '---',
  74. a. NAME,
  75. '---',
  76. IFNULL(SUM(d.numm), 0)
  77. ) AS cat
  78. FROM
  79. pms_product_category a
  80. LEFT JOIN (
  81. SELECT
  82. b.comp_name,
  83. b.comp_id,
  84. c.parent_id,
  85. CASE IFNULL(b.comp_id ,- 1)
  86. WHEN - 1 THEN
  87. 0
  88. ELSE
  89. 1
  90. END AS numm
  91. FROM
  92. pms_product b
  93. LEFT JOIN pms_product_category c ON b.product_category_id = c.id
  94. WHERE
  95. b.product_category_id IS NOT NULL
  96. GROUP BY
  97. c.parent_id,
  98. b.comp_id
  99. UNION ALL
  100. SELECT
  101. xxx.comp_name AS ums_company_info,
  102. xxx.id AS ums_company_info_id,
  103. xxx.product_category_id AS parent_id,
  104. 1 AS numm
  105. FROM
  106. ums_company_info_ext xxx
  107. ) d ON a.id = d.parent_id
  108. GROUP BY
  109. a.id
  110. </select>
  111. </mapper>