2018-02-28 12:15:52 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
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 com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.ServiceConfigInfo;
|
2018-03-26 14:43:58 +08:00
|
|
|
|
import com.nis.domain.basics.ServiceDictInfo;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
2018-02-28 12:15:52 +08:00
|
|
|
|
import com.nis.domain.configuration.ComplexkeywordCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.RequestInfo;
|
2018-03-26 14:43:58 +08:00
|
|
|
|
import com.nis.main.ConvertTool;
|
2018-02-28 12:15:52 +08:00
|
|
|
|
import com.nis.util.Constants;
|
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 增强字符串相关配置控制类
|
|
|
|
|
|
* @author dell
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
|
|
|
|
|
@RequestMapping("${adminPath}/cfg/complex")
|
|
|
|
|
|
public class ComplexStringCfgController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"list"})
|
2018-03-07 17:47:30 +08:00
|
|
|
|
public String cfgList(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")ComplexkeywordCfg cfg,HttpServletRequest request,HttpServletResponse response) {
|
2018-02-28 12:15:52 +08:00
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", audit);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
if(cfg!=null){
|
|
|
|
|
|
Integer serviceId=cfg.getServiceId();
|
|
|
|
|
|
logger.info("servcice id is "+serviceId);
|
|
|
|
|
|
if(serviceId!=null){
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
String tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
if(!StringUtils.isBlank(tableName)){
|
|
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
cfg.setTableName(tableName);
|
2018-03-12 16:34:55 +08:00
|
|
|
|
Page<ComplexkeywordCfg> page = complexStringCfgService.findPage(new Page<ComplexkeywordCfg>(request, response,"r"), cfg);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
model.addAttribute("action", cfg.getAction());
|
|
|
|
|
|
model.addAttribute("tableName", tableName);
|
|
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
|
|
|
|
|
|
model.addAttribute("requestInfos", requestInfos);
|
2018-03-05 16:30:16 +08:00
|
|
|
|
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
model.addAttribute("fls", fls);
|
2018-03-05 16:30:16 +08:00
|
|
|
|
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
model.addAttribute("xzs", xzs);
|
2018-03-05 16:30:16 +08:00
|
|
|
|
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
model.addAttribute("lables", lables);
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("未获取到正确的serviceId");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "/cfg/complexCfgList";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"form"})
|
|
|
|
|
|
public String cfgForm(int action,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("action", action);
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
logger.info("sercice id is "+serviceId);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
String tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
if(!StringUtils.isBlank(tableName)){
|
|
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
String className=complexStringCfgService.getClassName(tableName);
|
|
|
|
|
|
logger.info("class name is "+className);
|
|
|
|
|
|
String packageName=ComplexkeywordCfg.class.getPackage().getName();
|
|
|
|
|
|
try {
|
|
|
|
|
|
//通过反射获得ComplexkeywordCfg的子类的实例,并调用子类的initDefaultValue初始化默认值
|
|
|
|
|
|
Class clazz=Class.forName(packageName+"."+className);
|
|
|
|
|
|
ComplexkeywordCfg cfg=(ComplexkeywordCfg)clazz.newInstance();
|
|
|
|
|
|
cfg.setTableName(tableName);
|
|
|
|
|
|
cfg.initDefaultValue();
|
|
|
|
|
|
cfg.setAction(action);
|
|
|
|
|
|
cfg.setServiceId(serviceId);
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
|
|
|
|
|
model.addAttribute("tableName", tableName);
|
|
|
|
|
|
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);
|
|
|
|
|
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
logger.error("打开新增IP窗口失败",e);
|
|
|
|
|
|
e.printStackTrace();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/complexCfgForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = {"updateForm"})
|
|
|
|
|
|
public String updateStringCfgForm(String tableName,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("tableName", tableName);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
try{
|
|
|
|
|
|
if(StringUtils.isBlank(tableName)){
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-28 12:15:52 +08:00
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
ComplexkeywordCfg searchBean=new ComplexkeywordCfg();
|
|
|
|
|
|
searchBean.setCfgId(cfgId);
|
|
|
|
|
|
searchBean.setTableName(tableName);
|
|
|
|
|
|
ComplexkeywordCfg cfg=complexStringCfgService.getStringCfgById(searchBean);
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
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-03-26 14:43:58 +08:00
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
logger.error("发生异常", e);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/complexCfgForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* addStringCfg(新增IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"saveOrUpdateCfg"})
|
|
|
|
|
|
public String saveOrUpdateStringCfg(String cfgName,Model model, ComplexkeywordCfg cfg) {
|
|
|
|
|
|
model.addAttribute("cfgName",cfgName);
|
|
|
|
|
|
model.addAttribute("cfgType","complex");
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
model.addAttribute("serviceId",cfg.getServiceId());
|
|
|
|
|
|
model.addAttribute("action",cfg.getAction());
|
2018-02-28 12:15:52 +08:00
|
|
|
|
logger.info("saveOrUpdateStringCfg loaded");
|
2018-03-26 14:43:58 +08:00
|
|
|
|
try {
|
|
|
|
|
|
String tableName=cfg.getTableName();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
int serviceId=cfg.getServiceId();
|
2018-03-26 14:43:58 +08:00
|
|
|
|
if(StringUtils.isBlank(cfg.getTableName())){
|
|
|
|
|
|
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
cfg.setTableName(tableName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
int compileId = new ConvertTool().getCompileId();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
cfg.setIsValid(Constants.VALID_NO);
|
|
|
|
|
|
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
|
|
|
|
|
cfg.setCompileId(compileId);
|
|
|
|
|
|
if(cfg.getCfgId()==null){
|
|
|
|
|
|
cfg.setCreatorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setCreateTime(new Date());
|
|
|
|
|
|
complexStringCfgService.addStringCfg(cfg);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
cfg.setEditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setEditTime(new Date());
|
|
|
|
|
|
complexStringCfgService.updateStringCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
addMessage(model,"保存成功,正在为您跳转页面...");
|
2018-03-26 14:43:58 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
logger.error("保存失败!",e);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
addMessage(model,"保存失败!");
|
|
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
return "/cfg/resultPage";
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditStringCfg(审核IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"auditCfg"})
|
|
|
|
|
|
public String auditStringCfg(String cfgName,ComplexkeywordCfg cfg,Model model) {
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.AUDIT_PAGE);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
model.addAttribute("serviceId", cfg.getServiceId());
|
|
|
|
|
|
model.addAttribute("action", cfg.getAction());
|
|
|
|
|
|
try{
|
|
|
|
|
|
String tableName=cfg.getTableName();
|
|
|
|
|
|
String maatTable=null;
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(cfg.getServiceId());
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
if(StringUtils.isBlank(tableName)){
|
|
|
|
|
|
tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
cfg.setTableName(tableName);
|
|
|
|
|
|
}
|
|
|
|
|
|
maatTable=serviceConfigInfo.getMaatTable();
|
|
|
|
|
|
}
|
|
|
|
|
|
ComplexkeywordCfg bean=complexStringCfgService.getStringCfgById(cfg);
|
|
|
|
|
|
bean.setTableName(tableName);
|
|
|
|
|
|
int audit=bean.getIsAudit().intValue();
|
2018-02-28 12:15:52 +08:00
|
|
|
|
if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){
|
|
|
|
|
|
logger.error("审核通过的配置只能取消审核通过!");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
cfg.setAuditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setAuditTime(new Date());
|
2018-03-26 14:43:58 +08:00
|
|
|
|
bean.setIsAudit(cfg.getIsAudit());
|
2018-02-28 12:15:52 +08:00
|
|
|
|
if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_NO);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
bean.setIsValid(Constants.VALID_NO);
|
|
|
|
|
|
bean.setMaatTable(maatTable);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_YES);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
bean.setIsValid(Constants.VALID_YES);
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
int result=complexStringCfgService.auditStringCfg(bean,cfg);
|
|
|
|
|
|
if(result!=0){
|
|
|
|
|
|
addMessage(model,"审核成功!");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
addMessage(model,"审核失败!");
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
logger.error("发生异常",e);
|
|
|
|
|
|
addMessage(model,"审核失败!");
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
2018-03-07 17:47:30 +08:00
|
|
|
|
return "redirect:" + adminPath + "/cfg/complex/list";
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditStringCfg(删除IP配置,逻辑删除)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"deleteCfg"})
|
|
|
|
|
|
public String deleteStringCfg(String tableName,int action,long cfgId,String cfgName,Integer serviceId,Model model) {
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("action", action);
|
|
|
|
|
|
model.addAttribute("cfgType","complex");
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
try{
|
|
|
|
|
|
if(StringUtils.isBlank(tableName)){
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-28 12:15:52 +08:00
|
|
|
|
int audit=complexStringCfgService.getIsAudit(tableName,cfgId);
|
|
|
|
|
|
//未审核时可删除
|
|
|
|
|
|
if(audit!=Constants.AUDIT_YES){
|
|
|
|
|
|
ComplexkeywordCfg cfg=new ComplexkeywordCfg();
|
|
|
|
|
|
cfg.setCfgId(cfgId);
|
|
|
|
|
|
cfg.setTableName(tableName);
|
|
|
|
|
|
cfg.setEditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setEditTime(new Date());
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_DEL);
|
|
|
|
|
|
int result=complexStringCfgService.deleteStringCfg(cfg);
|
|
|
|
|
|
addMessage(model,"删除成功,正在为您跳转页面...");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("通过审核的配置不能删除!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
logger.error("删除失败", e);
|
|
|
|
|
|
addMessage(model,"删除失败!");
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/resultPage";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* getCompileId(获取编译ID)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*long
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
2018-03-26 14:43:58 +08:00
|
|
|
|
protected long getCompileId(ComplexkeywordCfg cfg){
|
|
|
|
|
|
long compileId=0l;
|
|
|
|
|
|
try {
|
|
|
|
|
|
compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
return compileId;
|
2018-02-28 12:15:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|