package CacheUtil import ( "dsDataex/Utils/ErrorConst" "dsDataex/Utils/LogUtil" "dsDataex/Utils/RedisUtil" "strings" "time" ) var GBT2260 map[string]string /** * @Author zhangjun * @Description 组织机构树缓存初始化,【机构下属学校】递归查询、并缓存 Redis * @Description TODO:如果性能还不行,使用全局静态变量存储【机构下属学校】!!!!! * @Date 2020-06-16 10:06 * @Param * @return **/ func OrgtreeCacheInit(){ //删除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)) OrgCacheCreate(list[no]["id"].(string),list[no]["id"].(string)) } } } } //行政区划缓存 sql = "SELECT area_code from t_dataex_gbt2260" list,_,_= Page(sql, 5000,0) GBT2260=make( map[string]string) for no:=0;no< len(list);no++{ GBT2260[list[no]["area_code"].(string)]=list[no]["area_name"].(string) } } /** * @Author zhangjun * @Description 刷新机构下属学校缓存 * @Date 2020-06-16 10:14 * @Param orgID string 教育局机构ID * @return **/ func OrgCacheCreate(orgID string,scope... string) { sql := "SELECT id from t_dataex_orgtree where delete_flag = -1 and enable_flag = 1 and parent_id = '" + orgID + "'" list, count, _ := Page(sql, 1000,0) if count>0{ for no:=0;no0{ Orgtree2Redis(list2,"Dataex_Scope_"+list[no]["id"].(string)) var newscope =append( scope ,list[no]["id"].(string)) for no:=0;no0{ return true } return false } func OrgtreeGetScope(orgId string) []string { result,_:= RedisUtil.RedisClient.Get("Dataex_Scope_"+orgId).Result() if result != ""{ return strings.Split(result,"##") } return nil }