fix: 导出SMSC添加result code和result cause列

This commit is contained in:
TsMask
2025-09-28 20:06:31 +08:00
parent 1bb5ad81ca
commit d8e9014460
14 changed files with 126 additions and 25 deletions

View File

@@ -422,12 +422,13 @@ func (s BackupExportCDRProcessor) exportSMSC(query map[string]string, fileType s
"Service Type",
"Caller",
"Called",
"Result",
"Result Code",
"Result Cause",
"Time",
},
}
// 读取字典数据 CDR 原因码
dictCDRCauseCode := s.sysDictService.FindByType("cdr_cause_code")
dictCDRSMSCCauseCode := s.sysDictService.FindByType("cdr_cause_smsc")
for _, row := range rows {
// 解析 JSON 字符串为 map
var cdrJSON map[string]interface{}
@@ -457,19 +458,20 @@ func (s BackupExportCDRProcessor) exportSMSC(query map[string]string, fileType s
caller = v.(string)
}
// 呼叫结果 0失败1成功
callResult := "Fail"
callResult := "FAILED"
if v, ok := cdrJSON["result"]; ok && v != nil {
resultVal := parse.Number(v)
if resultVal == 1 {
callResult = "Success"
callResult = "SUCCESS"
}
}
// 结果原因
if v, ok := cdrJSON["cause"]; ok && v != nil && callResult == "Fail" {
callCause := "UNKNOW ERROR"
if v, ok := cdrJSON["cause"]; ok && v != nil {
cause := fmt.Sprint(v)
for _, v := range dictCDRCauseCode {
for _, v := range dictCDRSMSCCauseCode {
if cause == v.DataValue {
callResult = fmt.Sprintf("%s, %s", callResult, i18n.TKey(language, v.DataLabel))
callCause = i18n.TKey(language, v.DataLabel)
break
}
}
@@ -492,6 +494,7 @@ func (s BackupExportCDRProcessor) exportSMSC(query map[string]string, fileType s
caller,
called,
callResult,
callCause,
timeStr,
})
}
@@ -511,11 +514,12 @@ func (s BackupExportCDRProcessor) exportSMSC(query map[string]string, fileType s
"D1": "Service Type",
"E1": "Caller",
"F1": "Called",
"G1": "Result",
"H1": "Time",
"G1": "Result Code",
"H1": "Result Cause",
"I1": "Time",
}
// 读取字典数据 CDR 原因码
dictCDRCauseCode := s.sysDictService.FindByType("cdr_cause_code")
dictCDRSMSCCauseCode := s.sysDictService.FindByType("cdr_cause_smsc")
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
@@ -548,19 +552,20 @@ func (s BackupExportCDRProcessor) exportSMSC(query map[string]string, fileType s
caller = v.(string)
}
// 呼叫结果 0失败1成功
callResult := "Fail"
callResult := "FAILED"
if v, ok := cdrJSON["result"]; ok && v != nil {
resultVal := parse.Number(v)
if resultVal == 1 {
callResult = "Success"
callResult = "SUCCESS"
}
}
// 结果原因
if v, ok := cdrJSON["cause"]; ok && v != nil && callResult == "Fail" {
callCause := "UNKNOW ERROR"
if v, ok := cdrJSON["cause"]; ok && v != nil {
cause := fmt.Sprint(v)
for _, v := range dictCDRCauseCode {
for _, v := range dictCDRSMSCCauseCode {
if cause == v.DataValue {
callResult = fmt.Sprintf("%s, %s", callResult, i18n.TKey(language, v.DataLabel))
callCause = i18n.TKey(language, v.DataLabel)
break
}
}
@@ -583,7 +588,8 @@ func (s BackupExportCDRProcessor) exportSMSC(query map[string]string, fileType s
"E" + idx: caller,
"F" + idx: called,
"G" + idx: callResult,
"H" + idx: timeStr,
"H" + idx: callCause,
"I" + idx: timeStr,
})
}
// 导出数据表格

View File

@@ -63,11 +63,12 @@ func (r CDREvent) ExportSMSC(rows []model.CDREvent, fileName, language string) (
"D1": "Service Type",
"E1": "Caller",
"F1": "Called",
"G1": "Result",
"H1": "Time",
"G1": "Result Code",
"H1": "Result Cause",
"I1": "Time",
}
// 读取字典数据 CDR 原因码
dictCDRCauseCode := sysService.NewSysDictData.FindByType("cdr_cause_code")
dictCDRSMSCCauseCode := sysService.NewSysDictData.FindByType("cdr_cause_smsc")
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
@@ -100,19 +101,20 @@ func (r CDREvent) ExportSMSC(rows []model.CDREvent, fileName, language string) (
caller = v.(string)
}
// 呼叫结果 0失败1成功
callResult := "Fail"
callResult := "FAILED"
if v, ok := cdrJSON["result"]; ok && v != nil {
resultVal := parse.Number(v)
if resultVal == 1 {
callResult = "Success"
callResult = "SUCCESS"
}
}
// 结果原因
if v, ok := cdrJSON["cause"]; ok && v != nil && callResult == "Fail" {
callCause := "UNKNOW ERROR"
if v, ok := cdrJSON["cause"]; ok && v != nil {
cause := fmt.Sprint(v)
for _, v := range dictCDRCauseCode {
for _, v := range dictCDRSMSCCauseCode {
if cause == v.DataValue {
callResult = fmt.Sprintf("%s, %s", callResult, i18n.TKey(language, v.DataLabel))
callCause = i18n.TKey(language, v.DataLabel)
break
}
}
@@ -135,7 +137,8 @@ func (r CDREvent) ExportSMSC(rows []model.CDREvent, fileName, language string) (
"E" + idx: caller,
"F" + idx: called,
"G" + idx: callResult,
"H" + idx: timeStr,
"H" + idx: callCause,
"I" + idx: timeStr,
})
}