您的位置:首页 > Web前端 > JQuery

jquery 切换 行是否显示

2014-03-03 16:22 197 查看
<%@ taglib prefix="s" uri="/struts-tags"%>

<%@ page contentType="text/html; charset=UTF-8"%>

<%@ taglib prefix="page" uri="/WEB-INF/tlds/paginated.tld"%>

<%@ include file="../common/language.jsp"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title><s:text name="msg.portalMS.siteMgr.list"/>——<s:text name="msg.portalMS.siteMgr.add"/></title>

<link href="../style/base.css" rel="stylesheet" type="text/css" />

<%@ include file="../common/commonJS.jsp" %>

<script type="text/javascript" src="../js/Calendar/WdatePicker.js"></script>

<script type="text/javascript" src="../js/jquery.js"></script>

<script type="text/javascript" src="../jsCBB/jquery.js"></script>

<script type="text/javascript" src="../js/dialogShow.js"></script>

<script type="text/javascript" src="../js/jquery.validate.js"></script>

<script type="text/javascript" src="../js/ex.jquery.validate.js"></script>

<script type="text/javascript" src="../js/ext/adapter/ext/ext-base.js"></script>

<script type="text/javascript" src="../js/ext/ext-all.js"></script>

<script type="text/javascript">

//防重复提交按键功能

var timerID;

function activethis(){

     timerID=setTimeout('document.getElementById("showButton").disabled=false',1000);

     $("#showButton").submit();

}

    jQuery(document).ready(function() {

    

        $("#tr_system").hide();

        $( "#siteName" ).focus();

        ////ajax提交表单

        $.validator.setDefaults({   

              submitHandler: function(form) {

        

              //恢复提交按键功能

              clearTimeout(timerID);

              document.getElementById("showButton").disabled=true;

              var system="";

              $('input[type="checkbox"][name="systems"]:checked').each(function(){    

                  system=system +","+ $(this).val();    

              });

            Ext.Ajax.request({

                  timeout: 100000,//超时时间100秒

                  url:'../Site/checkSystem.action',

                  params:{'id':system},

                  success: function(_response, action) {

                      if(_response.responseText=='ok'){

                            showConfirmAndCancel('<s:text name="msg.portalMS.page.message.tip"/>','<s:text name="msg.portalMS.sitemgr.businessSystem.submit.confirm" />',form);

                          }

                      else if(_response.responseText=='null'){

                          showText('<s:text name="msg.portalMS.page.message.tip"/>','<s:text name="msg.portalMS.sitemgr.businessSystem.noSelected" />',400,200,0,true);

                      }

                      else{

                            showText('<s:text name="msg.portalMS.page.message.tip"/>','<s:text name="msg.portalMS.sitemgr.businessSystem.error" />',400,200,0,true);

                          }

            

                    //恢复提交按键功能

                    document.getElementById("showButton").disabled=false;

                  },

                  failure: function(_response, action) {

                      var reqst=_response.status;        // 根据返回的状态码值判断是否超时

                      if(reqst=='-1'){                  // 超时的状态码为 -1

                          showText('<s:text name="msg.portalMS.page.message.tip"/>','<s:text name="msg.portalMS.sitemgr.businessSystem.timeout" />',400,200,0,true);

                        }

                      else

                      {

                          showText('<s:text name="msg.portalMS.page.message.tip"/>','<s:text name="msg.portalMS.failured.message.tip" />',400,200,0,true);

                      }    

                    //恢复提交按键功能

                    document.getElementById("showButton").disabled=false;                      

                     }

                  });    

            }   

        });

        $("#addIepg").validate({

            rules: {

                "iepgSiteVO.name":{

                            required: true,

                            regexMatch: "^[a-zA-Z0-9_]+$",

                            checkNameIepg:true,

                            minlength:4,

                            maxlength:30

                    },

                "iepgSiteVO.alias":{

                        required: true,

                        regexMatch: "^([\\w\\s\u4e00-\u9fa5]+)$",

                        checkAliasIepg:true,

                        minlength:2,

                        maxlength:30

                },

                "iepgSiteVO.context":{

                    required: true,

                    regexMatch: "^[a-zA-Z0-9_]+$",

                    checkContext:true,

                    minlength:1,

                    maxlength:10

                },

                "iepgSiteVO.remark":{

                    required: true,

                    minlength:1,

                    maxlength:50

                }

            },

            messages: {        

                "iepgSiteVO.name":{

                            required: '<s:text name="msg.portalMS.sitemgr.name.required" />',

                            regexMatch: '<s:text name="msg.portalMS.sitemgr.name.validate" />',

                            minlength: '<s:text name="msg.portalMS.sitemgr.name.length" />',

                            maxlength: '<s:text name="msg.portalMS.sitemgr.name.length" />'

                    },

                "iepgSiteVO.alias":{

                        required: '<s:text name="msg.portalMS.sitemgr.alias.required" />',

                        regexMatch: '<s:text name="msg.portalMS.sitemgr.alias.validate" />',

                        minlength: '<s:text name="msg.portalMS.sitemgr.alias.length" />',

                        maxlength: '<s:text name="msg.portalMS.sitemgr.alias.length" />'

                },

                "iepgSiteVO.context":{

                        required: '<s:text name="msg.portalMS.sitemgr.context.required" />',

                        regexMatch: '<s:text name="msg.portalMS.sitemgr.context.validate" />',

                        minlength: '<s:text name="msg.portalMS.sitemgr.context.length" />',

                        maxlength: '<s:text name="msg.portalMS.sitemgr.context.length" />'

                    },

                "iepgSiteVO.remark":{

                    required: '<s:text name="msg.portalMS.sitemgr.remark.required" />',

                    minlength: '<s:text name="msg.portalMS.sitemgr.remark.length" />',

                    maxlength: '<s:text name="msg.portalMS.sitemgr.remark.length" />'

                }

                

                

            },

            errorPlacement: function(error, element) {

                

                error.appendTo( element.parent() );

            }   

        });    

            

    });

    //ajax校验名称

    $.validator.addMethod("checkNameIepg",function(name){

        var result = true;

        $.ajax({

             cache:false,   

             async:false,           

             type:"POST",

                url: "../Site/checkNameIepg.action",    

                data: "iepgSiteVO.name="+name,

             success: function(checkFlag){

               if(checkFlag=='false'){

                  result = false;

                }else{

                  result = true;

                }     

               //恢复提交按键功能

               document.getElementById("showButton").disabled=false;

             } ,

             error: function(){

               //恢复提交按键功能

               document.getElementById("showButton").disabled=false;

              }        

               });

               return result;  

    },'<font color="red"><s:text name="msg.portalMS.iepg.siteName.existed" /></font>');

    //ajax校验别名

    $.validator.addMethod("checkAliasIepg",function(alias){

        var result = true;

        $.ajax({

             cache:false,   

             async:false,           

             type:"POST",

                url: "../Site/checkAliasIepg.action",    

                data: "iepgSiteVO.alias="+alias,

             success: function(checkFlag){

               if(checkFlag=='false'){

                  result = false;

                }else{

                  result = true;

                }

               //恢复提交按键功能

               document.getElementById("showButton").disabled=false;    

             } ,

             error: function(){

               //恢复提交按键功能

               document.getElementById("showButton").disabled=false;

              }      

               });

               return result;  

    },'<font color="red"><s:text name="msg.portalMS.iepg.siteAlias.existed" /></font>');

    //ajax校验上下文

    $.validator.addMethod("checkContext",function(context){

        var result = true;

        $.ajax({

             cache:false,   

             async:false,           

             type:"POST",

                url: "../Site/checkContext.action",    

                data: "iepgSiteVO.context="+context,

             success: function(checkFlag){

               if(checkFlag=='false'){

                  result = false;

                }else{

                  result = true;

                }

               //恢复提交按键功能

               document.getElementById("showButton").disabled=false;            

             } ,

             error: function(){

               //恢复提交按键功能

               document.getElementById("showButton").disabled=false;

              }      

               });

               return result;  

    },'<font color="red"><s:text name="msg.portalMS.iepg.siteContext.existed" /></font>');

    

    //两个radioButton间的切换(高清、标清)

    function chooseRadio(){

        var radioNameList = document.getElementsByName("iepgSiteVO.videoType");

        if(radioNameList[0].checked){

            return false;

        }else{

            radioNameList[0].checked

            }

         if(radioNameList[1].checked){

            return false;

        }else{

            radioNameList[1].checked

            }

    }

    //返回站点列表

    function queryIepg(){

        var url = "queryIepg.action?queryFlag=true";

        window.location=url;

    }

    //选中业务系统要显示业务系统对应的系统名称

    function changeDisplay(){

           var systemList;

           var id="";

           var isShow=false;

           var div=document.getElementById("businessSys");

           var ckb=document.getElementsByTagName("INPUT");

           var div1=document.getElementById("div_systm");

            var ckb1=document.getElementsByTagName("INPUT");  

           for(i=0;i <ckb.length;i++)

           {   //业务系统

               if(ckb[i].type== "checkbox"&& ckb[i].parentNode==div)  

               //业务系统被勾选

               if(ckb[i].checked)

               {

               alert(id=id+","+ckb[i].id   );

                    id=id+","+ckb[i].id;   

                    isShow=true;

               }

          }    

          if(isShow)

          {   //如果业务系统有值被勾选 则显示  同步系统名称

              $("#tr_system").show();  

              //根据业务系统ID 查询所配置的同步系统

              var url='../Site/readBussinessSystem.action?ts=' + new Date().getTime()+'&id='+id;

              //通过ajax 查询 同步系统

                 $.getJSON(url, null, function(data){        

                 systemList = data.sysList;

                

              //同步系统

              for(j=0;j <ckb1.length;j++)

              {  

                  if(ckb1[j].type== "checkbox"&& ckb1[j].parentNode==div1){

                  //$(ckb1[j]).removeAttr( "checked" );

                  $(ckb1[j]).hide();

                  var t =$(ckb1[j]).attr('logo');

                        $('#sys'+t).hide();

                        }

              }

              //属于 系统的同步系统则显示

              for(j=0;j <ckb1.length;j++)

              {  

                   if(ckb1[j].type== "checkbox"&& ckb1[j].parentNode==div1)  

                   {

                       for (var q= 0; q < systemList.length; q++)

                             {

                                       if(systemList[q] == ($(ckb1[j]).attr("logo")))

                                       {  

                                           $(ckb1[j]).show();

                                           var t =$(ckb1[j]).attr('logo');

                                        $('#sys'+t).show();

                                       }

                                       

                             }

                       if ($(ckb1[j]).is(":hidden"))

                                   {

                                       $(ckb1[j]).removeAttr( "checked" );

                                   }

                   }

              }

               });

          }

          else

          {//没选中则隐藏  同步系统

               $("#tr_system").hide();

               for(j=0;j <ckb1.length;j++)

                {  if(ckb1[j].type== "checkbox"&& ckb1[j].parentNode==div1){

                       $(ckb1[j]).removeAttr( "checked" );

                    }

                }

              

          }

    }

    

</script>

</head>

<body>

<s:form action="addIepg" theme="simple" onsubmit="return false;" validate="false" namespace="/Site" >

<div class="r_main">

  <!---导航 --->

  <div class="r_nav">

    <div class="left"><img src="../images/nav_l.gif" width="5" height="29" /></div>

    <div class="ct"><s:text name="msg.portalMS.system.current.position"/><s:text name="msg.portalMS.publishmgr.label.site.manage"/> > <s:text name="msg.portalMS.siteMgr.list"/> > <s:text name="msg.portalMS.siteMgr.add"/></div>

    <div class="right"><img src="../images/nav_r.jpg" width="5" height="29" /></div>

  </div>

  <!---主体 --->

  <div  class="info_tit">

    <div class="left"><s:text name="msg.portalMS.siteMgr.add"/></div>

  </div>

  <div  class="page_tb">

    <table width="100%" border="0" cellpadding="0" cellspacing="0"  class="in_table long">

      <tr>

        <td class="col1 must"><s:text name="msg.portalMS.sitemgr.name"/><s:text name="msg.portalMS.colon.label"/></td>

        <td width="84%">

            <s:textfield name="iepgSiteVO.name" theme="simple" id="siteName"/>

            <s:if test='%{action != "toAdd"}'>

            <s:fielderror fieldName="iepgSiteVO.siteName" cssStyle="color:red" theme="simple"/>

            </s:if>

            <font color='gray'> <s:text name="msg.portalMS.sitemgr.name.validate" /></font>

        </td>

      </tr>

      <tr class="bule">

        <td class="col1 must1"><s:text name="msg.portalMS.sitemgr.aliasName"/><s:text name="msg.portalMS.colon.label"/></td>

        <td width="84%">

            <s:textfield name="iepgSiteVO.alias" theme="simple" id="aliasName"/>

            <s:if test='%{action != "toAdd"}'>

            <s:fielderror fieldName="iepgSiteVO.aliasName" cssStyle="color:red" theme="simple"/>

            </s:if>

            <font color='gray'> <s:text name="msg.portalMS.sitemgr.alias.validate" /></font>

        </td>

      </tr>

      <tr>

        <td class="col1 must"><s:text name="msg.portalMS.resource.videoType"/><s:text name="msg.portalMS.colon.label"/></td>

        <td width="84%">

        <s:radio name="iepgSiteVO.videoType" list="#{'0':getText('msg.portalMS.resource.videoType.0'),'1':getText('msg.portalMS.resource.videoType.1')}" listKey="key" listValue="value" value="1" onclick="chooseRadio()"></s:radio>

            <s:if test='%{action != "toAdd"}'>

            <s:fielderror fieldName="iepgSiteVO.videoType" cssStyle="color:red" theme="simple"/>

            </s:if>

        </td>

      </tr>

     <tr class="blue">

     <td class="col1 must1" valign="middle"><s:text name="msg.portalMS.sitemgr.context.businessSystem"/><s:text name="msg.portalMS.colon.label"/>

     </td>

    

     <td style="background-color:#e9f0f9">

       <div id='businessSys'>

         <s:iterator value="bussinessSystemList" id="bussinessSystem" status="i">

             <input type="checkbox"  name="bussinessSystems" value="<s:property value="#bussinessSystem" />" id="<s:property value="#bussinessSystem"/>"

             onclick="changeDisplay()"/>

             <span><s:property value="#bussinessSystem"/></span>

         </s:iterator>

     </div>

     </td>

     </tr>   

    

     <tr id="tr_system">

     <td class="col1 must2" valign="middle"><s:text name="msg.portalMS.sitemgr.sncy.businessSystem"/><s:text name="msg.portalMS.colon.label"/>

     </td>

     <td>

     <div id="div_systm">

     <s:iterator value="systemsList" id="system" status="i">

       <input type="checkbox" name="systems" value="<s:property value="#system" />" logo="<s:property value="#system"/>"

       /><span id="sys<s:property value="#system"/>"><s:property value="#system"/></span>

             </s:iterator></div>

    </td>

     </tr>

    

      <tr>

        <td class="col1 must2" valign="middle"><s:text name="msg.portalMS.sitemgr.context"/><s:text name="msg.portalMS.colon.label"/></td>

        <td width="84%">

            <s:textfield name="iepgSiteVO.context" theme="simple" id="context"/>

            <s:if test='%{action != "toAdd"}'>

            <s:fielderror fieldName="iepgSiteVO.context" cssStyle="color:red" theme="simple"/>

            </s:if>

            <font color='gray'> <s:text name="msg.portalMS.sitemgr.context.validate" /></font><br/>

            <font color='gray'><s:text name="msg.portalMS.iepg.siteContext.desc" /></font>

        </td>

      </tr>

      <tr class="blue">

        <td width="205" class="col1 must3" valign="middle"><s:text name="msg.portalMS.sitemgr.remark"/><s:text name="msg.portalMS.colon.label"/></td>

        <td width="84%" style="background-color:#e9f0f9">

            <s:textarea name="iepgSiteVO.remark" theme="simple" rows="10" id="remark" cssClass="m_g text_eara"/><br/>

            <s:if test='%{action != "toAdd"}'>

            <s:fielderror fieldName="iepgSiteVO.remark" cssStyle="color:red" theme="simple"/>

            </s:if>

        </td>

      </tr>

      </table>

        <div class="info">

          <input type="submit" id="showButton" onclick="this.disabled=true;activethis();"  value="<s:text name="msg.portalMS.system.ok"/>"/>

          <!--<button name="addIepg"><s:text name="msg.portalMS.system.ok"/></button>-->

          <input type="button" onclick="queryIepg();setTimeout(function(){load()},tipTime);" value="<s:text name="msg.portalMS.system.goBack"/>"/>

        </div>

  </div>

</div>

</s:form>

</body>
</html>

   

sitemanage.xml

    <action name="readBussinessSystem" class="springSiteMgrAction" method="readBussinessSystem">

            <result name="sysList" type="json"></result>

    </action>

SiteMgrAction.java    

    /**

     * AJAX加载获取业务系统对应的同步系统名称

     */

    public String readBussinessSystem()

    {

        Set<String> set = new HashSet<String>();

        String[] systemStr = id.split(SerConstants.COMMA);

        // 当i=0的时候会为空所以要去掉。

        for (int i = 1; i < systemStr.length; i++)

        {

            List<String> systemList = XMLFactory.getValueList("uif.site." + systemStr[i]);

            for (String stringStr : systemList)

            {

                set.add(stringStr);

            }

        }

        sysList = new ArrayList<String>();

        sysList.addAll(set);

        return "sysList";

    }    

     <!-- ===================== 同步系统名称配置  Configure the sync system name======================== -->

  <uif>

    <site>

      <bussinessSystem>VOD</bussinessSystem>  

      <value>VOD</value>  

      <!-- 多个系统用逗号隔开

           Separate the systems with comma -->

      <VOD>SDPAdapter,IAG,Portal</VOD>

    </site>  

    <site>

      <bussinessSystem>OTT</bussinessSystem>  

      <value>OTT</value>  

      <OTT>OTT</OTT>

    </site>  

 </uif>

    /**

     * 获取配置文件中业务系统的信息

     */

    private static List<String> readSite()

    {

        List<String> bussinessSystemList = XMLFactory.getValueList("uif.site.bussinessSystem");

        return bussinessSystemList;

    }

    /**

     * 获取配置文件中同步系统名称的信息

     * @return

     */

    private static List<String> readSystems()

    {

        List<String> bussinessSystemsList = readSite();

        List<String> systemsList = new ArrayList<String>();

        Set<String> set = new HashSet<String>();

        for (String bussinessSystem : bussinessSystemsList)

        {

            List<String> systemList = XMLFactory.getValueList("uif.site." + bussinessSystem);

            for (String system : systemList)

            {

                set.add(system);

            }

        }

        systemsList.addAll(set);

        return systemsList;

    }

    

    

    

package com.coship.dhm.portalMS.site.web.action;

import java.io.IOException;

import java.io.Serializable;

import java.util.ArrayList;

import java.util.HashSet;

import java.util.List;

import java.util.Map;

import java.util.Set;

import org.apache.commons.lang.StringUtils;

import com.xxxxxx.dhm.common.config.impl.XMLFactory;

import com.xxxxxx.dhm.portalMS.base.web.action.BaseAction;

import com.xxxxxx.dhm.portalMS.common.Constants;

import com.xxxxxx.dhm.portalMS.common.SerConstants;

import com.xxxxxx.dhm.portalMS.common.util.FormBeanUtil;

import com.xxxxxx.dhm.portalMS.common.util.PageList;

import com.xxxxxx.dhm.portalMS.common.util.ShelfUtil;

import com.xxxxxx.dhm.portalMS.common.util.StringUtil;

import com.xxxxxx.dhm.portalMS.resource.entity.Category;

import com.xxxxxx.dhm.portalMS.site.entity.Site;

import com.xxxxxx.dhm.portalMS.site.service.ISiteService;

import com.xxxxxx.dhm.portalMS.sync.util.BaseSyncHelper;

import com.xxxxxx.dhm.portalMS.sync.util.SiteSyncHelper;

import com.xxxxxx.sdp.rights.model.domain.Admin;

import com.opensymphony.xwork2.ActionContext;

/**

 * ClassName:SiteMgrAction

 */

/**

 * 新增站点、编辑站点、删除站点、查看站点列表、切换站点Action

*/

@SuppressWarnings("unchecked")

public class SiteMgrAction extends BaseAction

{

    /**

     * 注释内容

     */

    private static final long serialVersionUID = 7556672003083594183L;

    /**有站点权限,页面显示.*/

    private static final String SHOW = "1";

    /* 从配置文件业务系统 */

    private List<String> bussinessSystemList = readSite();

    private List<String> systemsList = readSystems();

    private Site site;

    private PageList<Serializable> sites;

    private List<Long> siteIDs;

    /** 用于树的展现 */

    private String nodesString;

    private ISiteService siteService;

    private Site iepgSiteVO;

    private String[] systems;

    private String[] bussinessSystems;

    private String id;

    /**

     * 删除iEPG的id数组

     */

    private Long[] iepgIDs;

    private ArrayList<String> sysList;

    private Boolean checkFlag = Boolean.valueOf(true);

    private String errorMessage;

    private ActionContext actionContext = ActionContext.getContext();

    private Map<String, Object> session = actionContext.getSession();

    public String queryIepg() throws Exception

    {

        // 获取分页信息

        iepgSiteVO = (Site) getQueryInfo(queryFlag, iepgSiteVO);

        this.pager = this.siteService.findByCriteria(iepgSiteVO, currentPage, pageSize);

        if (pager.size() == 0 && pager.getTotalRows() > 0)

        {

            // 如果查询的pager为空

            changeCurrentPage(pager);

            this.pager = this.siteService.findByCriteria(iepgSiteVO, currentPage, pageSize);

        }

        // 保存分页信息

        setQueryInfo(iepgSiteVO);

        rankSite();

        return SUCCESS;

    }

    /**

     * 将当前站点排在第一位

     */

    private void rankSite()

    {

        // 设置业务数据权限,判断是否有站点的权限.

        String businessExp = (String) session.get(SerConstants.PERMISSION_SITE);

        String[] siteIds = null;

        if (StringUtils.isNotEmpty(businessExp))

        {

            siteIds = businessExp.split(SerConstants.COMMA);

        }

        int size = pager.size();

        if (size >= 1)

        {

            for (int i = 0; i < size; i++)

            {

                Site iepgSite = (Site) pager.get(i);

                if (session.get(Constants.CURRENT_SITE_ID.getStringValue()).equals(iepgSite.getSiteID()))

                {

                    pager.remove(i);

                    pager.add(0, iepgSite);

                }

                // 如果有站点的权限,设置显示状态为1.

                if (null == siteIds || isContentSite(siteIds, iepgSite.getSiteID().toString()))

                {

                    iepgSite.setDisabled(SHOW);

                }

            }

        }

    }

    /**

     * 判断是否有该站点的权限.

     * @param siteIds

     * @param site

     * @return

     */

    private boolean isContentSite(String[] siteIds, String site)

    {

        if (null == siteIds || siteIds.length <= 0)

        {

            return false;

        }

        for (int i = 0; i < siteIds.length; i++)

        {

            if (siteIds[i].equals(site))

            {

                return true;

            }

        }

        return false;

    }

    public String findIepg() throws Exception

    {

        return queryIepg();

    }

    /**

     * 新增站点

     * @return

     * @throws Exception

     */

    public String addIepg() throws Exception

    {

        if ("toAdd".equals(this.action))

        {

            return INPUT;

        }

        FormBeanUtil.stripStringProperty(iepgSiteVO);

        Admin loginUser = getAdmin();

        // 设置创建人id

        iepgSiteVO.setUpdater(loginUser.getId().longValue());

        if (null == siteService)

        {

            return ERROR;

        }

        StringBuffer sbSystem = getMessage(systems);

        StringBuffer sbBussinessSystems = getMessage(bussinessSystems);

        this.iepgSiteVO.setBusinessSystem(sbBussinessSystems.toString().substring(0, sbBussinessSystems.length() - 1)

                .toString());

        this.iepgSiteVO.setSyncSystemName(sbSystem.toString().substring(0, sbSystem.length() - 1).toString());

        iepgSiteVO.setCityId(loginUser.getCity().getCityId());

        siteService.saveEntity(this.iepgSiteVO);

        // 新增站点的时候会新增栏目所以需要同步

        List<String> systemNameList = new ArrayList<String>();

        String[] syncSystemName = iepgSiteVO.getSyncSystemName().split(SerConstants.COMMA);

        for (String system : syncSystemName)

        {

            systemNameList.add(system);

        }

        if (BaseSyncHelper.isNeedDistribute())

        {

            // 新增站点同步,如果需要同步给地市可以修改相应的底层方法

            SiteSyncHelper.syncSite(this.iepgSiteVO);

        }

        List<Category> categoryList = siteService.findCategoryBySite(iepgSiteVO);

        if (null != categoryList && categoryList.size() > 0)

        {

            for (Category cate : categoryList)

            {

                ShelfUtil.andOrUpdateColumnInformation(Constants.SYNC_CLOUMN.getStringValue(), cate, systemNameList,

                        SerConstants.CREATE);

            }

        }

        // 设置返回url

        // 操作成功,提示成功消息并记录操作日志

        String operateDesc = getText(Constants.MSG_PORTALMS + "siteMgr.add") + getText(Constants.MSG_PORTALMS+"colon.label") + iepgSiteVO;

        setSuccessInfo("operate.code.webmgr.add.iepg", operateDesc);

        return SUCCESS;

    }

    /**

     * 获取配置文件中业务系统的信息

     */

    private static List<String> readSite()

    {

        List<String> bussinessSystemList = XMLFactory.getValueList("uif.site.bussinessSystem");

        return bussinessSystemList;

    }

    /**

     * 获取配置文件中同步系统名称的信息

     * @return

     */

    private static List<String> readSystems()

    {

        List<String> bussinessSystemsList = readSite();

        List<String> systemsList = new ArrayList<String>();

        Set<String> set = new HashSet<String>();

        for (String bussinessSystem : bussinessSystemsList)

        {

            List<String> systemList = XMLFactory.getValueList("uif.site." + bussinessSystem);

            for (String system : systemList)

            {

                set.add(system);

            }

        }

        systemsList.addAll(set);

        return systemsList;

    }

    /**

     * 将前台传回的数据进行封装

     * @return

     */

    private StringBuffer getMessage(String[] strString)

    {

        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < strString.length; i++)

        {

            sb.append(strString[i]);

            sb.append(SerConstants.COMMA);

        }

        return sb;

    }

    /**

     * 删除站点信息

     * @return

     * @throws Exception

     */

    public String deleteIepg() throws Exception

    {

        if (iepgIDs == null || iepgIDs.length == 0)

        {

            // 页面请求有误,没有将参数传递进来

            errorMessage = getText(Constants.MSG_PORTALMS+"system.page.request.error");

            return ERROR;

        }

        siteService.deleteIepg(iepgIDs);

        if (BaseSyncHelper.isNeedDistribute())

        {

            SiteSyncHelper.deleteSite(iepgIDs);

        }

        // 操作成功,提示成功消息并记录操作日志

        String operateDesc = getText(Constants.MSG_PORTALMS + "message.delete.success") + StringUtil.getIdsAsString(iepgIDs);

        setSuccessInfo("operate.code.webmgr.delete.iepg", operateDesc);

        return SUCCESS;

    }

    /**

     * 修改站点信息

     * @return

     * @throws Exception

     */

    public String updateIepg() throws Exception

    {

        if ("toUpdate".equals(this.action))

        {

            iepgSiteVO = (Site) siteService.findById(iepgSiteVO.getSiteID());

            return INPUT;

        }

        FormBeanUtil.stripStringProperty(iepgSiteVO);

        Site updateSite = (Site) siteService.findById(iepgSiteVO.getSiteID());

        if (null == updateSite)

        {

            // 记录不存在

            errorMessage = getText(Constants.MSG_PORTALMS + "system.record.exist");

            return ERROR;

        }

        Admin loginUser = getAdmin();

        // 设置修改人

        iepgSiteVO.setUpdater(loginUser.getId().longValue());

        // 修改iEPG

        siteService.updateIepg(iepgSiteVO);

        iepgSiteVO.setSyncSystemName(updateSite.getSyncSystemName());

        iepgSiteVO.setBusinessSystem(updateSite.getBusinessSystem());

        if (BaseSyncHelper.isNeedDistribute())

        {

            // 修改站点同步,同步给地市

            SiteSyncHelper.syncSite(this.iepgSiteVO);

        }

        String operateDesc = getText(Constants.MSG_PORTALMS + "siteMgr.modify") + getText(Constants.MSG_PORTALMS+"colon.label") + iepgSiteVO;

        setSuccessInfo("operate.code.webmgr.update.iepg", operateDesc);

        return SUCCESS;

    }

    /**

     * 查询站点详情

     * @return

     * @throws Exception

     */

    public String viewSite() throws Exception

    {

        if (this.iepgSiteVO == null)

        {

            // 记录不存在

            errorMessage = getText(Constants.MSG_PORTALMS + "system.record.not.exist");

            return ERROR;

        }

        this.iepgSiteVO = (Site) this.siteService.findById(this.iepgSiteVO.getSiteID());

        return SUCCESS;

    }

    /**

     * 分页查询站点

     * @return

     * @throws Exception

     */

    public String findAllValidateSites() throws Exception

    {

        this.pager = this.siteService.findAllValidateSites(this.currentPage, this.pageSize);

        rankSite();

        return SUCCESS;

    }

    /**

     * 切换站点

     * @return

     * @throws Exception

     */

    public String switchSite() throws Exception

    {

        if (session.get(Constants.CURRENT_SITE_ID.getStringValue()) != null)

        {

            session.remove(Constants.CURRENT_SITE_ID.getStringValue());

        }

        session.put(Constants.CURRENT_SITE_ID.getStringValue(), site.getSiteID());

        Site currentSite = (Site) this.siteService.findById(site.getSiteID());

        if (session.get("currentSite") != null)

        {

            session.remove("currentSite");

        }

        session.put("currentSite", currentSite);

        // 设置返回url

        String operateDesc = getText(Constants.MSG_PORTALMS + "iepg.site.change") + getText(Constants.MSG_PORTALMS+"colon.label") + site.getSiteID();

        setSuccessInfo("operate.code.webmgr.switch.iepg", operateDesc);

        return SUCCESS;

    }

    /**

     *

     * @return

     * @throws Exception

     */

    public String reSetSite() throws Exception

    {

        iepgSiteVO.setStatus(Constants.IEPG_SITE_STATUS.getByteValue());

        Admin loginUser = getAdmin();

        // 设置修改人

        iepgSiteVO.setUpdater(loginUser.getId().longValue());

        // 修改iEPG

        siteService.updateIepg(this.iepgSiteVO);

        // 设置返回url

        this.showSuccessDialog = Constants.SUCCEED.getStringValue();

        String operateDesc = getText(Constants.MSG_PORTALMS + "sitemgr.reset") + getText(Constants.MSG_PORTALMS+"colon.label") + iepgSiteVO.getSiteID();

        setSuccessInfo("operate.code.webmgr.reset.iepg", operateDesc);

        return SUCCESS;

    }

    /**

     * AJAX加载获取业务系统对应的同步系统名称

     */

    public String readBussinessSystem()

    {

        Set<String> set = new HashSet<String>();

        String[] systemStr = id.split(SerConstants.COMMA);

        // 当i=0的时候会为空所以要去掉。

        for (int i = 1; i < systemStr.length; i++)

        {

            List<String> systemList = XMLFactory.getValueList("uif.site." + systemStr[i]);

            for (String stringStr : systemList)

            {

                set.add(stringStr);

            }

        }

        sysList = new ArrayList<String>();

        sysList.addAll(set);

        return "sysList";

    }

    /**

     * Ajax校验同步系统名称是否存在

     * @throws IOException

     */

    public void checkSystem() throws IOException

    {

        if (id == "" || id.equals(""))

        {

            this.getHttpServletResponse().getWriter().print("null");

        }

        else

        {

            List<String> valueList = XMLFactory.getValueList("uif.mule_endpoint.endpoint.name");

            String[] systemStr = id.split(SerConstants.COMMA);

            int count = 0;

            for (int i = 1; i < systemStr.length; i++)

            {

                for (String stringStr : valueList)

                {

                    if (stringStr.equals(systemStr[i]))

                    {

                        count++;

                        continue;

                    }

                }

            }

            if (count == systemStr.length - 1)

            {

                this.getHttpServletResponse().getWriter().print("ok");

            }

            else

            {

                this.getHttpServletResponse().getWriter().print("error");

            }

        }

    }

    /**

     * Ajax校验站点名称是否已存在

     * @return

     */

    public String checkNameIepg()

    {

        try

        {

            FormBeanUtil.stripStringProperty(iepgSiteVO);

            int rowCountName = siteService.findSameNameIepgCount(iepgSiteVO);

            if (rowCountName > 0)

            {

                this.checkFlag = Boolean.valueOf(false);

            }

        }

        catch (Exception e)

        {

            return "error";

        }

        return "success";

    }

    /**

     * Ajax校验站点别名是否已存在

     * @return

     */

    public String checkAliasIepg()

    {

        try

        {

            FormBeanUtil.stripStringProperty(iepgSiteVO);

            int rowCountAlias = siteService.findSameAliasIepgCount(iepgSiteVO);

            if (rowCountAlias > 0)

            {

                this.checkFlag = Boolean.valueOf(false);

            }

        }

        catch (Exception e)

        {

            return "error";

        }

        return "success";

    }

    /**

     * Ajax校验站点上下文是否已存在

     * @return

     */

    public String checkContext()

    {

        try

        {

            FormBeanUtil.stripStringProperty(iepgSiteVO);

            int rowContext = siteService.findSamContext(iepgSiteVO);

            if (rowContext > 0)

            {

                this.checkFlag = Boolean.valueOf(false);

            }

        }

        catch (Exception e)

        {

            return "error";

        }

        return "success";

    }

    /**

     * @param 对portalMSanageService进行赋值

     */

    public void setSiteService(ISiteService siteService)

    {

        this.siteService = siteService;

    }

    /**

     * @return 返回 iepgSiteVO

     */

    public Site getIepgSiteVO()

    {

        return iepgSiteVO;

    }

    /**

     * @param 对iepgSiteVO进行赋值

     */

    public void setIepgSiteVO(Site iepgSiteVO)

    {

        this.iepgSiteVO = iepgSiteVO;

    }

    /**

     * @return 返回 iepgIDs

     */

    public Long[] getIepgIDs()

    {

        Long[] temp = iepgIDs;

        return temp;

    }

    /**

     * @param 对iepgIDs进行赋值

     */

    public void setIepgIDs(Long[] iepgIDs)

    {

        this.iepgIDs = (Long[]) iepgIDs.clone();

    }

    public Site getSite()

    {

        return site;

    }

    public void setSite(Site site)

    {

        this.site = site;

    }

    /**

     * @return 返回 sites

     */

    public PageList<Serializable> getSites()

    {

        return sites;

    }

    /**

     * @param 对sites进行赋值

     */

    public void setSites(PageList<Serializable> sites)

    {

        this.sites = sites;

    }

    public List<Long> getSiteIDs()

    {

        return siteIDs;

    }

    public void setSiteIDs(List<Long> siteIDs)

    {

        this.siteIDs = siteIDs;

    }

    public String getNodesString()

    {

        return nodesString;

    }

    public void setNodesString(String nodesString)

    {

        this.nodesString = nodesString;

    }

    public String[] getSystems()

    {

        String[] temp = systems;

        return temp;

    }

    public void setSystems(String[] systems)

    {

        this.systems = (String[]) systems.clone();

    }

    public ArrayList<String> getSysList()

    {

        return sysList;

    }

    public void setSysList(ArrayList<String> sysList)

    {

        this.sysList = sysList;

    }

    public List<String> getBussinessSystemList()

    {

        return bussinessSystemList;

    }

    public void setBussinessSystemList(List<String> bussinessSystemList)

    {

        this.bussinessSystemList = bussinessSystemList;

    }

    public List<String> getSystemsList()

    {

        return systemsList;

    }

    public void setSystemsList(List<String> systemsList)

    {

        this.systemsList = systemsList;

    }

    public String[] getBussinessSystems()

    {

        String[] temp = bussinessSystems;

        return temp;

    }

    public void setBussinessSystems(String[] bussinessSystems)

    {

        this.bussinessSystems = (String[]) bussinessSystems.clone();

    }

    public String getId()

    {

        return id;

    }

    public void setId(String id)

    {

        this.id = id;

    }

    public Boolean getCheckFlag()

    {

        return checkFlag;

    }

    public void setCheckFlag(Boolean checkFlag)

    {

        this.checkFlag = checkFlag;

    }

    public String getErrorMessage()

    {

        return errorMessage;

    }

    public void setErrorMessage(String errorMessage)

    {

        this.errorMessage = errorMessage;

    }

}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: