Explorar o código

集中器和采集器

lin %!s(int64=4) %!d(string=hai) anos
pai
achega
b206741b19
Modificáronse 38 ficheiros con 2717 adicións e 8 borrados
  1. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java
  2. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/common/CommonController.java
  3. 106 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/CollectorController.java
  4. 196 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/ConcentratorController.java
  5. 19 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ChannelNumberMapper.java
  6. 40 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CollectorMapper.java
  7. 21 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ConcentratorCheckMapper.java
  8. 42 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ConcentratorMapper.java
  9. 25 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/WaterRelatedDeviceMapper.java
  10. 33 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/CollectorDto.java
  11. 50 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/ConcentratorDto.java
  12. 12 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDataDto.java
  13. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDto.java
  14. 54 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/ChannelNumber.java
  15. 63 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Collector.java
  16. 87 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Concentrator.java
  17. 52 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/ConcentratorCheck.java
  18. 50 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/WaterRelatedDevice.java
  19. 23 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/ChannelNumberService.java
  20. 30 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/CollectorService.java
  21. 21 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/ConcentratorCheckService.java
  22. 31 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/ConcentratorService.java
  23. 16 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/WaterRelatedDeviceService.java
  24. 105 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ChannelNumberServiceImpl.java
  25. 127 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CollectorServiceImpl.java
  26. 52 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorCheckServiceImpl.java
  27. 177 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorServiceImpl.java
  28. 32 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterRelatedDeviceServiceImpl.java
  29. 125 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/GdAgentUtils.java
  30. 19 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/model/ConcentratorInfo.java
  31. 27 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/model/MeterInfo.java
  32. 152 0
      smart-city-platform/src/main/resources/mapper/ChannelNumberMapper.xml
  33. 233 0
      smart-city-platform/src/main/resources/mapper/CollectorMapper.xml
  34. 150 0
      smart-city-platform/src/main/resources/mapper/ConcentratorCheckMapper.xml
  35. 325 0
      smart-city-platform/src/main/resources/mapper/ConcentratorMapper.xml
  36. 8 6
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  37. 162 0
      smart-city-platform/src/main/resources/mapper/WaterRelatedDeviceMapper.xml
  38. 40 0
      smart-city-platform/src/test/java/com/bz/smart_city/ScTest.java

+ 6 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java

@@ -38,6 +38,12 @@ public enum ResultStatus {
     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已存在,请重新输入"),
     CREATE_ORDER_NO_DEVICE1(-501,"创建工单失败,无法获取设备编号"),
     CREATE_ORDER_NO_DEVICE2(-502,"创建工单失败,无法获取设备"),
     CREATE_ORDER_NO_ALARMTYPE(-503,"创建工单失败,无对应告警类型"),

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/common/CommonController.java

@@ -119,7 +119,7 @@ public class CommonController {
     @ApiOperation(value = "获取系列(设备类型)列表")
     public AjaxMessage<List<DeviceTypeDto>> getDeviceTypeList(
             @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
-            @ApiParam(value = "设备类型 1:传感器 2;网关设备", required = false) @RequestParam(required = false) Integer type
+            @ApiParam(value = "设备类型 1:传感器 2;网关设备 3:集中器 4:采集器", required = false) @RequestParam(required = false) Integer type
     ) {
         List<DeviceTypeDto> list = deviceTypeService.getDeviceTypeList(sysId, type);
         return new AjaxMessage<>(ResultStatus.OK, list);
@@ -129,7 +129,7 @@ public class CommonController {
     @ApiOperation(value = "获取厂商/系列/型号树形数据")
     public AjaxMessage<List<TreeDataDto>> getTreeData(
             @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
-            @ApiParam(value = "类型 1:传感器 2;网关设备", required = false) @RequestParam(required = false) Integer type
+            @ApiParam(value = "类型 1:传感器 2;网关设备 3:集中器 4:采集器", required = false) @RequestParam(required = false) Integer type
     ) {
         List<TreeDataDto> list = deviceTypeService.getTreeData(sysId, type);
         return new AjaxMessage<>(ResultStatus.OK, list);

+ 106 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/CollectorController.java

@@ -0,0 +1,106 @@
+package com.bz.smart_city.controller.system;
+
+import com.bz.smart_city.commom.model.AjaxMessage;
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.dto.BuildingSelectDto;
+import com.bz.smart_city.dto.CollectorDto;
+import com.bz.smart_city.dto.WaterMeterReplaceLogDto;
+import com.bz.smart_city.entity.Collector;
+import com.bz.smart_city.entity.Concentrator;
+import com.bz.smart_city.service.CollectorService;
+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.format.annotation.DateTimeFormat;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Controller
+@ResponseBody
+@RequestMapping("system/collector")
+@Api(tags = "采集器管理")
+public class CollectorController {
+
+    @Autowired
+    private CollectorService collectorService;
+
+    @GetMapping("getPage")
+    @ApiOperation(value = "查询采集器分页")
+    public AjaxMessage<Pagination<CollectorDto>> getPage(
+            @ApiParam(value = "采集器编码", required = false) @RequestParam(required = false) String collectorNo,
+            @ApiParam(value = "集中器编码", required = false) @RequestParam(required = false) String serialNumber,
+            @ApiParam(value = "安装地址", required = false) @RequestParam(required = false) String address,
+            @ApiParam(value = "省", required = false) @RequestParam(required = false) Integer provinceId,
+            @ApiParam(value = "市", required = false) @RequestParam(required = false) Integer cityId,
+            @ApiParam(value = "区", required = false) @RequestParam(required = false) Integer regionId,
+            @ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer communityId,
+            @ApiParam(value = "建筑id", required = false) @RequestParam(required = false) Integer buildingId,
+            @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<CollectorDto> pageInfo = collectorService.getPage(
+                collectorNo,serialNumber,address,
+                provinceId,cityId,regionId,communityId,buildingId,
+                pageNum, pageSize);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
+    @GetMapping("getList")
+    @ApiOperation(value = "查询采集器列表")
+    public AjaxMessage<List<CollectorDto>> getList(
+            @ApiParam(value = "采集器编码", required = false) @RequestParam(required = false) String collectorNo,
+            @ApiParam(value = "集中器编码", required = false) @RequestParam(required = false) String serialNumber
+    ){
+        List<CollectorDto> list = collectorService.getList(
+                collectorNo,serialNumber);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @GetMapping("getAreaList")
+    @ApiOperation(value = "查询采集器区域列表")
+    public AjaxMessage<List<BuildingSelectDto>> getAreaList(
+            @ApiParam(value = "采集器编码", required = false) @RequestParam(required = false) String collectorNo,
+            @ApiParam(value = "集中器编码", required = false) @RequestParam(required = false) String serialNumber,
+            @ApiParam(value = "安装地址", required = false) @RequestParam(required = false) String address
+    ){
+        List<BuildingSelectDto> list = collectorService.getAreaList(
+                collectorNo,serialNumber,address
+        );
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @PostMapping("add")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "添加采集器")
+    public AjaxMessage add(
+            @ApiParam(value = "采集器", required = true) @RequestBody(required = true) Collector collector
+    ) {
+        collectorService.add(collector);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @PutMapping("edit")
+    @ApiOperation(value = "编辑采集器")
+    //@PreAuthorize("hasAuthority('sys:site:edit')")
+    public AjaxMessage edit(
+            @ApiParam(value = "采集器", required = true) @RequestBody(required = true) Collector collector
+    ) {
+        collectorService.edit(collector);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @DeleteMapping("/del")
+    //@PreAuthorize("hasAuthority('sys:site:del')")
+    @ApiOperation(value = "删除采集器")
+    public AjaxMessage del(
+            @ApiParam(value = "采集器id", required = true) @RequestParam(required = true) Integer id
+    ) {
+        collectorService.delete(id);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+}

+ 196 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/ConcentratorController.java

@@ -0,0 +1,196 @@
+package com.bz.smart_city.controller.system;
+
+import com.bz.smart_city.commom.model.AjaxMessage;
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.dto.BuildingSelectDto;
+import com.bz.smart_city.dto.ConcentratorDto;
+import com.bz.smart_city.entity.ChannelNumber;
+import com.bz.smart_city.entity.Concentrator;
+import com.bz.smart_city.entity.ConcentratorCheck;
+import com.bz.smart_city.service.ChannelNumberService;
+import com.bz.smart_city.service.ConcentratorCheckService;
+import com.bz.smart_city.service.ConcentratorService;
+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.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Controller
+@ResponseBody
+@RequestMapping("system/concentrator")
+@Api(tags = "集中器管理")
+public class ConcentratorController {
+
+    @Autowired
+    private ConcentratorService concentratorService;
+
+    @Autowired
+    private ChannelNumberService channelNumberService;
+
+    @Autowired
+    private ConcentratorCheckService concentratorCheckService;
+
+    @GetMapping("getPage")
+    @ApiOperation(value = "查询集中器分页")
+    public AjaxMessage<Pagination<ConcentratorDto>> getPage(
+            @ApiParam(value = "集中器编码", required = false) @RequestParam(required = false) String serialNumber,
+            @ApiParam(value = "设备状态 0:离线 1:在线", required = false) @RequestParam(required = false) Integer deviceStatus,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
+            @ApiParam(value = "安装地址", required = false) @RequestParam(required = false) String address,
+            @ApiParam(value = "省", required = false) @RequestParam(required = false) Integer provinceId,
+            @ApiParam(value = "市", required = false) @RequestParam(required = false) Integer cityId,
+            @ApiParam(value = "区", required = false) @RequestParam(required = false) Integer regionId,
+            @ApiParam(value = "小区", required = false) @RequestParam(required = false) Integer communityId,
+            @ApiParam(value = "建筑id", required = false) @RequestParam(required = false) Integer buildingId,
+            @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<ConcentratorDto> pageInfo = concentratorService.getPage(
+                serialNumber,deviceStatus,customerId,address,
+                provinceId,cityId,regionId,communityId,buildingId,
+                pageNum, pageSize);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
+    @GetMapping("getList")
+    @ApiOperation(value = "查询集中器列表")
+    public AjaxMessage<List<ConcentratorDto>> getList(
+            @ApiParam(value = "集中器编码", required = false) @RequestParam(required = false) String serialNumber
+    ){
+        List<ConcentratorDto> list = concentratorService.getList(
+                serialNumber);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @GetMapping("getAreaList")
+    @ApiOperation(value = "查询集中器区域列表")
+    public AjaxMessage<List<BuildingSelectDto>> getAreaList(
+            @ApiParam(value = "集中器编码", required = false) @RequestParam(required = false) String serialNumber,
+            @ApiParam(value = "设备状态 0:离线 1:在线", required = false) @RequestParam(required = false) Integer deviceStatus,
+            @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
+            @ApiParam(value = "安装地址", required = false) @RequestParam(required = false) String address
+    ){
+        List<BuildingSelectDto> list = concentratorService.getAreaList(
+                serialNumber,deviceStatus,customerId,address
+        );
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @PostMapping("add")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "添加集中器")
+    public AjaxMessage add(
+            @ApiParam(value = "集中器", required = true) @RequestBody(required = true) Concentrator concentrator
+    ) {
+        concentratorService.add(concentrator);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @PutMapping("edit")
+    @ApiOperation(value = "编辑集中器")
+    //@PreAuthorize("hasAuthority('sys:site:edit')")
+    public AjaxMessage edit(
+            @ApiParam(value = "集中器", required = true) @RequestBody(required = true) Concentrator concentrator
+    ) {
+        concentratorService.edit(concentrator);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @DeleteMapping("/del")
+    //@PreAuthorize("hasAuthority('sys:site:del')")
+    @ApiOperation(value = "删除集中器")
+    public AjaxMessage del(
+            @ApiParam(value = "集中器id", required = true) @RequestParam(required = true) Integer id
+    ) {
+        concentratorService.delete(id);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @PostMapping("refreshStatus")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "刷新集中器状态")
+    public AjaxMessage refreshStatus(
+            @ApiParam(value = "集中器id", required = true) @RequestParam(required = true) Integer id
+    ) {
+        concentratorService.refreshStatus(id);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @GetMapping("/channel/getList")
+    @ApiOperation(value = "查询通道列表")
+    public AjaxMessage<List<ChannelNumber>> getChannelList(
+            @ApiParam(value = "集中器id", required = false) @RequestParam(required = false) String concentratorId
+    ){
+        List<ChannelNumber> list = channelNumberService.getList(concentratorId);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @PostMapping("/channel/add")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "添加通道")
+    public AjaxMessage addChannel(
+            @ApiParam(value = "通道", required = true) @RequestBody(required = true) ChannelNumber channelNumber
+    ) {
+        channelNumberService.add(channelNumber);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @PutMapping("/channel/edit")
+    @ApiOperation(value = "编辑通道")
+    //@PreAuthorize("hasAuthority('sys:site:edit')")
+    public AjaxMessage editChannel(
+            @ApiParam(value = "通道", required = true) @RequestBody(required = true) ChannelNumber channelNumber
+    ) {
+        channelNumberService.edit(channelNumber);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @DeleteMapping("/channel/del")
+    //@PreAuthorize("hasAuthority('sys:site:del')")
+    @ApiOperation(value = "删除通道")
+    public AjaxMessage delChannel(
+            @ApiParam(value = "通道id", required = true) @RequestParam(required = true) Integer id
+    ) {
+        channelNumberService.delete(id);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @PostMapping("/check/archives")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "档案校验")
+    public AjaxMessage archives(
+            @ApiParam(value = "集中器id", required = false) @RequestParam(required = false) Integer concentratorId
+    ) {
+        concentratorCheckService.archivesCheck(concentratorId);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @GetMapping("/check/logPage")
+    @ApiOperation(value = "查询校验历史分页")
+    public AjaxMessage<Pagination<ConcentratorCheck>> logPage(
+            @ApiParam(value = "集中器id", required = false) @RequestParam(required = false) Integer concentratorId,
+            @ApiParam(value = "校验结果 1:正常 2:集中器档案缺失 3:档案不一致", required = false) @RequestParam(required = false) Integer checkResult,
+            @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<ConcentratorCheck> pageInfo = concentratorCheckService.getPage(
+                concentratorId,checkResult,
+                pageNum, pageSize);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
+    @PostMapping("/check/clear")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "清空校验列表")
+    public AjaxMessage clear(
+            @ApiParam(value = "集中器id", required = false) @RequestParam(required = false) Integer concentratorId
+    ) {
+        concentratorCheckService.checkClear(concentratorId);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+}

+ 19 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/ChannelNumberMapper.java

@@ -0,0 +1,19 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.entity.ChannelNumber;
+import java.util.List;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface ChannelNumberMapper {
+    int insertSelective(ChannelNumber record);
+
+    int updateByPrimaryKeySelective(ChannelNumber record);
+
+    int batchInsert(@Param("list") List<ChannelNumber> list);
+
+    List<ChannelNumber> getList(@Param("concentratorId") String concentratorId);
+
+    int findUnique(@Param("id") Integer id, @Param("channelNo") String channelNo, @Param("channelNamae") String channelNamae);
+}

+ 40 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/CollectorMapper.java

@@ -0,0 +1,40 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.dto.BuildingSelectInfoDto;
+import com.bz.smart_city.dto.CollectorDto;
+import com.bz.smart_city.entity.Collector;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface CollectorMapper {
+    int insertSelective(Collector record);
+
+    int updateByPrimaryKeySelective(Collector record);
+
+    int batchInsert(@Param("list") List<Collector> list);
+
+    List<CollectorDto> getList(
+            @Param("siteId") Integer siteId,
+            @Param("collectorNo") String collectorNo,
+            @Param("serialNumber") String serialNumber,
+            @Param("address") String address,
+            @Param("provinceId") Integer provinceId,
+            @Param("cityId") Integer cityId,
+            @Param("regionId") Integer regionId,
+            @Param("communityId") Integer communityId,
+            @Param("buildingId") Integer buildingId);
+
+    List<BuildingSelectInfoDto> getAreaList(
+            @Param("siteId") Integer siteId,
+            @Param("collectorNo") String collectorNo,
+            @Param("serialNumber") String serialNumber,
+            @Param("address") String address);
+
+    Integer countByConcentratorId(@Param("concentratorId") Integer concentratorId);
+
+    int findByCollectorNoUnique(@Param("id") Integer id, @Param("concentratorId") Integer concentratorId, @Param("collectorNo") String collectorNo);
+}

+ 21 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/ConcentratorCheckMapper.java

@@ -0,0 +1,21 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.entity.ConcentratorCheck;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface ConcentratorCheckMapper {
+    int insertSelective(ConcentratorCheck record);
+
+    int updateByPrimaryKeySelective(ConcentratorCheck record);
+
+    int batchInsert(@Param("list") List<ConcentratorCheck> list);
+
+    List<ConcentratorCheck> getList(@Param("concentratorId") Integer concentratorId, @Param("checkResult") Integer checkResult);
+
+    int checkClear(@Param("concentratorId") Integer concentratorId);
+}

+ 42 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/ConcentratorMapper.java

@@ -0,0 +1,42 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.dto.BuildingSelectInfoDto;
+import com.bz.smart_city.dto.ConcentratorDto;
+import com.bz.smart_city.entity.Concentrator;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface ConcentratorMapper {
+    int insertSelective(Concentrator record);
+
+    int updateByPrimaryKeySelective(Concentrator record);
+
+    int batchInsert(@Param("list") List<Concentrator> list);
+
+    List<ConcentratorDto> getList(
+            @Param("siteId") Integer siteId,
+            @Param("serialNumber") String serialNumber,
+            @Param("deviceStatus") Integer deviceStatus,
+            @Param("customerId") Integer customerId,
+            @Param("address") String address,
+            @Param("provinceId") Integer provinceId,
+            @Param("cityId") Integer cityId,
+            @Param("regionId") Integer regionId,
+            @Param("communityId") Integer communityId,
+            @Param("buildingId") Integer buildingId);
+
+    List<ConcentratorDto> findList(@Param("siteId") Integer siteId, @Param("serialNumber") String serialNumber);
+
+    List<BuildingSelectInfoDto> getAreaList(
+            @Param("siteId") Integer siteId,
+            @Param("serialNumber") String serialNumber,
+            @Param("deviceStatus") Integer deviceStatus,
+            @Param("customerId") Integer customerId,
+            @Param("address") String address);
+
+    int findBySerialNumberUnique(@Param("id") Integer id, @Param("serialNumber") String serialNumber);
+}

+ 25 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/WaterRelatedDeviceMapper.java

@@ -0,0 +1,25 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.dto.DeviceDto;
+import com.bz.smart_city.entity.Device;
+import com.bz.smart_city.entity.WaterRelatedDevice;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface WaterRelatedDeviceMapper {
+    int insertSelective(WaterRelatedDevice record);
+
+    int updateByPrimaryKeySelective(WaterRelatedDevice record);
+
+    int batchInsert(@Param("list") List<WaterRelatedDevice> list);
+
+    Integer countByConcentratorId(@Param("concentratorId") Integer concentratorId);
+
+    Integer countByChannelNumberId(@Param("channelNumberId") Integer channelNumberId);
+
+    List<DeviceDto> getDevice(@Param("concentratorId") Integer concentratorId);
+}

+ 33 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/CollectorDto.java

@@ -0,0 +1,33 @@
+package com.bz.smart_city.dto;
+
+import com.bz.smart_city.entity.Collector;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class CollectorDto extends Collector {
+    @ApiModelProperty(value="集中器编码")
+    private String serialNumber;
+
+    @ApiModelProperty(value="客户名称")
+    private String customerName;
+
+    @ApiModelProperty(value = "建筑名称", position = 103)
+    private String buildingName;
+
+    @ApiModelProperty(value = "省", position = 107)
+    private Integer province;
+
+    @ApiModelProperty(value = "市", position = 108)
+    private Integer city;
+
+    @ApiModelProperty(value = "区", position = 109)
+    private Integer region ;
+
+    @ApiModelProperty(value = "小区", position = 110)
+    private Integer community;
+}

+ 50 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/ConcentratorDto.java

@@ -0,0 +1,50 @@
+package com.bz.smart_city.dto;
+
+import com.bz.smart_city.entity.Concentrator;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel("")
+public class ConcentratorDto extends Concentrator {
+
+    @ApiModelProperty(value="客户名称")
+    private String customerName;
+
+    @ApiModelProperty(value = "建筑名称", position = 103)
+    private String buildingName;
+
+    @ApiModelProperty(value="通道数量")
+    private Integer channelNum;
+
+    @ApiModelProperty(value="采集器数量")
+    private Integer collectorNum;
+
+    @ApiModelProperty(value="设备数量")
+    private Integer deviceNum;
+
+    @ApiModelProperty(value = "系列", position = 100)
+    private String equipmentType;
+
+    @ApiModelProperty(value = "型号", position = 101)
+    private String model;
+
+    @ApiModelProperty(value = "厂商名称", position = 102)
+    private String manufacturerName;
+
+
+    @ApiModelProperty(value = "省", position = 107)
+    private Integer province;
+
+    @ApiModelProperty(value = "市", position = 108)
+    private Integer city;
+
+    @ApiModelProperty(value = "区", position = 109)
+    private Integer region ;
+
+    @ApiModelProperty(value = "小区", position = 110)
+    private Integer community;
+}

+ 12 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDataDto.java

@@ -46,4 +46,16 @@ public class DeviceDataDto {
     private String agentIdentifier;
     @ApiModelProperty(value = "站点id", position = 14)
     private Integer siteId;
+
+    @ApiModelProperty(value="参考集中器表")
+    private Integer concentratorId;
+
+    @ApiModelProperty(value="参考采集器表")
+    private Integer collectorId;
+
+    @ApiModelProperty(value="通道号id")
+    private Integer channelNumberId;
+
+    @ApiModelProperty(value="测量点号")
+    private String port;
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceDto.java

@@ -112,7 +112,11 @@ public class DeviceDto extends Device {
 
     @ApiModelProperty(value="是否有无阀门 0:无 1:有",position = 125)
     private Integer isValve;
+
     @ApiModelProperty(value="是否需要注册 0:否:是",position = 125)
     private Integer isRegister;
 
+    @ApiModelProperty(value="测量点号",position = 126)
+    private String port;
+
 }

+ 54 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/ChannelNumber.java

@@ -0,0 +1,54 @@
+package com.bz.smart_city.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+/**
+    * 水务行业专用,一个采集器下可以有多个水表
+    */
+@ApiModel(value="com-bz-smart_city-entity-ChannelNumber")
+@Data
+public class ChannelNumber {
+
+    @ApiModelProperty(value="主键")
+    private Integer id;
+
+    @JsonIgnore
+    @ApiModelProperty(value="站点,参考sc_site主键",hidden = true)
+    private Integer siteId;
+
+    @ApiModelProperty(value="参考集中器主键")
+    private Integer concentratorId;
+
+    @ApiModelProperty(value="通道名称")
+    private String channelName;
+
+    @ApiModelProperty(value="通道id")
+    private String channelNo;
+
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="备注",hidden = true)
+    private String remark;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间",hidden = true)
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间",hidden = true)
+    private LocalDateTime dateUpdate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人",hidden = true)
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人",hidden = true)
+    private String updateBy;
+}

+ 63 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Collector.java

@@ -0,0 +1,63 @@
+package com.bz.smart_city.entity;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+/**
+    * 水务行业专用,一个采集器下可以有多个水表
+    */
+@ApiModel(value="com-bz-smart_city-entity-Collector")
+@Data
+public class Collector {
+
+    @ApiModelProperty(value="主键")
+    private Integer id;
+
+    @ApiModelProperty(value="站点,参考sc_site主键",hidden = true)
+    private Integer siteId;
+
+    @ApiModelProperty(value="客户id")
+    private Integer customerId;
+
+    @ApiModelProperty(value="建筑id")
+    private Integer buildingId;
+
+    @ApiModelProperty(value="采集器编码")
+    private String collectorNo;
+
+    @ApiModelProperty(value="参考集中器主键")
+    private Integer concentratorId;
+
+    @ApiModelProperty(value="设备类型")
+    private Integer deviceType;
+
+    @ApiModelProperty(value="安装地址")
+    private String address;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态",hidden = true)
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="备注",hidden = true)
+    private String remark;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间",hidden = true)
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间",hidden = true)
+    private LocalDateTime dateUpdate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人",hidden = true)
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人",hidden = true)
+    private String updateBy;
+}

+ 87 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Concentrator.java

@@ -0,0 +1,87 @@
+package com.bz.smart_city.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+/**
+    * 水务行业专用,一个集中器下有多个水表或者采集器
+    */
+@ApiModel(value="com-bz-smart_city-entity-Concentrator")
+@Data
+public class Concentrator {
+
+    @ApiModelProperty(value="主键")
+    private Integer id;
+
+    @ApiModelProperty(value="站点,参考sc_site主键",hidden = true)
+    private Integer siteId;
+
+    @ApiModelProperty(value="客户")
+    private Integer customerId;
+
+    @ApiModelProperty(value="集中器编码")
+    private String serialNumber;
+
+    @ApiModelProperty(value="集中器名称")
+    private String name;
+
+    @ApiModelProperty(value="集中器类型,参考sc_w_meter_type主键",hidden = true)
+    private Integer type;
+
+    @ApiModelProperty(value="省,参考sc_area",hidden = true)
+    private Integer province;
+
+    @ApiModelProperty(value="市,参考sc_area",hidden = true)
+    private Integer city;
+
+    @ApiModelProperty(value="区,参考sc_area",hidden = true)
+    private Integer region;
+
+    @ApiModelProperty(value="建筑,参考sc_building")
+    private Integer buildingId;
+
+    @ApiModelProperty(value="安装地址")
+    private String address;
+
+    @ApiModelProperty(value="设备状态 0:离线 1:在线")
+    private Integer deviceStatus;
+
+    @ApiModelProperty(value="设备类型")
+    private Integer deviceType;
+
+    @ApiModelProperty(value="波特率 1:1200 b/s 2:2400 b/s 3:9600 b/s")
+    private Integer baudRate;
+
+    @ApiModelProperty(value="IP地址")
+    private String ip;
+
+    @ApiModelProperty(value="端口")
+    private Integer port;
+
+    @ApiModelProperty(value="sim卡号")
+    private String simNo;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="更新时间")
+    private LocalDateTime dateUpdate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人",hidden = true)
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人",hidden = true)
+    private String updateBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态",hidden = true)
+    private Integer status;
+}

+ 52 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/ConcentratorCheck.java

@@ -0,0 +1,52 @@
+package com.bz.smart_city.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+@ApiModel(value="com-bz-smart_city-entity-ConcentratorCheck")
+@Data
+public class ConcentratorCheck {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    @ApiModelProperty(value="集中器id")
+    private Integer concentratorId;
+
+    @ApiModelProperty(value="测量点号")
+    private String port;
+
+    @ApiModelProperty(value="设备水表电子号")
+    private String deviceWaterNo;
+
+    @ApiModelProperty(value="集中器水表电子号")
+    private String concentratorWaterNo;
+
+
+    @ApiModelProperty(value="校验结果 1:正常 2:集中器档案缺失 3:档案不一致")
+    private Integer checkResult;
+
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="更新时间")
+    private LocalDateTime dateUpdate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人")
+    private String createBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人")
+    private String updateBy;
+}

+ 50 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/WaterRelatedDevice.java

@@ -0,0 +1,50 @@
+package com.bz.smart_city.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+/**
+    * 水表可以关联集中器、采集器
+    */
+@ApiModel(value="com-bz-smart_city-entity-WaterRelatedDevice")
+@Data
+public class WaterRelatedDevice {
+
+    @ApiModelProperty(value="设备id")
+    private Long deviceId;
+
+    @ApiModelProperty(value="参考集中器表")
+    private Integer concentratorId;
+
+    @ApiModelProperty(value="参考采集器表")
+    private Integer collectorId;
+
+    /**
+    * 通道号id
+    */
+    @ApiModelProperty(value="通道号id")
+    private Integer channelNumberId;
+
+    @ApiModelProperty(value="测量点号")
+    private String port;
+
+    @ApiModelProperty(value="备注")
+    private String remark;
+
+    @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;
+}

+ 23 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/ChannelNumberService.java

@@ -0,0 +1,23 @@
+package com.bz.smart_city.service;
+
+import java.util.List;
+import com.bz.smart_city.entity.ChannelNumber;
+
+public interface ChannelNumberService {
+
+
+    int insertSelective(ChannelNumber record);
+
+    int updateByPrimaryKeySelective(ChannelNumber record);
+
+    int batchInsert(List<ChannelNumber> list);
+
+    List<ChannelNumber> getList(String concentratorId);
+
+    void add(ChannelNumber channelNumber);
+
+    void edit(ChannelNumber channelNumber);
+
+    void delete(Integer id);
+}
+

+ 30 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/CollectorService.java

@@ -0,0 +1,30 @@
+package com.bz.smart_city.service;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.dto.BuildingSelectDto;
+import com.bz.smart_city.dto.CollectorDto;
+import com.bz.smart_city.entity.Collector;
+public interface CollectorService{
+
+
+    int insertSelective(Collector record);
+
+    int updateByPrimaryKeySelective(Collector record);
+
+    int batchInsert(List<Collector> list);
+
+    Pagination<CollectorDto> getPage(String collectorNo, String serialNumber, String address, Integer provinceId, Integer cityId, Integer regionId, Integer communityId, Integer buildingId, int pageNum, int pageSize);
+
+    List<CollectorDto> getList(String collectorNo, String serialNumber);
+
+    List<BuildingSelectDto> getAreaList(String collectorNo, String serialNumber, String address);
+
+    void add(Collector collector);
+
+    void edit(Collector collector);
+
+    void delete(Integer id);
+}

+ 21 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/ConcentratorCheckService.java

@@ -0,0 +1,21 @@
+package com.bz.smart_city.service;
+
+import java.util.List;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.entity.ConcentratorCheck;
+public interface ConcentratorCheckService{
+
+
+    int insertSelective(ConcentratorCheck record);
+
+    int updateByPrimaryKeySelective(ConcentratorCheck record);
+
+    int batchInsert(List<ConcentratorCheck> list);
+
+    void archivesCheck(Integer concentratorId);
+
+    Pagination<ConcentratorCheck> getPage(Integer concentratorId, Integer checkResult, int pageNum, int pageSize);
+
+    void checkClear(Integer concentratorId);
+}

+ 31 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/ConcentratorService.java

@@ -0,0 +1,31 @@
+package com.bz.smart_city.service;
+
+import java.util.List;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.dto.BuildingSelectDto;
+import com.bz.smart_city.dto.ConcentratorDto;
+import com.bz.smart_city.entity.Concentrator;
+public interface ConcentratorService{
+
+
+    int insertSelective(Concentrator record);
+
+    int updateByPrimaryKeySelective(Concentrator record);
+
+    int batchInsert(List<Concentrator> list);
+
+    Pagination<ConcentratorDto> getPage(String serialNumber, Integer deviceStatus, Integer customerId, String address, Integer provinceId, Integer cityId, Integer regionId, Integer communityId, Integer buildingId, int pageNum, int pageSize);
+
+    List<ConcentratorDto> getList(String serialNumber);
+
+    List<BuildingSelectDto> getAreaList(String serialNumber, Integer deviceStatus, Integer customerId, String address);
+
+    void add(Concentrator concentrator);
+
+    void edit(Concentrator concentrator);
+
+    void delete(Integer id);
+
+    void refreshStatus(Integer id);
+}

+ 16 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/WaterRelatedDeviceService.java

@@ -0,0 +1,16 @@
+package com.bz.smart_city.service;
+
+import java.util.List;
+import com.bz.smart_city.entity.WaterRelatedDevice;
+
+public interface WaterRelatedDeviceService {
+
+
+    int insertSelective(WaterRelatedDevice record);
+
+    int updateByPrimaryKeySelective(WaterRelatedDevice record);
+
+    int batchInsert(List<WaterRelatedDevice> list);
+
+}
+

+ 105 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ChannelNumberServiceImpl.java

@@ -0,0 +1,105 @@
+package com.bz.smart_city.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.commom.exception.ServiceException;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
+import com.bz.smart_city.dto.LoginUser;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+import com.bz.smart_city.entity.ChannelNumber;
+import com.bz.smart_city.dao.ChannelNumberMapper;
+import com.bz.smart_city.service.ChannelNumberService;
+
+@Slf4j
+@Service
+public class ChannelNumberServiceImpl implements ChannelNumberService {
+
+    @Resource
+    private ChannelNumberMapper channelNumberMapper;
+    @Autowired
+    private WaterRelatedDeviceMapper waterRelatedDeviceMapper;
+
+    @Override
+    public int insertSelective(ChannelNumber record) {
+        return channelNumberMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(ChannelNumber record) {
+        return channelNumberMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public int batchInsert(List<ChannelNumber> list) {
+        return channelNumberMapper.batchInsert(list);
+    }
+
+    @Override
+    public List<ChannelNumber> getList(String concentratorId) {
+        return channelNumberMapper.getList(concentratorId);
+    }
+
+    @Override
+    public void add(ChannelNumber channelNumber) {
+        log.info("begin add ChannelNumber {}", JSON.toJSONString(channelNumber));
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        //校验
+        int result = channelNumberMapper.findUnique(null, channelNumber.getChannelNo(), channelNumber.getChannelName());
+        if (result > 0) {
+            throw new ServiceException(ResultStatus.CHANNEL_NUMBER_NOT_EXISTED);
+        }
+
+        channelNumber.setSiteId(loginUser.getSiteId());
+        channelNumber.setStatus(1);
+        channelNumber.setCreateBy(loginUser.getUsername());
+        channelNumber.setDateCreate(LocalDateTime.now());
+        channelNumber.setUpdateBy(loginUser.getUsername());
+        channelNumber.setDateUpdate(LocalDateTime.now());
+        this.insertSelective(channelNumber);
+        log.info("end add ChannelNumber");
+    }
+
+    @Override
+    public void edit(ChannelNumber channelNumber) {
+        log.info("begin edit ChannelNumber {}", JSON.toJSONString(channelNumber));
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        //校验
+        int result = channelNumberMapper.findUnique(channelNumber.getId(), channelNumber.getChannelNo(), channelNumber.getChannelName());
+        if (result > 0) {
+            throw new ServiceException(ResultStatus.CHANNEL_NUMBER_NOT_EXISTED);
+        }
+
+        channelNumber.setUpdateBy(loginUser.getUsername());
+        channelNumber.setDateUpdate(LocalDateTime.now());
+        this.updateByPrimaryKeySelective(channelNumber);
+        log.info("end edit ChannelNumber");
+    }
+
+    @Override
+    public void delete(Integer id) {
+        log.info("begin delete id = {}", id);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer deviceCount = waterRelatedDeviceMapper.countByChannelNumberId(id);
+        if (deviceCount > 0) {
+            throw new ServiceException(ResultStatus.CHANNEL_NUMBER_RELATED_NOT_EXISTED);
+        }
+
+        ChannelNumber channelNumber = new ChannelNumber();
+        channelNumber.setId(id);
+        channelNumber.setStatus(0);
+        channelNumber.setUpdateBy(loginUser.getUsername());
+        channelNumber.setDateUpdate(LocalDateTime.now());
+        this.updateByPrimaryKeySelective(channelNumber);
+        log.info("end delete ChannelNumber");
+    }
+}
+

+ 127 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CollectorServiceImpl.java

@@ -0,0 +1,127 @@
+package com.bz.smart_city.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.commom.exception.ServiceException;
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
+import com.bz.smart_city.dto.BuildingSelectDto;
+import com.bz.smart_city.dto.BuildingSelectInfoDto;
+import com.bz.smart_city.dto.CollectorDto;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.service.BuildingService;
+import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+import com.bz.smart_city.dao.CollectorMapper;
+import com.bz.smart_city.entity.Collector;
+import com.bz.smart_city.service.CollectorService;
+
+@Slf4j
+@Service
+public class CollectorServiceImpl implements CollectorService{
+
+    @Resource
+    private CollectorMapper collectorMapper;
+    @Autowired
+    private BuildingService buildingService;
+    @Autowired
+    private WaterRelatedDeviceMapper waterRelatedDeviceMapper;
+
+    @Override
+    public int insertSelective(Collector record) {
+        return collectorMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(Collector record) {
+        return collectorMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public int batchInsert(List<Collector> list) {
+        return collectorMapper.batchInsert(list);
+    }
+
+    @Override
+    public Pagination<CollectorDto> getPage(String collectorNo, String serialNumber, String address, Integer provinceId, Integer cityId, Integer regionId, Integer communityId, Integer buildingId, int pageNum, int pageSize) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        PageHelper.startPage(pageNum,pageSize);
+        List<CollectorDto> list = collectorMapper.getList(
+                loginUser.getSiteId(),collectorNo,serialNumber,address,
+                provinceId,cityId,regionId,communityId,buildingId
+        );
+        return new Pagination<>(list);
+    }
+
+    @Override
+    public List<CollectorDto> getList(String collectorNo, String serialNumber) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return collectorMapper.getList(loginUser.getSiteId(),collectorNo,serialNumber,null,null,null,null,null,null);
+    }
+
+    @Override
+    public List<BuildingSelectDto> getAreaList(String collectorNo, String serialNumber, String address) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<BuildingSelectInfoDto> buildingList = collectorMapper.getAreaList(
+                loginUser.getSiteId(),collectorNo,serialNumber,address);
+        return buildingService.areaList(buildingList);
+    }
+
+    @Override
+    public void add(Collector collector) {
+        log.info("begin add Collector = {}", JSON.toJSONString(collector));
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        //校验
+        int result = collectorMapper.findByCollectorNoUnique(null, collector.getConcentratorId(),collector.getCollectorNo());
+        if (result > 0) {
+            throw new ServiceException(ResultStatus.COLLECTOR_NOT_EXISTED);
+        }
+
+        collector.setSiteId(loginUser.getSiteId());
+        collector.setStatus(1);
+        collector.setCreateBy(loginUser.getUsername());
+        collector.setDateCreate(LocalDateTime.now());
+        collector.setUpdateBy(loginUser.getUsername());
+        collector.setDateUpdate(LocalDateTime.now());
+        this.insertSelective(collector);
+        log.info("end add Collector");
+    }
+
+    @Override
+    public void edit(Collector collector) {
+        log.info("begin edit Collector = {}", JSON.toJSONString(collector));
+        //校验
+        int result = collectorMapper.findByCollectorNoUnique(collector.getId(), collector.getConcentratorId(),collector.getCollectorNo());
+        if (result > 0) {
+            throw new ServiceException(ResultStatus.COLLECTOR_NOT_EXISTED);
+        }
+        this.updateByPrimaryKeySelective(collector);
+        log.info("end edit Collector");
+    }
+
+    @Override
+    public void delete(Integer id) {
+        log.info("begin delete Collector id={}", id);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer deviceCount = waterRelatedDeviceMapper.countByConcentratorId(id);
+        if(deviceCount > 0){
+            throw new ServiceException(ResultStatus.COLLECTOR_RELATED_NOT_EXISTED);
+        }
+
+        Collector collector = new Collector();
+        collector.setId(id);
+        collector.setStatus(1);
+        collector.setUpdateBy(loginUser.getUsername());
+        collector.setDateUpdate(LocalDateTime.now());
+        this.updateByPrimaryKeySelective(collector);
+        log.info("end delete Collector");
+    }
+}

+ 52 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorCheckServiceImpl.java

@@ -0,0 +1,52 @@
+package com.bz.smart_city.service.impl;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.service.udip.GdAgentUtils;
+import com.github.pagehelper.PageHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.List;
+import com.bz.smart_city.entity.ConcentratorCheck;
+import com.bz.smart_city.dao.ConcentratorCheckMapper;
+import com.bz.smart_city.service.ConcentratorCheckService;
+@Service
+public class ConcentratorCheckServiceImpl implements ConcentratorCheckService{
+
+    @Resource
+    private ConcentratorCheckMapper concentratorCheckMapper;
+    @Autowired
+    private GdAgentUtils gdAgentUtils;
+
+    @Override
+    public int insertSelective(ConcentratorCheck record) {
+        return concentratorCheckMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(ConcentratorCheck record) {
+        return concentratorCheckMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public int batchInsert(List<ConcentratorCheck> list) {
+        return concentratorCheckMapper.batchInsert(list);
+    }
+
+    @Override
+    public void archivesCheck(Integer concentratorId) {
+        gdAgentUtils.archivesCheck(concentratorId);
+    }
+
+    @Override
+    public Pagination<ConcentratorCheck> getPage(Integer concentratorId, Integer checkResult, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum,pageSize);
+        List<ConcentratorCheck> list = concentratorCheckMapper.getList(concentratorId,checkResult);
+        return new Pagination<>(list);
+    }
+
+    @Override
+    public void checkClear(Integer concentratorId) {
+        concentratorCheckMapper.checkClear(concentratorId);
+    }
+}

+ 177 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorServiceImpl.java

@@ -0,0 +1,177 @@
+package com.bz.smart_city.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.commom.exception.ServiceException;
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.BuildingMapper;
+import com.bz.smart_city.dao.CollectorMapper;
+import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
+import com.bz.smart_city.dto.*;
+import com.bz.smart_city.service.BuildingService;
+import com.bz.smart_city.service.udip.GdAgentUtils;
+import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+import com.bz.smart_city.dao.ConcentratorMapper;
+import com.bz.smart_city.entity.Concentrator;
+import com.bz.smart_city.service.ConcentratorService;
+
+@Slf4j
+@Service
+public class ConcentratorServiceImpl implements ConcentratorService{
+
+    @Resource
+    private ConcentratorMapper concentratorMapper;
+    @Autowired
+    private BuildingService buildingService;
+    @Resource
+    private BuildingMapper buildingMapper;
+    @Autowired
+    private CollectorMapper collectorMapper;
+    @Autowired
+    private WaterRelatedDeviceMapper waterRelatedDeviceMapper;
+    @Autowired
+    private GdAgentUtils gdAgentUtils;
+
+    @Override
+    public int insertSelective(Concentrator record) {
+        return concentratorMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(Concentrator record) {
+        return concentratorMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public int batchInsert(List<Concentrator> list) {
+        return concentratorMapper.batchInsert(list);
+    }
+
+    @Override
+    public Pagination<ConcentratorDto> getPage(String serialNumber, Integer deviceStatus, Integer customerId, String address, Integer provinceId, Integer cityId, Integer regionId, Integer communityId, Integer buildingId, int pageNum, int pageSize) {
+        LoginUser loginUser = new LoginUser();
+        PageHelper.startPage(pageNum,pageSize);
+        List<ConcentratorDto> list = concentratorMapper.getList(
+                loginUser.getSiteId(),serialNumber,deviceStatus,customerId,address,
+                provinceId,cityId,regionId,communityId,buildingId);
+        return new Pagination<>(list);
+    }
+
+    @Override
+    public List<ConcentratorDto> getList(String serialNumber) {
+        LoginUser loginUser = new LoginUser();
+        List<ConcentratorDto> list = concentratorMapper.findList(
+                loginUser.getSiteId(),serialNumber);
+        return list;
+    }
+
+    @Override
+    public List<BuildingSelectDto> getAreaList(String serialNumber, Integer deviceStatus, Integer customerId, String address) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        List<BuildingSelectInfoDto> buildingList = concentratorMapper.getAreaList(
+                loginUser.getSiteId(),serialNumber,deviceStatus,customerId,address);
+        return buildingService.areaList(buildingList);
+    }
+
+    @Override
+    public void add(Concentrator concentrator) {
+        log.info("begin add Concentrator ,{}", JSON.toJSONString(concentrator));
+
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        //校验
+        int result = concentratorMapper.findBySerialNumberUnique(null,concentrator.getSerialNumber());
+        if (result > 0) {
+            throw new ServiceException(ResultStatus.CONCENTRATOR_NOT_EXISTED);
+        }
+
+        BuildingDto building = buildingMapper.getBuilding(concentrator.getBuildingId());
+        if (building != null) {
+            concentrator.setSiteId(loginUser.getSiteId());
+            concentrator.setProvince(building.getProvince());
+            concentrator.setCity(building.getCity());
+            concentrator.setRegion(building.getRegion());
+        }
+        concentrator.setDeviceStatus(0);
+        concentrator.setStatus(1);
+        concentrator.setCreateBy(loginUser.getUsername());
+        concentrator.setUpdateBy(loginUser.getUsername());
+        concentrator.setDateCreate(LocalDateTime.now());
+        concentrator.setDateUpdate(LocalDateTime.now());
+        this.insertSelective(concentrator);
+
+        log.info("end add Concentrator");
+    }
+
+    @Override
+    public void edit(Concentrator concentrator) {
+        log.info("begin edit Concentrator ,{}", JSON.toJSONString(concentrator));
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        //校验
+        int result = concentratorMapper.findBySerialNumberUnique(concentrator.getId(),concentrator.getSerialNumber());
+        if (result > 0) {
+            throw new ServiceException(ResultStatus.CONCENTRATOR_NOT_EXISTED);
+        }
+
+        BuildingDto building = buildingMapper.getBuilding(concentrator.getBuildingId());
+        if (building != null) {
+            concentrator.setSiteId(loginUser.getSiteId());
+            concentrator.setProvince(building.getProvince());
+            concentrator.setCity(building.getCity());
+            concentrator.setRegion(building.getRegion());
+        }
+        concentrator.setUpdateBy(loginUser.getUsername());
+        concentrator.setDateUpdate(LocalDateTime.now());
+        this.updateByPrimaryKeySelective(concentrator);
+
+        log.info("end edit Concentrator");
+    }
+
+    @Override
+    public void delete(Integer id) {
+        log.info("begin delete Concentrator ,{}", id);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer collectorCount = collectorMapper.countByConcentratorId(id);
+        if(collectorCount > 0){
+            throw new ServiceException(ResultStatus.CONCENTRATOR_RELATED_NOT_EXISTED);
+        }
+
+        Integer deviceCount = waterRelatedDeviceMapper.countByConcentratorId(id);
+        if(deviceCount > 0){
+            throw new ServiceException(ResultStatus.CONCENTRATOR_RELATED_NOT_EXISTED);
+        }
+
+        Concentrator concentrator = new Concentrator();
+        concentrator.setId(id);
+        concentrator.setStatus(1);
+        concentrator.setUpdateBy(loginUser.getUsername());
+        concentrator.setDateUpdate(LocalDateTime.now());
+        this.updateByPrimaryKeySelective(concentrator);
+        log.info("end delete Concentrator");
+    }
+
+    @Override
+    public void refreshStatus(Integer id) {
+        log.info("begin refreshStatus id = {}", id);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        Integer status = gdAgentUtils.readConcentratorState(id);
+        if (status != null) {
+            Concentrator concentrator = new Concentrator();
+            concentrator.setId(id);
+            concentrator.setDeviceStatus(status);
+            concentrator.setUpdateBy(loginUser.getUsername());
+            concentrator.setDateUpdate(LocalDateTime.now());
+            this.updateByPrimaryKeySelective(concentrator);
+        }
+        log.info("end refreshStatus ");
+    }
+}

+ 32 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterRelatedDeviceServiceImpl.java

@@ -0,0 +1,32 @@
+package com.bz.smart_city.service.impl;
+
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.util.List;
+import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
+import com.bz.smart_city.entity.WaterRelatedDevice;
+import com.bz.smart_city.service.WaterRelatedDeviceService;
+
+@Service
+public class WaterRelatedDeviceServiceImpl implements WaterRelatedDeviceService {
+
+    @Resource
+    private WaterRelatedDeviceMapper waterRelatedDeviceMapper;
+
+    @Override
+    public int insertSelective(WaterRelatedDevice record) {
+        return waterRelatedDeviceMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(WaterRelatedDevice record) {
+        return waterRelatedDeviceMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public int batchInsert(List<WaterRelatedDevice> list) {
+        return waterRelatedDeviceMapper.batchInsert(list);
+    }
+
+}
+

+ 125 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/GdAgentUtils.java

@@ -0,0 +1,125 @@
+package com.bz.smart_city.service.udip;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.bz.smart_city.commom.model.AjaxMessage;
+import com.bz.smart_city.dao.ConcentratorCheckMapper;
+import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
+import com.bz.smart_city.dto.DeviceDto;
+import com.bz.smart_city.entity.ConcentratorCheck;
+import com.bz.smart_city.entity.Device;
+import com.bz.smart_city.service.ConcentratorCheckService;
+import com.bz.smart_city.service.udip.model.ConcentratorInfo;
+import com.bz.smart_city.service.udip.model.MeterInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+@Slf4j
+@Service
+public class GdAgentUtils {
+
+    private RestTemplate restTemplate = new RestTemplate();
+    @Autowired
+    private WaterRelatedDeviceMapper waterRelatedDeviceMapper;
+    @Autowired
+    private ConcentratorCheckMapper concentratorCheckMapper;
+
+    //读档案--按集中器读取档案信息
+    @Async
+    public void archivesCheck(Integer concentratorId){
+        log.info("begin archivesCheck");
+        String url = "http://10.0.0.160:6377/api/readmeter/readMeterInfoByID?concentratorId={concentratorId}";
+
+        Map<String,Integer> map = new HashMap<String,Integer>();
+        map.put("concentratorId",concentratorId);
+        JSONObject jsonObject = restTemplate.getForObject(url, JSONObject.class,map);
+        log.info("jsonObject ={}", JSON.toJSONString(jsonObject));
+        List<MeterInfo> list = newArrayList();
+        if(jsonObject != null){
+            if(jsonObject.getInteger("status")==1){
+                list = jsonObject.getJSONArray("data").toJavaList(MeterInfo.class);
+                log.info("成功 res="+list);
+            }else {
+                log.info("失败");
+            }
+        }
+        this.comparison(concentratorId,list);
+        log.info("end archivesCheck");
+    }
+
+    private void comparison(Integer concentratorId,List<MeterInfo> list){
+        List<DeviceDto> deviceList = waterRelatedDeviceMapper.getDevice(concentratorId);
+        if (deviceList != null && deviceList.size() > 0) {
+            List<ConcentratorCheck> concentratorCheckList = newArrayList();
+            for (DeviceDto deviceDto : deviceList) {
+                ConcentratorCheck concentratorCheck = new ConcentratorCheck();
+                concentratorCheck.setConcentratorId(concentratorId);
+                concentratorCheck.setPort(deviceDto.getPort());
+                concentratorCheck.setDeviceWaterNo(deviceDto.getWaterMeterNo());
+                concentratorCheck.setStatus(1);
+                concentratorCheck.setDateCreate(LocalDateTime.now());
+                concentratorCheck.setDateUpdate(LocalDateTime.now());
+                concentratorCheck.setCreateBy("system");
+                concentratorCheck.setUpdateBy("system");
+                if (list != null && list.size() > 0) {
+                    Boolean match = false;
+                    for (MeterInfo meterInfo : list) {
+                        if(meterInfo.getChannelPort().toString().equals(deviceDto.getPort())){
+                            match = true;
+                            concentratorCheck.setConcentratorWaterNo(meterInfo.getElectronicNo());
+                            //电子号后9位对比
+                            String deviceElectronicNo = deviceDto.getWaterMeterNo().substring(deviceDto.getWaterMeterNo().length()-9);
+                            String concentratorElectronicNo = meterInfo.getElectronicNo().substring(meterInfo.getElectronicNo().length()-9);
+                            if(deviceElectronicNo.equals(concentratorElectronicNo)){
+                                concentratorCheck.setCheckResult(1);//正常
+                            }else {
+                                concentratorCheck.setCheckResult(3);//档案不一致
+                            }
+                            continue;
+                        }
+                    }
+                    if(!match){
+                        concentratorCheck.setCheckResult(2);//集中器档案缺失
+                    }
+                }else {
+                    concentratorCheck.setCheckResult(2);//集中器档案缺失
+                }
+
+                concentratorCheckList.add(concentratorCheck);
+            }
+
+            concentratorCheckMapper.batchInsert(concentratorCheckList);
+        }
+    }
+
+    public Integer readConcentratorState(Integer concentratorId){
+        log.info("begin readConcentratorState");
+        String url = "http://10.0.0.160:6377/api/readmeter/readConcentratorState?concentratorId={concentratorId}";
+        Map<String,Integer> map = new HashMap<String,Integer>();
+        map.put("concentratorId",concentratorId);
+        ConcentratorInfo concentratorInfo = restTemplate.getForObject(url, ConcentratorInfo.class,map);
+        log.info("concentratorInfo ={}", JSON.toJSONString(concentratorInfo));
+        if(concentratorInfo != null){
+            if(concentratorInfo.getResult()==1){
+                return concentratorInfo.getConcentratorState();
+            }
+        }
+        return null;
+    }
+}

+ 19 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/model/ConcentratorInfo.java

@@ -0,0 +1,19 @@
+package com.bz.smart_city.service.udip.model;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class ConcentratorInfo {
+    @ApiModelProperty("结果:0 失败 1成功")
+    private Integer result;
+
+    @ApiModelProperty("结果描述")
+    private String message;
+
+    @ApiModelProperty("连接IDC状态(1 正常 0 失败) ")
+    private Integer idcState;
+
+    @ApiModelProperty("集中器状态(0:不在线 1:在线) ")
+    private Integer concentratorState;
+}

+ 27 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/model/MeterInfo.java

@@ -0,0 +1,27 @@
+package com.bz.smart_city.service.udip.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel
+public class MeterInfo {
+    @ApiModelProperty("集中器所属IDC的端口")
+    private Integer port;
+
+    @ApiModelProperty("集中器状态(0:不在线 1:在线)")
+    private Integer concentratorState;
+
+    @ApiModelProperty("水表电子号")
+    private String electronicNo;
+
+    @ApiModelProperty("测量点号")
+    private Integer channelPort;
+
+    @ApiModelProperty("连接IDC状态(true 正常 false 失败) ")
+    private Boolean idcState;
+
+    @ApiModelProperty("抄表状态(true 正常 false 失败)")
+    private Boolean readState;
+}

+ 152 - 0
smart-city-platform/src/main/resources/mapper/ChannelNumberMapper.xml

@@ -0,0 +1,152 @@
+<?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.ChannelNumberMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.ChannelNumber">
+    <!--@mbg.generated-->
+    <!--@Table sc_channel_number-->
+    <id column="id" property="id" />
+    <result column="site_id" property="siteId" />
+    <result column="concentrator_id" property="concentratorId" />
+    <result column="channel_name" property="channelName" />
+    <result column="channel_no" property="channelNo" />
+    <result column="status" property="status" />
+    <result column="remark" property="remark" />
+    <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, site_id, concentrator_id, channel_name, channel_no, `status`, remark, date_create, 
+    date_update, create_by, update_by
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.ChannelNumber" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_channel_number
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        site_id,
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id,
+      </if>
+      <if test="channelName != null">
+        channel_name,
+      </if>
+      <if test="channelNo != null">
+        channel_no,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="remark != null">
+        remark,
+      </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="siteId != null">
+        #{siteId},
+      </if>
+      <if test="concentratorId != null">
+        #{concentratorId},
+      </if>
+      <if test="channelName != null">
+        #{channelName},
+      </if>
+      <if test="channelNo != null">
+        #{channelNo},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="remark != null">
+        #{remark},
+      </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.bz.smart_city.entity.ChannelNumber">
+    <!--@mbg.generated-->
+    update sc_channel_number
+    <set>
+      <if test="siteId != null">
+        site_id = #{siteId},
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id = #{concentratorId},
+      </if>
+      <if test="channelName != null">
+        channel_name = #{channelName},
+      </if>
+      <if test="channelNo != null">
+        channel_no = #{channelNo},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="remark != null">
+        remark = #{remark},
+      </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>
+  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_channel_number
+    (site_id, concentrator_id, channel_name, channel_no, `status`, remark, date_create, 
+      date_update, create_by, update_by)
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.siteId}, #{item.concentratorId}, #{item.channelName}, #{item.channelNo}, 
+        #{item.status}, #{item.remark}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, 
+        #{item.updateBy})
+    </foreach>
+  </insert>
+
+  <select id="getList" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List" />
+    from sc_channel_number where status = 1 and concentrator_id = #{concentratorId}
+    order by date_create asc
+  </select>
+
+  <select id="findUnique" resultType="int">
+    select count(1) from sc_channel_number where status = 1 and (channel_no = #{channelNo} or channel_name = #{channelNamae})
+    <if test="id != null"> and id != #{id}</if>
+  </select>
+</mapper>

+ 233 - 0
smart-city-platform/src/main/resources/mapper/CollectorMapper.xml

@@ -0,0 +1,233 @@
+<?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.CollectorMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Collector">
+    <!--@mbg.generated-->
+    <!--@Table sc_collector-->
+    <id column="id" property="id" />
+    <result column="site_id" property="siteId" />
+    <result column="customer_id" property="customerId" />
+    <result column="building_id" property="buildingId" />
+    <result column="collector_no" property="collectorNo" />
+    <result column="concentrator_id" property="concentratorId" />
+    <result column="device_type" property="deviceType" />
+    <result column="address" property="address" />
+    <result column="status" property="status" />
+    <result column="remark" property="remark" />
+    <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, site_id, customer_id, building_id, collector_no, concentrator_id, device_type, 
+    address, `status`, remark, date_create, date_update, create_by, update_by
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.Collector" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_collector
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        site_id,
+      </if>
+      <if test="customerId != null">
+        customer_id,
+      </if>
+      <if test="buildingId != null">
+        building_id,
+      </if>
+      <if test="collectorNo != null">
+        collector_no,
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id,
+      </if>
+      <if test="deviceType != null">
+        device_type,
+      </if>
+      <if test="address != null">
+        address,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="remark != null">
+        remark,
+      </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="siteId != null">
+        #{siteId},
+      </if>
+      <if test="customerId != null">
+        #{customerId},
+      </if>
+      <if test="buildingId != null">
+        #{buildingId},
+      </if>
+      <if test="collectorNo != null">
+        #{collectorNo},
+      </if>
+      <if test="concentratorId != null">
+        #{concentratorId},
+      </if>
+      <if test="deviceType != null">
+        #{deviceType},
+      </if>
+      <if test="address != null">
+        #{address},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="remark != null">
+        #{remark},
+      </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.bz.smart_city.entity.Collector">
+    <!--@mbg.generated-->
+    update sc_collector
+    <set>
+      <if test="siteId != null">
+        site_id = #{siteId},
+      </if>
+      <if test="customerId != null">
+        customer_id = #{customerId},
+      </if>
+      <if test="buildingId != null">
+        building_id = #{buildingId},
+      </if>
+      <if test="collectorNo != null">
+        collector_no = #{collectorNo},
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id = #{concentratorId},
+      </if>
+      <if test="deviceType != null">
+        device_type = #{deviceType},
+      </if>
+      <if test="address != null">
+        address = #{address},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="remark != null">
+        remark = #{remark},
+      </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>
+  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_collector
+    (site_id, customer_id, building_id, collector_no, concentrator_id, device_type, address, 
+      `status`, remark, date_create, date_update, create_by, update_by)
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.siteId}, #{item.customerId}, #{item.buildingId}, #{item.collectorNo}, #{item.concentratorId}, 
+        #{item.deviceType}, #{item.address}, #{item.status}, #{item.remark}, #{item.dateCreate}, 
+        #{item.dateUpdate}, #{item.createBy}, #{item.updateBy})
+    </foreach>
+  </insert>
+
+  <select id="getList" resultType="com.bz.smart_city.dto.CollectorDto">
+    select
+    soll.*,
+    scon.serial_number,
+    sb.name building_name,
+    scu.customer_name,
+    sb.province,
+    sb.city,
+    sb.region,
+    sb.community
+    from sc_collector soll
+    left join sc_concentrator scon on(scon.id = soll.concentrator_id)
+    left join sc_building sb on(sb.id = soll.building_id)
+    left join sc_customer scu on(scu.id = soll.customer_id)
+    where soll.status = 1
+    <if test="siteId != null"> and soll.site_id = #{siteId}</if>
+    <if test="collectorNo != null and collectorNo != ''"> and soll.collector_no LIKE concat('%',#{collectorNo},'%')</if>
+    <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
+    <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
+    <if test="provinceId != null"> and sb.province = #{provinceId}</if>
+    <if test="cityId != null"> and sb.city = #{cityId}</if>
+    <if test="regionId != null"> and sb.region = #{regionId}</if>
+    <if test="communityId != null"> and sb.community = #{communityId}</if>
+    <if test="buildingId != null"> and sb.id = #{buildingId}</if>
+    order by soll.date_create desc
+  </select>
+
+  <select id="getAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
+    select
+    b.id,
+    b.name,
+    b.province,
+    b.city,
+    b.region,
+    b.community,
+    b.longitude,
+    b.latitude,
+    t1.device_count
+    from sc_building b
+    right join (
+    select soll.building_id,count(1) as device_count
+    from sc_collector soll
+    left join sc_concentrator scon on(scon.id = soll.concentrator_id)
+    where soll.status = 1
+    <if test="siteId != null"> and soll.site_id = #{siteId}</if>
+    <if test="collectorNo != null and collectorNo != ''"> and soll.collector_no LIKE concat('%',#{collectorNo},'%')</if>
+    <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
+    <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
+    GROUP BY soll.building_id
+    ) t1 on (t1.building_id = b.id)
+    where b.status = 1
+  </select>
+
+  <select id="countByConcentratorId" resultType="java.lang.Integer">
+    select count(1) from sc_collector where status = 1 and concentrator_id = #{concentratorId}
+  </select>
+
+  <select id="findByCollectorNoUnique" resultType="int">
+    select count(1) from sc_collector where status = 1 and concentrator_id = #{concentratorId} and collector_no = #{collectorNo}
+    <if test="id != null"> and id != #{id}</if>
+  </select>
+</mapper>

+ 150 - 0
smart-city-platform/src/main/resources/mapper/ConcentratorCheckMapper.xml

@@ -0,0 +1,150 @@
+<?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.ConcentratorCheckMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.ConcentratorCheck">
+    <!--@mbg.generated-->
+    <!--@Table sc_concentrator_check-->
+    <id column="id" property="id" />
+    <result column="concentrator_id" property="concentratorId" />
+    <result column="port" property="port" />
+    <result column="device_water_no" property="deviceWaterNo" />
+    <result column="concentrator_water_no" property="concentratorWaterNo" />
+    <result column="check_result" property="checkResult" />
+    <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, concentrator_id, port, device_water_no, concentrator_water_no, check_result, 
+    `status`, date_create, date_update, create_by, update_by
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.ConcentratorCheck" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_concentrator_check
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="concentratorId != null">
+        concentrator_id,
+      </if>
+      <if test="port != null">
+        port,
+      </if>
+      <if test="deviceWaterNo != null">
+        device_water_no,
+      </if>
+      <if test="concentratorWaterNo != null">
+        concentrator_water_no,
+      </if>
+      <if test="checkResult != null">
+        check_result,
+      </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="concentratorId != null">
+        #{concentratorId},
+      </if>
+      <if test="port != null">
+        #{port},
+      </if>
+      <if test="deviceWaterNo != null">
+        #{deviceWaterNo},
+      </if>
+      <if test="concentratorWaterNo != null">
+        #{concentratorWaterNo},
+      </if>
+      <if test="checkResult != null">
+        #{checkResult},
+      </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.bz.smart_city.entity.ConcentratorCheck">
+    <!--@mbg.generated-->
+    update sc_concentrator_check
+    <set>
+      <if test="concentratorId != null">
+        concentrator_id = #{concentratorId},
+      </if>
+      <if test="port != null">
+        port = #{port},
+      </if>
+      <if test="deviceWaterNo != null">
+        device_water_no = #{deviceWaterNo},
+      </if>
+      <if test="concentratorWaterNo != null">
+        concentrator_water_no = #{concentratorWaterNo},
+      </if>
+      <if test="checkResult != null">
+        check_result = #{checkResult},
+      </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>
+  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_concentrator_check
+    (concentrator_id, port, device_water_no, concentrator_water_no, check_result, `status`, 
+      date_create, date_update, create_by, update_by)
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.concentratorId}, #{item.port}, #{item.deviceWaterNo}, #{item.concentratorWaterNo}, 
+        #{item.checkResult}, #{item.status}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, 
+        #{item.updateBy})
+    </foreach>
+  </insert>
+
+  <select id="getList" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"/> from sc_concentrator_check where status = 1 and concentrator_id = #{concentratorId}
+    <if test="checkResult != null"> and check_result = #{checkResult}</if>
+  </select>
+
+  <update id="checkClear">
+    update sc_concentrator_check set status=0,date_update=NOW() where status = 1 and concentrator_id = #{concentratorId}
+  </update>
+</mapper>

+ 325 - 0
smart-city-platform/src/main/resources/mapper/ConcentratorMapper.xml

@@ -0,0 +1,325 @@
+<?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.ConcentratorMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Concentrator">
+    <!--@mbg.generated-->
+    <!--@Table sc_concentrator-->
+    <id column="id" property="id" />
+    <result column="site_id" property="siteId" />
+    <result column="customer_id" property="customerId" />
+    <result column="serial_number" property="serialNumber" />
+    <result column="name" property="name" />
+    <result column="type" property="type" />
+    <result column="province" property="province" />
+    <result column="city" property="city" />
+    <result column="region" property="region" />
+    <result column="building_id" property="buildingId" />
+    <result column="address" property="address" />
+    <result column="device_status" property="deviceStatus" />
+    <result column="device_type" property="deviceType" />
+    <result column="baud_rate" property="baudRate" />
+    <result column="ip" property="ip" />
+    <result column="port" property="port" />
+    <result column="sim_no" property="simNo" />
+    <result column="date_create" property="dateCreate" />
+    <result column="date_update" property="dateUpdate" />
+    <result column="create_by" property="createBy" />
+    <result column="update_by" property="updateBy" />
+    <result column="status" property="status" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, site_id, customer_id, serial_number, `name`, `type`, province, city, region, 
+    building_id, address, device_status, device_type, baud_rate, ip, port, sim_no, date_create, 
+    date_update, create_by, update_by, `status`
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.Concentrator" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_concentrator
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        site_id,
+      </if>
+      <if test="customerId != null">
+        customer_id,
+      </if>
+      <if test="serialNumber != null">
+        serial_number,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="type != null">
+        `type`,
+      </if>
+      <if test="province != null">
+        province,
+      </if>
+      <if test="city != null">
+        city,
+      </if>
+      <if test="region != null">
+        region,
+      </if>
+      <if test="buildingId != null">
+        building_id,
+      </if>
+      <if test="address != null">
+        address,
+      </if>
+      <if test="deviceStatus != null">
+        device_status,
+      </if>
+      <if test="deviceType != null">
+        device_type,
+      </if>
+      <if test="baudRate != null">
+        baud_rate,
+      </if>
+      <if test="ip != null">
+        ip,
+      </if>
+      <if test="port != null">
+        port,
+      </if>
+      <if test="simNo != null">
+        sim_no,
+      </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>
+      <if test="status != null">
+        `status`,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        #{siteId},
+      </if>
+      <if test="customerId != null">
+        #{customerId},
+      </if>
+      <if test="serialNumber != null">
+        #{serialNumber},
+      </if>
+      <if test="name != null">
+        #{name},
+      </if>
+      <if test="type != null">
+        #{type},
+      </if>
+      <if test="province != null">
+        #{province},
+      </if>
+      <if test="city != null">
+        #{city},
+      </if>
+      <if test="region != null">
+        #{region},
+      </if>
+      <if test="buildingId != null">
+        #{buildingId},
+      </if>
+      <if test="address != null">
+        #{address},
+      </if>
+      <if test="deviceStatus != null">
+        #{deviceStatus},
+      </if>
+      <if test="deviceType != null">
+        #{deviceType},
+      </if>
+      <if test="baudRate != null">
+        #{baudRate},
+      </if>
+      <if test="ip != null">
+        #{ip},
+      </if>
+      <if test="port != null">
+        #{port},
+      </if>
+      <if test="simNo != null">
+        #{simNo},
+      </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>
+      <if test="status != null">
+        #{status},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.Concentrator">
+    <!--@mbg.generated-->
+    update sc_concentrator
+    <set>
+      <if test="siteId != null">
+        site_id = #{siteId},
+      </if>
+      <if test="customerId != null">
+        customer_id = #{customerId},
+      </if>
+      <if test="serialNumber != null">
+        serial_number = #{serialNumber},
+      </if>
+      <if test="name != null">
+        `name` = #{name},
+      </if>
+      <if test="type != null">
+        `type` = #{type},
+      </if>
+      <if test="province != null">
+        province = #{province},
+      </if>
+      <if test="city != null">
+        city = #{city},
+      </if>
+      <if test="region != null">
+        region = #{region},
+      </if>
+      <if test="buildingId != null">
+        building_id = #{buildingId},
+      </if>
+      <if test="address != null">
+        address = #{address},
+      </if>
+      <if test="deviceStatus != null">
+        device_status = #{deviceStatus},
+      </if>
+      <if test="deviceType != null">
+        device_type = #{deviceType},
+      </if>
+      <if test="baudRate != null">
+        baud_rate = #{baudRate},
+      </if>
+      <if test="ip != null">
+        ip = #{ip},
+      </if>
+      <if test="port != null">
+        port = #{port},
+      </if>
+      <if test="simNo != null">
+        sim_no = #{simNo},
+      </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>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_concentrator
+    (site_id, customer_id, serial_number, `name`, `type`, province, city, region, building_id, 
+      address, device_status, device_type, baud_rate, ip, port, sim_no, date_create, 
+      date_update, create_by, update_by, `status`)
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.siteId}, #{item.customerId}, #{item.serialNumber}, #{item.name}, #{item.type}, 
+        #{item.province}, #{item.city}, #{item.region}, #{item.buildingId}, #{item.address}, 
+        #{item.deviceStatus}, #{item.deviceType}, #{item.baudRate}, #{item.ip}, #{item.port}, 
+        #{item.simNo}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, #{item.updateBy}, 
+        #{item.status})
+    </foreach>
+  </insert>
+
+  <select id="getList" resultType="com.bz.smart_city.dto.ConcentratorDto">
+        select
+        scon.*,
+        (select count(1) from sc_channel_number where status = 1 and concentrator_id = scon.id) as channel_num,
+        (select count(1) from sc_collector where status = 1 and concentrator_id = scon.id) as collector_num,
+        (select count(1) from sc_water_related_device where status = 1 and concentrator_id = scon.id) as device_num,
+        sc.customer_name,
+        sdt.equipment_type,
+        sdt.model,
+        sdm.name manufacturer_name,
+        sb.name as building_name
+        from sc_concentrator scon
+        left join sc_customer sc on(sc.id = scon.customer_id)
+        left join sc_device_type sdt on (sdt.id = scon.device_type)
+        left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id )
+        left join sc_building sb on (sb.id = scon.building_id)
+        where scon.status = 1
+        <if test="siteId != null"> and scon.site_id = #{siteId}</if>
+        <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
+        <if test="deviceStatus != null"> and scon.device_status = #{deviceStatus}</if>
+        <if test="customerId != null"> and scon.customer_id = #{customerId}</if>
+        <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
+        <if test="provinceId != null"> and sb.province = #{provinceId}</if>
+        <if test="cityId != null"> and sb.city = #{cityId}</if>
+        <if test="regionId != null"> and sb.region = #{regionId}</if>
+        <if test="communityId != null"> and sb.community = #{communityId}</if>
+        <if test="buildingId != null"> and sb.id = #{buildingId}</if>
+        order by scon.date_create desc
+  </select>
+
+  <select id="findList" resultType="com.bz.smart_city.dto.ConcentratorDto">
+    select
+    scon.*
+    from sc_concentrator scon
+    where scon.status = 1
+    <if test="siteId != null"> and scon.site_id = #{siteId}</if>
+    <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
+  </select>
+
+  <select id="getAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
+    select
+    b.id,
+    b.name,
+    b.province,
+    b.city,
+    b.region,
+    b.community,
+    b.longitude,
+    b.latitude,
+    t1.device_count
+    from sc_building b
+    right join (
+    select scon.building_id,count(1) as device_count
+    from sc_concentrator scon
+    where scon.status = 1
+    <if test="siteId != null"> and scon.site_id = #{siteId}</if>
+    <if test="serialNumber != null and serialNumber != ''"> and scon.serial_number LIKE concat('%',#{serialNumber},'%')</if>
+    <if test="deviceStatus != null"> and scon.device_status = #{deviceStatus}</if>
+    <if test="customerId != null"> and scon.customer_id = #{customerId}</if>
+    <if test="address != null and address != ''"> and scon.address LIKE concat('%',#{address},'%')</if>
+    GROUP BY scon.building_id
+    ) t1 on (t1.building_id = b.id)
+    where b.status = 1
+  </select>
+
+  <select id="findBySerialNumberUnique" resultType="int">
+    select count(1) from sc_concentrator where status = 1 and serial_number = #{serialNumber}
+    <if test="id != null"> and id != #{id}</if>
+  </select>
+</mapper>

+ 8 - 6
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -349,15 +349,17 @@
     </update>
 
     <select id="getList" resultType="com.bz.smart_city.dto.DeviceDto">
-        select sd.*,sdt.equipment_type,sdt.model,sdm.name manufacturer_name,sb.name as building_name,sc.channel_name as system_name,
+        select sd.*,
+        sdt.equipment_type,sdt.model,sdt.is_valve,sdm.name manufacturer_name,
+        sb.name as building_name,sc.channel_name as system_name,
         sb.longitude,sb.latitude,
         sb.province,sb.city,sb.region,sb.community,scom.name as community_name,
-        scon.serial_number as concentrator_name,scol.collector_no as collector_name,swmed.days,swmed.last_error_type,scus.customer_name,
+        scon.serial_number as concentrator_name,scol.collector_no as collector_name,
+        scus.customer_name,
         sil.plan_time,sil.install_time,sil.accept_time,
-        swmed.meter_reading,
-        swmed.valve_status,
-        swmed.valve_button_status,
-        sdt.is_valve
+        swmed.days,swmed.last_error_type,
+        swmed.meter_reading,swmed.valve_status,
+        swmed.valve_button_status
         from sc_device sd
         left join sc_device_type sdt on (sdt.id = sd.device_type and sdt.status = 1)
         left join sc_device_manufacturer sdm on (sdm.id = sd.manufacturer_id and sdm.status = 1)

+ 162 - 0
smart-city-platform/src/main/resources/mapper/WaterRelatedDeviceMapper.xml

@@ -0,0 +1,162 @@
+<?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.WaterRelatedDeviceMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.WaterRelatedDevice">
+    <!--@mbg.generated-->
+    <!--@Table sc_water_related_device-->
+    <id column="device_id" property="deviceId" />
+    <result column="concentrator_id" property="concentratorId" />
+    <result column="collector_id" property="collectorId" />
+    <result column="channel_number_id" property="channelNumberId" />
+    <result column="port" property="port" />
+    <result column="remark" property="remark" />
+    <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-->
+    device_id, concentrator_id, collector_id, channel_number_id, port, remark, `status`, 
+    date_create, date_update, create_by, update_by
+  </sql>
+  <insert id="insertSelective" parameterType="com.bz.smart_city.entity.WaterRelatedDevice">
+    <!--@mbg.generated-->
+    insert into sc_water_related_device
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="concentratorId != null">
+        concentrator_id,
+      </if>
+      <if test="collectorId != null">
+        collector_id,
+      </if>
+      <if test="channelNumberId != null">
+        channel_number_id,
+      </if>
+      <if test="port != null">
+        port,
+      </if>
+      <if test="remark != null">
+        remark,
+      </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="deviceId != null">
+        #{deviceId},
+      </if>
+      <if test="concentratorId != null">
+        #{concentratorId},
+      </if>
+      <if test="collectorId != null">
+        #{collectorId},
+      </if>
+      <if test="channelNumberId != null">
+        #{channelNumberId},
+      </if>
+      <if test="port != null">
+        #{port},
+      </if>
+      <if test="remark != null">
+        #{remark},
+      </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.bz.smart_city.entity.WaterRelatedDevice">
+    <!--@mbg.generated-->
+    update sc_water_related_device
+    <set>
+      <if test="concentratorId != null">
+        concentrator_id = #{concentratorId},
+      </if>
+      <if test="collectorId != null">
+        collector_id = #{collectorId},
+      </if>
+      <if test="channelNumberId != null">
+        channel_number_id = #{channelNumberId},
+      </if>
+      <if test="port != null">
+        port = #{port},
+      </if>
+      <if test="remark != null">
+        remark = #{remark},
+      </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 device_id = #{deviceId}
+  </update>
+  <insert id="batchInsert" parameterType="map">
+    <!--@mbg.generated-->
+    insert into sc_water_related_device
+    (device_id, concentrator_id, collector_id, channel_number_id, port, remark, `status`, 
+      date_create, date_update, create_by, update_by)
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.deviceId}, #{item.concentratorId}, #{item.collectorId}, #{item.channelNumberId}, 
+        #{item.port}, #{item.remark}, #{item.status}, #{item.dateCreate}, #{item.dateUpdate}, 
+        #{item.createBy}, #{item.updateBy})
+    </foreach>
+  </insert>
+
+  <select id="countByConcentratorId" resultType="java.lang.Integer">
+        select count(1) from sc_water_related_device where status = 1 and concentrator_id = #{concentratorId}
+  </select>
+
+  <select id="countByChannelNumberId" resultType="java.lang.Integer">
+    select count(1) from sc_water_related_device where status = 1 and channel_number_id = #{channelNumberId}
+  </select>
+
+  <select id="getDevice" resultType="com.bz.smart_city.dto.DeviceDto">
+    select sd.id,sd.device_no,sd.water_meter_no,sd.water_meter_file_no,swrd.`port`
+    from sc_water_related_device swrd
+    inner join sc_device sd on(sd.id = swrd.device_id)
+    where swrd.status = 1 and sd.status = 1 and concentrator_id = #{concentratorId}
+  </select>
+</mapper>

+ 40 - 0
smart-city-platform/src/test/java/com/bz/smart_city/ScTest.java

@@ -3,6 +3,7 @@ package com.bz.smart_city;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.util.HttpRequest;
 import com.bz.smart_city.commom.util.Jdk8DateUtils;
 import com.bz.smart_city.commom.util.Util;
@@ -11,6 +12,7 @@ import com.bz.smart_city.dto.NotifyDto;
 import com.bz.smart_city.dto.TreeDataDto;
 import com.bz.smart_city.dto.udip.DataCommandRequestDTO;
 import com.bz.smart_city.entity.User;
+import com.bz.smart_city.service.udip.model.MeterInfo;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
@@ -18,6 +20,12 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.message.BasicNameValuePair;
 import org.junit.Test;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
 
 import javax.validation.constraints.Null;
 import java.io.IOException;
@@ -352,6 +360,38 @@ public class ScTest {
         System.out.println(list);
     }
 
+    @Test
+    public void restTemplateTest(){
+        RestTemplate restTemplate = new RestTemplate();
+        String url = "http://10.0.0.160:6377/api/readmeter/readMeterInfoByID?concentratorId={concentratorId}";
+
+        /*HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+        */
+
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        params.add("concentratorId", "918");
+
+
+        //HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(params);
+
+        //ResponseEntity<JSONObject> token = restTemplate.exchange(url, HttpMethod.GET, entity, JSONObject.class);
+        Map<String,Integer> map = new HashMap<String,Integer>();
+        map.put("concentratorId",918);
+        JSONObject jsonObject = restTemplate.getForObject(url, JSONObject.class,map);
+        log.info("jsonObject ={}", JSON.toJSONString(jsonObject));
+        List<MeterInfo> list = newArrayList();
+        if(jsonObject != null){
+            if(jsonObject.getInteger("status")==1){
+                list = jsonObject.getJSONArray("data").toJavaList(MeterInfo.class);
+                log.info("成功 res="+list);
+            }else {
+                log.info("失败");
+            }
+        }
+    }
+
+