2018-01-09 16:50:39 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import org.springframework.stereotype.Controller;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.ServiceConfigInfo;
|
|
|
|
|
|
import com.nis.domain.SystemServiceInfo;
|
|
|
|
|
|
import com.nis.domain.basics.ServiceDictInfo;
|
|
|
|
|
|
import com.nis.domain.basics.SysDictInfo;
|
|
|
|
|
|
import com.nis.domain.configuration.AppIdCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.RequestInfo;
|
|
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
|
|
|
|
|
import com.nis.util.Constants;
|
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 特定协议相关配置控制类
|
2018-03-29 17:24:21 +08:00
|
|
|
|
* @author zhangwei
|
2018-01-09 16:50:39 +08:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
2018-03-29 17:24:21 +08:00
|
|
|
|
@RequestMapping("${adminPath}/cfg/app")
|
|
|
|
|
|
public class AppCfgController extends BaseController {
|
|
|
|
|
|
@RequestMapping(value = {"list"})
|
|
|
|
|
|
public String cfgList(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")AppIdCfg cfg,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("audit", audit);
|
|
|
|
|
|
if(cfg!=null){
|
|
|
|
|
|
Integer serviceId=cfg.getServiceId();
|
|
|
|
|
|
logger.info("servcice id is "+serviceId);
|
|
|
|
|
|
if(serviceId!=null){
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
List<ServiceConfigInfo> serviceList=serviceConfigInfoService.findList(serviceId);
|
|
|
|
|
|
if(serviceList!=null){
|
|
|
|
|
|
for(ServiceConfigInfo s:serviceList){
|
|
|
|
|
|
if(s.getTableType()==2 || s.getTableType()==4){
|
|
|
|
|
|
model.addAttribute("isContainFeaturesCfg", true);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Page<AppIdCfg> page = appCfgService.findPage(new Page<AppIdCfg>(request, response,"r"), cfg);
|
|
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
model.addAttribute("action", cfg.getAction());
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
|
|
|
|
|
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);
|
|
|
|
|
|
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
|
|
|
|
|
|
specificServiceCfg.setIsValid(1);
|
|
|
|
|
|
model.addAttribute("protocolList",specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg,"spec_service_id DESC"));
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("未获取到正确的serviceId");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "/cfg/appCfgList";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
2018-03-29 17:24:21 +08:00
|
|
|
|
@RequestMapping(value = {"form"})
|
|
|
|
|
|
public String cfgForm(int action,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
model.addAttribute("action", action);
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
logger.info("sercice id is "+serviceId);
|
|
|
|
|
|
|
|
|
|
|
|
// SystemServiceInfo serviceInfo=systemServiceService.get(serviceId);
|
|
|
|
|
|
// model.addAttribute("serviceInfo", serviceInfo);
|
|
|
|
|
|
//来函信息
|
|
|
|
|
|
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);
|
|
|
|
|
|
//特定服务信息
|
|
|
|
|
|
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
|
|
|
|
|
|
specificServiceCfg.setIsValid(1);
|
|
|
|
|
|
model.addAttribute("protocolList",specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg,"spec_service_id DESC"));
|
|
|
|
|
|
//协议特征配置
|
|
|
|
|
|
List<ServiceConfigInfo> featuresList = serviceConfigInfoService.findList(serviceId);
|
|
|
|
|
|
model.addAttribute("featuresList",featuresList);
|
|
|
|
|
|
//特征作用域信息
|
|
|
|
|
|
/*SysDictInfo sysDictInfo = new SysDictInfo();
|
|
|
|
|
|
sysDictInfo.setItemType(3);
|
|
|
|
|
|
Integer[] itType = new Integer[0];
|
|
|
|
|
|
List<SysDictInfo> featuresAreaList = sysDictInfoService.findAllSysDictInfo(sysDictInfo,itType,null);
|
|
|
|
|
|
model.addAttribute("featuresAreaList", featuresAreaList);*/
|
|
|
|
|
|
AppIdCfg cfg = new AppIdCfg();
|
|
|
|
|
|
cfg.initDefaultValue();
|
|
|
|
|
|
cfg.setAction(action);
|
|
|
|
|
|
cfg.setServiceId(serviceId.intValue());
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
|
|
|
|
|
return "/cfg/appCfgForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = {"updateForm"})
|
|
|
|
|
|
public String updateAppCfgForm(int action,long cfgId,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
model.addAttribute("action", action);
|
|
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
|
|
|
|
|
|
|
|
|
|
|
AppIdCfg searchBean=new AppIdCfg();
|
|
|
|
|
|
searchBean.setCfgId(cfgId);
|
|
|
|
|
|
AppIdCfg cfg=appCfgService.getAppCfgById(searchBean);
|
|
|
|
|
|
model.addAttribute("_cfg", 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);
|
|
|
|
|
|
//特定服务信息
|
|
|
|
|
|
SpecificServiceCfg specificServiceCfg = new SpecificServiceCfg();
|
|
|
|
|
|
specificServiceCfg.setIsValid(1);
|
|
|
|
|
|
model.addAttribute("protocolList",specificServiceCfgService.findAllSpecificServiceCfg(specificServiceCfg,"spec_service_id DESC"));
|
|
|
|
|
|
//协议特征配置
|
|
|
|
|
|
List<ServiceConfigInfo> featuresList = serviceConfigInfoService.findList(serviceId);
|
|
|
|
|
|
model.addAttribute("featuresList",featuresList);
|
|
|
|
|
|
return "/cfg/appCfgForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = {"showFeaturesCfg"})
|
|
|
|
|
|
public String showFeaturesCfg(int action,long cfgId,Integer compileId,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response){
|
|
|
|
|
|
AppIdCfg cfg=new AppIdCfg();
|
|
|
|
|
|
cfg.setCfgId(cfgId);
|
|
|
|
|
|
cfg.setCompileId(compileId);
|
|
|
|
|
|
cfg = appCfgService.findAppIdCfg(cfg);
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
model.addAttribute("action", action);
|
|
|
|
|
|
//协议特征配置
|
|
|
|
|
|
List<ServiceConfigInfo> featuresList = serviceConfigInfoService.findList(serviceId);
|
|
|
|
|
|
model.addAttribute("featuresList",featuresList);
|
|
|
|
|
|
return "/cfg/appFeaturesCfg";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* addAppCfg(新增IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"saveOrUpdateCfg"})
|
|
|
|
|
|
public String saveOrUpdateAppCfg(String cfgName,Model model, AppIdCfg cfg) {
|
|
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
|
|
|
|
|
model.addAttribute("cfgType","app");
|
|
|
|
|
|
model.addAttribute("cfgName",cfgName);
|
|
|
|
|
|
model.addAttribute("serviceId",cfg.getServiceId());
|
|
|
|
|
|
model.addAttribute("action",cfg.getAction());
|
|
|
|
|
|
logger.info("saveOrUpdateAppCfg loaded");
|
|
|
|
|
|
if(cfg==null){
|
|
|
|
|
|
logger.error("无法保存空的配置!");
|
|
|
|
|
|
addMessage(model,"保存失败!");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
SpecificServiceCfg protocol = specificServiceCfgService.getBySpecServiceId(cfg.getAppId().intValue());
|
|
|
|
|
|
if(protocol!=null){
|
|
|
|
|
|
cfg.setAppName(protocol.getSpecServiceName());
|
|
|
|
|
|
int serviceId=cfg.getServiceId();
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_NO);
|
|
|
|
|
|
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
|
|
|
|
|
if(cfg.getCfgId()==null){
|
|
|
|
|
|
cfg.setCreatorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setCreateTime(new Date());
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.addAppCfg(cfg);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.error("配置保存失败!"+e.getMessage());
|
|
|
|
|
|
addMessage(model,"保存失败!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
cfg.setEditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setEditTime(new Date());
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.updateAppCfg(cfg);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.error("配置保存失败!"+e.getMessage());
|
|
|
|
|
|
addMessage(model,"保存失败!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("serviceId",serviceId);
|
|
|
|
|
|
model.addAttribute("action",cfg.getAction());
|
|
|
|
|
|
addMessage(model,"保存成功,正在为您跳转页面...");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("所选协议信息无效!");
|
|
|
|
|
|
addMessage(model,"保存失败!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/resultPage";//StringEscapeUtils.escapeHtml4("?serviceId="+cfg.getServiceId()+"&action="+cfg.getAction()+"&cfgName="+cfgName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditAppCfg(审核IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"auditCfg"})
|
|
|
|
|
|
public String auditAppCfg(String cfgName,AppIdCfg cfg,Model model) {
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("audit", Constants.AUDIT_PAGE);
|
|
|
|
|
|
if(cfg==null){
|
|
|
|
|
|
logger.error("无法审核空的配置!");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
int audit=appCfgService.getIsAudit(cfg.getCfgId());
|
|
|
|
|
|
if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){
|
|
|
|
|
|
logger.error("审核通过的配置只能取消审核通过!");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
cfg.setAuditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setAuditTime(new Date());
|
|
|
|
|
|
|
|
|
|
|
|
if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_NO);
|
|
|
|
|
|
}else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_YES);
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
try {
|
|
|
|
|
|
int result=appCfgService.auditAppCfg(cfg);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.error("配置下发maat失败,"+e.getMessage());
|
|
|
|
|
|
addMessage(model,"配置审核下发失败!");
|
|
|
|
|
|
}
|
2018-03-29 17:24:21 +08:00
|
|
|
|
model.addAttribute("serviceId", cfg.getServiceId());
|
|
|
|
|
|
model.addAttribute("action", cfg.getAction());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "redirect:" + adminPath + "/cfg/app/list";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditAppCfg(删除IP配置,逻辑删除)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"deleteCfg"})
|
2018-04-03 11:12:49 +08:00
|
|
|
|
public String deleteAppCfg(int action,long cfgId,Integer compileId,String cfgName,Integer serviceId,Model model) {
|
2018-03-29 17:24:21 +08:00
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("action", action);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
model.addAttribute("cfgType","app");
|
2018-03-29 17:24:21 +08:00
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
|
|
|
|
|
int audit=appCfgService.getIsAudit(cfgId);
|
|
|
|
|
|
//未审核时可删除
|
|
|
|
|
|
if(audit!=Constants.AUDIT_YES){
|
|
|
|
|
|
AppIdCfg cfg=new AppIdCfg();
|
|
|
|
|
|
cfg.setCfgId(cfgId);
|
|
|
|
|
|
cfg.setEditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setEditTime(new Date());
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_DEL);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
cfg.setCompileId(compileId);
|
2018-03-29 17:24:21 +08:00
|
|
|
|
int result=appCfgService.deleteAppCfg(cfg);
|
|
|
|
|
|
addMessage(model,"删除成功,正在为您跳转页面...");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("通过审核的配置不能删除!");
|
|
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/resultPage";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* getCompileId(获取编译ID)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*long
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected Integer getCompileId(BaseCfg cfg){
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2018-01-09 16:50:39 +08:00
|
|
|
|
}
|