1.定时去统计界面和服务端的配置量入库,并新增系统管理-管理员用户预警界面列表的功能
2.实时扫描此表中界面和服务端的配置量是否一致,不一致,管理员用户告警提示
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package com.nis.web.controller.sys;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.SysUserWarn;
|
||||
import com.nis.domain.SysUserWarnData;
|
||||
import com.nis.domain.SysUserWarnRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.service.SysUserWarnService;
|
||||
/**
|
||||
* 定时查询 界面配置总量和 服务配置总量 并添加到 sys_user_warn表中
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StatisticSysUserWarnNumber {
|
||||
|
||||
private Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
|
||||
@Autowired
|
||||
protected SysUserWarnService sysUserWarnService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
|
||||
public void insertTotalInfo() {
|
||||
logger.info("定时统计业务号的界面配置总量和服务配置总量-开始。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
//获取界面配置的所有业务信息
|
||||
List<Map<String, Object>> serviceList = ServiceConfigTemplateUtil.getServiceList();
|
||||
getSysData(serviceList);
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("定时统计业务号的界面配置总量和服务配置总量-结束:"+(end-start)+"。。。。。。。。。。。。。。");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void getSysData(List<Map<String, Object>> serviceList){
|
||||
//调用服务端接口,查询所有业务服务端的配置总量
|
||||
try{
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("service", -1);
|
||||
String url = Constants.SERVICE_URL + Constants.CONFIG_BY_SERVICE;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
SysUserWarnRecvData fromJson = gson.fromJson(recv, new TypeToken<SysUserWarnRecvData>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
SysUserWarnData data = fromJson.getData();
|
||||
Map<String, List<String>> effective = data.getEffective();
|
||||
List<SysUserWarn> listTotal =new ArrayList<SysUserWarn>();
|
||||
for (Map<String, Object> map1 : serviceList) {
|
||||
SysUserWarn entity=new SysUserWarn();
|
||||
entity.setId(Integer.parseInt(map1.get("id").toString()));
|
||||
entity.setTableName(map1.get("tableName").toString());
|
||||
//根据serviceID和表名查询界面各个业务的配置数量
|
||||
Integer cfgCount = sysUserWarnService.getCfgCount(entity);
|
||||
//查询服务端的各个业务的配置数量
|
||||
List<String> list = effective.get(map1.get("id"));
|
||||
SysUserWarn sysUserWarn=new SysUserWarn();
|
||||
sysUserWarn.setServiceId(map1.get("id").toString());
|
||||
sysUserWarn.setServiceDesc(map1.get("desc").toString());
|
||||
if(cfgCount>0){
|
||||
sysUserWarn.setInterfaceCfgTotal(cfgCount);
|
||||
}else{
|
||||
sysUserWarn.setInterfaceCfgTotal(0);
|
||||
}
|
||||
if(list !=null && list.size()>0){
|
||||
sysUserWarn.setSystemCfgTotal(list.size());
|
||||
}else {
|
||||
sysUserWarn.setSystemCfgTotal(0);
|
||||
}
|
||||
sysUserWarn.setTime(new Date());
|
||||
listTotal.add(sysUserWarn);
|
||||
}
|
||||
//判断表中是否有数据
|
||||
Integer total = sysUserWarnService.getAllInfoCount();
|
||||
if(total !=null && total>0){//说明有数据 先删除 后添加
|
||||
sysUserWarnService.deleteAllData();
|
||||
sysUserWarnService.insert(listTotal);
|
||||
}else{// 没有 直接 添加
|
||||
sysUserWarnService.insert(listTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch(Exception e) {
|
||||
logger.error("更新所有业务的配置数量失败", e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.nis.web.controller.sys;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysUserWarn;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.SysUserWarnService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/warn")
|
||||
public class SysUserWarnController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
protected SysUserWarnService sysUserWarnService;
|
||||
|
||||
|
||||
|
||||
@RequiresPermissions("sys:warnList:view")
|
||||
@RequestMapping(value = {"userWarnList", ""})
|
||||
public String list(@ModelAttribute("warn") SysUserWarn warn, Model model,HttpServletRequest request
|
||||
,HttpServletResponse response) {
|
||||
Page<SysUserWarn> pageCondition = new Page<SysUserWarn>(request, response,"r");
|
||||
Properties msgProp = getMsgProp();
|
||||
Page<SysUserWarn> page = sysUserWarnService.getAllList(pageCondition,warn,msgProp);
|
||||
model.addAttribute("warn", warn);
|
||||
model.addAttribute("page", page);
|
||||
return "/sys/sysUserWarnList";
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:warnList:view")
|
||||
@ResponseBody
|
||||
@RequestMapping(value = {"serviceSum", ""})
|
||||
public SysUserWarn findServiceSum() {
|
||||
SysUserWarn findServiceSum = sysUserWarnService.findServiceSum();
|
||||
return findServiceSum;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
List<Map<String, Object>> serviceList = ServiceConfigTemplateUtil.getServiceList();
|
||||
System.out.println(serviceList);
|
||||
for (Map<String, Object> map : serviceList) {
|
||||
System.out.println(map.get("id"));
|
||||
System.out.println(map.get("tableName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user