No Description

TPestcCoalPollutionStarCowRecordMapper.xml 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.yt.zhylplat.modulePest.specialRecord.mapper.TPestcCoalPollutionStarCowRecordMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap"
  6. type="com.yt.zhylplat.modulePest.specialRecord.entity.TPestcCoalPollutionStarCowRecord">
  7. <id column="id" property="id"/>
  8. <result column="survey_user_id" property="surveyUserId"/>
  9. <result column="survey_address" property="surveyAddress"/>
  10. <result column="survey_date" property="surveyDate"/>
  11. <result column="host_plant" property="hostPlant"/>
  12. <result column="sample_num" property="sampleNum"/>
  13. <result column="disease_sample_amount" property="diseaseSampleAmount"/>
  14. <result column="survey_type" property="surveyType"/>
  15. <result column="remark" property="remark"/>
  16. <result column="create_user_id" property="createUserId"/>
  17. <result column="create_date" property="createDate"/>
  18. <result column="update_user_id" property="updateUserId"/>
  19. <result column="update_date" property="updateDate"/>
  20. <result column="del_flg" property="delFlg"/>
  21. </resultMap>
  22. <!-- 通用查询结果列 -->
  23. <sql id="Base_Column_List">
  24. id, survey_user_id, survey_address, survey_date, host_plant, sample_num, disease_sample_amount, survey_type, remark, create_user_id, create_date, update_user_id, update_date, del_flg
  25. </sql>
  26. <select id="pageList" resultMap="BaseResultMap">
  27. select
  28. uuid,
  29. survey_date
  30. from T_Pestc_Coal_Pollution_Star_Cow_Record
  31. where del_flg = '0'
  32. and survey_type = #{tPestcCoalPollutionStarCowRecord.surveyType}
  33. <if test="tPestcCoalPollutionStarCowRecord.surveyDate !=null">
  34. and survey_date = #{tPestcCoalPollutionStarCowRecord.surveyDate}
  35. </if>
  36. <if test="tPestcCoalPollutionStarCowRecord.surveyAddress !=null and tPestcCoalPollutionStarCowRecord.surveyAddress != '' ">
  37. and survey_address like concat('%',#{tPestcCoalPollutionStarCowRecord.surveyAddress},'%')
  38. </if>
  39. <if test="tPestcCoalPollutionStarCowRecord.hostPlant !=null and tPestcCoalPollutionStarCowRecord.hostPlant != '' ">
  40. and host_plant like concat('%',#{tPestcCoalPollutionStarCowRecord.hostPlant},'%')
  41. </if>
  42. <if test="tPestcCoalPollutionStarCowRecord.surveyUserId !=null and tPestcCoalPollutionStarCowRecord.surveyUserId != '' ">
  43. and survey_user_id = #{tPestcCoalPollutionStarCowRecord.surveyUserId}
  44. </if>
  45. group by uuid,survey_date
  46. order by survey_date desc
  47. </select>
  48. <select id="selectCoalPollutionStarCowRecordList"
  49. resultType="com.yt.zhylplat.modulePest.specialRecord.entity.TPestcCoalPollutionStarCowRecord">
  50. select
  51. date_format(survey_date, '%Y-%m') as surveyMonth,
  52. sum(if(disease_sample_amount is null, 0, disease_sample_amount)) as disease_sample_amount
  53. from
  54. T_Pestc_Coal_Pollution_Star_Cow_Record
  55. where
  56. del_flg = 0
  57. <if test="surveyType != null">
  58. and survey_type = #{surveyType}
  59. </if>
  60. <if test="surveyUserId != null">
  61. and survey_user_id = #{surveyUserId}
  62. </if>
  63. group by
  64. date_format(survey_date, '%Y-%m')
  65. order by
  66. date_format(survey_date, '%Y-%m')
  67. </select>
  68. <select id="selectCoalPollutionRecordList"
  69. resultType="com.yt.zhylplat.modulePest.specialRecord.entity.TPestcCoalPollutionStarCowRecord">
  70. select
  71. date_format(temp.survey_date, '%Y-%m') as surveyMonth,
  72. avg(temp.sufferRate) as sufferRate
  73. from
  74. (<include refid="coalPollutionSufferRateSql"/>) temp
  75. group by
  76. date_format(temp.survey_date, '%Y-%m')
  77. order by
  78. date_format(temp.survey_date, '%Y-%m')
  79. </select>
  80. <sql id="coalPollutionSufferRateSql">
  81. select
  82. survey_date,
  83. survey_user_id,
  84. sum(if(disease_sample_amount is null or disease_sample_amount = 0, 0, 1)) / 5 as sufferRate
  85. from
  86. T_Pestc_Coal_Pollution_Star_Cow_Record
  87. where
  88. del_flg = 0
  89. and
  90. survey_type = 1
  91. <if test="surveyUserId != null">
  92. and survey_user_id = #{surveyUserId}
  93. </if>
  94. group by
  95. survey_date,
  96. survey_user_id
  97. </sql>
  98. </mapper>