2018-07-24 18:45:27 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import java.util.ArrayList;
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import java.util.Calendar;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import java.util.Date;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import java.util.HashMap;
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import java.util.HashSet;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import java.util.List;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import java.util.Map;
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import java.util.Set;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
2018-12-05 17:56:41 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
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.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.configuration.AppPolicyCfg;
|
2018-10-24 18:36:31 +08:00
|
|
|
|
import com.nis.domain.configuration.BaseStringCfg;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import com.nis.domain.configuration.CfgIndexInfo;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.domain.configuration.IpPortCfg;
|
2018-08-22 15:20:14 +08:00
|
|
|
|
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import com.nis.domain.report.NtcPzReport;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import com.nis.domain.specific.ConfigGroupInfo;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
2018-08-22 15:20:14 +08:00
|
|
|
|
import com.nis.exceptions.CallExternalProceduresException;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import com.nis.util.ConfigServiceUtil;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
import com.nis.web.security.UserUtils;
|
|
|
|
|
|
|
2019-01-14 10:52:06 +08:00
|
|
|
|
import net.sf.json.JSONArray;
|
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
import net.sf.json.JsonConfig;
|
|
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 基础协议控制类
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @author wx
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
|
|
|
|
|
@RequestMapping("${adminPath}/basicprotocol")
|
|
|
|
|
|
public class BasicProtocolController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* app策略列表
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @param model
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-21 15:13:48 +08:00
|
|
|
|
@RequestMapping(value = { "list" })
|
|
|
|
|
|
public String policyCfgList(Model model, @ModelAttribute("cfg") AppPolicyCfg cfg, HttpServletRequest request,
|
|
|
|
|
|
HttpServletResponse response) {
|
|
|
|
|
|
Page<AppPolicyCfg> searchPage = new Page<AppPolicyCfg>(request, response, "r");
|
2018-07-24 18:45:27 +08:00
|
|
|
|
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
|
2018-12-21 15:13:48 +08:00
|
|
|
|
// for(AppPolicyCfg entity:page.getList()){
|
|
|
|
|
|
// SpecificServiceCfg app =
|
|
|
|
|
|
// specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
|
|
|
|
|
|
// if(app!=null) {
|
|
|
|
|
|
// entity.setAppName(app.getSpecServiceName());
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
2018-07-24 18:45:27 +08:00
|
|
|
|
model.addAttribute("page", page);
|
2018-12-21 15:13:48 +08:00
|
|
|
|
initPageCondition(model, cfg);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
return "/cfg/basicprotocol/list";
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询APP策略IP子配置
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @param model
|
|
|
|
|
|
* @param cfgId
|
|
|
|
|
|
* @param index
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-21 15:13:48 +08:00
|
|
|
|
@RequestMapping(value = { "ajaxIpList" })
|
|
|
|
|
|
public String ajaxSslSubList(Model model, Long cfgId, Integer index, Integer compileId) {
|
|
|
|
|
|
AppPolicyCfg cfg = appCfgService.getAppPolicyCfg(cfgId, compileId);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
List<String[]> tabList = new ArrayList();
|
2018-12-21 15:13:48 +08:00
|
|
|
|
if (cfg.getIpPortList() != null) {
|
2018-07-24 18:45:27 +08:00
|
|
|
|
String cfgType = null;
|
2018-12-21 15:13:48 +08:00
|
|
|
|
for (IpPortCfg ip : cfg.getIpPortList()) {
|
|
|
|
|
|
if (!ip.getCfgType().equals(cfgType)) {
|
|
|
|
|
|
tabList.add(new String[] { "1", ip.getCfgType() });
|
2018-07-24 18:45:27 +08:00
|
|
|
|
cfgType = ip.getCfgType();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
if (cfg.getNtcSubscribeIdCfgList() != null) {
|
2018-08-22 15:20:14 +08:00
|
|
|
|
String cfgType = null;
|
2018-12-21 15:13:48 +08:00
|
|
|
|
for (NtcSubscribeIdCfg ntc : cfg.getNtcSubscribeIdCfgList()) {
|
|
|
|
|
|
if (!ntc.getCfgType().equals(cfgType)) {
|
|
|
|
|
|
tabList.add(new String[] { "2", ntc.getCfgType() });
|
2018-08-22 15:20:14 +08:00
|
|
|
|
cfgType = ntc.getCfgType();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
model.addAttribute("index", index);
|
|
|
|
|
|
model.addAttribute("tabList", tabList);
|
2018-08-30 19:09:39 +08:00
|
|
|
|
return "/cfg/basicprotocol/basicProtocolSubList";
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置表单
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @param model
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-21 15:13:48 +08:00
|
|
|
|
@RequestMapping(value = { "form" })
|
|
|
|
|
|
@RequiresPermissions(value = { "basicprotocol:config" })
|
|
|
|
|
|
public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) {
|
|
|
|
|
|
if (StringUtils.isNotBlank(ids)) {
|
|
|
|
|
|
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null);
|
|
|
|
|
|
initUpdateFormCondition(model, entity);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
initFormCondition(model, entity);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("_cfg", entity);
|
|
|
|
|
|
return "/cfg/basicprotocol/form";
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置新增修改
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @param model
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-21 15:13:48 +08:00
|
|
|
|
@RequestMapping(value = { "save" })
|
|
|
|
|
|
@RequiresPermissions(value = { "basicprotocol:config" })
|
|
|
|
|
|
public String saveAppPolicyCfg(Model model, HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
|
AppPolicyCfg entity, RedirectAttributes redirectAttributes) {
|
2018-07-24 18:45:27 +08:00
|
|
|
|
try {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
SpecificServiceCfg specificService = specificServiceCfgService
|
|
|
|
|
|
.getBySpecServiceId(entity.getSpecServiceId());
|
|
|
|
|
|
if (specificService != null) {
|
2018-07-24 18:45:27 +08:00
|
|
|
|
entity.setAppCode(specificService.getSpecServiceCode());
|
|
|
|
|
|
}
|
|
|
|
|
|
appCfgService.saveOrUpdateAppPolicyCfg(entity);
|
2018-12-21 15:13:48 +08:00
|
|
|
|
addMessage(redirectAttributes, "success", "save_success");
|
2018-07-24 18:45:27 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-12-21 15:13:48 +08:00
|
|
|
|
logger.error("基础协议信息保存失败", e);
|
|
|
|
|
|
if (e instanceof MaatConvertException) {
|
|
|
|
|
|
// addMessage(redirectAttributes,e.getMessage());
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "request_service_failed");
|
|
|
|
|
|
} else if (e instanceof CallExternalProceduresException) {
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "save_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
|
|
|
|
|
return "redirect:" + adminPath + "/basicprotocol/list?functionId=" + entity.getFunctionId();
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置审核
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @param isAudit
|
|
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-21 15:13:48 +08:00
|
|
|
|
@RequestMapping(value = { "audit" })
|
|
|
|
|
|
@RequiresPermissions(value = { "basicprotocol:confirm" })
|
|
|
|
|
|
public String auditAppPolicyCfg(Model model, @ModelAttribute("cfg") AppPolicyCfg cfg, Integer isValid,
|
|
|
|
|
|
Integer isAudit, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
|
|
|
|
|
HttpServletResponse response, HttpServletRequest request) {
|
|
|
|
|
|
if (!StringUtil.isEmpty(ids)) {
|
2018-12-05 17:56:41 +08:00
|
|
|
|
AppPolicyCfg entity = new AppPolicyCfg();
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
2018-12-21 15:13:48 +08:00
|
|
|
|
for (String id : idArray) {
|
|
|
|
|
|
entity = appCfgService.getAppPolicyCfg(Long.parseLong(id), null);
|
2018-12-05 17:56:41 +08:00
|
|
|
|
entity.setIsAudit(isAudit);
|
|
|
|
|
|
entity.setIsValid(isValid);
|
|
|
|
|
|
entity.setAuditorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setAuditTime(new Date());
|
|
|
|
|
|
entity.setFunctionId(functionId);
|
|
|
|
|
|
entity.setConfigType(Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL);
|
|
|
|
|
|
try {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
appCfgService.auditAppPolicyCfg(entity, isAudit);
|
|
|
|
|
|
addMessage(redirectAttributes, "success", "audit_success");
|
2018-12-05 17:56:41 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
if (e instanceof MaatConvertException) {
|
2018-12-05 17:56:41 +08:00
|
|
|
|
e.printStackTrace();
|
2018-12-21 15:13:48 +08:00
|
|
|
|
logger.info("app策略配置下发失败:" + e.getMessage());
|
|
|
|
|
|
;
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "request_service_failed");
|
|
|
|
|
|
} else {
|
2018-12-05 17:56:41 +08:00
|
|
|
|
e.printStackTrace();
|
2018-12-21 15:13:48 +08:00
|
|
|
|
logger.error("app策略配置下发失败", e);
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "audit_failed");
|
2018-12-05 17:56:41 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-12-05 17:56:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
Page<AppPolicyCfg> searchPage = new Page<AppPolicyCfg>(request, response, "r");
|
|
|
|
|
|
Page<AppPolicyCfg> auditPage = new Page<AppPolicyCfg>(request, response, "r");
|
2018-12-05 17:56:41 +08:00
|
|
|
|
BeanUtils.copyProperties(searchPage, auditPage);
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
try {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
auditAll(auditPage, isValid, cfg);
|
|
|
|
|
|
addMessage(redirectAttributes, "success", "audit_success");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
logger.error("配置下发失败:", e);
|
|
|
|
|
|
if (e instanceof MaatConvertException) {
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "request_service_failed");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "audit_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-12-05 17:56:41 +08:00
|
|
|
|
return policyCfgList(model, cfg, request, response);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
return "redirect:" + adminPath + "/basicprotocol/list?functionId=" + functionId;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置删除
|
2018-12-21 15:13:48 +08:00
|
|
|
|
*
|
2018-07-24 18:45:27 +08:00
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-21 15:13:48 +08:00
|
|
|
|
@RequestMapping(value = { "updateValid" })
|
|
|
|
|
|
@RequiresPermissions(value = { "basicprotocol:config" })
|
|
|
|
|
|
public String updateAppPolicyCfgValid(Integer isValid, String ids, Integer functionId,
|
|
|
|
|
|
RedirectAttributes redirectAttributes) {
|
2018-08-22 15:20:14 +08:00
|
|
|
|
try {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
appCfgService.updateAppPolicyCfgValid(isValid, ids, functionId);
|
|
|
|
|
|
addMessage(redirectAttributes, "success", "delete_success");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-12-21 15:13:48 +08:00
|
|
|
|
logger.error("基础协议信息保存失败", e);
|
|
|
|
|
|
if (e instanceof MaatConvertException) {
|
2018-08-22 15:20:14 +08:00
|
|
|
|
e.printStackTrace();
|
2018-12-21 15:13:48 +08:00
|
|
|
|
addMessage(redirectAttributes, "error", "request_service_failed");
|
|
|
|
|
|
} else if (e instanceof CallExternalProceduresException) {
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
|
|
|
|
|
} else {
|
2018-08-22 15:20:14 +08:00
|
|
|
|
e.printStackTrace();
|
2018-12-21 15:13:48 +08:00
|
|
|
|
addMessage(redirectAttributes, "error", "delete_failed");
|
2018-08-22 15:20:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
return "redirect:" + adminPath + "/basicprotocol/list?functionId=" + functionId;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
|
|
|
|
|
// ip配置导出
|
|
|
|
|
|
@RequestMapping(value = "exportIpAddr")
|
|
|
|
|
|
public void exportIpAddr(Model model, HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
|
@ModelAttribute("cfg") AppPolicyCfg entity, String ids, RedirectAttributes redirectAttributes) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// export data info
|
|
|
|
|
|
List<String> titleList = new ArrayList<String>();
|
|
|
|
|
|
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
|
|
|
|
|
Map<String, List> dataMap = new HashMap<String, List>();
|
|
|
|
|
|
Map<String, String> noExportMap = new HashMap<String, String>();
|
|
|
|
|
|
|
|
|
|
|
|
List<AppPolicyCfg> ipLists = new ArrayList<AppPolicyCfg>();
|
|
|
|
|
|
// 导出选中记录
|
|
|
|
|
|
if (!StringUtil.isEmpty(ids)) {
|
|
|
|
|
|
ipLists = appCfgService.findAppByPolicyList(ids);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
entity.setTableName(IpPortCfg.getTablename());
|
|
|
|
|
|
Page<AppPolicyCfg> pageInfo = new Page<AppPolicyCfg>(request, response, "r");
|
|
|
|
|
|
pageInfo.setPageNo(1);
|
|
|
|
|
|
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
|
|
|
|
|
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(pageInfo, entity);
|
|
|
|
|
|
ipLists = page.getList();
|
|
|
|
|
|
}
|
2019-01-14 10:52:06 +08:00
|
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> logTotals=new ArrayList<Map<String,Object>>();
|
|
|
|
|
|
StringBuilder compileIds=new StringBuilder(",");//配置ids
|
|
|
|
|
|
Set<Integer> set=new HashSet<Integer>();//服务ids
|
2018-12-21 15:13:48 +08:00
|
|
|
|
for (AppPolicyCfg policy : ipLists) {
|
2019-01-14 10:52:06 +08:00
|
|
|
|
if(policy.getIsAudit()!=0){
|
|
|
|
|
|
set.add(policy.getServiceId());
|
|
|
|
|
|
compileIds.append(policy.getCompileId()+",");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
Map<String,Object> logTotal=new HashMap<String,Object>();
|
|
|
|
|
|
logTotal.put("compileId", policy.getCompileId()+"");
|
|
|
|
|
|
logTotal.put("sum",0L);
|
|
|
|
|
|
logTotals.add(logTotal);
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
|
|
|
|
|
|
if (app != null) {
|
|
|
|
|
|
policy.setAppName(app.getSpecServiceName());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2019-01-14 10:52:06 +08:00
|
|
|
|
StringBuilder serviceIds=new StringBuilder(",");
|
|
|
|
|
|
for (Integer id : set) {
|
|
|
|
|
|
serviceIds.append(id+",");
|
|
|
|
|
|
}
|
2019-01-15 21:56:56 +08:00
|
|
|
|
if(serviceIds.length()>1&&compileIds.length()>1){
|
|
|
|
|
|
String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1);
|
|
|
|
|
|
String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1);
|
|
|
|
|
|
//获取日志总量
|
|
|
|
|
|
if(!StringUtils.isBlank(serviceIdsStr)&&!StringUtils.isBlank(compileIdsStr)){
|
|
|
|
|
|
List<Map<String,Object>> logs = getLogTotal( null,serviceIdsStr,compileIdsStr);
|
|
|
|
|
|
logTotals.addAll(logs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
titleList.add(entity.getMenuNameCode());
|
|
|
|
|
|
titleList.add("NTC_IP");
|
|
|
|
|
|
titleList.add("NTC_SUBSCRIBE_ID");
|
|
|
|
|
|
classMap.put(entity.getMenuNameCode(), AppPolicyCfg.class);
|
|
|
|
|
|
classMap.put("NTC_IP", IpPortCfg.class);
|
|
|
|
|
|
classMap.put("NTC_SUBSCRIBE_ID", NtcSubscribeIdCfg.class);
|
2019-01-14 10:52:06 +08:00
|
|
|
|
String cfgIndexInfoNoExport = ",do_blacklist,encrypted_tunnel_behavior,behaviour_type,social_app,behaviour_type,expression_type,match_method,whether_hexbinary,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
2018-12-21 15:13:48 +08:00
|
|
|
|
String ipPortInfoNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
|
|
|
|
|
+ ",config_time,editor,edit_time,auditor,audit_time"
|
|
|
|
|
|
+ ",letter,whether_area_block,classification,attribute,label"
|
|
|
|
|
|
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
|
|
|
|
|
|
String subscribeInfoNoExport = ",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
|
|
|
|
|
|
+ ",config_time,editor,edit_time,auditor,audit_time"
|
|
|
|
|
|
+ ",letter,whether_area_block,classification,attribute,label"
|
|
|
|
|
|
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
|
|
|
|
|
|
|
|
|
|
|
|
// 时间过滤
|
|
|
|
|
|
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
|
|
|
|
|
|
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (entity.getSearch_edit_time_start() == null && entity.getSearch_edit_time_end() == null) {
|
|
|
|
|
|
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (entity.getSearch_audit_time_start() == null && entity.getSearch_audit_time_end() == null) {
|
|
|
|
|
|
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!StringUtil.isEmpty(entity.gethColumns())) {
|
|
|
|
|
|
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
|
2018-10-17 10:36:38 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
|
|
|
|
|
|
noExportMap.put(entity.getMenuNameCode(), cfgIndexInfoNoExport);
|
|
|
|
|
|
noExportMap.put("NTC_IP", ipPortInfoNoExport);
|
|
|
|
|
|
noExportMap.put("NTC_SUBSCRIBE_ID", subscribeInfoNoExport);
|
|
|
|
|
|
List<IpPortCfg> ipList = new ArrayList<IpPortCfg>();
|
|
|
|
|
|
List<BaseStringCfg> subscribeInfoList = new ArrayList<BaseStringCfg>();
|
|
|
|
|
|
for (AppPolicyCfg cfg : ipLists) {
|
2019-01-14 10:52:06 +08:00
|
|
|
|
for (Map<String,Object> logTotal : logTotals) {
|
|
|
|
|
|
if(cfg.getCompileId().equals(Integer.parseInt((String) logTotal.get("compileId")))){
|
|
|
|
|
|
cfg.setTotalLogs((Long)logTotal.get("sum"));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
AppPolicyCfg cfgIndexInfo = appCfgService.exportIpInfo(cfg);
|
|
|
|
|
|
ipList.addAll(cfgIndexInfo.getIpPortList());
|
|
|
|
|
|
subscribeInfoList.addAll(cfgIndexInfo.getNtcSubscribeIdCfgList());
|
|
|
|
|
|
}
|
|
|
|
|
|
subscribeInfoList = BaseStringCfg.baseHexList(subscribeInfoList);
|
|
|
|
|
|
dataMap.put(entity.getMenuNameCode(), ipLists);
|
|
|
|
|
|
dataMap.put("NTC_IP", ipList);
|
|
|
|
|
|
dataMap.put("NTC_SUBSCRIBE_ID", subscribeInfoList);
|
|
|
|
|
|
|
|
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
|
|
|
|
String timeRange = initTimeMap(entity);
|
|
|
|
|
|
noExportMap.put("timeRange", timeRange);
|
|
|
|
|
|
if ("csv".equals(entity.getExType())) {
|
|
|
|
|
|
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
|
|
|
|
|
classMap, dataMap, noExportMap);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
|
|
|
|
|
classMap, dataMap, noExportMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("ip addr export failed", e);
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "export_failed");
|
2018-10-17 10:36:38 +08:00
|
|
|
|
}
|
2018-12-21 15:13:48 +08:00
|
|
|
|
// return "redirect:" + adminPath
|
|
|
|
|
|
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
|
|
|
|
|
}
|
2019-01-14 10:52:06 +08:00
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|