2024-08-06 朱宝民 获取指定时间段内开阀次数低于指定值的农户
| | |
| | | * @return |
| | | */ |
| | | List<VoClient> getLargeOpenCountClients(Map<String, Object> params); |
| | | |
| | | /** |
| | | * 获取指定时间段内开阀次数低于指定值的农户数量 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getSmallOpenCountClientsCount(Map<String, Object> params); |
| | | |
| | | /** |
| | | * 获取指定时间段内开阀次数低于指定值的农户 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoClient> getSmallOpenCountClients(Map<String, Object> params); |
| | | } |
| | |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | |
| | | <!--获取指定时间段内开阀次数低于指定值的农户数量--> |
| | | <select id="getSmallOpenCountClientsCount" resultType="java.lang.Long"> |
| | | SELECT COUNT(*) AS recordCount |
| | | FROM se_client cli |
| | | WHERE (SELECT COUNT(*) |
| | | FROM rm_open_close_valve_history his |
| | | WHERE his.client_id = cli.id |
| | | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{openCount} |
| | | </select> |
| | | |
| | | <!--获取指定时间段内开阀次数低于指定值的农户--> |
| | | <select id="getSmallOpenCountClients" 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 |
| | | WHERE (SELECT COUNT(*) |
| | | FROM rm_open_close_valve_history his |
| | | WHERE his.client_id = cli.id |
| | | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{openCount} |
| | | 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> |
| | |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取指定时间段内开阀次数低于指定值的农户 |
| | | * @param qo |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getSmallOpenCountClients") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoClient>>> getSmallOpenCountClients(@Valid OpenCountQO qo, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(clientSv.getSmallOpenCountClients(qo)); |
| | | } catch (Exception e) { |
| | | log.error("获取开卡记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | } |
| | |
| | | rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeOpenCountClients(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 获取指定时间段内开阀次数低于指定值的农户 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoClient>> getSmallOpenCountClients(OpenCountQO 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.getSmallOpenCountClientsCount(params)).orElse(0L); |
| | | |
| | | QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; |
| | | |
| | | rsVo.pageSize = qo.pageSize ; |
| | | rsVo.pageCurr = qo.pageCurr ; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = rmOpenCloseValveHistoryMapper.getSmallOpenCountClients(params); |
| | | return rsVo ; |
| | | } |
| | | } |