|
|
@@ -2,15 +2,12 @@ package api.service.call.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import api.entity.database.call.Ivr;
|
|
4
|
4
|
import api.entity.input.call.*;
|
|
5
|
|
-
|
|
6
|
5
|
import api.mapper.call.IvrMapper;
|
|
7
|
6
|
import api.service.call.IIvrService;
|
|
8
|
7
|
import api.service.BaseServiceImpl;
|
|
9
|
8
|
import api.service.call.IIvrSqlService;
|
|
10
|
9
|
import api.util.enums.IvrType;
|
|
11
|
|
-import api.util.helper.StringHelper;
|
|
12
|
|
-import api.util.helper.TtsHelper;
|
|
13
|
|
-
|
|
|
10
|
+import api.util.helper.*;
|
|
14
|
11
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
15
|
12
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
16
|
13
|
import lombok.var;
|
|
|
@@ -26,11 +23,17 @@ import java.util.stream.Collectors;
|
|
26
|
23
|
public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements IIvrService{
|
|
27
|
24
|
public IvrServiceImpl(){ super(false); }
|
|
28
|
25
|
@Autowired
|
|
|
26
|
+ public static final String middlewareUrl= SpringHelper.getRequiredProperty("spring.middlewareUrl");
|
|
|
27
|
+ @Autowired
|
|
|
28
|
+ public static final String curlUrl= SpringHelper.getRequiredProperty("spring.curlUrl");
|
|
|
29
|
+
|
|
|
30
|
+ @Autowired
|
|
29
|
31
|
private IIvrSqlService iIvrSqlService;
|
|
30
|
32
|
//新增
|
|
31
|
33
|
@Override
|
|
32
|
34
|
public boolean insert(Ivr entity) {
|
|
33
|
35
|
dealIvr(entity);
|
|
|
36
|
+ HttpHelper.sendGet(middlewareUrl+"/ivr/delete");
|
|
34
|
37
|
return this.save(entity);
|
|
35
|
38
|
}
|
|
36
|
39
|
|
|
|
@@ -38,6 +41,7 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
38
|
41
|
@Override
|
|
39
|
42
|
public boolean update(Ivr entity) {
|
|
40
|
43
|
dealIvr(entity);
|
|
|
44
|
+ HttpHelper.sendGet(middlewareUrl+"/ivr/delete");
|
|
41
|
45
|
return this.updateById(entity);
|
|
42
|
46
|
}
|
|
43
|
47
|
|
|
|
@@ -70,7 +74,7 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
70
|
74
|
" <action application=\"set\" data=\"call_timeout=60\"/>\n" +
|
|
71
|
75
|
" <action application=\"set\" data=\"continue_on_fail=USER_BUSY,NO_ANSWER\"/>\n" +
|
|
72
|
76
|
" <action application=\"export\" data=\"op_type=${op_type}\"/>\n" +
|
|
73
|
|
- " <action application=\"bridge\" data=\"{origination_caller_id_name=18538595479,origination_caller_id_number=18538595478,ignore_early_media=true}sofia/gateway/hykj/$1\"/>\n" +
|
|
|
77
|
+ " <action application=\"bridge\" data=\"{ignore_early_media=true}sofia/gateway/hykj/$1\"/>\n" +
|
|
74
|
78
|
" <action application=\"hangup\" data=\"${originate_disposition}\"/>\n" +
|
|
75
|
79
|
" <action name=\"start_dtmf\"/>\n" +
|
|
76
|
80
|
" </condition>\n" +
|
|
|
@@ -180,6 +184,7 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
180
|
184
|
" <action application=\"sleep\" data=\"1000\"/>\n" +
|
|
181
|
185
|
" <action application=\"answer\"/>\n" +
|
|
182
|
186
|
" <action application=\"set\" data=\"basenumber=$1\"/>\n" +
|
|
|
187
|
+ " <action application=\"odbc_query\" inline=\"true\" data=\"call proc_IVRFirst('${uuid}','${caller_id_number}','${basenumber}','${network_addr}')\"/>" +
|
|
183
|
188
|
" <action application=\"set\" data=\"wait=0\"/>\n" +
|
|
184
|
189
|
" <action application=\"transfer\" data=\"$1 XML " + toNode.getProperties().getName() + toNode.getId()+ "\"/>\n" +
|
|
185
|
190
|
" </condition>\n" +
|
|
|
@@ -210,11 +215,14 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
210
|
215
|
private StringBuilder getXml( List<IvrProperties> nodes , List<IvrEdges> paths,IvrProperties currNode,List<String> ids,StringBuilder menuXml) {
|
|
211
|
216
|
|
|
212
|
217
|
|
|
|
218
|
+
|
|
213
|
219
|
boolean isexist = ids.contains(currNode.getId());
|
|
214
|
220
|
if (!isexist) {
|
|
215
|
221
|
ids.add(currNode.getId());
|
|
216
|
222
|
}
|
|
217
|
|
-
|
|
|
223
|
+ else {
|
|
|
224
|
+ return new StringBuilder();
|
|
|
225
|
+ }
|
|
218
|
226
|
StringBuilder xml = new StringBuilder();
|
|
219
|
227
|
StringBuilder nextXml = new StringBuilder();
|
|
220
|
228
|
Map<String, Object> data = currNode.getProperties().getAttr();
|
|
|
@@ -235,10 +243,10 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
235
|
243
|
}
|
|
236
|
244
|
else
|
|
237
|
245
|
{
|
|
238
|
|
- mxml.append("greet-long").append("=\"").append(TtsHelper.TextToSpeech(data.get("content").toString())).append("\" ");
|
|
239
|
|
- mxml.append("greet-short").append("=\"").append(TtsHelper.TextToSpeech(data.get("greetShort").toString())).append("\" ");
|
|
240
|
|
- mxml.append("invalid-sound").append("=\"").append(TtsHelper.TextToSpeech(data.get("invalidSound").toString())).append("\" ");
|
|
241
|
|
- mxml.append("exit-sound").append("=\"").append(TtsHelper.TextToSpeech(data.get("xitSound").toString())).append("\" ");
|
|
|
246
|
+ mxml.append("greet-long").append("=\"").append(curlUrl).append(TtsHelper.TextToSpeech(data.get("content").toString())).append("\" ");
|
|
|
247
|
+ mxml.append("greet-short").append("=\"").append(curlUrl).append(TtsHelper.TextToSpeech(data.get("greetShort").toString())).append("\" ");
|
|
|
248
|
+ mxml.append("invalid-sound").append("=\"").append(curlUrl).append(TtsHelper.TextToSpeech(data.get("invalidSound").toString())).append("\" ");
|
|
|
249
|
+ mxml.append("exit-sound").append("=\"").append(curlUrl).append(TtsHelper.TextToSpeech(data.get("xitSound").toString())).append("\" ");
|
|
242
|
250
|
|
|
243
|
251
|
}
|
|
244
|
252
|
mxml.append("confirm-macro").append("=\"").append("\" ");
|
|
|
@@ -247,10 +255,10 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
247
|
255
|
mxml.append("tts-voice").append("=\"").append("\" ");
|
|
248
|
256
|
mxml.append("confirm-attempts").append("=\"").append("\" ");
|
|
249
|
257
|
mxml.append("timeout").append("=\"").append(data.get("timeout").toString()).append("\" ");
|
|
250
|
|
- mxml.append("inter-digit-timeout").append("\" ");
|
|
|
258
|
+ mxml.append("inter-digit-timeout").append("=\" ").append("\" ");
|
|
251
|
259
|
mxml.append("max-failures").append("=\"").append(data.get("maxFailures").toString()).append("\" ");
|
|
252
|
260
|
mxml.append("max-timeouts").append("=\"").append(data.get("maxTimeouts").toString()).append("\" ");
|
|
253
|
|
- mxml.append("digit-len").append("=\"").append("\" ");
|
|
|
261
|
+ mxml.append("digit-len").append("=\"").append("1\" ");
|
|
254
|
262
|
|
|
255
|
263
|
mxml.append(">\n");
|
|
256
|
264
|
for (IvrEdges path : nodePaths) {
|
|
|
@@ -312,9 +320,20 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
312
|
320
|
var content= mapper.readValue(model.getSqlContent(), Map.class);
|
|
313
|
321
|
if(content!=null)
|
|
314
|
322
|
{
|
|
315
|
|
- xml.append(" " +
|
|
316
|
|
- " <action application=\"odbc_query\" data=\"").
|
|
317
|
|
- append(content.get("content").toString()).append("\"/>\n");
|
|
|
323
|
+ if (Objects.equals(content.get("field").toString(), "curl_response_data"))
|
|
|
324
|
+ {
|
|
|
325
|
+ xml.append(" " +
|
|
|
326
|
+ " <action application=\"curl\" data=\"").
|
|
|
327
|
+ append(content.get("content").toString()).append("\"/>\n");
|
|
|
328
|
+ }
|
|
|
329
|
+ else
|
|
|
330
|
+ {
|
|
|
331
|
+ xml.append(" " +
|
|
|
332
|
+ " <action application=\"odbc_query\" data=\"").
|
|
|
333
|
+ append(content.get("content").toString()).append("\"/>\n");
|
|
|
334
|
+ }
|
|
|
335
|
+
|
|
|
336
|
+
|
|
318
|
337
|
}
|
|
319
|
338
|
}
|
|
320
|
339
|
}
|
|
|
@@ -376,7 +395,7 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
376
|
395
|
}
|
|
377
|
396
|
else
|
|
378
|
397
|
{
|
|
379
|
|
- xml.append(" <action application=\"playback\" data=\"").append(TtsHelper.TextToSpeech(data.get("content").toString())).append("\"/>\n");
|
|
|
398
|
+ xml.append(" <action application=\"playback\" data=\"").append(curlUrl).append(TtsHelper.TextToSpeech(data.get("content").toString())).append("\"/>\n");
|
|
380
|
399
|
}
|
|
381
|
400
|
break;
|
|
382
|
401
|
case queue:
|
|
|
@@ -420,6 +439,10 @@ public class IvrServiceImpl extends BaseServiceImpl<IvrMapper, Ivr> implements I
|
|
420
|
439
|
case hangup:
|
|
421
|
440
|
xml.append(" <action application=\"hangup\"/>\n");
|
|
422
|
441
|
break;
|
|
|
442
|
+ case robot:
|
|
|
443
|
+ xml.append(" <action application=\"set\" data=\"robot=1\"/>");
|
|
|
444
|
+ xml.append(" <action application=\"park\"/>");
|
|
|
445
|
+ break;
|
|
423
|
446
|
}
|
|
424
|
447
|
|
|
425
|
448
|
if (nodePaths.size() > 0) {
|