hym 4 年之前
父节点
当前提交
7df4db2887
共有 31 个文件被更改,包括 536 次插入70 次删除
  1. 2 13
      src/main/java/com/zoniot/ccrc/controller/GridManagementController.java
  2. 2 4
      src/main/java/com/zoniot/ccrc/controller/applets/AppletsUserController.java
  3. 6 6
      src/main/java/com/zoniot/ccrc/controller/applets/StatisticsController.java
  4. 2 1
      src/main/java/com/zoniot/ccrc/controller/applets/WarningMessageController.java
  5. 9 1
      src/main/java/com/zoniot/ccrc/controller/applets/WarningRuleController.java
  6. 2 2
      src/main/java/com/zoniot/ccrc/controller/system/CommunityManagerController.java
  7. 9 0
      src/main/java/com/zoniot/ccrc/controller/system/SiteController.java
  8. 4 0
      src/main/java/com/zoniot/ccrc/dao/DeviceMapper.java
  9. 2 2
      src/main/java/com/zoniot/ccrc/dao/GridManagementMapper.java
  10. 7 0
      src/main/java/com/zoniot/ccrc/dao/SiteMapper.java
  11. 1 1
      src/main/java/com/zoniot/ccrc/dao/WarningRuleMapper.java
  12. 1 1
      src/main/java/com/zoniot/ccrc/dto/ClientUserDto.java
  13. 20 0
      src/main/java/com/zoniot/ccrc/dto/FeeTypeDto.java
  14. 31 0
      src/main/java/com/zoniot/ccrc/dto/LadderInfoDto.java
  15. 53 0
      src/main/java/com/zoniot/ccrc/dto/PriceInfo.java
  16. 67 0
      src/main/java/com/zoniot/ccrc/entity/Customer.java
  17. 2 2
      src/main/java/com/zoniot/ccrc/entity/GridManagement.java
  18. 3 0
      src/main/java/com/zoniot/ccrc/service/SiteService.java
  19. 6 1
      src/main/java/com/zoniot/ccrc/service/StatisticsService.java
  20. 9 1
      src/main/java/com/zoniot/ccrc/service/impl/AppletsServiceImpl.java
  21. 5 2
      src/main/java/com/zoniot/ccrc/service/impl/GridManagementServiceImpl.java
  22. 10 3
      src/main/java/com/zoniot/ccrc/service/impl/SiteServiceImpl.java
  23. 94 12
      src/main/java/com/zoniot/ccrc/service/impl/StatisticsServiceImpl.java
  24. 5 2
      src/main/java/com/zoniot/ccrc/service/impl/WarningMessageServiceImpl.java
  25. 6 2
      src/main/java/com/zoniot/ccrc/service/impl/WarningRuleServiceImpl.java
  26. 2 2
      src/main/resources/application-dev.properties
  27. 3 0
      src/main/resources/mapper/DeviceMapper.xml
  28. 6 10
      src/main/resources/mapper/GridManagementMapper.xml
  29. 23 0
      src/main/resources/mapper/SiteMapper.xml
  30. 138 0
      src/main/resources/mapper/WarningMessageMapper.xml
  31. 6 2
      src/main/resources/mapper/WarningRuleMapper.xml

+ 2 - 13
src/main/java/com/zoniot/ccrc/controller/GridManagementController.java

@@ -69,18 +69,7 @@ public class GridManagementController {
 
     }
 
-    /**
-     * 删除一条数据
-     *
-     * @param gridManagement 参数对象
-     * @return Response对象
-     */
-    @RequestMapping(value = "delete", method = RequestMethod.POST)
-    @ApiOperation(value = "查询设施配置列表")
-    public AjaxMessage<Integer> delete(@ApiParam(value = "设置配置", required = true) @RequestBody GridManagement gridManagement) {
-        int result = gridManagementService.deleteById(gridManagement.getId());
-        return new AjaxMessage<>(ResultStatus.OK, result);
-    }
+   
 
 
     /**
@@ -98,7 +87,7 @@ public class GridManagementController {
         GridManagement gridManagement = new GridManagement();
         gridManagement.setAddress(adddress);
         gridManagement.setUserId(userId);
-        gridManagement.setWaterMeterNo(waterNo);
+        gridManagement.setMeterNo(waterNo);
         gridManagement.setCustomerName(name);
         PageHelper.startPage(pageNum, pageSize);
         List<GridManagement> gridManagements = gridManagementService.selectList(gridManagement);

+ 2 - 4
src/main/java/com/zoniot/ccrc/controller/applets/AppletsUserController.java

@@ -10,15 +10,13 @@ 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 org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigInteger;
 
 @Controller
+@RequestMapping("appletUser")
 public class AppletsUserController {
     @Autowired
     private AppletsService appletsService;

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

@@ -3,6 +3,7 @@ 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.PriceInfo;
 import com.zoniot.ccrc.dto.UseWaterAnalyze;
 import com.zoniot.ccrc.dto.UseWaterDto;
 import com.zoniot.ccrc.dto.WaterPriceDto;
@@ -24,7 +25,7 @@ import java.util.List;
 @Controller
 @ResponseBody
 @RequestMapping("statistics")
-@Api(tags = "统计分析")
+@Api(tags = "小程序统计分析")
 public class StatisticsController {
 
 
@@ -66,12 +67,11 @@ public class StatisticsController {
     @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
+    public AjaxMessage<PriceInfo> waterPriceQuery(
+
     ) {
-        WaterPriceDto waterPriceDto = statisticsService.waterPriceQuery(deviceId, date);
-        return new AjaxMessage<>(ResultStatus.OK, waterPriceDto);
+        PriceInfo priceInfo = statisticsService.waterPriceQuery();
+        return new AjaxMessage<>(ResultStatus.OK, priceInfo);
     }
 
 

+ 2 - 1
src/main/java/com/zoniot/ccrc/controller/applets/WarningMessageController.java

@@ -5,6 +5,7 @@ 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.StatisticsService;
 import com.zoniot.ccrc.service.WarningMessageService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -20,7 +21,7 @@ import java.util.List;
 @Controller
 @ResponseBody
 @RequestMapping("warningMessage")
-@Api( tags = "预警消息")
+@Api( tags = "小程序预警消息")
 public class WarningMessageController {
 
     @Autowired

+ 9 - 1
src/main/java/com/zoniot/ccrc/controller/applets/WarningRuleController.java

@@ -4,6 +4,7 @@ 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.scheduled.WarningMessageJob;
 import com.zoniot.ccrc.service.WarningRuleService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -19,11 +20,13 @@ import java.util.List;
 @Controller
 @ResponseBody
 @RequestMapping("warningRule")
-@Api( tags = "预警规则")
+@Api( tags = "小程序预警规则")
 public class WarningRuleController {
 
     @Autowired
     private WarningRuleService warningRuleService;
+    @Autowired
+    private WarningMessageJob warningMessageJob;
 
 
     @ResponseBody
@@ -55,4 +58,9 @@ public class WarningRuleController {
         warningRuleService.delWaringRule(id);
         return new AjaxMessage<>(ResultStatus.OK);
     }
+    @GetMapping("/startTheAlertImmediately")
+    @ApiOperation(value = "立即启动预警")
+    public void startTheAlertImmediately(){
+        warningMessageJob.warningMessage();
+    }
 }

+ 2 - 2
src/main/java/com/zoniot/ccrc/controller/system/CommunityManagerController.java

@@ -107,10 +107,10 @@ public class CommunityManagerController {
 		return new AjaxMessage(ResultStatus.OK);
 	}
 	@GetMapping("getOrgCommunity")
-	@ApiOperation(value = "获取机构小区", notes = "权限: sys:community:del")
+	@ApiOperation(value = "获取机构小区")
 
 	public AjaxMessage getOrgCommunity(
-			@ApiParam(value = "小区Id", required = true) @RequestParam(required = true) Integer orgId
+			@ApiParam(value = "小区Id") @RequestParam(required = false) Integer orgId
 	) {
 		List<Community>communities=communityService.getOrgCommunity(orgId);
 		return new AjaxMessage(ResultStatus.OK,communities);

+ 9 - 0
src/main/java/com/zoniot/ccrc/controller/system/SiteController.java

@@ -6,6 +6,7 @@ import com.zoniot.ccrc.commom.model.ResultStatus;
 import com.zoniot.ccrc.commom.utils.TreeUtil;
 import com.zoniot.ccrc.dto.SiteDto;
 import com.zoniot.ccrc.dto.UserDto;
+import com.zoniot.ccrc.entity.Customer;
 import com.zoniot.ccrc.entity.Permission;
 import com.zoniot.ccrc.service.PermissionService;
 import com.zoniot.ccrc.service.SiteService;
@@ -119,4 +120,12 @@ public class SiteController {
         List<Permission> list = permissionService.getSitePermission(siteId);
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
+    @GetMapping("getCustomerList")
+    @ApiOperation(value = "获取客户编号么")
+    public AjaxMessage<List<Customer>> getCustomerList(
+
+    ) {
+        List<Customer> list = siteService.getCustomerList();
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
 }

+ 4 - 0
src/main/java/com/zoniot/ccrc/dao/DeviceMapper.java

@@ -1,5 +1,6 @@
 package com.zoniot.ccrc.dao;
 
+import com.zoniot.ccrc.dto.PriceInfo;
 import com.zoniot.ccrc.entity.Device;
 import java.util.List;
 import org.apache.ibatis.annotations.Mapper;
@@ -16,4 +17,7 @@ public interface DeviceMapper {
     int batchInsert(@Param("list") List<Device> list);
 
     Long getDeviceIdByUserNumber(Integer id);
+
+    List<PriceInfo> getPriceInfo();
+
 }

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

@@ -84,8 +84,8 @@ public interface GridManagementMapper {
 
     List<GridUser> selectGirdUserInfo(@Param("username") String username,
                                       @Param("orgId") Integer orgId,
-                                      @Param("roleId") Integer roleId,
-                                      @Param("siteId") Integer siteId, @Param("userId") Integer userId);
+                                      @Param("siteId") Integer siteId,
+                                      @Param("userId") Integer userId);
 
     List<Community> getCommutityByOrg(@Param("ids") List<Integer> orgId);
 

+ 7 - 0
src/main/java/com/zoniot/ccrc/dao/SiteMapper.java

@@ -1,6 +1,7 @@
 package com.zoniot.ccrc.dao;
 
 import com.zoniot.ccrc.dto.SiteDto;
+import com.zoniot.ccrc.entity.Customer;
 import com.zoniot.ccrc.entity.Site;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -26,4 +27,10 @@ public interface SiteMapper {
     Site findById(@Param("siteId") Integer siteId);
 
     int findByCustomerIdUnique(@Param("id") Integer id, @Param("customerId") Integer customerId);
+
+    List<Customer> getCustomerList();
+
+    void updateCustomerSiteId(@Param("id") Integer id, @Param("customerId") Integer customerId);
+
+    void deleteCustomerRelations(@Param("id") Integer id);
 }

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

@@ -14,5 +14,5 @@ public interface WarningRuleMapper {
 
     List<WarningRule> getList(@Param("type") Integer type);
 
-    List<WarningRule> getListByDeviceId(Long id);
+    List<WarningRule> getListByDeviceId(@Param("deviceId")Long deviceId);
 }

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

@@ -21,7 +21,7 @@ import java.util.List;
 public class ClientUserDto extends ClientUser {
     @ApiModelProperty(value = "本月用水量")
     private BigDecimal useAmount;
-
+    private String accountnumber;
     @JsonIgnore
     @ApiModelProperty(value = "用水性质ID")
     private BigInteger waterpropertyid;

+ 20 - 0
src/main/java/com/zoniot/ccrc/dto/FeeTypeDto.java

@@ -0,0 +1,20 @@
+package com.zoniot.ccrc.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @program: water-query
+ * @description: 费用类型
+ * @author: Yangyang.Wang
+ * @create: 2020-05-10 19:53
+ **/
+@Data
+public class FeeTypeDto {
+    @ApiModelProperty(value = "费用名称", position = 1)
+    private  String feeTypeName;
+    @ApiModelProperty(value = "阶梯详情", position = 4)
+    List<LadderInfoDto> ladderInfoDtos;
+}

+ 31 - 0
src/main/java/com/zoniot/ccrc/dto/LadderInfoDto.java

@@ -0,0 +1,31 @@
+package com.zoniot.ccrc.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @program: water-query
+ * @description: 阶梯信息
+ * @author: Yangyang.Wang
+ * @create: 2020-05-10 19:56
+ **/
+@Data
+public class LadderInfoDto {
+
+    @ApiModelProperty(value="阶梯名称")
+    private  String ladderName;
+
+    @ApiModelProperty(value="最小值")
+    private BigDecimal minValue;
+
+
+    @ApiModelProperty(value="最大值")
+    private BigDecimal maxValue;
+
+    @ApiModelProperty(value="阶段水价")
+    private BigDecimal waterPrice;
+
+
+}

+ 53 - 0
src/main/java/com/zoniot/ccrc/dto/PriceInfo.java

@@ -0,0 +1,53 @@
+package com.zoniot.ccrc.dto;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @program: water-query
+ * @description: 用水价格信息
+ * @author: Yangyang.Wang
+ * @create: 2020-05-10 19:50
+ **/
+@Data
+public class PriceInfo {
+    @ApiModelProperty(value = "用水类别", position = 1)
+    private String waterTypeName;
+    @ApiModelProperty(value = "水司名称", position = 1)
+    private String customerName;
+
+    @JsonIgnore
+    @ApiModelProperty(value = "费用类型", position = 2)
+    private Integer feetype;
+    @JsonIgnore
+    @ApiModelProperty(value = "费用名称", position = 3)
+    private String feeTypeName;
+    @JsonIgnore
+    @ApiModelProperty(value = "阶梯", position = 4)
+    private Integer ladderlevel;
+    @JsonIgnore
+    @ApiModelProperty(value = "阶梯价格", position = 5)
+    private BigDecimal price;
+    @JsonIgnore
+    @ApiModelProperty(value = "水量上限", position = 6)
+    private BigDecimal available1;
+    @JsonIgnore
+    @ApiModelProperty(value = "水量上限", position = 7)
+    private BigDecimal available2;
+    @JsonIgnore
+    @ApiModelProperty(value = "水量上限", position = 8)
+    private BigDecimal  available3;
+    @JsonIgnore
+    @ApiModelProperty(value = "水量上限", position = 9)
+    private BigDecimal  available4;
+    @JsonIgnore
+    @ApiModelProperty(value = "阶梯类型", position = 10)
+    private Integer laddertype;
+
+    @ApiModelProperty(value = "费用名称", position = 11)
+    private List<FeeTypeDto> feeTypeDtos;
+}

+ 67 - 0
src/main/java/com/zoniot/ccrc/entity/Customer.java

@@ -0,0 +1,67 @@
+package com.zoniot.ccrc.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@ApiModel(value="客户")
+@Data
+public class Customer implements Serializable {
+
+    @ApiModelProperty(value="主键")
+    private Integer id;
+
+    @ApiModelProperty(value="站点,参考sc_site主键", hidden = true)
+    private Integer siteId;
+
+    @ApiModelProperty(value="客户名称")
+    private String customerName;
+
+    @ApiModelProperty(value="客户联系方式")
+    private String customerPhone;
+
+    @ApiModelProperty(value="客户联系人")
+    private String customerContactPerson;
+
+    @ApiModelProperty(value="推送地址")
+    private String pushUrl;
+
+    @ApiModelProperty(value="客户编号", hidden = true)
+    private String customerNo;
+
+    @ApiModelProperty(value="客户token")
+    private String token;
+
+    @ApiModelProperty(value="备注")
+    private String remark;
+
+    @ApiModelProperty(value="状态", hidden = true)
+    private Integer status;
+
+    @ApiModelProperty(value="客户对应机构,每个客户都会有个对应的机构", hidden = true)
+    private Integer customerOrgId;
+
+    @ApiModelProperty(value="创建时间", hidden = true)
+    private LocalDateTime dateCreate;
+
+    @ApiModelProperty(value="更新时间", hidden = true)
+    private LocalDateTime dateUpdate;
+
+    @ApiModelProperty(value="创建人", hidden = true)
+    private String createBy;
+
+    @ApiModelProperty(value="更新人", hidden = true)
+    private String updateBy;
+
+    @ApiModelProperty(value="上级客户ID")
+    private Integer parentId;
+
+    @ApiModelProperty(value="子客户数量")
+    private Integer childrenNum;
+
+    @ApiModelProperty(value="收据类型:0:默认 1:开鲁 2:盖州")
+    private Integer payInvoiceType;
+}

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

@@ -78,9 +78,9 @@ public class GridManagement implements Serializable {
     @ApiModelProperty(value = "")
     private Integer status;
     @ApiModelProperty(value = "水表电子号")
-    private String waterMeterNo;
+    private String meterNo;
     @ApiModelProperty(value = "水表档案号")
-    private String waterMeterFileNo;
+    private String fileNo;
     @ApiModelProperty(value = "机构")
     private String orgName;
     @ApiModelProperty(value = "建筑")

+ 3 - 0
src/main/java/com/zoniot/ccrc/service/SiteService.java

@@ -3,6 +3,7 @@ package com.zoniot.ccrc.service;
 
 import com.zoniot.ccrc.commom.model.Pagination;
 import com.zoniot.ccrc.dto.SiteDto;
+import com.zoniot.ccrc.entity.Customer;
 import com.zoniot.ccrc.entity.Site;
 
 import java.util.List;
@@ -28,4 +29,6 @@ public interface SiteService{
     void delete(Integer id);
 
 
+    List<Customer> getCustomerList();
+
 }

+ 6 - 1
src/main/java/com/zoniot/ccrc/service/StatisticsService.java

@@ -1,5 +1,6 @@
 package com.zoniot.ccrc.service;
 
+import com.zoniot.ccrc.dto.PriceInfo;
 import com.zoniot.ccrc.dto.UseWaterAnalyze;
 import com.zoniot.ccrc.dto.UseWaterDto;
 import com.zoniot.ccrc.dto.WaterPriceDto;
@@ -13,7 +14,11 @@ public interface StatisticsService {
 
     UseWaterAnalyze getUseWaterAnalyze();
 
-    WaterPriceDto waterPriceQuery(Long deviceId, String date);
+
 
     Double getDeviceVolume(Integer startDate, Integer endDate);
+    Long getDeviceId();
+
+    PriceInfo waterPriceQuery();
+
 }

+ 9 - 1
src/main/java/com/zoniot/ccrc/service/impl/AppletsServiceImpl.java

@@ -16,6 +16,7 @@ import com.zoniot.ccrc.service.WechatService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
@@ -26,7 +27,7 @@ import java.util.ArrayList;
 import java.util.List;
 @Service
 public class AppletsServiceImpl implements AppletsService {
-    @Autowired
+    @Resource
     private UserMapper userMapper;
     @Autowired
     private StatisticsService statisticsService;
@@ -54,12 +55,19 @@ public class AppletsServiceImpl implements AppletsService {
         if(clientUserDtos!=null&&clientUserDtos.size()>0)
         {
             clientUserDto = clientUserDtos.get(0);
+            clientUserDto.setUserNumber(clientUserDto.getAccountnumber());
             clientUserDto.setAvailablel1(10d);
             clientUserDto.setAvailablel2(20d);
             clientUserDto.setAvailablel3(999d);
             clientUserDto.setUseAmount(BigDecimal.valueOf(volume));
             BaseWaterProperty baseWaterProperty = new BaseWaterProperty();
             baseWaterProperty.setLaddertype(1);
+            baseWaterProperty.setAvailable1(10);
+            baseWaterProperty.setAvailable2(20);
+            baseWaterProperty.setAvailable3(999);
+            baseWaterProperty.setTotalpriceL1(new BigDecimal("0.8"));
+            baseWaterProperty.setTotalpriceL2(new BigDecimal("1.2"));
+            baseWaterProperty.setTotalpriceL3(new BigDecimal("1.6"));
             List<CustomerWaterStage> customerWaterStages = new ArrayList<CustomerWaterStage>();
 
             CustomerWaterStage  customerWaterStage1 = new CustomerWaterStage();

+ 5 - 2
src/main/java/com/zoniot/ccrc/service/impl/GridManagementServiceImpl.java

@@ -86,6 +86,7 @@ public class GridManagementServiceImpl implements GridManagementService {
             gridManagement.setUserId(userId);
             gridManagement.setDeviceId(deviceId);
             gridManagement.setStatus(1);
+            gridManagement.setIsDefault(0);
             gridManagements.add(gridManagement);
         });
         if(gridManagements.size()>0)
@@ -141,12 +142,12 @@ public class GridManagementServiceImpl implements GridManagementService {
 
     @Override
     public List<GridUser> selectGirdUserInfo(String name, Integer orgId) {
-        Integer roleId=108;
+
         LoginUser currentUser = UserUtil.getCurrentUser();
 
         Integer siteId=currentUser.getSiteId();
         Integer userId=currentUser.getId();
-        List<GridUser> users=gridManagementMapper.selectGirdUserInfo(name,orgId,roleId,siteId,userId);
+        List<GridUser> users=gridManagementMapper.selectGirdUserInfo(name,orgId,siteId,userId);
         return users;
     }
 
@@ -154,7 +155,9 @@ public class GridManagementServiceImpl implements GridManagementService {
     public List<Community> getCommutityByOrg(Integer orgId) {
         List<OrganizationDto> list = organizationMapper.findList(UserUtil.getCurrentUser().getSiteId());
         List<Integer>ids=new ArrayList<>();
+
         TreeUtil.getOrganList(list,orgId,0,ids);
+        ids.add(orgId);
         //TreeUtil.getOrganTree()
         List<Community> communities=gridManagementMapper.getCommutityByOrg(ids);
         return communities;

+ 10 - 3
src/main/java/com/zoniot/ccrc/service/impl/SiteServiceImpl.java

@@ -169,7 +169,7 @@ public class SiteServiceImpl implements SiteService {
 
         }
 
-
+        siteMapper.updateCustomerSiteId(siteDto.getId(),siteDto.getCustomerId());
         log.info("end add site");
     }
 
@@ -259,7 +259,8 @@ public class SiteServiceImpl implements SiteService {
 
 
         }
-
+        siteMapper.deleteCustomerRelations(siteDto.getId());
+        siteMapper.updateCustomerSiteId(siteDto.getId(),siteDto.getCustomerId());
         log.info("end edit site");
     }
 
@@ -274,8 +275,14 @@ public class SiteServiceImpl implements SiteService {
         List<Integer> list = siteUserMapper.findBySiteId(id,null);
         //userMapper.batchDelectUser(list, UserUtil.getCurrentUser().getUsername());
         siteUserMapper.deleteBySiteId(id, UserUtil.getCurrentUser().getUsername(), null);
-
+        siteMapper.deleteCustomerRelations(id);
         log.info("end delete site");
     }
 
+    @Override
+    public List<Customer> getCustomerList() {
+        List<Customer> customers=siteMapper.getCustomerList();
+        return customers;
+    }
+
 }

+ 94 - 12
src/main/java/com/zoniot/ccrc/service/impl/StatisticsServiceImpl.java

@@ -2,10 +2,7 @@ package com.zoniot.ccrc.service.impl;
 
 import com.zoniot.ccrc.commom.utils.UserUtil;
 import com.zoniot.ccrc.dao.DeviceMapper;
-import com.zoniot.ccrc.dto.LoginUser;
-import com.zoniot.ccrc.dto.UseWaterAnalyze;
-import com.zoniot.ccrc.dto.UseWaterDto;
-import com.zoniot.ccrc.dto.WaterPriceDto;
+import com.zoniot.ccrc.dto.*;
 import com.zoniot.ccrc.service.MongoMeterReadRecordService;
 import com.zoniot.ccrc.service.StatisticsService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,12 +10,11 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.BigInteger;
 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.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -118,20 +114,106 @@ public class StatisticsServiceImpl implements StatisticsService {
         return useWaterAnalyze;
     }
 
-    @Override
-    public WaterPriceDto waterPriceQuery(Long deviceId, String date) {
-        return null;
-    }
+
 
     @Override
     public Double getDeviceVolume(Integer startDate, Integer endDate) {
         Long deviceId=getDeviceId();
         return mongoMeterReadRecordService.getDeviceVolume(deviceId, startDate, endDate);
     }
-    Long getDeviceId(){
+    @Override
+    public Long getDeviceId(){
         LoginUser loginClientUser = UserUtil.getCurrentUser();
         Long deviceId= deviceMapper.getDeviceIdByUserNumber(loginClientUser.getId());
 
         return deviceId;
     }
+
+    @Override
+    public PriceInfo waterPriceQuery() {
+        LoginUser loginClientUser = UserUtil.getCurrentUser();
+
+        PriceInfo priceInfo = new PriceInfo();
+        List<PriceInfo> priceInfos = deviceMapper.getPriceInfo();
+        Map<String,List<LadderInfoDto>> feeType = new HashMap<>();
+        List<FeeTypeDto> feeTypeDtos = new ArrayList<>();
+        if(priceInfos!=null&&priceInfos.size()>0)
+        {
+            priceInfo.setWaterTypeName(priceInfos.get(0).getWaterTypeName());
+            for (PriceInfo priceInfo1:priceInfos)
+            {
+                if(!feeType.containsKey(priceInfo1.getFeeTypeName()))
+                {
+                    LadderInfoDto ladderInfoDto = new LadderInfoDto();
+                    Integer ladderLever = priceInfo1.getLadderlevel();
+                    switch (ladderLever)
+                    {
+                        case 1:ladderInfoDto.setLadderName("第一阶梯");
+                            ladderInfoDto.setMinValue(BigDecimal.valueOf(0));
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable1());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                        case 2:ladderInfoDto.setLadderName("第二阶梯");
+                            ladderInfoDto.setMinValue(priceInfo1.getAvailable1());
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable2());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                        case 3:ladderInfoDto.setLadderName("第三阶梯");
+                            ladderInfoDto.setMinValue(priceInfo1.getAvailable2());
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable3());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                        case 4:ladderInfoDto.setLadderName("第四阶梯");
+                            ladderInfoDto.setMinValue(priceInfo1.getAvailable3());
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable4());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                    }
+                    List<LadderInfoDto> ladderInfoDtos = new ArrayList<>();
+                    ladderInfoDtos.add(ladderInfoDto);
+                    feeType.put(priceInfo1.getFeeTypeName(),ladderInfoDtos);
+
+                }else
+                {
+                    LadderInfoDto ladderInfoDto = new LadderInfoDto();
+                    Integer ladderLever = priceInfo1.getLadderlevel();
+                    switch (ladderLever)
+                    {
+                        case 1:ladderInfoDto.setLadderName("第一阶梯");
+                            ladderInfoDto.setMinValue(BigDecimal.valueOf(0));
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable1());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                        case 2:ladderInfoDto.setLadderName("第二阶梯");
+                            ladderInfoDto.setMinValue(priceInfo1.getAvailable1());
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable2());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                        case 3:ladderInfoDto.setLadderName("第三阶梯");
+                            ladderInfoDto.setMinValue(priceInfo1.getAvailable2());
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable3());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                        case 4:ladderInfoDto.setLadderName("第四阶梯");
+                            ladderInfoDto.setMinValue(priceInfo1.getAvailable3());
+                            ladderInfoDto.setMaxValue(priceInfo1.getAvailable4());
+                            ladderInfoDto.setWaterPrice(priceInfo1.getPrice());
+                            break;
+                    }
+                    feeType.get(priceInfo1.getFeeTypeName()).add(ladderInfoDto);
+                }
+            }
+            for (Map.Entry<String, List<LadderInfoDto>> entry : feeType.entrySet()) {
+                FeeTypeDto feeTypeDto = new FeeTypeDto();
+                feeTypeDto.setFeeTypeName(entry.getKey());
+                feeTypeDto.setLadderInfoDtos(entry.getValue());
+                feeTypeDtos.add(feeTypeDto);
+            }
+
+            priceInfo.setCustomerName(loginClientUser.getCustomerName());
+            priceInfo.setFeeTypeDtos(feeTypeDtos);
+        }
+        return priceInfo;
+
+    }
 }

+ 5 - 2
src/main/java/com/zoniot/ccrc/service/impl/WarningMessageServiceImpl.java

@@ -9,6 +9,7 @@ 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.StatisticsService;
 import com.zoniot.ccrc.service.WarningMessageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,6 +25,8 @@ public class WarningMessageServiceImpl implements WarningMessageService {
     private WarningMessageMapper warningMessageMapper;
     @Resource
     private WarningLogMapper warningLogMapper;
+    @Autowired
+    private StatisticsService statisticsService;
 
 
     @Override
@@ -43,12 +46,12 @@ public class WarningMessageServiceImpl implements WarningMessageService {
 
     @Override
     public List<WarningMessageDto> getPage(Integer date) {
-       return null;//warningMessageMapper.getList(deviceDto.getDeviceId(), date);
+       return warningMessageMapper.getList(statisticsService.getDeviceId(), date);
     }
 
     @Override
     public List<WarningMessageStatusDto> getDateStatus(Integer date) {
-        return null;//warningMessageMapper.getDateStatus(deviceDto.getDeviceId(), date);
+        return warningMessageMapper.getDateStatus(statisticsService.getDeviceId(), date);
     }
 
     @Override

+ 6 - 2
src/main/java/com/zoniot/ccrc/service/impl/WarningRuleServiceImpl.java

@@ -3,7 +3,9 @@ package com.zoniot.ccrc.service.impl;
 
 import com.zoniot.ccrc.dao.WarningRuleMapper;
 import com.zoniot.ccrc.entity.WarningRule;
+import com.zoniot.ccrc.service.StatisticsService;
 import com.zoniot.ccrc.service.WarningRuleService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -16,6 +18,8 @@ public class WarningRuleServiceImpl implements WarningRuleService {
 
     @Resource
     private WarningRuleMapper warningRuleMapper;
+    @Autowired
+    private StatisticsService statisticsService;
 
     @Override
     public int insertSelective(WarningRule record) {
@@ -29,14 +33,14 @@ public class WarningRuleServiceImpl implements WarningRuleService {
 
     @Override
     public List<WarningRule> getRuleList() {
-        Long id=0l;
+        Long id=statisticsService.getDeviceId();
 
         return  warningRuleMapper.getListByDeviceId(id);
     }
 
     @Override
     public int addRule(Integer warningType) {
-        Long deviceId=0l;;
+        Long deviceId=statisticsService.getDeviceId();;
 
 
         WarningRule warningRule = new WarningRule();

+ 2 - 2
src/main/resources/application-dev.properties

@@ -1,4 +1,4 @@
-server.port=8098
+server.port=8099
 server.servlet.context-path=/api
 
 project.path=./log
@@ -34,7 +34,7 @@ mybatis.type-aliases-package=com.zoniot.ccrc.entity
 mybatis.configuration.map-underscore-to-camel-case=true
 mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 mybatis.configuration.use-column-label=true
-spring.data.mongodb.uri=mongodb://114.135.61.188:17017/water-iot-database
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
 spring.jackson.time-zone=GMT+8
 #spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 #spring.jackson.joda-date-time-format: yyyy-MM-dd HH:mm:ss

+ 3 - 0
src/main/resources/mapper/DeviceMapper.xml

@@ -359,4 +359,7 @@
            inner join  sc_device b on b.id=a.device_id where a.id=#{id}
 
   </select>
+    <select id="getPriceInfo" resultType="com.zoniot.ccrc.dto.PriceInfo">
+      select * from prict_info
+    </select>
 </mapper>

+ 6 - 10
src/main/resources/mapper/GridManagementMapper.xml

@@ -74,9 +74,9 @@
             <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 test="meterNo != null and meterNo !=''">
+                and ( b.meter_no LIKE concat('%',#{meterNo},'%') or
+                b.file_no LIKE concat('%',#{meterNo},'%'))
             </if>
               <if test="isDefault != null">
                 and is_default = #{isDefault}
@@ -190,21 +190,17 @@
         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
+                a.status=1 and ((ssu.type !=4) or(ssu.type=4 and a.id=#{userId}))
             <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 == 108  ">
-                and e.id = #{roleId}
-                and a.id=#{userId}
-            </if>
+
             <if test="siteId != null  ">
                 and ssu.site_id = #{siteId}
             </if>
@@ -220,7 +216,7 @@
              and status=1
     </select>
     <select id="getBuildingByCommutity" resultType="com.zoniot.ccrc.entity.Building">
-        select * from sc_building where community=#{commutityId} and status=1
+        select * from sc_building where community_id=#{commutityId} and status=1
     </select>
     <select id="getDevices" resultType="com.zoniot.ccrc.entity.Device">
         select * from sc_device where building_id=#{buildingId} and

+ 23 - 0
src/main/resources/mapper/SiteMapper.xml

@@ -162,6 +162,7 @@
         WHERE id = #{site.id,jdbcType=INTEGER}
     </update>
 
+
     <select id="getList" resultType="com.zoniot.ccrc.dto.SiteDto">
         select
                ss.*,
@@ -179,6 +180,25 @@
     <update id="delete">
         update sc_site set status = 0,update_date=NOW(),update_by=#{updateBy} where id = #{id}
     </update>
+    <update id="deleteCustomerRelations">
+        update sc_customer set site_id=null where id=#{id}
+    </update>
+    <update id="updateCustomerSiteId">
+        update sc_customer set site_id=#{id}
+        where id in ( SELECT  DATA.id FROM(
+                                              SELECT
+                                                  @ids as _ids,
+                                                  (   SELECT @ids := GROUP_CONCAT(id)
+                                                      FROM sc_customer
+                                                      WHERE FIND_IN_SET(parent_id, @ids)
+                                                  ) as cids,
+                                                  @l := @l+1 as level
+                                              FROM sc_customer,
+                                                   (SELECT @ids :=#{customerId}, @l := 0 ) b
+                                              WHERE @ids IS NOT NULL
+                                          ) id, sc_customer DATA
+                      WHERE FIND_IN_SET(DATA.id, ID._ids))
+    </update>
 
 
     <select id="findByNameUnique" resultType="int">
@@ -195,5 +215,8 @@
         select count(1) from sc_site where status = 1 and customer_id = #{customerId}
         <if test="id != null"> and id != #{id}</if>
     </select>
+    <select id="getCustomerList" resultType="com.zoniot.ccrc.entity.Customer">
+        select * from sc_customer where parent_id=0 and status=1
+    </select>
 </mapper>
 

+ 138 - 0
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.zoniot.ccrc.dao.WarningMessageMapper">
+  <resultMap id="BaseResultMap" type="com.zoniot.ccrc.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.zoniot.ccrc.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.zoniot.ccrc.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.zoniot.ccrc.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.zoniot.ccrc.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>

+ 6 - 2
src/main/resources/mapper/WarningRuleMapper.xml

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