Browse Source

Merge remote-tracking branch 'origin/20200908' into 20200908

pengdi@zoniot.com 4 years ago
parent
commit
5af5cecf59
27 changed files with 1091 additions and 1065 deletions
  1. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/async/SyncLinHeTask.java
  2. 7 4
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  3. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/BuildingMapper.java
  4. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java
  5. 5 3
      smart-city-platform/src/main/java/com/bz/smart_city/excel/AbstractResolverExcelTemplate.java
  6. 93 102
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/BuildingResolverExcelTemplate.java
  7. 114 122
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/CollectorResolveExcelTemplate.java
  8. 142 150
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/ConcentratorResolveExcelTemplate.java
  9. 191 179
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/GdDeviceResolverExcelTemplate.java
  10. 103 111
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/GeneralDeviceResolverExcelTemplate.java
  11. 204 189
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallResolverExcelTemplate.java
  12. 153 145
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/WaterDeviceResolverExcelTemplate.java
  13. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/BuildingService.java
  14. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  15. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/BuildingServiceImpl.java
  16. 8 12
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  17. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/JobCardServiceImpl.java
  18. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/assistant/InstallManagerServiceImpl.java
  19. 47 31
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/HlhtService.java
  20. 4 3
      smart-city-platform/src/main/java/com/bz/smart_city/service/udip/UdipUnitService.java
  21. BIN
      smart-city-platform/src/main/resources/excel/deviceTemplateV3.xlsx
  22. BIN
      smart-city-platform/src/main/resources/excel/installPlanTemplate20200731.xlsx
  23. 1 0
      smart-city-platform/src/main/resources/mapper/BuildingMapper.xml
  24. 2 0
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  25. 1 1
      smart-city-platform/src/main/resources/mapper/InstallListMapper.xml
  26. 3 3
      smart-city-platform/src/test/java/com/bz/smart_city/ForCreateDataTest.java
  27. 2 2
      smart-city-platform/src/test/java/com/bz/smart_city/ScTest.java

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

@@ -37,7 +37,7 @@ public class SyncLinHeTask {
                 if (syncStatus) {
                     device.setSyncStatus(1);
                 }else {
-                    device.setSyncStatus(0);
+                    device.setSyncStatus(2);
                 }
                 device.setDateUpdate(LocalDateTime.now());
                 deviceMapper.updateByPrimaryKeySelective(device);

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

@@ -65,6 +65,7 @@ public class DeviceController {
             @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
             @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus,
             @ApiParam(value = "下发状态 0:未下发 1:已下发", required = false) @RequestParam(required = false) Integer issueStatus,
+            @ApiParam(value = "同步状态 0:未同步 1:已同步", required = false) @RequestParam(required = false) Integer syncStatus,
             @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false,defaultValue = "sd.date_create") String sortColumn,
             @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false, defaultValue = "DESC") String sortOrder,
             @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
@@ -72,7 +73,7 @@ public class DeviceController {
     ) {
         Pagination<DeviceDto> pageInfo = deviceService.getList(sysId, buildingId, StringUtils.trim(deviceNo), status, manufacturerId, StringUtils.trim(equipmentType), StringUtils.trim(model), isTag,
                 floor, StringUtils.trim(locDesc), province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,
-                deviceTypeId,valveStatus,registerStatus,issueStatus,sortColumn, sortOrder, pageNum, pageSize);
+                deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus,sortColumn, sortOrder, pageNum, pageSize);
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
 
@@ -118,13 +119,14 @@ public class DeviceController {
             @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
             @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus,
             @ApiParam(value = "下发状态 0:未下发 1:已下发", required = false) @RequestParam(required = false) Integer issueStatus,
+            @ApiParam(value = "同步状态 0:未同步 1:已同步", required = false) @RequestParam(required = false) Integer syncStatus,
             @ApiParam(value = "排序参数,对应列表字段", required = false) @RequestParam(required = false,defaultValue = "sd.date_create") String sortColumn,
             @ApiParam(value = "排序方式,顺序:ASC  倒序:DESC", required = false) @RequestParam(required = false,defaultValue = "DESC") String sortOrder,
             HttpServletResponse httpServletResponse
     ) {
         deviceService.getDeviceListExcel(sysId, buildingId, StringUtils.trim(deviceNo), status, manufacturerId, StringUtils.trim(equipmentType), StringUtils.trim(model), isTag,
                 floor, StringUtils.trim(locDesc), province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,
-                deviceTypeId,valveStatus,registerStatus,issueStatus,sortColumn, sortOrder, httpServletResponse);
+                deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus,sortColumn, sortOrder, httpServletResponse);
 
     }
 
@@ -191,10 +193,11 @@ public class DeviceController {
             @ApiParam(value = "设备类型ID", required = false) @RequestParam(required = false) Integer deviceTypeId,
             @ApiParam(value = "阀门状态 0:关阀 1:开阀  2:无阀", required = false) @RequestParam(required = false) Integer valveStatus,
             @ApiParam(value = "注册状态 0:未注册 1:已注册", required = false) @RequestParam(required = false) Integer registerStatus,
-            @ApiParam(value = "下发状态 0:未下发 1:已下发", required = false) @RequestParam(required = false) Integer issueStatus
+            @ApiParam(value = "下发状态 0:未下发 1:已下发", required = false) @RequestParam(required = false) Integer issueStatus,
+            @ApiParam(value = "同步状态 0:未同步 1:已同步", required = false) @RequestParam(required = false) Integer syncStatus
     ) {
         List<BuildingSelectDto> list = buildingService.deviceAreaList(sysId, buildingId, deviceNo, status, manufacturerId, equipmentType, model, isTag,
-                floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,deviceTypeId,valveStatus,registerStatus,issueStatus);
+                floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId, days, startDays,endDays,deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus);
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
 

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

@@ -67,7 +67,7 @@ public interface BuildingMapper {
 
     List<Building> findByIds(@Param("ids") List<Integer> ids);
 
-    List<BuildingSelectInfoDto> deviceCountAreaList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("deviceNo") String deviceNo, @Param("status") Integer status, @Param("manufacturerId") Integer manufacturerId, @Param("equipmentType") String equipmentType, @Param("model") String model, @Param("isTag") Integer isTag, @Param("floor") Integer floor, @Param("locDesc") String locDesc, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("concentratorNo") String concentratorNo, @Param("collectorNo") String collectorNo, @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("days") Integer days, @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus, @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus);
+    List<BuildingSelectInfoDto> deviceCountAreaList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("deviceNo") String deviceNo, @Param("status") Integer status, @Param("manufacturerId") Integer manufacturerId, @Param("equipmentType") String equipmentType, @Param("model") String model, @Param("isTag") Integer isTag, @Param("floor") Integer floor, @Param("locDesc") String locDesc, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("concentratorNo") String concentratorNo, @Param("collectorNo") String collectorNo, @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("days") Integer days, @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus, @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus, @Param("syncStatus") Integer syncStatus);
 
     List<BuildingSelectInfoDto> abnormalAreaBuildingList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems, @Param("sysId") Integer sysId, @Param("buildingId") Integer buildingId, @Param("floor") Integer floor, @Param("measuringId") Integer measuringId, @Param("deviceId") Long deviceId, @Param("deviceNo") String deviceNo, @Param("location") String location, @Param("alarmCategory") Integer alarmCategory, @Param("handleStatus") Integer handleStatus, @Param("alarmTypeId") Integer alarmTypeId, @Param("equipmentId") Integer equipmentId, @Param("manufacturerId") Integer manufacturerId, @Param("customerId") Integer customerId, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region, @Param("communityId") Integer communityId, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate);
 

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

@@ -32,7 +32,8 @@ public interface DeviceMapper {
                             @Param("model") String model, @Param("isTag") Integer isTag, @Param("floor") Integer floor, @Param("locDesc") String locDesc, @Param("province") Integer province,
                             @Param("city") Integer city, @Param("region") Integer region, @Param("community") Integer community, @Param("concentratorNo") String concentratorNo,
                             @Param("collectorNo") String collectorNo, @Param("errorType") String errorType, @Param("customerId") Integer customerId, @Param("days") Integer days,
-                            @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus, @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
+                            @Param("startDays") Integer startDays, @Param("endDays") Integer endDays, @Param("deviceTypeId") Integer deviceTypeId, @Param("valveStatus") Integer valveStatus,
+                            @Param("registerStatus") Integer registerStatus, @Param("issueStatus") Integer issueStatus, @Param("syncStatus") Integer syncStatus, @Param("sortColumn") String sortColumn, @Param("sortOrder") String sortOrder);
 
     //按设备编号查询
     List<DeviceDto> getWaterMeterListByDeviceNo(@Param("deviceNo") String deviceNo, @Param("waterMeterNo") String waterMeterNo);

+ 5 - 3
smart-city-platform/src/main/java/com/bz/smart_city/excel/AbstractResolverExcelTemplate.java

@@ -132,9 +132,8 @@ public abstract class AbstractResolverExcelTemplate {
         record.setFailTime(failTime.get());
         importService.updateByPrimaryKeySelective(record);
 
-        if(!invalidTemplate){
-            messageContent.append("无效模板");
-        }else {
+
+        if(invalidTemplate){
             messageContent.append("导入完成,");
             messageContent.append("导入成功");
             messageContent.append(successTime);
@@ -142,7 +141,10 @@ public abstract class AbstractResolverExcelTemplate {
             messageContent.append("导入失败");
             messageContent.append(failTime);
             messageContent.append("条。");
+        }else {
+            messageContent.append("无效模板");
         }
+
         //更新完成生成消息
         Message message = new Message();
         message.setSiteId(record.getUserId());

+ 93 - 102
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/BuildingResolverExcelTemplate.java

@@ -41,120 +41,111 @@ public class BuildingResolverExcelTemplate extends AbstractResolverExcelTemplate
     protected void cycleExcel() {
         log.info("begin buildingResolverExcelTemplate");
         String executeSheetName = "省市区";
-        try {
-            FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                // 循环行Row
-                for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    if (row != null) {
-
-                        Cell buildingNameCell = row.getCell(0);
-                        Cell provinceNameCell = row.getCell(1);
-                        Cell provinceCell = row.getCell(2);
-                        Cell cityNameCell = row.getCell(3);
-                        Cell cityCell = row.getCell(4);
-                        Cell regionNameCell = row.getCell(5);
-                        Cell regionCell = row.getCell(6);
-                        Cell communityNameCell = row.getCell(7);
-                        Cell addressCell = row.getCell(8);
-                        Cell c_remark = row.getCell(9);
-                        if (buildingNameCell == null || StringUtils.equals("", buildingNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        //查询小区是否存在
-                        String communityName = communityNameCell.getStringCellValue();
-                        Community community = communityService.findByName(record.getSiteId(), communityName);
-                        //查询建筑是否存在
-                        Building buildingResult = buildingMapper.findByName(record.getSiteId(), buildingNameCell.getStringCellValue());
-                        if (buildingResult != null) {
-                            failTime.incrementAndGet();
-                            c_remark.setCellValue("该建筑名称已存在");
-                            continue;
-                        }
-                        CellValue cellValueProvince = evaluator.evaluate(provinceCell);
-                        CellValue cellValueCity = evaluator.evaluate(cityCell);
-                        CellValue cellValueRegion = evaluator.evaluate(regionCell);
+        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            // 循环行Row
+            for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                if (row != null) {
 
-                        Building building = new Building();
-                        building.setSiteId(record.getSiteId());
-                        building.setName(buildingNameCell.getStringCellValue());
-                        building.setAddress(addressCell.getStringCellValue());
-                        building.setProvince((int) cellValueProvince.getNumberValue());
-                        building.setCity((int) cellValueCity.getNumberValue());
-                        building.setRegion((int) cellValueRegion.getNumberValue());
-                        building.setStatus(1);
-                        building.setCreateBy("system");
-                        building.setUpdateBy("system");
-                        building.setCreateDate(LocalDateTime.now());
-                        building.setUpdateDate(LocalDateTime.now());
-                        if (community != null) {
-                            building.setCommunity(community.getId());
-                        } else {
-                            //添加小区
-                            Community communityNew = new Community();
-                            //获取小区最大值,然后加1
-                            String code = "001";
-                            List<Community> communities = communityMapper.getMaxCodeBySiteId(record.getSiteId());
-                            if(communities.size()==1)
-                            {
-                                if (communities.get(0) != null) {
-                                    code =String.format("%03d",Integer.valueOf(communities.get(0).getCode()));
-                                }else {
-                                    code = String.format("%03d",Integer.valueOf("1"));
-                                }
+                    Cell buildingNameCell = row.getCell(0);
+                    Cell provinceNameCell = row.getCell(1);
+                    Cell provinceCell = row.getCell(2);
+                    Cell cityNameCell = row.getCell(3);
+                    Cell cityCell = row.getCell(4);
+                    Cell regionNameCell = row.getCell(5);
+                    Cell regionCell = row.getCell(6);
+                    Cell communityNameCell = row.getCell(7);
+                    Cell addressCell = row.getCell(8);
+                    Cell c_remark = row.getCell(9);
+                    if (buildingNameCell == null || StringUtils.equals("", buildingNameCell.getStringCellValue())) {
+                        continue;
+                    }
+                    //查询小区是否存在
+                    String communityName = communityNameCell.getStringCellValue();
+                    Community community = communityService.findByName(record.getSiteId(), communityName);
+                    //查询建筑是否存在
+                    Building buildingResult = buildingMapper.findByName(record.getSiteId(), buildingNameCell.getStringCellValue());
+                    if (buildingResult != null) {
+                        failTime.incrementAndGet();
+                        c_remark.setCellValue("该建筑名称已存在");
+                        continue;
+                    }
+                    CellValue cellValueProvince = evaluator.evaluate(provinceCell);
+                    CellValue cellValueCity = evaluator.evaluate(cityCell);
+                    CellValue cellValueRegion = evaluator.evaluate(regionCell);
 
+                    Building building = new Building();
+                    building.setSiteId(record.getSiteId());
+                    building.setName(buildingNameCell.getStringCellValue());
+                    building.setAddress(addressCell.getStringCellValue());
+                    building.setProvince((int) cellValueProvince.getNumberValue());
+                    building.setCity((int) cellValueCity.getNumberValue());
+                    building.setRegion((int) cellValueRegion.getNumberValue());
+                    building.setStatus(1);
+                    building.setCreateBy("system");
+                    building.setUpdateBy("system");
+                    building.setCreateDate(LocalDateTime.now());
+                    building.setUpdateDate(LocalDateTime.now());
+                    if (community != null) {
+                        building.setCommunity(community.getId());
+                    } else {
+                        //添加小区
+                        Community communityNew = new Community();
+                        //获取小区最大值,然后加1
+                        String code = "001";
+                        List<Community> communities = communityMapper.getMaxCodeBySiteId(record.getSiteId());
+                        if(communities.size()==1)
+                        {
+                            if (communities.get(0) != null) {
+                                code =String.format("%03d",Integer.valueOf(communities.get(0).getCode()));
+                            }else {
+                                code = String.format("%03d",Integer.valueOf("1"));
                             }
-                            communityNew.setCode(code);
-                            communityNew.setSiteId(record.getSiteId());
-                            communityNew.setName(communityName);
-                            communityNew.setProvince((int) cellValueProvince.getNumberValue());
-                            communityNew.setCity((int) cellValueCity.getNumberValue());
-                            communityNew.setRegion((int) cellValueRegion.getNumberValue());
-                            communityNew.setStatus(1);
-                            communityService.insert(communityNew);
-                            building.setCommunity(communityNew.getId());
-                        }
-                        log.info("begin building"+buildingNameCell.getStringCellValue()+" geo");
-                        GeoDTO geoDTO = geoService.getBuildingInfo(cityNameCell.getStringCellValue(), communityName, buildingNameCell.getStringCellValue());
-                        if (geoDTO != null) {
-                            log.info("geoDTO:"+ JSON.toJSONString(geoDTO));
-                            building.setLongitude(Double.valueOf(geoDTO.getLng()));
-                            building.setLatitude(Double.valueOf(geoDTO.getLat()));
+
                         }
+                        communityNew.setCode(code);
+                        communityNew.setSiteId(record.getSiteId());
+                        communityNew.setName(communityName);
+                        communityNew.setProvince((int) cellValueProvince.getNumberValue());
+                        communityNew.setCity((int) cellValueCity.getNumberValue());
+                        communityNew.setRegion((int) cellValueRegion.getNumberValue());
+                        communityNew.setStatus(1);
+                        communityService.insert(communityNew);
+                        building.setCommunity(communityNew.getId());
+                    }
+                    log.info("begin building"+buildingNameCell.getStringCellValue()+" geo");
+                    GeoDTO geoDTO = geoService.getBuildingInfo(cityNameCell.getStringCellValue(), communityName, buildingNameCell.getStringCellValue());
+                    if (geoDTO != null) {
+                        log.info("geoDTO:"+ JSON.toJSONString(geoDTO));
+                        building.setLongitude(Double.valueOf(geoDTO.getLng()));
+                        building.setLatitude(Double.valueOf(geoDTO.getLat()));
+                    }
 
-                        buildingMapper.insertSelective(building);
+                    buildingMapper.insertSelective(building);
 
-                        hssfSheet.removeRow(row);//成功删除该行
-                        successTime.incrementAndGet();
-                    }
+                    hssfSheet.removeRow(row);//成功删除该行
+                    successTime.incrementAndGet();
                 }
+            }
 
-                log.info("开始循环为空的行上移");
-                //循环为空的行上移
-                if(failTime.incrementAndGet() > 0){
-                    for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 0 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            log.info("开始循环为空的行上移");
+            //循环为空的行上移
+            if(failTime.incrementAndGet() > 0){
+                for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 0 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
-
-                isDownload = true;
             }
 
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+            isDownload = true;
         }
 
         log.info("end buildingResolverExcelTemplate");

+ 114 - 122
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/CollectorResolveExcelTemplate.java

@@ -45,135 +45,127 @@ public class CollectorResolveExcelTemplate extends AbstractResolverExcelTemplate
     @Override
     protected void cycleExcel() {
         log.info("begin CollectorResolveExcelTemplate");
-        try {
-            String executeSheetName = "表格模板";
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                invalidTemplate = true;
-                // 循环行Row
-                for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    if (row != null) {
-                        Cell collectorNameCell = row.getCell(0);
-                        Cell customerNameCell = row.getCell(1);
-                        Cell buildingNameCell = row.getCell(2);
-                        Cell locDescCell = row.getCell(3);
-                        Cell concentratorNameCell = row.getCell(4);
-                        Cell remarkCell = row.getCell(5);
-
-
-                        collectorNameCell.setCellType(CellType.STRING);
-                        locDescCell.setCellType(CellType.STRING);
-                        concentratorNameCell.setCellType(CellType.STRING);
-
-
-
-                        if (StringUtils.equals("", collectorNameCell.getStringCellValue().trim()) &&
-                                StringUtils.equals("", concentratorNameCell.getStringCellValue().trim()) &&
-                                StringUtils.equals("", customerNameCell.getStringCellValue()) &&
-                                StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
-                                StringUtils.equals("", locDescCell.getStringCellValue().trim())
-                        ) {
-                            continue;
-                        }
-
-                        if (StringUtils.equals("", collectorNameCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", concentratorNameCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-
-                        if (StringUtils.equals("", customerNameCell.getStringCellValue())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", buildingNameCell.getStringCellValue())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", locDescCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-
-                        Customer customer = customerService.findCacheByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
-                        if (customer == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Building building = buildingService.findCacheByName(record.getSiteId(),buildingNameCell.getStringCellValue().trim());
-                        if (building == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Concentrator concentrator = concentratorService.findCacheByName(record.getSiteId(),concentratorNameCell.getStringCellValue().trim());
-                        if (concentrator == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        //校验
-                        int result = collectorMapper.findByCollectorNoUnique(null, concentrator.getId(),collectorNameCell.getStringCellValue().trim());
-                        if (result > 0) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.COLLECTOR_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        //添加集中器
-                        Collector collector = new Collector();
-                        collector.setSiteId(record.getSiteId());
-                        collector.setCustomerId(customer.getId());
-                        collector.setBuildingId(building.getId());
-                        collector.setCollectorNo(collectorNameCell.getStringCellValue().trim());
-                        collector.setConcentratorId(concentrator.getId());
-                        //collector.setDeviceType();
-                        collector.setAddress(locDescCell.getStringCellValue().trim());
-                        collector.setStatus(1);
-                        //collector.setRemark();
-                        collector.setDateCreate(LocalDateTime.now());
-                        collector.setDateUpdate(LocalDateTime.now());
-                        collector.setCreateBy("system");
-                        collector.setUpdateBy("system");
-                        collectorMapper.insertSelective(collector);
-
-                        hssfSheet.removeRow(row);//成功删除该行
-
-                        successTime.incrementAndGet();
+        String executeSheetName = "表格模板";
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            invalidTemplate = true;
+            // 循环行Row
+            for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                if (row != null) {
+                    Cell collectorNameCell = row.getCell(0);
+                    Cell customerNameCell = row.getCell(1);
+                    Cell buildingNameCell = row.getCell(2);
+                    Cell locDescCell = row.getCell(3);
+                    Cell concentratorNameCell = row.getCell(4);
+                    Cell remarkCell = row.getCell(5);
+
+
+                    collectorNameCell.setCellType(CellType.STRING);
+                    locDescCell.setCellType(CellType.STRING);
+                    concentratorNameCell.setCellType(CellType.STRING);
+
+
+
+                    if (StringUtils.equals("", collectorNameCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", concentratorNameCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", customerNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", locDescCell.getStringCellValue().trim())
+                    ) {
+                        continue;
+                    }
+
+                    if (StringUtils.equals("", collectorNameCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", concentratorNameCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+
+                    if (StringUtils.equals("", customerNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", buildingNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", locDescCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+
+                    Customer customer = customerService.findCacheByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
+                    if (customer == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
+                        continue;
                     }
+
+                    Building building = buildingService.findCacheByName(record.getSiteId(),buildingNameCell.getStringCellValue().trim());
+                    if (building == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    Concentrator concentrator = concentratorService.findCacheByName(record.getSiteId(),concentratorNameCell.getStringCellValue().trim());
+                    if (concentrator == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    //校验
+                    int result = collectorMapper.findByCollectorNoUnique(null, concentrator.getId(),collectorNameCell.getStringCellValue().trim());
+                    if (result > 0) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.COLLECTOR_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    //添加集中器
+                    Collector collector = new Collector();
+                    collector.setSiteId(record.getSiteId());
+                    collector.setCustomerId(customer.getId());
+                    collector.setBuildingId(building.getId());
+                    collector.setCollectorNo(collectorNameCell.getStringCellValue().trim());
+                    collector.setConcentratorId(concentrator.getId());
+                    //collector.setDeviceType();
+                    collector.setAddress(locDescCell.getStringCellValue().trim());
+                    collector.setStatus(1);
+                    //collector.setRemark();
+                    collector.setDateCreate(LocalDateTime.now());
+                    collector.setDateUpdate(LocalDateTime.now());
+                    collector.setCreateBy("system");
+                    collector.setUpdateBy("system");
+                    collectorMapper.insertSelective(collector);
+
+                    hssfSheet.removeRow(row);//成功删除该行
+
+                    successTime.incrementAndGet();
                 }
-                //循环为空的行上移
-                if(failTime.get() > 0){
-                    for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            }
+            //循环为空的行上移
+            if(failTime.get() > 0){
+                for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
+            }
 
 
 
-                isDownload = true;
-            }
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+            isDownload = true;
         }
 
         log.info("end CollectorResolveExcelTemplate");

+ 142 - 150
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/ConcentratorResolveExcelTemplate.java

@@ -41,163 +41,155 @@ public class ConcentratorResolveExcelTemplate  extends AbstractResolverExcelTemp
     @Override
     protected void cycleExcel() {
         log.info("begin ConcentratorResolveExcelTemplate");
-        try {
-            String executeSheetName = "表格模板";
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                invalidTemplate = true;
-                // 循环行Row
-                for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    if (row != null) {
-                        Cell concentratorNameCell = row.getCell(0);
-                        Cell deviceTypeNameCell = row.getCell(1);
-                        Cell customerNameCell = row.getCell(2);
-                        Cell buildingNameCell = row.getCell(3);
-                        Cell locDescCell = row.getCell(4);
-                        Cell ipCell = row.getCell(5);
-                        Cell portCell = row.getCell(6);
-                        Cell baudRateCell = row.getCell(7);
-                        Cell simNoCell = row.getCell(8);
-                        Cell remarkCell = row.getCell(9);
-
-
-                        concentratorNameCell.setCellType(CellType.STRING);
-                        locDescCell.setCellType(CellType.STRING);
-                        ipCell.setCellType(CellType.STRING);
-                        portCell.setCellType(CellType.STRING);
-                        simNoCell.setCellType(CellType.STRING);
-
-
-                        if (StringUtils.equals("", concentratorNameCell.getStringCellValue().trim()) &&
-                                StringUtils.equals("", deviceTypeNameCell.getStringCellValue()) &&
-                                StringUtils.equals("", customerNameCell.getStringCellValue()) &&
-                                StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
-                                StringUtils.equals("", locDescCell.getStringCellValue().trim()) &&
-                                StringUtils.equals("", ipCell.getStringCellValue().trim()) &&
-                                StringUtils.equals("", baudRateCell.getStringCellValue().trim()) &&
-                                StringUtils.equals("", portCell.getStringCellValue().trim())
-                        ) {
-                            continue;
-                        }
-
-                        if (StringUtils.equals("", concentratorNameCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", customerNameCell.getStringCellValue())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", buildingNameCell.getStringCellValue())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", locDescCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", ipCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", baudRateCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-                        if (StringUtils.equals("", portCell.getStringCellValue().trim())) {
-                            failTime.incrementAndGet();
-                            continue;
-                        }
-
-                        String[] deviceType  = StringUtils.split(deviceTypeNameCell.getStringCellValue().trim(),"/");
-                        DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
-                        if(dt == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Customer customer = customerService.findCacheByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
-                        if (customer == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Building building = buildingService.findCacheByName(record.getSiteId(),buildingNameCell.getStringCellValue().trim());
-                        if (building == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        //校验
-                        int result = concentratorMapper.findBySerialNumberUnique(null,concentratorNameCell.getStringCellValue().trim());
-                        if (result > 0) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.CONCENTRATOR_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        //添加集中器
-                        Concentrator concentrator = new Concentrator();
-                        concentrator.setSiteId(record.getSiteId());
-                        concentrator.setCustomerId(customer.getId());
-                        concentrator.setSerialNumber(concentratorNameCell.getStringCellValue().trim());
-                        //concentrator.setName();
-                        //concentrator.setType();
-                        concentrator.setProvince(building.getProvince());
-                        concentrator.setCity(building.getCity());
-                        concentrator.setRegion(building.getRegion());
-                        concentrator.setBuildingId(building.getId());
-                        concentrator.setAddress(locDescCell.getStringCellValue().trim());
-                        concentrator.setDeviceStatus(0);
-                        concentrator.setDeviceType(dt.getId());
-                        concentrator.setBaudRate(getBaudRate(baudRateCell.getStringCellValue().trim()));
-                        concentrator.setIp(ipCell.getStringCellValue().trim());
-                        concentrator.setPort(Integer.valueOf(portCell.getStringCellValue().trim()));
-                        concentrator.setSimNo(simNoCell.getStringCellValue().trim());
-                        concentrator.setDateCreate(LocalDateTime.now());
-                        concentrator.setDateUpdate(LocalDateTime.now());
-                        concentrator.setCreateBy("system");
-                        concentrator.setUpdateBy("system");
-                        concentrator.setStatus(1);
-                        concentratorMapper.insertSelective(concentrator);
-
-                        hssfSheet.removeRow(row);//成功删除该行
-
-                        successTime.incrementAndGet();
+        String executeSheetName = "表格模板";
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            invalidTemplate = true;
+            // 循环行Row
+            for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                if (row != null) {
+                    Cell concentratorNameCell = row.getCell(0);
+                    Cell deviceTypeNameCell = row.getCell(1);
+                    Cell customerNameCell = row.getCell(2);
+                    Cell buildingNameCell = row.getCell(3);
+                    Cell locDescCell = row.getCell(4);
+                    Cell ipCell = row.getCell(5);
+                    Cell portCell = row.getCell(6);
+                    Cell baudRateCell = row.getCell(7);
+                    Cell simNoCell = row.getCell(8);
+                    Cell remarkCell = row.getCell(9);
+
+
+                    concentratorNameCell.setCellType(CellType.STRING);
+                    locDescCell.setCellType(CellType.STRING);
+                    ipCell.setCellType(CellType.STRING);
+                    portCell.setCellType(CellType.STRING);
+                    simNoCell.setCellType(CellType.STRING);
+
+
+                    if (StringUtils.equals("", concentratorNameCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", deviceTypeNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", customerNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", locDescCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", ipCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", baudRateCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", portCell.getStringCellValue().trim())
+                    ) {
+                        continue;
+                    }
+
+                    if (StringUtils.equals("", concentratorNameCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
                     }
+                    if (StringUtils.equals("", customerNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", buildingNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", locDescCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", ipCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", baudRateCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", portCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+
+                    String[] deviceType  = StringUtils.split(deviceTypeNameCell.getStringCellValue().trim(),"/");
+                    DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
+                    if(dt == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    Customer customer = customerService.findCacheByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
+                    if (customer == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    Building building = buildingService.findCacheByName(record.getSiteId(),buildingNameCell.getStringCellValue().trim());
+                    if (building == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    //校验
+                    int result = concentratorMapper.findBySerialNumberUnique(null,concentratorNameCell.getStringCellValue().trim());
+                    if (result > 0) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.CONCENTRATOR_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    //添加集中器
+                    Concentrator concentrator = new Concentrator();
+                    concentrator.setSiteId(record.getSiteId());
+                    concentrator.setCustomerId(customer.getId());
+                    concentrator.setSerialNumber(concentratorNameCell.getStringCellValue().trim());
+                    //concentrator.setName();
+                    //concentrator.setType();
+                    concentrator.setProvince(building.getProvince());
+                    concentrator.setCity(building.getCity());
+                    concentrator.setRegion(building.getRegion());
+                    concentrator.setBuildingId(building.getId());
+                    concentrator.setAddress(locDescCell.getStringCellValue().trim());
+                    concentrator.setDeviceStatus(0);
+                    concentrator.setDeviceType(dt.getId());
+                    concentrator.setBaudRate(getBaudRate(baudRateCell.getStringCellValue().trim()));
+                    concentrator.setIp(ipCell.getStringCellValue().trim());
+                    concentrator.setPort(Integer.valueOf(portCell.getStringCellValue().trim()));
+                    concentrator.setSimNo(simNoCell.getStringCellValue().trim());
+                    concentrator.setDateCreate(LocalDateTime.now());
+                    concentrator.setDateUpdate(LocalDateTime.now());
+                    concentrator.setCreateBy("system");
+                    concentrator.setUpdateBy("system");
+                    concentrator.setStatus(1);
+                    concentratorMapper.insertSelective(concentrator);
+
+                    hssfSheet.removeRow(row);//成功删除该行
+
+                    successTime.incrementAndGet();
                 }
-                //循环为空的行上移
-                if(failTime.get() > 0){
-                    for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            }
+            //循环为空的行上移
+            if(failTime.get() > 0){
+                for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
+            }
 
 
 
-                isDownload = true;
-            }
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+            isDownload = true;
         }
 
         log.info("end ConcentratorResolveExcelTemplate");

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

@@ -54,192 +54,204 @@ public class GdDeviceResolverExcelTemplate extends AbstractResolverExcelTemplate
     protected void cycleExcel() {
         log.info("begin GdDeviceResolverExcelTemplate");
         String executeSheetName = "表格模板";
-        try {
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                invalidTemplate = true;
-                // 循环行Row
-                for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    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);
-
-                        electronicNoCell.setCellType(CellType.STRING);
-                        fileNoCell.setCellType(CellType.STRING);
-                        locDescCell.setCellType(CellType.STRING);
-                        concentratorNameCell.setCellType(CellType.STRING);
-                        portCell.setCellType(CellType.STRING);
-
-
-                        if (StringUtils.equals("", electronicNoCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (deviceTypeNameCell == null || StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (customerNameCell == null || StringUtils.equals("", customerNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (buildingNameCell == null || StringUtils.equals("", buildingNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (locDescCell == null || StringUtils.equals("", locDescCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (concentratorNameCell == null || StringUtils.equals("", concentratorNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (channelNumberNameCell == null || StringUtils.equals("", channelNumberNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (portCell == null || StringUtils.equals("", portCell.getStringCellValue())) {
-                            continue;
-                        }
-
-
-                        String[] deviceType  = StringUtils.split(deviceTypeNameCell.getStringCellValue().trim(),"/");
-                        DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
-                        if(dt == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Customer customer = customerService.findCacheByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
-                        if (customer == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Building building = buildingService.findCacheByName(record.getSiteId(),buildingNameCell.getStringCellValue().trim());
-                        if (building == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-                        Concentrator concentrator = concentratorService.findCacheByName(record.getSiteId(),concentratorNameCell.getStringCellValue().trim());
-                        if (concentrator == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.CONCENTRATOR_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        Collector collector = null;
-                        if(!StringUtils.equals("", collectorNameCell.getStringCellValue())){
-                            collector = collectorService.findCacheByName(concentrator.getId(),collectorNameCell.getStringCellValue().trim());
-                        }
-
-
-                        ChannelNumber channelNumber = channelNumberService.findCacheByName(concentrator.getId(),channelNumberNameCell.getStringCellValue().trim());
-                        if (channelNumber == null) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.CHANNEL_NUMBER_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        int resultWaterMeterNo = deviceMapper.findByWaterMeterNoUnique(null, electronicNoCell.getStringCellValue().trim());
-                        if (resultWaterMeterNo > 0) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.DEVICE_ELECTRONIC_NO_NOT_EXISTED.getMessage());
-                            continue;
-                        }
-
-                        // 1、添加设备
-                        Device device = new Device();
-                        device.setId(idWorker.nextId());
-                        device.setSysId(sysId);
-                        device.setSiteId(record.getSiteId());
-                        device.setDeviceType(dt.getId());
-                        device.setCustomerId(customer.getId());
-                        device.setBuildingId(building.getId());
-                        device.setManufacturerId(dt.getManufacturerId());
-                        device.setWaterMeterNo(electronicNoCell.getStringCellValue().trim());
-                        device.setWaterMeterFileNo(StringUtils.equals("", fileNoCell.getStringCellValue())?null:fileNoCell.getStringCellValue().trim());
-                        device.setLocDesc(locDescCell.getStringCellValue().trim());
-                        device.setDeviceStatus(5);//未启用
-                        device.setStatus(1);
-                        device.setIsTag(0);
-                        device.setCreateBy("system");
-                        device.setDateCreate(LocalDateTime.now());
-                        device.setUpdateBy("system");
-                        device.setDateUpdate(LocalDateTime.now());
-                        deviceMapper.insertSelective(device);
-
-                        //2、同步集中器关系
-                        WaterRelatedDevice waterRelatedDevice = new WaterRelatedDevice();
-                        waterRelatedDevice.setDeviceId(device.getId());
-                        waterRelatedDevice.setConcentratorId(concentrator.getId());
-                        waterRelatedDevice.setCollectorId(collector!=null?collector.getId():null);
-                        waterRelatedDevice.setChannelNumberId(channelNumber.getId());
-                        waterRelatedDevice.setPort(portCell.getStringCellValue().trim());
-                        waterRelatedDevice.setIssueStatus(0);
-                        waterRelatedDevice.setStatus(1);
-                        waterRelatedDevice.setDateCreate(LocalDateTime.now());
-                        waterRelatedDevice.setDateUpdate(LocalDateTime.now());
-                        waterRelatedDevice.setCreateBy("system");
-                        waterRelatedDevice.setUpdateBy("system");
-                        waterRelatedDeviceMapper.insertSelective(waterRelatedDevice);
-
-                        //3、同步设备维度关系
-                        //Building building = buildingMapper.getBuilding(device.getBuildingId());
-                        DeviceDimension deviceDimension = new DeviceDimension();
-                        deviceDimension.setDeviceId(device.getId());
-                        deviceDimension.setProvince(String.valueOf(building.getProvince()));
-                        deviceDimension.setCity(String.valueOf(building.getCity()));
-                        deviceDimension.setRegion(String.valueOf(building.getRegion()));
-                        deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
-                        deviceDimension.setBuilding(String.valueOf(building.getId()));
-                        deviceDimension.setFloor(String.valueOf(device.getFloor()));
-                        deviceDimension.setDevice(device.getDeviceNo());
-                        deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
-                        deviceDimension.setStatus(1);
-                        deviceDimension.setCreateBy("system");
-                        deviceDimension.setUpdateBy("system");
-                        deviceDimension.setDateCreate(LocalDateTime.now());
-                        deviceDimension.setDateUpdate(LocalDateTime.now());
-
-                        deviceDimensionMapper.insertSelective(deviceDimension);
-
-                        hssfSheet.removeRow(row);//成功删除该行
-
-                        successTime.incrementAndGet();
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            invalidTemplate = true;
+            // 循环行Row
+            for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                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);
+
+                    electronicNoCell.setCellType(CellType.STRING);
+                    fileNoCell.setCellType(CellType.STRING);
+                    locDescCell.setCellType(CellType.STRING);
+                    concentratorNameCell.setCellType(CellType.STRING);
+                    portCell.setCellType(CellType.STRING);
+
+
+                    if (StringUtils.equals("", electronicNoCell.getStringCellValue()) &&
+                            StringUtils.equals("", deviceTypeNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", customerNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", locDescCell.getStringCellValue()) &&
+                            StringUtils.equals("", concentratorNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", channelNumberNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", portCell.getStringCellValue())
+                    ) {
+                        continue;
+                    }
+
+                    if (StringUtils.equals("", electronicNoCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", customerNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", buildingNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", locDescCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", concentratorNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", channelNumberNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", portCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+
+
+                    String[] deviceType  = StringUtils.split(deviceTypeNameCell.getStringCellValue().trim(),"/");
+                    DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
+                    if(dt == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    Customer customer = customerService.findCacheByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
+                    if (customer == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
+                        continue;
                     }
+
+                    Building building = buildingService.findCacheByName(record.getSiteId(),buildingNameCell.getStringCellValue().trim());
+                    if (building == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+                    Concentrator concentrator = concentratorService.findCacheByName(record.getSiteId(),concentratorNameCell.getStringCellValue().trim());
+                    if (concentrator == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.CONCENTRATOR_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    Collector collector = null;
+                    if(!StringUtils.equals("", collectorNameCell.getStringCellValue())){
+                        collector = collectorService.findCacheByName(concentrator.getId(),collectorNameCell.getStringCellValue().trim());
+                    }
+
+
+                    ChannelNumber channelNumber = channelNumberService.findCacheByName(concentrator.getId(),channelNumberNameCell.getStringCellValue().trim());
+                    if (channelNumber == null) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.CHANNEL_NUMBER_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    int resultWaterMeterNo = deviceMapper.findByWaterMeterNoUnique(null, electronicNoCell.getStringCellValue().trim());
+                    if (resultWaterMeterNo > 0) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.DEVICE_ELECTRONIC_NO_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+                    // 1、添加设备
+                    Device device = new Device();
+                    device.setId(idWorker.nextId());
+                    device.setSysId(sysId);
+                    device.setSiteId(record.getSiteId());
+                    device.setDeviceType(dt.getId());
+                    device.setCustomerId(customer.getId());
+                    device.setBuildingId(building.getId());
+                    device.setManufacturerId(dt.getManufacturerId());
+                    device.setWaterMeterNo(electronicNoCell.getStringCellValue().trim());
+                    device.setWaterMeterFileNo(StringUtils.equals("", fileNoCell.getStringCellValue())?null:fileNoCell.getStringCellValue().trim());
+                    device.setLocDesc(locDescCell.getStringCellValue().trim());
+                    device.setDeviceStatus(5);//未启用
+                    device.setStatus(1);
+                    device.setIsTag(0);
+                    device.setCreateBy("system");
+                    device.setDateCreate(LocalDateTime.now());
+                    device.setUpdateBy("system");
+                    device.setDateUpdate(LocalDateTime.now());
+                    deviceMapper.insertSelective(device);
+
+                    //2、同步集中器关系
+                    WaterRelatedDevice waterRelatedDevice = new WaterRelatedDevice();
+                    waterRelatedDevice.setDeviceId(device.getId());
+                    waterRelatedDevice.setConcentratorId(concentrator.getId());
+                    waterRelatedDevice.setCollectorId(collector!=null?collector.getId():null);
+                    waterRelatedDevice.setChannelNumberId(channelNumber.getId());
+                    waterRelatedDevice.setPort(portCell.getStringCellValue().trim());
+                    waterRelatedDevice.setIssueStatus(0);
+                    waterRelatedDevice.setStatus(1);
+                    waterRelatedDevice.setDateCreate(LocalDateTime.now());
+                    waterRelatedDevice.setDateUpdate(LocalDateTime.now());
+                    waterRelatedDevice.setCreateBy("system");
+                    waterRelatedDevice.setUpdateBy("system");
+                    waterRelatedDeviceMapper.insertSelective(waterRelatedDevice);
+
+                    //3、同步设备维度关系
+                    //Building building = buildingMapper.getBuilding(device.getBuildingId());
+                    DeviceDimension deviceDimension = new DeviceDimension();
+                    deviceDimension.setDeviceId(device.getId());
+                    deviceDimension.setProvince(String.valueOf(building.getProvince()));
+                    deviceDimension.setCity(String.valueOf(building.getCity()));
+                    deviceDimension.setRegion(String.valueOf(building.getRegion()));
+                    deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
+                    deviceDimension.setBuilding(String.valueOf(building.getId()));
+                    deviceDimension.setFloor(String.valueOf(device.getFloor()));
+                    deviceDimension.setDevice(device.getDeviceNo());
+                    deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
+                    deviceDimension.setStatus(1);
+                    deviceDimension.setCreateBy("system");
+                    deviceDimension.setUpdateBy("system");
+                    deviceDimension.setDateCreate(LocalDateTime.now());
+                    deviceDimension.setDateUpdate(LocalDateTime.now());
+
+                    deviceDimensionMapper.insertSelective(deviceDimension);
+
+                    hssfSheet.removeRow(row);//成功删除该行
+
+                    successTime.incrementAndGet();
                 }
-                //循环为空的行上移
-                if(failTime.get() > 0){
-                    for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            }
+            //循环为空的行上移
+            if(failTime.get() > 0){
+                for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
+            }
 
 
 
-                isDownload = true;
-            }
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+            isDownload = true;
         }
 
         log.info("end GdDeviceResolverExcelTemplate");

+ 103 - 111
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/GeneralDeviceResolverExcelTemplate.java

@@ -39,130 +39,122 @@ public class GeneralDeviceResolverExcelTemplate extends AbstractResolverExcelTem
     protected void cycleExcel() {
         log.info("begin GeneralDeviceResolverExcelTemplate");
         String executeSheetName = "表格模板";
-        try {
-            FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                invalidTemplate = true;
-                // 循环行Row
-                for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    if (row != null) {
-                        Cell buildingNameCell = row.getCell(0);
-                        Cell buildingIdCell = row.getCell(1);
-                        Cell deviceTypeNameCell = row.getCell(2);
-                        Cell deviceTypeIdCell = row.getCell(3);
-                        Cell deviceNoCell = row.getCell(4);
-                        Cell floorCell = row.getCell(5);
-                        Cell locDescCell = row.getCell(6, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
-                        Cell remarkCell = row.getCell(7);
+        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            invalidTemplate = true;
+            // 循环行Row
+            for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                if (row != null) {
+                    Cell buildingNameCell = row.getCell(0);
+                    Cell buildingIdCell = row.getCell(1);
+                    Cell deviceTypeNameCell = row.getCell(2);
+                    Cell deviceTypeIdCell = row.getCell(3);
+                    Cell deviceNoCell = row.getCell(4);
+                    Cell floorCell = row.getCell(5);
+                    Cell locDescCell = row.getCell(6, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
+                    Cell remarkCell = row.getCell(7);
 
-                        if (buildingNameCell == null || StringUtils.equals("", buildingNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (buildingIdCell == null) {
-                            continue;
-                        }
-                        if (deviceNoCell == null || StringUtils.equals("", deviceNoCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (deviceTypeNameCell == null || StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (deviceTypeIdCell == null) {
-                            continue;
-                        }
-                        if (floorCell == null) {
-                            continue;
-                        }
-                        Device device = new Device();
-                        device.setId(idWorker.nextId());
-                        device.setSysId(sysId);
-                        device.setSiteId(record.getSiteId());
-                        CellValue cellValuesetBuildingId = evaluator.evaluate(buildingIdCell);
-                        device.setBuildingId((int) cellValuesetBuildingId.getNumberValue());
-                        CellValue cellValueDeviceTypeId = evaluator.evaluate(deviceTypeIdCell);
-                        device.setDeviceType((int) cellValueDeviceTypeId.getNumberValue());
-                        String deviceNo = StringUtils.lowerCase(deviceNoCell.getStringCellValue().trim());
-                        int deviceNoResult = deviceMapper.findByDeviceNoUnique(null, deviceNo);
-                        if (deviceNoResult > 0) {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue("设备编号已存在");
-                            continue;
-                        }
-                        device.setDeviceNo(deviceNo);
-                        floorCell.setCellType(CellType.NUMERIC);
-                        device.setFloor((int) floorCell.getNumericCellValue());
-                        if (locDescCell != null) {
-                            if (locDescCell.getCellTypeEnum() == CellType.NUMERIC) {
-                                device.setLocDesc(String.format("%.0f", locDescCell.getNumericCellValue()));
-                            } else if (locDescCell.getCellTypeEnum() == CellType.STRING) {
-                                device.setLocDesc(locDescCell.getStringCellValue().trim());
-                            }
+                    if (buildingNameCell == null || StringUtils.equals("", buildingNameCell.getStringCellValue())) {
+                        continue;
+                    }
+                    if (buildingIdCell == null) {
+                        continue;
+                    }
+                    if (deviceNoCell == null || StringUtils.equals("", deviceNoCell.getStringCellValue())) {
+                        continue;
+                    }
+                    if (deviceTypeNameCell == null || StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
+                        continue;
+                    }
+                    if (deviceTypeIdCell == null) {
+                        continue;
+                    }
+                    if (floorCell == null) {
+                        continue;
+                    }
+                    Device device = new Device();
+                    device.setId(idWorker.nextId());
+                    device.setSysId(sysId);
+                    device.setSiteId(record.getSiteId());
+                    CellValue cellValuesetBuildingId = evaluator.evaluate(buildingIdCell);
+                    device.setBuildingId((int) cellValuesetBuildingId.getNumberValue());
+                    CellValue cellValueDeviceTypeId = evaluator.evaluate(deviceTypeIdCell);
+                    device.setDeviceType((int) cellValueDeviceTypeId.getNumberValue());
+                    String deviceNo = StringUtils.lowerCase(deviceNoCell.getStringCellValue().trim());
+                    int deviceNoResult = deviceMapper.findByDeviceNoUnique(null, deviceNo);
+                    if (deviceNoResult > 0) {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue("设备编号已存在");
+                        continue;
+                    }
+                    device.setDeviceNo(deviceNo);
+                    floorCell.setCellType(CellType.NUMERIC);
+                    device.setFloor((int) floorCell.getNumericCellValue());
+                    if (locDescCell != null) {
+                        if (locDescCell.getCellTypeEnum() == CellType.NUMERIC) {
+                            device.setLocDesc(String.format("%.0f", locDescCell.getNumericCellValue()));
+                        } else if (locDescCell.getCellTypeEnum() == CellType.STRING) {
+                            device.setLocDesc(locDescCell.getStringCellValue().trim());
                         }
-                        DeviceType deviceType = deviceTypeMapper.findByid(device.getDeviceType());
-                        device.setManufacturerId(deviceType.getManufacturerId());
-                        device.setDeviceStatus(5);//未启用
-                        device.setStatus(1);
-                        device.setXCoordinates(device.getXCoordinates());
-                        device.setYCoordinates(device.getYCoordinates());
-                        device.setIsTag(device.getXCoordinates() != null && device.getYCoordinates() != null ? 1 : 0);
-                        device.setCreateBy("system");
-                        device.setDateCreate(LocalDateTime.now());
-                        device.setUpdateBy("system");
-                        device.setDateUpdate(LocalDateTime.now());
+                    }
+                    DeviceType deviceType = deviceTypeMapper.findByid(device.getDeviceType());
+                    device.setManufacturerId(deviceType.getManufacturerId());
+                    device.setDeviceStatus(5);//未启用
+                    device.setStatus(1);
+                    device.setXCoordinates(device.getXCoordinates());
+                    device.setYCoordinates(device.getYCoordinates());
+                    device.setIsTag(device.getXCoordinates() != null && device.getYCoordinates() != null ? 1 : 0);
+                    device.setCreateBy("system");
+                    device.setDateCreate(LocalDateTime.now());
+                    device.setUpdateBy("system");
+                    device.setDateUpdate(LocalDateTime.now());
 
-                        deviceMapper.insertSelective(device);
+                    deviceMapper.insertSelective(device);
 
-                        //2、同步设备维度关系
-                        Building building = buildingMapper.getBuilding(device.getBuildingId());
-                        DeviceDimension deviceDimension = new DeviceDimension();
-                        deviceDimension.setDeviceId(device.getId());
-                        deviceDimension.setProvince(String.valueOf(building.getProvince()));
-                        deviceDimension.setCity(String.valueOf(building.getCity()));
-                        deviceDimension.setRegion(String.valueOf(building.getRegion()));
-                        deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
-                        deviceDimension.setBuilding(String.valueOf(building.getId()));
-                        deviceDimension.setFloor(String.valueOf(device.getFloor()));
-                        deviceDimension.setDevice(device.getDeviceNo());
-                        deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
-                        deviceDimension.setStatus(1);
-                        deviceDimension.setCreateBy("system");
-                        deviceDimension.setUpdateBy("system");
-                        deviceDimension.setDateCreate(LocalDateTime.now());
-                        deviceDimension.setDateUpdate(LocalDateTime.now());
+                    //2、同步设备维度关系
+                    Building building = buildingMapper.getBuilding(device.getBuildingId());
+                    DeviceDimension deviceDimension = new DeviceDimension();
+                    deviceDimension.setDeviceId(device.getId());
+                    deviceDimension.setProvince(String.valueOf(building.getProvince()));
+                    deviceDimension.setCity(String.valueOf(building.getCity()));
+                    deviceDimension.setRegion(String.valueOf(building.getRegion()));
+                    deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
+                    deviceDimension.setBuilding(String.valueOf(building.getId()));
+                    deviceDimension.setFloor(String.valueOf(device.getFloor()));
+                    deviceDimension.setDevice(device.getDeviceNo());
+                    deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
+                    deviceDimension.setStatus(1);
+                    deviceDimension.setCreateBy("system");
+                    deviceDimension.setUpdateBy("system");
+                    deviceDimension.setDateCreate(LocalDateTime.now());
+                    deviceDimension.setDateUpdate(LocalDateTime.now());
 
-                        deviceDimensionMapper.insertSelective(deviceDimension);
+                    deviceDimensionMapper.insertSelective(deviceDimension);
 
-                        hssfSheet.removeRow(row);//成功删除该行
+                    hssfSheet.removeRow(row);//成功删除该行
 
-                        successTime.incrementAndGet();
-                    }
+                    successTime.incrementAndGet();
                 }
-                //循环为空的行上移
-                if(failTime.get() > 0){
-                    for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            }
+            //循环为空的行上移
+            if(failTime.get() > 0){
+                for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
+            }
 
 
 
-                isDownload = true;
-            }
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+            isDownload = true;
         }
 
         log.info("end GeneralDeviceResolverExcelTemplate");

+ 204 - 189
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/InstallResolverExcelTemplate.java

@@ -49,222 +49,237 @@ public class InstallResolverExcelTemplate extends AbstractResolverExcelTemplate
         InstallListDTO dto = new InstallListDTO();
         dto.setSiteId(record.getSiteId());
         dto.setInstallTime(LocalDateTime.now());
-        try {
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null) {
-                    continue;
-                }
-                if (!StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                invalidTemplate = true;
-                // 1,处理表头,解析客户、户数
-                Row customerRow = hssfSheet.getRow(1); // 客户Id行
-                Cell customerNameCell =  customerRow.getCell(5);
-                customerNameCell.setCellType(CellType.STRING);
-                if(StringUtils.equals("", customerNameCell.getStringCellValue().trim())) {
-                    messageContent.append("导入失败,");
-                    messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
-                    continue;
-                }
-                Customer customer = customerMapper.findByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
-                if(customer!=null){
-                    dto.setCustomerId(customer.getId());
-
-                }else {
-                    messageContent.append("导入失败,");
-                    messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
-                    continue;
-                }
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null) {
+                continue;
+            }
+            if (!StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            invalidTemplate = true;
+            // 1,处理表头,解析客户、户数
+            Row customerRow = hssfSheet.getRow(1); // 客户Id行
+            Cell customerNameCell =  customerRow.getCell(5);
+            customerNameCell.setCellType(CellType.STRING);
+            if(StringUtils.equals("", customerNameCell.getStringCellValue().trim())) {
+                messageContent.append("导入失败,");
+                messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
+                continue;
+            }
+            Customer customer = customerMapper.findByName(record.getSiteId(),customerNameCell.getStringCellValue().trim());
+            if(customer!=null){
+                dto.setCustomerId(customer.getId());
+
+            }else {
+                messageContent.append("导入失败,");
+                messageContent.append(ResultStatus.CUSTOMER_IS_NOT_EXISTED.getMessage());
+                continue;
+            }
 
 
-                Row numberRow = hssfSheet.getRow(2); // 安装数字,只处理指定安装户数的数据
-                Cell numberCell = numberRow.getCell(5);
+            Row numberRow = hssfSheet.getRow(2); // 安装数字,只处理指定安装户数的数据
+            Cell numberCell = numberRow.getCell(5);
 
-                numberCell.setCellType(CellType.NUMERIC);
-                int number = ((Double)numberCell.getNumericCellValue()).intValue();
-                if(number < 0 || number > 5000) {
-                    messageContent.append("导入失败,");
-                    messageContent.append(ResultStatus.NUMBER_IS_OUT_RANGE.getMessage());
-                    continue;
-                }
+            numberCell.setCellType(CellType.NUMERIC);
+            int number = ((Double)numberCell.getNumericCellValue()).intValue();
+            if(number < 0 || number > 5000) {
+                messageContent.append("导入失败,");
+                messageContent.append(ResultStatus.NUMBER_IS_OUT_RANGE.getMessage());
+                continue;
+            }
 
-                // 2,处理明细行数据
-                for (int rowNum = 8; rowNum < 8+number ; rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    if (row != null) {
-
-                        Cell idCell = row.getCell(1) ; // 编号
-                        Cell communityCell = row.getCell(2);
-                        Cell buildingCell = row.getCell(3);
-                        Cell doorNoCell = row.getCell(4);
-                        Cell deviceTypeCell = row.getCell(5);
-                        Cell electronicNoCell = row.getCell(6);
-                        Cell deviceNoCell = row.getCell(7);
-                        Cell fileNoCell = row.getCell(8);
-                        Cell newMeterStartCell = row.getCell(9);
-                        Cell oldMeterEndCell = row.getCell(10);
-                        Cell userNameCell = row.getCell(11);
-                        Cell userPhoneCell = row.getCell(12);
-                        Cell idCardCell = row.getCell(13);
-                        Cell remarkCell = row.getCell(14);
-
-
-                        if(idCell !=null){
-                            Double idVal = idCell.getNumericCellValue();
-                            dto.setId(idVal.intValue());
-                        }
+            // 2,处理明细行数据
+            for (int rowNum = 8; rowNum < 8+number ; rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                if (row != null) {
+
+                    Cell idCell = row.getCell(1) ; // 编号
+                    Cell communityCell = row.getCell(2);
+                    Cell buildingCell = row.getCell(3);
+                    Cell doorNoCell = row.getCell(4);
+                    Cell deviceTypeCell = row.getCell(5);
+                    Cell electronicNoCell = row.getCell(6);
+                    Cell deviceNoCell = row.getCell(7);
+                    Cell fileNoCell = row.getCell(8);
+                    Cell newMeterStartCell = row.getCell(9);
+                    Cell oldMeterEndCell = row.getCell(10);
+                    Cell userNameCell = row.getCell(11);
+                    Cell userPhoneCell = row.getCell(12);
+                    Cell idCardCell = row.getCell(13);
+                    Cell remarkCell = row.getCell(14);
+
+
+                    if(idCell !=null){
+                        Double idVal = idCell.getNumericCellValue();
+                        dto.setId(idVal.intValue());
+                    }
 
-                        communityCell.setCellType(CellType.STRING);
-                        if (StringUtils.equals("", communityCell.getStringCellValue().trim())) {
-                            continue;
-                        }
-                        Community community = communityService.findCacheByName(record.getSiteId(),communityCell.getStringCellValue().trim());
-                        if (community != null) {
-                            dto.setCommunityId(community.getId());
-                        }else {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.COMMUNITY_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
+                    communityCell.setCellType(CellType.STRING);
+                    buildingCell.setCellType(CellType.STRING);
+                    doorNoCell.setCellType(CellType.STRING);
+                    deviceTypeCell.setCellType(CellType.STRING);
+                    electronicNoCell.setCellType(CellType.STRING);
+                    deviceNoCell.setCellType(CellType.STRING);
+                    newMeterStartCell.setCellType(CellType.STRING);
+
+                    if (StringUtils.equals("", communityCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", buildingCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", doorNoCell.getStringCellValue()) &&
+                            StringUtils.equals("", deviceTypeCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", electronicNoCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", deviceNoCell.getStringCellValue().trim()) &&
+                            StringUtils.equals("", newMeterStartCell.getStringCellValue().trim())
+                    ) {
+                        continue;
+                    }
 
 
-                        buildingCell.setCellType(CellType.STRING);
-                        if (StringUtils.equals("", buildingCell.getStringCellValue().trim())) {
-                            continue;
-                        }
-                        Building building = buildingService.findCacheByName(record.getSiteId(),buildingCell.getStringCellValue().trim());
-                        if (building != null) {
-                            dto.setBuildingId(building.getId());
-                        }else {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
-                            continue;
-                        }
+                    if (StringUtils.equals("", communityCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    Community community = communityService.findCacheByName(record.getSiteId(),communityCell.getStringCellValue().trim());
+                    if (community != null) {
+                        dto.setCommunityId(community.getId());
+                    }else {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.COMMUNITY_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
 
 
-                        doorNoCell.setCellType(CellType.STRING);
-                        if (!StringUtils.equals("", doorNoCell.getStringCellValue())) {
-                            String doorNo = doorNoCell.getStringCellValue().trim();
-                            dto.setDoorNo(doorNo);
-                            dto.setLocation(doorNo);
-                        }else {
-                            continue;
-                        }
 
+                    if (StringUtils.equals("", buildingCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    Building building = buildingService.findCacheByName(record.getSiteId(),buildingCell.getStringCellValue().trim());
+                    if (building != null) {
+                        dto.setBuildingId(building.getId());
+                    }else {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.BUILDING_IS_NOT_EXISTED.getMessage());
+                        continue;
+                    }
 
-                        deviceTypeCell.setCellType(CellType.STRING);
-                        if (StringUtils.equals("", deviceTypeCell.getStringCellValue().trim())) {
-                            continue;
-                        }
-                        String[] deviceType  = StringUtils.split(deviceTypeCell.getStringCellValue().trim(),"/");
-                        DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
-                        if(dt != null) {
-                            dto.setDeviceTypeId(dt.getId());
-                            dto.setFactoryId(dt.getManufacturerId());
-                        }else {
-                            failTime.incrementAndGet();
-                            remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
-                            continue;
-                        }
 
 
-                        electronicNoCell.setCellType(CellType.STRING);
-                        String electronicNo = electronicNoCell.getStringCellValue().trim();
-                        if(StringUtils.isBlank(electronicNo)) {
-                            continue;
-                        }
-                        dto.setElectronicNo(electronicNo);
+                    if (!StringUtils.equals("", doorNoCell.getStringCellValue())) {
+                        String doorNo = doorNoCell.getStringCellValue().trim();
+                        dto.setDoorNo(doorNo);
+                        dto.setLocation(doorNo);
+                    }else {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
 
-                        deviceNoCell.setCellType(CellType.STRING);
-                        String deviceNo = deviceNoCell.getStringCellValue().trim();
-                        if(StringUtils.isBlank(deviceNo)) {
-                            continue;
-                        }
-                        dto.setDeviceNo(deviceNo);
-
-                        if(fileNoCell != null){
-                            fileNoCell.setCellType(CellType.STRING);
-                            String fileNo = fileNoCell.getStringCellValue().trim();
-                            if(!StringUtils.equals("",fileNo)) {
-                                dto.setFileNo(fileNo);
-                            }
+
+
+                    if (StringUtils.equals("", deviceTypeCell.getStringCellValue().trim())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    String[] deviceType  = StringUtils.split(deviceTypeCell.getStringCellValue().trim(),"/");
+                    DeviceTypeDto dt = deviceTypeService.getByName(deviceType[1],deviceType[2]);
+                    if(dt != null) {
+                        dto.setDeviceTypeId(dt.getId());
+                        dto.setFactoryId(dt.getManufacturerId());
+                    }else {
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue(ResultStatus.DEVICE_TYPE_NOT_EXISTED.getMessage());
+                        continue;
+                    }
+
+
+
+                    String electronicNo = electronicNoCell.getStringCellValue().trim();
+                    if(StringUtils.isBlank(electronicNo)) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    dto.setElectronicNo(electronicNo);
+
+
+                    String deviceNo = deviceNoCell.getStringCellValue().trim();
+                    if(StringUtils.isBlank(deviceNo)) {
+                        continue;
+                    }
+                    dto.setDeviceNo(deviceNo);
+
+                    if(fileNoCell != null){
+                        fileNoCell.setCellType(CellType.STRING);
+                        String fileNo = fileNoCell.getStringCellValue().trim();
+                        if(!StringUtils.equals("",fileNo)) {
+                            dto.setFileNo(fileNo);
                         }
+                    }
+
+                    String newMeterStart = newMeterStartCell.getStringCellValue().trim();
+                    if(StringUtils.isBlank(newMeterStart)) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    dto.setNewMeterStart(newMeterStart);
 
+                    oldMeterEndCell.setCellType(CellType.STRING);
+                    String oldMeterEnd  = oldMeterEndCell.getStringCellValue().trim();
+                    dto.setOldMeterEnd(oldMeterEnd);
 
-                        newMeterStartCell.setCellType(CellType.STRING);
-                        String newMeterStart = newMeterStartCell.getStringCellValue().trim();
-                        if(StringUtils.isBlank(newMeterStart)) {
-                            continue;
+                    userNameCell.setCellType(CellType.STRING);
+                    String userName = userNameCell.getStringCellValue().trim();
+                    dto.setUserName(userName);
+
+                    userPhoneCell.setCellType(CellType.STRING);
+                    String userPhone = userPhoneCell.getStringCellValue().trim();
+                    dto.setUserPhone(userPhone);
+
+                    //身份证号
+                    idCardCell.setCellType(CellType.STRING);
+                    String idCard = idCardCell.getStringCellValue().trim();
+                    dto.setIdCard(idCard);
+
+
+                    dto.setChannelId(-99);
+
+                    try {
+                        //保存安装信息
+                        boolean isOk = installManagerService.saveInstallInfo(dto);
+                        if(isOk) {
+                            hssfSheet.removeRow(row);//成功删除该行
+                            successTime.incrementAndGet();
+                        }else {
+                            failTime.incrementAndGet();
+                            remarkCell.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
                         }
-                        dto.setNewMeterStart(newMeterStart);
-
-                        oldMeterEndCell.setCellType(CellType.STRING);
-                        String oldMeterEnd  = oldMeterEndCell.getStringCellValue().trim();
-                        dto.setOldMeterEnd(oldMeterEnd);
-
-                        userNameCell.setCellType(CellType.STRING);
-                        String userName = userNameCell.getStringCellValue().trim();
-                        dto.setUserName(userName);
-
-                        userPhoneCell.setCellType(CellType.STRING);
-                        String userPhone = userPhoneCell.getStringCellValue().trim();
-                        dto.setUserPhone(userPhone);
-
-                        //身份证号
-                        idCardCell.setCellType(CellType.STRING);
-                        String idCard = idCardCell.getStringCellValue().trim();
-                        dto.setIdCard(idCard);
-
-
-                        dto.setChannelId(-99);
-
-                        try {
-                            //保存安装信息
-                            boolean isOk = installManagerService.saveInstallInfo(dto);
-                            if(isOk) {
-                                hssfSheet.removeRow(row);//成功删除该行
-                                successTime.incrementAndGet();
-                            }else {
-                                failTime.incrementAndGet();
-                                remarkCell.setCellValue(ResultStatus.DELETE_AND_DOOR_EXISTED.getMessage());
-                            }
-                        } catch (ServiceException e){
-                            if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
-                                failTime.incrementAndGet();
-                                remarkCell.setCellValue(e.getMessage());
-                            }else {
-                                failTime.incrementAndGet();
-                            }
-                        }catch (Exception e){
+                    } catch (ServiceException e){
+                        if(e.getStatus() == ResultStatus.DEVICE_NO_IS_EXISTED.getStatus()){
+                            failTime.incrementAndGet();
+                            remarkCell.setCellValue(e.getMessage());
+                        }else {
                             failTime.incrementAndGet();
-                            remarkCell.setCellValue("导入异常");
                         }
+                    }catch (Exception e){
+                        failTime.incrementAndGet();
+                        remarkCell.setCellValue("导入异常");
                     }
+                }
 
 
-                }
+            }
 
-                //循环为空的行上移
-                if(failTime.get() > 0){
-                    for (int rowNum = 8+number-1; rowNum >= 8 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            //循环为空的行上移
+            if(failTime.get() > 0){
+                for (int rowNum = 8+number-1; rowNum >= 8 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
-
-                isDownload = true;
             }
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+
+            isDownload = true;
         }
         log.info("end InstallResolverExcelTemplate");
     }

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

@@ -44,172 +44,180 @@ public class WaterDeviceResolverExcelTemplate extends AbstractResolverExcelTempl
     protected void cycleExcel() {
         log.info("begin WaterDeviceResolverExcelTemplate");
         String executeSheetName = "表格模板";
-        try {
-            FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
-            // 循环工作表Sheet
-            for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
-                Sheet hssfSheet = workbook.getSheetAt(numSheet);
-                if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
-                    continue;
-                }
-                invalidTemplate = true;
-                // 循环行Row
-                for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
-                    Row row = hssfSheet.getRow(rowNum);
-                    if (row != null) {
-                        Cell buildingNameCell = row.getCell(0);
-                        Cell buildingIdCell = row.getCell(1);
-                        Cell deviceNoCell = row.getCell(2);
-                        Cell waterMeterNoCell = row.getCell(3, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
-                        Cell waterMeterFileNoCell = row.getCell(4, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
-                        Cell deviceTypeNameCell = row.getCell(5);
-                        Cell deviceTypeIdCell = row.getCell(6);
-                        Cell customerNameCell = row.getCell(7, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
-                        Cell customerIdCell = row.getCell(8, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
-                        Cell locDescCell = row.getCell(9);
-                        Cell floorCell = row.getCell(10, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
-                        Cell c_remark = row.getCell(11);
-                        if (buildingNameCell == null || StringUtils.equals("", buildingNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (buildingIdCell == null) {
-                            continue;
-                        }
-                        if (deviceNoCell == null || StringUtils.equals("", deviceNoCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (deviceTypeNameCell == null || StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
-                            continue;
-                        }
-                        if (deviceTypeIdCell == null) {
-                            continue;
-                        }
-                        if (locDescCell == null) {
-                            continue;
-                        }
-                        Device device = new Device();
-                        device.setId(idWorker.nextId());
-                        device.setSysId(sysId);
-                        device.setSiteId(record.getSiteId());
-                        CellValue cellValuesetBuildingId = evaluator.evaluate(buildingIdCell);
-                        device.setBuildingId((int) cellValuesetBuildingId.getNumberValue());
-                        CellValue cellValueDeviceTypeId = evaluator.evaluate(deviceTypeIdCell);
-                        device.setDeviceType((int) cellValueDeviceTypeId.getNumberValue());
-                        String deviceNo = StringUtils.lowerCase(deviceNoCell.getStringCellValue().trim());
-                        int deviceNoResult = deviceMapper.findByDeviceNoUnique(null, deviceNo);
-                        if (deviceNoResult > 0) {
+        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+        // 循环工作表Sheet
+        for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
+            Sheet hssfSheet = workbook.getSheetAt(numSheet);
+            if (hssfSheet == null || !StringUtils.equals(executeSheetName, hssfSheet.getSheetName())) {
+                continue;
+            }
+            invalidTemplate = true;
+            // 循环行Row
+            for (int rowNum = 4; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
+                Row row = hssfSheet.getRow(rowNum);
+                if (row != null) {
+                    Cell buildingNameCell = row.getCell(0);
+                    Cell buildingIdCell = row.getCell(1);
+                    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);
+
+                    if (StringUtils.equals("", buildingNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", deviceNoCell.getStringCellValue()) &&
+                            StringUtils.equals("", deviceTypeNameCell.getStringCellValue()) &&
+                            StringUtils.equals("", locDescCell.getStringCellValue())
+                    ) {
+                        continue;
+                    }
+
+
+                    if (StringUtils.equals("", buildingNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (buildingIdCell == null) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", deviceNoCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", deviceTypeNameCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (deviceTypeIdCell == null) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    if (StringUtils.equals("", locDescCell.getStringCellValue())) {
+                        failTime.incrementAndGet();
+                        continue;
+                    }
+                    Device device = new Device();
+                    device.setId(idWorker.nextId());
+                    device.setSysId(sysId);
+                    device.setSiteId(record.getSiteId());
+                    CellValue cellValuesetBuildingId = evaluator.evaluate(buildingIdCell);
+                    device.setBuildingId((int) cellValuesetBuildingId.getNumberValue());
+                    CellValue cellValueDeviceTypeId = evaluator.evaluate(deviceTypeIdCell);
+                    device.setDeviceType((int) cellValueDeviceTypeId.getNumberValue());
+                    String deviceNo = StringUtils.lowerCase(deviceNoCell.getStringCellValue().trim());
+                    int deviceNoResult = deviceMapper.findByDeviceNoUnique(null, deviceNo);
+                    if (deviceNoResult > 0) {
+                        failTime.incrementAndGet();
+                        c_remark.setCellValue("设备编号已存在");
+                        continue;
+                    }
+                    device.setDeviceNo(deviceNo);
+                    if (locDescCell.getCellTypeEnum() == CellType.NUMERIC) {
+                        device.setLocDesc(String.format("%.0f", locDescCell.getNumericCellValue()));
+                    } else if (locDescCell.getCellTypeEnum() == CellType.STRING) {
+                        device.setLocDesc(locDescCell.getStringCellValue().trim());
+                    }
+                    if (floorCell != null) {
+                        device.setFloor((int) floorCell.getNumericCellValue());
+                    }
+                    if (customerIdCell != null) {
+                        CellValue cellValuesetCustomerId = evaluator.evaluate(customerIdCell);
+                        device.setCustomerId((int) cellValuesetCustomerId.getNumberValue());
+                    }
+                    if (waterMeterNoCell != null) {
+                        //设置单元格类型
+                        waterMeterNoCell.setCellType(CellType.STRING);
+                        String waterMeterNo = StringUtils.lowerCase(waterMeterNoCell.getStringCellValue().trim());
+                        int waterMeterNoResult = deviceMapper.findByWaterMeterNoUnique(null, waterMeterNo);
+                        if (waterMeterNoResult > 0) {
                             failTime.incrementAndGet();
-                            c_remark.setCellValue("设备编号已存在");
+                            c_remark.setCellValue("水表电子号已存在");
                             continue;
                         }
-                        device.setDeviceNo(deviceNo);
-                        if (locDescCell.getCellTypeEnum() == CellType.NUMERIC) {
-                            device.setLocDesc(String.format("%.0f", locDescCell.getNumericCellValue()));
-                        } else if (locDescCell.getCellTypeEnum() == CellType.STRING) {
-                            device.setLocDesc(locDescCell.getStringCellValue().trim());
-                        }
-                        if (floorCell != null) {
-                            device.setFloor((int) floorCell.getNumericCellValue());
-                        }
-                        if (customerIdCell != null) {
-                            CellValue cellValuesetCustomerId = evaluator.evaluate(customerIdCell);
-                            device.setCustomerId((int) cellValuesetCustomerId.getNumberValue());
-                        }
-                        if (waterMeterNoCell != null) {
-                            //设置单元格类型
-                            waterMeterNoCell.setCellType(CellType.STRING);
-                            String waterMeterNo = StringUtils.lowerCase(waterMeterNoCell.getStringCellValue().trim());
-                            int waterMeterNoResult = deviceMapper.findByWaterMeterNoUnique(null, waterMeterNo);
-                            if (waterMeterNoResult > 0) {
-                                failTime.incrementAndGet();
-                                c_remark.setCellValue("水表电子号已存在");
-                                continue;
-                            }
-                            device.setWaterMeterNo(waterMeterNo);
-                        }
-                        if (waterMeterFileNoCell != null) {
-                            waterMeterFileNoCell.setCellType(CellType.STRING);
-                            String waterMeterFileNo = StringUtils.lowerCase(waterMeterFileNoCell.getStringCellValue().trim());
-                            if(!StringUtils.equals("",waterMeterFileNo)){
-                                device.setWaterMeterFileNo(waterMeterFileNo);
-                            }
+                        device.setWaterMeterNo(waterMeterNo);
+                    }
+                    if (waterMeterFileNoCell != null) {
+                        waterMeterFileNoCell.setCellType(CellType.STRING);
+                        String waterMeterFileNo = StringUtils.lowerCase(waterMeterFileNoCell.getStringCellValue().trim());
+                        if(!StringUtils.equals("",waterMeterFileNo)){
+                            device.setWaterMeterFileNo(waterMeterFileNo);
                         }
+                    }
+
+
 
+                    DeviceTypeDto deviceType = deviceTypeMapper.getById(device.getDeviceType());
 
+                    //DeviceType deviceType = deviceTypeMapper.findByid(device.getDeviceType());
+                    device.setManufacturerId(deviceType.getManufacturerId());
+                    device.setDeviceStatus(5);//未启用
+                    device.setStatus(1);
+                    device.setXCoordinates(device.getXCoordinates());
+                    device.setYCoordinates(device.getYCoordinates());
+                    device.setIsTag(device.getXCoordinates() != null && device.getYCoordinates() != null ? 1 : 0);
+                    device.setCreateBy("system");
+                    device.setDateCreate(LocalDateTime.now());
+                    device.setUpdateBy("system");
+                    device.setDateUpdate(LocalDateTime.now());
 
-                        DeviceTypeDto deviceType = deviceTypeMapper.getById(device.getDeviceType());
-
-                        //DeviceType deviceType = deviceTypeMapper.findByid(device.getDeviceType());
-                        device.setManufacturerId(deviceType.getManufacturerId());
-                        device.setDeviceStatus(5);//未启用
-                        device.setStatus(1);
-                        device.setXCoordinates(device.getXCoordinates());
-                        device.setYCoordinates(device.getYCoordinates());
-                        device.setIsTag(device.getXCoordinates() != null && device.getYCoordinates() != null ? 1 : 0);
-                        device.setCreateBy("system");
-                        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);
-                            }
+                    if(device.getCustomerId().equals(linheCustomerId)){
+                        Boolean syncStatus = hlhtService.updatePayMeterEleno(device.getWaterMeterNo(),device.getWaterMeterFileNo());
+                        if (syncStatus) {
+                            device.setSyncStatus(1);
                         }else {
-                            device.setSyncStatus(0);
+                            device.setSyncStatus(2);
                         }
+                    }else {
+                        device.setSyncStatus(0);
+                    }
 
 
-                        deviceMapper.insertSelective(device);
+                    deviceMapper.insertSelective(device);
 
-                        //2、同步设备维度关系
-                        Building building = buildingMapper.getBuilding(device.getBuildingId());
-                        DeviceDimension deviceDimension = new DeviceDimension();
-                        deviceDimension.setDeviceId(device.getId());
-                        deviceDimension.setProvince(String.valueOf(building.getProvince()));
-                        deviceDimension.setCity(String.valueOf(building.getCity()));
-                        deviceDimension.setRegion(String.valueOf(building.getRegion()));
-                        deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
-                        deviceDimension.setBuilding(String.valueOf(building.getId()));
-                        deviceDimension.setFloor(String.valueOf(device.getFloor()));
-                        deviceDimension.setDevice(device.getDeviceNo());
-                        deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
-                        deviceDimension.setStatus(1);
-                        deviceDimension.setCreateBy("system");
-                        deviceDimension.setUpdateBy("system");
-                        deviceDimension.setDateCreate(LocalDateTime.now());
-                        deviceDimension.setDateUpdate(LocalDateTime.now());
+                    //2、同步设备维度关系
+                    Building building = buildingMapper.getBuilding(device.getBuildingId());
+                    DeviceDimension deviceDimension = new DeviceDimension();
+                    deviceDimension.setDeviceId(device.getId());
+                    deviceDimension.setProvince(String.valueOf(building.getProvince()));
+                    deviceDimension.setCity(String.valueOf(building.getCity()));
+                    deviceDimension.setRegion(String.valueOf(building.getRegion()));
+                    deviceDimension.setCommunity(String.valueOf(building.getCommunity()));
+                    deviceDimension.setBuilding(String.valueOf(building.getId()));
+                    deviceDimension.setFloor(String.valueOf(device.getFloor()));
+                    deviceDimension.setDevice(device.getDeviceNo());
+                    deviceDimension.setCustomer(String.valueOf(device.getCustomerId()));
+                    deviceDimension.setStatus(1);
+                    deviceDimension.setCreateBy("system");
+                    deviceDimension.setUpdateBy("system");
+                    deviceDimension.setDateCreate(LocalDateTime.now());
+                    deviceDimension.setDateUpdate(LocalDateTime.now());
 
-                        deviceDimensionMapper.insertSelective(deviceDimension);
+                    deviceDimensionMapper.insertSelective(deviceDimension);
 
-                        hssfSheet.removeRow(row);//成功删除该行
+                    hssfSheet.removeRow(row);//成功删除该行
 
-                        successTime.incrementAndGet();
-                    }
+                    successTime.incrementAndGet();
                 }
-                //循环为空的行上移
-                if(failTime.get() > 0){
-                    for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
-                        Row row = hssfSheet.getRow(rowNum);
-                        if (row == null) {
-                            hssfSheet.shiftRows(rowNum+1, 5000, -1);
-                        }
+            }
+            //循环为空的行上移
+            if(failTime.get() > 0){
+                for (int rowNum = hssfSheet.getLastRowNum(); rowNum > 3 ; rowNum--) {
+                    Row row = hssfSheet.getRow(rowNum);
+                    if (row == null) {
+                        hssfSheet.shiftRows(rowNum+1, 5000, -1);
                     }
                 }
+            }
 
 
 
-                isDownload = true;
-            }
-        }catch (Exception e){
-            invalidTemplate = true;
-            log.error("read excel error" + e.getMessage());
-            messageContent.append("导入失败,读取文件错误。");
-        }finally {
-            FileUtil.deleteFile(record.getImportFilePath());
+            isDownload = true;
         }
 
         log.info("end WaterDeviceResolverExcelTemplate");

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

@@ -81,7 +81,7 @@ public interface BuildingService{
 
     public List<BuildingSelectDto> areaList(List<BuildingSelectInfoDto> buildingList);
 
-    List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus);
+    List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus);
 
     List<BuildingSelectDto> abnormalAreaBuildingList(Integer sysId, Integer buildingId, Integer floor, Integer measuringId, Long deviceId, String deviceNo, String location, Integer alarmCategory, Integer handleStatus, Integer alarmTypeId, Integer equipmentId, Integer manufacturerId, Integer customerId, Integer province, Integer city, Integer region, Integer communityId, LocalDateTime startDate, LocalDateTime endDate);
 

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

@@ -38,13 +38,13 @@ public interface DeviceService{
 
     Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor,
                                   String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType,
-                                  Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, String sortColumn, String sortOrder, int pageNum, int pageSize);
+                                  Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, String sortColumn, String sortOrder, int pageNum, int pageSize);
 
     List<DeviceDto> getWaterMeterListByDeviceNo(String deviceNo,String waterMeterNo);
 
     void getDeviceListExcel(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor,
                             String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType,
-                            Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
+                            Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
 
     void exportDeviceListAsXML(Integer sysId,

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

@@ -926,10 +926,10 @@ public class BuildingServiceImpl implements BuildingService {
     }
 
     @Override
-    public List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer communityId, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus) {
+    public List<BuildingSelectDto> deviceAreaList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer communityId, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         //查询用户数据项下的建筑列表
-        List<BuildingSelectInfoDto> buildingList = buildingMapper.deviceCountAreaList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingId, deviceNo, status, manufacturerId, equipmentType, model, isTag, floor, locDesc, province, city, region, communityId, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,deviceTypeId,valveStatus,registerStatus,issueStatus);
+        List<BuildingSelectInfoDto> buildingList = buildingMapper.deviceCountAreaList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), sysId, buildingId, deviceNo, status, manufacturerId, equipmentType, model, isTag, floor, locDesc, province, city, region, communityId, concentratorNo, collectorNo, errorType, customerId, days, startDays, endDays,deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus);
 
         return this.areaList(buildingList);
     }

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

@@ -19,8 +19,6 @@ 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.*;
-import com.bz.smart_city.service.valve.ValveContext;
-import com.bz.smart_city.service.valve.impl.GdDeviceValveStrategy;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -30,13 +28,11 @@ import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.output.Format;
 import org.jdom.output.XMLOutputter;
-import org.jxls.util.JxlsHelper;
 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.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.io.File;
@@ -173,13 +169,13 @@ public  class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, String sortColumn, String sortOrder, int pageNum, int pageSize) {
+    public Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, String sortColumn, String sortOrder, int pageNum, int pageSize) {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         PageHelper.startPage(pageNum, pageSize);
         List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
                 equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
-                days, startDays, endDays,deviceTypeId, valveStatus, registerStatus, issueStatus, sortColumn, sortOrder);
+                days, startDays, endDays,deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, sortColumn, sortOrder);
         return new Pagination<>(list);
     }
 
@@ -190,12 +186,12 @@ public  class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public void getDeviceListExcel(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
+    public void getDeviceListExcel(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
                 equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
-                days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, sortColumn, sortOrder);
+                days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, sortColumn, sortOrder);
         String title = "设备列表";
         //判断是否是水表场景
         WMeterType wMeterType = wMeterTypeMapper.getChannelIdAndLevel(sysId, 2);
@@ -203,7 +199,7 @@ public  class DeviceServiceImpl implements DeviceService {
         if (wMeterType != null || sysId == -99) {
             if(StringUtils.equals("photoelectricMeter",channel.getChannelCode())){
                 DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-                String[] rowsName = new String[]{"序号", "水表电子号", "设备型", "客户", "设备状态", "集中器编码", "采集器编码", "下发状态", "当前读数", "建筑", "安装地址", "阀门控制", "最后一次更新时间","出厂时间","安装时间","验收时间"};
+                String[] rowsName = new String[]{"序号", "水表电子号", "设备型", "客户", "设备状态", "集中器编码", "采集器编码", "下发状态", "当前读数", "建筑", "安装地址", "阀门控制", "最后一次更新时间","出厂时间","安装时间","验收时间"};
                 List<Object[]> dataList = newArrayList();
                 Object[] objs = null;
                 for (int i = 0; i < list.size(); i++) {
@@ -463,7 +459,7 @@ public  class DeviceServiceImpl implements DeviceService {
             if (syncStatus) {
                 device.setSyncStatus(1);
             }else {
-                device.setSyncStatus(0);
+                device.setSyncStatus(2);
             }
         }else {
             device.setSyncStatus(0);
@@ -667,7 +663,7 @@ public  class DeviceServiceImpl implements DeviceService {
             if (syncStatus) {
                 device.setSyncStatus(1);
             }else {
-                device.setSyncStatus(0);
+                device.setSyncStatus(2);
             }
         }else {
             device.setSyncStatus(0);
@@ -1535,7 +1531,7 @@ public  class DeviceServiceImpl implements DeviceService {
             if (syncStatus) {
                 deviceUpdate.setSyncStatus(1);
             }else {
-                deviceUpdate.setSyncStatus(0);
+                deviceUpdate.setSyncStatus(2);
 
             }
             deviceMapper.updateByPrimaryKeySelective(deviceUpdate);

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

@@ -71,6 +71,7 @@ public class JobCardServiceImpl implements JobCardService {
 		device.setId(deviceId);
 		device.setStatus(1);
 		device.setRegisterStatus(0);
+		device.setSyncStatus(0);
 
 		int result = deviceMapper.insert(device);
 		// 2,添加设备扩展信息,一个是设备种类信息,一个是设备是否使用的信息

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

@@ -815,6 +815,7 @@ public class InstallManagerServiceImpl implements InstallManagerService, Initial
 			DeviceDto d = convertInstallList(dto);
 			d.setDateCreate(LocalDateTime.now());
 			d.setRegisterStatus(0);
+			d.setSyncStatus(0);
 			deviceMapper.insert(d);
 			saveDeviceDimInfo(d);
 

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

@@ -37,23 +37,31 @@ public class HlhtService {
             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);
+            log.info("postData : {}", JSON.toJSONString(postData));
+            ResponseEntity<String> responseEntity = null;
+            try {
+                responseEntity = restTemplate.postForEntity(url, postData, String.class);
+            }catch (Exception e){
+                log.error("request error e={}",e.getMessage());
+            }
+            if (responseEntity != null) {
+                log.info("responseEntity : {} {}", responseEntity.getStatusCodeValue(),responseEntity.getBody());
+                if (responseEntity.getStatusCode()== HttpStatus.OK) {
+                    //String result = (String) responseEntity.getBody();
+                    JSONObject jsonObject = JSONObject.parseObject(responseEntity.getBody());
 
-                String succ = jsonObject.getString("succ");
-                if (StringUtils.equals(succ,"0")){
-                    syncStatus = true;
-                    log.info("success");
+                    String succ = jsonObject.getString("succ");
+                    if (StringUtils.equals(succ,"0")){
+                        syncStatus = true;
+                        log.info("success");
+                    }else {
+                        log.info("fail");
+                    }
                 }else {
-                    log.info("fail");
+                    log.error("request error");
                 }
-            }else {
-                log.error("request error");
             }
+
         }
         log.info("end updatePayMeterEleno");
         return syncStatus;
@@ -81,29 +89,37 @@ public class HlhtService {
             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");
+            log.info("postData : {}", JSON.toJSONString(postData));
+            ResponseEntity<String> responseEntity = null;
+            try {
+                responseEntity = restTemplate.postForEntity(url, postData, String.class);
+            }catch (Exception e){
+                log.error("request error e={}",e.getMessage());
+            }
+            if (responseEntity != null) {
+                log.info("responseEntity : {} {}", responseEntity.getStatusCodeValue(),responseEntity.getBody());
+                if (responseEntity.getStatusCode()== HttpStatus.OK) {
+                    JSONObject jsonObject = JSONObject.parseObject(responseEntity.getBody());
+                    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 {
-                        throw new ServiceException(-999, msg);
+                        log.info("meter fail");
                     }
                 }else {
-                    log.info("meter fail");
+                    log.error("request error");
                 }
-            }else {
-                log.error("request error");
             }
+
         }
         log.info("end equipmentMeter");
         return syncStatus;

+ 4 - 3
smart-city-platform/src/main/java/com/bz/smart_city/service/udip/UdipUnitService.java

@@ -89,11 +89,12 @@ public class UdipUnitService {
                     JSONObject data = jsonObject.getJSONObject("data");
                     return data.getString("id");
                 }else {
-                    //throw new ServiceException(-900, jsonObject.getString("msg"));
-                    return null;
+                    log.error("updateUdipUnit error = {}",jsonObject.getString("msg"));
+                    throw new ServiceException(-900, "更新集成元错误");
+                    //return null;
                 }
             } catch (IOException e) {
-                throw new ServiceException(-900, "新增集成元错误");
+                throw new ServiceException(-900, "更新集成元异常");
             }
         }else {
             return saveUdipUnit(identifier,customerId,deviceType);

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


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


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

@@ -1028,6 +1028,7 @@
             <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>
             <if test="registerStatus != null"> and sd.register_status = #{registerStatus} </if>
             <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus} </if>
+            <if test="syncStatus != null"> and sd.sync_status = #{syncStatus} </if>
             <if test="programItems != null and programItems.size() != 0"> and
                 <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
                     sdd.${item.dimensionCode} = #{item.dimensionValue}

+ 2 - 0
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -405,6 +405,7 @@
         <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>
         <if test="registerStatus != null"> and sd.register_status = #{registerStatus}</if>
         <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus}</if>
+        <if test="syncStatus != null"> and sd.sync_status = #{syncStatus}</if>
         <if test="days != null">
             <choose>
                 <when test="days == 0">
@@ -466,6 +467,7 @@
         <if test="valveStatus != null and valveStatus == 2"> and sdt.is_valve = 0</if>
         <if test="registerStatus != null"> and sd.register_status = #{registerStatus}</if>
         <if test="issueStatus != null"> and swrd.issue_status = #{issueStatus}</if>
+        <if test="syncStatus != null"> and sd.sync_status = #{syncStatus}</if>
         <if test="days != null">
             <choose>
                 <when test="days == 0">

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

@@ -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,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 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

+ 3 - 3
smart-city-platform/src/test/java/com/bz/smart_city/ForCreateDataTest.java

@@ -99,7 +99,7 @@ public class ForCreateDataTest {
         Integer systemId = 18;
         Integer siteId = 37;
         String prefix = "30393731";
-        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null, null, null, null, null, null, null, null,null);
+        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null, null, null, null, null, null, null, null, null,null);
         int i = 0;
         for (DeviceDto d : devices) {
             if (i % 100 == 0) {
@@ -195,7 +195,7 @@ public class ForCreateDataTest {
         Integer systemId = 4;
         Integer siteId = 37;
         String prefix = "004a70124";
-        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
+        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
         int i = 0;
         for (DeviceDto d : devices) {
             if (i % 100 == 0) {
@@ -218,7 +218,7 @@ public class ForCreateDataTest {
         Integer systemId = 4;
         Integer siteId = 37;
         String prefix = "004a70124";
-        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
+        List<DeviceDto> devices = deviceMapper.getList(systemId, null, siteId, null, prefix, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,null);
 
         for (int i = 0; i < 105; i++) {
             DeviceDto d = devices.get(getRandom(devices.size()));

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

@@ -395,8 +395,8 @@ public class ScTest {
     @Test
     public void HlhtService(){
         HlhtService hlhtService =  new HlhtService();
-        //hlhtService.updatePayMeterEleno("3412345131234","311000002201");
-        hlhtService.equipmentMeter("311000002201","10","0","3412345131235","3412345131234");
+        hlhtService.updatePayMeterEleno("2020092515000","318010000602");
+        //hlhtService.equipmentMeter("311000002201","10","0","3412345131235","3412345131234");
     }