YdbpMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.siwei.apply.mapper.YdbpMapper">
  6. <!-- ResultMap 映射 -->
  7. <resultMap id="YdbpResultMap" type="com.siwei.apply.domain.Ydbp">
  8. <id property="id" column="id"/>
  9. <result property="projectId" column="project_id"/>
  10. <result property="tdyt" column="tdyt"/>
  11. <result property="ydArea" column="yd_area"/>
  12. <result property="ydUnit" column="yd_unit"/>
  13. <result property="zsArea" column="zs_area"/>
  14. <result property="zsUnit" column="zs_unit"/>
  15. <result property="hasZz" column="has_zz"/>
  16. <result property="bpDate" column="bp_date"/>
  17. <result property="pfwh" column="pfwh"/>
  18. <result property="pfDate" column="pf_date"/>
  19. <result property="hasOnchain" column="has_onchain"/>
  20. <result property="creatorId" column="creator_id"/>
  21. <result property="createdAt" column="created_at"/>
  22. <result property="updatedAt" column="updated_at"/>
  23. </resultMap>
  24. <select id="isExit" resultType="Boolean">
  25. SELECT COUNT(1) > 0
  26. FROM t_ydbp
  27. WHERE project_id = #{projectId}
  28. </select>
  29. <!-- 插入语句 -->
  30. <insert id="add" parameterType="com.siwei.apply.domain.Ydbp">
  31. INSERT INTO t_ydbp (id, project_id, tdyt, yd_area, yd_unit, zs_area, zs_unit, has_zz,
  32. bp_date, pfwh, pf_date, has_onchain, creator_id, created_at, updated_at)
  33. VALUES (#{id}, #{projectId}, #{tdyt}, #{ydArea}, #{ydUnit}, #{zsArea}, #{zsUnit}, #{hasZz},
  34. #{bpDate}, #{pfwh}, #{pfDate}, false, #{creatorId}, now(), now())
  35. </insert>
  36. <!-- 查询语句 -->
  37. <select id="get" resultMap="YdbpResultMap">
  38. SELECT *
  39. FROM t_ydbp
  40. WHERE project_id = #{projectId}
  41. </select>
  42. <!-- 新增:根据主键id获取记录 -->
  43. <select id="getById" resultMap="YdbpResultMap">
  44. SELECT *
  45. FROM t_ydbp
  46. WHERE id = #{id}
  47. </select>
  48. <select id="getStatisticsList" resultType="map">
  49. SELECT
  50. pro.ID AS project_id,
  51. bp.ID AS node_id,
  52. bp.zs_area,
  53. left(bp.pf_date,4) AS nf,
  54. bp.zs_unit,
  55. <if test="hasGeom != null and hasGeom">
  56. (SELECT array_to_string(array_agg(ST_AsEWKT(gd.geom)), '|')
  57. FROM t_node_land nl
  58. LEFT JOIN t_geom_db_details gd ON nl.geom_db_id = gd.upload_id
  59. WHERE nl.node_id = bp.id
  60. AND gd.geom IS NOT NULL) as geom,
  61. </if>
  62. COALESCE (
  63. CASE
  64. WHEN bp.zs_unit = '平方米' THEN
  65. COALESCE ( bp.zs_area, 0 ) / 666.6666667
  66. WHEN bp.zs_unit = '公顷' THEN
  67. COALESCE ( bp.zs_area, 0 ) * 15
  68. WHEN bp.zs_unit = '亩' THEN
  69. COALESCE ( bp.zs_area, 0 ) * 1
  70. END,
  71. 0
  72. ) AS mj_mu
  73. FROM
  74. t_ydbp bp
  75. LEFT JOIN t_project pro ON bp.project_id = pro."id"
  76. WHERE
  77. pro.on_chain_num > 0
  78. AND bp.has_onchain = 't'
  79. <if test="year != null and year != '' ">
  80. AND left(bp.pf_date,4) = #{year}
  81. </if>
  82. <if test="keyWord != null and keyWord != ''">
  83. AND (
  84. COALESCE(pro.name, '') LIKE CONCAT('%', #{keyWord}, '%')
  85. OR COALESCE(pro.company, '') LIKE CONCAT('%', #{keyWord}, '%')
  86. )
  87. </if>
  88. </select>
  89. <!-- 更新语句 -->
  90. <update id="update" parameterType="com.siwei.apply.domain.vo.YdbpUpdateVo">
  91. UPDATE t_ydbp
  92. <set>
  93. <if test="projectId != null">project_id = #{projectId},</if>
  94. <if test="tdyt != null">tdyt = #{tdyt},</if>
  95. <if test="ydArea != null">yd_area = #{ydArea},</if>
  96. <if test="ydUnit != null">yd_unit = #{ydUnit},</if>
  97. <if test="zsArea != null">zs_area = #{zsArea},</if>
  98. <if test="zsUnit != null">zs_unit = #{zsUnit},</if>
  99. <if test="hasZz != null">has_zz = #{hasZz},</if>
  100. <if test="bpDate != null">bp_date = #{bpDate},</if>
  101. <if test="pfwh != null">pfwh = #{pfwh},</if>
  102. <if test="pfDate != null">pf_date = #{pfDate},</if>
  103. <if test="hasOnchain != null">has_onchain = #{hasOnchain},</if>
  104. updated_at = now()
  105. </set>
  106. WHERE id = #{id}
  107. </update>
  108. <update id="updateHasOnchain">
  109. UPDATE t_ydbp
  110. SET has_onchain = #{hasOnchain}, updated_at = now()
  111. WHERE id = #{id}
  112. </update>
  113. </mapper>