2018-02-27 15:31:30 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
import java.util.Date;
|
2018-04-10 10:42:24 +08:00
|
|
|
|
import java.util.List;
|
2018-02-27 15:31:30 +08:00
|
|
|
|
|
|
|
|
|
|
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-04-10 10:42:24 +08:00
|
|
|
|
import com.nis.domain.configuration.AreaIpCfg;
|
2018-02-27 15:31:30 +08:00
|
|
|
|
import com.nis.domain.configuration.BaseStringCfg;
|
|
|
|
|
|
import com.nis.util.Constants;
|
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 字符串相关配置控制类
|
|
|
|
|
|
* @author dell
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
|
|
|
|
|
@RequestMapping("${adminPath}/cfg/string")
|
|
|
|
|
|
public class StringCfgController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"list"})
|
2018-03-07 17:47:30 +08:00
|
|
|
|
public String stringCfgList(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")BaseStringCfg stringCfg,HttpServletRequest request,HttpServletResponse response) {
|
2018-02-27 15:31:30 +08:00
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", audit);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
if(stringCfg!=null){
|
|
|
|
|
|
Integer serviceId=stringCfg.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);
|
|
|
|
|
|
stringCfg.setTableName(tableName);
|
2018-03-12 15:22:52 +08:00
|
|
|
|
Page<BaseStringCfg> page = stringCfgService.findPage(new Page<BaseStringCfg>(request,response,"r"), stringCfg);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
model.addAttribute("action", stringCfg.getAction());
|
|
|
|
|
|
model.addAttribute("tableName", tableName);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
initPageCondition(model);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("未获取到正确的serviceId");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/stringCfgList";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"form"})
|
|
|
|
|
|
public String stringCfgForm(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-27 15:31:30 +08:00
|
|
|
|
logger.info("sercice id is "+serviceId);
|
|
|
|
|
|
if(serviceId!=null){
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
String tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
if(!StringUtils.isBlank(tableName)){
|
|
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
String className=stringCfgService.getClassName(tableName);
|
|
|
|
|
|
logger.info("class name is "+className);
|
|
|
|
|
|
String packageName=BaseStringCfg.class.getPackage().getName();
|
|
|
|
|
|
try {
|
|
|
|
|
|
//通过反射获得BaseStringCfg的子类的实例,并调用子类的initDefaultValue初始化默认值
|
|
|
|
|
|
Class clazz=Class.forName(packageName+"."+className);
|
|
|
|
|
|
BaseStringCfg stringcfg=(BaseStringCfg)clazz.newInstance();
|
|
|
|
|
|
stringcfg.setTableName(tableName);
|
|
|
|
|
|
stringcfg.initDefaultValue();
|
|
|
|
|
|
stringcfg.setAction(action);
|
2018-04-08 16:15:06 +08:00
|
|
|
|
//监测缺省不需要区域管控
|
|
|
|
|
|
if(action==Constants.ACTION_DJ){
|
|
|
|
|
|
stringcfg.setIsAreaEffective(0);
|
|
|
|
|
|
}
|
2018-02-27 15:31:30 +08:00
|
|
|
|
stringcfg.setServiceId(serviceId);
|
|
|
|
|
|
model.addAttribute("_cfg", stringcfg);
|
|
|
|
|
|
model.addAttribute("tableName", tableName);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
initFormCondition(model);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
logger.error("打开新增IP窗口失败",e);
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logger.error("未获取到正确的serviceId");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "/cfg/stringCfgForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = {"updateForm"})
|
2018-04-09 16:38:45 +08:00
|
|
|
|
public String updateStringCfgForm(String tableName,int action,long cfgId,String cfgName,Integer serviceId,Model model) {
|
2018-02-27 15:31:30 +08:00
|
|
|
|
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-27 15:31:30 +08:00
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
BaseStringCfg searchBean=new BaseStringCfg();
|
|
|
|
|
|
searchBean.setCfgId(cfgId);
|
|
|
|
|
|
searchBean.setTableName(tableName);
|
|
|
|
|
|
BaseStringCfg stringCfg=stringCfgService.getStringCfgById(searchBean);
|
|
|
|
|
|
model.addAttribute("_cfg", stringCfg);
|
2018-04-09 16:38:45 +08:00
|
|
|
|
model.addAttribute("tableName", tableName);
|
|
|
|
|
|
initUpdateFormCondition(model,stringCfg);
|
|
|
|
|
|
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger.error("发生异常",e);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/stringCfgForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* addStringCfg(新增IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"saveOrUpdateCfg"})
|
2018-04-09 16:38:45 +08:00
|
|
|
|
public String saveOrUpdateStringCfg(String cfgName,Model model, BaseStringCfg stringCfg,String areaCfgIds) {
|
2018-02-27 15:31:30 +08:00
|
|
|
|
model.addAttribute("cfgName",cfgName);
|
|
|
|
|
|
model.addAttribute("cfgType","string");
|
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",stringCfg.getServiceId());
|
|
|
|
|
|
model.addAttribute("action",stringCfg.getAction());
|
2018-02-27 15:31:30 +08:00
|
|
|
|
logger.info("saveOrUpdateStringCfg loaded");
|
2018-03-26 14:43:58 +08:00
|
|
|
|
try{
|
2018-04-09 16:38:45 +08:00
|
|
|
|
setSaveOrUpdateProps(model,stringCfg,areaCfgIds);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger.error("保存失败!",e);
|
2018-04-08 16:27:47 +08:00
|
|
|
|
addMessage(model,"save_failed");
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
return "/cfg/resultPage";
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditStringCfg(审核IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"auditCfg"})
|
|
|
|
|
|
public String auditStringCfg(String cfgName,BaseStringCfg stringCfg,Model model) {
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.AUDIT_PAGE);
|
2018-03-27 16:00:07 +08:00
|
|
|
|
model.addAttribute("cfgType","string");
|
2018-03-26 14:43:58 +08:00
|
|
|
|
model.addAttribute("serviceId", stringCfg.getServiceId());
|
|
|
|
|
|
model.addAttribute("action", stringCfg.getAction());
|
|
|
|
|
|
try{
|
|
|
|
|
|
String tableName=stringCfg.getTableName();
|
|
|
|
|
|
int serviceId=stringCfg.getServiceId();
|
|
|
|
|
|
String maatTable=null;
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
if(StringUtils.isBlank(tableName)){
|
|
|
|
|
|
tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
stringCfg.setTableName(tableName);
|
|
|
|
|
|
}
|
|
|
|
|
|
maatTable=serviceConfigInfo.getMaatTable();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BaseStringCfg bean=stringCfgService.getStringCfgById(stringCfg);
|
|
|
|
|
|
bean.setTableName(tableName);
|
|
|
|
|
|
int audit=bean.getIsAudit().intValue();
|
2018-02-27 15:31:30 +08:00
|
|
|
|
if(audit==Constants.AUDIT_YES&&stringCfg.getIsAudit()!=Constants.AUDIT_NOT_YES){
|
|
|
|
|
|
logger.error("审核通过的配置只能取消审核通过!");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
stringCfg.setAuditorId(stringCfg.getCurrentUser().getId());
|
|
|
|
|
|
stringCfg.setAuditTime(new Date());
|
2018-03-26 14:43:58 +08:00
|
|
|
|
bean.setIsAudit(stringCfg.getIsAudit());
|
2018-02-27 15:31:30 +08:00
|
|
|
|
if(stringCfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
|
|
|
|
|
stringCfg.setIsValid(Constants.VALID_NO);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
bean.setIsValid(Constants.VALID_NO);
|
|
|
|
|
|
bean.setMaatTable(maatTable);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}else if(stringCfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1
|
|
|
|
|
|
stringCfg.setIsValid(Constants.VALID_YES);
|
2018-03-26 14:43:58 +08:00
|
|
|
|
bean.setIsValid(Constants.VALID_YES);
|
2018-03-27 14:42:22 +08:00
|
|
|
|
bean.setMaatTable(maatTable);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
int result=stringCfgService.auditStringCfg(bean,stringCfg);
|
|
|
|
|
|
if(result!=0){
|
2018-04-08 16:27:47 +08:00
|
|
|
|
addMessage(model,"audit_success");
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}else{
|
2018-04-08 16:27:47 +08:00
|
|
|
|
addMessage(model,"audit_failed");
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger.error("审核失败", e);
|
2018-04-08 16:27:47 +08:00
|
|
|
|
addMessage(model,"audit_failed");
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
2018-03-27 16:00:07 +08:00
|
|
|
|
return "/cfg/resultPage";
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditStringCfg(删除IP配置,逻辑删除)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"deleteCfg"})
|
2018-04-10 10:42:24 +08:00
|
|
|
|
public String deleteStringCfg(String tableName,int action,long cfgId,int compileId,String cfgName,Integer serviceId,Model model) {
|
2018-02-27 15:31:30 +08:00
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
model.addAttribute("cfgName", cfgName);
|
|
|
|
|
|
model.addAttribute("action", action);
|
|
|
|
|
|
model.addAttribute("cfgType","string");
|
2018-03-07 11:30:37 +08:00
|
|
|
|
model.addAttribute("audit", Constants.CFG_PAGE);
|
2018-04-10 10:42:24 +08:00
|
|
|
|
|
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-04-10 10:42:24 +08:00
|
|
|
|
model.addAttribute("tableName", tableName);
|
2018-02-27 15:31:30 +08:00
|
|
|
|
int audit=stringCfgService.getIsAudit(tableName,cfgId);
|
2018-04-10 10:42:24 +08:00
|
|
|
|
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(compileId);
|
|
|
|
|
|
if(areaCfg!=null&&areaCfg.size()>0){
|
|
|
|
|
|
for(AreaIpCfg c:areaCfg){
|
|
|
|
|
|
c.setTableName(AreaIpCfg.getTablename());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-27 15:31:30 +08:00
|
|
|
|
//未审核时可删除
|
2018-04-10 10:42:24 +08:00
|
|
|
|
if(audit!=Constants.AUDIT_YES&&audit!=Constants.AUDIT_NOT_YES){
|
2018-02-27 15:31:30 +08:00
|
|
|
|
BaseStringCfg stringCfg=new BaseStringCfg();
|
|
|
|
|
|
stringCfg.setCfgId(cfgId);
|
|
|
|
|
|
stringCfg.setTableName(tableName);
|
|
|
|
|
|
stringCfg.setEditorId(stringCfg.getCurrentUser().getId());
|
|
|
|
|
|
stringCfg.setEditTime(new Date());
|
|
|
|
|
|
stringCfg.setIsValid(Constants.VALID_DEL);
|
2018-04-10 10:42:24 +08:00
|
|
|
|
int result=stringCfgService.deleteStringCfg(stringCfg, areaCfg);
|
|
|
|
|
|
if(result==0){
|
|
|
|
|
|
addMessage(model,"delete_failed");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
addMessage(model,"delete_success");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}else{
|
2018-04-10 10:42:24 +08:00
|
|
|
|
logger.error("通过审核/取消审核通过的配置不能删除!");
|
|
|
|
|
|
addMessage(model,"delete_failed");
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-26 14:43:58 +08:00
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
logger.error("删除失败",e);
|
2018-04-08 16:27:47 +08:00
|
|
|
|
addMessage(model,"delete_failed");
|
2018-02-27 15:31:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
return "/cfg/resultPage";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|