2017-12-29 16:18:40 +08:00
|
|
|
|
package com.nis.web.controller;
|
|
|
|
|
|
import java.beans.PropertyEditorSupport;
|
|
|
|
|
|
import java.io.IOException;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import java.util.ArrayList;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import java.util.Date;
|
2018-06-05 17:52:26 +08:00
|
|
|
|
import java.util.HashMap;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import java.util.List;
|
2018-06-05 17:52:26 +08:00
|
|
|
|
import java.util.Map;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import java.util.Properties;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.beust.jcommander.internal.Lists;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.domain.FunctionRegionDict;
|
|
|
|
|
|
import com.nis.domain.FunctionServiceDict;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.basics.ServiceDictInfo;
|
|
|
|
|
|
import com.nis.domain.basics.SysDictInfo;
|
|
|
|
|
|
import com.nis.domain.configuration.AreaBean;
|
|
|
|
|
|
import com.nis.domain.configuration.AreaIpCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
|
|
|
|
|
import com.nis.domain.configuration.IpCfgTemplate;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.domain.configuration.RequestInfo;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.domain.configuration.StringCfgTemplate;
|
2018-06-13 14:36:58 +08:00
|
|
|
|
import com.nis.domain.log.BaseLogEntity;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import com.nis.util.Configurations;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
//import com.nis.main.ConvertTool;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.util.DateUtils;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.util.DictUtils;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.util.JsonMapper;
|
2018-06-13 09:58:13 +08:00
|
|
|
|
import com.nis.util.excel.ExportExcel;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
import com.nis.web.service.ArchiveServcie;
|
|
|
|
|
|
import com.nis.web.service.AreaService;
|
|
|
|
|
|
import com.nis.web.service.DictService;
|
|
|
|
|
|
import com.nis.web.service.LogService;
|
|
|
|
|
|
import com.nis.web.service.MenuService;
|
|
|
|
|
|
import com.nis.web.service.OfficeService;
|
|
|
|
|
|
import com.nis.web.service.RoleService;
|
|
|
|
|
|
import com.nis.web.service.SystemService;
|
|
|
|
|
|
import com.nis.web.service.UserService;
|
2018-06-20 13:33:46 +08:00
|
|
|
|
import com.nis.web.service.basics.PolicyGroupInfoService;
|
2018-03-06 10:31:18 +08:00
|
|
|
|
import com.nis.web.service.basics.ServiceDictInfoService;
|
|
|
|
|
|
import com.nis.web.service.basics.SysDictInfoService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.AppCfgService;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.web.service.configuration.AvCfgService;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
import com.nis.web.service.configuration.AvContentCfgService;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
import com.nis.web.service.configuration.BgpCfgService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.ComplexStringCfgService;
|
2018-06-23 14:08:53 +08:00
|
|
|
|
import com.nis.web.service.configuration.ControlPolicyService;
|
2018-04-09 16:38:45 +08:00
|
|
|
|
import com.nis.web.service.configuration.DnsIpCfgService;
|
2018-06-22 10:12:54 +08:00
|
|
|
|
import com.nis.web.service.configuration.DnsResStrategyService;
|
2018-06-05 11:06:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.FileTransferCfgService;
|
2018-06-29 13:56:08 +08:00
|
|
|
|
import com.nis.web.service.configuration.HttpRedirectCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import com.nis.web.service.configuration.IpCfgService;
|
|
|
|
|
|
import com.nis.web.service.configuration.MailCfgService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
import com.nis.web.service.configuration.NumCfgService;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
import com.nis.web.service.configuration.RequestInfoService;
|
2018-06-29 12:44:33 +08:00
|
|
|
|
import com.nis.web.service.configuration.DomainService;
|
2018-05-25 13:25:21 +08:00
|
|
|
|
import com.nis.web.service.configuration.WebsiteCfgService;
|
2018-06-13 10:18:06 +08:00
|
|
|
|
import com.nis.web.service.configuration.XmppCfgService;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
import com.nis.web.service.specific.SpecificServiceCfgService;
|
|
|
|
|
|
import com.nis.web.service.specific.SpecificServiceHostCfgService;
|
2018-02-23 09:16:32 +08:00
|
|
|
|
import com.nis.web.service.systemService.ServiceConfigInfoService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
|
|
|
|
|
public class BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected UserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SystemService systemService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected OfficeService officeService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AreaService areaService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected RoleService roleService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected MenuService menuService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected LogService logService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ArchiveServcie archiveServcie;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DictService dictService;
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected IpCfgService ipCfgService;
|
|
|
|
|
|
|
2018-03-22 14:41:10 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DnsIpCfgService dnsIpCfgService;
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected MailCfgService mailCfgService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2018-06-05 11:06:37 +08:00
|
|
|
|
protected FileTransferCfgService fileTransferCfgService;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AppCfgService appCfgService;
|
2018-06-23 14:08:53 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ControlPolicyService controlPolicyService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-02-09 16:50:27 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceDictInfoService serviceDictInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SysDictInfoService sysDictInfoService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
protected final Logger logger = Logger.getLogger(this.getClass());
|
2017-12-29 16:18:40 +08:00
|
|
|
|
|
2018-02-23 09:16:32 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceConfigInfoService serviceConfigInfoService;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected RequestInfoService requestInfoService;
|
2018-02-27 15:31:30 +08:00
|
|
|
|
@Autowired
|
2018-06-29 12:44:33 +08:00
|
|
|
|
protected DomainService domainService;
|
2018-02-28 12:16:37 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected NumCfgService numCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ComplexStringCfgService complexStringCfgService;
|
2018-03-17 17:09:19 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SpecificServiceCfgService specificServiceCfgService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected SpecificServiceHostCfgService specificServiceHostCfgService;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvCfgService avCfgService;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvContentCfgService avContentCfgService;
|
2018-05-25 13:25:21 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected WebsiteCfgService websiteCfgService;
|
2018-06-13 09:30:03 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected BgpCfgService bgpCfgService;
|
2018-06-13 10:18:06 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected XmppCfgService xmppCfgService;
|
2018-06-20 13:33:46 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected PolicyGroupInfoService policyGroupInfoService;
|
2018-06-22 10:12:54 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected DnsResStrategyService dnsResStrategyService;
|
2018-06-29 13:56:08 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected HttpRedirectCfgService httpRedirectCfgService;
|
2017-12-29 16:18:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 管理基础路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${adminPath}")
|
|
|
|
|
|
protected String adminPath;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 前端基础路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${frontPath}")
|
|
|
|
|
|
protected String frontPath;
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 前端URL后缀
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Value("${urlSuffix}")
|
|
|
|
|
|
protected String urlSuffix;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 客户端返回JSON字符串
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param object
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected String renderString(HttpServletResponse response, Object object) {
|
|
|
|
|
|
return renderString(response, JsonMapper.toJsonString(object), "application/json");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 客户端返回字符串
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param string
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected String renderString(HttpServletResponse response, String string, String type) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
response.reset();
|
|
|
|
|
|
response.setContentType(type);
|
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
|
response.getWriter().print(string);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加Model消息
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessage(Model model, String... messages) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (String message : messages){
|
|
|
|
|
|
sb.append(message).append(messages.length>1?"<br/>":"");
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("message", sb.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加Flash消息
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (String message : messages){
|
|
|
|
|
|
sb.append(message).append(messages.length>1?"<br/>":"");
|
|
|
|
|
|
}
|
|
|
|
|
|
redirectAttributes.addFlashAttribute("message", sb.toString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 初始化数据绑定
|
|
|
|
|
|
* 1. 将所有传递进来的String进行HTML编码,防止XSS攻击
|
|
|
|
|
|
* 2. 将字段中Date类型转换为String类型
|
|
|
|
|
|
*/
|
|
|
|
|
|
@InitBinder
|
|
|
|
|
|
protected void initBinder(WebDataBinder binder) {
|
|
|
|
|
|
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
|
|
|
|
|
|
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void setAsText(String text) {
|
|
|
|
|
|
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getAsText() {
|
|
|
|
|
|
Object value = getValue();
|
|
|
|
|
|
return value != null ? value.toString() : "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// Date 类型转换
|
|
|
|
|
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void setAsText(String text) {
|
|
|
|
|
|
setValue(DateUtils.parseDate(text));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
protected void initPageCondition(Model model){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
|
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
|
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
|
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
protected void initPageCondition(Model model,BaseCfg cfg){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
|
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
|
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
|
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
|
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
protected void initFormCondition(Model model){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findFlDict();
|
|
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findXzDict();
|
|
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();
|
|
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<Integer> itTypeList=new ArrayList<Integer>();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
|
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
|
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("isps", isps);
|
|
|
|
|
|
//初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg=new AreaIpCfg();
|
|
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
protected void initFormCondition(Model model,BaseCfg cfg){
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findFlDict();
|
|
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findXzDict();
|
|
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findLableDict();
|
|
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
List<Integer> itTypeList=new ArrayList<Integer>();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
|
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
|
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("isps", isps);
|
|
|
|
|
|
//初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg=new AreaIpCfg();
|
|
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-05-25 16:01:01 +08:00
|
|
|
|
//ip配置设置protocolId
|
|
|
|
|
|
if(cfg instanceof BaseIpCfg){
|
|
|
|
|
|
for(FunctionServiceDict dict:serviceList){
|
|
|
|
|
|
if(cfg.getFunctionId().intValue()==dict.getFunctionId().intValue()){
|
|
|
|
|
|
((BaseIpCfg) cfg).setProtocolId(dict.getProtocolId().intValue());
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
}
|
2018-04-09 16:38:45 +08:00
|
|
|
|
protected void initUpdateFormCondition(Model model,BaseCfg cfg){
|
2018-06-01 18:13:07 +08:00
|
|
|
|
List<Integer> itTypeList=new ArrayList<Integer>();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_AREA);
|
|
|
|
|
|
List<SysDictInfo> areas = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("areas", areas);
|
|
|
|
|
|
itTypeList.clear();
|
|
|
|
|
|
itTypeList.add(Constants.ITEM_TYPE_ISP);
|
|
|
|
|
|
List<SysDictInfo> isps = sysDictInfoService.findAllSysDictInfo(new SysDictInfo(),itTypeList,null);
|
|
|
|
|
|
model.addAttribute("isps", isps);
|
|
|
|
|
|
|
2018-04-09 16:38:45 +08:00
|
|
|
|
//查询配置对应的地域ip
|
|
|
|
|
|
List<AreaIpCfg> areaCfgs=ipCfgService.getAreaCfgByCompileId(cfg.getCompileId());
|
|
|
|
|
|
model.addAttribute("areaCfgs", areaCfgs);
|
|
|
|
|
|
StringBuffer areaCfgIds=new StringBuffer();
|
|
|
|
|
|
for(AreaIpCfg areaCfg:areaCfgs){
|
|
|
|
|
|
areaCfgIds.append(areaCfg.getCfgId()+",");
|
|
|
|
|
|
}
|
|
|
|
|
|
//update时判断是否有删除地域ip
|
|
|
|
|
|
model.addAttribute("areaCfgIds", areaCfgIds.toString());
|
|
|
|
|
|
//初始化一个默认的地域ip给界面
|
|
|
|
|
|
AreaIpCfg areaIpCfg=new AreaIpCfg();
|
|
|
|
|
|
areaIpCfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_areaCfg", areaIpCfg);
|
|
|
|
|
|
//从区域生效ID中获取区域与运营商
|
|
|
|
|
|
String areaEffectiveIds=cfg.getAreaEffectiveIds();
|
|
|
|
|
|
List<AreaBean> areaIspList=new ArrayList<AreaBean>();
|
2018-06-05 17:52:26 +08:00
|
|
|
|
getAreaIsps(areaEffectiveIds,areaIspList,isps,areas);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("_areaIsps", areaIspList);
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
|
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
|
|
|
|
|
model.addAttribute("fls", fls);
|
|
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
|
|
|
|
|
model.addAttribute("xzs", xzs);
|
|
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
|
|
|
|
|
model.addAttribute("lables", lables);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("regionList", regionList);
|
|
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
|
|
|
|
|
|
model.addAttribute("serviceList", serviceList);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
}
|
2018-06-05 17:52:26 +08:00
|
|
|
|
public List<AreaBean> getAreaIsps(String areaEffectiveIds,List<AreaBean> areaIspList,List<SysDictInfo> isps,List<SysDictInfo> areas) {
|
|
|
|
|
|
Map<String, SysDictInfo> areaMap=new HashMap<String, SysDictInfo>();
|
|
|
|
|
|
for (SysDictInfo areaDict : areas) {
|
|
|
|
|
|
areaMap.put(areaDict.getItemCode(), areaDict);
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, SysDictInfo> ispMap=new HashMap<String, SysDictInfo>();
|
|
|
|
|
|
for (SysDictInfo ispDict : isps) {
|
|
|
|
|
|
ispMap.put(ispDict.getItemCode(), ispDict);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// : 存在冒号,则冒号前为area后为isp;不存在冒号,判断id是否为isp,否则为area
|
|
|
|
|
|
if(StringUtils.isNotBlank(areaEffectiveIds)){
|
|
|
|
|
|
String[] areaIsps=areaEffectiveIds.split(",");
|
|
|
|
|
|
for(String areaIsp:areaIsps){
|
|
|
|
|
|
AreaBean area=new AreaBean();
|
|
|
|
|
|
if(areaIsp.contains(":")){
|
|
|
|
|
|
area.setArea(areaIsp.split(":")[0]);
|
|
|
|
|
|
area.setIsp(areaIsp.split(":")[1]);
|
|
|
|
|
|
area.setAreaName(areaMap.get(areaIsp.split(":")[0]).getItemValue());
|
|
|
|
|
|
area.setIspName(ispMap.get(areaIsp.split(":")[1]).getItemValue());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(ispMap.keySet().contains(areaIsp)){
|
|
|
|
|
|
area.setIsp(areaIsp);
|
|
|
|
|
|
area.setIspName(ispMap.get(areaIsp).getItemValue());
|
|
|
|
|
|
area.setAreaName("");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
area.setArea(areaIsp);
|
|
|
|
|
|
area.setIspName("");
|
|
|
|
|
|
area.setAreaName(areaMap.get(areaIsp).getItemValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
areaIspList.add(area);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return areaIspList;
|
|
|
|
|
|
}
|
2018-06-13 09:30:03 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取国际化配置文件
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Properties getMsgProp(){
|
|
|
|
|
|
Properties msgProp = new Properties();
|
|
|
|
|
|
try {
|
|
|
|
|
|
String language = LocaleContextHolder.getLocale().getLanguage();
|
|
|
|
|
|
if(language.equals("zh_cn")||language.equals("zh")){
|
|
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_zh_CN.properties"));
|
|
|
|
|
|
}else if(language.equals("ru")){
|
|
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_ru.properties"));
|
|
|
|
|
|
}else{
|
|
|
|
|
|
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_en.properties"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
|
|
|
|
|
logger.error("未知i18n消息配置文件,请确定文件是否存在!",e);
|
|
|
|
|
|
}
|
|
|
|
|
|
return msgProp;
|
|
|
|
|
|
}
|
2018-06-13 09:58:13 +08:00
|
|
|
|
public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
|
|
|
|
|
|
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode){
|
|
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
try {
|
|
|
|
|
|
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
|
|
|
|
|
for(FunctionRegionDict dict:dictList){
|
|
|
|
|
|
if(dict.getConfigRegionCode()==cfgRegionCode){
|
|
|
|
|
|
String fileName = dict.getConfigRegionValue()+".xlsx";
|
|
|
|
|
|
if(dict.getRegionType()==1){
|
|
|
|
|
|
List<IpCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new IpCfgTemplate());
|
2018-06-15 09:33:53 +08:00
|
|
|
|
new ExportExcel(msgProp,null, IpCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
2018-06-13 09:58:13 +08:00
|
|
|
|
write(request,response, fileName).dispose();
|
|
|
|
|
|
}else if(dict.getRegionType()==2){
|
|
|
|
|
|
List<StringCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new StringCfgTemplate());
|
2018-06-15 09:33:53 +08:00
|
|
|
|
new ExportExcel(msgProp,null, StringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
2018-06-13 09:58:13 +08:00
|
|
|
|
write(request,response, fileName).dispose();
|
|
|
|
|
|
}else if(dict.getRegionType()==3){
|
|
|
|
|
|
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
|
|
|
|
|
list.add(new ComplexStringCfgTemplate());
|
2018-06-15 09:33:53 +08:00
|
|
|
|
new ExportExcel(msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(msgProp,list,null).
|
2018-06-13 09:58:13 +08:00
|
|
|
|
write(request,response, fileName).dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-13 14:36:58 +08:00
|
|
|
|
|
2018-06-14 10:37:59 +08:00
|
|
|
|
public void setLogAction(BaseLogEntity log) {
|
2018-06-13 14:36:58 +08:00
|
|
|
|
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
2018-06-14 10:37:59 +08:00
|
|
|
|
for (FunctionServiceDict dict : serviceList) {
|
|
|
|
|
|
if (dict.getServiceId().intValue() == log.getServiceType().intValue()) {
|
|
|
|
|
|
log.setAction(dict.getAction());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-13 14:36:58 +08:00
|
|
|
|
}
|
2018-06-14 10:37:59 +08:00
|
|
|
|
|
2018-06-13 16:25:00 +08:00
|
|
|
|
//初始化查询值判断
|
|
|
|
|
|
public void initLogSearchValue(BaseLogEntity entry,Map<String, Object> params){
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())&&StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
|
|
|
|
|
|
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
|
|
|
|
|
|
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
//设置默认查询当前时间及前五分钟
|
2018-06-14 10:37:59 +08:00
|
|
|
|
String endTime = DateUtils.getDateTime();
|
|
|
|
|
|
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_RANGE);
|
|
|
|
|
|
String startTime = DateUtils.formatDateTime(dateStart);
|
2018-06-13 16:25:00 +08:00
|
|
|
|
params.put("searchFoundStartTime", startTime);
|
|
|
|
|
|
params.put("searchFoundEndTime",endTime );
|
|
|
|
|
|
entry.setSearchFoundStartTime(startTime);
|
|
|
|
|
|
entry.setSearchFoundEndTime(endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getProtocol())) {
|
|
|
|
|
|
params.put("searchProtocol", entry.getProtocol());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (entry.getServiceType()!=null) {
|
|
|
|
|
|
params.put("searchServiceType", entry.getServiceType());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getServerIp())) {
|
|
|
|
|
|
params.put("searchServerIp", entry.getServerIp());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getClientIp())) {
|
|
|
|
|
|
params.put("searchClientIp", entry.getClientIp());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(entry.getCljIp())) {
|
|
|
|
|
|
params.put("searchCljIp", entry.getCljIp());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (entry.getDirection()!=null) {
|
|
|
|
|
|
params.put("searchDirection", entry.getDirection());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (entry.getEntranceId()!=null) {
|
|
|
|
|
|
params.put("searchEntranceId", entry.getEntranceId());
|
|
|
|
|
|
}
|
2018-06-20 13:33:46 +08:00
|
|
|
|
if (entry.getCfgId()!=null) {
|
|
|
|
|
|
params.put("searchCfgId", entry.getCfgId());
|
|
|
|
|
|
}
|
2018-06-13 16:25:00 +08:00
|
|
|
|
}
|
2017-12-29 16:18:40 +08:00
|
|
|
|
}
|