pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java
@@ -150,4 +150,46 @@ * @return */ List<VoClient> getSmallOpenCountClients(Map<String, Object> params); /** * 获取指定时间段内用水量超过指定值的农户数量 * @param params * @return */ Long getLargeWaterConsumptionClientsCount(Map<String, Object> params); /** * 获取指定时间段内用水量超过指定值的农户 * @param params * @return */ List<VoClient> getLargeWaterConsumptionClients(Map<String, Object> params); /** * 获取指定时间段内消费金额超过指定值的农户数量 * @param params * @return */ Long getLargeAmountSpentClientsCount(Map<String, Object> params); /** * 获取指定时间段内消费金额超过指定值的农户 * @param params * @return */ List<VoClient> getLargeAmountSpentClients(Map<String, Object> params); /** * 获取指定时间段内用水时长超过指定值的农户数量 * @param params * @return */ Long getLargeWaterDurationClientsCount(Map<String, Object> params); /** * 获取指定时间段内用水时长超过指定值的农户 * @param params * @return */ List<VoClient> getLargeWaterDurationClients(Map<String, Object> params); } pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -786,4 +786,90 @@ </if> </trim> </select> <!--获取指定时间段内用水量超过指定值的农户数量--> <select id="getLargeWaterConsumptionClientsCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM se_client cli INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop} AND his.cl_this_amount > #{waterConsumption} </select> <!--获取指定时间段内用水量超过指定值的农户--> <select id="getLargeWaterConsumptionClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> SELECT cli.id AS clientId, cli.name AS clientName, cli.clientNum, CONCAT(cli.districtTitle, cli.address) AS address, cli.phone, cli.idCard FROM se_client cli INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop} AND his.cl_this_amount > #{waterConsumption} ORDER BY cli.id <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="getLargeAmountSpentClientsCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM se_client cli INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop} AND his.cl_this_money > #{amountSpent} </select> <!--获取指定时间段内消费金额超过指定值的农户--> <select id="getLargeAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> SELECT cli.id AS clientId, cli.name AS clientName, cli.clientNum, CONCAT(cli.districtTitle, cli.address) AS address, cli.phone, cli.idCard FROM se_client cli INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop} AND his.cl_this_money > #{amountSpent} ORDER BY cli.id <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="getLargeWaterDurationClientsCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM se_client cli INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop} AND his.cl_this_time > #{waterDuration} </select> <!--获取指定时间段内用水时长超过指定值的农户--> <select id="getLargeWaterDurationClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> SELECT cli.id AS clientId, cli.name AS clientName, cli.clientNum, CONCAT(cli.districtTitle, cli.address) AS address, cli.phone, cli.idCard FROM se_client cli INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop} AND his.cl_this_time > #{waterDuration} ORDER BY cli.id <trim prefix="limit "> <if test="start != null and count != null"> #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} </if> </trim> </select> </mapper> pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
@@ -5,7 +5,10 @@ import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.voSt.VoClient; import com.dy.pipIrrStatistics.client.qo.AmountSpentQO; import com.dy.pipIrrStatistics.client.qo.OpenCountQO; import com.dy.pipIrrStatistics.client.qo.WaterConsumptionQO; import com.dy.pipIrrStatistics.client.qo.WaterDurationQO; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -71,4 +74,64 @@ return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 获取指定时间段内用水量超过指定值的农户 * @param qo * @param bindingResult * @return */ @GetMapping(path = "/getLargeWaterConsumptionClients") @SsoAop() public BaseResponse<QueryResultVo<List<VoClient>>> getLargeWaterConsumptionClients(@Valid WaterConsumptionQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(clientSv.getLargeWaterConsumptionClients(qo)); } catch (Exception e) { log.error("获取开卡记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 获取指定时间段内消费金额超过指定值的农户 * @param qo * @param bindingResult * @return */ @GetMapping(path = "/getLargeAmountSpentClients") @SsoAop() public BaseResponse<QueryResultVo<List<VoClient>>> getLargeAmountSpentClients(@Valid AmountSpentQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(clientSv.getLargeAmountSpentClients(qo)); } catch (Exception e) { log.error("获取开卡记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } /** * 获取指定时间段内用水时长超过指定值的农户 * @param qo * @param bindingResult * @return */ @GetMapping(path = "/getLargeWaterDurationClients") @SsoAop() public BaseResponse<QueryResultVo<List<VoClient>>> getLargeWaterDurationClients(@Valid WaterDurationQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(clientSv.getLargeWaterDurationClients(qo)); } catch (Exception e) { log.error("获取开卡记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
@@ -3,7 +3,10 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper; import com.dy.pipIrrGlobal.voSt.VoClient; import com.dy.pipIrrStatistics.client.qo.AmountSpentQO; import com.dy.pipIrrStatistics.client.qo.OpenCountQO; import com.dy.pipIrrStatistics.client.qo.WaterConsumptionQO; import com.dy.pipIrrStatistics.client.qo.WaterDurationQO; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -102,4 +105,118 @@ rsVo.obj = rmOpenCloseValveHistoryMapper.getSmallOpenCountClients(params); return rsVo ; } /** * 获取指定时间段内用水量超过指定值的农户 * @param qo * @return */ public QueryResultVo<List<VoClient>> getLargeWaterConsumptionClients(WaterConsumptionQO qo) { /** * 补齐起止时间,如果开始时间为空,则默认为当前日期 */ String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); if(timeStart != null) { timeStart = timeStart + " 00:00:00"; }else { timeStart = LocalDate.now() + " 00:00:00"; } if(timeStop != null) { timeStop = timeStop + " 23:59:59"; } qo.setTimeStart(timeStart); qo.setTimeStop(timeStop); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeWaterConsumptionClientsCount(params)).orElse(0L); QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeWaterConsumptionClients(params); return rsVo ; } /** * 获取指定时间段内消费金额超过指定值的农户 * @param qo * @return */ public QueryResultVo<List<VoClient>> getLargeAmountSpentClients(AmountSpentQO qo) { /** * 补齐起止时间,如果开始时间为空,则默认为当前日期 */ String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); if(timeStart != null) { timeStart = timeStart + " 00:00:00"; }else { timeStart = LocalDate.now() + " 00:00:00"; } if(timeStop != null) { timeStop = timeStop + " 23:59:59"; } qo.setTimeStart(timeStart); qo.setTimeStop(timeStop); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeAmountSpentClientsCount(params)).orElse(0L); QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeAmountSpentClients(params); return rsVo ; } /** * 获取指定时间段内用水时长超过指定值的农户 * @param qo * @return */ public QueryResultVo<List<VoClient>> getLargeWaterDurationClients(WaterDurationQO qo) { /** * 补齐起止时间,如果开始时间为空,则默认为当前日期 */ String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); if(timeStart != null) { timeStart = timeStart + " 00:00:00"; }else { timeStart = LocalDate.now() + " 00:00:00"; } if(timeStop != null) { timeStop = timeStop + " 23:59:59"; } qo.setTimeStart(timeStart); qo.setTimeStop(timeStop); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; // 获取符合条件的记录数 Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeWaterDurationClientsCount(params)).orElse(0L); QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeWaterDurationClients(params); return rsVo ; } } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/qo/AmountSpentQO.java
New file @@ -0,0 +1,22 @@ package com.dy.pipIrrStatistics.client.qo; import com.dy.pipIrrStatistics.intake.qo.CommonQO; import jakarta.validation.constraints.NotNull; import lombok.Data; /** * @author ZhuBaoMin * @date 2024-08-06 11:31 * @LastEditTime 2024-08-06 11:31 * @Description 消费金额查询对象 */ @Data public class AmountSpentQO extends CommonQO { /** * 消费金额 */ @NotNull(message = "消费金额不能为空") private Double amountSpent; } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/qo/WaterConsumptionQO.java
New file @@ -0,0 +1,22 @@ package com.dy.pipIrrStatistics.client.qo; import com.dy.pipIrrStatistics.intake.qo.CommonQO; import jakarta.validation.constraints.NotNull; import lombok.Data; /** * @author ZhuBaoMin * @date 2024-08-06 11:28 * @LastEditTime 2024-08-06 11:28 * @Description 用水量查询对象 */ @Data public class WaterConsumptionQO extends CommonQO { /** * 指定的用水量 */ @NotNull(message = "用水量不能为空") private Double waterConsumption; } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/qo/WaterDurationQO.java
New file @@ -0,0 +1,22 @@ package com.dy.pipIrrStatistics.client.qo; import com.dy.pipIrrStatistics.intake.qo.CommonQO; import jakarta.validation.constraints.NotNull; import lombok.Data; /** * @author ZhuBaoMin * @date 2024-08-06 11:33 * @LastEditTime 2024-08-06 11:33 * @Description 用水时长查询对象 */ @Data public class WaterDurationQO extends CommonQO { /** * 用水时长 */ @NotNull(message = "用水时长不能为空") private Integer waterDuration; }