1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381 |
- package data_manage_permission
- import (
- "encoding/json"
- "eta/eta_mobile/models"
- "eta/eta_mobile/models/data_manage"
- "eta/eta_mobile/models/data_manage/data_manage_permission"
- "eta/eta_mobile/models/data_manage/excel"
- "eta/eta_mobile/models/system"
- "eta/eta_mobile/utils"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/uuid"
- "strconv"
- "strings"
- "time"
- )
- // GetEdbChartClassifyList
- // @Description: 获取数据权限那边的分类列表
- // @author: Roc
- // @datetime 2024-04-01 09:46:29
- // @param source int
- // @param subSource int
- // @return resp data_manage.EdbChartClassifyResp
- // @return err error
- func GetEdbChartClassifyList(source, subSource int) (resp data_manage.EdbChartClassifyResp, err error) {
- switch source {
- case 1: //手工数据指标
- list, e := models.GetEdbdataClassify(0)
- if e != nil {
- err = e
- return
- }
- for _, v := range list {
- item := data_manage.EdbChartClassify{
- ClassifyId: v.ClassifyId,
- ClassifyName: v.ClassifyName,
- ParentId: v.ParentId,
- }
- for _, v2 := range v.Child {
- child := data_manage.EdbChartClassify{
- ClassifyId: v2.ClassifyId,
- ClassifyName: v2.ClassifyName,
- ParentId: v2.ParentId,
- }
- item.Child = append(item.Child, &child)
- }
- resp.List = append(resp.List, &item)
- }
- case 2: //上海钢联数据库
- rootList, e := data_manage.GetBaseFromMysteelChemicalClassifyByParentId(0)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- classifyAll, e := data_manage.GetAllBaseFromMysteelChemicalClassify()
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- rootChildMap := make(map[int][]*data_manage.BaseFromMysteelChemicalClassifyItems)
- for _, v := range classifyAll {
- rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
- }
- nodeAll := make([]*data_manage.BaseFromMysteelChemicalClassifyItems, 0)
- for _, v := range rootList {
- if existItems, ok := rootChildMap[v.BaseFromMysteelChemicalClassifyId]; ok {
- v.Children = existItems
- } else {
- items := make([]*data_manage.BaseFromMysteelChemicalClassifyItems, 0)
- v.Children = items
- }
- nodeAll = append(nodeAll, v)
- }
- for _, v := range nodeAll {
- item := data_manage.EdbChartClassify{
- ClassifyId: v.BaseFromMysteelChemicalClassifyId,
- ClassifyName: v.ClassifyName,
- ParentId: v.ParentId,
- }
- for _, v2 := range v.Children {
- child := data_manage.EdbChartClassify{
- ClassifyId: v2.BaseFromMysteelChemicalClassifyId,
- ClassifyName: v2.ClassifyName,
- ParentId: v2.ParentId,
- }
- item.Child = append(item.Child, &child)
- }
- resp.List = append(resp.List, &item)
- }
- case 3:
- //ETA指标库
- //rootList, e := data_manage.GetEdbClassifyByParentId(0, 0)
- //if e != nil && e.Error() != utils.ErrNoRow() {
- // err = e
- // return
- //}
- // 考虑到后面可以会迭代到10层, 这里直接用递归处理
- classifyAll, e := data_manage.GetAllEdbClassifyByType(0)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- resp.List = GetEdbMenuTreeRecursive(classifyAll, 0)
- case 4:
- //ETA预测指标
- // 考虑到后面可以会迭代到10层, 这里直接用递归
- classifyAll, e := data_manage.GetAllEdbClassifyByType(1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- resp.List = GetEdbMenuTreeRecursive(classifyAll, 0)
- case 5: //图库
- // 考虑到后面可以会迭代到10层, 这里直接用递归处理
- classifyAll, e := data_manage.GetAllChartClassifyItemsBySource(1)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- resp.List = GetChartMenuTreeRecursive(classifyAll, 0)
- // 将数据加入缓存
- //if utils.Re == nil {
- // utils.Rc.Delete(key)
- //}
- case 6:
- // ETA表格
- // 考虑到后面可以会迭代到10层, 这里直接用递归处理
- classifyAll, e := excel.GetExcelClassifyBySourceOrderByLevel(subSource)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = e
- return
- }
- resp.List = GetExcelMenuTreeRecursive(classifyAll, 0)
- default:
- return
- }
- return
- }
- // GetEdbMenuTreeRecursive 递归指标库菜单树
- func GetEdbMenuTreeRecursive(list []*data_manage.EdbClassifyItems, parentId int) []*data_manage.EdbChartClassify {
- res := make([]*data_manage.EdbChartClassify, 0)
- for _, v := range list {
- t := new(data_manage.EdbChartClassify)
- t.ClassifyId = v.ClassifyId
- t.ClassifyName = v.ClassifyName
- t.ParentId = v.ParentId
- t.IsJoinPermission = v.IsJoinPermission
- if v.ParentId == parentId {
- t.Child = GetEdbMenuTreeRecursive(list, v.ClassifyId)
- res = append(res, t)
- }
- }
- return res
- }
- // GetChartMenuTreeRecursive 递归指标库菜单树
- func GetChartMenuTreeRecursive(list []*data_manage.ChartClassifyItems, parentId int) []*data_manage.EdbChartClassify {
- res := make([]*data_manage.EdbChartClassify, 0)
- for _, v := range list {
- t := new(data_manage.EdbChartClassify)
- t.ClassifyId = v.ChartClassifyId
- t.ClassifyName = v.ChartClassifyName
- t.ParentId = v.ParentId
- t.IsJoinPermission = v.IsJoinPermission
- if v.ParentId == parentId {
- t.Child = GetChartMenuTreeRecursive(list, v.ChartClassifyId)
- res = append(res, t)
- }
- }
- return res
- }
- // GetExcelMenuTreeRecursive
- // @Description: 递归ETA表格菜单树
- // @author: Roc
- // @datetime 2024-03-27 10:30:32
- // @param list []*data_manage.ChartClassifyItems
- // @param parentId int
- // @return []*data_manage.EdbChartClassify
- func GetExcelMenuTreeRecursive(list []*excel.ExcelClassifyItems, parentId int) []*data_manage.EdbChartClassify {
- res := make([]*data_manage.EdbChartClassify, 0)
- for _, v := range list {
- t := new(data_manage.EdbChartClassify)
- t.ClassifyId = v.ExcelClassifyId
- t.ClassifyName = v.ExcelClassifyName
- t.ParentId = v.ParentId
- t.IsJoinPermission = v.IsJoinPermission
- if v.ParentId == parentId {
- t.Child = GetExcelMenuTreeRecursive(list, v.ExcelClassifyId)
- res = append(res, t)
- }
- }
- return res
- }
- // GetMoveEdbChartList 获取待转移的指标/图表列表
- // @param source 来源 :1:手工数据指标 2:上海钢联数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
- func GetMoveEdbChartList(source, subSource, userId int, keyword, classify string, startSize, pageSize int) (list []data_manage.MoveEdbChartList, total int, err error) {
- var condition string
- var pars []interface{}
- switch source {
- case 1: //手工数据指标
- if keyword != "" {
- condition += ` AND (a.SEC_NAME LIKE ? OR a.TRADE_CODE like ? ) `
- pars = utils.GetLikeKeywordPars(pars, keyword, 2)
- }
- if userId > 0 {
- condition += ` AND a.user_id = ? `
- pars = append(pars, userId)
- }
- if classify != "" {
- condition += ` AND a.classify_id IN (` + classify + `) `
- }
- total, err = models.GetEdbinfoListCount(condition, pars, "", 0)
- if err != nil {
- return
- }
- tmpList, tmpErr := models.GetEdbinfoList(condition, pars, startSize, pageSize, "", 0)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- adminIdList := make([]int, 0)
- for _, v := range tmpList {
- adminIdList = append(adminIdList, v.UserId)
- }
- adminList, tmpErr := system.GetAdminListByIdListWithoutEnable(adminIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- adminMap := make(map[int]string)
- for _, adminInfo := range adminList {
- adminMap[adminInfo.AdminId] = adminInfo.RealName
- }
- for _, v := range tmpList {
- list = append(list, data_manage.MoveEdbChartList{
- DataId: v.TradeCode,
- Code: v.TradeCode,
- Name: v.SecName,
- ClassifyName: v.ClassifyName,
- NameEn: v.SecName,
- ClassifyNameEn: v.ClassifyName,
- CreateUserId: v.UserId,
- CreateUserName: adminMap[v.UserId],
- })
- }
- }
- case 2: //上海钢联数据库
- if keyword != `` {
- condition += " AND (index_name like ? OR index_code like ? OR sys_user_real_name like ? ) "
- pars = utils.GetLikeKeywordPars(pars, keyword, 3)
- }
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- if classify != "" {
- condition += ` AND base_from_mysteel_chemical_classify_id IN (` + classify + `) `
- }
- total, err = data_manage.GetMysteelChemicalIndexCount(condition, pars)
- if err != nil {
- return
- }
- tmpList, tmpErr := data_manage.GetMysteelChemicalIndexList(condition, pars, startSize, pageSize, "DESC")
- if tmpErr != nil {
- err = tmpErr
- return
- }
- for _, v := range tmpList {
- list = append(list, data_manage.MoveEdbChartList{
- DataId: strconv.Itoa(v.BaseFromMysteelChemicalIndexId),
- Code: v.IndexCode,
- Name: v.IndexName,
- NameEn: v.IndexName,
- //ClassifyName: v.,
- CreateUserId: v.SysUserId,
- CreateUserName: v.SysUserRealName,
- })
- }
- case 3, 4: //ETA指标库、ETA预测指标
- if keyword != `` {
- condition += " AND (edb_code like ? OR edb_name like ? OR edb_name_en like ? OR sys_user_real_name like ? ) "
- pars = utils.GetLikeKeywordPars(pars, keyword, 4)
- }
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- if classify != "" {
- condition += ` AND classify_id IN (` + classify + `) `
- }
- edbInfoType := 0 //ETA指标库
- if source == 4 { //ETA预测指标
- edbInfoType = 1
- }
- condition += ` AND edb_info_type = ? `
- pars = append(pars, edbInfoType)
- total, err = data_manage.GetEdbInfoByConditionCount(condition, pars)
- if err != nil {
- return
- }
- tmpList, tmpErr := data_manage.GetEdbInfoListByCondition(condition, pars, startSize, pageSize, "DESC")
- if tmpErr != nil {
- err = tmpErr
- return
- }
- for _, v := range tmpList {
- list = append(list, data_manage.MoveEdbChartList{
- DataId: strconv.Itoa(v.EdbInfoId),
- Code: v.EdbCode,
- Name: v.EdbName,
- NameEn: v.EdbNameEn,
- //ClassifyName: v.,
- CreateUserId: v.SysUserId,
- CreateUserName: v.SysUserRealName,
- })
- }
- case 5: //图库
- // 只展示eta图库
- condition += ` AND source = ? `
- pars = append(pars, utils.CHART_SOURCE_DEFAULT)
- // 关键字搜索
- if keyword != `` {
- condition += " AND (chart_name like ? or chart_name_en like ? OR sys_user_real_name like ? ) "
- pars = utils.GetLikeKeywordPars(pars, keyword, 3)
- }
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- if classify != "" {
- condition += ` AND chart_classify_id IN (` + classify + `) `
- }
- total, err = data_manage.GetChartInfoCountByCondition(condition, pars)
- if err != nil {
- return
- }
- tmpList, tmpErr := data_manage.GetChartInfoListByCondition(condition, pars, startSize, pageSize)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- // 获取所有的图表分类
- firstClassifyList, tmpErr := data_manage.GetChartClassifyByParentId(0, 1)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- firstClassifyNameMap := make(map[int]string)
- firstClassifyNameEnMap := make(map[int]string)
- for _, v := range firstClassifyList {
- firstClassifyNameMap[v.ChartClassifyId] = v.ChartClassifyName
- firstClassifyNameEnMap[v.ChartClassifyId] = v.ChartClassifyNameEn
- }
- secondClassList, tmpErr := data_manage.GetChartClassifyAll(1)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- secondClassifyNameMap := make(map[int]string)
- secondClassifyNameEnMap := make(map[int]string)
- for _, v := range secondClassList {
- firstName := firstClassifyNameMap[v.ParentId]
- firstNameEn := firstClassifyNameEnMap[v.ParentId]
- if firstName != `` {
- firstName = firstName + " / "
- }
- if firstNameEn != `` {
- firstNameEn = firstNameEn + " / "
- }
- secondClassifyNameMap[v.ChartClassifyId] = firstName + v.ChartClassifyName
- secondClassifyNameEnMap[v.ChartClassifyId] = firstNameEn + v.ChartClassifyNameEn
- }
- for _, v := range tmpList {
- list = append(list, data_manage.MoveEdbChartList{
- DataId: strconv.Itoa(v.ChartInfoId),
- Name: v.ChartName,
- ClassifyName: secondClassifyNameMap[v.ChartClassifyId],
- NameEn: v.ChartNameEn,
- ClassifyNameEn: secondClassifyNameEnMap[v.ChartClassifyId],
- CreateUserId: v.SysUserId,
- CreateUserName: v.SysUserRealName,
- })
- }
- case 6: //ETA表格
- if keyword != `` {
- condition += " AND (excel_name like ? OR sys_user_real_name like ? ) "
- pars = utils.GetLikeKeywordPars(pars, keyword, 2)
- }
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- if classify != "" {
- condition += ` AND excel_classify_id IN (` + classify + `) `
- }
- condition += " AND source = ? "
- pars = append(pars, subSource)
- total, err = excel.GetExcelInfoCountByCondition(condition, pars)
- if err != nil {
- return
- }
- tmpList, tmpErr := excel.GetNoContentExcelInfoListByCondition(condition, pars, startSize, pageSize)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- // 获取所有的图表分类
- firstClassifyList, tmpErr := excel.GetExcelClassifyByParentId(0, subSource)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- firstClassifyNameMap := make(map[int]string)
- for _, v := range firstClassifyList {
- firstClassifyNameMap[v.ExcelClassifyId] = v.ExcelClassifyName
- }
- secondClassList, tmpErr := excel.GetExcelClassifyBySource(subSource)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- secondClassifyNameMap := make(map[int]string)
- for _, v := range secondClassList {
- firstName := firstClassifyNameMap[v.ParentId]
- if firstName != `` {
- firstName = firstName + " / "
- }
- secondClassifyNameMap[v.ExcelClassifyId] = firstName + v.ExcelClassifyName
- }
- for _, v := range tmpList {
- list = append(list, data_manage.MoveEdbChartList{
- DataId: strconv.Itoa(v.ExcelInfoId),
- Name: v.ExcelClassifyName,
- ClassifyName: secondClassifyNameMap[v.ExcelClassifyId],
- NameEn: v.ExcelClassifyName,
- ClassifyNameEn: secondClassifyNameMap[v.ExcelClassifyId],
- CreateUserId: v.SysUserId,
- CreateUserName: v.SysUserRealName,
- })
- }
- default:
- return
- }
- return
- }
- // MoveEdbChart 转移指标/图表创建人
- // @param source 来源 :1:手工数据指标 2:上海钢联数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
- func MoveEdbChart(source, subSource, oldUserId, newUserId int, isSelectAll bool, dataId, noDataId []string, keyword, classify string, opUserId int) (err error, errMsg string) {
- adminInfo, err := system.GetSysAdminById(newUserId)
- if err != nil {
- return
- }
- // 如果勾选全部数据,那么
- if isSelectAll {
- // 找出不要的指标ID列表
- noDataIdMap := make(map[string]string, 0)
- for _, v := range noDataId {
- noDataIdMap[v] = v
- }
- // 需要转义的指标/图表ID列表
- dataId = make([]string, 0)
- // 获取所有指标/图表
- list, _, tmpErr := GetMoveEdbChartList(source, subSource, oldUserId, keyword, classify, 0, 100000)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- for _, v := range list {
- if _, ok := noDataIdMap[v.DataId]; !ok {
- dataId = append(dataId, v.DataId)
- }
- }
- }
- // 操作记录
- dataPermissionMoveRecordList := make([]*data_manage_permission.DataPermissionMoveRecord, 0)
- uniqueCode := uuid.NewUUID().Hex32()
- title := `资产转移`
- content := `资产转入`
- switch source {
- case 1: //手工数据指标
- content += `(手工指标数据)`
- tmpList, tmpErr := models.GetEdbinfoListByCodeListByCodeIdList(dataId)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.UserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: v.TradeCode,
- DataCode: v.TradeCode,
- DataName: v.SecName,
- OriginalUserId: int32(v.UserId),
- OriginalUserName: v.UserName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = models.ModifyEdbinfoUserIdByCodeList(dataId, newUserId)
- }
- case 2: //上海钢联数据库
- content += `(上海钢联数据库)`
- tmpList, tmpErr := data_manage.GetMysteelChemicalIndexListByIndexId(dataId)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.SysUserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.BaseFromMysteelChemicalIndexId),
- DataCode: v.IndexCode,
- DataName: v.IndexName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyMysteelChemicalIndexUserIdByCodeList(dataId, adminInfo.AdminId, adminInfo.RealName)
- }
- case 3, 4: //ETA指标库、ETA预测指标
- if source == 3 {
- content += `(ETA指标库)`
- } else {
- content += `(ETA预测指标)`
- }
- tmpList, tmpErr := data_manage.GetEdbInfoListByEdbInfoId(dataId)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.SysUserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.EdbInfoId),
- DataCode: v.EdbCode,
- DataName: v.EdbName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyEdbInfoUserIdByCodeList(dataId, adminInfo.AdminId, adminInfo.RealName)
- // 移除当前用户的不可操作权限
- {
- obj := data_manage.EdbInfoNoPermissionAdmin{}
- for _, v := range dataId {
- edbInfoId, _ := strconv.Atoi(v)
- go obj.DeleteByEdbInfoIdAndAdminId(edbInfoId, adminInfo.AdminId)
- }
- }
- }
- case 5: //图库
- content += `(ETA图库)`
- // 只展示eta图库
- subSource = utils.CHART_SOURCE_DEFAULT
- tmpList, tmpErr := data_manage.GetChartInfoListByChartIdList(dataId)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.SysUserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.ChartInfoId),
- DataCode: fmt.Sprint(v.ChartInfoId),
- DataName: v.ChartName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyChartInfoUserIdByCodeList(dataId, adminInfo.AdminId, adminInfo.RealName)
- }
- case 6: // ETA表格
- content += `(ETA表格)`
- tmpList, tmpErr := excel.GetNoContentExcelListByExcelInfoIdList(dataId)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.SysUserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.ExcelInfoId),
- DataCode: fmt.Sprint(v.ExcelInfoId),
- DataName: v.ExcelName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = excel.ModifyExcelInfoUserIdByCodeList(dataId, adminInfo.AdminId, adminInfo.RealName)
- }
- default:
- return
- }
- // 转移失败了那么就直接返回了
- if err != nil {
- return
- }
- // 添加资产转移的记录
- dataPermissionMessage := &data_manage_permission.DataPermissionMessage{
- DataPermissionMessageId: 0,
- SendUserId: int32(opUserId),
- ReceiveUserId: int32(adminInfo.AdminId),
- Content: title,
- Remark: content,
- OpType: 1,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- IsRead: 0,
- CreateTime: time.Now(),
- ModifyTime: time.Now(),
- }
- tmpErr := data_manage_permission.AddDataPermissionMoveRecord(dataPermissionMoveRecordList, dataPermissionMessage)
- // 失败的话,日志记录
- if tmpErr != nil {
- // 序列化结构体为 JSON 数据
- recordListJsonBytes, tmpErr2 := json.Marshal(dataPermissionMoveRecordList)
- if tmpErr2 != nil {
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;list转json失败:;操作记录:%+v;消息记录:%+v", tmpErr.Error(), dataPermissionMoveRecordList, dataPermissionMessage))
- return
- }
- // 序列化结构体为 JSON 数据
- messageJsonBytes, tmpErr2 := json.Marshal(dataPermissionMessage)
- if tmpErr2 != nil {
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;message转json失败:;操作记录:%+v;消息记录:%+v", tmpErr.Error(), dataPermissionMoveRecordList, dataPermissionMessage))
- return
- }
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;操作记录:%s;消息记录:%s", tmpErr.Error(), string(recordListJsonBytes), string(messageJsonBytes)))
- }
- return
- }
- // MoveAllEdbChartOld
- // @Description: 通过原创建人转移指标/图表创建人
- // @author: Roc
- // @datetime 2024-03-26 15:11:12
- // @param sourceList []int 1:手工数据指标 2:上海钢联数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
- // @param oldUserId []int
- // @param userId int
- // @param opUserId int
- // @return err error
- // @return errMsg string
- func MoveAllEdbChartOld(sourceList, oldUserIdList []int, userId, opUserId int) (err error, errMsg string) {
- adminInfo, err := system.GetSysAdminById(userId)
- if err != nil {
- return
- }
- // 操作记录
- dataPermissionMoveRecordList := make([]*data_manage_permission.DataPermissionMoveRecord, 0)
- uniqueCode := uuid.NewUUID().Hex32()
- title := `资产转移`
- content := `资产转入`
- sourceStrList := make([]string, 0)
- for _, source := range sourceList {
- switch source {
- case 1: //手工数据指标
- sourceStrList = append(sourceStrList, "手工指标数据")
- tmpList, tmpErr := models.GetEdbinfoListByCodeListByUserId(oldUserIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: 0,
- OpUniqueCode: uniqueCode,
- DataId: v.TradeCode,
- DataCode: v.TradeCode,
- DataName: v.SecName,
- OriginalUserId: int32(v.UserId),
- OriginalUserName: v.UserName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = models.ModifyEdbinfoUserIdByOldUserId(oldUserIdList, userId)
- }
- case 2: //上海钢联数据库
- sourceStrList = append(sourceStrList, "上海钢联数据库")
- tmpList, tmpErr := data_manage.GetMysteelChemicalIndexListByUserId(oldUserIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.SysUserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: 0,
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.BaseFromMysteelChemicalIndexId),
- DataCode: v.IndexCode,
- DataName: v.IndexName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyMysteelChemicalIndexUserIdByOldUserId(oldUserIdList, adminInfo.AdminId, adminInfo.RealName)
- }
- case 3: //ETA指标库
- sourceStrList = append(sourceStrList, "ETA指标库")
- edbInfoType := 0
- tmpList, tmpErr := data_manage.GetEdbInfoListByUserId(oldUserIdList, edbInfoType)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(edbInfoType),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.EdbInfoId),
- DataCode: v.EdbCode,
- DataName: v.EdbName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyEdbInfoUserIdByOldUserId(oldUserIdList, edbInfoType, adminInfo.AdminId, adminInfo.RealName)
- }
- case 4: //ETA预测指标
- sourceStrList = append(sourceStrList, "ETA预测指标")
- edbInfoType := 1
- tmpList, tmpErr := data_manage.GetEdbInfoListByUserId(oldUserIdList, edbInfoType)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(edbInfoType),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.EdbInfoId),
- DataCode: v.EdbCode,
- DataName: v.EdbName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyEdbInfoUserIdByOldUserId(oldUserIdList, edbInfoType, adminInfo.AdminId, adminInfo.RealName)
- }
- case 5: //ETA图库
- sourceStrList = append(sourceStrList, "ETA图库")
- // 只展示eta图库
- subSource := utils.CHART_SOURCE_DEFAULT
- tmpList, tmpErr := data_manage.GetChartInfoListByUserId(oldUserIdList, subSource)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.ChartInfoId),
- DataCode: fmt.Sprint(v.ChartInfoId),
- DataName: v.ChartName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = data_manage.ModifyChartInfoUserIdByOldUserId(oldUserIdList, adminInfo.AdminId, adminInfo.RealName)
- }
- case 6: // ETA表格
- sourceStrList = append(sourceStrList, "ETA表格")
- tmpList, tmpErr := excel.GetNoContentExcelListByUserId(oldUserIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(v.Source),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.ExcelInfoId),
- DataCode: fmt.Sprint(v.ExcelInfoId),
- DataName: v.ExcelName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- // 修改创建人
- err = excel.ModifyExcelInfoUserIdByOldUserId(oldUserIdList, adminInfo.AdminId, adminInfo.RealName)
- }
- default:
- }
- // 转移失败了那么就直接返回了
- if err != nil {
- return
- }
- }
- content += fmt.Sprintf("(%s)", strings.Join(sourceStrList, ","))
- // 添加资产转移的记录
- dataPermissionMessage := &data_manage_permission.DataPermissionMessage{
- DataPermissionMessageId: 0,
- SendUserId: int32(opUserId),
- ReceiveUserId: int32(adminInfo.AdminId),
- Content: title,
- Remark: content,
- OpType: 2,
- OpUniqueCode: uniqueCode,
- IsRead: 0,
- CreateTime: time.Now(),
- ModifyTime: time.Now(),
- }
- tmpErr := data_manage_permission.AddDataPermissionMoveRecord(dataPermissionMoveRecordList, dataPermissionMessage)
- // 失败的话,日志记录
- if tmpErr != nil {
- // 序列化结构体为 JSON 数据
- recordListJsonBytes, tmpErr2 := json.Marshal(dataPermissionMoveRecordList)
- if tmpErr2 != nil {
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;list转json失败:;操作记录:%+v;消息记录:%+v", tmpErr.Error(), dataPermissionMoveRecordList, dataPermissionMessage))
- return
- }
- // 序列化结构体为 JSON 数据
- messageJsonBytes, tmpErr2 := json.Marshal(dataPermissionMessage)
- if tmpErr2 != nil {
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;message转json失败:;操作记录:%+v;消息记录:%+v", tmpErr.Error(), dataPermissionMoveRecordList, dataPermissionMessage))
- return
- }
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;操作记录:%s;消息记录:%s", tmpErr.Error(), string(recordListJsonBytes), string(messageJsonBytes)))
- }
- return
- }
- // MoveAllEdbChart
- // @Description: 通过原创建人转移指标/图表创建人
- // @author: Roc
- // @datetime 2024-03-26 15:11:12
- // @param sourceList []int 1:手工数据指标 2:上海钢联数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
- // @param oldUserId []int
- // @param userId int
- // @param opUserId int
- // @return err error
- // @return errMsg string
- func MoveAllEdbChart(sourceList, oldUserIdList []int, userId, opUserId int) (err error, errMsg string) {
- adminInfo, err := system.GetSysAdminById(userId)
- if err != nil {
- return
- }
- // 操作记录
- dataPermissionMoveRecordList := make([]*data_manage_permission.DataPermissionMoveRecord, 0)
- uniqueCode := uuid.NewUUID().Hex32()
- title := `资产转移`
- content := `资产转入`
- sourceStrList := make([]string, 0)
- var isMoveManual, isMoveMysteelChemical, isMoveEdb, isMovePredictEdb, isMoveChart, isMoveExcel bool
- // 遍历需要转移的模块,1:手工数据指标 2:上海钢联数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格,并找出当前需要转移的资产
- for _, source := range sourceList {
- switch source {
- case 1: //手工数据指标
- sourceStrList = append(sourceStrList, "手工指标数据")
- tmpList, tmpErr := models.GetEdbinfoListByCodeListByUserId(oldUserIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: 0,
- OpUniqueCode: uniqueCode,
- DataId: v.TradeCode,
- DataCode: v.TradeCode,
- DataName: v.SecName,
- OriginalUserId: int32(v.UserId),
- OriginalUserName: v.UserName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- isMoveManual = true
- }
- case 2: //上海钢联数据库
- sourceStrList = append(sourceStrList, "上海钢联数据库")
- tmpList, tmpErr := data_manage.GetMysteelChemicalIndexListByUserId(oldUserIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- //if v.SysUserId == newUserId {
- // errMsg = "新创建人不可和原创建人一致"
- // err = errors.New(errMsg)
- // return
- //}
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: 0,
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.BaseFromMysteelChemicalIndexId),
- DataCode: v.IndexCode,
- DataName: v.IndexName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- isMoveMysteelChemical = true
- }
- case 3: //ETA指标库
- sourceStrList = append(sourceStrList, "ETA指标库")
- edbInfoType := 0
- tmpList, tmpErr := data_manage.GetEdbInfoListByUserId(oldUserIdList, edbInfoType)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(edbInfoType),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.EdbInfoId),
- DataCode: v.EdbCode,
- DataName: v.EdbName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- isMoveEdb = true
- }
- case 4: //ETA预测指标
- sourceStrList = append(sourceStrList, "ETA预测指标")
- edbInfoType := 1
- tmpList, tmpErr := data_manage.GetEdbInfoListByUserId(oldUserIdList, edbInfoType)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(edbInfoType),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.EdbInfoId),
- DataCode: v.EdbCode,
- DataName: v.EdbName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- isMovePredictEdb = true
- }
- case 5: //ETA图库
- sourceStrList = append(sourceStrList, "ETA图库")
- // 只展示eta图库
- subSource := utils.CHART_SOURCE_DEFAULT
- tmpList, tmpErr := data_manage.GetChartInfoListByUserId(oldUserIdList, subSource)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(subSource),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.ChartInfoId),
- DataCode: fmt.Sprint(v.ChartInfoId),
- DataName: v.ChartName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- isMoveChart = true
- }
- case 6: // ETA表格
- sourceStrList = append(sourceStrList, "ETA表格")
- tmpList, tmpErr := excel.GetNoContentExcelListByUserId(oldUserIdList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- if len(tmpList) > 0 {
- for _, v := range tmpList {
- // 操作记录
- dataPermissionMoveRecordList = append(dataPermissionMoveRecordList, &data_manage_permission.DataPermissionMoveRecord{
- DataPermissionMoveRecordId: 0,
- Source: int32(source),
- SubSource: int32(v.Source),
- OpUniqueCode: uniqueCode,
- DataId: fmt.Sprint(v.ExcelInfoId),
- DataCode: fmt.Sprint(v.ExcelInfoId),
- DataName: v.ExcelName,
- OriginalUserId: int32(v.SysUserId),
- OriginalUserName: v.SysUserRealName,
- NewUserId: int32(adminInfo.AdminId),
- NewUserName: adminInfo.RealName,
- CreateTime: time.Now(),
- })
- }
- isMoveExcel = true
- }
- default:
- }
- }
- // 修改创建人
- err = data_manage_permission.ModifyDataUserIdByOldUserId(oldUserIdList, adminInfo.AdminId, adminInfo.RealName, isMoveManual, isMoveMysteelChemical, isMoveEdb, isMovePredictEdb, isMoveChart, isMoveExcel)
- // 转移失败了那么就直接返回了
- if err != nil {
- return
- }
- // 添加资产转移的记录
- content += fmt.Sprintf("(%s)", strings.Join(sourceStrList, ","))
- dataPermissionMessage := &data_manage_permission.DataPermissionMessage{
- DataPermissionMessageId: 0,
- SendUserId: int32(opUserId),
- ReceiveUserId: int32(adminInfo.AdminId),
- Content: title,
- Remark: content,
- OpType: 2,
- OpUniqueCode: uniqueCode,
- IsRead: 0,
- CreateTime: time.Now(),
- ModifyTime: time.Now(),
- }
- tmpErr := data_manage_permission.AddDataPermissionMoveRecord(dataPermissionMoveRecordList, dataPermissionMessage)
- // 失败的话,日志记录
- if tmpErr != nil {
- // 序列化结构体为 JSON 数据
- recordListJsonBytes, tmpErr2 := json.Marshal(dataPermissionMoveRecordList)
- if tmpErr2 != nil {
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;list转json失败:;操作记录:%+v;消息记录:%+v", tmpErr.Error(), dataPermissionMoveRecordList, dataPermissionMessage))
- return
- }
- // 序列化结构体为 JSON 数据
- messageJsonBytes, tmpErr2 := json.Marshal(dataPermissionMessage)
- if tmpErr2 != nil {
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;message转json失败:;操作记录:%+v;消息记录:%+v", tmpErr.Error(), dataPermissionMoveRecordList, dataPermissionMessage))
- return
- }
- utils.FileLog.Error(fmt.Sprintf("添加资产转移的记录失败:%s;操作记录:%s;消息记录:%s", tmpErr.Error(), string(recordListJsonBytes), string(messageJsonBytes)))
- }
- return
- }
- // GetMoveEdbChartCount 获取待转移的指标/图表列表
- // @param userId 用户
- // @param countType 来源 :1:设置资产权限;2:设置数据权限
- func GetMoveEdbChartCount(userId, countType int) (sourceMap map[int]int, err error) {
- sourceMap = make(map[int]int)
- {
- // 手工数据指标
- var condition string
- var pars []interface{}
- if userId > 0 {
- condition += ` AND a.user_id = ? `
- pars = append(pars, userId)
- }
- total, tmpErr := models.GetEdbinfoListCount(condition, pars, "", 0)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- sourceMap[1] = total
- }
- {
- // 上海钢联数据库
- var condition string
- var pars []interface{}
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- total, tmpErr := data_manage.GetMysteelChemicalIndexCount(condition, pars)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- sourceMap[2] = total
- }
- {
- // ETA指标库
- var condition string
- var pars []interface{}
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- //ETA指标库
- condition += ` AND edb_info_type = ? `
- pars = append(pars, 0)
- total, tmpErr := data_manage.GetEdbInfoByConditionCount(condition, pars)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- sourceMap[3] = total
- }
- {
- // ETA预测指标库
- var condition string
- var pars []interface{}
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- //ETA预测指标
- condition += ` AND edb_info_type = ? `
- pars = append(pars, 1)
- total, tmpErr := data_manage.GetEdbInfoByConditionCount(condition, pars)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- sourceMap[4] = total
- }
- {
- // 图库
- var condition string
- var pars []interface{}
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- total, tmpErr := data_manage.GetChartInfoCountByCondition(condition, pars)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- sourceMap[5] = total
- }
- {
- // ETA表格
- var condition string
- var pars []interface{}
- condition += ` AND is_delete = 0 `
- if userId > 0 {
- condition += ` AND sys_user_id = ? `
- pars = append(pars, userId)
- }
- switch countType {
- case 2:
- condition += ` AND source in (2,3) `
- default:
- condition += ` AND source in (2,3,4) `
- }
- total, tmpErr := excel.GetExcelInfoCountByCondition(condition, pars)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- sourceMap[6] = total
- }
- return
- }
|