diff --git a/dsDataex/Config/Config.ini b/dsDataex/Config/Config.ini index eba8fa4e..4f601bd1 100644 --- a/dsDataex/Config/Config.ini +++ b/dsDataex/Config/Config.ini @@ -12,13 +12,20 @@ pwd = dsideal ;pwd = DsideaL147258369 [redis] -ip =server.dsmin.com -port = 18890 -db = 0 +ip = 127.0.0.1 +port = 6379 +db = 1 expireTime = 86400 +;ip =server.dsmin.com +;port = 18890 +;db = 0 +;expireTime = 86400 + + + [kafka] -KafkaAddress = 192.168.0.200:9092 +KafkaAddress = 127.0.0.1:9092 [elasticsearch] nodes = http://10.10.14.61:9200,http://10.10.14.62:9200,http://10.10.14.63:9200 diff --git a/dsDataex/GenXorm/models/t_dataex_error.go b/dsDataex/GenXorm/models/t_dataex_error.go index 141d5764..a01e82a8 100644 --- a/dsDataex/GenXorm/models/t_dataex_error.go +++ b/dsDataex/GenXorm/models/t_dataex_error.go @@ -12,6 +12,7 @@ type TDataexError struct { DataId string `json:"data_id" xorm:"not null comment('数据ID【输入参数】') VARCHAR(36)"` DataContent string `json:"data_content" xorm:"default 'NULL' comment('数据内容【Json格式输入参数】') VARCHAR"` FileUri string `json:"file_uri" xorm:"default 'NULL' comment('文件地址【文件交换】') VARCHAR(500)"` + ErrorInfo string `json:"error_info" xorm:"default 'NULL' comment('错误信息说明') VARCHAR(5000)"` CreateTime time.Time `json:"create_time" xorm:"default 'NULL' created comment('建立时间') DATETIME"` ChangeTime time.Time `json:"change_time" xorm:"default 'NULL' updated comment('最近修改时间') DATETIME"` DeleteTime time.Time `json:"delete_time" xorm:"default 'NULL' deleted comment('删除时间') DATETIME"` diff --git a/dsDataex/MyService/DataEX/DataexDAO/DataexDAO.go b/dsDataex/MyService/DataEX/DataexDAO/DataexDAO.go index 45dcc686..14fd1961 100644 --- a/dsDataex/MyService/DataEX/DataexDAO/DataexDAO.go +++ b/dsDataex/MyService/DataEX/DataexDAO/DataexDAO.go @@ -1,6 +1,7 @@ package DataexDAO import ( + "dsDataex/MyService/MySwagger" "dsDataex/Utils/CacheUtil" "dsDataex/Utils/DbUtil" "html" @@ -93,6 +94,7 @@ func CheckDatasourceSet(systemID string,datasource string) (bool, string, map[st return false, "数据源校验失败,接入系统无权操作此数据源", nil,nil } } + /** * @Author zhangjun * @Description 校验接入系统是否为数据源消费者 @@ -252,4 +254,11 @@ func CheckConsumeOrgID(consumeType int, consumeOrgid string,orgID string) (bool, break } return false, "数据权限校验不通过,无权访问此机构下属数据", nil +} + +func SaveDataError(fails []MySwagger.FailResult,esData string) (bool, string, error) { + + + + return true, "数据添加成功", nil } \ No newline at end of file diff --git a/dsDataex/MyService/DataEX/DataexService/BaseGOProc.go b/dsDataex/MyService/DataEX/DataexService/BaseGOProc.go index c29b963d..2e38d870 100644 --- a/dsDataex/MyService/DataEX/DataexService/BaseGOProc.go +++ b/dsDataex/MyService/DataEX/DataexService/BaseGOProc.go @@ -47,13 +47,38 @@ func OrgtreeProc(datas []MySwagger.Data) { } else { var areaCode string - if jsonData["area_code"].(string)[4:] != "00" { - areaCode = jsonData["area_code"].(string)[0:4] + "00" - } else { + if jsonData["area_code"].(string)[2:] == "0000" {//省级 + + areaCode="100000" + }else if jsonData["area_code"].(string)[4:] == "00" {//市级 + areaCode = jsonData["area_code"].(string)[0:2] + "0000" - } + } else { //县区级 + + areaCode = jsonData["area_code"].(string)[0:4] + "00" + + //处理直辖市 + if areaCode == "110100" { + areaCode = "110000" //北京 + } + if areaCode == "120100" { + areaCode = "120000" //天津 + } + if areaCode == "310100" { + areaCode = "310000" //上海 + } + if areaCode == "500100" { + areaCode = "500000" //重庆 + } + if areaCode == "500200" { + areaCode = "500000" + } + if areaCode == "371200" { + areaCode = "370100" //济南 + } - data.ParentId = DataexDAO.GetParentIDBaseGO(areaCode) + data.ParentId = DataexDAO.GetParentIDBaseGO(areaCode) + } } break @@ -137,6 +162,9 @@ func OrgtreeProcBatch(datas []MySwagger.Data) { var sqls []string var sql string + //补 parent_id + var sqls2 []string + var refresh = false for no:=0;no< len(datas) ;no++{ @@ -182,32 +210,40 @@ func OrgtreeProcBatch(datas []MySwagger.Data) { //处理直辖市 if areaCode=="110100"{ - areaCode="110000" + areaCode="110000"//北京 } if areaCode=="120100"{ - areaCode="120000" + areaCode="120000"//天津 } if areaCode=="310100"{ - areaCode="310000" + areaCode="310000"//上海 } if areaCode=="500100"{ - areaCode="500000" + areaCode="500000"//重庆 } if areaCode=="500200"{ areaCode="500000" } + if areaCode=="371200"{ + areaCode="370100"//济南 + } } parentID = parentMap[areaCode] - if parentID==""{ - parentID = DataexDAO.GetParentIDBaseGO(areaCode) - } - //处理教育部 if jsonData["area_code"].(string)=="100000"{ parentID="0" } + + //delete by zhangjun 2020-07-17 + //if parentID==""{ + // parentID = DataexDAO.GetParentIDBaseGO(areaCode) + //} + + if parentID==""{ + sqls2=append(sqls2,"update t_dataex_orgtree set parent_id =(select id from t_dataex_orgtree where org_type=1 and area_id='" + areaCode + "') where id='"+IDs[no] +"'") + } }else { parentID = parentMap[jsonData["area_code"].(string)] @@ -216,8 +252,10 @@ func OrgtreeProcBatch(datas []MySwagger.Data) { } } } - - + //是否需要刷新 机构访问控制缓存 + if Contains( CacheUtil.PARENT_IDS,parentID)>-1{ + refresh=true + } var provinceId = jsonData["province_code"].(string) @@ -247,6 +285,15 @@ func OrgtreeProcBatch(datas []MySwagger.Data) { } DbUtil.Engine.Sqls(sqls).Execute() + + if len(sqls2)>0{ + DbUtil.Engine.Sqls(sqls2).Execute() + } + + //缓存命中、缓存为空、parent_id未知 刷新缓存 + if refresh || len(CacheUtil.PARENT_IDS)==0 || len(sqls2)>0{ + CacheUtil.RefreshOrgtree() + } } func Contains(array interface{}, val interface{}) (index int) { diff --git a/dsDataex/Utils/CacheUtil/OrgtreeCache.go b/dsDataex/Utils/CacheUtil/OrgtreeCache.go index 55eb46e0..3014c1bf 100644 --- a/dsDataex/Utils/CacheUtil/OrgtreeCache.go +++ b/dsDataex/Utils/CacheUtil/OrgtreeCache.go @@ -12,6 +12,8 @@ var GBT2260 map[string]string var XXBXLXM map[string]string +var PARENT_IDS []string + /** * @Author zhangjun * @Description 组织机构树缓存初始化,【机构下属学校】递归查询、并缓存 Redis @@ -29,6 +31,8 @@ func OrgtreeCacheInit(){ list, count, _ := Page(sql, 1000,0) + PARENT_IDS=make([]string,0) + if count>0{ for no:=0;no0{ Orgtree2Redis(list2,"Dataex_Scope_"+list[no]["id"].(string)) + PARENT_IDS =append(PARENT_IDS,list[no]["id"].(string)) + OrgCacheCreate(list[no]["id"].(string),list[no]["id"].(string)) } } @@ -115,6 +121,36 @@ func OrgtreeCacheInit(){ XXBXLXM["933"]="其他培训机构" } +func RefreshOrgtree(){ + + //删除Redis缓存 + RedisUtil.RedisClient.FlushDB() + + //机构树缓存 + sql := "SELECT id from t_dataex_orgtree where delete_flag = -1 and enable_flag = 1 and parent_id = '-1'" + + list, count, _ := Page(sql, 1000,0) + + if count>0{ + for no:=0;no0{ + Orgtree2Redis(list2,"Dataex_Scope_"+list[no]["id"].(string)) + + PARENT_IDS =append(PARENT_IDS,list[no]["id"].(string)) + + OrgCacheCreate(list[no]["id"].(string),list[no]["id"].(string)) + } + } + } + } +} + /** * @Author zhangjun * @Description 刷新机构下属学校缓存 @@ -138,6 +174,8 @@ func OrgCacheCreate(orgID string,scope... string) { if count2>0{ Orgtree2Redis(list2,"Dataex_Scope_"+list[no]["id"].(string)) + PARENT_IDS =append(PARENT_IDS,list[no]["id"].(string)) + var newscope =append( scope ,list[no]["id"].(string)) for no:=0;no