diff options
author | guochuyicmri <guochuyi@chinamobile.com> | 2018-10-31 10:31:19 +0800 |
---|---|---|
committer | guochuyicmri <guochuyi@chinamobile.com> | 2018-10-31 10:31:26 +0800 |
commit | 7f3cd4ccd60fea5f579d8e963531ae9d611dac8e (patch) | |
tree | 859397bb10a43f560146e00d5f446c4e8b5c1ca7 | |
parent | 9168c54611ad28f04d269291011779e5f4b286f3 (diff) |
add method:getServiceNumByCustomerId
Change-Id: Ifc3137dabd2efd5a1b6eba67c5def55a269d493c
Issue-ID: USECASEUI-168
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
3 files changed, 24 insertions, 2 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java index fb911b76..79503873 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java @@ -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){ diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java index e9416f8f..28bd9e06 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java @@ -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; } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java index 6405795b..b7f89593 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java @@ -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); } } |