调整日志配置总量查询,整页配置只查询一次,减小资源浪费

This commit is contained in:
wangxin
2018-08-26 10:43:03 +08:00
parent 6b79b5f7ef
commit 9678a4a10f
3 changed files with 89 additions and 55 deletions

View File

@@ -25,21 +25,14 @@ public class NtcPzReport extends BaseReport<NtcPzReport>{
*/
private static final long serialVersionUID = 7079305499220977782L;
private Long configId;
private Long cfgId;
private Date statTime;
/**
* configId
* @return configId
*/
public Long getConfigId() {
return configId;
public Long getCfgId() {
return cfgId;
}
/**
* @param configId the configId to set
*/
public void setConfigId(Long configId) {
this.configId = configId;
public void setCfgId(Long cfgId) {
this.cfgId = cfgId;
}
/**
* statTime

View File

@@ -50,30 +50,46 @@ import net.sf.json.JsonConfig;
public class NtcPzReportController extends BaseController{
@RequestMapping(value="ajaxGetLogTotal",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> ajaxGetLogTotal(Model model,long endTime,int action,Integer functionId,Integer compileId){
Map<String, Object> data=new HashMap<String, Object>();
public List<Map<String, Object>> ajaxGetLogTotal(Model model,long endTime,String actions,Integer functionId,String compileIds){
List<Map<String, Object>> dataList=new ArrayList<>();
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
int interval=Constants.LOG_TIME_RANGE;
Date endDate=new Date(endTime);
Date startDate=new Date(endTime-interval);
int serviceId=0;
String serviceIdsStr="";
StringBuffer serviceIds=new StringBuffer();
List<FunctionServiceDict> serviceList=DictUtils.getFunctionServiceDictList(functionId.intValue());
for(FunctionServiceDict service:serviceList){
if(service.getAction().intValue()==action){
serviceId=service.getServiceId().intValue();
break;
for(String action:actions.split(",")) {
for(FunctionServiceDict service:serviceList){
if(service.getAction().intValue()==Integer.parseInt(action)){
serviceIds.append(service.getServiceId().intValue());
serviceIds.append(",");
}
}
}
data.put("compileId", compileId.intValue());
String json=ConfigServiceUtil.getReport(Constants.BUSINESSTYPE_CONFIG, String.valueOf(compileId), String.valueOf(serviceId), sdf.format(startDate), sdf.format(endDate));
if(serviceIds.toString().endsWith(",")) {
serviceIdsStr=serviceIds.toString().substring(0,serviceIds.toString().lastIndexOf(","));
}
String json=ConfigServiceUtil.getReport(Constants.BUSINESSTYPE_CONFIG, compileIds, serviceIdsStr, sdf.format(startDate), sdf.format(endDate));
List<NtcPzReport> list=getList(json);
if(list!=null&&list.size()>0){
data.put("sum",list.get(0).getSum().longValue());
String[] idArr=compileIds.split(",");
if(list!=null&&(list.size()>0)){
for(NtcPzReport report:list) {
Map<String, Object> data=new HashMap<String, Object>();
data.put("compileId", report.getCfgId().longValue());
data.put("sum",report.getSum().longValue());
dataList.add(data);
}
}else {
data.put("sum", 0);
for(String id:idArr) {
Map<String, Object> data=new HashMap<String, Object>();
data.put("compileId", id);
data.put("sum",0);
dataList.add(data);
}
}
return data;
return dataList;
}
@RequestMapping("/ntcPzReport")
public String list(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) {