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){
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;
}
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;
}
}
- 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);
}
}