lin 4 years ago
parent
commit
4cabdcb58a
36 changed files with 517 additions and 107 deletions
  1. 1 0
      smart-city-platform/build.gradle
  2. 3 3
      smart-city-platform/src/main/java/com/bz/smart_city/async/AsyncInstallPlanDownloadTask.java
  3. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  4. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallController.java
  5. 40 9
      smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/MobileController.java
  6. 11 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/common/TestController.java
  7. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java
  8. 107 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceData.java
  9. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceMeasuringDataDTO.java
  10. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceTypeDto.java
  11. 12 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/assistant/InstallListDTO.java
  12. 0 1
      smart-city-platform/src/main/java/com/bz/smart_city/entity/assistant/InstallList.java
  13. 12 9
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/GdDeviceResolverExcelTemplate.java
  14. 10 7
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/WaterDeviceResolverExcelTemplate.java
  15. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/RabbitConfig.java
  16. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/redis/RedisConfig.java
  17. 10 0
      smart-city-platform/src/main/java/com/bz/smart_city/repository/DeviceDataRepository.java
  18. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceDataDimService.java
  19. 18 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CollectorServiceImpl.java
  20. 20 7
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorServiceImpl.java
  21. 46 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceDataDimServiceImpl.java
  22. 13 6
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  23. 101 13
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/GdServiceImpl.java
  24. 9 11
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java
  25. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallManagerServiceImpl.java
  26. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/model/GdInputDto.java
  27. 6 2
      smart-city-platform/src/main/resources/application-dev.properties
  28. 5 1
      smart-city-platform/src/main/resources/application-prd.properties
  29. 5 1
      smart-city-platform/src/main/resources/application-sit.properties
  30. BIN
      smart-city-platform/src/main/resources/excel/installWaterMeterTemplate20210114-yc.xlsx
  31. 6 5
      smart-city-platform/src/main/resources/json/deviceCustomColumn.json
  32. 1 1
      smart-city-platform/src/main/resources/mapper/BuildingMapper.xml
  33. 30 4
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  34. 17 14
      smart-city-platform/src/main/resources/mapper/DeviceTypeMapper.xml
  35. 13 1
      smart-city-platform/src/main/resources/mapper/InstallListMapper.xml
  36. 0 1
      smart-city-platform/src/main/resources/mapper/MeterReadRecordMapper.xml

+ 1 - 0
smart-city-platform/build.gradle

@@ -105,6 +105,7 @@ dependencies {
     compile('com.aliyun:aliyun-java-sdk-core:4.1.0')
     //jdom
     compile('org.jdom:jdom:1.1')
+    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
 }
 tasks.withType(JavaCompile) {
     options.encoding = 'UTF-8'

+ 3 - 3
smart-city-platform/src/main/java/com/bz/smart_city/async/AsyncInstallPlanDownloadTask.java

@@ -341,7 +341,7 @@ public class AsyncInstallPlanDownloadTask {
 
 
             //4、获取水表类型数据
-            List<DeviceTypeDto> deviceTypeList = deviceTypeMapper.getWaterMeterType(null);
+            List<DeviceTypeDto> deviceTypeList = deviceTypeMapper.getWaterMeterType(1);
 
             //获取集中器数据和采集器数据
             List<ConcentratorDto> concentratorList = concentratorMapper.getLazyList(loginUser.getSiteId(),UserUtil.getCustomerIds());
@@ -349,7 +349,7 @@ public class AsyncInstallPlanDownloadTask {
             //5、获取安装计划清单数据
 
 
-            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installWaterMeterTemplate20201228-yc.xlsx");   //得到文档的路径
+            InputStream in = this.getClass().getClassLoader().getResourceAsStream("excel/installWaterMeterTemplate20210114-yc.xlsx");   //得到文档的路径
 
             //列表数据将存储到指定的excel文件路径
             FileOutputStream out = new FileOutputStream(filePath);
@@ -409,7 +409,7 @@ public class AsyncInstallPlanDownloadTask {
 
 
             //4、获取水表类型数据
-            List<DeviceTypeDto> deviceTypeList = deviceTypeMapper.getWaterMeterType(null);
+            List<DeviceTypeDto> deviceTypeList = deviceTypeMapper.getWaterMeterType(2);
 
             //5、获取安装计划清单数据
 

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -402,7 +402,7 @@ public class DeviceController {
             @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer startDate,
             @ApiParam(value = "查询日期,YYYYMMDD格式", required = true) @RequestParam Integer endDate
     ) {
-        List<DeviceMeasuringDataDTO> list = deviceDataDimService.getData(deviceId,startDate,endDate) ;
+        List<DeviceMeasuringDataDTO> list = deviceDataDimService.getDataV2(deviceId,startDate,endDate) ;
         return new AjaxMessage<>(ResultStatus.OK,list);
     }
 

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallController.java

@@ -117,7 +117,7 @@ public class InstallController {
     	dto.setIdCard(idCard);
     	dto.setConcentratorId(concentratorId);
     	dto.setCollectorId(collectorId);
-    	dto.setChannelNumberId(customerId);
+    	dto.setChannelNumberId(channelNumberId);
     	dto.setPort(port);
     	dto.setSealNo(sealNo);
 
@@ -185,7 +185,7 @@ public class InstallController {
     	dto.setIdCard(idCard);
 		dto.setConcentratorId(concentratorId);
 		dto.setCollectorId(collectorId);
-		dto.setChannelNumberId(customerId);
+		dto.setChannelNumberId(channelNumberId);
 		dto.setPort(port);
     	dto.setSealNo(sealNo);
 

+ 40 - 9
smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/MobileController.java

@@ -4,14 +4,12 @@ import java.time.LocalDateTime;
 import java.util.List;
 
 import com.bz.smart_city.commom.util.AssistantUserUtil;
-import com.bz.smart_city.dto.FloorDto;
-import com.bz.smart_city.dto.WaterMeterReplaceInputDto;
+import com.bz.smart_city.dto.*;
 import com.bz.smart_city.dto.assistant.*;
+import com.bz.smart_city.entity.ChannelNumber;
 import com.bz.smart_city.entity.DeviceAlarmLevel;
 import com.bz.smart_city.entity.OperationLog;
-import com.bz.smart_city.service.BuildingService;
-import com.bz.smart_city.service.DeviceService;
-import com.bz.smart_city.service.OperationLogService;
+import com.bz.smart_city.service.*;
 import com.bz.smart_city.service.assistant.InstallPlanDeviceTypeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -21,8 +19,6 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.MemberUtil;
 import com.bz.smart_city.commom.util.UserUtil;
-import com.bz.smart_city.dto.DeviceTypeDto;
-import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.service.assistant.InstallManagerService;
 
 import io.swagger.annotations.Api;
@@ -48,6 +44,12 @@ public class MobileController {
 	DeviceService deviceService;
 	@Autowired
 	private OperationLogService operationLogService;
+	@Autowired
+	private CollectorService collectorService;
+	@Autowired
+	private ConcentratorService concentratorService;
+	@Autowired
+	private ChannelNumberService channelNumberService;
 
 	@ResponseBody
 	@GetMapping("/getMeterCode")
@@ -326,7 +328,6 @@ public class MobileController {
     	dto.setCreateBy(loginAssistantUser.getPhoneNumber());
     	dto.setNewMeterStart(newMeterStart);
     	dto.setInstallTime(LocalDateTime.now());
-    	dto.setFileNo(fileNo);
     	dto.setOldMeterEnd(oldMeterEnd);
     	dto.setImageUrl(newImageUrl);
     	dto.setOldImageUrl(oldImageUrl);
@@ -361,7 +362,7 @@ public class MobileController {
 	@PostMapping("/checkDevice")
 	@ApiOperation(value = "检查设备否存在",notes = "返回原因类型 0:正常 1:设备编号雷同 2:水表电子号雷同 3:水表电子号和设备编号雷同")
 	public AjaxMessage checkDevice(
-			@ApiParam(value = "新设备编号", required = true) @RequestParam(required = true) String deviceNo,
+			@ApiParam(value = "新设备编号", required = false) @RequestParam(required = false) String deviceNo,
 			@ApiParam(value = "新水表电子号", required = true) @RequestParam(required = true) String waterMeterNo
 	){
 		Integer result = installManagerService.checkDevice(deviceNo,waterMeterNo);
@@ -377,4 +378,34 @@ public class MobileController {
 		operationLogService.addMobileOperationLog(operationLog);
 		return new AjaxMessage(ResultStatus.OK);
 	}
+
+	@GetMapping("/concentrator/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("/collector/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("/concentrator/channel/getList")
+	@ApiOperation(value = "查询通道列表")
+	public AjaxMessage<List<ChannelNumber>> getChannelList(
+			@ApiParam(value = "集中器id", required = false) @RequestParam(required = false) Integer concentratorId
+	){
+		List<ChannelNumber> list = channelNumberService.getList(concentratorId);
+		return new AjaxMessage<>(ResultStatus.OK, list);
+	}
 }

+ 11 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/common/TestController.java

@@ -475,4 +475,15 @@ public class TestController {
                 meterTypeCode,meterWSVCode);
         return new AjaxMessage(ResultStatus.OK);
     }
+
+    @ResponseBody
+    @PostMapping("/importRemoteMeterExcel")
+    @ApiOperation(value = "Execl批量导入远传水表设备", notes = "Execl批量导入设备")
+    public String importRemoteMeterExcel(
+            @ApiParam(value = "文件") @RequestParam MultipartFile file,
+            HttpServletRequest request, HttpServletResponse response
+    ) {
+        //int result = deviceService.importRemoteMeterExcel(file);
+        return "ok";
+    }
 }

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java

@@ -102,7 +102,7 @@ public interface DeviceMapper {
                                    @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("province") Integer province,
                                    @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("buildingId") Integer buildingId,
                                    @Param("locDesc") String locDesc, @Param("deviceTypeId") Integer deviceTypeId, @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus, @Param("concentratorId") Integer concentratorId, @Param("channelNumberId") Integer channelNumberId, @Param("collectorNo") String collectorNo, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate,
-                                   @Param("programItems") List<ProgramItem> programItems, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
+                                   @Param("programItems") List<ProgramItem> programItems, @Param("deviceTypeIdList") List<Integer> deviceTypeIdList, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
 
     List<DeviceDto> queryDeviceByNo(@Param("siteId") Integer siteId,
                                     @Param("sysId") Integer sysId,

+ 107 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceData.java

@@ -0,0 +1,107 @@
+package com.bz.smart_city.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 
+ * @Description  
+ * <p>设备数据表,按照设备ID进行分片</p>
+ * sh.enableSharding("meter-reading-database")
+ * sh.shardCollection("meter-reading-database.sc_device_data",{"receiveDate":1,"deviceId":1});
+ * @author wilian.peng
+ * @date 2019年11月12日 下午10:05:10
+ */
+@Data
+@ApiModel("设备数据表")
+@Document(collection = "sc_device_data")
+public class DeviceData implements Serializable{
+	private static final long serialVersionUID = 4357722209160768792L;
+	@Id
+	@ApiModelProperty("id")
+	private Long id;
+
+	@ApiModelProperty("设备ID")
+	private Long deviceId ;
+
+	@ApiModelProperty("设备编号")
+	private String deviceNo;
+
+	@ApiModelProperty("站点ID")
+	private Integer siteId ;
+
+	@ApiModelProperty(value = "厂商", position = 9)
+	private Integer manufacturerId;
+
+//	@ApiModelProperty(value = "厂商名称", position = 9)
+//	private String manufacturerName ;
+
+	@ApiModelProperty("场景ID")
+	private Integer channelId;
+
+	@ApiModelProperty("设备类型ID")
+	private Integer deviceTypeId ;
+
+//	@ApiModelProperty("设备类型名称")
+//	private String deviceTypeName;
+
+	@ApiModelProperty("建筑Id")
+	private Integer buildingId;
+
+//	private String buildingName ;
+
+	@ApiModelProperty("小区Id")
+	private Integer communityId;
+
+//	private String  communityName ;
+
+//	@ApiModelProperty("省Id")
+//	private Integer provinceId;
+//
+//	private String provinceName ;
+
+//	@ApiModelProperty("市Id")
+//	private Integer cityId;
+//
+//	private String cityName ;
+
+//	@ApiModelProperty("区Id")
+//	private Integer regionId;
+//
+//	private String regionName ;
+
+	@ApiModelProperty("设备地址")
+	private String location ;
+
+	@ApiModelProperty("上报日期")
+	private Integer receiveDate ;
+
+	@ApiModelProperty("上报详细时间")
+	private Date receiveTime;
+
+	@ApiModelProperty("状态")
+	private Integer status;
+
+	@ApiModelProperty("上报详细数据")
+	private Map<String,String> data;
+
+	@ApiModelProperty("创建时间")
+	private LocalDateTime dateCreate;
+
+	@ApiModelProperty("更新时间")
+	private LocalDateTime dateUpdate ;
+
+	@ApiModelProperty("客户Id")
+	private Integer customerId;
+
+//	@ApiModelProperty("客户名称")
+//	private String customerName ;
+}

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceMeasuringDataDTO.java

@@ -14,5 +14,5 @@ public class DeviceMeasuringDataDTO {
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "时间",position = 2)
-    private String dateTime;
+    private Date dateTime;
 }

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/DeviceTypeDto.java

@@ -37,6 +37,9 @@ public class DeviceTypeDto extends DeviceType implements Serializable {
     @ApiModelProperty(value = "所属场景,水务专用")
     private Integer channelId;
 
+    @ApiModelProperty(value = "水表类型,1:远传表,2:智能表,9:流量计")
+    private Integer meterType;
+
     @ApiModelProperty(value = "测点", position = 102, hidden = true)
     private List<DeviceMeasuringPoint> measuringPoint;
 

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

@@ -63,15 +63,27 @@ public class InstallListDTO extends InstallList {
 	@ApiModelProperty(value="参考集中器表", position = 15)
 	private Integer concentratorId;
 
+	@ApiModelProperty(value="参考集中器表", position = 15)
+	private String concentratorName;
+
 	@ApiModelProperty(value="参考采集器表", position = 16)
 	private Integer collectorId;
 
+	@ApiModelProperty(value="参考采集器表", position = 16)
+	private String collectorName;
+
 	@ApiModelProperty(value="通道号id", position = 17)
 	private Integer channelNumberId;
 
+	@ApiModelProperty(value="通道号id", position = 17)
+	private String channelNumberName;
+
 	@ApiModelProperty(value="测量点号", position = 18)
 	private String port;
 
 	@ApiModelProperty(value="铅封号", position = 19)
 	private String sealNo;
+
+	@ApiModelProperty(value="水表类型", position = 19)
+	private Integer meterType;
 }

+ 0 - 1
smart-city-platform/src/main/java/com/bz/smart_city/entity/assistant/InstallList.java

@@ -100,7 +100,6 @@ public class InstallList {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime acceptTime;
 
-    @JsonIgnore
     @ApiModelProperty(value = "备注",hidden = true)
     private String remark;
 

+ 12 - 9
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/GdDeviceResolverExcelTemplate.java

@@ -67,21 +67,23 @@ public class GdDeviceResolverExcelTemplate extends AbstractResolverExcelTemplate
                 if (row != null) {
                     Cell electronicNoCell = row.getCell(0);
                     Cell fileNoCell = row.getCell(1);
-                    Cell deviceTypeNameCell = row.getCell(2);
-                    Cell customerNameCell = row.getCell(3);
-                    Cell buildingNameCell = row.getCell(4);
-                    Cell locDescCell = row.getCell(5);
-                    Cell concentratorNameCell = row.getCell(6);
-                    Cell collectorNameCell = row.getCell(7);
-                    Cell channelNumberNameCell = row.getCell(8);
-                    Cell portCell = row.getCell(9);
-                    Cell remarkCell = row.getCell(10);
+                    Cell sealNoCell = row.getCell(2);
+                    Cell deviceTypeNameCell = row.getCell(3);
+                    Cell customerNameCell = row.getCell(4);
+                    Cell buildingNameCell = row.getCell(5);
+                    Cell locDescCell = row.getCell(6);
+                    Cell concentratorNameCell = row.getCell(7);
+                    Cell collectorNameCell = row.getCell(8);
+                    Cell channelNumberNameCell = row.getCell(9);
+                    Cell portCell = row.getCell(10);
+                    Cell remarkCell = row.getCell(11);
 
                     electronicNoCell.setCellType(CellType.STRING);
                     fileNoCell.setCellType(CellType.STRING);
                     locDescCell.setCellType(CellType.STRING);
                     concentratorNameCell.setCellType(CellType.STRING);
                     portCell.setCellType(CellType.STRING);
+                    sealNoCell.setCellType(CellType.STRING);
 
 
                     if (StringUtils.equals("", electronicNoCell.getStringCellValue()) &&
@@ -190,6 +192,7 @@ public class GdDeviceResolverExcelTemplate extends AbstractResolverExcelTemplate
                     device.setWaterMeterNo(electronicNoCell.getStringCellValue().trim());
                     device.setWaterMeterFileNo(StringUtils.equals("", fileNoCell.getStringCellValue())?null:fileNoCell.getStringCellValue().trim());
                     device.setLocDesc(locDescCell.getStringCellValue().trim());
+                    device.setSealNo(sealNoCell.getStringCellValue().trim());
                     device.setDeviceStatus(5);//未启用
                     device.setStatus(1);
                     device.setIsTag(0);

+ 10 - 7
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/WaterDeviceResolverExcelTemplate.java

@@ -61,18 +61,20 @@ public class WaterDeviceResolverExcelTemplate extends AbstractResolverExcelTempl
                     Cell deviceNoCell = row.getCell(2);
                     Cell waterMeterNoCell = row.getCell(3);
                     Cell waterMeterFileNoCell = row.getCell(4);
-                    Cell deviceTypeNameCell = row.getCell(5);
-                    Cell deviceTypeIdCell = row.getCell(6);
-                    Cell customerNameCell = row.getCell(7);
-                    Cell customerIdCell = row.getCell(8);
-                    Cell locDescCell = row.getCell(9);
-                    Cell floorCell = row.getCell(10);
-                    Cell c_remark = row.getCell(11);
+                    Cell sealNoCell = row.getCell(5);
+                    Cell deviceTypeNameCell = row.getCell(6);
+                    Cell deviceTypeIdCell = row.getCell(7);
+                    Cell customerNameCell = row.getCell(8);
+                    Cell customerIdCell = row.getCell(9);
+                    Cell locDescCell = row.getCell(10);
+                    Cell floorCell = row.getCell(11);
+                    Cell c_remark = row.getCell(12);
 
                     buildingNameCell.setCellType(CellType.STRING);
                     deviceNoCell.setCellType(CellType.STRING);
                     deviceTypeNameCell.setCellType(CellType.STRING);
                     locDescCell.setCellType(CellType.STRING);
+                    sealNoCell.setCellType(CellType.STRING);
 
                     if (StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
                             StringUtils.equals("", deviceNoCell.getStringCellValue()) &&
@@ -209,6 +211,7 @@ public class WaterDeviceResolverExcelTemplate extends AbstractResolverExcelTempl
 
                     //DeviceType deviceType = deviceTypeMapper.findByid(device.getDeviceType());
                     device.setManufacturerId(deviceType.getManufacturerId());
+                    device.setSealNo(sealNoCell.getStringCellValue().trim());
                     device.setDeviceStatus(5);//未启用
                     device.setStatus(1);
                     device.setXCoordinates(device.getXCoordinates());

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/RabbitConfig.java

@@ -37,7 +37,7 @@ public class RabbitConfig {
     @Bean
     public ConnectionFactory routeConnectionFactory(){
         log.info("init routeConnectionFactory");
-        List<ScRabbitConfig> list = scRabbitConfigMapper.findByType(1);
+        List<ScRabbitConfig> list = scRabbitConfigMapper.findByType(null);
         if (list != null && list.size() > 0) {
             DynamicRoutingConnectionFactory dynamicRoutingConnectionFactory = DynamicRoutingConnectionFactory.getInstance();
             Map<Object, ConnectionFactory> map = new HashMap<>();

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/redis/RedisConfig.java

@@ -5,6 +5,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.GenericToStringSerializer;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 @Configuration
@@ -32,10 +33,14 @@ public class RedisConfig {
         //objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
 
         //jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
+        GenericToStringSerializer genericToStringSerializer = new GenericToStringSerializer(Object.class);
 
         // 设置value的序列化规则和 key的序列化规则
         //redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
+        //redisTemplate.setValueSerializer(genericToStringSerializer);
         redisTemplate.setKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashValueSerializer(genericToStringSerializer);
         redisTemplate.afterPropertiesSet();
         return redisTemplate;
     }

+ 10 - 0
smart-city-platform/src/main/java/com/bz/smart_city/repository/DeviceDataRepository.java

@@ -0,0 +1,10 @@
+package com.bz.smart_city.repository;
+
+import com.bz.smart_city.dto.DeviceData;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+import java.util.List;
+
+public interface DeviceDataRepository extends  MongoRepository<DeviceData, Long> {
+	List<DeviceData> findByDeviceId(Long deviceId) ;
+}

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceDataDimService.java

@@ -25,5 +25,7 @@ public interface DeviceDataDimService{
 
     List<DeviceMeasuringDataDTO> getData(Long deviceId, Integer startDate, Integer endDate);
 
+    List<DeviceMeasuringDataDTO> getDataV2(Long deviceId, Integer startDate, Integer endDate);
+
     void getDataExcel(Long deviceId, Integer startDate, Integer endDate, HttpServletResponse httpServletResponse);
 }

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

@@ -4,11 +4,15 @@ 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.AssistantUserUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.ConcentratorMapper;
+import com.bz.smart_city.dao.CustomerMapper;
 import com.bz.smart_city.dao.WaterRelatedDeviceMapper;
 import com.bz.smart_city.dto.*;
+import com.bz.smart_city.dto.assistant.LoginAssistantUser;
 import com.bz.smart_city.entity.Concentrator;
+import com.bz.smart_city.entity.Customer;
 import com.bz.smart_city.excel.download.template.CollectorDownloadExcelTemplate;
 import com.bz.smart_city.service.BuildingService;
 import com.github.pagehelper.PageHelper;
@@ -37,6 +41,8 @@ public class CollectorServiceImpl implements CollectorService{
     private CollectorDownloadExcelTemplate collectorDownloadExcelTemplate;
     @Resource
     private ConcentratorMapper concentratorMapper;
+    @Autowired
+    private CustomerMapper customerMapper;
 
     @Override
     public int insertSelective(Collector record) {
@@ -66,8 +72,19 @@ public class CollectorServiceImpl implements CollectorService{
 
     @Override
     public List<CollectorDto> getList(String collectorNo, String serialNumber) {
+        Integer siteId = null;
         LoginUser loginUser = UserUtil.getCurrentUser();
-        return collectorMapper.getList(loginUser.getSiteId(),collectorNo,serialNumber,null,null,null,null,null,null, UserUtil.getCustomerIds());
+        if (loginUser != null) {
+            siteId = loginUser.getSiteId();
+        }
+        LoginAssistantUser loginAssistantUser = AssistantUserUtil.getCurrentUser();
+        if (loginAssistantUser != null) {
+            Customer customer = customerMapper.findById(loginAssistantUser.getCustomerId());
+            if (customer != null) {
+                siteId = customer.getSiteId();
+            }
+        }
+        return collectorMapper.getList(siteId,collectorNo,serialNumber,null,null,null,null,null,null, UserUtil.getCustomerIds());
     }
 
     @Override

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

@@ -4,11 +4,11 @@ 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.AssistantUserUtil;
 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.dao.*;
 import com.bz.smart_city.dto.*;
+import com.bz.smart_city.dto.assistant.LoginAssistantUser;
 import com.bz.smart_city.entity.*;
 import com.bz.smart_city.excel.download.template.ConcentratorDownloadExcelTemplate;
 import com.bz.smart_city.service.BuildingService;
@@ -21,7 +21,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.time.LocalDateTime;
 import java.util.List;
-import com.bz.smart_city.dao.ConcentratorMapper;
+
 import com.bz.smart_city.service.ConcentratorService;
 
 @Slf4j
@@ -42,6 +42,8 @@ public class ConcentratorServiceImpl implements ConcentratorService{
     private GdAgentUtils gdAgentUtils;
     @Autowired
     private ConcentratorDownloadExcelTemplate concentratorDownloadTemplate;
+    @Autowired
+    private CustomerMapper customerMapper;
 
     @Override
     public int insertSelective(Concentrator record) {
@@ -60,7 +62,7 @@ public class ConcentratorServiceImpl implements ConcentratorService{
 
     @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();
+        LoginUser loginUser = UserUtil.getCurrentUser();
         PageHelper.startPage(pageNum,pageSize);
         List<ConcentratorDto> list = concentratorMapper.getList(
                 loginUser.getSiteId(),serialNumber,deviceStatus,customerId,address,
@@ -70,9 +72,20 @@ public class ConcentratorServiceImpl implements ConcentratorService{
 
     @Override
     public List<ConcentratorDto> getList(String serialNumber) {
-        LoginUser loginUser = new LoginUser();
+        Integer siteId = null;
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        if (loginUser != null) {
+            siteId = loginUser.getSiteId();
+        }
+        LoginAssistantUser loginAssistantUser = AssistantUserUtil.getCurrentUser();
+        if (loginAssistantUser != null) {
+            Customer customer = customerMapper.findById(loginAssistantUser.getCustomerId());
+            if (customer != null) {
+                siteId = customer.getSiteId();
+            }
+        }
         List<ConcentratorDto> list = concentratorMapper.findList(
-                loginUser.getSiteId(),serialNumber,UserUtil.getCustomerIds());
+                siteId,serialNumber,UserUtil.getCustomerIds());
         return list;
     }
 

+ 46 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceDataDimServiceImpl.java

@@ -10,14 +10,20 @@ import com.bz.smart_city.dto.*;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.entity.DeviceData;
 import com.bz.smart_city.entity.TplMeasuringDataDef;
+import com.bz.smart_city.repository.DeviceDataRepository;
 import com.bz.smart_city.service.DeviceMeasuringPointService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
@@ -42,6 +48,10 @@ public class DeviceDataDimServiceImpl implements DeviceDataDimService {
     private DeviceMeasuringPointService deviceMeasuringPointService;
     @Resource
     private DeviceMapper deviceMapper;
+    @Autowired
+    private DeviceDataRepository deviceDataRepository;
+    @Autowired
+    MongoTemplate mongoTemplate;
 
     @Override
     public int insert(DeviceDataDim deviceDataDim) {
@@ -106,7 +116,7 @@ public class DeviceDataDimServiceImpl implements DeviceDataDimService {
         for(String key:map.keySet()){
             List<MeasuringDataDTO> listTemp = map.get(key);
             DeviceMeasuringDataDTO deviceMeasuringDataDTO = new DeviceMeasuringDataDTO();
-            deviceMeasuringDataDTO.setDateTime(key);
+            //deviceMeasuringDataDTO.setDateTime(key);
             //list按测点code转map
             Map<String, String> mapTemp = listTemp.stream().collect(Collectors.toMap(MeasuringDataDTO::getMeasuringCode, MeasuringDataDTO::getMeasuringData, (key1, key2) -> key2));
             deviceMeasuringDataDTO.setMeasuringData(mapTemp);
@@ -115,15 +125,48 @@ public class DeviceDataDimServiceImpl implements DeviceDataDimService {
         return dateList;
     }
 
+    @Override
+    public List<DeviceMeasuringDataDTO> getDataV2(Long deviceId, Integer startDate, Integer endDate) {
+        List<DeviceMeasuringDataDTO> result = new ArrayList<>();
+        Query query = new Query();
+        query.addCriteria(Criteria.where("deviceId").is(deviceId));
+        if(startDate != null || endDate != null){
+            Criteria criteria = Criteria.where("receiveDate");
+            if(startDate != null){
+                criteria.gte(startDate);
+            }
+            if(endDate != null){
+                criteria.lte(endDate);
+            }
+            query.addCriteria(criteria);
+        }
+
+        query.with(Sort.by(Sort.Order.desc("receiveTime")));
+
+        List<com.bz.smart_city.dto.DeviceData> list = mongoTemplate.find(query,com.bz.smart_city.dto.DeviceData.class,"sc_device_data");
+        //System.out.println(JSON.toJSONString(list));
+        if (list != null && list.size() > 0) {
+            for (com.bz.smart_city.dto.DeviceData deviceData : list) {
+                DeviceMeasuringDataDTO dto = new DeviceMeasuringDataDTO();
+                dto.setMeasuringData(deviceData.getData());
+                dto.setDateTime(deviceData.getReceiveTime());
+                result.add(dto);
+
+            }
+        }
+        return result;
+    }
+
     @Override
     public void getDataExcel(Long deviceId, Integer startDate, Integer endDate, HttpServletResponse httpServletResponse) {
         String title = "历史数据";
-        List<DeviceMeasuringDataDTO> list =  getData(deviceId,startDate,endDate);
+        List<DeviceMeasuringDataDTO> list =  getDataV2(deviceId,startDate,endDate);
         Device device = deviceMapper.findByDeviceId(deviceId);
         List<DeviceMeasuringPointDto> measuringList = deviceMeasuringPointService.getDeviceMeasuringPoint(device.getDeviceType());
 
         List<String> rowsNameList = getRowsNameList(measuringList);
         List<String> rowCodeList = getRowsCodeList(measuringList);
+        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         //DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         //String[] rowsName = new String[]{"序号", "日期", "水表电子号", "设备型号", "建筑", "安装地址", "设备状态", "当前读数", "最后上报时间"};
         String[] rowsName = rowsNameList.toArray(new String[rowsNameList.size()]);
@@ -133,7 +176,7 @@ public class DeviceDataDimServiceImpl implements DeviceDataDimService {
             DeviceMeasuringDataDTO data = list.get(i);
             objs = new Object[rowsName.length];
             objs[0] = i;
-            objs[1] = data.getDateTime();
+            objs[1] = dateformat.format(data.getDateTime());
             for (int j = 2; j < rowsNameList.size(); j++) {
                 objs[j] = getRowsValue(data,rowCodeList.get(j),measuringList);
             }

+ 13 - 6
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -40,7 +40,6 @@ import java.io.File;
 import java.math.BigInteger;
 import java.net.URLEncoder;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -124,6 +123,8 @@ public  class DeviceServiceImpl implements DeviceService {
     private GeneralDownload generalDownload;
     @Autowired
     private MessageService messageService;
+    @Autowired
+    private ChannelDeviceTypeUseMapper channelDeviceTypeUseMapper;
 
     @Override
     public int insert(Device device) {
@@ -1113,8 +1114,9 @@ public  class DeviceServiceImpl implements DeviceService {
     @Override
     public Pagination<DeviceDto> getInstallPage(Integer channelId, String deviceNo, Integer status, String errorType, Integer customerId, Integer province, Integer city, Integer region, Integer community, Integer buildingId, String locDesc, Integer deviceTypeId, Integer registerStatus, Integer issueStatus, Integer concentratorId, Integer channelNumberId, String collectorNo, LocalDateTime startDate, LocalDateTime endDate, String sortColumn, String sortOrder, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
+        List<Integer> deviceTypeIdList = channelDeviceTypeUseMapper.findDeviceTypeByChannelId(channelId);
         PageHelper.startPage(pageNum, pageSize);
-        List<DeviceDto> list = deviceMapper.getInstallList(loginUser.getSiteId(), channelId, deviceNo, status, errorType, customerId, province, city, region, community, buildingId, locDesc, deviceTypeId, registerStatus,issueStatus,concentratorId,channelNumberId,collectorNo, startDate, endDate,UserUtil.getCurrentSiteProgramItems(loginUser),sortColumn,sortOrder);
+        List<DeviceDto> list = deviceMapper.getInstallList(loginUser.getSiteId(), channelId, deviceNo, status, errorType, customerId, province, city, region, community, buildingId, locDesc, deviceTypeId, registerStatus,issueStatus,concentratorId,channelNumberId,collectorNo, startDate, endDate,UserUtil.getCurrentSiteProgramItems(loginUser),deviceTypeIdList,sortColumn,sortOrder);
         return new Pagination<>(list);
     }
 
@@ -1122,11 +1124,16 @@ public  class DeviceServiceImpl implements DeviceService {
     public void exportInstallList(Integer channelId, String deviceNo, Integer status, String errorType, Integer customerId, Integer province, Integer city, Integer region, Integer community, Integer buildingId, String locDesc, Integer deviceTypeId, Integer registerStatus, Integer issueStatus, Integer concentratorId, Integer channelNumberId, String collectorNo, LocalDateTime startDate, LocalDateTime endDate, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
         String title = "已装水表列表";
         LoginUser loginUser = UserUtil.getCurrentUser();
-        List<DeviceDto> rtnList = deviceMapper.getInstallList(loginUser.getSiteId(), channelId, deviceNo, status, errorType, customerId, province, city, region, community, buildingId, locDesc, deviceTypeId, registerStatus, issueStatus, concentratorId, channelNumberId, collectorNo, startDate, endDate,UserUtil.getCurrentSiteProgramItems(loginUser),sortColumn,sortOrder);
-        if(channelId != null && channelId == 55){
+        List<Integer> deviceTypeIdList = channelDeviceTypeUseMapper.findDeviceTypeByChannelId(channelId);
+        List<DeviceDto> rtnList = deviceMapper.getInstallList(loginUser.getSiteId(), channelId, deviceNo, status, errorType, customerId, province, city, region, community, buildingId, locDesc, deviceTypeId, registerStatus, issueStatus, concentratorId, channelNumberId, collectorNo, startDate, endDate,UserUtil.getCurrentSiteProgramItems(loginUser), deviceTypeIdList, sortColumn,sortOrder);
+        if(55 == channelId){
             generalDownload.export(title,"installRemoteMeter",rtnList,httpServletResponse);
-        }else {
-            generalDownload.export(title,"installMeter",rtnList,httpServletResponse);
+        }
+        if(40 == channelId){
+            generalDownload.export(title,"installLoraMeter",rtnList,httpServletResponse);
+        }
+        if(58 == channelId){
+            generalDownload.export(title,"installNbiotMeter",rtnList,httpServletResponse);
         }
 
     }

+ 101 - 13
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/GdServiceImpl.java

@@ -3,18 +3,26 @@ package com.bz.smart_city.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.bz.smart_city.commom.model.CommonQueryCondition;
+import com.bz.smart_city.commom.util.JacksonUtil;
+import com.bz.smart_city.commom.util.SnowflakeIdWorker;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.MessageMapper;
 import com.bz.smart_city.dao.MeterReadRecordMapper;
+import com.bz.smart_city.dao.ScRabbitConfigMapper;
+import com.bz.smart_city.dto.AcceptData;
+import com.bz.smart_city.dto.AcceptListData;
 import com.bz.smart_city.dto.InputDeviceDto;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.entity.Message;
 import com.bz.smart_city.entity.MeterReadRecord;
+import com.bz.smart_city.entity.ScRabbitConfig;
 import com.bz.smart_city.service.GdService;
 import com.bz.smart_city.service.udip.GdAgentUtils;
 import com.bz.smart_city.service.udip.model.GdInputDto;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.connection.SimpleResourceHolder;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -22,10 +30,12 @@ import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.nio.charset.Charset;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -42,6 +52,12 @@ public class GdServiceImpl implements GdService {
     private GdAgentUtils gdAgentUtils;
     @Resource
     private MessageMapper messageMapper;
+    @Autowired
+    private SnowflakeIdWorker idWorker;
+    @Autowired
+    RabbitTemplate rabbitTemplate;
+    @Resource
+    private ScRabbitConfigMapper scRabbitConfigMapper;
 
     @Override
     public String batchReadReal(InputDeviceDto inputDeviceDto) {
@@ -71,13 +87,14 @@ public class GdServiceImpl implements GdService {
                 }
             }
             if(success.get() > 0){
-                GdInputDto gdInputDto= new GdInputDto();
+                /*GdInputDto gdInputDto= new GdInputDto();
                 gdInputDto.setSiteId(loginUser.getSiteId());
                 gdInputDto.setUserId(loginUser.getId());
                 gdInputDto.setType(2);
                 gdInputDto.setMap(map);
                 System.out.println(JSON.toJSONString(gdInputDto));
-                gdAgentUtils.batchReadReal(gdInputDto);
+                gdAgentUtils.batchReadReal(gdInputDto);*/
+                sendMsg(loginUser.getSiteId(),loginUser.getId(),2, map);
             }else {
                 Message message = new Message();
                 message.setSiteId(loginUser.getSiteId());
@@ -93,7 +110,7 @@ public class GdServiceImpl implements GdService {
                 message.setUpdateBy("system");
                 messageMapper.insertSelective(message);
             }
-            log.info("end allReadFreeze success={},fail={}",success.get(),fail.get());
+            log.info("end batchReadReal success={},fail={}",success.get(),fail.get());
             if(fail.get() > 0){
                 return "您选择表有"+fail.get()+"只正在执行操作,仅对剩下的"+success.get()+"只进行点抄。请稍后在消息查看结果,通过刷新页面查看设备最新抄表数。";
             }else {
@@ -146,12 +163,13 @@ public class GdServiceImpl implements GdService {
             }
             if(success.get() > 0){
                 GdInputDto gdInputDto= new GdInputDto();
-                gdInputDto.setSiteId(loginUser.getSiteId());
+                /*gdInputDto.setSiteId(loginUser.getSiteId());
                 gdInputDto.setUserId(loginUser.getId());
-                gdInputDto.setType(1);
-                gdInputDto.setMap(map);
+                gdInputDto.setType(1);*/
+                /*gdInputDto.setMap(map);
                 System.out.println(JSON.toJSONString(gdInputDto));
-                gdAgentUtils.batchReadFreeze(gdInputDto);
+                gdAgentUtils.batchReadFreeze(gdInputDto);*/
+                sendMsg(loginUser.getSiteId(),loginUser.getId(),1, map);
             }else {
                 Message message = new Message();
                 message.setSiteId(loginUser.getSiteId());
@@ -167,7 +185,7 @@ public class GdServiceImpl implements GdService {
                 message.setUpdateBy("system");
                 messageMapper.insertSelective(message);
             }
-            log.info("end allReadFreeze success={},fail={},complete={}",success.get(),fail.get(),complete.get());
+            log.info("end batchReadFreeze success={},fail={},complete={}",success.get(),fail.get(),complete.get());
             if(fail.get() > 0){
                 return "您选择表有"+fail.get()+"只正在执行操作,仅对剩下的"+success.get()+"只进行补抄。请稍后在消息查看结果,通过刷新页面查看设备最新抄表数。";
             }else {
@@ -214,13 +232,14 @@ public class GdServiceImpl implements GdService {
             }
         }
         if(success.get() > 0){
-            GdInputDto gdInputDto= new GdInputDto();
+            /*GdInputDto gdInputDto= new GdInputDto();
             gdInputDto.setSiteId(condition.getSiteId());
             gdInputDto.setUserId(condition.getUserId());
             gdInputDto.setType(4);
             gdInputDto.setMap(map);
             System.out.println(JSON.toJSONString(gdInputDto));
-            gdAgentUtils.batchReadReal(gdInputDto);
+            gdAgentUtils.batchReadReal(gdInputDto);*/
+            sendMsg(condition.getSiteId(),condition.getUserId(),4, map);
         }else {
             Message message = new Message();
             message.setSiteId(condition.getSiteId());
@@ -236,7 +255,7 @@ public class GdServiceImpl implements GdService {
             message.setUpdateBy("system");
             messageMapper.insertSelective(message);
         }
-        log.info("end allReadFreeze success={},fail={}",success.get(),fail.get());
+        log.info("end allReadReal success={},fail={}",success.get(),fail.get());
         if(fail.get() > 0){
             return "您选择表有"+fail.get()+"只正在执行操作,仅对剩下的"+success.get()+"只进行点抄。请稍后在消息查看结果,通过刷新页面查看设备最新抄表数。";
         }else {
@@ -275,13 +294,14 @@ public class GdServiceImpl implements GdService {
             }
         }
         if(success.get() > 0){
-            GdInputDto gdInputDto= new GdInputDto();
+            /*GdInputDto gdInputDto= new GdInputDto();
             gdInputDto.setSiteId(condition.getSiteId());
             gdInputDto.setUserId(condition.getUserId());
             gdInputDto.setType(3);
             gdInputDto.setMap(map);
             System.out.println(JSON.toJSONString(gdInputDto));
-            gdAgentUtils.batchReadFreeze(gdInputDto);
+            gdAgentUtils.batchReadFreeze(gdInputDto);*/
+            sendMsg(condition.getSiteId(),condition.getUserId(),3, map);
         }else {
             Message message = new Message();
             message.setSiteId(condition.getSiteId());
@@ -317,4 +337,72 @@ public class GdServiceImpl implements GdService {
         if(type == 4) return "全部补抄";
         return "";
     }
+
+    private void sendMsg(Integer siteId,Integer userId,Integer type,Map<String,List<String>> map){
+        List<Map<String,List<String>>> list = newArrayList();
+        if (map != null) {
+            for (String key : map.keySet()) {
+                List<String> deviceIdStrList = map.get(key);
+                // 分批
+                if (deviceIdStrList != null && deviceIdStrList.size() > 0) {
+                    int total = deviceIdStrList.size();
+                    int pageSize = 5;
+                    int totalPage = total / pageSize;
+                    if (total % pageSize != 0) {
+                        totalPage++;
+                    }
+                    for (int i = 1; i <= totalPage; i++)
+                    {
+                        log.info("current page = " + i);
+                        List<String> records = newArrayList();
+                        int start = (i - 1) * pageSize;
+                        int j = 0;
+
+                        for (int index = 0; (j < pageSize) && (index < total); j++)
+                        {
+                            index = start + j;
+                            records.add(deviceIdStrList.get(index));
+                            index++;
+                        }
+
+                        Map<String,List<String>> tempMap = new HashMap<>();
+                        tempMap.put(key,records);
+                        list.add(tempMap);
+                    }
+                }
+            }
+        }
+        log.info("current list size = " + list.size());
+        //保存redis
+        Long id = idWorker.nextId();
+        Map<String,Object> redisMap = new HashMap<>();
+        redisMap.put("siteId",siteId);
+        redisMap.put("userId",userId);
+        redisMap.put("type",type);
+        redisMap.put("size",list.size());
+        redisMap.put("complete",0);
+        redisMap.put("success",0);
+        redisMap.put("fail",0);
+        redisTemplate.opsForHash().putAll("GdReadingTask:"+id,redisMap);
+        redisTemplate.expire("GdReadingTask:"+id,86400, TimeUnit.SECONDS);
+
+        ScRabbitConfig config = scRabbitConfigMapper.findByCode("gd-read-meter");
+
+        for (Map<String, List<String>> stringListMap : list) {
+
+            GdInputDto gdInputDto= new GdInputDto();
+            gdInputDto.setTaskId(id.toString());
+            gdInputDto.setMap(stringListMap);
+            //发送消息
+            //设置当前线程lookupKey,内部由ThreadLocal实现
+            SimpleResourceHolder.bind(rabbitTemplate.getConnectionFactory(), config.getCode());
+            //业务操作会根据线程中的lookupKey从routeConnectionFactory的targetConnectionFactories中选择对应的connectionFactory
+            String msg = JSON.toJSONString(gdInputDto);
+            System.out.println(msg);
+            rabbitTemplate.convertAndSend(config.getExchange(),config.getRoutingKey(), msg.getBytes(Charset.forName("UTF-8")));
+            //操作完以后记得解绑。不影响线程的后序其他工厂操作
+            SimpleResourceHolder.unbind(rabbitTemplate.getConnectionFactory());
+        }
+    }
+
 }

+ 9 - 11
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java

@@ -237,19 +237,16 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
             newDevice.setWaterMeterNo(waterMeterReplaceInputDto.getNewElectronicNo());
         }
         if (waterMeterReplaceInputDto.getNewDeviceTypeId() != null && waterMeterReplaceInputDto.getNewDeviceTypeId()!=0) {
-            Integer channelId = null;
-            if(device.getSysId()!=-99){
-                ChannelDeviceTypeUse use = channelDeviceTypeUseMapper.findByDeviceId(waterMeterReplaceInputDto.getNewDeviceTypeId());
-                if (use != null) {
-                    channelId = use.getChannelId();
+            ChannelDeviceTypeUse use = channelDeviceTypeUseMapper.findByDeviceId(waterMeterReplaceInputDto.getNewDeviceTypeId());
+            if (use != null) {
+                if( use.getChannelId() == 55){
+                    remoteMeterFlag = true;
+                }
+                if(device.getSysId()!=-99){
                     newDevice.setSysId(use.getChannelId());
                 }
-            }else {
-                channelId = device.getSysId();
-            }
-            if(channelId!=null && channelId == 55){
-                remoteMeterFlag = true;
             }
+
             newDevice.setDeviceType(waterMeterReplaceInputDto.getNewDeviceTypeId());
 
         }
@@ -262,6 +259,7 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
             }
 
         }
+        newDevice.setSealNo(waterMeterReplaceInputDto.getSealNo());
         newDevice.setDateUpdate(LocalDateTime.now());
         deviceMapper.updateByPrimaryKeySelective(newDevice);
 
@@ -309,6 +307,6 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
         log.info("waterMeterReplaceData:" + json);
         kafkaTemplate.send(acceptMeterReplaceTopic,json);
 
-        log.info("end submitWaterMeterReplace");
+        log.info("end submitWaterMeterReplace remoteMeterFlag={}",remoteMeterFlag);
     }
 }

+ 4 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallManagerServiceImpl.java

@@ -463,7 +463,10 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 		param.setDeviceNo(deviceNo);
 		
 		List<InstallListDTO> dtoList = installListMapper.queryInstallList(param);
-		InstallListDTO response = dtoList.get(0);
+		InstallListDTO response = null;
+		if (dtoList != null && dtoList.size()>0) {
+			response = dtoList.get(0);
+		}
 		log.info("end InstallManagerService queryInstallListByDevice ,request = {},{}",deviceId,deviceNo);
 		return response;
 	}

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

@@ -7,6 +7,7 @@ import java.util.Map;
 
 @Data
 public class GdInputDto {
+    String taskId;
     Integer siteId;
     Integer userId;
     //1、批量补抄 2、批量点抄 3、全部补抄 4、全部点抄

+ 6 - 2
smart-city-platform/src/main/resources/application-dev.properties

@@ -42,7 +42,7 @@ spring.redis.port=26379
 spring.redis.password=zoniot
 #spring.redis.port=6379
 #spring.redis.password=100Zone@123
-spring.redis.database=1
+spring.redis.database=7
 init.data.cache = 0
 spring.redis.timeout=10000ms
 spring.redis.jedis.pool.max-active=8
@@ -171,4 +171,8 @@ sync.customer.linhe.id=126
 sync.data.limit=50
 
 #银行代收客户id
-payfee.bank.customerId=47
+payfee.bank.customerId=47
+
+#mongodb url
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

+ 5 - 1
smart-city-platform/src/main/resources/application-prd.properties

@@ -175,4 +175,8 @@ sync.customer.linhe.id=68
 sync.data.limit=100
 
 #银行代收客户id
-payfee.bank.customerId=47
+payfee.bank.customerId=47
+
+#mongodb url
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

+ 5 - 1
smart-city-platform/src/main/resources/application-sit.properties

@@ -174,4 +174,8 @@ sync.customer.linhe.id=126
 sync.data.limit=100
 
 #银行代收客户id
-payfee.bank.customerId=47
+payfee.bank.customerId=47
+
+#mongodb url
+spring.data.mongodb.uri=mongodb://114.135.61.188:17017/meter-reading-database
+logging.level.org.springframework.data.mongodb.core=DEBUG

BIN
smart-city-platform/src/main/resources/excel/installWaterMeterTemplate20210114-yc.xlsx


+ 6 - 5
smart-city-platform/src/main/resources/json/deviceCustomColumn.json

@@ -1,12 +1,13 @@
 {
   "general": ["deviceNo", "deviceModel", "customerName", "deviceStatus", "buildingName", "locDesc", "dateCreate", "lastReceiveTime"],
-  "loraMeter": ["deviceNo", "waterMeterFileNo", "waterMeterNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "buildingName", "locDesc", "syncStatus", "valveStatus"],
-  "photoelectricMeter": ["waterMeterNo","waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "concentratorName", "channelNumberName","collectorName", "issueStatus", "meterReading", "buildingName", "installTime"],
-  "nbiotMeter": ["deviceNo", "waterMeterNo","waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "buildingName", "locDesc", "registerStatus", "valveStatus"],
+  "loraMeter": ["deviceNo", "waterMeterFileNo", "waterMeterNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading","communityName", "buildingName", "locDesc", "syncStatus", "valveStatus","lastReceiveTime","userName"],
+  "photoelectricMeter": ["waterMeterNo","waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "concentratorName", "channelNumberName","collectorName", "issueStatus", "meterReading","communityName", "buildingName", "installTime","locDesc","valveStatus","lastReceiveTime","userName"],
+  "nbiotMeter": ["deviceNo", "waterMeterNo","waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading","communityName", "buildingName", "locDesc", "registerStatus", "valveStatus","lastReceiveTime","userName"],
   "waterQualityMeter": ["deviceNo", "deviceModel", "customerName", "deviceStatus", "buildingName", "locDesc", "lastReceiveTime"],
   "flowmeter": ["deviceNo", "deviceModel", "customerName", "deviceStatus", "buildingName", "locDesc", "lastReceiveTime"],
-  "installMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "oldMeterEnd", "registerStatus", "communityName", "buildingName", "locDesc", "installTime", "lastReceiveTime", "userName"],
-  "installRemoteMeter": ["waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus","concentratorName","channelNumberName","collectorName","issueStatus", "meterReading", "oldMeterEnd", "communityName", "buildingName", "locDesc", "installTime"],
+  "installLoraMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "oldMeterEnd", "communityName", "buildingName", "installTime", "lastReceiveTime", "userName"],
+  "installNbiotMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus", "lastErrorType", "meterReading", "oldMeterEnd", "registerStatus", "communityName", "buildingName", "installTime", "lastReceiveTime", "userName"],
+  "installRemoteMeter": ["waterMeterNo", "waterMeterFileNo", "deviceModel", "customerName", "deviceStatus","concentratorName","channelNumberName","collectorName","issueStatus", "meterReading", "oldMeterEnd", "communityName", "buildingName", "installTime","lastReceiveTime", "userName"],
   "rmcp_loraMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "buildingName", "locDesc", "deviceStatus", "meterReading", "lastReceiveTime", "valveStatus"],
   "rmcp_photoelectricMeter": ["waterMeterNo", "waterMeterFileNo", "deviceModel", "buildingName", "locDesc", "deviceStatus", "meterReading", "lastReceiveTime", "valveStatus"],
   "rmcp_nbiotMeter": ["deviceNo", "waterMeterNo", "waterMeterFileNo", "deviceModel", "buildingName", "locDesc", "deviceStatus", "meterReading", "lastReceiveTime", "valveStatus"]

+ 1 - 1
smart-city-platform/src/main/resources/mapper/BuildingMapper.xml

@@ -1228,7 +1228,7 @@
         <if test="errorType != null and errorType != ''">left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)</if>
         <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
         <if test="registerStatus != null"> left join sc_device_type sdt on (sdt.id = sd.device_type)</if>
-        <if test="concentratorId != null or channelNumberId != null or (collectorNo != null and collectorNo != '')"> left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
+        <if test="concentratorId != null or channelNumberId != null or (collectorNo != null and collectorNo != '') or issueStatus != null"> left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
         left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)
         left join sc_collector scol on ( scol.id = swrd.collector_id)</if>
         left join sc_install_list sil on (sil.device_id = sd.id)

+ 30 - 4
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -366,7 +366,7 @@
         <if test="sysId==55">swrd.concentrator_id,swrd.collector_id,swrd.channel_number_id,swrd.port,swrd.issue_status,
         scon.serial_number as concentrator_name,scol.collector_no as collector_name,scn.channel_name as channel_number_name,</if>
         scus.customer_name,
-        sil.plan_time,sil.install_time,sil.accept_time,
+        sil.plan_time,sil.install_time,sil.accept_time,sil.user_name,
         swmed.days,swmed.last_error_type,
         swmed.meter_reading,swmed.valve_status,
         swmed.valve_button_status,
@@ -783,7 +783,13 @@
         sd.sync_status,
         sil.user_name,
         sil.user_phone,
-        sil.id_card
+        sil.id_card,
+        swrd.issue_status,
+        swrd.channel_number_id,
+        swrd.concentrator_id,
+        swrd.collector_id,
+        swrd.port,
+        scn.channel_name as channel_number_name
         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)
@@ -792,13 +798,19 @@
         left join sc_community scom on ( scom.id = sb.community and scom.status = 1)
         left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
         left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)
+        left join sc_channel_number scn on ( scn.id = swrd.channel_number_id and scn.status = 1)
         left join sc_collector scol on ( scol.id = swrd.collector_id)
         left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)
         left join sc_customer scus on ( scus.id = sd.customer_id)
         left join sc_install_list sil on (sil.device_id = sd.id)
         <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
         where sd.status = 1 and sil.status = 1 AND sd.sys_id = -99
-        <if test="sysId != null">  and sd.device_type in(select scdtu.device_type_id from sc_channel_device_type_use scdtu where scdtu.status = 1 and scdtu.channel_id = #{sysId})</if>
+        <if test="deviceTypeIdList != null and deviceTypeIdList.size() != 0">
+            and sd.device_type in
+            <foreach collection="deviceTypeIdList" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="siteId != null"> AND sd.site_id = #{siteId}</if>
         <if test="deviceNo != null and deviceNo != ''"> AND (sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_file_no LIKE concat('%',#{deviceNo},'%'))</if>
         <if test="status != null"> AND sd.device_status = #{status}</if>
@@ -1101,10 +1113,24 @@
             sc.id as device_id ,
             sc.device_no as device_no,
             sc.water_meter_no as  electronic_no ,
+            sc.seal_no,
             sc.loc_desc as location,
-            sc.device_status as device_status
+            sc.device_status as device_status,
+            w.parent_id as meter_type,
+            swrd.concentrator_id,
+            swrd.collector_id,
+            swrd.channel_number_id,
+            swrd.port,
+            scon.serial_number as concentrator_name,
+            scol.collector_no as collector_name,
+            scn.channel_name as channel_number_name
         from
         sc_device sc
+        left join sc_w_meter_type w on (w.device_type_id = sc.device_type and w.`status` = 1)
+        left join sc_water_related_device swrd on (swrd.device_id = sc.id and swrd.`status` = 1)
+        left join sc_concentrator scon on(scon.id = swrd.concentrator_id)
+        left join sc_collector scol on(scol.id = swrd.collector_id)
+        left join sc_channel_number scn on(scn.id = swrd.channel_number_id)
         where sc.`status` = 1
         and sc.customer_id = #{customerId}
         and sc.device_status in (2,5)

+ 17 - 14
smart-city-platform/src/main/resources/mapper/DeviceTypeMapper.xml

@@ -234,22 +234,18 @@
 			dt.equipment_type as equipment_type,
 			dt.device_type as device_type,
 			dt.manufacturer_id,
-			dm.`name` as manufacturer_name
+			dm.`name` as manufacturer_name,
+            w.parent_id as meter_type
 		FROM
 			sc_device_type dt 
 			left join sc_device_manufacturer dm on (dt.manufacturer_id = dm.id and dm.`status` = 1)
-		WHERE
-			dt.`status` = 1 
-		and dt.id in (
-			select  
-				device_type_id 
-			from sc_w_meter_type
-			where status = 1
-			<if test = "parentId != null and parentId != 0" >
-				and parent_id = #{parentId}
-			</if> 
-		)
-	</select>
+        inner join sc_w_meter_type w on (w.device_type_id = dt.id and w.`status` = 1)
+        WHERE
+			dt.`status` = 1
+            <if test = "parentId != null and parentId != 0" >
+                and w.parent_id = #{parentId}
+            </if>
+    </select>
 	<select id="getConditionWithDeviceType" resultType="com.bz.smart_city.dto.DeviceTypeDto">
 		SELECT
 			dt.id as id,
@@ -300,9 +296,16 @@
 	</select>
 
     <select id="findByIds" resultType="com.bz.smart_city.dto.DeviceTypeDto">
-        select sdt.id,sdt.equipment_type,sdt.model,sdt.manufacturer_id,sdt.device_type,sdm.name as manufacturer_name
+        select
+        sdt.id,
+        sdt.equipment_type,
+        sdt.model,
+        sdt.manufacturer_id,
+        sdt.device_type,sdm.name as manufacturer_name,
+        w.parent_id as meter_type
         from sc_device_type sdt
         left join sc_device_manufacturer sdm on (sdm.id = sdt.manufacturer_id and sdm.status = 1)
+        left join sc_w_meter_type w on (w.device_type_id = sdt.id and w.status = 1)
         where sdt.status = 1
         <if test="deviceTypeIds != null and deviceTypeIds.size() != 0">
             and sdt.id in

+ 13 - 1
smart-city-platform/src/main/resources/mapper/InstallListMapper.xml

@@ -436,6 +436,7 @@
             sd.device_no as device_no,
             sd.water_meter_no as electronic_no,
 			sd.water_meter_file_no as file_no,
+			sd.seal_no,
 			n.new_meter_start as new_meter_start,
 			n.old_meter_end as old_meter_end,
 			n.image_url as new_image_url,
@@ -456,7 +457,14 @@
             swmed.meter_reading,
             n.metercode as metercode,
             n.account_id as account_id,
-            n.account_id as accountId
+            n.account_id as accountId,
+            swrd.concentrator_id,
+            swrd.collector_id,
+            swrd.channel_number_id,
+            swrd.port,
+            scon.serial_number as concentrator_name,
+            scol.collector_no as collector_name,
+            scn.channel_name as channel_number_name
 		FROM
 			sc_install_list n 
 			left join sc_device sd on (sd.id = n.device_id)
@@ -466,6 +474,10 @@
 			left join sc_device_manufacturer dm on (dm.id = dt.manufacturer_id)
             left join sc_community com on (com.id = b.community)
             left join sc_water_meter_error_days swmed on ( swmed.device_id = n.device_id)
+            left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
+            left join sc_concentrator scon on(scon.id = swrd.concentrator_id)
+            left join sc_collector scol on(scol.id = swrd.collector_id)
+            left join sc_channel_number scn on(scn.id = swrd.channel_number_id)
 		WHERE
 			n.STATUS = 1
 		<if test="siteId != null">

+ 0 - 1
smart-city-platform/src/main/resources/mapper/MeterReadRecordMapper.xml

@@ -886,7 +886,6 @@
         <if test = "param.channelId != null and param.channelId != 0"> and m.sys_id = #{param.channelId}</if>
         <if test = "param.startDate != null and param.startDate != 0"> and  read_date >= #{param.startDate}</if>
         <if test = "param.endDate != null and param.endDate != 0"> and  read_date <![CDATA[ <= ]]>  #{param.endDate}</if>
-        order by read_time desc
     </select>