From d24d060892415caeeead78c9dddd45ab3d81e3c7 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期五, 11 十月 2024 14:25:36 +0800 Subject: [PATCH] 实现接口 指定时间段内用水量低于指定值的农户 指定时间段内消费金额低于指定值的农户 指定时间段内用水时长低于指定值的农户 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml | 143 +++++++++++++++++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java | 108 ++++++++++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java | 42 +++++++ pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java | 60 ++++++++++ 4 files changed, 353 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java index 21ec5bd..c08d6a2 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java @@ -168,6 +168,20 @@ List<VoClient> getLargeWaterConsumptionClients(Map<String, Object> params); /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忎綆浜庢寚瀹氬�肩殑鍐滄埛鏁伴噺 + * @param params + * @return + */ + Long getSmallWaterConsumptionClientsCount(Map<String, Object> params); + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忎綆浜庢寚瀹氬�肩殑鍐滄埛 + * @param params + * @return + */ + List<VoClient> getSmallWaterConsumptionClients(Map<String, Object> params); + + /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍐滄埛鏁伴噺 * @param params * @return @@ -182,6 +196,20 @@ List<VoClient> getLargeAmountSpentClients(Map<String, Object> params); /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦浣庝簬鎸囧畾鍊肩殑鍐滄埛鏁伴噺 + * @param params + * @return + */ + Long getSmallAmountSpentClientsCount(Map<String, Object> params); + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦浣庝簬鎸囧畾鍊肩殑鍐滄埛 + * @param params + * @return + */ + List<VoClient> getSmallAmountSpentClients(Map<String, Object> params); + + /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍐滄埛鏁伴噺 * @param params * @return @@ -196,6 +224,20 @@ List<VoClient> getLargeWaterDurationClients(Map<String, Object> params); /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱浣庝簬鎸囧畾鍊肩殑鍐滄埛鏁伴噺 + * @param params + * @return + */ + Long getSmallWaterDurationClientsCount(Map<String, Object> params); + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱浣庝簬鎸囧畾鍊肩殑鍐滄埛 + * @param params + * @return + */ + List<VoClient> getSmallWaterDurationClients(Map<String, Object> params); + + /** * 鎸囧畾鏃堕棿娈电敤姘撮噺瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙f暟閲� * @param params * @return diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml index 453e6e3..461c803 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml @@ -781,6 +781,54 @@ </trim> </select> + <!--鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忎綆浜庢寚瀹氬�肩殑鍐滄埛鏁伴噺--> + <select id="getSmallWaterConsumptionClientsCount" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client cli + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterConsumption != null"> + (SELECT SUM(his.cl_this_amount) + FROM rm_open_close_valve_history his + WHERE his.client_id = cli.id + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{waterConsumption} + </if> + </where> + </select> + + <!--鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忎綆浜庢寚瀹氬�肩殑鍐滄埛--> + <select id="getSmallWaterConsumptionClients" 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, + IFNULL((SELECT SUM(his.cl_this_amount) + FROM rm_open_close_valve_history his + <where> + his.client_id = cli.id + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + ),0) AS waterConsumption + FROM se_client cli + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterConsumption != null"> + (SELECT SUM(his.cl_this_amount) + FROM rm_open_close_valve_history his + WHERE his.client_id = cli.id + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{waterConsumption} + </if> + </where> + 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 @@ -818,6 +866,53 @@ FROM rm_open_close_valve_history his WHERE his.client_id = cli.id AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{amountSpent} + </if> + </where> + 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="getSmallAmountSpentClientsCount" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client cli + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and amountSpent != null"> + (SELECT SUM(his.cl_this_money) + FROM rm_open_close_valve_history his + WHERE his.client_id = cli.id + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{amountSpent} + </if> + </where> + </select> + <!--鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦浣庝簬鎸囧畾鍊肩殑鍐滄埛--> + <select id="getSmallAmountSpentClients" 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, + IFNULL((SELECT SUM(his.cl_this_money) + FROM rm_open_close_valve_history his + <where> + his.client_id = cli.id + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + ),0) AS amountSpent + FROM se_client cli + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and amountSpent != null"> + (SELECT SUM(his.cl_this_money) + FROM rm_open_close_valve_history his + WHERE his.client_id = cli.id + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{amountSpent} </if> </where> ORDER BY cli.id @@ -875,6 +970,54 @@ </if> </trim> </select> + + <!--鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱浣庝簬鎸囧畾鍊肩殑鍐滄埛鏁伴噺--> + <select id="getSmallWaterDurationClientsCount" resultType="java.lang.Long"> + SELECT COUNT(*) AS recordCount + FROM se_client cli + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterDuration != null"> + (SELECT SUM(his.cl_this_time) + FROM rm_open_close_valve_history his + WHERE his.client_id = cli.id + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{waterDuration} + </if> + </where> + </select> + + <!--鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱浣庝簬鎸囧畾鍊肩殑鍐滄埛--> + <select id="getSmallWaterDurationClients" 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, + IFNULL((SELECT SUM(his.cl_this_time) + FROM rm_open_close_valve_history his + <where> + his.client_id = cli.id + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + ),0) AS waterDuration + FROM se_client cli + <where> + <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and waterDuration != null"> + (SELECT SUM(his.cl_this_time) + FROM rm_open_close_valve_history his + WHERE his.client_id = cli.id + AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{waterDuration} + </if> + </where> + 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> <!--鎸囧畾鏃堕棿娈电敤姘撮噺瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙f暟閲�--> <select id="getUseWaterGtValueIntakesCount" resultType="java.lang.Long"> select diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java index 2d43649..7675944 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java @@ -96,6 +96,26 @@ } /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忎綆浜庢寚瀹氬�肩殑鍐滄埛 + * @param qo + * @param bindingResult + * @return + */ + @GetMapping(path = "/getSmallWaterConsumptionClients") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoClient>>> getSmallWaterConsumptionClients(@Valid WaterConsumptionQO qo, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + try { + return BaseResponseUtils.buildSuccess(clientSv.getSmallWaterConsumptionClients(qo)); + } catch (Exception e) { + log.error("鑾峰彇璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍐滄埛 * @param qo * @param bindingResult @@ -116,6 +136,26 @@ } /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦浣庝簬鎸囧畾鍊肩殑鍐滄埛 + * @param qo + * @param bindingResult + * @return + */ + @GetMapping(path = "/getSmallAmountSpentClients") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoClient>>> getSmallAmountSpentClients(@Valid AmountSpentQO qo, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + try { + return BaseResponseUtils.buildSuccess(clientSv.getSmallAmountSpentClients(qo)); + } catch (Exception e) { + log.error("鑾峰彇璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍐滄埛 * @param qo * @param bindingResult @@ -136,6 +176,26 @@ } /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱浣庝簬鎸囧畾鍊肩殑鍐滄埛 + * @param qo + * @param bindingResult + * @return + */ + @GetMapping(path = "/getSmallWaterDurationClients") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoClient>>> getSmallWaterDurationClients(@Valid WaterDurationQO qo, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + try { + return BaseResponseUtils.buildSuccess(clientSv.getSmallWaterDurationClients(qo)); + } catch (Exception e) { + log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** * 缁熻鎸囧畾鏈堜唤鍚勫啘鎴峰悇澶╃敤姘撮噺鍙婃秷璐归噾棰� * @param qo * @return diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java index 999d976..1e5b1ad 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java @@ -149,6 +149,42 @@ } /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忎綆浜庢寚瀹氬�肩殑鍐滄埛 + * @param qo + * @return + */ + public QueryResultVo<List<VoClient>> getSmallWaterConsumptionClients(WaterConsumptionQO qo) { + /** + * 琛ラ綈璧锋鏃堕棿 + */ + String timeStart = qo.getTimeStart(); + String timeStop = qo.getTimeStop(); + if(timeStart != null && timeStart != "") { + timeStart = timeStart + " 00:00:00"; + } + if(timeStop != null && timeStop != "") { + 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.getSmallWaterConsumptionClientsCount(params)).orElse(0L); + + QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmOpenCloseValveHistoryMapper.getSmallWaterConsumptionClients(params); + return rsVo ; + } + + /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍐滄埛 * @param qo * @return @@ -185,6 +221,42 @@ } /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦浣庝簬鎸囧畾鍊肩殑鍐滄埛 + * @param qo + * @return + */ + public QueryResultVo<List<VoClient>> getSmallAmountSpentClients(AmountSpentQO qo) { + /** + * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡 + */ + String timeStart = qo.getTimeStart(); + String timeStop = qo.getTimeStop(); + if(timeStart != null && timeStart != "") { + timeStart = timeStart + " 00:00:00"; + } + if(timeStop != null && timeStop != "") { + 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.getSmallAmountSpentClientsCount(params)).orElse(0L); + + QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmOpenCloseValveHistoryMapper.getSmallAmountSpentClients(params); + return rsVo ; + } + + /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍐滄埛 * @param qo * @return @@ -221,6 +293,42 @@ } /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱浣庝簬鎸囧畾鍊肩殑鍐滄埛 + * @param qo + * @return + */ + public QueryResultVo<List<VoClient>> getSmallWaterDurationClients(WaterDurationQO qo) { + /** + * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡 + */ + String timeStart = qo.getTimeStart(); + String timeStop = qo.getTimeStop(); + if(timeStart != null && timeStart != "") { + timeStart = timeStart + " 00:00:00"; + } + if(timeStop != null && timeStop != "") { + 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.getSmallWaterDurationClientsCount(params)).orElse(0L); + + QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmOpenCloseValveHistoryMapper.getSmallWaterDurationClients(params); + return rsVo ; + } + + /** * 鎸囧畾鏃堕棿娈靛唴寮�鐗╃悊鍗″啘鎴� * @param qo * @return -- Gitblit v1.8.0