123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package services
- import (
- "fmt"
- "hongze/hongze_mfyx/models"
- "hongze/hongze_mfyx/utils"
- "strconv"
- "time"
- )
- func GetReportMappingMap() (mapResp map[int]bool, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("GetReportMappingMap, ErrMsg: "+err.Error(), 3)
- }
- }()
- mapResp = make(map[int]bool, 0)
- list, err := models.GetReportMappingByPermissionName(utils.CE_LUE_NAME)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- if len(list) > 0 {
- for _, v := range list {
- mapResp[v.CategoryId] = true
- }
- }
- return
- }
- // 生成查研观向的报告匹配类型
- func init111() {
- list, err := models.GetReportMapping()
- if err != nil {
- fmt.Print(err)
- }
- var condition string
- for _, v := range list {
- if v.MatchTypeName == "" {
- continue
- }
- item := new(models.CygxReportMappingCygx)
- item.ChartPermissionId = v.ChartPermissionId
- item.ChartPermissionName = v.ChartPermissionName
- item.MatchTypeName = v.MatchTypeName
- item.ReportType = v.ReportType
- item.Sort = v.Sort
- item.IsCustom = v.IsCustom
- item.IsSummary = v.IsSummary
- item.IsReport = v.IsReport
- item.PermissionType = v.PermissionType
- condition = ` AND match_type_name = '` + v.MatchTypeName + `' AND chart_permission_id = ` + strconv.Itoa(v.ChartPermissionId)
- total, err := models.GetCygxReportMappingCygxCount(condition)
- if err != nil {
- fmt.Print(err)
- }
- if total == 0 {
- _, err = models.AddCygxReportMappingCygx(item)
- if err != nil {
- fmt.Print(err)
- }
- }
- }
- }
- // 生成多对多关系表
- func init1232() {
- list, err := models.GetCygxReportMappingCygx()
- if err != nil {
- fmt.Print(err)
- }
- var condition string
- for _, v := range list {
- if v.MatchTypeName == "" {
- continue
- }
- condition = ` AND match_type_name = '` + v.MatchTypeName + `' AND chart_permission_id = ` + strconv.Itoa(v.ChartPermissionId)
- listCelue, err := models.GetCygxReportMappingcelue(condition)
- if err != nil {
- fmt.Print(err)
- }
- for _, vC := range listCelue {
- item := new(models.CygxReportMappingGroup)
- item.IdCygx = v.Id
- item.CategoryIdCelue = vC.CategoryId
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- fmt.Println(item)
- _, err = models.AddCygxReportMappingGroup(item)
- if err != nil {
- fmt.Print(err)
- }
- }
- }
- }
|