Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmClientAmountDayLast; |
| | | import com.dy.pipIrrGlobal.voRm.VoClientAmountDay; |
| | | import com.dy.pipIrrGlobal.voSt.VoClient; |
| | | import com.dy.pipIrrGlobal.voSt.VoDayClient; |
| | | import com.dy.pipIrrGlobal.voSt.VoMonthClient; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | * @return |
| | | */ |
| | | List<VoMonthClient> getMonthAmountAndMoney(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 最近未充值的农户数量 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getNotRechargeLastClientsCount(Map<String, Object> params); |
| | | |
| | | /** |
| | | * 最近未充值的农户 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoClient> getNotRechargeLastClients(Map<String, Object> params); |
| | | } |
| | |
| | | package com.dy.pipIrrGlobal.voRm; |
| | | |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | */ |
| | | |
| | | @Data |
| | | @JsonPropertyOrder({"intakeNum", "isOnLine", "rtuAddr", "vcNum", "orderNo", "state", "planned"}) |
| | | public class VoUnclosedValve implements BaseEntity { |
| | | private static final long serialVersionUID = 202405241634001L; |
| | | |
| | | //private String commandCode; |
| | | |
| | | /** |
| | | * 取水口编号 |
| | | */ |
| | | private String intakeNum; |
| | | |
| | | /** |
| | | * 是否在线 |
| | | */ |
| | | private Boolean isOnLine; |
| | | |
| | | /** |
| | | * 阀控器地址 |
| | | */ |
| | | private String rtuAddr; |
| | | |
| | | /** |
| | | * 虚拟卡编号 |
| | | */ |
| | | private String vcNum; |
| | | |
| | | /** |
| | | * 订单号 |
| | | */ |
| | | private String orderNo; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | private String state; |
| | | |
| | | /** |
| | | * 是否计划性开阀 |
| | | */ |
| | | private Boolean planned; |
| | | |
| | | //private Date openTime; |
| | | } |
| | |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | <!--最近未充值的农户数量--> |
| | | <select id="getNotRechargeLastClientsCount" resultType="java.lang.Long"> |
| | | SELECT COUNT(*) |
| | | FROM |
| | | ( SELECT |
| | | sc.id AS clientId, |
| | | sc.`name` AS clientName, |
| | | sc.clientNum AS clientNum, |
| | | sc.address AS address, |
| | | sc.phone AS phone, |
| | | sc.idCard AS idCard |
| | | FROM |
| | | se_client sc |
| | | LEFT JOIN (SELECT srh.clientId FROM `se_recharge_history` srh |
| | | <where> |
| | | srh.amount > 0 AND srh.operate_valid = 2 |
| | | <if test="timeStart != null and timeStart != ''"> |
| | | AND srh.operateDt > #{timeStart} |
| | | </if> |
| | | </where> |
| | | ) c on c.clientId = sc.id |
| | | WHERE c.clientId IS NULL |
| | | GROUP BY sc.id) d |
| | | </select> |
| | | <!--最近未充值的农户--> |
| | | <select id="getNotRechargeLastClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> |
| | | SELECT |
| | | sc.id AS clientId, |
| | | sc.`name` AS clientName, |
| | | sc.clientNum AS clientNum, |
| | | sc.address AS address, |
| | | sc.phone AS phone, |
| | | sc.idCard AS idCard |
| | | FROM |
| | | se_client sc |
| | | LEFT JOIN (SELECT srh.clientId FROM `se_recharge_history` srh |
| | | <where> |
| | | srh.amount > 0 AND srh.operate_valid = 2 |
| | | <if test="timeStart != null and timeStart != ''"> |
| | | AND srh.operateDt > #{timeStart} |
| | | </if> |
| | | </where> |
| | | ) c on c.clientId = sc.id |
| | | WHERE c.clientId IS NULL |
| | | GROUP BY sc.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> |
| | |
| | | |
| | | <!--根据操作员ID获取未关阀记录(包含在线情况)--> |
| | | <select id="getUnclosedValves" resultType="com.dy.pipIrrGlobal.voRm.VoUnclosedValve"> |
| | | SELECT inta.name AS intakeNum, |
| | | SELECT |
| | | inta.name AS intakeNum, |
| | | rtus.isOnLine, |
| | | com.rtu_addr AS rtuAddr, |
| | | com.param ->> '$.icCardNo' AS vcNum, |
| | | (SELECT param ->> '$.orderNo' AS orderNo |
| | | ( |
| | | SELECT param ->> '$.orderNo' AS orderNo |
| | | FROM rm_command_history |
| | | WHERE rtu_addr = com.rtu_addr |
| | | ORDER BY send_time desc |
| | | LIMIT 0,1) AS orderNo, |
| | | 'toClose' AS state |
| | | LIMIT 0,1 |
| | | ) AS orderNo, |
| | | 'toClose' AS state, |
| | | CASE |
| | | WHEN com.command_code = 'A1' OR com.command_code = 'A2' THEN 0 |
| | | ELSE 0 |
| | | END AS planned, |
| | | com.send_time AS sendTime |
| | | FROM rm_command_history com |
| | | INNER JOIN pr_controller con ON com.rtu_addr = con.rtuAddr |
| | | INNER JOIN pr_intake inta ON con.intakeId = inta.id |
| | | INNER JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | LEFT JOIN JSON_TABLE( |
| | | <!-- '[{"rtuAddr":"620201000030","isOnLine":true}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | |
| | | ) |
| | | ) rtus ON com.rtu_addr = rtus.rtuAddr |
| | | <where> |
| | | AND (com.command_code = '92' OR com.command_code = 'A2' OR com.command_code = '97') |
| | | AND com.operator = #{operator} |
| | | AND (com.protocol = 'p206V1_0_1' AND (com.command_code = '92' OR com.command_code = '97' OR com.command_code = '99' OR com.command_code = 'A0' OR com.command_code = 'A1' OR com.command_code = 'A2')) |
| | | AND NOT EXISTS( |
| | | SELECT * |
| | | FROM rm_command_history |
| | | SELECT * FROM rm_command_history |
| | | WHERE (result IS NULL OR result = 1) |
| | | AND (command_code = '93' OR command_code = 'A3' OR command_code = '98') |
| | | AND (com.protocol = 'p206V1_0_1' AND (command_code = '93' OR command_code = '98' OR command_code = '00')) |
| | | AND param ->> '$.orderNo' = com.param ->> '$.orderNo' |
| | | ) |
| | | </where> |
| | | GROUP BY inta.name, rtus.isOnLine, com.rtu_addr, com.param ->> '$.icCardNo' |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT inta.name AS intakeNum, |
| | | rtus.isOnLine, |
| | | com.rtu_addr AS rtuAddr, |
| | | com.param ->> '$.icCardNo' AS vcNum, |
| | | (SELECT param ->> '$.orderNo' AS orderNo |
| | | FROM rm_command_history |
| | | WHERE rtu_addr = com.rtu_addr |
| | | ORDER BY send_time desc |
| | | LIMIT 0,1) AS orderNo, |
| | | 'toCancel' AS state |
| | | FROM rm_command_history com |
| | | INNER JOIN pr_intake inta ON inta.id = com.intake_id |
| | | INNER JOIN JSON_TABLE( |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | ) rtus ON com.rtu_addr = rtus.rtuAddr |
| | | <where> |
| | | AND (command_code = 'A1' OR command_code = 'A2') |
| | | AND com.operator = #{operator} |
| | | AND DATE_FORMAT( |
| | | CONCAT(com.param ->> '$.year', '-', com.param ->> '$.month', '-', com.param ->> '$.day', |
| | | ' ', |
| | | com.param ->> '$.hour', ':', com.param ->> '$.minute', ':', '0'), |
| | | '%Y-%m-%d %H:%i:%S') > NOW() |
| | | </where> |
| | | GROUP BY inta.name, rtus.isOnLine, com.rtu_addr, com.param ->> '$.icCardNo', com.command_code, com.send_time |
| | | ORDER BY com.send_time DESC |
| | | LIMIT 1 |
| | | </select> |
| | | |
| | | <!--根据取水口ID获取该取水口未关阀参数--> |
| | |
| | | AND oh.rtu_addr LIKE CONCAT('%', #{rtuAddr}, '%') |
| | | </if> |
| | | <if test="timeStart_open != null and timeStart_open != '' and timeStop_open != null and timeStop_open != ''"> |
| | | AND oh.op_dt BETWEEN #{timeStart_open} AND #{timeStop_open} |
| | | AND oh.open_dt BETWEEN #{timeStart_open} AND #{timeStop_open} |
| | | </if> |
| | | <if test="timeStart_close != null and timeStart_close != '' and timeStop_close != null and timeStop_close != ''"> |
| | | AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close} |
| | | AND oh.close_dt BETWEEN #{timeStart_close} AND #{timeStop_close} |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | AND oh.rtu_addr LIKE CONCAT('%', #{rtuAddr}, '%') |
| | | </if> |
| | | <if test="timeStart_open != null and timeStart_open != '' and timeStop_open != null and timeStop_open != ''"> |
| | | AND oh.op_dt BETWEEN #{timeStart_open} AND #{timeStop_open} |
| | | AND oh.open_dt BETWEEN #{timeStart_open} AND #{timeStop_open} |
| | | </if> |
| | | <if test="timeStart_close != null and timeStart_close != '' and timeStop_close != null and timeStop_close != ''"> |
| | | AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close} |
| | | AND oh.close_dt BETWEEN #{timeStart_close} AND #{timeStop_close} |
| | | </if> |
| | | </where> |
| | | ORDER BY oh.op_dt DESC |
| | |
| | | |
| | | // 添加巡检记录 |
| | | OpeInspect opeInspect = new OpeInspect(); |
| | | opeInspect.setInspectorId(inspects.getInspectorId()); |
| | | opeInspect.setInspectorId(inspectorId); |
| | | if(startTime != null) { |
| | | opeInspect.setStartTime(startTime); |
| | | } |
| | |
| | | } |
| | | }else { |
| | | // 该巡检已上传过记录,续传 |
| | | if(stopTime != null) { |
| | | OpeInspect inspect = new OpeInspect(); |
| | | inspect.setId(inspectId); |
| | | inspect.setStopTime(stopTime); |
| | | inspectSv.updateInspect(inspect); |
| | | } |
| | | |
| | | if(tracks != null && tracks.size() > 0) { |
| | | for (int j = 0; j < tracks.size(); j++) { |
| | | tracks.get(j).setId(idLongGenerator.generate()); |
| | | tracks.get(j).setInspectId(inspectId); |
| | | } |
| | | Integer rec = inspectSv.insertTracks(tracks); |
| | | if(rec == null || rec == 0) { |
| | | return BaseResponseUtils.buildErrorMsg("巡检轨迹添加失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改巡检记录 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Integer updateInspect(OpeInspect po) { |
| | | return opeInspectMapper.updateByPrimaryKeySelective(po); |
| | | } |
| | | |
| | | /** |
| | | * 批量添加巡检轨迹 |
| | | * @param list |
| | | * @return |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 最近未充值的农户 |
| | | * |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getNotRechargeLastClients") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoClient>>> getNotRechargeLastClients(CommonQO qo) { |
| | | try { |
| | | QueryResultVo<List<VoClient>> res = clientSv.getNotRechargeLastClients(qo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | }catch (Exception e){ |
| | | log.error("获取记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | rsVo.obj = rmClientAmountDayLastMapper.getMonthAmountAndMoney(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 最近未充值的农户 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoClient>> getNotRechargeLastClients(CommonQO qo) { |
| | | String timeStart = qo.getTimeStart(); |
| | | if (timeStart != null && timeStart != ""){ |
| | | timeStart = timeStart + " 00:00:00"; |
| | | qo.setTimeStart(timeStart); |
| | | } |
| | | // 生成查询参数 |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; |
| | | |
| | | // 获取符合条件的记录数 |
| | | Long itemTotal = Optional.ofNullable(rmClientAmountDayLastMapper.getNotRechargeLastClientsCount(params)).orElse(0L); |
| | | |
| | | QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; |
| | | |
| | | rsVo.pageSize = qo.pageSize ; |
| | | rsVo.pageCurr = qo.pageCurr ; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = rmClientAmountDayLastMapper.getNotRechargeLastClients(params); |
| | | return rsVo ; |
| | | } |
| | | } |
| | |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | |
| | | System.out.println(jsonArray); |
| | | System.out.println(jsonArray.toJSONString()); |
| | | List<VoUnclosedValve> res = rmCommandHistoryMapper.getUnclosedValves(jsonArray.toJSONString(), operator); |
| | | if(res != null) { |
| | | return res; |