123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.siwei.apply.mapper.ProjectMapper">
- <resultMap id="projectMap" type="com.siwei.apply.domain.Project">
- <id column="id" property="id"/>
- <result column="name" property="name"/>
- <result column="code" property="code"/>
- <result column="company" property="company"/>
- <result column="created_at" property="createAt"/>
- <result column="updated_at" property="updateAt"/>
- <result column="project_type" property="projectType"/>
- <result column="creator_id" property="creatorId"/>
- </resultMap>
- <insert id="add" parameterType="com.siwei.apply.domain.Project">
- INSERT INTO t_project (id, name, code, company,
- created_at, updated_at, project_type, creator_id)
- VALUES (#{id}, #{name}, #{code}, #{company}, now(), now(), #{projectType},
- #{creatorId})
- </insert>
- <select id="get" resultMap="projectMap">
- SELECT *
- FROM t_project
- where t_project.id = #{id}
- </select>
- <select id="getList" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="projectMap">
- SELECT *
- FROM t_project
- <where>
- <if test="name != null and name != ''">
- AND name LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="code != null and code != ''">
- AND code LIKE CONCAT('%', #{code}, '%')
- </if>
- <if test="keyWord != null and keyWord != ''">
- AND (
- name LIKE CONCAT('%', #{keyWord}, '%')
- OR company LIKE CONCAT('%', #{keyWord}, '%')
- )
- </if>
- <if test="projectType != null and projectType != 0">
- AND project_type = #{projectType}
- </if>
- </where>
- ORDER BY updated_at DESC
- LIMIT #{pageSize} offset #{offset}
- </select>
- <select id="getCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
- SELECT COUNT(*)
- FROM t_project
- <where>
- <if test="name != null and name != ''">
- AND name LIKE CONCAT('%', #{name}, '%')
- </if>
- <if test="code != null and code != ''">
- AND code LIKE CONCAT('%', #{code}, '%')
- </if>
- <if test="keyWord != null and keyWord != ''">
- AND (
- name LIKE CONCAT('%', #{keyWord}, '%')
- OR company LIKE CONCAT('%', #{keyWord}, '%')
- )
- </if>
- <if test="projectType != null and projectType != 0">
- AND project_type = #{projectType}
- </if>
- </where>
- </select>
- <update id="update" parameterType="com.siwei.apply.domain.vo.ProjectUpdateVo">
- UPDATE t_project
- <set>
- <if test="name != null">name = #{name},</if>
- <if test="code != null">code = #{code},</if>
- <if test="company != null">company = #{company},</if>
- <if test="projectType != null">project_type = #{projectType},</if>
- updated_at = now()
- </set>
- WHERE id = #{id}
- </update>
- <delete id="batchDelete">
- DELETE FROM t_project
- WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="getProjectTypeById" parameterType="string" resultType="int">
- SELECT project_type
- FROM t_project
- WHERE id = #{id}
- </select>
- <!-- 单一方法:一次返回 1/2 和总数的统计结果 -->
- <select id="countTypeStats" resultType="com.siwei.apply.domain.res.ProjectNumRes">
- SELECT
- SUM(CASE WHEN project_type = 1 THEN 1 ELSE 0 END) AS singleCount,
- SUM(CASE WHEN project_type = 2 THEN 1 ELSE 0 END) AS batchCount,
- COUNT(*) AS total
- FROM t_project
- </select>
- <select id="selectOtherSupply" resultType="com.siwei.apply.domain.res.ProjectSupplyRes">
- SELECT
- '其他' AS gdType,
- '亩' AS gdUnit,
- CAST(0 AS double precision) AS gdArea,
- CAST(0 AS int) AS count
- </select>
- <select id="selectOtherSupplyExcludeProject" resultType="com.siwei.apply.domain.res.ProjectSupplyRes">
- SELECT
- '其他' AS gdType,
- '亩' AS gdUnit,
- COALESCE(
- SUM(
- CASE
- WHEN gd_unit = '0' THEN COALESCE(gd_area, 0) / 666.6666667
- WHEN gd_unit = '1' THEN COALESCE(gd_area, 0) * 15
- ELSE COALESCE(gd_area, 0)
- END
- ), 0
- ) AS gdArea,
- COUNT(*) AS count
- FROM t_tdgy
- WHERE project_id IS NULL OR project_id = ''
- </select>
- <!-- 根据节点获取项目信息-->
- <select id="getProjectByNodeId" resultMap="projectMap">
- SELECT project.* FROM "public"."t_project" project
- LEFT JOIN "public"."t_project_workflow" flow
- on flow.project_id=project.id
- WHERE flow.node_id = #{nodeId} LIMIT 1
- </select>
- </mapper>
|