feat: 更新多个模块以支持新的数据结构和日志格式

This commit is contained in:
TsMask
2025-02-20 10:08:27 +08:00
parent 045a2b6b01
commit f3c33b31ac
272 changed files with 13246 additions and 15885 deletions

View File

@@ -25,21 +25,21 @@ type CDREventIMS struct {
cdrEventIMSRepository *repository.CDREventIMS // CDR会话事件数据信息
}
// SelectPage 根据条件分页查询
func (r *CDREventIMS) SelectPage(querys model.CDREventIMSQuery) ([]model.CDREventIMS, int64) {
return r.cdrEventIMSRepository.SelectByPage(querys)
// FindByPage 根据条件分页查询
func (r *CDREventIMS) FindByPage(query model.CDREventIMSQuery) ([]model.CDREventIMS, int64) {
return r.cdrEventIMSRepository.SelectByPage(query)
}
// DeleteByIds 批量删除信息
func (r *CDREventIMS) DeleteByIds(cdrIds []string) (int64, error) {
func (r *CDREventIMS) DeleteByIds(ids []int64) (int64, error) {
// 检查是否存在
ids := r.cdrEventIMSRepository.SelectByIds(cdrIds)
if len(ids) <= 0 {
rows := r.cdrEventIMSRepository.SelectByIds(ids)
if len(rows) <= 0 {
return 0, fmt.Errorf("not data")
}
if len(ids) == len(cdrIds) {
rows := r.cdrEventIMSRepository.DeleteByIds(cdrIds)
if len(rows) == len(ids) {
rows := r.cdrEventIMSRepository.DeleteByIds(ids)
return rows, nil
}
// 删除信息失败!
@@ -61,16 +61,16 @@ func (r CDREventIMS) ExportXlsx(rows []model.CDREventIMS, fileName, language str
"I1": "Hangup Time",
}
// 读取字典数据 CDR SIP响应代码类别类型
dictCDRSipCode := sysService.NewSysDictData.SelectDictDataByType("cdr_sip_code")
dictCDRSipCode := sysService.NewSysDictData.FindByType("cdr_sip_code")
// 读取字典数据 CDR 呼叫类型
dictCDRCallType := sysService.NewSysDictData.SelectDictDataByType("cdr_call_type")
dictCDRCallType := sysService.NewSysDictData.FindByType("cdr_call_type")
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 解析 JSON 字符串为 map
var cdrJSON map[string]interface{}
err := json.Unmarshal([]byte(row.CDRJSONStr), &cdrJSON)
var cdrJSON map[string]any
err := json.Unmarshal([]byte(row.CdrJson), &cdrJSON)
if err != nil {
logger.Warnf("CDRExport Error parsing JSON: %s", err.Error())
continue
@@ -86,8 +86,8 @@ func (r CDREventIMS) ExportXlsx(rows []model.CDREventIMS, fileName, language str
if v, ok := cdrJSON["callType"]; ok && v != nil {
callType = v.(string)
for _, v := range dictCDRCallType {
if callType == v.DictValue {
callTypeLable = i18n.TKey(language, v.DictLabel)
if callType == v.DataValue {
callTypeLable = i18n.TKey(language, v.DataLabel)
break
}
}
@@ -112,8 +112,8 @@ func (r CDREventIMS) ExportXlsx(rows []model.CDREventIMS, fileName, language str
if v, ok := cdrJSON["cause"]; ok && v != nil && callType != "sms" {
cause := fmt.Sprint(v)
for _, v := range dictCDRSipCode {
if cause == v.DictValue {
callResult = i18n.TKey(language, v.DictLabel)
if cause == v.DataValue {
callResult = i18n.TKey(language, v.DataLabel)
break
}
}