From 7e243d1b887bbc82d2d4c8075bf4c4a549e79f68 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期六, 19 十月 2024 11:58:42 +0800 Subject: [PATCH] 实现接口 获取指定时间内农户充值、消费、余额合计 --- pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java | 2 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java | 42 ++++++++++++++++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientMapper.java | 15 +++++++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml | 38 ++++++++++++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java | 22 +++++++++++ 5 files changed, 116 insertions(+), 3 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientMapper.java index 7f24819..a40d8d6 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeClientMapper.java @@ -4,6 +4,7 @@ import com.dy.pipIrrGlobal.pojoSe.SeClient; import com.dy.pipIrrGlobal.voSe.VoClient; import com.dy.pipIrrGlobal.voSe.VoClientWechat; +import com.dy.pipIrrGlobal.voSt.VoCardUsage; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -112,4 +113,18 @@ * @return */ VoClientWechat getSimpleClientInfo(@Param("sessionId") Long sessionId, @Param("openId") String openId); + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛啘鎴凤細鍏呭�煎悎璁°�佹秷璐瑰悎璁°�佷綑棰� + * @param params + * @return + */ + Long getClientUsagesCount(Map<String, Object> params); + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛啘鎴凤細鍏呭�煎悎璁°�佹秷璐瑰悎璁°�佷綑棰� + * @param params + * @return + */ + List<VoCardUsage> getClientUsages(Map<String, Object> params); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml index 65bb9e1..fefa9d6 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml @@ -475,5 +475,41 @@ </where> LIMIT 0,1 </select> - + <!--鑾峰彇鎸囧畾鏃堕棿娈靛啘鎴凤細鍏呭�煎悎璁°�佹秷璐瑰悎璁°�佷綑棰�--> + <select id="getClientUsagesCount" resultType="java.lang.Long"> + SELECT + count(*) + FROM se_client cli + <where> + <if test="clientName != null and clientName != ''"> + AND cli.name like CONCAT('%', #{clientName}, '%') + </if> + <if test="clientNum != null and clientNum != ''"> + AND cli.clientNum like CONCAT('%', #{clientNum}, '%') + </if> + </where> + </select> + <!--鑾峰彇鎸囧畾鏃堕棿娈靛啘鎴凤細鍏呭�煎悎璁°�佹秷璐瑰悎璁°�佷綑棰�--> + <select id="getClientUsages" resultType="com.dy.pipIrrGlobal.voSt.VoCardUsage"> + SELECT + cli.name AS clientName, + (SELECT ROUND(SUM(rch.amount),2) FROM se_recharge_history rch WHERE rch.clientId = cli.id AND rch.operateDt BETWEEN #{timeStart} AND #{timeStop}) AS totalRecharge, + (SELECT ROUND(SUM(his.cl_this_money),2) FROM rm_open_close_valve_history his WHERE his.client_id = cli.id AND his.cl_dt BETWEEN #{timeStart} AND #{timeStop}) AS totalConsumption, + (SELECT ROUND(SUM(card.money),2) FROM se_client_card card WHERE card.clientId = cli.id) AS balance + FROM se_client cli + <where> + <if test="clientName != null and clientName != ''"> + AND cli.name like CONCAT('%', #{clientName}, '%') + </if> + <if test="clientNum != null and clientNum != ''"> + AND cli.clientNum like CONCAT('%', #{clientNum}, '%') + </if> + </where> + ORDER BY totalConsumption DESC, totalRecharge DESC + <trim prefix="limit "> + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java index 375a1c8..f798af0 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/card/IcCardSv.java @@ -167,7 +167,7 @@ if (timeStart != null && timeStart != ""){ timeStart = timeStart + " 00:00:00"; }else { - timeStart = LocalDate.now() + " 00:00:00"; + timeStart = LocalDateTime.now().minusYears(1).toString(); } if (timeStop != null && timeStop != ""){ timeStop = timeStop + " 23:59:59"; 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 d485488..bd809b3 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 @@ -6,6 +6,7 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.voSt.*; import com.dy.pipIrrStatistics.card.IcCardqo.CommonQO; +import com.dy.pipIrrStatistics.card.qo.CardUsageQO; import com.dy.pipIrrStatistics.client.qo.*; import com.dy.pipIrrStatistics.intake.qo.ClientAmountQO; import com.dy.pipIrrStatistics.result.StatisticlResultCode; @@ -316,4 +317,25 @@ return BaseResponseUtils.buildException(e.getMessage()); } } + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛啘鎴凤細鍏呭�煎悎璁°�佹秷璐瑰悎璁°�佷綑棰� + * @param qo + //* @param bindingResult + * @return + */ + @GetMapping(path = "/client_usage") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoCardUsage>>> getClientUsages(@Valid CardUsageQO qo, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + try { + return BaseResponseUtils.buildSuccess(clientSv.getClientUsages(qo)); + } catch (Exception e) { + log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } } 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 334c320..5a61fcf 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 @@ -4,8 +4,10 @@ import com.dy.pipIrrGlobal.daoRm.RmClientAmountDayLastMapper; import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper; import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper; +import com.dy.pipIrrGlobal.daoSe.SeClientMapper; import com.dy.pipIrrGlobal.voSt.*; import com.dy.pipIrrStatistics.card.IcCardqo.CommonQO; +import com.dy.pipIrrStatistics.card.qo.CardUsageQO; import com.dy.pipIrrStatistics.client.qo.*; import com.dy.pipIrrStatistics.intake.qo.ClientAmountQO; import lombok.extern.slf4j.Slf4j; @@ -36,9 +38,10 @@ private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; @Autowired private SeCardOperateMapper seCardOperateMapper; - @Autowired private RmClientAmountDayLastMapper rmClientAmountDayLastMapper; + @Autowired + private SeClientMapper seClientMapper; /** * 鑾峰彇鎸囧畾鏃堕棿娈靛唴寮�闃�娆℃暟瓒呰繃鎸囧畾鍊肩殑鍐滄埛 @@ -520,4 +523,41 @@ rsVo.obj = rmClientAmountDayLastMapper.getNotRechargeLastClients(params); return rsVo ; } + + /** + * 鑾峰彇鎸囧畾鏃堕棿娈靛啘鎴凤細鍏呭�煎悎璁°�佹秷璐瑰悎璁°�佷綑棰� + * @param qo + * @return + */ + public QueryResultVo<List<VoCardUsage>> getClientUsages(CardUsageQO qo) { + + String timeStart = qo.getTimeStart(); + String timeStop = qo.getTimeStop(); + + if (timeStart != null && timeStart != ""){ + timeStart = timeStart + " 00:00:00"; + }else { + timeStart = LocalDateTime.now().minusYears(1).toString(); + } + if (timeStop != null && timeStop != ""){ + timeStop = timeStop + " 23:59:59"; + }else { + timeStop = LocalDateTime.now().toString(); + } + qo.setTimeStart(timeStart); + qo.setTimeStop(timeStop); + + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); + // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟 + Long itemTotal = Optional.ofNullable(seClientMapper.getClientUsagesCount(params)).orElse(0L); + + QueryResultVo<List<VoCardUsage>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = seClientMapper.getClientUsages(params); + return rsVo ; + } } -- Gitblit v1.8.0