This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/java/com/nis/web/controller/basics/AsnIpController.java
wangxin 85507b5a55 asn 相关修改提交
(1)asn_ip_cfg增加四列
(2)新增asn_group_info表
(3)asn ip菜单移动到policy object下,新增审核审计菜单
(4)asn ip导入修改,适应新的需求放弃了使用AsnCache,直接从数据库查
(5)asn ip加入审核流程
(6)Packet IP选择asn时,改为选中一个组织,审核下发的配置为as号字符串域
(7)asn ip 新增业务新增function_service_dict字典,serviceId为400
2019-01-04 18:28:57 +06:00

270 lines
11 KiB
Java

package com.nis.web.controller.basics;
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 javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.exceptions.MaatConvertException;
//import com.nis.util.AsnCacheUtils;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import jersey.repackaged.com.google.common.collect.Lists;
@Controller
@RequestMapping(value = "${adminPath}/basics/asn")
public class AsnIpController extends BaseController{
@RequestMapping(value = {"/list"})
public String list(Model model,HttpServletRequest request
,HttpServletResponse response,@ModelAttribute("cfg")AsnIpCfg entity
){
Page<AsnIpCfg> page = asnIpCfgService.findPage(new Page<AsnIpCfg>(request, response,"r"), entity);
model.addAttribute("page", page);
// initPageCondition(model);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
model.addAttribute("regionList", regionList);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
model.addAttribute("serviceList", serviceList);
return "/basics/asnIpCfgList";
}
@RequestMapping(value = {"/addForm"})
public String addForm(Model model,HttpServletRequest request
,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg
,RedirectAttributes redirectAttributes){
initFormCondition(model,cfg);
List<ConfigGroupInfo> groupInfos=configGroupInfoService.findAllList(4);
model.addAttribute("policyGroups", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/asnIpCfgFormAdd";
}
@RequestMapping(value = {"/updateForm"})
public String updateForm(Model model,HttpServletRequest request
,HttpServletResponse response,String ids,@ModelAttribute("cfg")AsnIpCfg cfg
,RedirectAttributes redirectAttributes){
cfg = asnIpCfgService.get(Long.parseLong(ids));
initUpdateFormCondition(model, cfg);
List<ConfigGroupInfo> groupInfos=configGroupInfoService.findAllList(4);
model.addAttribute("policyGroups", groupInfos);
model.addAttribute("_cfg", cfg);
return "/basics/asnIpCfgFormUpdate";
}
@RequestMapping(value = {"/save"})
@RequiresPermissions(value={"asn:ip:config"})
public String save(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes){
try{
asnIpCfgService.saveAsnIpCfg(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/update"})
@RequiresPermissions(value={"asn:ip:config"})
public String update(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")AsnIpCfg cfg,RedirectAttributes redirectAttributes){
try{
asnIpCfgService.update(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
addMessage(redirectAttributes,"error","save_failed");
}
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/audit"})
@RequiresPermissions(value={"asn:ip:confirm"})
public String audit(Model model,@ModelAttribute("cfg")AsnIpCfg cfg
,Integer isAudit
,Integer isValid
,String ids
,Integer functionId
, HttpServletRequest request
,HttpServletResponse response
,RedirectAttributes redirectAttributes) {
//选中配置审核
if(!StringUtil.isEmpty(ids)) {
List<AsnIpCfg> asnIps=asnIpCfgService.getByIds(ids);
Map<Long,List<AsnIpCfg>> asnIpMap=Maps.newHashMap();
for(AsnIpCfg asnIpCfg:asnIps) {
asnIpCfg.setIsAudit(isAudit);
asnIpCfg.setIsValid(isValid);
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
asnIpCfg.setAuditTime(new Date());
asnIpCfg.setFunctionId(functionId);
if(asnIpMap.containsKey(Long.parseLong(asnIpCfg.getUserRegion1()))) {
asnIpMap.get(Long.parseLong(asnIpCfg.getUserRegion1())).add(asnIpCfg);
}else {
List<AsnIpCfg> _asnIps=Lists.newArrayList();
_asnIps.add(asnIpCfg);
asnIpMap.put(Long.parseLong(asnIpCfg.getUserRegion1()), _asnIps);
}
}
asnIpCfgService.auditIpBatch(asnIpMap,isValid);
}/*else {
//条件下所有配置审核
Page<AsnIpCfg> searchPage=new Page<AsnIpCfg>(request,response,"a");
Page<AsnIpCfg> auditPage=new Page<AsnIpCfg>(request,response,"a");
BeanUtils.copyProperties(searchPage, auditPage);
try {
auditAll(auditPage,isValid , cfg);
addMessage(redirectAttributes,"success", "audit_success");
} catch (Exception e) {
logger.error("配置下发失败:",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error", "request_service_failed");
}else {
addMessage(redirectAttributes,"error", "audit_failed");
}
}
return list(model, request, response, cfg);
}*/
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"/delete"})
@RequiresPermissions(value={"asn:ip:config"})
public String delete(Integer isValid
,String ids,Integer functionId
,RedirectAttributes redirectAttributes){
try{
asnIpCfgService.delete(ids);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error",e.getMessage());
}else {
addMessage(redirectAttributes,"error","delete_failed");
}
}
return "redirect:" + adminPath +"/basics/asn/list?functionId="+functionId;
}
@RequestMapping(value = {"/ajaxDeleteAsnIp"})
public void ajaxDeleteAsnIp(String ids, HttpServletRequest request, HttpServletResponse response){
try{
asnIpCfgService.ajaxDeleteAsnIp(ids);
}catch(Exception e){
logger.error("Delete failed",e);
}
}
@RequestMapping(value="ajaxGetGroups",method=RequestMethod.POST)
@ResponseBody
public List<AsnGroupInfo> ajaxGetGroups(Model model,@RequestParam(required=true,value="org")String org){
if(StringUtils.isNotBlank(org)) {
return asnGroupInfoService.getByOrg(org);
}
return new ArrayList<AsnGroupInfo>();
}
@RequestMapping(value="ajaxIsLast",method=RequestMethod.POST)
@ResponseBody
public boolean ajaxIsLast(Model model,@RequestParam(required=true,value="serviceGroupIds")String serviceGroupIds,@RequestParam(required=true,value="ids")String ids){
if(StringUtils.isNotBlank(serviceGroupIds)&&StringUtils.isNotBlank(ids)) {
return asnIpCfgService.hasLastIp(serviceGroupIds,ids);
}
return false;
}
//asnIp配置导出
@RequestMapping(value = "exportAsnIp")
public void exportAsnIp(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")AsnIpCfg 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<AsnIpCfg> list = new ArrayList<AsnIpCfg>();
if (!StringUtil.isEmpty(ids)) {
list = asnIpCfgService.findByPage(ids);
} else {
Page<AsnIpCfg> pageInfo=new Page<AsnIpCfg>(request, response,"r");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<AsnIpCfg> page = asnIpCfgService.findPage(pageInfo, entity);
list=page.getList();
}
for (AsnIpCfg asnIp : list) {
asnIp.setIsIssued(String.valueOf(asnIp.getIsValid()));
}
titleList.add(entity.getMenuNameCode());
classMap.put(entity.getMenuNameCode(), AsnIpCfg.class);
String cfgIndexInfoNoExport=",block_type,do_log,action,valid_identifier,is_audit"
+ ",auditor,audit_time,letter,whether_area_block,classification,attribute,label"
+",userregion2,userregion3,userregion4,userregion5,ir_type,group_name,&userregion1:asn_no-";
// 时间过滤
if (entity.getSearch_create_time_start() == null ) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
dataMap.put(entity.getMenuNameCode(), list);
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("asnIp export failed",e);
addMessage(redirectAttributes,"error","export_failed");
}
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
}
}