add method:getServiceNumByCustomerId 18/71518/1
authorguochuyicmri <guochuyi@chinamobile.com>
Wed, 31 Oct 2018 02:31:19 +0000 (10:31 +0800)
committerguochuyicmri <guochuyi@chinamobile.com>
Wed, 31 Oct 2018 02:31:26 +0000 (10:31 +0800)
Change-Id: Ifc3137dabd2efd5a1b6eba67c5def55a269d493c
Issue-ID: USECASEUI-168
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java

index fb911b7..7950387 100644 (file)
@@ -97,6 +97,11 @@ public class ServiceInstanceController {
         return mapper.writeValueAsString(map);
     }
        
+       @ResponseBody
+    @RequestMapping(value = {"/uui-lcm/serviceNumByCustomer"}, method = RequestMethod.GET , produces = "application/json")
+    public String serviceNumByCustomer(HttpServletRequest request) throws JsonProcessingException{
+               return serviceInstanceService.serviceNumByCustomer();
+       }
     @ResponseBody
     @RequestMapping(value = {"/uui-lcm/getServiceInstanceById"}, method = RequestMethod.GET , produces = "application/json")
     public String getServiceInstanceById(HttpServletRequest request){
index e9416f8..28bd9e0 100644 (file)
@@ -17,9 +17,13 @@ package org.onap.usecaseui.server.service.lcm;
 
 import java.util.List;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+
 public interface ServiceInstanceService {
 
     List<String> listServiceInstances(String customerId, String serviceType);
     
     String getRelationShipData(String customerId, String serviceType,String serviceId );
+    
+    String serviceNumByCustomer() throws JsonProcessingException;
 }
index 6405795..b7f8959 100644 (file)
@@ -18,7 +18,9 @@ package org.onap.usecaseui.server.service.lcm.impl;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Resource;
 
@@ -138,20 +140,31 @@ public class DefaultServiceInstanceService implements ServiceInstanceService {
         }
        }
        
-       public String serviceNumByCustomer(){
+       @Override
+       public String serviceNumByCustomer() throws JsonProcessingException{
+               Map<String,Object> result = new HashMap();
+               ObjectMapper omAlarm = new ObjectMapper();
                List<AAICustomer> customers = customerService.listCustomer();
                int total =0;
+               List<Map<String,Object>> list = new ArrayList<>();
                if(customers.size()>0){
                        for(AAICustomer customer : customers){
+                               Map<String,Object> customerMap = new HashMap<String,Object>();
+                               int customerNum = 0;
                                List<AAIServiceSubscription> serviceSubscriptions = customerService.listServiceSubscriptions(customer.getGlobalCustomerId());
                                if(serviceSubscriptions.size()>0){
                                        for(AAIServiceSubscription serviceSubscription:serviceSubscriptions){
                                                List<String> serviceInstances =this.listServiceInstances(customer.getGlobalCustomerId(), serviceSubscription.getServiceType());
                                                total+=serviceInstances.size();
+                                               customerNum+=serviceInstances.size();
                                        }
                                }
+                               customerMap.put(customer.getSubscriberName(), customerNum);
+                               list.add(customerMap);
                        }
                }
-               return null;
+               result.put("serviceTotalNum", total);
+               result.put("customerServiceList", list);
+               return omAlarm.writeValueAsString(result);
        }
 }