123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- package services
- import (
- "fmt"
- "hongze/hongze_task/models"
- "strconv"
- "strings"
- "time"
- )
- //客户权限设置
- func SetCompanyPermission() {
- var err error
- defer func() {
- if err != nil {
- fmt.Println("SetCompanyPermission Err:", err.Error())
- }
- }()
- companyList, err := models.GetCompany()
- fmt.Println("len:", len(companyList))
- time.Sleep(10 * time.Second)
- if err != nil {
- return
- }
- for k, v := range companyList {
- fmt.Println("line 24:", k, v.CompanyName)
- permissionList, err := models.GetCompanyReportPermission(v.CompanyId)
- if err != nil {
- return
- }
- if len(permissionList) == 14 {
- fmt.Println(k, v.CompanyName, "大套餐客户")
- } else {
- fmt.Println(k, v.CompanyName, "小套餐客户")
- flag := 0
- for m, n := range permissionList {
- fmt.Println(m, n.ChartPermissionId)
- if n.ChartPermissionId == 17 {
- flag = 1
- }
- if n.ChartPermissionId == 8 {
- flag = 2
- }
- }
- if flag == 0 || flag == 1 {
- //新增炉料权限
- item := new(models.CompanyReportPermission)
- item.CompanyId = v.CompanyId
- item.ChartPermissionId = 8
- item.CreatedTime = time.Now()
- item.LastUpdatedTime = time.Now()
- item.ReportPermissionId = 8
- err = models.AddCompanyReportPermission(item)
- if err != nil {
- fmt.Println("AddCompanyReportPermission Err:", err.Error())
- //return
- }
- }
- }
- }
- }
- func addCompany12() {
- str := `25,
- 28,
- 51,
- 61,
- 65,
- 74,
- 79,
- 91,
- 96,
- 135,
- 153,
- 158,
- 170,
- 173,
- 175,
- 199,
- 235,
- 241,
- 248,
- 275,
- 280,
- 339,
- 367,
- 368,
- 395,
- 400,
- 424,
- 473,
- 488,
- 493,
- 561,
- 562,
- 565,
- 568,
- 569,
- 588,
- 617,
- 650,
- 728,
- 738,
- 740,
- 742,
- 753,
- 763,
- 780,
- 796,
- 829,
- 840,
- 862,
- 896,
- 940,
- 951,
- 964,
- 980,
- 993,
- 1049,
- 1064,
- 1075,
- 1101,
- 1103,
- 1113,
- 1116,
- 1118,
- 1156,
- 1201,
- 1256,
- 1298,
- 1428,
- 1443,
- 1505,
- 1620,
- 1720,
- 1730,
- 1780,
- 1782,
- 1861,
- 1906,
- 1917,
- 2005,
- 2011,
- 2172,
- 2232,
- 2302,
- 2399,
- 2428,
- 2488,
- 2507,
- 2539,
- 2577,
- 2581,
- 2594,
- 2660,
- 2825,
- 2890,
- 2950,
- 3014,
- 3088,
- 3201,
- 3235,
- 3417,
- 3445,
- 3451,
- 3510,
- 3543,
- 3592,
- 3687,
- 3763,
- 3798,
- 3890,
- 3962,
- 3987,
- 4002,
- 4085,
- 4399,
- 4413,
- 4489`
- strArr := strings.Split(str, ",")
- for k, v := range strArr {
- fmt.Println(k)
- //新增炉料权限
- v=strings.Replace(v,"\n","",-1)
- companyId,err:=strconv.Atoi(v)
- if err!=nil {
- fmt.Println("strconv",err.Error())
- }
- item := new(models.CompanyReportPermission)
- item.CompanyId = companyId
- item.ChartPermissionId = 12
- item.CreatedTime = time.Now()
- item.LastUpdatedTime = time.Now()
- item.ReportPermissionId = 12
- err = models.AddCompanyReportPermission(item)
- if err != nil {
- fmt.Println("AddCompanyReportPermission Err:", err.Error(), "CompanyId:", v)
- //return
- }
- }
- }
|