pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmOpenCloseValveHistoryMapper.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoRm.RmOpenCloseValveHistory; import com.dy.pipIrrGlobal.voRm.VoOpenCloseValve; import com.dy.pipIrrGlobal.voSt.VoClient; import com.dy.pipIrrGlobal.voSt.VoIntake; import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount; import org.apache.ibatis.annotations.Mapper; @@ -121,4 +122,74 @@ * @return */ List<VoIntakeOpenCount> getOpenValveLtIntakes(Map<String, Object> params); /** * 获取指定时间段内开阀次数超过指定值的农户数量 * @param params * @return */ Long getLargeOpenCountClientsCount(Map<String, Object> params); /** * 获取指定时间段内开阀次数超过指定值的农户 * @param params * @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); /** * 获取指定时间段内用水量超过指定值的农户数量 * @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/java/com/dy/pipIrrGlobal/voSt/VoClient.java
New file @@ -0,0 +1,48 @@ package com.dy.pipIrrGlobal.voSt; import com.alibaba.fastjson2.annotation.JSONField; import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import lombok.Data; /** * @author ZhuBaoMin * @date 2024-08-06 9:45 * @LastEditTime 2024-08-06 9:45 * @Description 农户视图对象 */ @Data public class VoClient { private static final long serialVersionUID = 202408060947001L; /** * 农户ID */ @JSONField(serializeUsing= ObjectWriterImplToString.class) private Long clientId; /** * 农户姓名 */ private String clientName; /** * 农户编号 */ private String clientNum; /** * 农户地址 */ private String address; /** * 手机号 */ private String phone; /** * 身份证号 */ private String idCard; } pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -72,7 +72,7 @@ pipIrr: global: dev: true #是否开发阶段,true或false dev: false #是否开发阶段,true或false dsName: ym #开发阶段,设置临时的数据库名称 mw: webPort: 8070 pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -435,30 +435,29 @@ where id = #{id,jdbcType=BIGINT} </update> <!--根据指定条件获取开关阀报历史记录数量--> <select id="getOpenCloseValveReportsCount_history" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM rm_open_close_valve_history oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId >0"> AND oh.intake_id = #{intakeId} </if> <if test = "intakeNum != null and intakeNum !=''"> AND inta.name LIKE CONCAT('%',#{intakeNum},'%') </if> <if test = "rtuAddr != null and rtuAddr !=''"> 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} </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} </if> </where> </select> <!--根据指定条件获取开关阀报历史记录数量--> <select id="getOpenCloseValveReportsCount_history" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM rm_open_close_valve_history oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId > 0"> AND oh.intake_id = #{intakeId} </if> <if test="intakeNum != null and intakeNum != ''"> AND inta.name LIKE CONCAT('%', #{intakeNum}, '%') </if> <if test="rtuAddr != null and rtuAddr != ''"> 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} </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} </if> </where> </select> <!--根据指定条件获取开关阀报历史记录数量--> <select id="getOpenCloseValveReportsCount_history" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount @@ -552,170 +551,325 @@ </if> </trim> </select> <!--根据指定条件获取开关阀报历史记录--> <select id="getOpenCloseValveReports_history" resultType="com.dy.pipIrrGlobal.voRm.VoOpenCloseValve"> SELECT oh.intake_id AS intakeId, inta.name AS intakenum, oh.rtu_addr AS rtuAddr, oh.client_name AS clientName, oh.op_ic_card_no AS openIcNum, oh.op_ic_card_addr AS openIcAddr, oh.op_dt AS openTime, CASE WHEN oh.op_type = 1 THEN "刷卡开阀" WHEN oh.op_type = 3 THEN "中心站开阀" WHEN oh.op_type = 5 THEN "欠费关阀" WHEN oh.op_type = 8 THEN "用户远程开阀" WHEN oh.op_type = 11 THEN "开关阀卡开阀" ELSE "未知" END AS openType, oh.op_order_no AS openOrderNo, oh.op_total_amount AS openTotalAmount, oh.op_remain_money AS openRemainMoney, oh.op_water_remain_user AS openWaterRemain, oh.op_ele_total_amount AS openEleTotalAmount, oh.cl_ic_card_no AS closeIcNum, oh.cl_ic_card_addr AS closeIcAddr, oh.cl_dt AS closeTime, CASE WHEN oh.cl_type = 2 THEN "刷卡关阀" WHEN oh.cl_type = 4 THEN "中心站关阀" WHEN oh.cl_type = 5 THEN "欠费关阀" WHEN oh.cl_type = 6 THEN "流量计故障关阀" WHEN oh.cl_type = 7 THEN "紧急关闭" WHEN oh.cl_type = 9 THEN "用户远程关阀" WHEN oh.cl_type = 10 THEN "开关阀卡关阀" WHEN oh.cl_type = 12 THEN "黑名单命令关阀" WHEN oh.cl_type = 13 THEN "用户远程定时关阀" WHEN oh.cl_type = 14 THEN "用户远程定量关阀" ELSE "未知" END AS closeType, oh.cl_this_amount AS closeThisAmount, oh.cl_this_time AS thisTime, oh.cl_this_money AS thisMoney, oh.cl_remain_money AS closeRemainMoney, oh.cl_total_amount AS closeTotalAmount FROM rm_open_close_valve_history oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId >0"> AND oh.intake_id = #{intakeId} </if> <if test = "intakeNum != null and intakeNum !=''"> AND inta.name LIKE CONCAT('%',#{intakeNum},'%') </if> <if test = "rtuAddr != null and rtuAddr !=''"> 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} </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} </if> </where> ORDER BY oh.op_dt DESC <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="getNeverOpenValveIntakesCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM pr_intake inta INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 AND NOT EXISTS(SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} AND intake_id = inta.id) <!--根据指定条件获取开关阀报历史记录--> <select id="getOpenCloseValveReports_history" resultType="com.dy.pipIrrGlobal.voRm.VoOpenCloseValve"> SELECT oh.intake_id AS intakeId, inta.name AS intakenum, oh.rtu_addr AS rtuAddr, oh.client_name AS clientName, oh.op_ic_card_no AS openIcNum, oh.op_ic_card_addr AS openIcAddr, oh.op_dt AS openTime, CASE WHEN oh.op_type = 1 THEN '刷卡开阀' WHEN oh.op_type = 3 THEN '中心站开阀' WHEN oh.op_type = 5 THEN '欠费关阀' WHEN oh.op_type = 8 THEN '用户远程开阀' WHEN oh.op_type = 11 THEN '开关阀卡开阀' ELSE '未知' END AS openType, oh.op_order_no AS openOrderNo, oh.op_total_amount AS openTotalAmount, oh.op_remain_money AS openRemainMoney, oh.op_water_remain_user AS openWaterRemain, oh.op_ele_total_amount AS openEleTotalAmount, oh.cl_ic_card_no AS closeIcNum, oh.cl_ic_card_addr AS closeIcAddr, oh.cl_dt AS closeTime, CASE WHEN oh.cl_type = 2 THEN '刷卡关阀' WHEN oh.cl_type = 4 THEN '中心站关阀' WHEN oh.cl_type = 5 THEN '欠费关阀' WHEN oh.cl_type = 6 THEN '流量计故障关阀' WHEN oh.cl_type = 7 THEN '紧急关闭' WHEN oh.cl_type = 9 THEN '用户远程关阀' WHEN oh.cl_type = 10 THEN '开关阀卡关阀' WHEN oh.cl_type = 12 THEN '黑名单命令关阀' WHEN oh.cl_type = 13 THEN '用户远程定时关阀' WHEN oh.cl_type = 14 THEN '用户远程定量关阀' ELSE '未知' END AS closeType, oh.cl_this_amount AS closeThisAmount, oh.cl_this_time AS thisTime, oh.cl_this_money AS thisMoney, oh.cl_remain_money AS closeRemainMoney, oh.cl_total_amount AS closeTotalAmount FROM rm_open_close_valve_history oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId > 0"> AND oh.intake_id = #{intakeId} </if> <if test="intakeNum != null and intakeNum != ''"> AND inta.name LIKE CONCAT('%', #{intakeNum}, '%') </if> <if test="rtuAddr != null and rtuAddr != ''"> 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} </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} </if> </where> ORDER BY oh.op_dt DESC <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="getNeverOpenValveIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> SELECT inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 AND NOT EXISTS(SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} AND intake_id = inta.id) ORDER BY inta.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="getOpenValveGtIntakesCount" resultType="java.lang.Long"> select count(*) from (SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount > #{value}) a </select> <!--获取指定时间段内开阀次数超过指定值的取水口--> <select id="getOpenValveGtIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount"> SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount > #{value} ORDER BY inta.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="getOpenValveLtIntakesCount" resultType="java.lang.Long"> select count(*) from (SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount < #{value}) a </select> <!--获取指定时间段内开阀次数低于指定值的取水口--> <select id="getOpenValveLtIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount"> SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId,intakeNum,blockName HAVING recordCount < #{value} ORDER BY inta.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="getNeverOpenValveIntakesCount" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM pr_intake inta INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 AND NOT EXISTS(SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} AND intake_id = inta.id) </select> <!--获取指定时间段内从未开过阀的取水口--> <select id="getNeverOpenValveIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> SELECT inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 AND NOT EXISTS(SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} AND intake_id = inta.id) ORDER BY inta.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="getOpenValveGtIntakesCount" resultType="java.lang.Long"> select count(*) from (SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId, intakeNum, blockName HAVING recordCount > #{value}) a </select> <!--获取指定时间段内开阀次数超过指定值的取水口--> <select id="getOpenValveGtIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount"> SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId, intakeNum, blockName HAVING recordCount > #{value} <!-- ORDER BY inta.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="getOpenValveLtIntakesCount" resultType="java.lang.Long"> select count(*) from (SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId, intakeNum, blockName HAVING recordCount < #{value}) a </select> <!--获取指定时间段内开阀次数低于指定值的取水口--> <select id="getOpenValveLtIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount"> SELECT COUNT(*) AS recordCount, inta.id AS intakeId, inta.name AS intakeNum, blo.name AS blockName FROM pr_intake inta LEFT JOIN (SELECT * FROM rm_open_close_valve_history WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id INNER JOIN ba_block blo ON blo.id = inta.blockId WHERE inta.deleted = 0 GROUP BY intakeId, intakeNum, blockName HAVING recordCount < #{value} <!-- ORDER BY inta.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="getLargeOpenCountClientsCount" 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="getLargeOpenCountClients" 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> <!--获取指定时间段内开阀次数低于指定值的农户数量--> <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> <!--获取指定时间段内用水量超过指定值的农户数量--> <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-global/src/main/resources/mapper/RmOpenCloseValveLastMapper.xml
@@ -454,101 +454,99 @@ where id = #{id,jdbcType=BIGINT} </update> <!--根据指定条件获取开关阀报最新记录数量--> <select id="getOpenCloseValveReportsCount_last" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM rm_open_close_valve_last oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId >0"> AND oh.intake_id = #{intakeId} </if> <if test = "intakeNum != null and intakeNum !=''"> AND inta.name LIKE CONCAT('%',#{intakeNum},'%') </if> <if test = "rtuAddr != null and rtuAddr !=''"> 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} </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} </if> </where> </select> <!--根据指定条件获取开关阀报最新记录数量--> <select id="getOpenCloseValveReportsCount_last" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM rm_open_close_valve_last oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId > 0"> AND oh.intake_id = #{intakeId} </if> <if test="intakeNum != null and intakeNum != ''"> AND inta.name LIKE CONCAT('%', #{intakeNum}, '%') </if> <if test="rtuAddr != null and rtuAddr != ''"> 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} </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} </if> </where> </select> <!--根据指定条件获取开关阀报最新记录--> <select id="getOpenCloseValveReports_last" resultType="com.dy.pipIrrGlobal.voRm.VoOpenCloseValve"> SELECT oh.intake_id AS intakeId, inta.name AS intakeNum, oh.rtu_addr AS rtuAddr, oh.client_name AS clientName, oh.op_ic_card_no AS openIcNum, oh.op_ic_card_addr AS openIcAddr, oh.op_dt AS openTime, CASE WHEN oh.op_type = 1 THEN "刷卡开阀" WHEN oh.op_type = 3 THEN "中心站开阀" WHEN oh.op_type = 5 THEN "欠费关阀" WHEN oh.op_type = 8 THEN "用户远程开阀" WHEN oh.op_type = 11 THEN "开关阀卡开阀" ELSE "未知" END AS openType, oh.op_order_no AS openOrderNo, oh.op_total_amount AS openTotalAmount, oh.op_remain_money AS openRemainMoney, oh.op_water_remain_user AS openWaterRemain, oh.op_ele_total_amount AS openEleTotalAmount, oh.cl_ic_card_no AS closeIcNum, oh.cl_ic_card_addr AS closeIcAddr, oh.cl_dt AS closeTime, CASE WHEN oh.cl_type = 2 THEN "刷卡关阀" WHEN oh.cl_type = 4 THEN "中心站关阀" WHEN oh.cl_type = 5 THEN "欠费关阀" WHEN oh.cl_type = 6 THEN "流量计故障关阀" WHEN oh.cl_type = 7 THEN "紧急关闭" WHEN oh.cl_type = 9 THEN "用户远程关阀" WHEN oh.cl_type = 10 THEN "开关阀卡关阀" WHEN oh.cl_type = 12 THEN "黑名单命令关阀" WHEN oh.cl_type = 13 THEN "用户远程定时关阀" WHEN oh.cl_type = 14 THEN "用户远程定量关阀" ELSE "未知" END AS closeType, oh.cl_this_amount AS closeThisAmount, oh.cl_this_time AS thisTime, oh.cl_this_money AS thisMoney, oh.cl_remain_money AS closeRemainMoney, oh.cl_total_amount AS closeTotalAmount FROM rm_open_close_valve_last oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId >0"> AND oh.intake_id = #{intakeId} </if> <if test = "intakeNum != null and intakeNum !=''"> AND inta.name LIKE CONCAT('%',#{intakeNum},'%') </if> <if test = "rtuAddr != null and rtuAddr !=''"> 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} </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} </if> </where> ORDER BY oh.op_dt DESC <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="getOpenCloseValveReports_last" resultType="com.dy.pipIrrGlobal.voRm.VoOpenCloseValve"> SELECT oh.intake_id AS intakeId, inta.name AS intakeNum, oh.rtu_addr AS rtuAddr, oh.client_name AS clientName, oh.op_ic_card_no AS openIcNum, oh.op_ic_card_addr AS openIcAddr, oh.op_dt AS openTime, CASE WHEN oh.op_type = 1 THEN '刷卡开阀' WHEN oh.op_type = 3 THEN '中心站开阀' WHEN oh.op_type = 5 THEN '欠费关阀' WHEN oh.op_type = 8 THEN '用户远程开阀' WHEN oh.op_type = 11 THEN '开关阀卡开阀' ELSE '未知' END AS openType, oh.op_order_no AS openOrderNo, oh.op_total_amount AS openTotalAmount, oh.op_remain_money AS openRemainMoney, oh.op_water_remain_user AS openWaterRemain, oh.op_ele_total_amount AS openEleTotalAmount, oh.cl_ic_card_no AS closeIcNum, oh.cl_ic_card_addr AS closeIcAddr, oh.cl_dt AS closeTime, CASE WHEN oh.cl_type = 2 THEN '刷卡关阀' WHEN oh.cl_type = 4 THEN '中心站关阀' WHEN oh.cl_type = 5 THEN '欠费关阀' WHEN oh.cl_type = 6 THEN '流量计故障关阀' WHEN oh.cl_type = 7 THEN '紧急关闭' WHEN oh.cl_type = 9 THEN '用户远程关阀' WHEN oh.cl_type = 10 THEN '开关阀卡关阀' WHEN oh.cl_type = 12 THEN '黑名单命令关阀' WHEN oh.cl_type = 13 THEN '用户远程定时关阀' WHEN oh.cl_type = 14 THEN '用户远程定量关阀' ELSE '未知' END AS closeType, oh.cl_this_amount AS closeThisAmount, oh.cl_this_time AS thisTime, oh.cl_this_money AS thisMoney, oh.cl_remain_money AS closeRemainMoney, oh.cl_total_amount AS closeTotalAmount FROM rm_open_close_valve_last oh INNER JOIN pr_intake inta ON inta.id = oh.intake_id <where> <if test="intakeId != null and intakeId > 0"> AND oh.intake_id = #{intakeId} </if> <if test="intakeNum != null and intakeNum != ''"> AND inta.name LIKE CONCAT('%', #{intakeNum}, '%') </if> <if test="rtuAddr != null and rtuAddr != ''"> 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} </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} </if> </where> ORDER BY oh.op_dt DESC <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="getOpenCloseValveReports_last" resultType="com.dy.pipIrrGlobal.voRm.VoOpenCloseValve"> SELECT oh.intake_id AS intakeId, pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
@@ -9,8 +9,6 @@ import com.dy.rtuMw.server.tasks.FromRtuComResultConstantTask; import com.dy.rtuMw.server.tasks.FromRtuDataConstantTask; import com.dy.common.mw.UnitInterface; import com.dy.common.mw.channel.rmi.RmiConfigVo; import com.dy.common.mw.channel.rmi.RmiUnit; import com.dy.common.mw.channel.tcp.TcpConfigVo; import com.dy.common.mw.channel.tcp.TcpUnit; import com.dy.common.mw.core.CoreUnit; @@ -53,21 +51,29 @@ new Server().startServer(); } */ public void startServer(){ /** try { URL url = Server.class.getResource("/config/this.licence"); if(!new Lnp(null).parese(url.getPath())){ System.out.println("licence error!") ; return ; } } catch (Exception e) { System.out.println("licence error!") ; return ; } */ if(this.doStartServer()){ ServerShutDownHook.OnShutDown(); } } /** * 启动服务 */ public void startServer(){ // try { // URL url = Server.class.getResource("/config/this.licence"); // if(!new Lnp(null).parese(url.getPath())){ // System.out.println("licence error!") ; // return ; // } // } catch (Exception e) { // System.out.println("licence error!") ; // return ; // } //Server sv = new Server(); private boolean doStartServer(){ boolean running = false ; long start = System.currentTimeMillis() ; try { //ConfigProperties.init(this.getClass().getResourceAsStream("/config/config.properties"), false); @@ -120,11 +126,13 @@ System.out.println("@@@@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ Runing in standalone mode" ) ; System.out.println("@@@@@@@@@@@@@@@@@@@@@& &@@@@@@@@ Startup in " + (System.currentTimeMillis() - start) + " MS" ) ; System.out.println("@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ " + company) ; System.out.println("@@@@@@@@@@@@@@@@#O &@@@@@@@@") ; System.out.println("@@@@@@@@@@@@@@@@#O &@@@@@@@@") ; running = true ; }catch(Exception e){ e.printStackTrace(); running = false ; } return running ; } private void startUnits(){ pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/ServerShutDownHook.java
New file @@ -0,0 +1,36 @@ package com.dy.rtuMw; import com.dy.common.mw.protocol.Command; import com.dy.common.mw.protocol.CommandType; import com.dy.rtuMw.server.local.CommandInnerDeaLer; import com.dy.rtuMw.server.local.localProtocol.CodeLocal; import lombok.extern.slf4j.Slf4j; /** * @Author: liurunyu * @Date: 2024/8/6 9:51 * @Description 程序(控制台)关闭处理钩子类 */ @Slf4j public class ServerShutDownHook { public static void OnShutDown(){ Runtime.getRuntime().addShutdownHook(new Thread(){ @Override public void run(){ try{ // 确保这段代码尽可能快速执行,避免影响JVM的关闭 log.info("程序(控制台)关闭钩子类执行"); Command com = new Command() ; com.id = Command.defaultId ; com.code = CodeLocal.stopTcpSv ; com.type = CommandType.innerCommand ; new CommandInnerDeaLer().deal(com) ; //Thread.sleep(100L);//实测不执行 log.info("关闭程序前,关闭了TCP服务"); }catch (Exception e){ log.error("程序(控制台)关闭钩子发生异常", e); } } }); } } pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application.yml
@@ -1,3 +1,9 @@ logging: charset: console: UTF-8 config: classpath: log4j2.yml spring: profiles: include: global, database pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/log4j2.yml
@@ -19,7 +19,7 @@ name: CONSOLE target: SYSTEM_OUT ThresholdFilter: level: debug #输出日志级别,输出日志时,首先由Loggers.Root.level或Loggers.Logger.level判断是否输出,然后再由本level判断是否输出 level: DEBUG #输出日志级别(DEBUG,INFO,WARN,ERROR,FATAL),输出日志时,首先由Loggers.Root.level或Loggers.Logger.level判断是否输出,然后再由本level判断是否输出 onMatch: ACCEPT #onMatch=ACCEPT 大于等于 "level" 配置的等级地日志输出 onMismatch: DENY #onMismatch=DENY 小于 "level" 配置的等级地日志不输出 #日志内容样式 @@ -44,7 +44,7 @@ fileName: ${log.path}/${project.name}.log filePattern: "${log.path}/$${date:yyyy-MM}/${project.name}-%d{yyyy-MM-dd}-%i.log.gz" ThresholdFilter: level: error #输出日志级别,输出日志时,首先由Loggers.Root.level或Loggers.Logger.level判断是否输出,然后再由本level判断是否输出 level: error #输出日志级别(DEBUG,INFO,WARN,ERROR,FATAL),输出日志时,首先由Loggers.Root.level或Loggers.Logger.level判断是否输出,然后再由本level判断是否输出 onMatch: ACCEPT #onMatch=ACCEPT 大于等于 "level" 配置的等级地日志输出 onMismatch: DENY #onMismatch=DENY 小于 "level" 配置的等级地日志不输出 #日志内容样式 @@ -58,7 +58,7 @@ Loggers: Root: level: info #日志输出级别,共有8个级别,按照从低到高为:all < trace < debug < info < warn < error < fatal < off level: INFO #日志输出级别(DEBUG,INFO,WARN,ERROR,FATAL),共有8个级别,按照从低到高为:all < trace < debug < info < warn < error < fatal < off AppenderRef: #Root的子节点,用来指定该日志输出到哪个Appender. - ref: CONSOLE #输出日志时,首先由本level判断是否输出,然后再由上面的Appenders.Console.ThresholdFilter.level判断是否输出 - ref: ROLLING_FILE #输出日志时,首先由本level判断是否输出,然后再由上面的Appenders.RollingFile.ThresholdFilter.level判断是否输出 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
New file @@ -0,0 +1,137 @@ package com.dy.pipIrrStatistics.client; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; 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; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Objects; /** * @author ZhuBaoMin * @date 2024-08-06 9:43 * @LastEditTime 2024-08-06 9:43 * @Description */ @Slf4j @RestController @RequestMapping(path="statistics") @RequiredArgsConstructor public class ClientCtrl { private final ClientSv clientSv; /** * 获取指定时间段内开阀次数超过指定值的农户 * @param qo * @return */ @GetMapping(path = "/getLargeOpenCountClients") @SsoAop() public BaseResponse<QueryResultVo<List<VoClient>>> getLargeOpenCountClients(@Valid OpenCountQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(clientSv.getLargeOpenCountClients(qo)); } catch (Exception e) { log.error("获取开卡记录异常", e); 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()) ; } } /** * 获取指定时间段内用水量超过指定值的农户 * @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
New file @@ -0,0 +1,222 @@ package com.dy.pipIrrStatistics.client; 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; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.util.List; import java.util.Map; import java.util.Optional; /** * @author ZhuBaoMin * @date 2024-08-06 9:43 * @LastEditTime 2024-08-06 9:43 * @Description */ @Slf4j @Service public class ClientSv { @Autowired private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; /** * 获取指定时间段内开阀次数超过指定值的农户 * @param qo * @return */ public QueryResultVo<List<VoClient>> getLargeOpenCountClients(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.getLargeOpenCountClientsCount(params)).orElse(0L); QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); 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 ; } /** * 获取指定时间段内用水量超过指定值的农户 * @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/OpenCountQO.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 9:55 * @LastEditTime 2024-08-06 9:55 * @Description 开阀次数查询对象 */ @Data public class OpenCountQO extends CommonQO { /** * 开阀次数 */ @NotNull(message = "开阀次数不能为空") private Integer openCount; } 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; } pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
@@ -17,6 +17,8 @@ import com.dy.pipIrrStatistics.intake.qo.CumulativeFlowQO; import com.dy.pipIrrStatistics.intake.qo.IntakeQO; import com.dy.pipIrrStatistics.intake.qo.IntakeCountValueQO; import com.dy.pipIrrStatistics.intake.qo.CommonQO; import com.dy.pipIrrStatistics.intake.qo.IntakeValueQO; import com.dy.pipIrrStatistics.intake.qo.SignalIntensityQO; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; @@ -65,7 +67,7 @@ * @param qo * @return */ public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(IntakeQO qo) { public QueryResultVo<List<VoIntake>> getNotOnlineIntakes(CommonQO qo) { DecimalFormat df = new DecimalFormat("0.00"); /** * 补齐起止时间,如果开始时间为空,则默认为当前日期 @@ -195,7 +197,7 @@ * 获取从未开过阀的取水口 * @return */ public QueryResultVo<List<VoIntake>> getNeverOpenValveIntakes(IntakeQO qo) { public QueryResultVo<List<VoIntake>> getNeverOpenValveIntakes(CommonQO qo) { String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntkeCtrl.java
@@ -17,13 +17,16 @@ import com.dy.pipIrrStatistics.intake.qo.SignalIntensityQO; import com.dy.pipIrrStatistics.intake.qo.IntakeCountValueQO; import com.dy.pipIrrStatistics.result.StatisticlResultCode; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Objects; /** * @author ZhuBaoMin @@ -46,7 +49,11 @@ */ @GetMapping(path = "/getNotOnlineIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoIntake>>> getNotOnlineIntakes(IntakeQO qo) { public BaseResponse<QueryResultVo<List<VoIntake>>> getNotOnlineIntakes(@Valid CommonQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getNotOnlineIntakes(qo)); } catch (Exception e) { @@ -62,7 +69,10 @@ */ @GetMapping(path = "/getLargeFlowIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoCumulativeFlow>>> getLargeFlowIntakes(CumulativeFlowQO qo) { public BaseResponse<QueryResultVo<List<VoCumulativeFlow>>> getLargeFlowIntakes(@Valid CumulativeFlowQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getLargeFlowIntakes(qo)); } catch (Exception e) { @@ -78,7 +88,10 @@ */ @GetMapping(path = "/getSmallFlowIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoCumulativeFlow>>> getSmallFlowIntakes(CumulativeFlowQO qo) { public BaseResponse<QueryResultVo<List<VoCumulativeFlow>>> getSmallFlowIntakes(@Valid CumulativeFlowQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getSmallFlowIntakes(qo)); } catch (Exception e) { @@ -94,7 +107,10 @@ */ @GetMapping(path = "/getUnderVoltIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoBatteryVolt>>> getUnderVoltIntakes(BatteryVoltQO qo) { public BaseResponse<QueryResultVo<List<VoBatteryVolt>>> getUnderVoltIntakes(@Valid BatteryVoltQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getUnderVoltIntakes(qo)); } catch (Exception e) { @@ -110,7 +126,10 @@ */ @GetMapping(path = "/getSpecifiedSignalIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoSignalIntensity>>> getSpecifiedSignalIntakes(SignalIntensityQO qo) { public BaseResponse<QueryResultVo<List<VoSignalIntensity>>> getSpecifiedSignalIntakes(@Valid SignalIntensityQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getSpecifiedSignalIntakes(qo)); } catch (Exception e) { @@ -126,7 +145,10 @@ */ @GetMapping(path = "/getCountByOpenType") @SsoAop() public BaseResponse<QueryResultVo<VoCountOfOpenType>> getCountByOpenType(OpenTypeQO qo) { public BaseResponse<QueryResultVo<VoCountOfOpenType>> getCountByOpenType(@Valid OpenTypeQO qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getCountByOpenType(qo)); } catch (Exception e) { @@ -142,7 +164,10 @@ */ @GetMapping(path = "/getCountByCloseType") @SsoAop() public BaseResponse<QueryResultVo<VoCountOfCloseType>> getCountByCloseType(CloseTypeQo qo) { public BaseResponse<QueryResultVo<VoCountOfCloseType>> getCountByCloseType(@Valid CloseTypeQo qo, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } try { return BaseResponseUtils.buildSuccess(intakeSv.getCountByCloseType(qo)); } catch (Exception e) { @@ -159,7 +184,7 @@ */ @GetMapping(path = "/getNeverOpenValveIntakes") @SsoAop() public BaseResponse<QueryResultVo<List<VoIntake>>> getNeverOpenValveIntakes(IntakeQO qo) { public BaseResponse<QueryResultVo<List<VoIntake>>> getNeverOpenValveIntakes(CommonQO qo) { try { QueryResultVo<List<VoIntake>> res = intakeSv.getNeverOpenValveIntakes(qo); if(res.itemTotal == 0) { pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/qo/CommonQO.java
File was renamed from pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/qo/IntakeQO.java @@ -13,7 +13,7 @@ */ @Data public class IntakeQO extends QueryConditionVo { public class CommonQO extends QueryConditionVo { /** * 开始时间 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/qo/IntakeCountValueQO.java
@@ -12,7 +12,7 @@ * @Description */ @Data public class IntakeCountValueQO extends IntakeQO { public class IntakeCountValueQO extends CommonQO { /**