Prechádzať zdrojové kódy

计费和临河水司同步接口

lin 4 rokov pred
rodič
commit
c5443246fe
51 zmenil súbory, kde vykonal 723 pridanie a 45 odobranie
  1. 48 0
      smart-city-platform/src/main/java/com/bz/smart_city/async/SyncLinHeTask.java
  2. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java
  3. 12 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  4. 51 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/SyncDataApi.java
  5. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallController.java
  6. 12 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/ConcentratorController.java
  7. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ChannelNumberMapper.java
  8. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/CustomerMapper.java
  9. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java
  10. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/WaterMeterReplaceLogMapper.java
  11. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/WaterRelatedDeviceMapper.java
  12. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/assistant/InstallListMapper.java
  13. 9 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/assistant/InstallPlanDataDTO.java
  14. 15 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/MeterAcceptDto.java
  15. 45 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/MeterSyncDto.java
  16. 19 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/MeterSyncInputDto.java
  17. 37 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/ReplaceMeteDto.java
  18. 14 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/ReplaceMeteInputDto.java
  19. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Device.java
  20. 21 0
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/WaterDeviceResolverExcelTemplate.java
  21. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/ChannelNumberService.java
  22. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/ConcentratorService.java
  23. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  24. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/WaterRelatedDeviceService.java
  25. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  26. 23 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ChannelNumberServiceImpl.java
  27. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/CollectorServiceImpl.java
  28. 5 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/ConcentratorServiceImpl.java
  29. 48 4
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  30. 10 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterMaintenanceLogServiceImpl.java
  31. 11 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java
  32. 1 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterRelatedDeviceServiceImpl.java
  33. 13 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/AcceptManagerServiceImpl.java
  34. 12 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallManagerServiceImpl.java
  35. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallPlanServiceImpl.java
  36. 46 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/SyncServiceImpl.java
  37. 13 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/SyncService.java
  38. 13 6
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/GdAgentUtils.java
  39. 111 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/HlhtService.java
  40. 2 0
      smart-city-platform/src/main/resources/application-dev.properties
  41. 3 1
      smart-city-platform/src/main/resources/application-prd.properties
  42. 3 1
      smart-city-platform/src/main/resources/application-sit.properties
  43. BIN
      smart-city-platform/src/main/resources/excel/installPlanTemplate20200731.xlsx
  44. 7 3
      smart-city-platform/src/main/resources/mapper/ChannelNumberMapper.xml
  45. 1 0
      smart-city-platform/src/main/resources/mapper/ConcentratorCheckMapper.xml
  46. 4 0
      smart-city-platform/src/main/resources/mapper/CustomerMapper.xml
  47. 34 6
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  48. 16 2
      smart-city-platform/src/main/resources/mapper/InstallListMapper.xml
  49. 16 0
      smart-city-platform/src/main/resources/mapper/WaterMeterReplaceLogMapper.xml
  50. 4 0
      smart-city-platform/src/main/resources/mapper/WaterRelatedDeviceMapper.xml
  51. 8 0
      smart-city-platform/src/test/java/com/bz/smart_city/ScTest.java

+ 48 - 0
smart-city-platform/src/main/java/com/bz/smart_city/async/SyncLinHeTask.java

@@ -0,0 +1,48 @@
+package com.bz.smart_city.async;
+
+import com.bz.smart_city.dao.DeviceMapper;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.dto.assistant.InstallListDTO;
+import com.bz.smart_city.dto.assistant.InstallPlanDTO;
+import com.bz.smart_city.entity.Device;
+import com.bz.smart_city.service.udip.HlhtService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 异步同步临河水司电子号任务
+ */
+@Slf4j
+@Service
+public class SyncLinHeTask {
+    @Autowired
+    private HlhtService hlhtService;
+    @Resource
+    private DeviceMapper deviceMapper;
+
+    @Async
+    public void sync(List<InstallListDTO> list) {
+        log.info("begin  SyncLinHeTask sync");
+        if (list != null && list.size() > 0) {
+            for (InstallListDTO installList : list) {
+                Device device = new Device();
+                device.setId(installList.getDeviceId());
+                Boolean syncStatus = hlhtService.updatePayMeterEleno(installList.getElectronicNo(),installList.getFileNo());
+                if (syncStatus) {
+                    device.setSyncStatus(1);
+                }else {
+                    device.setSyncStatus(0);
+                }
+                device.setDateUpdate(LocalDateTime.now());
+                deviceMapper.updateByPrimaryKeySelective(device);
+            }
+        }
+        log.info("end  SyncLinHeTask sync");
+    }
+}

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

@@ -38,7 +38,7 @@ public enum ResultStatus {
     DEVICE_TYPE_NOT_EXISTED(-312,"设备类型不存在,请先录入设备类型"),
     DEVICE_NO_NOT_EXISTED(-313,"设备编号已经存在"),
     DEVICE_ELECTRONIC_NO_NOT_EXISTED(-314,"您输入的水表电子号已存在,请重新输入"),
-    CONCENTRATOR_RELATED_NOT_EXISTED(-315,"该集中器已存在关联设备,无法删除。"),
+    CONCENTRATOR_RELATED_NOT_EXISTED(-315,"该集中器已存在关联设备或采集器,无法删除。"),
     COLLECTOR_RELATED_NOT_EXISTED(-316,"该采集器已存在关联设备,无法删除。"),
     CONCENTRATOR_NOT_EXISTED(-317,"您输入的集中器编码已存在,请重新输入"),
     COLLECTOR_NOT_EXISTED(-318,"您输入的采集器编号该集中器下已存在,请重新输入"),

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

@@ -339,7 +339,8 @@ public class DeviceController {
     public AjaxMessage fileReset(
             @ApiParam(value = "设备", required = true) @RequestBody(required = true) InputDeviceDto inputDeviceDto
     ) {
-        waterRelatedDeviceService.fileReset(inputDeviceDto);
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        waterRelatedDeviceService.fileReset(loginUser,inputDeviceDto);
         return new AjaxMessage(ResultStatus.OK);
     }
 
@@ -354,4 +355,14 @@ public class DeviceController {
         return new AjaxMessage(ResultStatus.OK);
     }
 
+    @ResponseBody
+    @PostMapping("syncDevice")
+    @ApiOperation(value = "同步设备电子号")
+    public AjaxMessage syncDevice(
+            @ApiParam(value = "设备id", required = true) @RequestParam(required = true) Long deviceId
+    ){
+        Integer msg = deviceService.syncDevice(deviceId);
+        return new AjaxMessage<>(ResultStatus.OK,msg);
+    }
+
 }

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

@@ -4,11 +4,15 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ListObjectWrapper;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.dto.ClearingDataDTO;
+import com.bz.smart_city.dto.assistant.InstallPlanInputDTO;
+import com.bz.smart_city.dto.sync.*;
 import com.bz.smart_city.dto.CommunityDto;
 import com.bz.smart_city.dto.syncdata.*;
 import com.bz.smart_city.entity.Community;
 import com.bz.smart_city.service.CommunityService;
 import com.bz.smart_city.service.SyncDataService;
+import com.bz.smart_city.service.assistant.InstallPlanService;
+import com.bz.smart_city.service.pay.SyncService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -21,12 +25,18 @@ import java.util.List;
 @Controller
 @ResponseBody
 @RequestMapping("/syncData")
-@Api(tags = "数据同步接口类")
+@Api(tags = "计费数据同步接口类")
 public class SyncDataApi {
     @Autowired
     private SyncDataService syncDataService;
     @Autowired
+    private SyncService syncService;
+    @Autowired
     CommunityService communityService;
+    @Autowired
+    private InstallPlanService installPlanService;
+
+
     @ResponseBody
     @PostMapping ("/clearingData")
     @ApiOperation(value = "结算水量同步接口")
@@ -75,4 +85,44 @@ public class SyncDataApi {
         }
 
     }
+
+    @ResponseBody
+    @PostMapping("/meterSync")
+    @ApiOperation(value = "水表同步接口")
+    public AjaxMessage<List<MeterSyncDto>> meterSync(
+            @ApiParam(value = "参数", required = true) @RequestBody(required = true) MeterSyncInputDto meterSync
+    ){
+        List<MeterSyncDto> list = syncService.meterSync(meterSync);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @ResponseBody
+    @PostMapping("/meterAccept")
+    @ApiOperation(value = "水表验收接口")
+    public AjaxMessage<List<MeterAcceptDto>> meterAccept(
+            @ApiParam(value = "参数", required = true) @RequestBody(required = true) MeterSyncInputDto meterSync
+    ){
+        List<MeterAcceptDto> list = syncService.meterAccept(meterSync);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @ResponseBody
+    @PostMapping("/replaceMete")
+    @ApiOperation(value = "换表同步接口")
+    public AjaxMessage<List<ReplaceMeteDto>> replaceMete(
+            @ApiParam(value = "参数", required = true) @RequestBody(required = true) ReplaceMeteInputDto replaceMete
+    ){
+        List<ReplaceMeteDto> list = syncService.replaceMete(replaceMete);
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @ResponseBody
+    @PostMapping("syncPlan")
+    @ApiOperation(value = "同步计划")
+    public AjaxMessage syncPlan(
+            @ApiParam(value = "安装计划", required = true) @RequestBody(required = true) InstallPlanInputDTO installPlanInput
+    ) {
+        installPlanService.syncPlan(installPlanInput);
+        return new AjaxMessage(ResultStatus.OK);
+    }
 }

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

@@ -300,4 +300,6 @@ public class InstallController {
 		String msg = deviceService.batchRegister(deviceIds);
 		return new AjaxMessage<>(0,msg,null);
 	}
+
+
 }

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

@@ -140,8 +140,7 @@ public class ConcentratorController {
     public AjaxMessage refreshStatus(
             @ApiParam(value = "集中器id", required = true) @RequestParam(required = true) Integer id
     ) {
-        concentratorService.refreshStatus(id);
-        return new AjaxMessage(ResultStatus.OK);
+        return new AjaxMessage<>(ResultStatus.OK,concentratorService.refreshStatus(id));
     }
 
     @GetMapping("/channel/getList")
@@ -183,6 +182,17 @@ public class ConcentratorController {
         return new AjaxMessage(ResultStatus.OK);
     }
 
+    @PostMapping("/channel/batchAdd/{concentratorId}")
+    //@PreAuthorize("hasAuthority('sys:site:add')")
+    @ApiOperation(value = "批量添加通道")
+    public AjaxMessage batchAdd(
+            @ApiParam(value = "集中器id", required = true) @PathVariable(required = true) Integer concentratorId,
+            @ApiParam(value = "通道", required = true) @RequestBody(required = true) List<ChannelNumber> list
+    ) {
+        channelNumberService.batchAdd(concentratorId,list);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
     @PostMapping("/check/archives")
     //@PreAuthorize("hasAuthority('sys:site:add')")
     @ApiOperation(value = "档案校验")

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

@@ -20,4 +20,6 @@ public interface ChannelNumberMapper {
     int findUnique(@Param("id") Integer id, @Param("concentratorId") Integer concentratorId, @Param("channelNo") String channelNo, @Param("channelNamae") String channelNamae);
 
     ChannelNumber findName(@Param("concentratorId") Integer concentratorId, @Param("name") String name);
+
+    int delByConcentratorId(@Param("concentratorId") Integer concentratorId);
 }

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

@@ -56,4 +56,5 @@ public interface CustomerMapper {
 
     Customer findByName(@Param("siteId") Integer siteId, @Param("name") String name);
 
+    Integer findByCustomerNo(@Param("customerNo") Integer customerNo);
 }

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

@@ -4,6 +4,7 @@ import com.bz.smart_city.dto.*;
 import com.bz.smart_city.dto.assistant.InstallListDTO;
 import com.bz.smart_city.dto.assistant.PlanBuildingDTO;
 import com.bz.smart_city.dto.assistant.PlanCommunityDTO;
+import com.bz.smart_city.dto.sync.MeterSyncDto;
 import com.bz.smart_city.entity.*;
 
 import org.apache.ibatis.annotations.Mapper;
@@ -157,7 +158,10 @@ public interface DeviceMapper {
             @Param("deviceNo") String deviceNo,
             @Param("waterMeterNo") String waterMeterNo,
             @Param("programItems") List<ProgramItem> programItems);
+
     List<Device> findByFileNo(@Param("fileNos") List<String> fileNos,
                               @Param("customerNo") String customerNo);
+
+    List<MeterSyncDto> meterSync(@Param("createDate") String createDate, @Param("customerId") Integer customerId, @Param("fileNo") List<String> fileNo);
 }
 

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/WaterMeterReplaceLogMapper.java

@@ -2,6 +2,7 @@ package com.bz.smart_city.dao;
 
 import com.bz.smart_city.dto.BuildingSelectInfoDto;
 import com.bz.smart_city.dto.WaterMeterReplaceLogDto;
+import com.bz.smart_city.dto.sync.ReplaceMeteDto;
 import com.bz.smart_city.entity.ProgramItem;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -10,6 +11,7 @@ import java.time.LocalDateTime;
 import java.util.List;
 
 import com.bz.smart_city.entity.WaterMeterReplaceLog;
+import org.joda.time.DateTime;
 
 @Mapper
 public interface WaterMeterReplaceLogMapper {
@@ -50,4 +52,6 @@ public interface WaterMeterReplaceLogMapper {
             @Param("startDate") LocalDateTime startDate,
             @Param("endDate") LocalDateTime endDate,
             @Param("programItems") List<ProgramItem> programItems);
+
+    List<ReplaceMeteDto> replaceMete(@Param("rePlaceDate") String rePlaceDate, @Param("customerId") Integer customerId);
 }

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

@@ -28,4 +28,6 @@ public interface WaterRelatedDeviceMapper {
     int updateIssueStatus(@Param("deviceIds") List<Long> deviceIds, @Param("issueStatus") Integer issueStatus);
 
     Building getConcentratorId(@Param("concentratorId") Integer concentratorId);
+
+    Integer countByCollectorId(@Param("collectorId") Integer collectorId);
 }

+ 4 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/assistant/InstallListMapper.java

@@ -3,6 +3,7 @@ package com.bz.smart_city.dao.assistant;
 import com.bz.smart_city.dto.assistant.InstallListDTO;
 import com.bz.smart_city.dto.assistant.PlanBuildingDTO;
 import com.bz.smart_city.dto.assistant.PlanCommunityDTO;
+import com.bz.smart_city.dto.sync.MeterAcceptDto;
 import com.bz.smart_city.entity.assistant.InstallList;
 
 import java.util.List;
@@ -22,7 +23,7 @@ public interface InstallListMapper {
 
     List<PlanCommunityDTO> queryPlanCommunityList(@Param("customerId") Integer customerId, @Param("communityName") String communityName);
 
-    List<PlanBuildingDTO> queryPlanBuildingList(@Param("customerId") Integer customerId, @Param("communityId") Integer communityId,@Param("buildingName")String buildingName);
+    List<PlanBuildingDTO> queryPlanBuildingList(@Param("customerId") Integer customerId, @Param("communityId") Integer communityId, @Param("buildingName") String buildingName);
 
     int countByInstallPlanIdAndIsInstalled(@Param("installPlanId") Integer installPlanId, @Param("isInstalled") int isInstalled);
 
@@ -67,4 +68,6 @@ public interface InstallListMapper {
     List<Integer> queryFloorList(@Param("buildingId") Integer buildingId);
 
     int updateByDeviceId(@Param("deviceId") Long deviceId, @Param("newDeviceNo") String newDeviceNo, @Param("newWaterMeterNo") String newWaterMeterNo);
+
+    List<MeterAcceptDto> meterAccept(@Param("createDate") String createDate, @Param("customerId") Integer customerId, @Param("fileNo") List<String> fileNo);
 }

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

@@ -21,6 +21,15 @@ public class InstallPlanDataDTO {
     @ApiModelProperty(value="名称",position = 1,example = "测试")
     private String name;
 
+    @ApiModelProperty(value="水表档案号",position = 1)
+    private String fileNo;
+
+    @ApiModelProperty(value="用户姓名",position = 1)
+    private String userName;
+
+    @ApiModelProperty(value="用户手机号",position = 1)
+    private String userPhone;
+
     @ApiModelProperty(value = "是否已安装,0否1是", position = 2,example = "0")
     private Integer isInstalled = 0;
 

+ 15 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/MeterAcceptDto.java

@@ -0,0 +1,15 @@
+package com.bz.smart_city.dto.sync;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel
+public class MeterAcceptDto {
+    @ApiModelProperty("水表档案号")
+    private String fileNo;
+
+    @ApiModelProperty("水表是否已验收,1是,0否")
+    private Integer status;
+}

+ 45 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/MeterSyncDto.java

@@ -0,0 +1,45 @@
+package com.bz.smart_city.dto.sync;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel
+public class MeterSyncDto {
+    @ApiModelProperty("设备编号")
+    private String deviceNo;
+
+    @ApiModelProperty("地址")
+    private String locDesc;
+
+    @ApiModelProperty("客户id")
+    private Integer customerId;
+
+    @ApiModelProperty("水表电子号")
+    private String waterMeterNo;
+
+    @ApiModelProperty("水表档案号")
+    private String fileNo;
+
+    @ApiModelProperty("状态")
+    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;
+
+    @ApiModelProperty("水表起度")
+    private String initialData;
+
+    @ApiModelProperty("设备型号  厂商/系列/型号")
+    private String deviceType;
+}

+ 19 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/MeterSyncInputDto.java

@@ -0,0 +1,19 @@
+package com.bz.smart_city.dto.sync;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+import java.util.List;
+
+@Data
+public class MeterSyncInputDto {
+    @ApiModelProperty("创建日期 格式:yyyyMMdd")
+    private String createDate;
+
+    @ApiModelProperty("客户编码")
+    private Integer customerNo;
+
+    @ApiModelProperty("水表档案号")
+    private List<String> fileNo;
+}

+ 37 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/ReplaceMeteDto.java

@@ -0,0 +1,37 @@
+package com.bz.smart_city.dto.sync;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel
+public class ReplaceMeteDto {
+    @ApiModelProperty("水表档案号")
+    private String fileNo;
+
+    @ApiModelProperty("新表表号")
+    private String newWaterNo;
+
+    @ApiModelProperty("旧表表号")
+    private String oldWaterNo;
+
+    @ApiModelProperty("新表止度")
+    private String newBeginWsv;
+
+    @ApiModelProperty("旧表止度")
+    private String oldEndWsv;
+
+    @ApiModelProperty("新节点编号")
+    private String newDeviceNo;
+
+    @ApiModelProperty("旧节点编号")
+    private String oldDeviceNo;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty("换表日期")
+    private LocalDateTime dateCreate;
+}

+ 14 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/sync/ReplaceMeteInputDto.java

@@ -0,0 +1,14 @@
+package com.bz.smart_city.dto.sync;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+@Data
+public class ReplaceMeteInputDto {
+    @ApiModelProperty("创建日期 格式:yyyyMMdd")
+    private String rePlaceDate;
+
+    @ApiModelProperty("客户编码")
+    private Integer customerNo;
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Device.java

@@ -97,6 +97,9 @@ public class Device {
     @ApiModelProperty(value = "是否注册", position = 20)
     private Integer registerStatus;
 
+    @ApiModelProperty(value = "同步状态", position = 20)
+    private Integer syncStatus;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "设备最后上报时间", position = 21)
     private LocalDateTime lastReceiveTime;

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

@@ -11,10 +11,12 @@ import com.bz.smart_city.dto.DeviceTypeDto;
 import com.bz.smart_city.entity.*;
 import com.bz.smart_city.excel.AbstractResolverExcelTemplate;
 import com.bz.smart_city.service.DeviceTypeService;
+import com.bz.smart_city.service.udip.HlhtService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -33,6 +35,10 @@ public class WaterDeviceResolverExcelTemplate extends AbstractResolverExcelTempl
     private DeviceTypeMapper deviceTypeMapper;
     @Resource
     private BuildingMapper buildingMapper;
+    @Autowired
+    private HlhtService hlhtService;
+    @Value("${sync.customer.linhe.id}")
+    private Integer linheCustomerId;
 
     @Override
     protected void cycleExcel() {
@@ -131,6 +137,8 @@ public class WaterDeviceResolverExcelTemplate extends AbstractResolverExcelTempl
                             }
                         }
 
+
+
                         DeviceTypeDto deviceType = deviceTypeMapper.getById(device.getDeviceType());
 
                         //DeviceType deviceType = deviceTypeMapper.findByid(device.getDeviceType());
@@ -144,6 +152,19 @@ public class WaterDeviceResolverExcelTemplate extends AbstractResolverExcelTempl
                         device.setDateCreate(LocalDateTime.now());
                         device.setUpdateBy("system");
                         device.setDateUpdate(LocalDateTime.now());
+
+                        if(device.getCustomerId().equals(linheCustomerId)){
+                            Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
+                            if (syncStatus) {
+                                device.setSyncStatus(1);
+                            }else {
+                                device.setSyncStatus(0);
+                            }
+                        }else {
+                            device.setSyncStatus(0);
+                        }
+
+
                         deviceMapper.insertSelective(device);
 
                         //2、同步设备维度关系

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

@@ -21,5 +21,7 @@ public interface ChannelNumberService {
     void delete(Integer id);
 
     ChannelNumber findCacheByName(Integer id, String name);
+
+    void batchAdd(Integer concentratorId, List<ChannelNumber> list);
 }
 

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

@@ -30,7 +30,7 @@ public interface ConcentratorService{
 
     void delete(Integer id);
 
-    void refreshStatus(Integer id);
+    Integer refreshStatus(Integer id);
 
     Concentrator findCacheByName(Integer siteId, String name);
 

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

@@ -130,4 +130,5 @@ public interface DeviceService{
 
     List<DeviceDto> queryDeviceInfoList(String deviceNo, String waterMeterNo);
 
+    Integer syncDevice(Long deviceId);
 }

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

@@ -15,7 +15,7 @@ public interface WaterRelatedDeviceService {
 
     int batchInsert(List<WaterRelatedDevice> list);
 
-    void fileReset(InputDeviceDto inputDeviceDto);
+    void fileReset(LoginUser loginUser, InputDeviceDto inputDeviceDto);
 
     void batchReleaseFiles(LoginUser loginUser, InputDeviceDto inputDeviceDto);
 }

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java

@@ -64,9 +64,9 @@ public class BuildingServiceImpl implements BuildingService {
 
     @Override
     public int insert(Building building) {
-        building.setCreateBy(UserUtil.getCurrentUser().getUsername());
+        building.setCreateBy("system");
         building.setCreateDate(LocalDateTime.now());
-        building.setUpdateBy(UserUtil.getCurrentUser().getUsername());
+        building.setUpdateBy("system");
         building.setUpdateDate(LocalDateTime.now());
         return buildingMapper.insert(building);
     }

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

@@ -93,12 +93,12 @@ public class ChannelNumberServiceImpl implements ChannelNumberService {
             throw new ServiceException(ResultStatus.CHANNEL_NUMBER_RELATED_NOT_EXISTED);
         }
 
-        ChannelNumber channelNumber = new ChannelNumber();
+        /*ChannelNumber channelNumber = new ChannelNumber();
         channelNumber.setId(id);
         channelNumber.setStatus(0);
         channelNumber.setUpdateBy(loginUser.getUsername());
         channelNumber.setDateUpdate(LocalDateTime.now());
-        this.updateByPrimaryKeySelective(channelNumber);
+        this.updateByPrimaryKeySelective(channelNumber);*/
         log.info("end delete ChannelNumber");
     }
 
@@ -106,5 +106,26 @@ public class ChannelNumberServiceImpl implements ChannelNumberService {
     public ChannelNumber findCacheByName(Integer concentratorId, String name) {
         return channelNumberMapper.findName(concentratorId,name);
     }
+
+    @Override
+    public void batchAdd(Integer concentratorId, List<ChannelNumber> list) {
+        log.info("begin batchAdd concentratorId={} list = {}",concentratorId, JSON.toJSONString(list));
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        channelNumberMapper.delByConcentratorId(concentratorId);
+        if (list != null && list.size() > 0) {
+            for (ChannelNumber channelNumber : list) {
+                channelNumber.setSiteId(loginUser.getSiteId());
+                channelNumber.setConcentratorId(concentratorId);
+                channelNumber.setStatus(1);
+                channelNumber.setCreateBy(loginUser.getUsername());
+                channelNumber.setDateCreate(LocalDateTime.now());
+                channelNumber.setUpdateBy(loginUser.getUsername());
+                channelNumber.setDateUpdate(LocalDateTime.now());
+            }
+            channelNumberMapper.batchInsert(list);
+        }
+
+        log.info("end batchAdd");
+    }
 }
 

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

@@ -125,14 +125,14 @@ public class CollectorServiceImpl implements CollectorService{
         log.info("begin delete Collector id={}", id);
         LoginUser loginUser = UserUtil.getCurrentUser();
 
-        Integer deviceCount = waterRelatedDeviceMapper.countByConcentratorId(id);
+        Integer deviceCount = waterRelatedDeviceMapper.countByCollectorId(id);
         if(deviceCount > 0){
             throw new ServiceException(ResultStatus.COLLECTOR_RELATED_NOT_EXISTED);
         }
 
         Collector collector = new Collector();
         collector.setId(id);
-        collector.setStatus(1);
+        collector.setStatus(0);
         collector.setUpdateBy(loginUser.getUsername());
         collector.setDateUpdate(LocalDateTime.now());
         this.updateByPrimaryKeySelective(collector);

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

@@ -156,7 +156,7 @@ public class ConcentratorServiceImpl implements ConcentratorService{
 
         Concentrator concentrator = new Concentrator();
         concentrator.setId(id);
-        concentrator.setStatus(1);
+        concentrator.setStatus(0);
         concentrator.setUpdateBy(loginUser.getUsername());
         concentrator.setDateUpdate(LocalDateTime.now());
         this.updateByPrimaryKeySelective(concentrator);
@@ -164,7 +164,7 @@ public class ConcentratorServiceImpl implements ConcentratorService{
     }
 
     @Override
-    public void refreshStatus(Integer id) {
+    public synchronized Integer refreshStatus(Integer id) {
         log.info("begin refreshStatus id = {}", id);
         LoginUser loginUser = UserUtil.getCurrentUser();
         Integer status = gdAgentUtils.readConcentratorState(id);
@@ -176,7 +176,9 @@ public class ConcentratorServiceImpl implements ConcentratorService{
             concentrator.setDateUpdate(LocalDateTime.now());
             this.updateByPrimaryKeySelective(concentrator);
         }
-        log.info("end refreshStatus ");
+        log.info("end refreshStatus status = {}",status);
+        return status;
+
     }
 
     @Override

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

@@ -18,10 +18,7 @@ import com.bz.smart_city.excel.download.GdDeviceDownloadExcelTemplate;
 import com.bz.smart_city.excel.download.GeneralDownloadExcelTemplate;
 import com.bz.smart_city.excel.download.WaterDownloadExcelTemplate;
 import com.bz.smart_city.service.*;
-import com.bz.smart_city.service.udip.EasylinkinUtils;
-import com.bz.smart_city.service.udip.GdAgentUtils;
-import com.bz.smart_city.service.udip.UdipEtlDataCommandService;
-import com.bz.smart_city.service.udip.UdipUnitService;
+import com.bz.smart_city.service.udip.*;
 import com.bz.smart_city.service.valve.ValveContext;
 import com.bz.smart_city.service.valve.impl.GdDeviceValveStrategy;
 import com.github.pagehelper.PageHelper;
@@ -120,6 +117,10 @@ public  class DeviceServiceImpl implements DeviceService {
     private WaterDownloadExcelTemplate waterDownloadExcelTemplate;
     @Autowired
     private GdAgentUtils gdAgentUtils;
+    @Autowired
+    private HlhtService hlhtService;
+    @Value("${sync.customer.linhe.id}")
+    private Integer linheCustomerId;
 
     @Override
     public int insert(Device device) {
@@ -410,6 +411,17 @@ public  class DeviceServiceImpl implements DeviceService {
         device.setCustomerId(deviceDataDto.getCustomerId());
         device.setWaterMeterNo(deviceDataDto.getWaterMeterNo());
         device.setRegisterStatus(0);
+
+        if(device.getCustomerId().equals(linheCustomerId)){
+            Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
+            if (syncStatus) {
+                device.setSyncStatus(1);
+            }else {
+                device.setSyncStatus(0);
+            }
+        }else {
+            device.setSyncStatus(0);
+        }
         //device.setUdipId(udipId);
         int result = this.insert(device);
 
@@ -603,6 +615,17 @@ public  class DeviceServiceImpl implements DeviceService {
             device.setUdipId(udipId);
             device.setRegisterStatus(1);
         }
+
+        if(device.getCustomerId().equals(linheCustomerId)){
+            Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
+            if (syncStatus) {
+                device.setSyncStatus(1);
+            }else {
+                device.setSyncStatus(0);
+            }
+        }else {
+            device.setSyncStatus(0);
+        }
         int result = this.updateByPrimaryKeySelective(device);
 
 
@@ -1455,4 +1478,25 @@ public  class DeviceServiceImpl implements DeviceService {
         LoginUser loginUser = UserUtil.getCurrentUser();
         return deviceMapper.queryDeviceInfoList(loginUser.getSiteId(),deviceNo,waterMeterNo,UserUtil.getCurrentSiteProgramItems(loginUser));
     }
+
+    @Override
+    public Integer syncDevice(Long deviceId) {
+        Device device = deviceMapper.findByDeviceId(deviceId);
+        if(device.getCustomerId().equals(linheCustomerId)){
+            Device deviceUpdate = new Device();
+            deviceUpdate.setId(deviceId);
+            Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
+            if (syncStatus) {
+                deviceUpdate.setSyncStatus(1);
+            }else {
+                deviceUpdate.setSyncStatus(0);
+
+            }
+            deviceMapper.updateByPrimaryKeySelective(deviceUpdate);
+            return deviceUpdate.getSyncStatus();
+
+        }else {
+            return 0;
+        }
+    }
 }

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

@@ -10,10 +10,12 @@ import com.bz.smart_city.dto.*;
 import com.bz.smart_city.entity.*;
 import com.bz.smart_city.entity.assistant.InstallList;
 import com.bz.smart_city.service.WorkOrderService;
+import com.bz.smart_city.service.udip.HlhtService;
 import com.bz.smart_city.service.udip.UdipUnitService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -53,6 +55,10 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
     private UdipUnitService udipUnitService;
     @Resource
     private ChannelDeviceTypeUseMapper channelDeviceTypeUseMapper;
+    @Autowired
+    private HlhtService hlhtService;
+    @Value("${sync.customer.linhe.id}")
+    private Integer linheCustomerId;
 
     @Override
     public int insert(WaterMeterMaintenanceLog waterMeterMaintenanceLog) {
@@ -107,6 +113,10 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
             }
         }
 
+        if(device.getCustomerId().equals(linheCustomerId)){
+            hlhtService.equipmentMeter(device.getWaterMeterFileNo(),waterMeterMaintenanceLog.getOldEndWsv(),waterMeterMaintenanceLog.getNewBeginWsv(),waterMeterMaintenanceLog.getNewWaterNo(),waterMeterMaintenanceLog.getOldWaterNo());
+        }
+
         if (!StringUtils.equals(workOrder.getOrderStatus(), "3")) {
             //1、添加维修记录
             waterMeterMaintenanceLog.setAlarmId(deviceErrorDto.getId());

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

@@ -15,12 +15,14 @@ import com.bz.smart_city.dto.assistant.LoginAssistantUser;
 import com.bz.smart_city.entity.ChannelDeviceTypeUse;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.service.BuildingService;
+import com.bz.smart_city.service.udip.HlhtService;
 import com.bz.smart_city.service.udip.UdipUnitService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.kafka.clients.ClientUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
@@ -50,6 +52,10 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
     private BuildingService buildingService;
     @Resource
     private ChannelDeviceTypeUseMapper channelDeviceTypeUseMapper;
+    @Autowired
+    private HlhtService hlhtService;
+    @Value("${sync.customer.linhe.id}")
+    private Integer linheCustomerId;
 
 
     @Override
@@ -170,6 +176,10 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
             }
         }
 
+        if(device.getCustomerId().equals(linheCustomerId)){
+            hlhtService.equipmentMeter(device.getWaterMeterFileNo(),waterMeterReplaceInputDto.getOldEndWsv(),waterMeterReplaceInputDto.getNewBeginWsv(),waterMeterReplaceInputDto.getNewElectronicNo(),device.getWaterMeterNo());
+        }
+
 
         Integer deviceTypeId = waterMeterReplaceInputDto.getNewDeviceTypeId()!=null?waterMeterReplaceInputDto.getNewDeviceTypeId():device.getDeviceType();
 
@@ -232,6 +242,7 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
         newDevice.setDateUpdate(LocalDateTime.now());
         deviceMapper.updateByPrimaryKeySelective(newDevice);
 
+
         log.info("end submitWaterMeterReplace");
     }
 }

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

@@ -49,9 +49,8 @@ public class WaterRelatedDeviceServiceImpl implements WaterRelatedDeviceService
 
     @Override
     @Async
-    public void fileReset(InputDeviceDto inputDeviceDto) {
+    public void fileReset(LoginUser loginUser, InputDeviceDto inputDeviceDto) {
         log.info("begin fileReset inputDeviceDto:{}", JSON.toJSONString(inputDeviceDto));
-        LoginUser loginUser = UserUtil.getCurrentUser();
         waterRelatedDeviceMapper.updateIssueStatus(inputDeviceDto.getDeviceIds(),0);
 
         Message message = new Message();

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

@@ -6,6 +6,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.bz.smart_city.async.SyncLinHeTask;
 import com.bz.smart_city.commom.constant.DeviceStatusEnum;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.util.*;
@@ -93,6 +94,10 @@ public class AcceptManagerServiceImpl implements AcceptManagerService,Initializi
 
 	@Value("${spring.profiles.active}")
 	private String active;
+	@Value("${sync.customer.linhe.id}")
+	private Integer linheCustomerId;
+	@Autowired
+	private SyncLinHeTask syncLinHeTask;
 	
 	@Override
 	public boolean createAcceptPlan(AcceptPlanDTO dto) {
@@ -178,7 +183,8 @@ public class AcceptManagerServiceImpl implements AcceptManagerService,Initializi
 			acceptListDataList.add(acceptListData);
 		}
 
-		//分批推送验收立户
+
+		// 4、分批推送验收立户
 		if (acceptListDataList != null && acceptListDataList.size() > 0) {
 			int total = acceptListDataList.size();
 			int pageSize = 100;
@@ -210,6 +216,12 @@ public class AcceptManagerServiceImpl implements AcceptManagerService,Initializi
 			}
 		}
 
+		//5、临河同步电子号
+		if(acceptPlan.getCustomerId().equals(linheCustomerId)){
+			syncLinHeTask.sync(installList);
+		}
+
+
 		isOk = true;
 		log.info("end AcceptManagerService accetpInstallList ,isOk ={}",isOk);
 		return isOk;

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

@@ -21,6 +21,7 @@ import com.bz.smart_city.entity.assistant.InstallAbnormalDevice;
 import com.bz.smart_city.entity.assistant.InstallAbnormalRecord;
 import com.bz.smart_city.service.DeviceService;
 import com.bz.smart_city.service.WaterMeterReplaceLogService;
+import com.bz.smart_city.service.udip.HlhtService;
 import com.bz.smart_city.service.udip.UdipUnitService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
@@ -678,8 +679,12 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 		deviceMapper.updateByPrimaryKeySelective(d);
 		// 6,维护设备维度信息
 		deviceDimInfoMapper.delByDeviceId(d.getId(), dto.getUpdateBy());
+
+
+
 		saveDeviceDimInfo(d);;
-		isSuccess = true ; 
+		isSuccess = true ;
+
 		// 7.记录操作日志
 		genrateInstallLog(dto,InstallAction.EDIT,"");
 		isSuccess = true ; 
@@ -746,15 +751,21 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 			dto.setIsInstalled(1); // 1 已安装 0 未安装
 			installListMapper.insertSelective(dto);  // 保存安装清单
 		}
+
+
+
 		
 		// 4,保存设备信息
 		DeviceDto d = convertInstallList(dto);
 		d.setDateCreate(LocalDateTime.now());
 		d.setRegisterStatus(0);
+		d.setSyncStatus(0);
 		deviceMapper.insert(d);
 		// 6,保存设备维度信息
 		saveDeviceDimInfo(d);
 		isSuccess = true ;
+
+
 		
 		// 7.记录操作日志
 		genrateInstallLog(dto,InstallAction.INSTALL,"");

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

@@ -347,7 +347,7 @@ public class InstallPlanServiceImpl implements InstallPlanService {
     @Override
     @Transactional
     public void syncPlan(InstallPlanInputDTO installPlanInput) {
-        log.info("begin add InstallPlan : " + JSON.toJSONString(installPlanInput));
+        log.info("begin syncPlan installPlanInput : " + JSON.toJSONString(installPlanInput));
 
         Integer siteId = 1;
 
@@ -502,6 +502,9 @@ public class InstallPlanServiceImpl implements InstallPlanService {
                                         installList.setDoorNo(installPlanDoor.getName());
                                         installList.setDeviceTypeId(installPlanInput.getDeviceTypeId());
                                         installList.setCustomerId(installPlanInput.getCustomerId());
+                                        installList.setFileNo(installPlanDoor.getFileNo());
+                                        installList.setUserName(installPlanDoor.getUserName());
+                                        installList.setUserPhone(installPlanDoor.getUserPhone());
                                         installList.setIsInPlan(1);
                                         installList.setIsInstalled(0);
                                         installList.setIsAccepted(0);

+ 46 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/SyncServiceImpl.java

@@ -0,0 +1,46 @@
+package com.bz.smart_city.service.impl.pay;
+
+import com.bz.smart_city.dao.CustomerMapper;
+import com.bz.smart_city.dao.DeviceMapper;
+import com.bz.smart_city.dao.WaterMeterReplaceLogMapper;
+import com.bz.smart_city.dao.assistant.InstallListMapper;
+import com.bz.smart_city.dto.sync.*;
+import com.bz.smart_city.service.pay.SyncService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Slf4j
+@Service
+public class SyncServiceImpl implements SyncService {
+    @Autowired
+    private CustomerMapper customerMapper;
+    @Autowired
+    private DeviceMapper deviceMapper;
+    @Autowired
+    private InstallListMapper installListMapper;
+    @Resource
+    private WaterMeterReplaceLogMapper waterMeterReplaceLogMapper;
+
+    @Override
+    public List<MeterSyncDto> meterSync(MeterSyncInputDto meterSync) {
+
+        Integer customerId = customerMapper.findByCustomerNo(meterSync.getCustomerNo());
+        return deviceMapper.meterSync(meterSync.getCreateDate(),customerId,meterSync.getFileNo());
+    }
+
+    @Override
+    public List<MeterAcceptDto> meterAccept(MeterSyncInputDto meterSync) {
+        Integer customerId = customerMapper.findByCustomerNo(meterSync.getCustomerNo());
+        return installListMapper.meterAccept(meterSync.getCreateDate(),customerId,meterSync.getFileNo());
+    }
+
+    @Override
+    public List<ReplaceMeteDto> replaceMete(ReplaceMeteInputDto replaceMete) {
+        Integer customerId = customerMapper.findByCustomerNo(replaceMete.getCustomerNo());
+        return waterMeterReplaceLogMapper.replaceMete(replaceMete.getRePlaceDate(),customerId);
+    }
+}

+ 13 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/SyncService.java

@@ -0,0 +1,13 @@
+package com.bz.smart_city.service.pay;
+
+import com.bz.smart_city.dto.sync.*;
+
+import java.util.List;
+
+public interface SyncService {
+    List<MeterSyncDto> meterSync(MeterSyncInputDto meterSync);
+
+    List<MeterAcceptDto> meterAccept(MeterSyncInputDto meterSync);
+
+    List<ReplaceMeteDto> replaceMete(ReplaceMeteInputDto replaceMete);
+}

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

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -125,16 +126,22 @@ public class GdAgentUtils {
         String url = gdAgentUrl+"/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();
+        ResponseEntity<ConcentratorInfo> responseEntity = restTemplate.getForEntity(url, ConcentratorInfo.class,map);
+        log.info("responseEntity ={}", JSON.toJSONString(responseEntity));
+        if(responseEntity.getStatusCode() == HttpStatus.OK){
+            ConcentratorInfo concentratorInfo = responseEntity.getBody();
+            if(concentratorInfo != null){
+                if(concentratorInfo.getResult()==1){
+                    return concentratorInfo.getConcentratorState();
+                }
             }
+        }else {
+            log.error("刷新集中器状态异常");
         }
+
         return null;
     }
-    //下发档案
+    //
     public Integer setMeterInfo(Long deviceId){
         log.info("begin setMeterInfo deviceId={}",deviceId);
         String url = gdAgentUrl+"/api/readmeter/setMeterInfo?deviceId={deviceId}";

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

@@ -0,0 +1,111 @@
+package com.bz.smart_city.service.udip;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.bz.smart_city.commom.exception.ServiceException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * 互联互通
+ */
+@Slf4j
+@Service
+public class HlhtService {
+
+    private RestTemplate restTemplate = new RestTemplate();
+
+    /**
+     * 更新水表电子号
+     * @param eleno 水表电子号
+     * @param metercode 水表档案号
+     */
+    public Boolean updatePayMeterEleno(String eleno,String metercode){
+        log.info("begin updatePayMeterEleno");
+        Boolean syncStatus = false;
+        if (metercode != null && !StringUtils.equals("",metercode)) {
+            //String url ="http://192.168.0.170:8089/HuaxuIswaterV1.1/Archives/updatePayMeterEleno";
+            String url ="http://183.62.175.140:9182/HuaxuIswaterV1.1/Archives/updatePayMeterEleno";
+            JSONObject postData = new JSONObject();
+            postData.put("eleno", eleno);
+            postData.put("metercode", metercode);
+            ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, postData, String.class);
+            log.info("responseEntity : {}", JSON.toJSONString(responseEntity));
+            if (responseEntity != null && responseEntity.getStatusCode()== HttpStatus.OK) {
+                //String result = (String) responseEntity.getBody();
+                JSONObject jsonObject = JSONObject.parseObject(responseEntity.getBody());
+                log.info("result : {}", jsonObject);
+
+                String succ = jsonObject.getString("succ");
+                if (StringUtils.equals(succ,"0")){
+                    syncStatus = true;
+                    log.info("success");
+                }else {
+                    log.info("fail");
+                }
+            }else {
+                log.error("request error");
+            }
+        }
+        log.info("end updatePayMeterEleno");
+        return syncStatus;
+    }
+
+    /**
+     * 换表
+     * @param metercode 水表档案号
+     * @param oldStartcount 旧表起度
+     * @param newStartcount 新表起度
+     * @param newEleno 新表电子号
+     * @param oldEleno 旧表电子号
+     */
+    public Boolean equipmentMeter(String metercode,String oldStartcount,String newStartcount,String newEleno,String oldEleno){
+        log.info("begin equipmentMeter");
+        Boolean syncStatus = false;
+        if (metercode != null && !StringUtils.equals("",metercode)) {
+            //String url ="http://192.168.0.170:8089/HuaxuIswaterV1.1/Archives/equipmentMeter";
+            String url ="http://183.62.175.140:9182/HuaxuIswaterV1.1/Archives/equipmentMeter";
+            JSONObject postData = new JSONObject();
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            postData.put("replacedate", LocalDateTime.now().format(df));//换表时间(yyyy-MM-dd HH:mm:ss)
+            postData.put("metercode", metercode);
+            postData.put("oldStartcount", oldStartcount);
+            postData.put("newStartcount", newStartcount);
+            postData.put("newEleno", newEleno);
+            postData.put("oldEleno", oldEleno);
+            ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, postData, String.class);
+            log.info("responseEntity : {}", JSON.toJSONString(responseEntity));
+            if (responseEntity != null && responseEntity.getStatusCode()== HttpStatus.OK) {
+                JSONObject jsonObject = JSONObject.parseObject(responseEntity.getBody());
+                log.info("result : {}", jsonObject);
+                String succ = jsonObject.getString("succ");
+                JSONArray meterList = jsonObject.getJSONArray("meterList");
+                JSONObject meter = meterList.getJSONObject(0);
+                if (meter != null) {
+                    String result = meter.getString("result");
+                    String msg = meter.getString("msg");
+                    if (StringUtils.equals(result,"0")){
+                        syncStatus = true;
+                        log.info("success");
+                    }else {
+                        throw new ServiceException(-999, msg);
+                    }
+                }else {
+                    log.info("meter fail");
+                }
+            }else {
+                log.error("request error");
+            }
+        }
+        log.info("end equipmentMeter");
+        return syncStatus;
+    }
+}

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

@@ -165,4 +165,6 @@ invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpO
 invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action
 #光电直读agent url
 gd.agent.url=http://10.0.0.160:6377
+#临河客户
+sync.customer.linhe.id=126
 

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

@@ -168,4 +168,6 @@ udip.unit.url=http://47.112.15.78:8322
 invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
 invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action
 #光电直读agent url
-gd.agent.url=http://10.0.0.160:6377
+gd.agent.url=http://10.0.0.160:6377
+#临河客户
+sync.customer.linhe.id=126

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

@@ -167,4 +167,6 @@ udip.unit.url=http://114.135.61.188:48322
 invoice.print.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action
 invoice.query.url=http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action
 #光电直读agent url
-gd.agent.url=http://10.0.0.160:6377
+gd.agent.url=http://10.0.0.160:6377
+#临河客户
+sync.customer.linhe.id=126

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


+ 7 - 3
smart-city-platform/src/main/resources/mapper/ChannelNumberMapper.xml

@@ -128,12 +128,12 @@
   </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, 
+    replace into sc_channel_number
+    (id, 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.id}, #{item.siteId}, #{item.concentratorId}, #{item.channelName}, #{item.channelNo},
         #{item.status}, #{item.remark}, #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, 
         #{item.updateBy})
     </foreach>
@@ -153,4 +153,8 @@
   <select id="findName" resultMap="BaseResultMap">
     select id,channel_name,channel_no from sc_channel_number where status = 1 and concentrator_id = #{concentratorId} and channel_name = #{name}
   </select>
+
+  <update id="delByConcentratorId">
+    update sc_channel_number set status = 0,date_update = NOW() where status = 1 and concentrator_id = #{concentratorId}
+  </update>
 </mapper>

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

@@ -142,6 +142,7 @@
   <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>
+    order by date_create desc
   </select>
 
   <update id="checkClear">

+ 4 - 0
smart-city-platform/src/main/resources/mapper/CustomerMapper.xml

@@ -355,6 +355,10 @@
         select id,customer_name from sc_customer where status = 1 and site_id = #{siteId} and customer_name = #{name} limit 1
     </select>
 
+    <select id="findByCustomerNo" resultType="java.lang.Integer">
+        select id from sc_customer where status = 1 and customer_no = #{customerNo}
+    </select>
+
 
 </mapper>
 

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

@@ -168,7 +168,8 @@
             metercode,
             account_id,
             udip_id,
-            register_status
+            register_status,
+            sync_status
         ) VALUES (
             #{device.id,jdbcType=BIGINT},
             #{device.deviceNo,jdbcType=VARCHAR},
@@ -196,7 +197,8 @@
             #{device.metercode,jdbcType=VARCHAR},
             #{device.accountId,jdbcType=BIGINT},
             #{device.udipId,jdbcType=VARCHAR},
-            #{device.registerStatus,jdbcType=INTEGER}
+            #{device.registerStatus,jdbcType=INTEGER},
+            #{device.syncStatus,jdbcType=INTEGER}
         )
 </insert>
 
@@ -343,7 +345,8 @@
                 <if test="device.waterMeterFileNo != null"> water_meter_file_no = #{device.waterMeterFileNo,jdbcType=VARCHAR},</if>
                 <if test="device.customerId != null"> customer_id = #{device.customerId,jdbcType=INTEGER},</if>
                 <if test="device.udipId != null"> udip_id = #{device.udipId,jdbcType=VARCHAR},</if>
-                <if test="device.registerStatus != null"> register_status = #{device.registerStatus,jdbcType=INTEGER}</if>
+                <if test="device.registerStatus != null"> register_status = #{device.registerStatus,jdbcType=INTEGER},</if>
+                <if test="device.syncStatus != null"> sync_status = #{device.syncStatus,jdbcType=INTEGER}</if>
         </set>
 		WHERE id = #{device.id,jdbcType=BIGINT}
     </update>
@@ -360,7 +363,8 @@
         sil.plan_time,sil.install_time,sil.accept_time,
         swmed.days,swmed.last_error_type,
         swmed.meter_reading,swmed.valve_status,
-        swmed.valve_button_status
+        swmed.valve_button_status,
+        sd.sync_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)
@@ -606,7 +610,8 @@
         sil.plan_time,sil.install_time,sil.accept_time,
         swmed.days,swmed.last_error_type,
         swmed.meter_reading,swmed.valve_status,
-        swmed.valve_button_status
+        swmed.valve_button_status,
+        sd.sync_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)
@@ -768,7 +773,8 @@
         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,swmed.meter_reading,scus.customer_name,
-        sil.plan_time,sil.install_time,sil.accept_time,sil.new_meter_start,sil.id as install_id,sil.old_meter_end,sd.register_status,sdt.is_valve,sdt.is_register
+        sil.plan_time,sil.install_time,sil.accept_time,sil.new_meter_start,sil.id as install_id,sil.old_meter_end,sd.register_status,sdt.is_valve,sdt.is_register,
+        sd.sync_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)
@@ -1110,5 +1116,27 @@
             #{item}
         </foreach>
     </select>
+
+    <select id="meterSync" resultType="com.bz.smart_city.dto.sync.MeterSyncDto">
+        select
+        sd.device_no,
+        sd.loc_desc,
+        sd.customer_id,
+        sd.water_meter_no,
+        sd.water_meter_file_no as file_no,
+        sd.status,
+        sd.date_create,
+        sd.date_update,
+        sil.new_meter_start,
+        CONCAT_WS('/',sdm.name,sdt.equipment_type,sdt.model) as device_type
+        from sc_device sd
+        left join sc_install_list sil on(sil.device_id = sd.id)
+        left join sc_device_type sdt on(sdt.id = sd.device_type)
+        left join sc_device_manufacturer sdm on(sdm.id = sdt.manufacturer_id)
+        where sd.status = 1
+        and sd.customer_id = #{customerId}
+        <if test="createDate != null and createDate != ''"> and DATE_FORMAT(sd.date_create, '%Y%m%d' ) = #{createDate}</if>
+        and sd.water_meter_file_no in <foreach collection="fileNo" item="item" open="(" separator="," close=")">#{item}</foreach>
+    </select>
 </mapper>
 

+ 16 - 2
smart-city-platform/src/main/resources/mapper/InstallListMapper.xml

@@ -435,7 +435,7 @@
 			dm.`name` as facory_name,
             sd.device_no as device_no,
             sd.water_meter_no as electronic_no,
-			n.file_no as file_no,
+			sd.water_meter_file_no as file_no,
 			n.new_meter_start as new_meter_start,
 			n.old_meter_end as old_meter_end,
 			n.image_url as new_image_url,
@@ -878,7 +878,7 @@
     </select>
 
     <select id="getInstallListByBuildIngId" resultMap="BaseResultMap">
-        select id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id, customer_id, door_no, device_id, device_no, electronic_no, user_name, user_phone, is_in_plan, is_installed, install_time from sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId} and building_id = #{buildingId}
+        select id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id, customer_id, door_no, device_id, device_no, electronic_no,file_no, user_name, user_phone, is_in_plan, is_installed, install_time from sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId} and building_id = #{buildingId}
     </select>
     <select id="queryFloorList" resultType="java.lang.Integer">
         select floor from sc_install_list where status = 1 and building_id = #{buildingId} group by floor order by floor asc
@@ -898,4 +898,18 @@
         status = 1
         and device_id = #{deviceId}
     </update>
+
+  <select id="meterAccept" resultType="com.bz.smart_city.dto.sync.MeterAcceptDto">
+    select
+    sd.water_meter_file_no as file_no,
+    sil.is_installed as status
+    from sc_install_list sil
+    inner join sc_device sd on(sd.id = sil.device_id)
+    where sil.status = 1 and sd.status = 1
+    and sd.customer_id = #{customerId}
+    <if test="createDate != null and createDate != ''"> and DATE_FORMAT(sil.accept_time, '%Y%m%d' ) = #{createDate}</if>
+    <if test="fileNo != null and fileNo.size() != 0">
+      and sd.water_meter_file_no in <foreach collection="fileNo" item="item" open="(" separator="," close=")">#{item}</foreach>
+    </if>
+  </select>
 </mapper>

+ 16 - 0
smart-city-platform/src/main/resources/mapper/WaterMeterReplaceLogMapper.xml

@@ -428,4 +428,20 @@
         ) t1 on (t1.building_id = b.id)
         where b.status = 1
     </select>
+
+    <select id="replaceMete" resultType="com.bz.smart_city.dto.sync.ReplaceMeteDto">
+        select
+        sd.water_meter_file_no as file_no,
+        swmrl.new_water_no,
+        swmrl.old_water_no,
+        swmrl.new_begin_wsv,
+        swmrl.old_end_wsv,
+        swmrl.new_device_no,
+        swmrl.old_device_no,
+        swmrl.date_create
+        from sc_water_meter_replace_log swmrl
+        inner join sc_device sd on(sd.id = swmrl.device_id)
+        where swmrl.status = 1 and sd.status = 1 and sd.customer_id = #{customerId}
+        and DATE_FORMAT(swmrl.date_create, '%Y%m%d' ) = #{rePlaceDate}
+    </select>
 </mapper>

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

@@ -185,4 +185,8 @@
     left join sc_building sb on(sb.id = sd.building_id)
     where swrd.status = 1 and sd.`status`=1 and swrd.concentrator_id = #{concentratorId} limit 1
   </select>
+
+  <select id="countByCollectorId" resultType="java.lang.Integer">
+    select count(1) from sc_water_related_device where status = 1 and collector_id = #{collectorId}
+  </select>
 </mapper>

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

@@ -12,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.HlhtService;
 import com.bz.smart_city.service.udip.model.MeterInfo;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -391,6 +392,13 @@ public class ScTest {
         }
     }
 
+    @Test
+    public void HlhtService(){
+        HlhtService hlhtService =  new HlhtService();
+        //hlhtService.updatePayMeterEleno("3412345131234","311000002201");
+        hlhtService.equipmentMeter("311000002201","10","0","3412345131235","3412345131234");
+    }
+