diff --git a/src/main/java/com/nis/web/service/basics/SysDictInfoService.java b/src/main/java/com/nis/web/service/basics/SysDictInfoService.java index 74737892e..3b0fb65df 100644 --- a/src/main/java/com/nis/web/service/basics/SysDictInfoService.java +++ b/src/main/java/com/nis/web/service/basics/SysDictInfoService.java @@ -2,7 +2,9 @@ package com.nis.web.service.basics; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -222,104 +224,80 @@ public class SysDictInfoService extends BaseService{ return sysDictInfoDao.getDistrictDict(tableName); } - // 组织区域、运营商配置下发格式 + + /** + * 组织区域、运营商配置下发格式 + * @param areaEffectiveIds + * @return + */ public String setEffectiveRange(String areaEffectiveIds){ - EffectiveRangeCfg rangeCfg = new EffectiveRangeCfg(); - List> effectiveRangeList = new ArrayList(); - - List locaValueList = new ArrayList(); - List ispValueList = new ArrayList(); - + HashMap> map = new HashMap>(); + List ispList = new ArrayList(); for (String areaEffectiveId : StringUtils.split(areaEffectiveIds, ",")) { - List areaIspList = new ArrayList(); - - AreaIsp area = new AreaIsp(); - area.setTag(Constants.AREA_TAG); - AreaIsp isp = new AreaIsp(); - isp.setTag(Constants.ISP_TAG); - String areaStr = ""; - // 区域和运营商 if(areaEffectiveId.contains(":")) { - + // 区域和运营商 int index = areaEffectiveId.indexOf(":"); String areaCode = areaEffectiveId.substring(0, index); String ispCode = areaEffectiveId.substring(index+1); - // 查询该区域信息及其所有父节点信息 - List list = sysDictInfoDao.getEffectiveArea(areaCode); - for (SysDictInfo sysDictInfo : list) { - areaStr += sysDictInfo.getItemValue(); - while(sysDictInfo.getParent().getSysDictId() != 0) { - sysDictInfo = sysDictInfoDao.getDictById(sysDictInfo.getParent().getSysDictId()); - areaStr += "/"+sysDictInfo.getItemValue(); + + if(!map.containsKey(areaCode)){ + ispList = new ArrayList(); + ispList.add(ispCode); + map.put(areaCode, ispList); + }else{ + if(!ispList.contains(ispCode)){ + ispList.add(ispCode); } + map.replace(areaCode, ispList); } - String areaItemValue = StringUtils.revertStr(areaStr, "/"); - if(!locaValueList.contains(areaItemValue)) { - - locaValueList = new ArrayList(); - ispValueList = new ArrayList(); - - locaValueList.add(areaItemValue); - - }else { - // 区域相同就只加运营商信息 - SysDictInfo ispStr = sysDictInfoDao.getDictByItemCode(ispCode); - if(!ispValueList.contains(ispStr.getItemValue())) { - ispValueList.add(ispStr.getItemValue()); - if(ispValueList.size() < 2) { - - isp.setValue(ispValueList); - areaIspList.add(isp); - effectiveRangeList.add(areaIspList); - } - } - continue; - } - - // 查询运营商信息 - SysDictInfo ispStr = sysDictInfoDao.getDictByItemCode(ispCode); - if(!ispValueList.contains(ispStr.getItemValue())) { - ispValueList.add(ispStr.getItemValue()); - } - - area.setValue(locaValueList); - isp.setValue(ispValueList); - - areaIspList.add(area); - areaIspList.add(isp); - effectiveRangeList.add(areaIspList); }else { // 区域 - SysDictInfo dict = sysDictInfoDao.getDictByItemCode(areaEffectiveId); - - // 查询所有父节点区域信息 - areaStr += dict.getItemValue(); - while(dict.getParent().getSysDictId() != 0) { - dict = sysDictInfoDao.getDictById(dict.getParent().getSysDictId()); - areaStr += "/"+dict.getItemValue(); - } - String areaItemValue = StringUtils.revertStr(areaStr, "/"); - if(!locaValueList.contains(areaItemValue)) { - locaValueList = new ArrayList(); - locaValueList.add(areaItemValue); - area.setValue(locaValueList); - areaIspList.add(area); - effectiveRangeList.add(areaIspList); + if(!map.containsKey(areaEffectiveId)){ + map.put(areaEffectiveId, null); } } } - + + EffectiveRangeCfg rangeCfg = new EffectiveRangeCfg(); + List> effectiveRangeList = new ArrayList(); + Set keySet = map.keySet(); + for (String key : keySet) { + AreaIsp area = new AreaIsp(); + area.setTag(Constants.AREA_TAG); + AreaIsp isp = new AreaIsp(); + isp.setTag(Constants.ISP_TAG); + List locaValueList = new ArrayList(); + List ispValueList = new ArrayList(); + List areaIspList = new ArrayList(); + // 获取区域信息 + String areaStr = ""; + SysDictInfo areaDict = sysDictInfoDao.getDictByItemCode(key); + areaStr += areaDict.getItemValue(); + while(areaDict.getParent().getSysDictId() != 0) { + areaDict = sysDictInfoDao.getDictById(areaDict.getParent().getSysDictId()); + areaStr += "/"+areaDict.getItemValue(); + } + locaValueList.add(StringUtils.revertStr(areaStr, "/")); + area.setValue(locaValueList); + areaIspList.add(area); + + // 获取运营商信息 + if(map.get(key) != null){ + for (String ispCode : map.get(key)) { + SysDictInfo ispDict = sysDictInfoDao.getDictByItemCode(ispCode); + ispValueList.add(ispDict.getItemValue()); + } + isp.setValue(ispValueList); + areaIspList.add(isp); + } + effectiveRangeList.add(areaIspList); + + } rangeCfg.setEffectiveRangeList(effectiveRangeList); return gsonToJson(rangeCfg); - } - - public static void main(String[] args) { - SysDictInfoService service = new SysDictInfoService(); - String json = service.setEffectiveRange("7182:4,7182:5"); - System.err.println(json); } } diff --git a/src/main/webapp/WEB-INF/include/form/basicInfo.jsp b/src/main/webapp/WEB-INF/include/form/basicInfo.jsp index 4771854fe..f03ca7ae7 100644 --- a/src/main/webapp/WEB-INF/include/form/basicInfo.jsp +++ b/src/main/webapp/WEB-INF/include/form/basicInfo.jsp @@ -39,9 +39,9 @@ + labelValue="${classifyValue}" labelEmptyValue="0" + title="classification" url="/basics/serviceDictInfo/treeData?itType=1&isShowLeaf=true" notAllowSelectRoot="false" allowClear="true" notAllowSelectParent="false" + checked="true" cssClass="form-control" checkedPS="ps" unCheckedPS="s"/> <%-- > @@ -134,9 +134,9 @@ + labelValue="${lableValue}" labelEmptyValue="0" + title="label" url="/basics/serviceDictInfo/treeData?itType=3&isShowLeaf=true" notAllowSelectRoot="false" allowClear="true" notAllowSelectParent="false" + checked="true" cssClass="form-control" checkedPS="ps" unCheckedPS="s"/> <%-- " data-msg-required="${dataMsgRequired}" placeholder="${(empty value or value eq extId)?labelValue:value}" @@ -45,7 +46,7 @@ return true; } // 正常打开 - top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&selectIds="+$("#${id}Id").val()+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}&title=${title}&enableAddBtn=${enableAddBtn}&enableSearch=${enableSearch}", " ", 320, 420, { + top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&selectIds="+$("#${id}Id").val()+"&module=${module}&checked=${checked}&checkedPS=${checkedPS}&unCheckedPS=${unCheckedPS}&extId=${extId}&isAll=${isAll}&title=${title}&enableAddBtn=${enableAddBtn}&enableSearch=${enableSearch}", " ", 320, 420, { ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"":"ok", "":"clear","":true}, submit:function(v, h, f){ if (v == "ok"){ var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents(); @@ -90,6 +91,11 @@ top.$.jBox.tip("("+nodes[i].name+")"); return false; }// + if("${labelEmptyValue}"&&""!="${labelEmptyValue}"){ + if("${extId}"==nodes[i].id){ + continue; + } + } ids.push(nodes[i].id); // if (nodes[i].id != null ){ @@ -109,7 +115,7 @@ names.push(nodes[i].name); } - }); + }); }// // @@ -119,7 +125,9 @@ break; // 如果为非复选框选择,则返回第一个选择 // } - + if(ids.length==0&&"${labelEmptyValue}"&&""!="${labelEmptyValue}"){ + ids.push("${labelEmptyValue}"); + } $("#${id}Id").val(ids.join(",").replace(/u_/ig,"")); $("#${id}Id").change();//手动触发change事件,使Id的值得变化可以被监听到 $("#${id}Name").val(names.join(",")); @@ -127,7 +135,11 @@ $("#${id}Name").attr("placeholder",""); } }else if (v == "clear"){ - $("#${id}Id").val(""); + if("${labelEmptyValue}"&&""!="${labelEmptyValue}"){ + $("#${id}Id").val("${labelEmptyValue}"); + }else{ + $("#${id}Id").val(""); + } $("#${id}Id").change();//手动触发change事件,使Id的值得变化可以被监听到 $("#${id}Name").val(""); $("#${id}Name").attr("placeholder",""); diff --git a/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp b/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp index c2859f844..1cfc57e5d 100644 --- a/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp +++ b/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp @@ -194,9 +194,18 @@ label.errorShow {
- - + + + + + + + + + +
diff --git a/src/main/webapp/static/global/scripts/common.js b/src/main/webapp/static/global/scripts/common.js index 192d5d99c..a759a1330 100644 --- a/src/main/webapp/static/global/scripts/common.js +++ b/src/main/webapp/static/global/scripts/common.js @@ -539,11 +539,11 @@ $(function(){ } }); - $("#classifyId,#attributeId,#lableId").on("change",function(){ + /*$("#classifyId,#attributeId,#lableId").on("change",function(){ if($(this).val()==0 || $(this).val()==''){ $(this).val(0); } - }); + });*/ //配置修改时已经展开的域上的加号隐藏 $(".boxSolid:visible").each(function(){ $(this).prev("h4").find(".glyphicon-plus").addClass("hidden");