pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSt/StClientAmountYearMapper.java
@@ -2,6 +2,7 @@ import com.dy.pipIrrGlobal.pojoSt.StClientAmountYear; import com.dy.pipIrrGlobal.voSt.VoStClientAmountYearRecord; import com.dy.pipIrrGlobal.voSt.VoStClientIdAmountYearRecord; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -73,11 +74,15 @@ * @return */ Long selectCountYearStatistics(Map<?, ?> params) ; Long selectCountYearStatistics4OneYear(Map<?, ?> params) ; List<VoStClientIdAmountYearRecord> selectClientIds4YearStatistics(Map<?, ?> params) ; /** * 查询分页数据 * @param params * @return */ List<VoStClientAmountYearRecord> selectYearStatistics4OneYear(Map<?, ?> params) ; List<VoStClientAmountYearRecord> selectYearStatistics(Map<?, ?> params) ; ////////////////////////////////////// pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSt/VoStClientIdAmountYearRecord.java
New file @@ -0,0 +1,17 @@ package com.dy.pipIrrGlobal.voSt; import lombok.Data; /** * @Author: liurunyu * @Date: 2025/1/6 9:38 * @Description */ @Data public class VoStClientIdAmountYearRecord { /** * 农户ID */ public Long clientId; } pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountYearMapper.xml
@@ -125,6 +125,63 @@ </if> </trim> </select> <select id="selectCountYearStatistics4OneYear" resultType="java.lang.Long"> select count(*) from se_client ctb INNER JOIN st_client_amount_year cayTb on cayTb.client_id = ctb.id where ctb.deleted != 1 <trim prefix="and" suffixOverrides="and"> <if test="year != null"> cayTb.`year` = #{year,jdbcType=INTEGER} </if> <if test="name != null and name != ''"> and ctb.name like concat('%', #{name}, '%') </if> </trim> </select> <select id="selectClientIds4YearStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientIdAmountYearRecord"> select mtb.id as clientId from se_client mtb where mtb.deleted != 1 <trim prefix="and" suffixOverrides="and"> <if test="name != null and name != ''"> mtb.name like concat('%', #{name}, '%') </if> </trim> order by mtb.id ASC </select> <select id="selectYearStatistics4OneYear" resultType="com.dy.pipIrrGlobal.voSt.VoStClientAmountYearRecord"> select ctb.id as clientId, ctb.clientNum as clientNum, ctb.name as clientName, ctb.address as clientAddress, cayTb.amount as amount, cayTb.money as money, cayTb.times as times from se_client ctb INNER JOIN st_client_amount_year cayTb on cayTb.client_id = ctb.id where ctb.deleted != 1 <trim prefix="and" suffixOverrides="and"> <if test="year != null"> cayTb.`year` = #{year,jdbcType=INTEGER} </if> <if test="name != null and name != ''"> and ctb.name like concat('%', #{clientName}, '%') </if> </trim> order by ctb.id 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="selectYearStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientAmountYearRecord"> select @@ -136,14 +193,23 @@ cayTb.money as money, cayTb.times as times from se_client ctb LEFT JOIN st_client_amount_year cayTb on cayTb.client_id = ctb.id <if test="clientIdsJson != null and clientIdsJson !=''"> INNER JOIN JSON_TABLE( <!--'[{"clientId":"37142501020100215"},{"clientId":"37142501020100215"}]'--> #{clientIdsJson}, '$[*]' COLUMNS ( clientId BIGINT PATH '$.clientId' ) ) clientIdTb ON clientIdTb.clientId = ctb.id </if> LEFT JOIN st_client_amount_year cayTb on cayTb.client_id = clientIdTb.clientId where ctb.deleted != 1 <trim prefix="and" suffixOverrides="and"> <if test="year != null"> cayTb.`year` = #{year,jdbcType=INTEGER} </if> <if test="name != null and name != ''"> and ctb.name like concat('%', #{name}, '%') and ctb.name like concat('%', #{clientName}, '%') </if> </trim> order by ctb.id DESC pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/stClient/StClientQo.java
@@ -28,7 +28,7 @@ public Integer month; /** * 取水口编号 * 农户姓名 */ public String clientName; public String name; } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/stClient/StClientSv.java
@@ -1,5 +1,6 @@ package com.dy.pipIrrStatistics.stClient; import com.alibaba.fastjson2.JSON; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoSt.StClientAmountDayMapper ; import com.dy.pipIrrGlobal.daoSt.StClientAmountMonthMapper ; @@ -100,10 +101,19 @@ rsVo.yearGrp = yearGrp ; rsQrVo.obj = rsVo ; boolean oneYear = yearGrp.size() == 1? true : false ; // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = stClientAmountYearDao.selectCountYearStatistics(params) ; Long itemTotal = 0L ; String clientIdsJson = null ; if(oneYear){ itemTotal = stClientAmountYearDao.selectCountYearStatistics4OneYear(params) ; }else{ itemTotal = stClientAmountYearDao.selectCountYearStatistics(params) ; List<VoStClientIdAmountYearRecord> clientIds = stClientAmountYearDao.selectClientIds4YearStatistics(params); clientIdsJson = JSON.toJSONString(clientIds) ; } if(itemTotal != null && itemTotal > 0) { rsQrVo.pageSize = qo.pageSize; @@ -114,7 +124,16 @@ int count = 1 ; for(int year: yearGrp){ params.put("year", year); List<VoStClientAmountYearRecord> list = stClientAmountYearDao.selectYearStatistics(params); List<VoStClientAmountYearRecord> list ; if(oneYear){ list = stClientAmountYearDao.selectYearStatistics4OneYear(params); }else{ if(clientIdsJson != null){ params.put("clientIdsJson", clientIdsJson); } list = stClientAmountYearDao.selectYearStatistics(params); } if(group.isEmpty()){ this.completion(group, list); }