|
@@ -243,3 +243,93 @@ func FixHistory2() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func FixHistory3() {
|
|
|
+ list, err := report.GetMailOutsideReportHistory2()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("获取没有分类的信息失败:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ruleJson, err := eta.GetBusinessConfByKey("MailCheckRule")
|
|
|
+ if err != nil {
|
|
|
+ global.FILE_LOG.Error("获取规则配置失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var ruleList []report.MailRule
|
|
|
+ err = json.Unmarshal([]byte(ruleJson.ConfVal), &ruleList)
|
|
|
+ if err != nil {
|
|
|
+ global.FILE_LOG.Error("解析规则配置失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ruleMap := make(map[string]report.MailRule)
|
|
|
+ for _, v := range ruleList {
|
|
|
+ ruleMap[v.Rule] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ classifyAll, e := report.GetClassifyAll()
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ global.FILE_LOG.Error("获取分类失败:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ calssifyMap := make(map[int]*report.Classify)
|
|
|
+ for _, v := range classifyAll {
|
|
|
+ calssifyMap[v.Id] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, reportInfo := range list {
|
|
|
+ for _, v := range ruleList {
|
|
|
+ title := strings.ToLower(reportInfo.Title)
|
|
|
+ rule := strings.ToLower(v.Rule)
|
|
|
+ if strings.Contains(title, rule) {
|
|
|
+ fmt.Println(reportInfo.Title, "匹配到规则:", v.Rule)
|
|
|
+ reportInfo.Title = v.Title
|
|
|
+ reportInfo.Abstract = v.Abstract
|
|
|
+ reportInfo.ClassifyID = v.ClassifyId
|
|
|
+ if calssifyMap[v.ClassifyId] != nil {
|
|
|
+ reportInfo.ClassifyName = calssifyMap[v.ClassifyId].ClassifyName
|
|
|
+ }
|
|
|
+ // 特殊规则
|
|
|
+ if reportInfo.ClassifyID == 377 || reportInfo.ClassifyID == 378 {
|
|
|
+ if reportInfo.SysUserName == "report.pcanalyst00@petrochina-usa.com" {
|
|
|
+ v.Author = "PCI"
|
|
|
+ } else {
|
|
|
+ v.Author = reportInfo.SysUserName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(v.Author, "@") {
|
|
|
+ sysUser, tmpErr := eta.GetSysUserByEmail(v.Author)
|
|
|
+ if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if sysUser.AdminId > 0 {
|
|
|
+ reportInfo.SysUserID = sysUser.AdminId
|
|
|
+ reportInfo.SysUserName = sysUser.RealName
|
|
|
+ } else {
|
|
|
+ reportInfo.SysUserName = v.Author
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ reportInfo.SysUserName = v.Author
|
|
|
+ }
|
|
|
+ err = reportInfo.Update([]string{"Title", "Abstract", "SysUserID", "SysUserName"})
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("更新失败:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(reportInfo.Title, "更新成功")
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if strings.Contains(reportInfo.Title, "[PCI ANALYTICS CLOUD PLATFORM(00) Fwd] - ") {
|
|
|
+ reportInfo.Title = strings.Replace(reportInfo.Title, "[PCI ANALYTICS CLOUD PLATFORM(00) Fwd] - ", "", -1)
|
|
|
+ err = reportInfo.Update([]string{"Title"})
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("更新失败:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(reportInfo.Title, "去除前缀成功")
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|