From 34e795bedc57454c43b00cdf8e2cc2d9eb5a932a Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期五, 11 四月 2025 14:59:50 +0800 Subject: [PATCH] 优化轮灌组分页查询接口 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml | 465 +++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 298 insertions(+), 167 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml index ae93ff0..34efe21 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml @@ -1,176 +1,307 @@ <?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.dy.pipIrrGlobal.daoIr.IrIrrigateGroupMapper"> - <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> - <!--@mbg.generated--> - <!--@Table ir_irrigate_group--> - <id column="id" jdbcType="BIGINT" property="id" /> - <result column="project_id" jdbcType="BIGINT" property="projectId" /> - <result column="group_code" jdbcType="VARCHAR" property="groupCode" /> - <result column="remarks" jdbcType="VARCHAR" property="remarks" /> - <result column="operator" jdbcType="BIGINT" property="operator" /> - <result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" /> - <result column="deleted" jdbcType="TINYINT" property="deleted" /> - </resultMap> - <sql id="Base_Column_List"> - <!--@mbg.generated--> - id, project_id, group_code, remarks, `operator`, - operate_time, deleted - </sql> - <!--娣诲姞--> - <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> - <!--@mbg.generated--> - insert into ir_irrigate_group - <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null"> - id, - </if> - <if test="projectId != null"> - project_id, - </if> - <if test="groupCode != null"> - group_code, - </if> - <if test="remarks != null"> - remarks, - </if> - <if test="operator != null"> - `operator`, - </if> - <if test="operateDt != null"> - operate_time, - </if> - <if test="deleted != null"> - deleted, - </if> - </trim> - <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="id != null"> - #{id,jdbcType=BIGINT}, - </if> - <if test="projectId != null"> - #{projectId,jdbcType=BIGINT}, - </if> - <if test="groupCode != null"> - #{groupCode,jdbcType=VARCHAR}, - </if> - <if test="remarks != null"> - #{remarks,jdbcType=VARCHAR}, - </if> - <if test="operator != null"> - #{operator,jdbcType=BIGINT}, - </if> - <if test="operateDt != null"> - #{operateDt,jdbcType=TIMESTAMP}, - </if> - <if test="deleted != null"> - #{deleted,jdbcType=TINYINT}, - </if> - </trim> - </insert> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> + <!--@mbg.generated--> + <!--@Table ir_irrigate_group--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="group_code" jdbcType="VARCHAR" property="groupCode" /> + <result column="default_duration" jdbcType="INTEGER" property="defaultDuration" /> + <result column="remarks" jdbcType="VARCHAR" property="remarks" /> + <result column="operator" jdbcType="BIGINT" property="operator" /> + <result column="operate_time" jdbcType="TIMESTAMP" property="operateTime" /> + <result column="deleted" jdbcType="TINYINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, group_code, default_duration, remarks, `operator`, operate_time, deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from ir_irrigate_group + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from ir_irrigate_group + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> + <!--@mbg.generated--> + insert into ir_irrigate_group (id, group_code, default_duration, + remarks, `operator`, operate_time, + deleted) + values (#{id,jdbcType=BIGINT}, #{groupCode,jdbcType=VARCHAR}, #{defaultDuration,jdbcType=INTEGER}, + #{remarks,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{operateTime,jdbcType=TIMESTAMP}, + #{deleted,jdbcType=TINYINT}) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> + <!--@mbg.generated--> + insert into ir_irrigate_group + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="groupCode != null"> + group_code, + </if> + <if test="defaultDuration != null"> + default_duration, + </if> + <if test="remarks != null"> + remarks, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operateTime != null"> + operate_time, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="groupCode != null"> + #{groupCode,jdbcType=VARCHAR}, + </if> + <if test="defaultDuration != null"> + #{defaultDuration,jdbcType=INTEGER}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operateTime != null"> + #{operateTime,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> + <!--@mbg.generated--> + update ir_irrigate_group + <set> + <if test="groupCode != null"> + group_code = #{groupCode,jdbcType=VARCHAR}, + </if> + <if test="defaultDuration != null"> + default_duration = #{defaultDuration,jdbcType=INTEGER}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operateTime != null"> + operate_time = #{operateTime,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> + <!--@mbg.generated--> + update ir_irrigate_group + set group_code = #{groupCode,jdbcType=VARCHAR}, + default_duration = #{defaultDuration,jdbcType=INTEGER}, + remarks = #{remarks,jdbcType=VARCHAR}, + `operator` = #{operator,jdbcType=BIGINT}, + operate_time = #{operateTime,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> - <!--閫昏緫鍒犻櫎--> - <delete id="deleteLogicById" parameterType="java.lang.Long"> - <!--@mbg.generated--> - update ir_irrigate_group - set deleted = 1 - where id = #{id,jdbcType=BIGINT} - </delete> + <!--閫昏緫鍒犻櫎--> + <delete id="deleteLogicById" parameterType="java.lang.Long"> + <!--@mbg.generated--> + update ir_irrigate_group + set deleted = 1 + where id = #{id,jdbcType=BIGINT} + </delete> - <!--淇敼涓�涓疆缃愮粍--> - <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> - update ir_irrigate_group - <set> - <if test="projectId != null"> - project_id = #{projectId,jdbcType=BIGINT}, - </if> - <if test="groupCode != null"> - group_code = #{groupCode,jdbcType=VARCHAR}, - </if> - <if test="remarks != null"> - remarks = #{remarks,jdbcType=VARCHAR}, - </if> - <if test="operator != null"> - operator = #{operator,jdbcType=BIGINT}, - </if> - <if test="operateDt != null"> - operate_time = #{operateDt,jdbcType=TIMESTAMP}, - </if> - <if test="deleted != null"> - deleted = #{deleted,jdbcType=TINYINT}, - </if> - </set> - where id = #{id,jdbcType=BIGINT} - </update> + <!--淇敼涓�涓疆缃愮粍--> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup"> + update ir_irrigate_group + <set> + <if test="groupCode != null"> + group_code = #{groupCode,jdbcType=VARCHAR}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + operator = #{operator,jdbcType=BIGINT}, + </if> + <if test="operateTime != null"> + operate_time = #{operateTime,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> - <!--鏌ヤ竴涓疆缃愮粍--> - <select id="selectById" resultType="com.dy.pipIrrGlobal.voIr.VoGroupOne"> - select - CAST(pro.id AS char)AS projectId, - pro.project_name AS projectName, - CAST(gro.id AS char)AS id, - CAST(gro.operator AS char)AS operator, - cli.name AS operatorName, - gro.group_code AS groupCode, - COUNT(gu.group_id) AS itemCount, - gro.remarks, - gro.operate_time AS operateDt - from ir_irrigate_group gro - left join ir_project pro on pro.id = gro.project_id - left join se_client cli on cli.id = gro.operator - left join ir_group_unit gu on gu.group_id = gro.id - where gro.id = #{id,jdbcType=BIGINT} and gro.deleted = 0 and pro.deleted != 1 - </select> + <!--鏌ヤ竴涓疆缃愮粍--> + <select id="selectById" resultType="com.dy.pipIrrGlobal.voIr.VoGroupOne"> + select + CAST(pro.id AS char)AS projectId, + pro.project_name AS projectName, + CAST(gro.id AS char)AS id, + CAST(gro.operator AS char)AS operator, + cli.name AS operatorName, + gro.group_code AS groupCode, + COUNT(gu.group_id) AS itemCount, + gro.remarks, + gro.operate_time AS operateDt + from ir_irrigate_group gro + left join ir_project pro on pro.id = gro.project_id + left join se_client cli on cli.id = gro.operator + left join ir_group_unit gu on gu.group_id = gro.id + where gro.id = #{id,jdbcType=BIGINT} and gro.deleted = 0 and pro.deleted != 1 + </select> - <!--鍒嗛〉鏌ヨ疆鐏岀粍--> - <select id="getIrrigateGroups" resultType="com.dy.pipIrrGlobal.voIr.VoGroup"> + <!--鍒嗛〉鏌ヨ疆鐏岀粍--> + <select id="getIrrigateGroups" resultType="com.dy.pipIrrGlobal.voIr.VoGroup"> + SELECT + CAST(pro.id AS char)AS projectId, + pro.project_name AS projectName, + CAST(gro.id AS char)AS id, + CAST(gro.operator AS char)AS operator, + cli.name AS operatorName, + gro.group_code AS groupCode, + COUNT(gu.group_id) AS itemCount, + gro.remarks, + gro.operate_time AS operateDt + from ir_irrigate_group gro + left join ir_project pro on pro.id = gro.project_id + left join se_client cli on cli.id = gro.operator + left join ir_group_unit gu on gu.group_id = gro.id + <where> + gro.deleted = 0 and pro.deleted != 1 + <if test="projectName != null and projectName != ''"> + AND pro.project_name LIKE CONCAT('%', #{projectName}, '%') + </if> + <if test="groupCode != null and groupCode != ''"> + AND gro.group_code = #{groupCode} + </if> + </where> + GROUP BY gro.id + ORDER BY gro.operate_time DESC + <if test="pageCurr != null and pageSize != null"> + LIMIT ${(pageCurr-1)*pageSize}, ${pageSize} + </if> + </select> + <!--鍒嗛〉鏌ヨ疆鐏岀粍璁板綍鏁�--> + <select id="getRecordCount" resultType="java.lang.Long"> + SELECT COUNT(*) FROM( + SELECT COUNT(*),gro.id AS recordCount + from ir_irrigate_group gro + left join ir_project pro on pro.id = gro.project_id + left join se_client cli on cli.id = gro.operator + left join ir_group_unit gu on gu.group_id = gro.id + <where> + gro.deleted = 0 and pro.deleted != 1 + <if test="projectName != null and projectName != ''"> + AND pro.project_name LIKE CONCAT('%', #{projectName}, '%') + </if> + <if test="groupCode != null and groupCode != ''"> + AND gro.group_code = #{groupCode} + </if> + </where> + GROUP BY gro.id + ) a + </select> + + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇杞亴缁勮褰曟暟--> + <select id="getSimpleGroupCount" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM ir_irrigate_group grp + <where> + AND grp.deleted = 0 + <if test="projectId != null"> + AND pg.project_id = #{projectId} + </if> + <if test="groupCode != null and groupCode != ''"> + AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%') + </if> + </where> + </select> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇杞亴缁勫垪琛�--> + <select id="getSimpleGroups" resultType="com.dy.pipIrrGlobal.voIr.VoGroupSimple"> + SELECT + grp.id AS groupId, + grp.group_code AS groupCode, + (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount, + grp.default_duration AS defaultDuration, + 0 as sort + FROM ir_irrigate_group grp + <where> + AND grp.deleted = 0 + + <if test="projectId != null"> + AND pg.project_id = #{projectId} + </if> + + <if test="groupCode != null and groupCode != ''"> + AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%') + </if> + </where> + ORDER BY grp.operate_time DESC + <trim prefix="limit "> + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + </select> + + <select id="getGroupDetail" resultType="com.dy.pipIrrGlobal.voIr.VoGroupDetail"> + SELECT + groupCode, + defaultDuration, + GROUP_CONCAT(intakeId) AS intakes + FROM + ( SELECT - CAST(pro.id AS char)AS projectId, - pro.project_name AS projectName, - CAST(gro.id AS char)AS id, - CAST(gro.operator AS char)AS operator, - cli.name AS operatorName, - gro.group_code AS groupCode, - COUNT(gu.group_id) AS itemCount, - gro.remarks, - gro.operate_time AS operateDt - from ir_irrigate_group gro - left join ir_project pro on pro.id = gro.project_id - left join se_client cli on cli.id = gro.operator - left join ir_group_unit gu on gu.group_id = gro.id - <where> - gro.deleted = 0 and pro.deleted != 1 - <if test="projectName != null and projectName != ''"> - AND pro.project_name LIKE CONCAT('%', #{projectName}, '%') - </if> - <if test="groupCode != null and groupCode != ''"> - AND gro.group_code = #{groupCode} - </if> - </where> - GROUP BY gro.id - ORDER BY gro.operate_time DESC - <if test="pageCurr != null and pageSize != null"> - LIMIT ${(pageCurr-1)*pageSize}, ${pageSize} - </if> - </select> - <!--鍒嗛〉鏌ヨ疆鐏岀粍璁板綍鏁�--> - <select id="getRecordCount" resultType="java.lang.Long"> - SELECT COUNT(*) FROM( - SELECT COUNT(*),gro.id AS recordCount - from ir_irrigate_group gro - left join ir_project pro on pro.id = gro.project_id - left join se_client cli on cli.id = gro.operator - left join ir_group_unit gu on gu.group_id = gro.id - <where> - gro.deleted = 0 and pro.deleted != 1 - <if test="projectName != null and projectName != ''"> - AND pro.project_name LIKE CONCAT('%', #{projectName}, '%') - </if> - <if test="groupCode != null and groupCode != ''"> - AND gro.group_code = #{groupCode} - </if> - </where> - GROUP BY gro.id - ) a - </select> + grp.group_code AS groupCode, + grp.default_duration AS defaultDuration, + inta.id AS intakeId + FROM ir_irrigate_group grp + INNER JOIN ir_group_intake gi ON gi.group_id = grp.id + INNER JOIN pr_intake inta ON inta.id = gi.intake_id + WHERE grp.deleted = 0 AND grp.id = #{groupId} + ) irrigateGroup + GROUP BY groupCode,defaultDuration + </select> + + <select id="getGroupResult" resultType="com.dy.pipIrrGlobal.voIr.VoGroupResult"> + SELECT + grp.id AS groupId, + grp.group_code AS groupCode, + IF(NOW() < sche.start_time, 2, + IF(NOW() > sche.start_time AND NOW() < DATE_ADD(sche.start_time, INTERVAL sche.duration MINUTE), 3, 4)) AS state, + sche.start_time AS startTime, + DATE_ADD(sche.start_time, INTERVAL sche.duration MINUTE) AS stopTime, + sche.duration, + NULL AS publishResult + FROM ir_irrigate_group grp + INNER JOIN ir_irrigate_schedule sche ON sche.group_id = grp.id + INNER JOIN ir_plan_schedule ps ON ps.schedule_id = sche.id + WHERE ps.plan_id = #{planId}; + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0