hym %!s(int64=4) %!d(string=hai) anos
pai
achega
0b4522074d
Modificáronse 28 ficheiros con 1329 adicións e 0 borrados
  1. 71 0
      src/main/java/com/zoniot/ccrc/controller/applets/AppletsUserController.java
  2. 78 0
      src/main/java/com/zoniot/ccrc/controller/applets/StatisticsController.java
  3. 68 0
      src/main/java/com/zoniot/ccrc/controller/applets/WarningMessageController.java
  4. 58 0
      src/main/java/com/zoniot/ccrc/controller/applets/WarningRuleController.java
  5. 98 0
      src/main/java/com/zoniot/ccrc/dao/GridManagementMapper.java
  6. 25 0
      src/main/java/com/zoniot/ccrc/dao/WarningMessageMapper.java
  7. 2 0
      src/main/java/com/zoniot/ccrc/dao/WarningRuleMapper.java
  8. 55 0
      src/main/java/com/zoniot/ccrc/dto/ClientUserDto.java
  9. 18 0
      src/main/java/com/zoniot/ccrc/dto/UseWaterAnalyze.java
  10. 14 0
      src/main/java/com/zoniot/ccrc/dto/UseWaterDto.java
  11. 20 0
      src/main/java/com/zoniot/ccrc/dto/WarningMessageDto.java
  12. 13 0
      src/main/java/com/zoniot/ccrc/dto/WarningMessageStatusDto.java
  13. 24 0
      src/main/java/com/zoniot/ccrc/dto/WaterPriceDto.java
  14. 64 0
      src/main/java/com/zoniot/ccrc/entity/ClientUser.java
  15. 63 0
      src/main/java/com/zoniot/ccrc/entity/CustomerWaterStage.java
  16. 75 0
      src/main/java/com/zoniot/ccrc/entity/GridManagement.java
  17. 42 0
      src/main/java/com/zoniot/ccrc/entity/WarningMessage.java
  18. 17 0
      src/main/java/com/zoniot/ccrc/service/AppletsService.java
  19. 30 0
      src/main/java/com/zoniot/ccrc/service/AppletsServiceImpl.java
  20. 17 0
      src/main/java/com/zoniot/ccrc/service/StatisticsService.java
  21. 28 0
      src/main/java/com/zoniot/ccrc/service/WarningMessageService.java
  22. 7 0
      src/main/java/com/zoniot/ccrc/service/WarningRuleService.java
  23. 30 0
      src/main/java/com/zoniot/ccrc/service/impl/AppletsServiceImpl.java
  24. 112 0
      src/main/java/com/zoniot/ccrc/service/impl/StatisticsServiceImpl.java
  25. 70 0
      src/main/java/com/zoniot/ccrc/service/impl/WarningMessageServiceImpl.java
  26. 37 0
      src/main/java/com/zoniot/ccrc/service/impl/WarningRuleServiceImpl.java
  27. 189 0
      src/main/resources/mapper/GridManagementMapper.xml
  28. 4 0
      src/main/resources/mapper/WarningRuleMapper.xml

+ 71 - 0
src/main/java/com/zoniot/ccrc/controller/applets/AppletsUserController.java

@@ -0,0 +1,71 @@
+package com.zoniot.ccrc.controller.applets;
+
+import com.zoniot.ccrc.commom.model.AjaxMessage;
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.commom.model.ResultStatus;
+import com.zoniot.ccrc.dto.ClientUserDto;
+import com.zoniot.ccrc.entity.ClientUser;
+import com.zoniot.ccrc.service.AppletsService;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigInteger;
+
+@Controller
+public class AppletsUserController {
+    @Autowired
+    private AppletsService appletsService;
+    @ResponseBody
+    @GetMapping("/getAccountInfo")
+    @ApiOperation(value = "获取默认客户信息实时数据(计费系统)")
+    public AjaxMessage<ClientUserDto> getDeviceInfoReal(
+
+    ) {
+        ClientUserDto accountInfoDto = appletsService.findUserAmountByIdReal();
+
+        return new AjaxMessage<>(ResultStatus.OK, accountInfoDto);
+    }
+    @ResponseBody
+    @GetMapping("/getAccountInfoPage")
+    @ApiOperation(value = "用户信息分页(计费系统)")
+    public AjaxMessage<Pagination<ClientUser>> getAccountInfoPage(
+            @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
+            @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize) {
+
+        Pagination<ClientUser> pageInfo = appletsService.getAccountInfoPage(pageNum, pageSize);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+    @ResponseBody
+    @PostMapping("/setDefault")
+    @ApiOperation(value = "设置默认(计费系统)")
+    public AjaxMessage setDefault(
+            @ApiParam(value = "id", required = true) @RequestParam(required = true) BigInteger id
+    ) {
+        appletsService.setDefault(id);
+        return new AjaxMessage<>(ResultStatus.OK);
+    }
+    @PostMapping("bindingMobile")
+    @ApiOperation(value = "绑定手机号码")
+    public AjaxMessage bindingMobile(
+            @ApiParam(value = "加密数据", required = true) @RequestParam(required = true) String encryptedData,
+            @ApiParam(value = "加密算法的初始向量", required = true) @RequestParam(required = true) String iv,
+            @ApiParam(value = "code", required = true) @RequestParam(required = true) String code,
+            HttpServletRequest httpServletRequest
+    ) {
+
+        int result=appletsService.bindingMobile(encryptedData, iv, code);
+        if(result==0){
+            return new AjaxMessage<>(ResultStatus.OK);
+        }else{
+            return new AjaxMessage(ResultStatus.ERROR);
+        }
+
+    }
+}

+ 78 - 0
src/main/java/com/zoniot/ccrc/controller/applets/StatisticsController.java

@@ -0,0 +1,78 @@
+package com.zoniot.ccrc.controller.applets;
+
+
+import com.zoniot.ccrc.commom.model.AjaxMessage;
+import com.zoniot.ccrc.commom.model.ResultStatus;
+import com.zoniot.ccrc.dto.UseWaterAnalyze;
+import com.zoniot.ccrc.dto.UseWaterDto;
+import com.zoniot.ccrc.dto.WaterPriceDto;
+import com.zoniot.ccrc.service.StatisticsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
+
+@Slf4j
+@Controller
+@ResponseBody
+@RequestMapping("statistics")
+@Api(tags = "统计分析")
+public class StatisticsController {
+
+
+    @Autowired
+    private StatisticsService statisticsService;
+
+    @ResponseBody
+    @GetMapping("/getRealTimeUseWater")
+    @ApiOperation(value = "实时用水量")
+    public AjaxMessage<List<UseWaterDto>> getRealTimeUseWater(
+            @ApiParam(value = "查询范围,7:近7日,30:近30日", required = true) @RequestParam(required = true) Integer period
+    ) {
+      List<UseWaterDto> list = statisticsService.getRealTimeUseWater(period);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @ResponseBody
+    @GetMapping("/getThirtyDaysUseWater")
+    @ApiOperation(value = "用水量近30天")
+    public AjaxMessage<UseWaterAnalyze> getThirtyDaysUseWater()
+     {
+        UseWaterAnalyze useWaterAnalyze =statisticsService.getThirtyDaysUseWater();
+
+
+
+        return new AjaxMessage<>(ResultStatus.OK, useWaterAnalyze);
+    }
+
+    @ResponseBody
+    @GetMapping("/getUseWaterAnalyze")
+    @ApiOperation(value = "用水分析")
+    public AjaxMessage<UseWaterAnalyze> getUseWaterAnalyze(
+
+    ) {
+        UseWaterAnalyze useWaterAnalyze = statisticsService.getUseWaterAnalyze();
+        return new AjaxMessage<>(ResultStatus.OK, useWaterAnalyze);
+    }
+
+    @ResponseBody
+    @GetMapping("/waterPriceQuery")
+    @ApiOperation(value = "水价查询")
+    public AjaxMessage<WaterPriceDto> waterPriceQuery(
+            @ApiParam(value = "客户编号", required = true) @RequestParam(required = true) Long deviceId,
+            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam(required = true)  String date
+    ) {
+        WaterPriceDto waterPriceDto = statisticsService.waterPriceQuery(deviceId, date);
+        return new AjaxMessage<>(ResultStatus.OK, waterPriceDto);
+    }
+
+
+}

+ 68 - 0
src/main/java/com/zoniot/ccrc/controller/applets/WarningMessageController.java

@@ -0,0 +1,68 @@
+package com.zoniot.ccrc.controller.applets;
+
+
+import com.zoniot.ccrc.commom.model.AjaxMessage;
+import com.zoniot.ccrc.commom.model.ResultStatus;
+import com.zoniot.ccrc.dto.WarningMessageDto;
+import com.zoniot.ccrc.dto.WarningMessageStatusDto;
+import com.zoniot.ccrc.service.WarningMessageService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@Controller
+@ResponseBody
+@RequestMapping("warningMessage")
+@Api( tags = "预警消息")
+public class WarningMessageController {
+
+    @Autowired
+    private WarningMessageService warningMessageService;
+
+
+
+
+    @ResponseBody
+    @GetMapping("/getPage")
+    @ApiOperation(value = "预警消息分页")
+    public AjaxMessage<List<WarningMessageDto>> getPage(
+            @ApiParam(value = "开始日期 格式:yyyyMMdd", required = false) @RequestParam(required = false)  Integer date
+            ) {
+
+        List<WarningMessageDto> pageInfo =warningMessageService.getPage(date);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
+
+    @ResponseBody
+    @GetMapping("/getDateStatus")
+    @ApiOperation(value = "预警消息日期状态")
+    public AjaxMessage<List<WarningMessageStatusDto>> getDateStatus(
+            @ApiParam(value = "日期 格式:yyyyMM", required = true) @RequestParam(required = true) Integer date
+            ) {
+
+        List<WarningMessageStatusDto> list = warningMessageService.getDateStatus(date);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @ResponseBody
+    @PostMapping("/feedback")
+    @ApiOperation(value = "反馈")
+    public AjaxMessage feedback(
+            @ApiParam(value = "id", required = true) @RequestParam(required = true) Integer id,
+            @ApiParam(value = "反馈状态 0:待反馈 1:已确认无异常 2:已反馈信息", required = true) @RequestParam(required = true) Integer feedbackStatus,
+            @ApiParam(value = "反馈内容", required = false) @RequestParam(required = false) String feedbackContent
+    ){
+        warningMessageService.feedback(id,feedbackStatus,feedbackContent);
+        return new AjaxMessage<>(ResultStatus.OK);
+    }
+
+
+}

+ 58 - 0
src/main/java/com/zoniot/ccrc/controller/applets/WarningRuleController.java

@@ -0,0 +1,58 @@
+package com.zoniot.ccrc.controller.applets;
+
+
+import com.zoniot.ccrc.commom.model.AjaxMessage;
+import com.zoniot.ccrc.commom.model.ResultStatus;
+import com.zoniot.ccrc.entity.WarningRule;
+import com.zoniot.ccrc.service.WarningRuleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Slf4j
+@Controller
+@ResponseBody
+@RequestMapping("warningRule")
+@Api( tags = "预警规则")
+public class WarningRuleController {
+
+    @Autowired
+    private WarningRuleService warningRuleService;
+
+
+    @ResponseBody
+    @GetMapping("/getList")
+    @ApiOperation(value = "规则列表")
+    public AjaxMessage<List<WarningRule>> getList(){
+
+        List<WarningRule> pageInfo = warningRuleService.getRuleList();
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
+    @ResponseBody
+    @PostMapping("/add")
+    @ApiOperation(value = "添加")
+    public AjaxMessage bindingAccount(
+            @ApiParam(value = "预警类型 1:较上日用水量激增30% 2:连续无用水量超过7天", required = true) @RequestParam(required = true) Integer warningType
+    ) {
+        ;
+        return new AjaxMessage<>(ResultStatus.OK,warningRuleService.addRule(warningType));
+    }
+
+
+    @ResponseBody
+    @DeleteMapping("/del")
+    @ApiOperation(value = "删除")
+    public AjaxMessage del(
+            @ApiParam(value = "id", required = true) @RequestParam(required = true) Integer id
+    ){
+        warningRuleService.delWaringRule(id);
+        return new AjaxMessage<>(ResultStatus.OK);
+    }
+}

+ 98 - 0
src/main/java/com/zoniot/ccrc/dao/GridManagementMapper.java

@@ -0,0 +1,98 @@
+package com.zoniot.ccrc.dao;
+
+import com.zoniot.ccrc.dto.GridUser;
+import com.zoniot.ccrc.entity.Building;
+import com.zoniot.ccrc.entity.Community;
+import com.zoniot.ccrc.entity.Device;
+import com.zoniot.ccrc.entity.GridManagement;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * (GridManagement)表数据库访问层
+ *
+ * @author hym
+ * @since 2021-02-23 11:48:07
+ */
+@Mapper
+public interface GridManagementMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    GridManagement selectById(Integer id);
+
+
+    /**
+     * 查询全部
+     *
+     * @return 对象列表
+     */
+    List<GridManagement> selectAll();
+
+    /**
+     * 通过实体作为筛选条件查询
+     *
+     * @param gridManagement 实例对象
+     * @return 对象列表
+     */
+    List<GridManagement> selectList(GridManagement gridManagement);
+
+    /**
+     * 新增数据
+     *
+     * @param gridManagement 实例对象
+     * @return 影响行数
+     */
+    int insert(GridManagement gridManagement);
+
+    /**
+     * 批量新增
+     *
+     * @param gridManagements 实例对象的集合
+     * @return 影响行数
+     */
+    int batchInsert(@Param("gridManagements") List<GridManagement> gridManagements);
+
+    /**
+     * 修改数据
+     *
+     * @param gridManagement 实例对象
+     * @return 影响行数
+     */
+    int update(GridManagement gridManagement);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+    /**
+     * 查询总数据数
+     *
+     * @return 数据总数
+     */
+    int count();
+
+    List<GridUser> selectGirdUserInfo(@Param("username") String username,
+                                      @Param("orgId") Integer orgId,
+                                      @Param("roleId") Integer roleId,
+                                      @Param("siteId") Integer siteId);
+
+    List<Community> getCommutityByOrg(@Param("orgId") Integer orgId);
+
+    List<Building> getBuildingByCommutity(@Param("commutityId") Integer commutityId);
+
+    List<Device> getDevices(@Param("buildingId") Integer buildingId,
+                            @Param("userId") Integer userId, @Param("address") String address);
+
+    GridManagement getByDeviceId(@Param("deviceId") Long deviceId);
+}

+ 25 - 0
src/main/java/com/zoniot/ccrc/dao/WarningMessageMapper.java

@@ -0,0 +1,25 @@
+package com.zoniot.ccrc.dao;
+
+
+import com.zoniot.ccrc.dto.WarningMessageDto;
+import com.zoniot.ccrc.dto.WarningMessageStatusDto;
+import com.zoniot.ccrc.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);
+}

+ 2 - 0
src/main/java/com/zoniot/ccrc/dao/WarningRuleMapper.java

@@ -13,4 +13,6 @@ public interface WarningRuleMapper {
     int updateByPrimaryKeySelective(WarningRule record);
 
     List<WarningRule> getList(@Param("type") Integer type);
+
+    List<WarningRule> getListByDeviceId(Long id);
 }

+ 55 - 0
src/main/java/com/zoniot/ccrc/dto/ClientUserDto.java

@@ -0,0 +1,55 @@
+package com.zoniot.ccrc.dto;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import com.zoniot.ccrc.entity.ClientUser;
+import com.zoniot.ccrc.entity.CustomerWaterStage;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * @program: water-query
+ * @description: 客户信息描述
+ * @author: Yangyang.Wang
+ * @create: 2020-04-26 14:43
+ **/
+@Data
+public class ClientUserDto extends ClientUser {
+    @ApiModelProperty(value = "本月用水量")
+    private BigDecimal useAmount;
+
+    @JsonIgnore
+    @ApiModelProperty(value = "用水性质ID")
+    private BigInteger waterpropertyid;
+    @ApiModelProperty(value = "阶梯类型(0 不启用 1 月阶梯  2 年阶梯)")
+    private  Integer laddertype;
+    @ApiModelProperty(value = "阶梯级别(0 不启用 1 一阶  2 二阶 3 3阶 4 4阶)")
+    private  Integer ladderlevel;
+    private  String laddertypename;
+    private  String  ladderlevelname;
+    @JsonIgnore
+    private  Double availableamount1;
+    @JsonIgnore
+    private  Double availableamount2;
+    @JsonIgnore
+    private  Double availableamount3;
+    @JsonIgnore
+    private  Double availableamount4;
+    @JsonIgnore
+    private  Double availablel1;
+    @JsonIgnore
+    private  Double availablel2;
+    @JsonIgnore
+    private  Double availablel3;
+    @JsonIgnore
+    private  Double availablel4;
+
+
+
+    @ApiModelProperty(value = "用水阶段")
+    private List<CustomerWaterStage> waterStages;
+}

+ 18 - 0
src/main/java/com/zoniot/ccrc/dto/UseWaterAnalyze.java

@@ -0,0 +1,18 @@
+package com.zoniot.ccrc.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
src/main/java/com/zoniot/ccrc/dto/UseWaterDto.java

@@ -0,0 +1,14 @@
+package com.zoniot.ccrc.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
src/main/java/com/zoniot/ccrc/dto/WarningMessageDto.java

@@ -0,0 +1,20 @@
+package com.zoniot.ccrc.dto;
+
+
+import com.zoniot.ccrc.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
src/main/java/com/zoniot/ccrc/dto/WarningMessageStatusDto.java

@@ -0,0 +1,13 @@
+package com.zoniot.ccrc.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;
+}

+ 24 - 0
src/main/java/com/zoniot/ccrc/dto/WaterPriceDto.java

@@ -0,0 +1,24 @@
+package com.zoniot.ccrc.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class WaterPriceDto {
+    @ApiModelProperty(value = "用水量", position = 1)
+    private Double useVolume = 0.0;
+
+    @ApiModelProperty(value = "水费", position = 2)
+    private BigDecimal WaterPrice;
+
+    @ApiModelProperty(value = "图片url", position = 3)
+    private String pictureUrl;
+
+    @ApiModelProperty(value = "开始时间", position = 4)
+    private Integer startDate;
+
+    @ApiModelProperty(value = "结束时间", position = 5)
+    private Integer endDate;
+}

+ 64 - 0
src/main/java/com/zoniot/ccrc/entity/ClientUser.java

@@ -0,0 +1,64 @@
+package com.zoniot.ccrc.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+
+@ApiModel(value="com.zcxk.water.entity.ClientUser")
+@Data
+public class ClientUser implements Serializable {
+
+    @ApiModelProperty(value="主键")
+    private BigInteger id;
+
+    @ApiModelProperty(value="手机号码")
+    private String mobilePhone;
+
+    @ApiModelProperty(value="客户名称")
+    private String username;
+
+    @ApiModelProperty(value = "客户编号")
+    private String userNumber;
+
+    @ApiModelProperty(value = "客户地址")
+    private String address;
+
+    @ApiModelProperty(value="是否默认 0:否 1:是")
+    private Integer isDefault;
+
+    @ApiModelProperty(value="水司ID",position = 11)
+    private BigInteger customerId;
+
+    @ApiModelProperty(value="WebChatID")
+    private String openid;
+
+    @ApiModelProperty(value="siteId")
+    private BigInteger siteId;
+
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建者")
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="修改者")
+    private String updateBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="修改时间")
+    private LocalDateTime dateUpdate;
+    private String label;
+    private String emergencyContact;
+    private String emergencyContactPhoneNumber;
+}

+ 63 - 0
src/main/java/com/zoniot/ccrc/entity/CustomerWaterStage.java

@@ -0,0 +1,63 @@
+package com.zoniot.ccrc.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@ApiModel(value="客户用水阶段")
+@Data
+public class CustomerWaterStage {
+
+    @ApiModelProperty(value="id")
+    private Integer id;
+
+
+    @ApiModelProperty(value="客户id")
+    private Integer customerId;
+
+
+    @JsonIgnore
+    @ApiModelProperty(value="类型 1:居民 2:单位 3:特殊",hidden = true)
+    private Integer type;
+
+    @ApiModelProperty(value="阶段名称")
+    private String name;
+
+
+    @ApiModelProperty(value="最小值")
+    private BigDecimal minValue;
+
+
+    @ApiModelProperty(value="最大值")
+    private BigDecimal maxValue;
+
+    @ApiModelProperty(value="阶段水价")
+    private BigDecimal waterPrice;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态",hidden = true)
+    private Integer status;
+
+    @ApiModelProperty(value = "阶梯类型 1:非阶梯 2:月阶梯 3:年阶梯", position = 1)
+    private Integer laddertype;
+
+    @JsonIgnore
+    @ApiModelProperty(value="null",hidden = true)
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="null",hidden = true)
+    private LocalDateTime createDate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="null",hidden = true)
+    private String updateBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="null",hidden = true)
+    private LocalDateTime updateDate;
+}

+ 75 - 0
src/main/java/com/zoniot/ccrc/entity/GridManagement.java

@@ -0,0 +1,75 @@
+package com.zoniot.ccrc.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * (GridManagement)实体类
+ *
+ * @author hym
+ * @since 2021-02-23 11:48:07
+ */
+@Data
+@ApiModel
+public class GridManagement implements Serializable {
+    private static final long serialVersionUID = 458833882113660963L;
+    /**
+     * 主键
+     */
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+    /**
+     * 设备id
+     */
+    @ApiModelProperty(value = "设备id")
+    private Long deviceId;
+    /**
+     * 客户编号
+     */
+    @ApiModelProperty(value = "客户编号")
+    private String customerNo;
+    /**
+     * 客户手机
+     */
+    @ApiModelProperty(value = "客户手机")
+    private String customerPhone;
+    /**
+     * 客户名称
+     */
+    @ApiModelProperty(value = "客户名称")
+    private String customerName;
+    /**
+     * 标签
+     */
+    @ApiModelProperty(value = "标签")
+    private String label;
+    /**
+     * 紧急联系人
+     */
+    @ApiModelProperty(value = "紧急联系人")
+    private String emergencyContact;
+    /**
+     * 紧急联系人电话
+     */
+    @ApiModelProperty(value = "紧急联系人电话")
+    private String emergencyContactPhoneNumber;
+    /**
+     * 用户id
+     */
+    @ApiModelProperty(value = "用户id")
+    private Integer userId;
+    @ApiModelProperty(value = "水表电子号")
+    private String waterMeterNo;
+    @ApiModelProperty(value = "水表档案号")
+    private String waterMeterFileNo;
+    @ApiModelProperty(value = "机构")
+    private String orgName;
+    @ApiModelProperty(value = "建筑")
+    private String bulidingName;
+    @ApiModelProperty(value = "安装地址")
+    private String address;
+
+}

+ 42 - 0
src/main/java/com/zoniot/ccrc/entity/WarningMessage.java

@@ -0,0 +1,42 @@
+package com.zoniot.ccrc.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@ApiModel(value="com-zcxk-water-entity-WarningMessage")
+@Data
+public class WarningMessage {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    @ApiModelProperty(value="")
+    private Integer warningLogId;
+
+    @ApiModelProperty(value="")
+    private String content;
+
+    @ApiModelProperty(value="")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="",hidden = true)
+    private String createBy;
+
+    @ApiModelProperty(value="")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="",hidden = true)
+    private String updateBy;
+
+    @JsonIgnore
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="",hidden = true)
+    private LocalDateTime dateUpdate;
+}

+ 17 - 0
src/main/java/com/zoniot/ccrc/service/AppletsService.java

@@ -0,0 +1,17 @@
+package com.zoniot.ccrc.service;
+
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.dto.ClientUserDto;
+import com.zoniot.ccrc.entity.ClientUser;
+
+import java.math.BigInteger;
+
+public interface AppletsService {
+    ClientUserDto findUserAmountByIdReal();
+
+    Pagination<ClientUser> getAccountInfoPage(int pageNum, int pageSize);
+
+    int bindingMobile(String encryptedData, String iv, String code);
+
+    void setDefault(BigInteger id);
+}

+ 30 - 0
src/main/java/com/zoniot/ccrc/service/AppletsServiceImpl.java

@@ -0,0 +1,30 @@
+package com.zoniot.ccrc.service;
+
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.dto.ClientUserDto;
+import com.zoniot.ccrc.entity.ClientUser;
+import org.springframework.stereotype.Service;
+
+import java.math.BigInteger;
+@Service
+public class AppletsServiceImpl implements AppletsService {
+    @Override
+    public ClientUserDto findUserAmountByIdReal() {
+        return null;
+    }
+
+    @Override
+    public Pagination<ClientUser> getAccountInfoPage(int pageNum, int pageSize) {
+        return null;
+    }
+
+    @Override
+    public int bindingMobile(String encryptedData, String iv, String code) {
+        return 0;
+    }
+
+    @Override
+    public void setDefault(BigInteger id) {
+
+    }
+}

+ 17 - 0
src/main/java/com/zoniot/ccrc/service/StatisticsService.java

@@ -0,0 +1,17 @@
+package com.zoniot.ccrc.service;
+
+import com.zoniot.ccrc.dto.UseWaterAnalyze;
+import com.zoniot.ccrc.dto.UseWaterDto;
+import com.zoniot.ccrc.dto.WaterPriceDto;
+
+import java.util.List;
+
+public interface StatisticsService {
+    List<UseWaterDto> getRealTimeUseWater(Integer period);
+
+    UseWaterAnalyze getThirtyDaysUseWater();
+
+    UseWaterAnalyze getUseWaterAnalyze();
+
+    WaterPriceDto waterPriceQuery(Long deviceId, String date);
+}

+ 28 - 0
src/main/java/com/zoniot/ccrc/service/WarningMessageService.java

@@ -0,0 +1,28 @@
+package com.zoniot.ccrc.service;
+
+
+
+import com.zoniot.ccrc.dto.WarningMessageDto;
+import com.zoniot.ccrc.dto.WarningMessageStatusDto;
+import com.zoniot.ccrc.entity.WarningMessage;
+
+import java.util.List;
+
+public interface WarningMessageService {
+
+
+    int insertSelective(WarningMessage record);
+
+    int updateByPrimaryKeySelective(WarningMessage record);
+
+    int batchInsert(List<WarningMessage> list);
+
+    List<WarningMessageDto> getPage(Integer date);
+
+    List<WarningMessageStatusDto> getDateStatus(Integer date);
+
+    void feedback(Integer id, Integer feedbackStatus, String feedbackContent);
+}
+
+
+

+ 7 - 0
src/main/java/com/zoniot/ccrc/service/WarningRuleService.java

@@ -3,6 +3,8 @@ package com.zoniot.ccrc.service;
 
 import com.zoniot.ccrc.entity.WarningRule;
 
+import java.util.List;
+
 public interface WarningRuleService{
 
 
@@ -10,4 +12,9 @@ public interface WarningRuleService{
 
     int updateByPrimaryKeySelective(WarningRule record);
 
+    List<WarningRule> getRuleList();
+
+    int addRule(Integer warningType);
+
+    void delWaringRule(Integer id);
 }

+ 30 - 0
src/main/java/com/zoniot/ccrc/service/impl/AppletsServiceImpl.java

@@ -0,0 +1,30 @@
+package com.zoniot.ccrc.service.impl;
+
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.dto.ClientUserDto;
+import com.zoniot.ccrc.entity.ClientUser;
+import com.zoniot.ccrc.service.AppletsService;
+
+import java.math.BigInteger;
+
+public class AppletsServiceImpl implements AppletsService {
+    @Override
+    public ClientUserDto findUserAmountByIdReal() {
+        return null;
+    }
+
+    @Override
+    public Pagination<ClientUser> getAccountInfoPage(int pageNum, int pageSize) {
+        return null;
+    }
+
+    @Override
+    public int bindingMobile(String encryptedData, String iv, String code) {
+        return 0;
+    }
+
+    @Override
+    public void setDefault(BigInteger id) {
+
+    }
+}

+ 112 - 0
src/main/java/com/zoniot/ccrc/service/impl/StatisticsServiceImpl.java

@@ -0,0 +1,112 @@
+package com.zoniot.ccrc.service.impl;
+
+import com.zoniot.ccrc.dto.UseWaterAnalyze;
+import com.zoniot.ccrc.dto.UseWaterDto;
+import com.zoniot.ccrc.dto.WaterPriceDto;
+import com.zoniot.ccrc.service.StatisticsService;
+import org.springframework.stereotype.Service;
+
+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;
+
+@Service
+public class StatisticsServiceImpl implements StatisticsService {
+    @Override
+    public List<UseWaterDto> getRealTimeUseWater(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;//warningRuleService.getDeviceId(meterNo,customerNo);;
+        List<UseWaterDto> list = null;// meterReadRecordMapper.getRealTimeUseWater(deviceId, startDate, endDate);
+        //填充缺失月份数据
+        fillDataForCertainMonths(period,list,startDateTime,df,0);
+        return null;
+    }
+    private void fillDataForCertainMonths(Integer period,List<UseWaterDto>list,
+                                          LocalDateTime startDateTime, DateTimeFormatter df,Integer type){
+        List<UseWaterDto> newList = new ArrayList<>();
+        for (int i = 0; i < period; i++) {
+            LocalDateTime nextDateTime = startDateTime.plusMonths(i);
+            if(type==0){
+                nextDateTime = startDateTime.plusDays(i);
+            }else if(type==1){
+                nextDateTime = startDateTime.plusMonths(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));
+
+    }
+    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 getThirtyDaysUseWater() {
+        List<UseWaterDto> list = getRealTimeUseWater( 30);
+        UseWaterAnalyze useWaterAnalyze = new UseWaterAnalyze();
+        useWaterAnalyze.setList(list);
+        statisticsOnWaterUsage(useWaterAnalyze,list);
+        return useWaterAnalyze;
+    }
+
+    @Override
+    public UseWaterAnalyze getUseWaterAnalyze() {
+        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 = null;//meterReadRecordMapper.getUseWaterByMonth(deviceId, startDate, endDate);
+        //填充缺失月份数据
+        fillDataForCertainMonths(12,list,startDateTime,dateTimeFormatter,1);
+        useWaterAnalyze.setList(list);
+        statisticsOnWaterUsage(useWaterAnalyze,list);
+        return useWaterAnalyze;
+    }
+
+    @Override
+    public WaterPriceDto waterPriceQuery(Long deviceId, String date) {
+        return null;
+    }
+}

+ 70 - 0
src/main/java/com/zoniot/ccrc/service/impl/WarningMessageServiceImpl.java

@@ -0,0 +1,70 @@
+package com.zoniot.ccrc.service.impl;
+
+
+import com.zoniot.ccrc.commom.utils.UserUtil;
+import com.zoniot.ccrc.dao.WarningLogMapper;
+import com.zoniot.ccrc.dao.WarningMessageMapper;
+import com.zoniot.ccrc.dto.LoginUser;
+import com.zoniot.ccrc.dto.WarningMessageDto;
+import com.zoniot.ccrc.dto.WarningMessageStatusDto;
+import com.zoniot.ccrc.entity.WarningLog;
+import com.zoniot.ccrc.entity.WarningMessage;
+import com.zoniot.ccrc.service.WarningMessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Service
+public class WarningMessageServiceImpl implements WarningMessageService {
+
+    @Resource
+    private WarningMessageMapper warningMessageMapper;
+    @Resource
+    private WarningLogMapper warningLogMapper;
+
+
+    @Override
+    public int insertSelective(WarningMessage record) {
+        return warningMessageMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(WarningMessage record) {
+        return warningMessageMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public int batchInsert(List<WarningMessage> list) {
+        return warningMessageMapper.batchInsert(list);
+    }
+
+    @Override
+    public List<WarningMessageDto> getPage(Integer date) {
+       return null;//warningMessageMapper.getList(deviceDto.getDeviceId(), date);
+    }
+
+    @Override
+    public List<WarningMessageStatusDto> getDateStatus(Integer date) {
+        return null;//warningMessageMapper.getDateStatus(deviceDto.getDeviceId(), date);
+    }
+
+    @Override
+    public void feedback(Integer id, Integer feedbackStatus, String feedbackContent) {
+        LoginUser loginClientUser = UserUtil.getCurrentUser();
+        WarningMessage warningMessage = warningMessageMapper.findById(id);
+
+        WarningLog warningLog = new WarningLog();
+        warningLog.setId(warningMessage.getWarningLogId());
+        warningLog.setFeedbackStatus(feedbackStatus);
+        warningLog.setFeedbackContent(feedbackContent);
+        warningLog.setUpdateBy(loginClientUser.getUsername());
+        warningLog.setDateUpdate(LocalDateTime.now());
+        warningLogMapper.updateByPrimaryKeySelective(warningLog);
+    }
+}
+
+
+

+ 37 - 0
src/main/java/com/zoniot/ccrc/service/impl/WarningRuleServiceImpl.java

@@ -7,6 +7,9 @@ import com.zoniot.ccrc.service.WarningRuleService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
 
 @Service
 public class WarningRuleServiceImpl implements WarningRuleService {
@@ -24,4 +27,38 @@ public class WarningRuleServiceImpl implements WarningRuleService {
         return warningRuleMapper.updateByPrimaryKeySelective(record);
     }
 
+    @Override
+    public List<WarningRule> getRuleList() {
+        Long id=0l;
+
+        return  warningRuleMapper.getListByDeviceId(id);
+    }
+
+    @Override
+    public int addRule(Integer warningType) {
+        Long deviceId=0l;;
+
+
+        WarningRule warningRule = new WarningRule();
+        warningRule.setDeviceId(deviceId);
+        warningRule.setWarningType(warningType);
+        warningRule.setStatus(1);
+       // warningRule.setCreateBy(userName);
+        warningRule.setDateCreate(LocalDateTime.now());
+       // warningRule.setUpdateBy(userName);
+        warningRule.setDateUpdate(LocalDateTime.now());
+        warningRuleMapper.insertSelective(warningRule);
+        return 0;
+    }
+
+    @Override
+    public void delWaringRule(Integer id) {
+        WarningRule warningRule = new WarningRule();
+        warningRule.setId(id);
+        warningRule.setStatus(0);
+       // warningRule.setUpdateBy(userName);
+        warningRule.setDateUpdate(LocalDateTime.now());
+        warningRuleMapper.updateByPrimaryKeySelective(warningRule);
+    }
+
 }

+ 189 - 0
src/main/resources/mapper/GridManagementMapper.xml

@@ -0,0 +1,189 @@
+<?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.bz.smart_city.dao.GridManagementMapper">
+    <!-- 结果集 -->
+    <resultMap type="com.bz.smart_city.entity.GridManagement" id="GridManagementMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="deviceId" column="device_id" jdbcType="INTEGER"/>
+        <result property="customerNo" column="customer_no" jdbcType="VARCHAR"/>
+        <result property="customerPhone" column="customer_phone" jdbcType="VARCHAR"/>
+        <result property="customerName" column="customer_name" jdbcType="VARCHAR"/>
+        <result property="label" column="label" jdbcType="VARCHAR"/>
+        <result property="emergencyContact" column="emergency_contact" jdbcType="VARCHAR"/>
+        <result property="emergencyContactPhoneNumber" column="emergency_contact_phone_number" jdbcType="VARCHAR"/>
+        <result property="userId" column="user_id" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <!-- 基本字段 -->
+    <sql id="Base_Column_List">
+        id, device_id, customer_no, customer_phone, customer_name, label, emergency_contact, emergency_contact_phone_number, user_id    </sql>
+
+    <!-- 查询单个 -->
+    <select id="selectById" resultMap="GridManagementMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_grid_management
+        where id = #{id}
+    </select>
+
+
+    <!-- 查询全部 -->
+    <select id="selectAll" resultMap="GridManagementMap">
+        select
+        <include refid="Base_Column_List"/>
+        from sc_grid_management
+    </select>
+
+    <!--通过实体作为筛选条件查询-->
+    <select id="selectList" resultMap="GridManagementMap">
+        select
+         a.*,b.water_meter_no,b.water_meter_file_no,b.loc_desc address,c.name bulidingName,
+         e.name orgName
+        from sc_grid_management a join sc_device b on a.device_id=b.id
+        join sc_building c on b.building_id=c.id join sc_community d on c.community =d.id
+        left join sc_organization e on d.org_id=e.id
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="deviceId != null">
+                and device_id = #{deviceId}
+            </if>
+            <if test="customerNo != null and customerNo != ''">
+                and customer_no = #{customerNo}
+            </if>
+            <if test="customerPhone != null and customerPhone != ''">
+                and customer_phone = #{customerPhone}
+            </if>
+            <if test="customerName != null and customerName != ''">
+                and customer_name LIKE concat('%',#{customerName},'%')
+            </if>
+            <if test="label != null and label != ''">
+                and label = #{label}
+            </if>
+            <if test="emergencyContact != null and emergencyContact != ''">
+                and emergency_contact = #{emergencyContact}
+            </if>
+            <if test="emergencyContactPhoneNumber != null and emergencyContactPhoneNumber != ''">
+                and emergency_contact_phone_number = #{emergencyContactPhoneNumber}
+            </if>
+            <if test="userId != null">
+                and user_id = #{userId}
+            </if>
+            <if test="address != null and address !=''">
+                and b.loc_desc LIKE concat('%',#{address},'%')
+            </if>
+            <if test="waterMeterNo != null and waterMeterNo !=''">
+                and ( b.water_meter_no LIKE concat('%',#{waterMeterNo},'%') or
+                      b.water_meter_file_no LIKE concat('%',#{waterMeterNo},'%'))
+            </if>
+        </where>
+    </select>
+
+    <!-- 新增所有列 -->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into sc_grid_management(id, device_id, customer_no, customer_phone, customer_name, label,
+                                       emergency_contact, emergency_contact_phone_number, user_id)
+        values (#{id}, #{deviceId}, #{customerNo}, #{customerPhone}, #{customerName}, #{label}, #{emergencyContact},
+                #{emergencyContactPhoneNumber}, #{userId})
+    </insert>
+
+    <!-- 批量新增 -->
+    <insert id="batchInsert">
+        insert into sc_grid_management(id, device_id, customer_no, customer_phone, customer_name, label,
+        emergency_contact, emergency_contact_phone_number, user_id)
+        values
+        <foreach collection="gridManagements" item="item" index="index" separator=",">
+            (
+            #{item.id}, #{item.deviceId}, #{item.customerNo}, #{item.customerPhone}, #{item.customerName},
+            #{item.label}, #{item.emergencyContact}, #{item.emergencyContactPhoneNumber}, #{item.userId} )
+        </foreach>
+    </insert>
+
+    <!-- 通过主键修改数据 -->
+    <update id="update">
+        update sc_grid_management
+        <set>
+            <if test="deviceId != null">
+                device_id = #{deviceId},
+            </if>
+            <if test="customerNo != null and customerNo != ''">
+                customer_no = #{customerNo},
+            </if>
+            <if test="customerPhone != null and customerPhone != ''">
+                customer_phone = #{customerPhone},
+            </if>
+            <if test="customerName != null and customerName != ''">
+                customer_name = #{customerName},
+            </if>
+            <if test="label != null and label != ''">
+                label = #{label},
+            </if>
+            <if test="emergencyContact != null and emergencyContact != ''">
+                emergency_contact = #{emergencyContact},
+            </if>
+            <if test="emergencyContactPhoneNumber != null and emergencyContactPhoneNumber != ''">
+                emergency_contact_phone_number = #{emergencyContactPhoneNumber},
+            </if>
+            <if test="userId != null">
+                user_id = #{userId},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from sc_grid_management
+        where id = #{id}
+    </delete>
+
+    <!-- 总数 -->
+    <select id="count" resultType="int">
+        select count(*)
+        from sc_grid_management
+    </select>
+    <select id="selectGirdUserInfo" resultType="com.bz.smart_city.grid.GridUser">
+        select  b.id orgId,a.id,username,mobile_phone,a.name,b.name org_name,b.address,ifnull(c.peoples,0) peoples from
+         sc_site_user ssu   join    sc_user a on ssu.user_id=a.id
+         join sc_organization b on ssu.organ_id=b.id
+         join sc_user_role d on d.uid=a.id join sc_role e on e.id=d.rid
+         left join (select count(*)peoples,user_id from sc_grid_management group by user_id)c
+         on a.id=c.user_id
+        <where>
+                d.status=1
+            <if test="username != null and username!='' ">
+                and username LIKE concat('%',#{username},'%')
+            </if>
+            <if test="orgId != null  ">
+                and ssu.organ_id = #{orgId}
+            </if>
+            <if test="roleId != null  ">
+                and e.id = #{roleId}
+            </if>
+            <if test="siteId != null  ">
+                and ssu.site_id = #{siteId}
+            </if>
+       </where>
+        order by ssu.create_date desc
+    </select>
+    <select id="getCommutityByOrg" resultType="com.bz.smart_city.entity.Community">
+        select * from sc_community a
+        where a.org_id=#{orgId} and status=1
+    </select>
+    <select id="getBuildingByCommutity" resultType="com.bz.smart_city.entity.Building">
+        select * from sc_building where community=#{commutityId} and status=1
+    </select>
+    <select id="getDevices" resultType="com.bz.smart_city.entity.Device">
+        select * from sc_device where building_id=#{buildingId} and
+         id not in (select distinct device_id from sc_grid_management) and status=1
+        <if test="address != null  ">
+            and loc_desc LIKE concat('%',#{address},'%')
+        </if>
+    </select>
+
+    <select id="getByDeviceId" resultMap="GridManagementMap">
+        select * from sc_grid_management where device_id = #{deviceId}
+    </select>
+</mapper>

+ 4 - 0
src/main/resources/mapper/WarningRuleMapper.xml

@@ -99,4 +99,8 @@
   <select id="getList" resultMap="BaseResultMap">
     select <include refid="Base_Column_List"/> from sc_warning_rule where status = 1 and warning_type = #{type}
   </select>
+    <select id="getListByDeviceId" resultType="com.zoniot.ccrc.entity.WarningRule">
+      select <include refid="Base_Column_List"/> from sc_warning_rule where status = 1
+      <if test="deviceId != null"> and device_id = #{deviceId} </if>
+    </select>
 </mapper>