Browse Source

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

zhoujiangyuan 4 years ago
parent
commit
fba77cd6c7

+ 12 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/TreeUtil.java

@@ -406,5 +406,17 @@ public class TreeUtil {
 
     }
 
+    public static void  eliminateCustomerRate(List<CustomerRateDto> list){
+        if (list != null && list.size()>0) {
+            for (CustomerRateDto customerRateDto : list) {
+                if (customerRateDto.getChildren() != null) {
+                    customerRateDto.setChildren(customerRateDto.getChildren().stream().filter(p -> p.getDeviceCount() > 0).sorted(Comparator.comparingInt(CustomerRateDto::getDeviceCount).reversed()).collect(Collectors.toList()));
+                }
+                eliminateCustomerRate(customerRateDto.getChildren());
+            }
+        }
+
+    }
+
 
 }

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

@@ -156,7 +156,7 @@ public class InstallController {
     	//dto.setCreateBy(loginUser.getName());
     	dto.setUpdateBy(loginUser.getName());
     	dto.setNewMeterStart(newMeterStart);
-    	dto.setInstallTime(LocalDateTime.now());
+    	//dto.setInstallTime(LocalDateTime.now());
     	dto.setFileNo(fileNo);
     	dto.setOldMeterEnd(oldMeterEnd);
     	dto.setImageUrl(newImageUrl);
@@ -288,7 +288,7 @@ public class InstallController {
     	
 		// 2,处理导入文件,返回成功数目
     	int result = installManagerService.importInstallList(dto, file);
-        return new AjaxMessage(ResultStatus.OK, result);
+        return new AjaxMessage<>(ResultStatus.OK, result);
     }
 
 	@ResponseBody
@@ -297,7 +297,7 @@ public class InstallController {
 	public AjaxMessage batchRegister(
 			@ApiParam(value = "设备id,多个英文逗号隔开", required = true) @RequestParam(required = true) List<Long> deviceIds
 	){
-		deviceService.batchRegister(deviceIds);
-		return new AjaxMessage(ResultStatus.OK);
+		String msg = deviceService.batchRegister(deviceIds);
+		return new AjaxMessage<>(0,msg,null);
 	}
 }

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

@@ -123,5 +123,5 @@ public interface DeviceService{
 
     void setValve(Long deviceId);
 
-    void batchRegister(List<Long> deviceIds);
+    String batchRegister(List<Long> deviceIds);
 }

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

@@ -1381,9 +1381,10 @@ public  class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public void batchRegister(List<Long> deviceIds) {
+    public String batchRegister(List<Long> deviceIds) {
         log.info("begin batchRegister,deviceIds = {}",  JSON.toJSONString(deviceIds));
         AtomicInteger count = new AtomicInteger(0);
+        AtomicInteger failCount = new AtomicInteger(0);
         if (deviceIds != null && deviceIds.size() > 0) {
             for (Long deviceId : deviceIds) {
                 try {
@@ -1399,13 +1400,18 @@ public  class DeviceServiceImpl implements DeviceService {
                         deviceUpdate.setDateUpdate(LocalDateTime.now());
                         deviceMapper.updateByPrimaryKeySelective(deviceUpdate);
                         count.incrementAndGet();
+                    }else {
+                        failCount.incrementAndGet();
                     }
 
                 }catch (Exception e){
                     log.info("register error deviceId={},e={}",deviceId,e.getMessage());
+                    failCount.incrementAndGet();
                 }
             }
         }
-        log.info("end batchRegister count={}",count.get());
+        String msg = "成功"+count.get()+"条 失败"+failCount.get()+"条";
+        log.info("end batchRegister msg={}",msg);
+        return msg;
     }
 }

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

@@ -390,6 +390,7 @@ public class StatMeterReadRateByBuildingServiceImpl implements StatMeterReadRate
             return TreeUtil.getCustomerRateTreeNode(list,customerId);
         }
         List<CustomerRateDto> newList = list.stream().filter(p -> p.getDeviceCount() > 0).sorted(Comparator.comparingInt(CustomerRateDto::getDeviceCount).reversed()).collect(Collectors.toList());
+        TreeUtil.eliminateCustomerRate(newList);
         return newList;
     }
 

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


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