Browse Source

水查查接口工程

hym 4 years ago
parent
commit
f7fec4c69b
24 changed files with 1669 additions and 0 deletions
  1. 125 0
      water_query_api/pom.xml
  2. 92 0
      water_query_api/src/main/java/com/zcxk/common/model/AjaxMessage.java
  3. 43 0
      water_query_api/src/main/java/com/zcxk/common/model/Pagination.java
  4. 115 0
      water_query_api/src/main/java/com/zcxk/common/model/ResultStatus.java
  5. 154 0
      water_query_api/src/main/java/com/zcxk/controller/WaterApiController.java
  6. 27 0
      water_query_api/src/main/java/com/zcxk/dao/MeterReadRecordMapper.java
  7. 24 0
      water_query_api/src/main/java/com/zcxk/dao/WarningMessageMapper.java
  8. 18 0
      water_query_api/src/main/java/com/zcxk/dao/WarningRuleMapper.java
  9. 18 0
      water_query_api/src/main/java/com/zcxk/dto/UseWaterAnalyze.java
  10. 14 0
      water_query_api/src/main/java/com/zcxk/dto/UseWaterDto.java
  11. 20 0
      water_query_api/src/main/java/com/zcxk/dto/WarningMessageDto.java
  12. 13 0
      water_query_api/src/main/java/com/zcxk/dto/WarningMessageStatusDto.java
  13. 97 0
      water_query_api/src/main/java/com/zcxk/entity/MeterReadRecord.java
  14. 36 0
      water_query_api/src/main/java/com/zcxk/entity/WarningMessage.java
  15. 45 0
      water_query_api/src/main/java/com/zcxk/entity/WarningRule.java
  16. 14 0
      water_query_api/src/main/java/com/zcxk/service/MeterReadRecordService.java
  17. 20 0
      water_query_api/src/main/java/com/zcxk/service/WarningMessageService.java
  18. 21 0
      water_query_api/src/main/java/com/zcxk/service/WarningRuleService.java
  19. 108 0
      water_query_api/src/main/java/com/zcxk/service/impl/MeterReadRecordServiceImpl.java
  20. 35 0
      water_query_api/src/main/java/com/zcxk/service/impl/WarningMessageServiceImpl.java
  21. 53 0
      water_query_api/src/main/java/com/zcxk/service/impl/WarningRuleServiceImpl.java
  22. 331 0
      water_query_api/src/main/resources/mapper/MeterReadRecordMapper.xml
  23. 138 0
      water_query_api/src/main/resources/mapper/WarningMessageMapper.xml
  24. 108 0
      water_query_api/src/main/resources/mapper/WarningRuleMapper.xml

+ 125 - 0
water_query_api/pom.xml

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.bz</groupId>
+    <artifactId>water-query-api</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.1.RELEASE</version>
+        <relativePath/>
+    </parent>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <!-- 跳过打包检测 -->
+        <skipTests>true</skipTests>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jdbc</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.3</version>
+        </dependency>
+        <!-- MySQL -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.7.0</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.7.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.2.10</version>
+        </dependency>
+        <!--Druid-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>0.2.9</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <!-- tomcatd的jsp支持 -->
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+        </dependency>
+        <!-- servlet容器 -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 92 - 0
water_query_api/src/main/java/com/zcxk/common/model/AjaxMessage.java

@@ -0,0 +1,92 @@
+package com.zcxk.common.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Ajax信息
+ *
+ */
+@ApiModel("返回信息")
+public class AjaxMessage<T> {
+
+    @ApiModelProperty(value = "返回状态", position = 0)
+    private int status;
+    @ApiModelProperty(value = "返回信息", position = 1)
+    private String msg;
+    @ApiModelProperty(value = "返回内容", position = 2)
+    private T data;
+
+    public AjaxMessage() {
+    }
+
+    public AjaxMessage(int status, String msg, T data) {
+        this.status = status;
+        this.msg = msg;
+        this.data = data;
+    }
+
+    public AjaxMessage(ResultStatus resultStatus, T data) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();
+        this.data = data;
+    }
+
+    public AjaxMessage(ResultStatus resultStatus) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();
+    }
+
+
+
+    public void setMsg(int status, String msg, T data) {
+        this.status = status;
+        this.msg = msg;
+        this.data = data;
+    }
+
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public T getData() {
+        return data;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    public void setMsg(int status, String msg) {
+        this.status = status;
+        this.msg = msg;
+        this.data = null;
+    }
+
+    public void setMsg(ResultStatus resultStatus, T data) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();;
+        this.data = data;
+    }
+
+    public void setMsg(ResultStatus resultStatus) {
+        this.status = resultStatus.getStatus();
+        this.msg = resultStatus.getMessage();;
+        this.data = null;
+    }
+
+
+}

+ 43 - 0
water_query_api/src/main/java/com/zcxk/common/model/Pagination.java

@@ -0,0 +1,43 @@
+package com.zcxk.common.model;
+
+import com.github.pagehelper.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 自定义分页
+ * @param <T>
+ */
+@Data
+public class Pagination<T> implements Serializable {
+    private static final long serialVersionUID = -4899829840696212229L;
+    @ApiModelProperty("总记录数")
+    private long total;
+
+    @ApiModelProperty("结果集")
+    private List<T> list;
+
+
+    public Pagination(){
+
+    };
+
+    /**
+     * 包装Page对象
+     *
+     * @param list
+     */
+    public Pagination(List<T> list) {
+        Page page = (Page) list;
+        this.list = page;
+        this.total = page.getTotal();
+    }
+
+    public Pagination(List<T> list ,long total){
+        this.list = list ;
+        this.total =total ;
+    }
+}

+ 115 - 0
water_query_api/src/main/java/com/zcxk/common/model/ResultStatus.java

@@ -0,0 +1,115 @@
+package com.zcxk.common.model;
+
+import lombok.Getter;
+
+
+@Getter
+public enum ResultStatus {
+
+    /**
+     *返回状态
+     */
+    OK(0, "成功"),
+    UNBOUND_WECHAT_ERROR(-2, "未绑定微信账号"),
+    ERROR(-100, "失败"),
+    VERIFICATION_CODE_ERROR(-101, "验证码错误"),
+    VERIFICATION_ERROR(-102, "验证码错误"),
+    USERNAME_NOT_FOUND_ERROR(-400, "您的手机号尚未注册,请注册后进行登录。"),
+    ACCOUNT_LOCKED_ERROR(-401, "账户已被锁定"),
+    CREDENTIALS_EXPIRED_ERROR(-402, "密码已过期"),
+    ACCOUNT_EXPIRED_ERROR(-403, "账户已过期"),
+    ACCOUNT_DISABLED_ERROR(-404, "账户已被禁用"),
+    ACCESS_DENIED_ERROR(-405, "权限不足,无法访问"),
+    ACCESS_UNVERIFIED_ERROR(-406, "身份未认证,请重新登录"),
+    APPLICATION_ERROR(-900, "应用异常"),
+    SERVICE_ERROR(-901, "业务逻辑验证错误"),
+    SYSTEM_ERROR(-999, "系统错误"),
+    DEVICE_NO_IS_NOT_NULL(-301,"节点编号不能为空"),
+    DEVICE_NO_IS_EXISTED(-302,"节点编号已存在"),
+    INSTALL_RECORD_IS_EXISETD(-303,"安装记录已存在或已有安装计划,请删除该记录"),
+    CUST_CODE_ERROR(-304,"客户编码不正确"),
+    LACK_NECESSARY_PARAM(-305,"缺乏必要的参数"),
+    DELETE_OBJECT_NOT_EXISTED(-306,"删除的记录不存在"),
+    DELETE_AND_DOOR_EXISTED(-307,"门牌已安装水表,请进行修改"),
+    CUSTOMER_IS_NOT_EXISTED(-308,"客户不存在,请先录入客户信息"),
+    COMMUNITY_IS_NOT_EXISTED(-309,"小区不存在,请先录入小区信息"),
+    BUILDING_IS_NOT_EXISTED(-310,"建筑不存在,请先录入建筑信息"),
+    NUMBER_IS_OUT_RANGE(-311,"安装数量大于5000"),
+    DEVICE_TYPE_NOT_EXISTED(-312,"设备类型不存在,请先录入设备类型"),
+    DEVICE_NO_NOT_EXISTED(-313,"设备编号已经存在"),
+    DEVICE_ELECTRONIC_NO_NOT_EXISTED(-314,"您输入的水表电子号已存在,请重新输入"),
+    CONCENTRATOR_RELATED_NOT_EXISTED(-315,"该集中器已存在关联设备或采集器,无法删除。"),
+    COLLECTOR_RELATED_NOT_EXISTED(-316,"该采集器已存在关联设备,无法删除。"),
+    CONCENTRATOR_NOT_EXISTED(-317,"您输入的集中器编码已存在,请重新输入"),
+    COLLECTOR_NOT_EXISTED(-318,"您输入的采集器编号该集中器下已存在,请重新输入"),
+    CHANNEL_NUMBER_RELATED_NOT_EXISTED(-319,"该通道已存在关联设备,无法删除。"),
+    CHANNEL_NUMBER_NOT_EXISTED(-320,"您输入的通道号或设备ID已存在,请重新输入"),
+    CONCENTRATOR_IS_NOT_EXISTED(-321,"集中器不存在,请先录入集中器信息"),
+    CHANNEL_NUMBER_IS_NOT_EXISTED(-321,"通道号不存在,请先录入通道号信息"),
+    COLLECTOR_IS_NOT_EXISTED(-322,"采集器不存在,请先录入采集器信息"),
+    CREATE_ORDER_NO_DEVICE1(-501,"创建工单失败,无法获取设备编号"),
+    CREATE_ORDER_NO_DEVICE2(-502,"创建工单失败,无法获取设备"),
+    CREATE_ORDER_NO_ALARMTYPE(-503,"创建工单失败,无对应告警类型"),
+    CREATE_ORDER_NO_LOCATION(-504,"创建工单失败,无对应告警地址"),
+    NOT_EXISTS_CLEARING_PLAN(-510,"不存在的结算计划"),
+    CLEARING_PLAN_NAME_EMPTY(-511,"结算计划名称不能为空"),
+    CLEARING_PLAN_STARTDATE_EMPTY(-512,"结算计划开始时间不能为空"),
+    CLEARING_PLAN_PERIOD_EMPTY(-513,"结算计划执行周期不能为空"),
+    CLEARING_PLAN_RANGE_EMPTY(-514,"结算计划范围不能为空"),
+    CLEARING_RECORD_EXISTS_ACCOUNTPERIOD(-515,"该结算记录已存在账期"),
+    CLEARING_RECORD_ACCOUNTPERIOD_EXISTS(-516,"存在该账期"),
+    CLEARING_ITEM_IS_AUDIT(-517,"该记录已经审核通过"),
+    CLEARING_DATA_QUERY_CONDITION_ERROR(-600,"缺乏必要的查询条件:电子号、节点编号、客户号,至少一个"),
+    CLEARING_DATA_QUERY_CONDITION_ACCOUNT(-601,"缺乏必要的查询条件:账期不能为空"),
+    CLEARING_DATA_QUERY_NO_CUSTOMER(-602,"查询客户不存在"),
+    CLEARING_DATA_QUERY_NO_ACCOUNT(-603,"查询账期不存在"),
+    CLEARING_DATA_QUERY_NO_DATA(-604,"无结算数据"),
+    METER_READ_DATA_QUERY_CONDITION_ACCOUNT(-605,"缺乏必要的查询条件:抄表日期不能为空"),
+    NO_DEFINED_PROCESS(-610,"无法启动流程,无对应流程配置"),
+    PROCESS_START_ERROR(-610,"流程启动失败,请联系管理员"),
+    NO_AUTH_OPERATE_TASK(-611,"无操作权限"),
+    TASK_OPERATE_FAILED(-612,"任务操作失败"),
+    MESSAGE_CONFIGURATION_ISEMPTY (-700,"短信配置信息不完整"),
+    MESSAGE_TEMPLATE_FAILED(-701,"短信模板获取失败"),
+    MESSAGE_DEBTFEE_FAILED(-702,"短信推送获取欠费信息失败"),
+    ClOSING_ACCCOUNT_NOT_EXIT(-703,"未查询到账期信息"),
+    OPERATE_RECORD_NOT_EXIT(-704,"未查询到有效记录"),
+    ClOSING_ACCCOUNT_ERROR_EXIT(-705,"添加失败:账期已存在,不允许重复添加"),
+    ClOSING_ACCCOUNT_ERROR_NOT_EXIT(-706,"结账失败:账期不存在"),
+    PAYFEE_TRANSAMOUNT_BELOW_ZERO(-707,"实收金额必须不小于零"),
+    PAYFEE_QUERY_NO_CUSTOMER(-708,"未查询到有效客户信息"),
+    WATER_PROPERTY_EDIT_EXIT(-709,"该用水性质已被应用,无法编辑"),
+    WATER_PROPERTY_DELETE_EXIT(-709,"该用水性质已被应用,无法删除"),
+    PAYFEE_QUERY_NO_PAYWAY(-709,"获取支付方式失败"),
+    PAYFEE_QUERY_NO_TRANSTYPE(-710,"获取交易类型失败"),
+    PAYFEE_QUERY_NO_CLOSINGACCOUNT(-711,"获取账期信息失败"),
+    AMOUNT__REVIEW_ERROR_CLOSINGACCOUNT(-712,"审核失败:只允许审核当前账期的水量信息"),
+    ACCOUNT_FAMILYSIZE_ISNULL(-714,"用户用水人口为空"),
+    ACCOUNT_FAMILYSIZE_ISENABLE(-715,"该开户关联的用水性质未启用阶梯水价"),
+    SYS_DICT_ERROR_EXIST(-716,"数据在字典中已存在,不允许重复添加"),
+    WATERCATEGORY_ERROR_USED(-717,"该用水类别已被应用,无法删除。"),
+    WATERCATEGORY_ERROR_EXIST(-718,"该用水类别已经存在,无法添加"),
+    PAY_ADD_CUSTOMER_GETACCOUNT(-719,"添加开户失败,客户信息有误"),
+    PAY_ADD_CUSTOMER_GETDEVICE(-720,"添加开户失败,水表信息有误"),
+    PAY_ADD_CUSTOMER_ERR(-721,"添加开户失败"),
+    PAY_ADD_CUSTOMER_UPDATEAMOUNT(-722,"添加开户失败,计算阶梯可用量有误"),
+    WATER_PROPERTY_CHENCK_NAME(-723,"该名称已经存在,请修改"),
+    ACCOUNT_OPERATOR_EERROR(-724,"操作员信息异常"),
+    PAYFEE_NOT_ENOUGH(-725,"缴费金额不足"),
+    PAY_INVOICE_EXISTED(-726,"收据信息已存在"),
+    PAY_CONDITION_ISNULL(-727,"查询条件为空"),
+    PAYFEE_DEBT_BELOW_ZERO(-728,"欠费金额必须不小于零"),
+    PAYFEE_REMAINING_BELOW_ZERO(-729,"预存金额必须不小于零"),
+    PAYFEE_WATERAMOUNT_BELOW_ZERO(-730,"购水金额必须不小于零"),
+    PAYFEE_TRANAMOUNT_BELOW_ZERO(-731,"实收金额不能小于购水金额"),
+    CUSTOMER_IS_EXISTED(-3001,"客户名称已存在"),
+    SYBC_DATA_PARM_ERROR(-3002,"档案号个数太多,限制为30个");
+    private final int status;
+
+    private final String message;
+
+    ResultStatus(int status, String message) {
+        this.status = status;
+        this.message = message;
+    }
+}

+ 154 - 0
water_query_api/src/main/java/com/zcxk/controller/WaterApiController.java

@@ -0,0 +1,154 @@
+package com.zcxk.controller;
+
+import com.github.pagehelper.PageHelper;
+import com.zcxk.common.model.AjaxMessage;
+import com.zcxk.common.model.Pagination;
+import com.zcxk.common.model.ResultStatus;
+import com.zcxk.dto.UseWaterAnalyze;
+import com.zcxk.dto.UseWaterDto;
+import com.zcxk.dto.WarningMessageDto;
+import com.zcxk.dto.WarningMessageStatusDto;
+import com.zcxk.entity.WarningMessage;
+import com.zcxk.entity.WarningRule;
+import com.zcxk.service.MeterReadRecordService;
+import com.zcxk.service.WarningMessageService;
+import com.zcxk.service.WarningRuleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * (WarningMessage)控制层
+ *
+ * @author hym
+ * @since 2021-01-13 16:02:27
+ */
+@RestController
+@RequestMapping("/platform")
+@Api(tags = "水查查物联网接口")
+public class WaterApiController {
+
+    @Autowired
+    private MeterReadRecordService meterReadRecordService;
+    @Autowired
+    private WarningRuleService warningRuleService;
+    @Autowired
+    private WarningMessageService warningMessageService;
+
+    /**
+     * 查询用户用水量
+     *
+     * @param meterNo 水表档案号
+     * @return 单条数据
+     */
+    @RequestMapping(value = "getRealTimeUseWater ", method = RequestMethod.POST)
+    @ApiOperation(value = "查询用户用水量")
+    public AjaxMessage<List<UseWaterDto>> getRealTimeUseWater(
+            @ApiParam(value = "水表档案号", required = true) String meterNo,
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "查询范围,7:近7日,30:近30日", required = true) Integer period) {
+        List<UseWaterDto>result=  meterReadRecordService.getRealTimeUseWater(meterNo,period);
+
+
+        return new AjaxMessage<>(ResultStatus.OK,result );
+    }
+    @RequestMapping(value = "getThirtyDaysUseWater ", method = RequestMethod.POST)
+    @ApiOperation(value = "分析30天用户用水量")
+    public AjaxMessage<UseWaterAnalyze> getThirtyDaysUseWater(
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "水表档案号", required = true) String meterNo) {
+        UseWaterAnalyze result=meterReadRecordService.getThirtyDaysUseWater(meterNo);
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+    /**
+     * 新增一条数据
+     *
+     * @param meterNo 水表档案号
+     * @return Response对象
+     */
+    @RequestMapping(value = "getUseWaterAnalyze", method = RequestMethod.POST)
+    @ApiOperation(value = "用水分析")
+    public AjaxMessage<UseWaterAnalyze> getUseWaterAnalyze(
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "水表档案号", required = true) String meterNo) {
+
+        UseWaterAnalyze useWaterAnalyze=meterReadRecordService.getUseWaterAnalyze(meterNo);
+        return new AjaxMessage<>(ResultStatus.OK, useWaterAnalyze);
+    }
+
+    /**
+     * 添加预警规则
+     *
+     * @param meterNo 水表档案号
+     * @return Response对象
+     */
+    @RequestMapping(value = "addRule", method = RequestMethod.POST)
+    @ApiOperation(value = "添加预警规则")
+    public AjaxMessage<Integer> addRule(
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "预警类型 1:较上日用水量激增30% 2:连续无用水量超过7天", required = true)
+            @RequestParam(required = true) Integer warningType
+            ,@ApiParam(value = "水表档案号", required = true) String meterNo
+
+            ,@ApiParam(value = "水表档案号", required = true) String userName) {
+         warningRuleService.addRule(warningType,meterNo,userName);
+        return new AjaxMessage<>(ResultStatus.OK, null);
+
+    }
+
+    /**
+     * 查询预警信息列表
+     *
+     * @param meterNo 水表档案号
+     * @return Response对象
+     */
+    @RequestMapping(value = "getDateStatus", method = RequestMethod.POST)
+    @ApiOperation(value = "查询对应日期预警信息状态")
+    public AjaxMessage<List<WarningMessageStatusDto>> getDateStatus(
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam(required = true) Integer date
+            ,@ApiParam(value = "水表档案号", required = true) String meterNo
+    ) {
+        List<WarningMessageStatusDto>result=warningMessageService.getDateStatus(date,meterNo);
+
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+    /**
+     * 查询预警信息列表
+     *
+     * @param meterNo 水表档案号
+     * @return Response对象
+     */
+    @RequestMapping(value = "getWariningList", method = RequestMethod.POST)
+    @ApiOperation(value = "获取预警信息列表")
+    public AjaxMessage<List<WarningMessageDto>> getWariningList(
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam(required = true) Integer date
+            ,@ApiParam(value = "水表档案号", required = true) String meterNo
+    ) {
+        List<WarningMessageDto> result = warningMessageService.getList(date, meterNo);
+
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+    /**
+     * 规则列表
+     *
+     * @param meterNo 水表档案号
+     *
+     * @return Response对象
+     */
+    @RequestMapping(value = "ruleList", method = RequestMethod.POST)
+    @ApiOperation(value = "规则列表")
+    public AjaxMessage< List<WarningRule>> ruleList(
+            @ApiParam(value = "客户id", required = true) String customerNo,
+            @ApiParam(value = "水表档案号", required = true) String meterNo) {
+        List<WarningRule>result=warningRuleService.getList(meterNo);
+        return new AjaxMessage<>(ResultStatus.OK, result);
+    }
+
+}

+ 27 - 0
water_query_api/src/main/java/com/zcxk/dao/MeterReadRecordMapper.java

@@ -0,0 +1,27 @@
+package com.zcxk.dao;
+
+
+import com.zcxk.dto.UseWaterDto;
+import com.zcxk.entity.MeterReadRecord;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Mapper
+public interface MeterReadRecordMapper {
+    int insertSelective(MeterReadRecord record);
+
+    int updateByPrimaryKeySelective(MeterReadRecord record);
+
+    Double getDeviceVolume(@Param("deviceId") Long deviceId, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
+
+    List<UseWaterDto> getRealTimeUseWater(@Param("deviceId") Long deviceId, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
+
+    List<UseWaterDto> getUseWaterByMonth(@Param("deviceId") Long deviceId, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
+
+    Integer queryNotWaterConsumptionDays(@Param("deviceId") Long deviceId, @Param("dateCreate") LocalDateTime dateCreate);
+
+    Boolean exceedConsumption(@Param("deviceId") Long deviceId, @Param("date") Integer date);
+}

+ 24 - 0
water_query_api/src/main/java/com/zcxk/dao/WarningMessageMapper.java

@@ -0,0 +1,24 @@
+package com.zcxk.dao;
+
+import com.zcxk.dto.WarningMessageDto;
+import com.zcxk.dto.WarningMessageStatusDto;
+import com.zcxk.entity.WarningMessage;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface WarningMessageMapper {
+    int insertSelective(WarningMessage record);
+
+    int updateByPrimaryKeySelective(WarningMessage record);
+
+    int batchInsert(@Param("list") List<WarningMessage> list);
+
+    WarningMessage findById(@Param("id") Integer id);
+
+    List<WarningMessageDto> getList(@Param("deviceId") Long deviceId, @Param("date") Integer date);
+
+    List<WarningMessageStatusDto> getDateStatus(@Param("deviceId") Long deviceId, @Param("date") Integer date);
+}

+ 18 - 0
water_query_api/src/main/java/com/zcxk/dao/WarningRuleMapper.java

@@ -0,0 +1,18 @@
+package com.zcxk.dao;
+
+import com.zcxk.entity.WarningRule;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface WarningRuleMapper {
+    int insertSelective(WarningRule record);
+
+    int updateByPrimaryKeySelective(WarningRule record);
+
+    List<WarningRule> getList(@Param("deviceId") Long deviceId);
+
+    int findByWarningTypeUnique(@Param("deviceId") Long deviceId, @Param("warningType") Integer warningType);
+}

+ 18 - 0
water_query_api/src/main/java/com/zcxk/dto/UseWaterAnalyze.java

@@ -0,0 +1,18 @@
+package com.zcxk.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UseWaterAnalyze {
+    private List<UseWaterDto> list;
+
+    private Double averageUseVolume;
+
+    private Double totalUseVolume;
+
+    private UseWaterDto maxUseWater;
+
+    private UseWaterDto minUseWater;
+}

+ 14 - 0
water_query_api/src/main/java/com/zcxk/dto/UseWaterDto.java

@@ -0,0 +1,14 @@
+package com.zcxk.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class UseWaterDto {
+
+    @ApiModelProperty(value = "用水量", position = 1)
+    private Double useVolume = 0.0;
+
+    @ApiModelProperty(value = "日期", position = 2)
+    private Integer date;
+}

+ 20 - 0
water_query_api/src/main/java/com/zcxk/dto/WarningMessageDto.java

@@ -0,0 +1,20 @@
+package com.zcxk.dto;
+
+
+import com.zcxk.entity.WarningMessage;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class WarningMessageDto extends WarningMessage {
+    @ApiModelProperty(value="预警类型 1:较上日用水量激增30% 2:连续无用水量超过7天")
+    private Integer warningType;
+
+    @ApiModelProperty(value="反馈状态 0:待反馈 1:已确认无异常 2:已反馈信息")
+    private Integer feedbackStatus;
+
+    @ApiModelProperty(value="反馈内容")
+    private String feedbackContent;
+}

+ 13 - 0
water_query_api/src/main/java/com/zcxk/dto/WarningMessageStatusDto.java

@@ -0,0 +1,13 @@
+package com.zcxk.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class WarningMessageStatusDto {
+    @ApiModelProperty(value="反馈状态 0:待反馈 1:已确认无异常 2:已反馈信息")
+    private Integer feedbackStatus;
+
+    @ApiModelProperty(value="天")
+    private Integer days;
+}

+ 97 - 0
water_query_api/src/main/java/com/zcxk/entity/MeterReadRecord.java

@@ -0,0 +1,97 @@
+package com.zcxk.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@ApiModel(value="com.zcxk.water.entity.MeterReadRecord")
+@Data
+public class MeterReadRecord {
+
+    @ApiModelProperty(value="主键")
+    private Long id;
+
+    @ApiModelProperty(value="读表日期")
+    private Integer readDate;
+
+    @ApiModelProperty(value="站点")
+    private Integer siteId;
+
+    @ApiModelProperty(value="场景")
+    private Integer sysId;
+
+    @ApiModelProperty(value="省")
+    private Integer province;
+
+    @ApiModelProperty(value="市")
+    private Integer city;
+
+    @ApiModelProperty(value="区")
+    private Integer region;
+
+    @ApiModelProperty(value="小区")
+    private Integer community;
+
+    @ApiModelProperty(value="客户")
+    private Integer customerId;
+
+    @ApiModelProperty(value="集中器")
+    private Integer concentratorId;
+
+    @ApiModelProperty(value="采集器")
+    private Integer collectorId;
+
+    @ApiModelProperty(value="建筑")
+    private Integer buildingId;
+
+    @ApiModelProperty(value="安装地址")
+    private String location;
+
+    @ApiModelProperty(value="设备类型")
+    private Integer deviceTypeId;
+
+    @ApiModelProperty(value="设备id")
+    private Long deviceId;
+
+    @ApiModelProperty(value="节点编号")
+    private String deviceNo;
+
+    @ApiModelProperty(value="电子号")
+    private String meterNo;
+
+    @ApiModelProperty(value="档案号")
+    private String meterFileNo;
+
+    @ApiModelProperty(value="读表时间")
+    private LocalDateTime readTime;
+
+    @ApiModelProperty(value="读表状态")
+    private String readStatus;
+
+    @ApiModelProperty(value="读表数据")
+    private String readData;
+
+    @ApiModelProperty(value="最近有效数据")
+    private String lastValid;
+
+    @ApiModelProperty(value="距离上次的消耗")
+    private BigDecimal lastCost;
+
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @ApiModelProperty(value="更新时间")
+    private LocalDateTime dateUpdate;
+
+    @ApiModelProperty(value="创建人")
+    private String createBy;
+
+    @ApiModelProperty(value="更新人")
+    private String updateBy;
+}

+ 36 - 0
water_query_api/src/main/java/com/zcxk/entity/WarningMessage.java

@@ -0,0 +1,36 @@
+package com.zcxk.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * (WarningMessage)实体类
+ *
+ * @author hym
+ * @since 2021-01-13 16:02:28
+ */
+@Data
+@ApiModel
+public class WarningMessage implements Serializable {
+    private static final long serialVersionUID = 399193511116761251L;
+    @ApiModelProperty(value = "")
+    private Integer id;
+    @ApiModelProperty(value = "")
+    private Integer warningLogId;
+    @ApiModelProperty(value = "")
+    private String content;
+    @ApiModelProperty(value = "")
+    private Integer status;
+    @ApiModelProperty(value = "")
+    private String createBy;
+    @ApiModelProperty(value = "")
+    private Date dateCreate;
+    @ApiModelProperty(value = "")
+    private String updateBy;
+    @ApiModelProperty(value = "")
+    private Date dateUpdate;
+}

+ 45 - 0
water_query_api/src/main/java/com/zcxk/entity/WarningRule.java

@@ -0,0 +1,45 @@
+package com.zcxk.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * (WarningRule)实体类
+ *
+ * @author hym
+ * @since 2021-01-13 15:59:10
+ */
+@Data
+@ApiModel
+public class WarningRule implements Serializable {
+    private static final long serialVersionUID = 257631501208107042L;
+    /**
+     * id
+     */
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * 设备id
+     */
+    @ApiModelProperty(value = "设备id")
+    private Long deviceId;
+    /**
+     * 预警类型
+     */
+    @ApiModelProperty(value = "预警类型")
+    private Integer warningType;
+    @ApiModelProperty(value = "")
+    private Integer status;
+    @ApiModelProperty(value = "")
+    private String createBy;
+    @ApiModelProperty(value = "")
+    private Date dateCreate;
+    @ApiModelProperty(value = "")
+    private String updateBy;
+    @ApiModelProperty(value = "")
+    private Date dateUpdate;
+}

+ 14 - 0
water_query_api/src/main/java/com/zcxk/service/MeterReadRecordService.java

@@ -0,0 +1,14 @@
+package com.zcxk.service;
+
+import com.zcxk.dto.UseWaterAnalyze;
+import com.zcxk.dto.UseWaterDto;
+
+import java.util.List;
+
+public interface MeterReadRecordService {
+    List<UseWaterDto> getRealTimeUseWater(String meterNo, Integer period);
+
+    UseWaterAnalyze getThirtyDaysUseWater(String meterNo);
+
+    UseWaterAnalyze getUseWaterAnalyze(String meterNo);
+}

+ 20 - 0
water_query_api/src/main/java/com/zcxk/service/WarningMessageService.java

@@ -0,0 +1,20 @@
+package com.zcxk.service;
+
+import com.zcxk.dto.WarningMessageDto;
+import com.zcxk.dto.WarningMessageStatusDto;
+import com.zcxk.entity.WarningMessage;
+
+import java.util.List;
+
+
+/**
+ * (WarningMessage)表服务接口
+ *
+ * @author hym
+ * @since 2021-01-13 16:02:27
+ */
+public interface WarningMessageService {
+
+    List<WarningMessageStatusDto> getDateStatus(Integer date, String meterNo);
+    List<WarningMessageDto> getList(Integer date, String meterNo);
+}

+ 21 - 0
water_query_api/src/main/java/com/zcxk/service/WarningRuleService.java

@@ -0,0 +1,21 @@
+package com.zcxk.service;
+
+import com.zcxk.entity.WarningRule;
+
+import java.util.List;
+
+
+/**
+ * (WarningRule)表服务接口
+ *
+ * @author hym
+ * @since 2021-01-13 15:59:09
+ */
+public interface WarningRuleService {
+
+
+
+    int addRule(Integer warningType, String meterNo,String userName);
+
+    List<WarningRule> getList(String meterNo);
+}

+ 108 - 0
water_query_api/src/main/java/com/zcxk/service/impl/MeterReadRecordServiceImpl.java

@@ -0,0 +1,108 @@
+package com.zcxk.service.impl;
+
+import com.zcxk.dao.MeterReadRecordMapper;
+import com.zcxk.dto.UseWaterAnalyze;
+import com.zcxk.dto.UseWaterDto;
+import com.zcxk.service.MeterReadRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class MeterReadRecordServiceImpl implements MeterReadRecordService {
+    @Autowired
+    private MeterReadRecordMapper meterReadRecordMapper;
+
+    @Override
+    public List<UseWaterDto> getRealTimeUseWater(String meterNo, Integer period) {
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
+        LocalDateTime startDateTime = LocalDateTime.now().plusDays(-period);
+        LocalDateTime endDateTime = LocalDateTime.now().plusDays(-1);
+        Integer startDate = Integer.valueOf(startDateTime.format(df));
+        Integer endDate = Integer.valueOf(endDateTime.format(df));
+        Long deviceId=0L;
+        List<UseWaterDto> list =  meterReadRecordMapper.getRealTimeUseWater(deviceId, startDate, endDate);
+        //填充缺失月份数据
+        fillDataForCertainMonths(period,list,startDateTime,df);
+
+
+        //合并
+
+        return list;
+    }
+    //补齐某些月份无数据
+     private void fillDataForCertainMonths(Integer period,List<UseWaterDto>list,
+                                                        LocalDateTime startDateTime, DateTimeFormatter df){
+        List<UseWaterDto> newList = new ArrayList<>();
+        for (int i = 0; i < period; i++) {
+            LocalDateTime nextDateTime = startDateTime.plusDays(i);
+            Integer times = Integer.valueOf(nextDateTime.format(df));
+
+            long count = list.stream().filter(ite -> ite.getDate().equals(times)).count();
+            if(count == 0){
+                UseWaterDto newUseWaterDto = new UseWaterDto();
+                newUseWaterDto.setUseVolume(0.0);
+                newUseWaterDto.setDate(times);
+                newList.add(newUseWaterDto);
+            }
+        }
+         list.addAll(newList);
+         //重新按天排序
+         list.sort(Comparator.comparing(UseWaterDto::getDate));
+
+    }
+    @Override
+    public UseWaterAnalyze getThirtyDaysUseWater(String meterNo) {
+        List<UseWaterDto> list = getRealTimeUseWater(meterNo, 30);
+        UseWaterAnalyze useWaterAnalyze = new UseWaterAnalyze();
+        useWaterAnalyze.setList(list);
+        statisticsOnWaterUsage(useWaterAnalyze,list);
+
+        return useWaterAnalyze;
+    }
+    void statisticsOnWaterUsage(UseWaterAnalyze useWaterAnalyze,List<UseWaterDto> list){
+        //总数
+        double sum = list.stream().mapToDouble(UseWaterDto::getUseVolume).sum();
+        useWaterAnalyze.setTotalUseVolume(new BigDecimal(sum).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+        // 平均数
+        double average = list.stream().mapToDouble(UseWaterDto::getUseVolume).average().getAsDouble();
+        //保留两位小数
+        BigDecimal b = new BigDecimal(average);
+        useWaterAnalyze.setAverageUseVolume(b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+
+        // 最大值
+        double max = list.stream().mapToDouble(UseWaterDto::getUseVolume).max().getAsDouble();
+        UseWaterDto maxUseWaterDto = list.stream().filter(ite -> ite.getUseVolume().equals(max)).collect(Collectors.toList()).get(0);
+        useWaterAnalyze.setMaxUseWater(maxUseWaterDto);
+
+        // 最小值
+        double min = list.stream().mapToDouble(UseWaterDto::getUseVolume).min().getAsDouble();
+        UseWaterDto mixUseWaterDto = list.stream().filter(ite -> ite.getUseVolume().equals(min)).collect(Collectors.toList()).get(0);
+        useWaterAnalyze.setMinUseWater(mixUseWaterDto);
+
+    }
+    @Override
+    public UseWaterAnalyze getUseWaterAnalyze(String meterNo) {
+        Long deviceId=0l;
+        UseWaterAnalyze useWaterAnalyze = new UseWaterAnalyze();
+        //近12月
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMM");
+        LocalDateTime startDateTime = LocalDateTime.now().plusMonths(-12).with(TemporalAdjusters.firstDayOfMonth());
+        LocalDateTime endDateTime = LocalDateTime.now().plusMonths(-1).with(TemporalAdjusters.lastDayOfMonth());
+        Integer startDate = Integer.valueOf(startDateTime.format(df));
+        Integer endDate = Integer.valueOf(endDateTime.format(df));
+        List<UseWaterDto> list = meterReadRecordMapper.getUseWaterByMonth(deviceId, startDate, endDate);
+        //填充缺失月份数据
+        fillDataForCertainMonths(12,list,startDateTime,dateTimeFormatter);
+        useWaterAnalyze.setList(list);
+        statisticsOnWaterUsage(useWaterAnalyze,list);
+        return useWaterAnalyze;
+    }
+}

+ 35 - 0
water_query_api/src/main/java/com/zcxk/service/impl/WarningMessageServiceImpl.java

@@ -0,0 +1,35 @@
+package com.zcxk.service.impl;
+
+import com.zcxk.dao.WarningMessageMapper;
+import com.zcxk.dto.WarningMessageDto;
+import com.zcxk.dto.WarningMessageStatusDto;
+import com.zcxk.entity.WarningMessage;
+import com.zcxk.service.WarningMessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * (WarningMessage表)服务实现类
+ *
+ * @author hym
+ * @since 2021-01-13 16:02:28
+ */
+@Service("warningMessageService")
+public class WarningMessageServiceImpl implements WarningMessageService {
+    private WarningMessageMapper warningMessageMapper;
+
+
+    @Override
+    public List<WarningMessageStatusDto> getDateStatus(Integer date, String meterNo) {
+        Long deviceId=0l;
+        return warningMessageMapper.getDateStatus(deviceId, date);
+    }
+
+    @Override
+    public List<WarningMessageDto> getList(Integer date, String meterNo) {
+        Long deviceId=0l;
+        return warningMessageMapper.getList(deviceId, date);
+    }
+}

+ 53 - 0
water_query_api/src/main/java/com/zcxk/service/impl/WarningRuleServiceImpl.java

@@ -0,0 +1,53 @@
+package com.zcxk.service.impl;
+
+import com.zcxk.dao.WarningRuleMapper;
+import com.zcxk.entity.WarningRule;
+import com.zcxk.service.WarningRuleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * (WarningRule表)服务实现类
+ *
+ * @author hym
+ * @since 2021-01-13 15:59:11
+ */
+@Service("warningRuleService")
+public class WarningRuleServiceImpl implements WarningRuleService {
+    @Autowired
+    private WarningRuleMapper warningRuleMapper;
+
+
+    @Override
+    public int addRule(Integer warningType, String meterNo,String userName) {
+        Long deviceId=0l;
+
+            int resultDeviceNo = warningRuleMapper.findByWarningTypeUnique(deviceId, warningType);
+            if (resultDeviceNo > 0) {
+                throw new RuntimeException("该预警类型已经存在");
+            }
+
+            WarningRule warningRule = new WarningRule();
+            warningRule.setDeviceId(deviceId);
+            warningRule.setWarningType(warningType);
+            warningRule.setStatus(1);
+            warningRule.setCreateBy(userName);
+            warningRule.setDateCreate(new Date());
+            warningRule.setUpdateBy(userName);
+            warningRule.setDateUpdate(new Date());
+            warningRuleMapper.insertSelective(warningRule);
+
+        return 0;
+    }
+
+    @Override
+    public List<WarningRule> getList(String meterNo) {
+        Long deviceId=0l;
+        return warningRuleMapper.getList(deviceId);
+    }
+
+}

+ 331 - 0
water_query_api/src/main/resources/mapper/MeterReadRecordMapper.xml

@@ -0,0 +1,331 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zcxk.dao.MeterReadRecordMapper">
+  <resultMap id="BaseResultMap" type="com.zcxk.entity.MeterReadRecord">
+    <!--@mbg.generated-->
+    <id column="id" property="id" />
+    <result column="read_date" property="readDate" />
+    <result column="site_id" property="siteId" />
+    <result column="sys_id" property="sysId" />
+    <result column="province" property="province" />
+    <result column="city" property="city" />
+    <result column="region" property="region" />
+    <result column="community" property="community" />
+    <result column="customer_id" property="customerId" />
+    <result column="concentrator_id" property="concentratorId" />
+    <result column="collector_id" property="collectorId" />
+    <result column="building_id" property="buildingId" />
+    <result column="location" property="location" />
+    <result column="device_type_id" property="deviceTypeId" />
+    <result column="device_id" property="deviceId" />
+    <result column="device_no" property="deviceNo" />
+    <result column="meter_no" property="meterNo" />
+    <result column="meter_file_no" property="meterFileNo" />
+    <result column="read_time" property="readTime" />
+    <result column="read_status" property="readStatus" />
+    <result column="read_data" property="readData" />
+    <result column="last_valid" property="lastValid" />
+    <result column="last_cost" property="lastCost" />
+    <result column="status" property="status" />
+    <result column="date_create" property="dateCreate" />
+    <result column="date_update" property="dateUpdate" />
+    <result column="create_by" property="createBy" />
+    <result column="update_by" property="updateBy" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, read_date, site_id, sys_id, province, city, region, community, customer_id, concentrator_id, 
+    collector_id, building_id, `location`, device_type_id, device_id, device_no, meter_no, 
+    meter_file_no, read_time, read_status, read_data, last_valid, last_cost, `status`, 
+    date_create, date_update, create_by, update_by
+  </sql>
+  <insert id="insertSelective" parameterType="com.zcxk.entity.MeterReadRecord">
+    <!--@mbg.generated-->
+    insert into sc_meter_read_record
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="readDate != null">
+        read_date,
+      </if>
+      <if test="siteId != null">
+        site_id,
+      </if>
+      <if test="sysId != null">
+        sys_id,
+      </if>
+      <if test="province != null">
+        province,
+      </if>
+      <if test="city != null">
+        city,
+      </if>
+      <if test="region != null">
+        region,
+      </if>
+      <if test="community != null">
+        community,
+      </if>
+      <if test="customerId != null">
+        customer_id,
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id,
+      </if>
+      <if test="collectorId != null">
+        collector_id,
+      </if>
+      <if test="buildingId != null">
+        building_id,
+      </if>
+      <if test="location != null">
+        `location`,
+      </if>
+      <if test="deviceTypeId != null">
+        device_type_id,
+      </if>
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="deviceNo != null">
+        device_no,
+      </if>
+      <if test="meterNo != null">
+        meter_no,
+      </if>
+      <if test="meterFileNo != null">
+        meter_file_no,
+      </if>
+      <if test="readTime != null">
+        read_time,
+      </if>
+      <if test="readStatus != null">
+        read_status,
+      </if>
+      <if test="readData != null">
+        read_data,
+      </if>
+      <if test="lastValid != null">
+        last_valid,
+      </if>
+      <if test="lastCost != null">
+        last_cost,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id},
+      </if>
+      <if test="readDate != null">
+        #{readDate},
+      </if>
+      <if test="siteId != null">
+        #{siteId},
+      </if>
+      <if test="sysId != null">
+        #{sysId},
+      </if>
+      <if test="province != null">
+        #{province},
+      </if>
+      <if test="city != null">
+        #{city},
+      </if>
+      <if test="region != null">
+        #{region},
+      </if>
+      <if test="community != null">
+        #{community},
+      </if>
+      <if test="customerId != null">
+        #{customerId},
+      </if>
+      <if test="concentratorId != null">
+        #{concentratorId},
+      </if>
+      <if test="collectorId != null">
+        #{collectorId},
+      </if>
+      <if test="buildingId != null">
+        #{buildingId},
+      </if>
+      <if test="location != null">
+        #{location},
+      </if>
+      <if test="deviceTypeId != null">
+        #{deviceTypeId},
+      </if>
+      <if test="deviceId != null">
+        #{deviceId},
+      </if>
+      <if test="deviceNo != null">
+        #{deviceNo},
+      </if>
+      <if test="meterNo != null">
+        #{meterNo},
+      </if>
+      <if test="meterFileNo != null">
+        #{meterFileNo},
+      </if>
+      <if test="readTime != null">
+        #{readTime},
+      </if>
+      <if test="readStatus != null">
+        #{readStatus},
+      </if>
+      <if test="readData != null">
+        #{readData},
+      </if>
+      <if test="lastValid != null">
+        #{lastValid},
+      </if>
+      <if test="lastCost != null">
+        #{lastCost},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.water.entity.MeterReadRecord">
+    <!--@mbg.generated-->
+    update sc_meter_read_record
+    <set>
+      <if test="readDate != null">
+        read_date = #{readDate},
+      </if>
+      <if test="siteId != null">
+        site_id = #{siteId},
+      </if>
+      <if test="sysId != null">
+        sys_id = #{sysId},
+      </if>
+      <if test="province != null">
+        province = #{province},
+      </if>
+      <if test="city != null">
+        city = #{city},
+      </if>
+      <if test="region != null">
+        region = #{region},
+      </if>
+      <if test="community != null">
+        community = #{community},
+      </if>
+      <if test="customerId != null">
+        customer_id = #{customerId},
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id = #{concentratorId},
+      </if>
+      <if test="collectorId != null">
+        collector_id = #{collectorId},
+      </if>
+      <if test="buildingId != null">
+        building_id = #{buildingId},
+      </if>
+      <if test="location != null">
+        `location` = #{location},
+      </if>
+      <if test="deviceTypeId != null">
+        device_type_id = #{deviceTypeId},
+      </if>
+      <if test="deviceId != null">
+        device_id = #{deviceId},
+      </if>
+      <if test="deviceNo != null">
+        device_no = #{deviceNo},
+      </if>
+      <if test="meterNo != null">
+        meter_no = #{meterNo},
+      </if>
+      <if test="meterFileNo != null">
+        meter_file_no = #{meterFileNo},
+      </if>
+      <if test="readTime != null">
+        read_time = #{readTime},
+      </if>
+      <if test="readStatus != null">
+        read_status = #{readStatus},
+      </if>
+      <if test="readData != null">
+        read_data = #{readData},
+      </if>
+      <if test="lastValid != null">
+        last_valid = #{lastValid},
+      </if>
+      <if test="lastCost != null">
+        last_cost = #{lastCost},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+    <select id="getDeviceVolume" resultType="java.lang.Double">
+      select ifnull(sum(last_cost),0) from sc_meter_read_record
+      where status = 1 and device_id = #{deviceId} and
+      read_date <![CDATA[ >= ]]> #{startDate} and read_date <![CDATA[ <= ]]> #{endDate}
+    </select>
+    <select id="getRealTimeUseWater" resultType="com.zcxk.dto.UseWaterDto">
+      select read_date as date,last_cost as use_volume from sc_meter_read_record
+      where status = 1 and device_id = #{deviceId} and
+      read_date <![CDATA[ >= ]]> #{startDate} and read_date <![CDATA[ <= ]]> #{endDate}
+      order by read_data asc
+    </select>
+  <select id="getUseWaterByMonth" resultType="com.zcxk.dto.UseWaterDto">
+    SELECT DATE_FORMAT(read_date,'%Y%m') as date,sum(last_cost) as useVolume FROM sc_meter_read_record
+    where status = 1 and device_id = #{deviceId}
+    and read_date <![CDATA[ >= ]]> #{startDate} and read_date <![CDATA[ <= ]]> #{endDate}
+    GROUP BY  date
+  </select>
+
+  <select id="queryNotWaterConsumptionDays" resultType="java.lang.Integer">
+    SELECT to_days(DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day) ,'%Y%m%d')) - to_days(read_date) FROM sc_meter_read_record WHERE device_id = #{deviceId} and last_cost > 0 ORDER BY read_date DESC LIMIT 1
+  </select>
+
+  <select id="exceedConsumption" resultType="java.lang.Boolean">
+    SELECT last_cost > (read_data * 0.3) FROM sc_meter_read_record WHERE device_id = #{deviceId} and read_date = #{date}
+  </select>
+</mapper>

+ 138 - 0
water_query_api/src/main/resources/mapper/WarningMessageMapper.xml

@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zcxk.dao.WarningMessageMapper">
+  <resultMap id="BaseResultMap" type="com.zcxk.entity.WarningMessage">
+    <!--@mbg.generated-->
+    <!--@Table sc_warning_message-->
+    <id column="id" property="id" />
+    <result column="warning_log_id" property="warningLogId" />
+    <result column="content" property="content" />
+    <result column="status" property="status" />
+    <result column="create_by" property="createBy" />
+    <result column="date_create" property="dateCreate" />
+    <result column="update_by" property="updateBy" />
+    <result column="date_update" property="dateUpdate" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, warning_log_id, content, `status`, create_by, date_create, update_by, date_update
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zcxk.entity.WarningMessage" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_warning_message
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="warningLogId != null">
+        warning_log_id,
+      </if>
+      <if test="content != null">
+        content,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="warningLogId != null">
+        #{warningLogId},
+      </if>
+      <if test="content != null">
+        #{content},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.entity.WarningMessage">
+    <!--@mbg.generated-->
+    update sc_warning_message
+    <set>
+      <if test="warningLogId != null">
+        warning_log_id = #{warningLogId},
+      </if>
+      <if test="content != null">
+        content = #{content},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_warning_message
+    (warning_log_id, content, `status`, create_by, date_create, update_by, date_update
+      )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.warningLogId}, #{item.content}, #{item.status}, #{item.createBy}, #{item.dateCreate}, 
+        #{item.updateBy}, #{item.dateUpdate})
+    </foreach>
+  </insert>
+
+  <select id="findById" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List" /> from sc_warning_message where status = 1 and id = #{id}
+  </select>
+
+  <select id="getList" resultType="com.zcxk.dto.WarningMessageDto">
+    SELECT
+    swm.*,
+    swl.warning_type,
+    swl.feedback_status,
+    swl.feedback_content
+    FROM sc_warning_message swm
+    LEFT JOIN sc_warning_log swl on(swl.id = swm.warning_log_id)
+    WHERE swm.`status` = 1 and swl.status = 1 and swl.device_id = #{deviceId}
+    <if test="date != null"> and date_format(swm.date_create, '%Y%m%d') = #{date}</if>
+    order by swm.date_create desc
+  </select>
+
+  <select id="getDateStatus" resultType="com.zcxk.dto.WarningMessageStatusDto">
+    SELECT
+    date_format(swm.date_create, '%Y%m%d') as days,
+    if(SUM(if(swl.feedback_status=0,1,0))>0,0,1) as feedback_status
+    FROM sc_warning_message swm
+    LEFT JOIN sc_warning_log swl on(swl.id = swm.warning_log_id)
+    WHERE swm.`status` = 1 and swl.status = 1 and swl.device_id = #{deviceId}
+    and   date_format(swm.date_create, '%Y%m') = #{date}
+    GROUP BY days
+    order by days asc
+  </select>
+</mapper>

+ 108 - 0
water_query_api/src/main/resources/mapper/WarningRuleMapper.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zcxk.dao.WarningRuleMapper">
+  <resultMap id="BaseResultMap" type="com.zcxk.entity.WarningRule">
+    <!--@mbg.generated-->
+    <!--@Table sc_warning_rule-->
+    <id column="id" property="id" />
+    <result column="device_id" property="deviceId" />
+    <result column="warning_type" property="warningType" />
+    <result column="status" property="status" />
+    <result column="create_by" property="createBy" />
+    <result column="date_create" property="dateCreate" />
+    <result column="update_by" property="updateBy" />
+    <result column="date_update" property="dateUpdate" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, device_id, warning_type, `status`, create_by, date_create, update_by, date_update
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zcxk.entity.WarningRule" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_warning_rule
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="warningType != null">
+        warning_type,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="deviceId != null">
+        #{deviceId},
+      </if>
+      <if test="warningType != null">
+        #{warningType},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.entity.WarningRule">
+    <!--@mbg.generated-->
+    update sc_warning_rule
+    <set>
+      <if test="deviceId != null">
+        device_id = #{deviceId},
+      </if>
+      <if test="warningType != null">
+        warning_type = #{warningType},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+
+  <select id="getList" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"/> from sc_warning_rule where status = 1
+    <if test="deviceId != null"> and device_id = #{deviceId} </if>
+
+  </select>
+
+  <select id="findByWarningTypeUnique" resultType="int">
+    select count(1) from sc_warning_rule where status = 1 and device_id = #{deviceId} and warning_type = #{warningType}
+  </select>
+</mapper>