zhoufan %!s(int64=6) %!d(string=před) měsíci
rodič
revize
537f4d01da

+ 47 - 45
midware-service/src/main/java/midware/service/rep/impl/IvrServiceImpl.java

@@ -103,52 +103,54 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
103 103
 
104 104
     //处理ivr
105 105
     private void dealIvr(Ivr entity){
106
-        IvrInput ivrInput = JSON.parseObject(entity.getJson(), IvrInput.class);
107
-        //获取所有节点
108
-        List<Node> nodes = ivrInput.getNodes();
109
-        //获取所有路径
110
-        List<Path> paths = ivrInput.getPaths();
111
-        //获取开始节点
112
-        Node startNode = nodes.stream().filter(p -> p.getType().equals(IvrType.START)).findFirst().get();
113
-        //获取开始节点的路径
114
-        List<Path> startPaths = paths.stream().filter(p -> p.getFrom().equals(startNode.getId())).collect(Collectors.toList());
115
-        if (startPaths.size() > 0) {
116
-            Path path = startPaths.get(0);
117
-            Node toNode = nodes.stream().filter(p -> p.getId().equals(path.getTo())).findFirst().get();
118
-            List<Integer> ids = new ArrayList<>();
119
-            StringBuilder menuXml = new StringBuilder();
120
-            StringBuilder contextXml = getXml(ivrInput, toNode, ids, menuXml);
106
+        if(StringHelper.isNotEmpty(entity.getJson())) {
107
+            IvrInput ivrInput = JSON.parseObject(entity.getJson(), IvrInput.class);
108
+            //获取所有节点
109
+            List<Node> nodes = ivrInput.getNodes();
110
+            //获取所有路径
111
+            List<Path> paths = ivrInput.getPaths();
112
+            //获取开始节点
113
+            Node startNode = nodes.stream().filter(p -> p.getType().equals(IvrType.START)).findFirst().get();
114
+            //获取开始节点的路径
115
+            List<Path> startPaths = paths.stream().filter(p -> p.getFrom().equals(startNode.getId())).collect(Collectors.toList());
116
+            if (startPaths.size() > 0) {
117
+                Path path = startPaths.get(0);
118
+                Node toNode = nodes.stream().filter(p -> p.getId().equals(path.getTo())).findFirst().get();
119
+                List<Integer> ids = new ArrayList<>();
120
+                StringBuilder menuXml = new StringBuilder();
121
+                StringBuilder contextXml = getXml(ivrInput, toNode, ids, menuXml);
121 122
 
122
-            String cXml = "" +
123
-                    "<document type=\"freeswitch/xml\">\n" +
124
-                    "    <section name=\"dialplan\">\n" +
125
-                    contextDefault +
126
-                    "        <context name=\"public\">\n" +
127
-                    "            <extension name=\"public_1\">\n" +
128
-                    "                <condition field=\"destination_number\" expression=\"^(.*)$\">\n" +
129
-                    "                    <action application=\"sleep\" data=\"500\"/>\n" +
130
-                    "                    <action application=\"answer\"/>\n" +
131
-                    "                    <action application=\"set\" data=\"basenumber=$1\"/>\n" +
132
-                    "                    <action application=\"transfer\" data=\"$1 XML " + toNode.getName() + "\"/>\n" +
133
-                    "                </condition>\n" +
134
-                    "            </extension>\n" +
135
-                    "        </context>\n" +
136
-                    contextXml +
137
-                    "    </section>\n" +
138
-                    "</document>";
139
-            String mXml = "" +
140
-                    "<document type=\"freeswitch/xml\">\n" +
141
-                    "    <section name=\"configuration\">\n" +
142
-                    "        <configuration name=\"ivr.conf\" description=\"IVR menus\">\n" +
143
-                    "            <menus>\n" +
144
-                    menuXml +
145
-                    menuDefault +
146
-                    "            </menus>\n" +
147
-                    "        </configuration>\n" +
148
-                    "    </section>\n" +
149
-                    "</document>";
150
-            entity.setContext(cXml);
151
-            entity.setMenu(mXml);
123
+                String cXml = "" +
124
+                        "<document type=\"freeswitch/xml\">\n" +
125
+                        "    <section name=\"dialplan\">\n" +
126
+                        contextDefault +
127
+                        "        <context name=\"public\">\n" +
128
+                        "            <extension name=\"public_1\">\n" +
129
+                        "                <condition field=\"destination_number\" expression=\"^(.*)$\">\n" +
130
+                        "                    <action application=\"sleep\" data=\"500\"/>\n" +
131
+                        "                    <action application=\"answer\"/>\n" +
132
+                        "                    <action application=\"set\" data=\"basenumber=$1\"/>\n" +
133
+                        "                    <action application=\"transfer\" data=\"$1 XML " + toNode.getName() + "\"/>\n" +
134
+                        "                </condition>\n" +
135
+                        "            </extension>\n" +
136
+                        "        </context>\n" +
137
+                        contextXml +
138
+                        "    </section>\n" +
139
+                        "</document>";
140
+                String mXml = "" +
141
+                        "<document type=\"freeswitch/xml\">\n" +
142
+                        "    <section name=\"configuration\">\n" +
143
+                        "        <configuration name=\"ivr.conf\" description=\"IVR menus\">\n" +
144
+                        "            <menus>\n" +
145
+                        menuXml +
146
+                        menuDefault +
147
+                        "            </menus>\n" +
148
+                        "        </configuration>\n" +
149
+                        "    </section>\n" +
150
+                        "</document>";
151
+                entity.setContext(cXml);
152
+                entity.setMenu(mXml);
153
+            }
152 154
         }
153 155
     }
154 156