GoafDevInfoMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.goaf.mapper.GoafDevInfoMapper">
  5. <resultMap id="GoafDevInfoMapper" type="com.zhyc.xps.goaf.entity.GoafDevInfo">
  6. <id column="goaf_dev_id" property="goafDevId" jdbcType="BIGINT"/>
  7. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  8. <result column="goaf_dev_name" property="goafDevName" jdbcType="VARCHAR"/>
  9. <result column="goaf_dev_location" property="goafDevLocation" jdbcType="VARCHAR"/>
  10. <result column="goaf_dev_typename" property="goafDevTypename" jdbcType="VARCHAR"/>
  11. <result column="goaf_install_time" property="goafInstallTime" jdbcType="TIMESTAMP"/>
  12. </resultMap>
  13. <resultMap id="GoafDevInfoDtoMapper" type="com.zhyc.xps.goaf.dto.GoafDevInfoDto">
  14. <id column="goaf_dev_id" property="goafDevId" jdbcType="BIGINT"/>
  15. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  16. <result column="goaf_dev_name" property="goafDevName" jdbcType="VARCHAR"/>
  17. <result column="goaf_dev_location" property="goafDevLocation" jdbcType="VARCHAR"/>
  18. <result column="goaf_dev_typename" property="goafDevTypename" jdbcType="VARCHAR"/>
  19. <result column="goaf_install_time" property="goafInstallTime" jdbcType="TIMESTAMP"/>
  20. </resultMap>
  21. <select id="getByList" parameterType="java.util.Map" resultMap="GoafDevInfoMapper">
  22. SELECT *
  23. FROM goaf_devinfo
  24. <trim prefix="where" prefixOverrides="AND">
  25. <if test="ocId !=null">
  26. oc_id = #{ocId ,jdbcType=BIGINT}
  27. </if>
  28. <if test="goafDevName !=null and goafDevName != ''">
  29. AND goaf_dev_name = #{goafDevName ,jdbcType=VARCHAR}
  30. </if>
  31. <if test="goafDevLocation !=null and goafDevLocation != ''">
  32. AND goaf_dev_location = #{goafDevLocation ,jdbcType=VARCHAR}
  33. </if>
  34. <if test="goafDevTypename !=null and goafDevTypename != ''">
  35. AND goaf_dev_typename = #{goafDevTypename ,jdbcType=VARCHAR}
  36. </if>
  37. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  38. AND goaf_install_time BETWEEN #{startDate} AND #{endDate}
  39. </if>
  40. </trim>
  41. </select>
  42. <!--分页查询-->
  43. <select id="getByPage" parameterType="java.util.Map" resultMap="GoafDevInfoMapper">
  44. SELECT *
  45. FROM goaf_devinfo
  46. <trim prefix="where" prefixOverrides="AND">
  47. <if test="ocId !=null">
  48. oc_id = #{ocId ,jdbcType=BIGINT}
  49. </if>
  50. <if test="goafDevName !=null and goafDevName != ''">
  51. AND goaf_dev_name = #{goafDevName ,jdbcType=VARCHAR}
  52. </if>
  53. <if test="goafDevLocation !=null and goafDevLocation != ''">
  54. AND goaf_dev_location = #{goafDevLocation ,jdbcType=VARCHAR}
  55. </if>
  56. <if test="goafDevTypename !=null and goafDevTypename != ''">
  57. AND goaf_dev_typename = #{goafDevTypename ,jdbcType=VARCHAR}
  58. </if>
  59. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  60. AND goaf_install_time BETWEEN #{startDate} AND #{endDate}
  61. </if>
  62. </trim>
  63. </select>
  64. <select id="getByGoafDevId" resultMap="GoafDevInfoMapper">
  65. SELECT *
  66. FROM goaf_devinfo
  67. WHERE goaf_dev_id = #{goafDevId, jdbcType=BIGINT}
  68. </select>
  69. <select id="getByGoafDevName" resultMap="GoafDevInfoMapper">
  70. SELECT *
  71. FROM goaf_devinfo
  72. WHERE goaf_dev_name = #{goafDevName, jdbcType=VARCHAR}
  73. </select>
  74. <insert id="create" parameterType="com.zhyc.xps.goaf.entity.GoafDevInfo">
  75. insert into goaf_devinfo
  76. <trim prefix="(" suffix=")" suffixOverrides=",">
  77. <if test="goafDevId != null">
  78. goaf_dev_id,
  79. </if>
  80. <if test="ocId != null">
  81. oc_id,
  82. </if>
  83. <if test="goafDevName != null and goafDevName != ''">
  84. goaf_dev_name,
  85. </if>
  86. <if test="goafDevLocation != null and goafDevLocation != ''">
  87. goaf_dev_location,
  88. </if>
  89. <if test="goafDevTypename != null and goafDevTypename != ''">
  90. goaf_dev_typename,
  91. </if>
  92. <if test="goafInstallTime != null">
  93. goaf_install_time,
  94. </if>
  95. </trim>
  96. <trim prefix="values (" suffix=")" suffixOverrides=",">
  97. <if test="goafDevId != null">
  98. #{goafDevId, jdbcType=BIGINT},
  99. </if>
  100. <if test="ocId != null">
  101. #{ocId, jdbcType=BIGINT},
  102. </if>
  103. <if test="goafDevName != null and goafDevName != ''">
  104. #{goafDevName, jdbcType=VARCHAR},
  105. </if>
  106. <if test="goafDevLocation != null and goafDevLocation != ''">
  107. #{goafDevLocation, jdbcType=VARCHAR},
  108. </if>
  109. <if test="goafDevTypename != null and goafDevTypename != ''">
  110. #{goafDevTypename, jdbcType=VARCHAR},
  111. </if>
  112. <if test="goafInstallTime != null">
  113. #{goafInstallTime, jdbcType=TIMESTAMP},
  114. </if>
  115. </trim>
  116. </insert>
  117. <!--Update更新-->
  118. <update id="update" parameterType="com.zhyc.xps.goaf.entity.GoafDevInfo">
  119. UPDATE goaf_devinfo
  120. <trim suffixOverrides=",">
  121. <set>
  122. <if test="goafDevName != null and goafDevName != ''">
  123. goaf_dev_name = #{goafDevName, jdbcType=VARCHAR},
  124. </if>
  125. <if test="goafDevLocation != null and goafDevLocation != ''">
  126. goaf_dev_location = #{goafDevLocation, jdbcType=VARCHAR},
  127. </if>
  128. <if test="goafDevTypename != null and goafDevTypename != ''">
  129. goaf_dev_typename = #{goafDevTypename, jdbcType=VARCHAR},
  130. </if>
  131. <if test="goafInstallTime != null">
  132. goaf_install_time = #{goafInstallTime, jdbcType=TIMESTAMP},
  133. </if>
  134. </set>
  135. </trim>
  136. WHERE goaf_dev_id = #{goafDevId, jdbcType=BIGINT}
  137. </update>
  138. <delete id="delete" >
  139. DELETE FROM goaf_devinfo
  140. WHERE goaf_dev_id = #{goafDevId, jdbcType=BIGINT}
  141. </delete>
  142. <!--列表查询-->
  143. <select id="getStatisNum" parameterType="java.util.Map" resultType="com.zhyc.xps.goaf.vo.DevStatisVo">
  144. SELECT
  145. COUNT(*) AS 'goafDevTotalNum',
  146. IFNULL(SUM( CASE WHEN goaf_dev_typename = '空压机' THEN 1 ELSE 0 END ), 0) AS 'compressorNum',
  147. IFNULL(SUM( CASE WHEN goaf_dev_typename = '水泵' THEN 1 ELSE 0 END ), 0) AS 'waterpumpNum',
  148. IFNULL(SUM( CASE WHEN goaf_dev_typename = '电机' THEN 1 ELSE 0 END ), 0) AS 'electricalmachineryNum',
  149. IFNULL(SUM( CASE WHEN goaf_dev_typename = '其它' THEN 1 ELSE 0 END ), 0) AS 'otherNum'
  150. FROM goaf_devinfo
  151. WHERE oc_id = #{ocId ,jdbcType=BIGINT}
  152. </select>
  153. </mapper>