获取管辖职位

1. 低于自己的职位
779588
public function getPositions()
	{
		$me = Member::find($this->selfId)->position;

		$code = Position::find($me)->order;

		$recs = Position::where('order','>', $code)->orderBy('order','DESC')->get();

		$arr = [];
		if(count($recs)){
			foreach ($recs as $rec) {
				$arr = array_add($arr, $rec->id, $rec->name);
			}
		}else{
			//最低职位的人员, 无管辖职位,返回空数组
			//die('FooWeChat\Authorize\Auth\getDepartments: 记录异常');
			//return view('40x',['color'=>'danger', 'type'=>'1', 'code'=>'1.2']);
		}
		return $arr;
	}
751915
function getRowSample1() {
  //设置读取最新版本，默认为1
  params.maxVersions = 1;
  //设置读取指定的列
  params.columnsToGet = ["Col1", "Col2"];
  client.getRow(params, function (err, data) {
    if (err) {
      console.log('error:', err);
      return;
    }
    console.log('success:', data);
  });
}
256637
function parseValue (num) {
  if (num === '') return '0'

  const numStr = _toString(num)
  if (numStr.indexOf('0') === 0
    && numStr.indexOf('.') === -1) {
    // 处理01变成1,并且不处理1.
    return _toString(parseFloat(num))
  }
  return _toString(num)
}
1092383
function init(element, callback, extraOptions /* Internal Use Only */ ) {
            // 初始化任务队列
            // var queue = Util.queue() // #20

            // 如果已经被初始化，则立即返回
            var clientId = element.clientId
            if (clientId !== undefined) {
                if (callback) callback(undefined, CACHE[clientId])
                return
            }

            // 如果没有模块标识符，则不需要初始化
            if (!element.getAttribute(Constant.ATTRS.id)) {
                if (callback) callback(undefined, undefined)
                return
            }

            // 1. 解析配置项
            var options = Options.parse(element)
            if (extraOptions) Util.extend(options, extraOptions)

            var BrixImpl, instance

            var label = 'module ' + options.moduleId + ' ' + options.clientId
            if (DEBUG) {
                console.group(label)
                console.time(label)
                var _callback = callback
                callback = function(error, instance) {
                    console.timeEnd(label)
                    console.groupEnd(label)
                    if (_callback) _callback(error, instance)
                }
            }

            __loadModule()

            function __loadModule(next) {
                next = next || __createInstance

                // 2. 加载组件模块
                // load module file
                /* jshint unused:false */
                // try {
                //     // 尝试快速获取已经加载过的模块
                //     BrixImpl = require(options.moduleId)
                //     setTimeout(next, 4)
                //     return
                // } catch (error) {}

                require([options.moduleId], function __loadModuleComplete(module) {
                    BrixImpl = module
                    next()
                }, function(error) {
                    // http://requirejs.org/docs/api.html#errbacks
                    if (callback) callback(new Error(error.message), instance)
                    else console.error(error.stack || error)

                    if (Loader.onerror) {
                        error.moduleId = options.moduleId
                        Loader.onerror(error) // 运行时异常收集
                    }
                })
            }

            function __createInstance(next) {
                next = next || __interceptInstanceDestroy

                try {
                    // 在组件模块上附加标记 __x_created_with，指示负责初始化的是 Brix Loader
                    // Add a mark to component module, indicating the Brix Loader is response for the initializing.
                    var __x_created_with = BrixImpl.__x_created_with
                    BrixImpl.__x_created_with = 'Brix Loader'

                    // 3. 创建组件实例（按需传入参数 options）
                    // Create a new module instance
                    instance = BrixImpl.length ? new BrixImpl(options) : new BrixImpl()

                    // 恢复标记
                    // Recovery the mark
                    BrixImpl.__x_created_with = __x_created_with

                    // 设置实例属性 options
                    instance.options = Util.extend(true, {}, instance.options, options)

                    // 设置其他公共属性
                    Util.extend(instance, Util.pick(options, Constant.OPTIONS))
                    instance.element.setAttribute('data-clientId', options.clientId)

                    next()
                } catch (error) {
                    if (callback) callback(error, instance)
                    else console.error(error.stack || error)

                    if (Loader.onerror) {
                        error.moduleId = options.moduleId
                        Loader.onerror(error) // 运行时异常收集
                    }
                }
            }

            function __interceptInstanceDestroy(next) {
                next = next || __cacheInstance

                // 拦截销毁方法
                // intercept destroy method of the module instance
                instance._destroy = instance.destroy
                instance.destroy = function() {
                    destroy(false, instance)
                }
                next()
            }

            function __cacheInstance(next) {
                next = next || __callInstanceInitialization

                // 缓存起来，关联父组件
                // cache the module instance
                cache(instance)
                next()
            }

            function __callInstanceInitialization(next) {
                next = next || __interceptInstanceRender

                // 4. 执行初始化
                // exec module instance initialize
                if (!instance.init) {
                    next()
                    return
                }

                try {
                    if (DEBUG) console.time(label + ' call  init')
                    var result = instance.init()
                    if (DEBUG) console.timeEnd(label + ' call  init')

                    // 如果返回了 Promise，则依赖 Promise 的状态
                    if (result && result.then) {
                        result.then(function() {
                            next()
                        }, function(error) {
                            throw error
                        })
                    } else {
                        next()
                    }
                } catch (error) {
                    if (callback) callback(error, instance)
                    else console.error(error)

                    if (Loader.onerror) {
                        error.moduleId = options.moduleId
                        Loader.onerror(error) // 运行时异常收集
                    }
                }
            }

            function __interceptInstanceRender(next) {
                next = next || __callInstanceRender

                // 拦截渲染方法
                // intercept render method of the module instance
                if (instance._render) {
                    next()
                    return
                }

                instance._render = instance.render
                instance.render = function() {
                    var deferred = Util.defer()
                    var promise = deferred.promise

                    // 如果存在已经被渲染的子组件，则先销毁
                    var hasRenderedChildren
                    if (instance.childClientIds.length) {
                        hasRenderedChildren = true
                        Util.each(instance.childClientIds, function(childClientId) {
                            if (CACHE[childClientId]) destroy(childClientId)
                        })
                    }
                    // 调用组件的 .render()
                    var result
                    if (instance._render) result = instance._render.apply(instance, arguments)
                    else console.warn(instance.clientId, instance.moduleId, 'render() is not defined')

                    // 如果返回了 Promise，则依赖 Promise 的状态
                    if (result && result.then) {
                        result.then(function() {
                            renderChildren()
                            syncClientId()
                        }, function(error) {
                            throw error
                        })
                    } else {
                        renderChildren()
                        syncClientId()
                    }

                    return promise

                    // 再次初始化子组件
                    function renderChildren() {
                        if (hasRenderedChildren) {
                            boot(instance.element, function( /* context */ ) {
                                deferred.resolve()
                            })
                        } else {
                            deferred.resolve()
                        }
                    }

                    // 同步 clientId
                    function syncClientId() {
                        var relatedElement = instance.relatedElement || instance.$relatedElement
                        if (relatedElement) {
                            // element
                            if (relatedElement.nodeType && (relatedElement.clientId === undefined)) {
                                relatedElement.clientId = options.clientId
                            } else if (relatedElement.length) {
                                // [ element ]
                                Util.each(relatedElement, function(item /*, index*/ ) {
                                    if (item.nodeType && (item.clientId === undefined)) {
                                        item.clientId = options.clientId
                                        item.setAttribute('data-moduleId', options.moduleId)
                                        item.setAttribute('data-clientId', options.clientId)
                                    }
                                })
                            }
                        }
                    }

                }
                next()
            }

            function __callInstanceRender(next) {
                next = next || __bindLifecycleEvent

                // 5. 执行渲染（不存在怎么办？必须有！）
                // exec render method of the module instance
                try {
                    if (DEBUG) console.time(label + ' call  render')
                    var result = instance.render(function(error /*, instance*/ ) {
                        if (error) {}
                    })
                    if (DEBUG) console.timeEnd(label + ' call  render')

                    // deferred
                    if (result && result.then) {
                        result.then(function() {
                            next()
                        }, function(error) {
                            if (callback) callback(error, instance)
                            else console.error(error.stack || error)

                            if (Loader.onerror) {
                                error.moduleId = options.moduleId
                                Loader.onerror(error) // 运行时异常收集
                            }
                        })
                    } else {
                        next()
                    }
                } catch (error) {
                    // TODO 渲染时发生错误的组件是否应该自动销毁？
                    if (callback) callback(error, instance)
                    else console.error(error.stack || error)

                    if (Loader.onerror) {
                        error.moduleId = options.moduleId
                        Loader.onerror(error) // 运行时异常收集
                    }
                }
            }

            function __bindLifecycleEvent(next) {
                next = next || __inspectDescendants

                // 绑定测试事件
                // bind lifecycle event of the module instance
                if (DEBUG && instance.on) {
                    Util.each(Constant.EVENTS, function(type) {
                        instance.on(type + Constant.LOADER_NAMESPACE, function(event) {
                            console.log(label, 'event', event.type)
                        })
                    })
                }
                next()
                    // .delay(100) // 每个组件之间的渲染间隔 100ms，方便观察
            }

            function __inspectDescendants(next) {
                next = next || __triggerReadyEvent

                // 检测是否有后代组件
                var descendants = element.getElementsByTagName('*')
                var hasBrixElement = false
                Util.each(descendants, function(descendant /*, index*/ ) {
                    if (descendant.nodeType !== 1) return
                    if (!hasBrixElement &&
                        descendant.getAttribute(Constant.ATTRS.id)) {
                        hasBrixElement = true
                    }
                })

                // 7. 如果有后代组件，则递归加载
                // boot descendants recursively
                if (hasBrixElement) {
                    boot(instance, function() {
                        next()
                    })
                } else {
                    // 如果没有后代组件，那么此时当前组件已经就绪。
                    next()
                }
            }

            function __triggerReadyEvent( /*next*/ ) {
                // 8. 当前组件和后代组件的渲染都完成后，触发 ready 事件
                // trigger ready event after current module instance and it's descendants are rendered
                if (instance.triggerHandler) {
                    instance.triggerHandler(Constant.EVENTS.ready)
                }
                if (callback) callback(undefined, instance)
            }
        }
486531
private function f1()
    {
        $_linkstr = "\n<p class=\"links\">\n"; //begin
        if ($this->totalpage < 2) {
            $nextpage = $this->cpage + 1;
            $_linkstr .= "<span class=\"disabled\">首页</span>" . " \n";
            $_linkstr .= "<span class=\"disabled\">上一页</span> \n";
            $_linkstr .= "<span class=\"disabled\">下一页</span> \n";
            $_linkstr .= "<span class=\"disabled\">尾页</span> \n";
        } elseif ($this->cpage < 2) {
            // 首页
            $nextpage = $this->cpage + 1;
            $_linkstr .= "<span class=\"disabled\">首页</span>" . " \n";
            $_linkstr .= "<span class=\"disabled\">上一页</span> \n";
            $_linkstr .= "<a href=\"" . $this->url ( $nextpage ) . "\">下一页</a> \n";
            $_linkstr .= "<a href=\"" . $this->url ( $this->totalpage ) . "\">尾页</a> \n";
        } elseif ($this->cpage >= $this->totalpage) {
            // ＝尾页
            $prepage = $this->cpage - 1;

            $_linkstr .= "<a href=\"" . $this->url ( 1 ) . "\">首页</a>\n";
            $_linkstr .= "<a href=\"" . $this->url ( $prepage ) . "\">上一页</a>\n";
            $_linkstr .= "\n<span class=\"disabled\">下一页</span>\n";
            $_linkstr .= "<span class=\"disabled\">尾页</span>" . "\n";
        } else {
            // 正常
            $prepage  = $this->cpage - 1;
            $nextpage = $this->cpage + 1;

            $_linkstr .= "<a href=\"" . $this->url ( 1 ) . "\">首页</a>\n";
            $_linkstr .= "<a href=\"" . $this->url ( $prepage ) . "\">上一页</a>\n";
            $_linkstr .= "\n<a href=\"" . $this->url ( $nextpage ) . "\">下一页</a>\n";
            $_linkstr .= "<a href=\"" . $this->url ( $this->totalpage ) . "\">尾页</a>\n";
        }
        $_linkstr .= "</p>\n"; //end div
        return $_linkstr;
    }
1104765
function (unloadedMods, errorList, stack, cache, ret) {
            var i, m, mod, modStatus,
                stackDepth,
                self = this;

            if ('@DEBUG@') {
                stack = stack || [];
            }
            ret = ret || [];
            // 提高性能，不用每个模块都再次全部依赖计算
            // 做个缓存，每个模块对应的待动态加载模块
            cache = cache || {};

            for (i = 0; i < unloadedMods.length; i++) {
                mod = unloadedMods[i];
                m = mod.name;

                if (cache[m]) {
                    continue;
                }

                if ('@DEBUG@') {
                    stackDepth = stack.length;
                }

                modStatus = mod.status;
                if (modStatus === ERROR) {
                    errorList.push(mod);
                    cache[m] = 1;
                    continue;
                }
                if (modStatus > LOADED) {
                    cache[m] = 1;
                    continue;
                } else if (modStatus !== LOADED && !mod.contains(self)) {
                    if (modStatus !== LOADING) {
                        mod.status = LOADING;
                        ret.push(mod);
                    }
                    mod.add(self);
                    self.wait(mod);
                }

                if ('@DEBUG@') {
                    // do not use indexOf, poor performance in ie8
                    if (stack[m]) {
                        S.log('find cyclic dependency between mods: ' + stack, 'warn');
                        cache[m] = 1;
                        continue;
                    } else {
                        stack[m] = 1;
                        stack.push(m);
                    }
                }

                self.calculate(mod.getNormalizedRequiredModules(), errorList, stack, cache, ret);
                cache[m] = 1;
                if ('@DEBUG@') {
                    for (var si = stackDepth; si < stack.length; si++) {
                        stack[stack[si]] = 0;
                    }
                    stack.length = stackDepth;
                }
            }

            return ret;
        }
812890
function parseFunction (node) {
	const args = [];
	let index = 0;
	node.nodes.forEach((subNode) => {
		if (subNode.type === "div" && subNode.value === ",") {
			// 遇到`,`下标自加1
			index++;
			return;
		} else if (subNode.type === "function") {
			// 将参数中的`color-stop`,`from`,`to`三种function特殊处理
			if ((subNode.value === "from" || subNode.value === "to" || subNode.value === "color-stop")) {
				let colorStop = subNode.nodes.filter((colorStopInfo) => {
					// colorStop的子节点，除function和word外，都丢去
					return colorStopInfo.type === "function" || colorStopInfo.type === "word";
				}).map((colorStopInfo) => {
					// colorStop的子节点，转换为字符串
					return valueParser.stringify(colorStopInfo);
				});

				// 组装新的对象传递出去
				colorStop = {
					nodes: colorStop,
					type: "function",
					value: subNode.value,
				};

				// 不使用第三个数组维度，而是将其存在最上面的维度上
				args[index] = colorStop;
				return args[index];
			}
		} else if (subNode.type !== "word") {
			return;
		}

		if (!args[index]) {
			// 如果未初始化该数组维度，对其初始化
			args[index] = [];
		}
		// 未特殊处理的function，还有普通的word，将其转字符串
		args[index].push(valueParser.stringify(subNode));
	});
	// 返回转换后的数组
	return args;
}
1038544
public function init()
    {
        // 缓存实例代码是否设置
        if (!empty($this->cacheInstanceString)) {
            $cache = str_eval($this->cacheInstanceString);
            if (isset($cache) && $cache instanceof Store) {
                $this->cache = $cache;
            }
        }

        // urlRule 预处理
        if (null === $this->cache) {
            $this->_rules = $this->parseUrlRule();
        } else if (null !== ($rules = $this->cache->get(self::CACHE_KEY))) {
            $this->_rules = $rules;
        } else {
            $this->_rules = $this->parseUrlRule();
            $this->cache->set(self::CACHE_KEY, $this->_rules);
        }
    }
1287638
function(node, attributes) {
      var len = attributes.length,
        operatorFilters = expandFilters["operators"];

      for (; len--;) {
        var attribute = attributes[len],
          operator = attribute["operator"],
          filter = operatorFilters[operator],
          nodeValue = getAttribute(node, attribute.key);

          if (nodeValue === null) {
            if (operator !== "!=") return false;
            continue;
          }
        if (!operator) continue;
        if (!filter) throw Error("不支持的操作符:" + operator);
        if (!filter(attribute.value, nodeValue + "")) return false;
      }
      return true;
    }
211994
private static String getNoSign(Map<String, Object> params, boolean includeEmptyParam) {
        //对参数按照key做升序排序，对map的所有value进行处理，转化成string类型
        //拼接成key=value&key=value&....格式的字符串
        StringBuilder content = new StringBuilder();

        // 按照key做排序
        List<String> keys = new ArrayList<String>(params.keySet());
        Collections.sort(keys);

        String value = null;
        Object object = null;
        boolean isFirstParm = true;
        for (int i = 0; i < keys.size(); i++) {
            String key = (String) keys.get(i);
            object = params.get(key);

            if (object == null) {
                value = "";
            }else if (object instanceof String) {
                value = (String) object;
            } else {
                value = String.valueOf(object);
            }

            if (includeEmptyParam || !TextUtils.isEmpty(value)) {
                content.append((isFirstParm ? "" : "&") + key + "=" + value);
                isFirstParm = false;
            } else {
                continue;
            }
        }

        //待签名的字符串
        return content.toString();
    }
1020087
@Override
    public void recognition(Term[] terms) {
        int length = terms.length - 1;
        Term from = null;
        Term to = null;
        Term temp = null;
        for (int i = 0; i < length; i++) {
            if (terms[i] == null) {
                continue;
            } else if (".".equals(terms[i].getName()) || "．".equals(terms[i].getName())) {
                // 如果是.前后都为数字进行特殊处理
                to = terms[i].to();
                from = terms[i].from();
                if (from.termNatures().numAttr.flag && to.termNatures().numAttr.flag) {
                    from.setName(from.getName() + "." + to.getName());
                    TermUtil.termLink(from, to.to());
                    terms[to.getOffe()] = null;
                    terms[i] = null;
                    i = from.getOffe() - 1;
                }
                continue;
            } else if (!terms[i].termNatures().numAttr.flag) {
                continue;
            }

            temp = terms[i];
            // 将所有的数字合并
            while ((temp = temp.to()).termNatures().numAttr.flag) {
                terms[i].setName(terms[i].getName() + temp.getName());
            }
            // 如果是数字结尾
            if (MyStaticValue.isQuantifierRecognition && temp.termNatures().numAttr.numEndFreq > 0) {
                terms[i].setName(terms[i].getName() + temp.getName());
                temp = temp.to();
            }

            // 如果不等,说明terms[i]发生了改变
            if (terms[i].to() != temp) {
                TermUtil.termLink(terms[i], temp);
                // 将中间无用元素设置为null
                for (int j = i + 1; j < temp.getOffe(); j++) {
                    terms[j] = null;
                }
                i = temp.getOffe() - 1;
            }
        }

    }
1264017
private void buildNode(Node parent, List<String>[] sequence, int from, List<Node> leaf){
        //递归退出条件：二维数组遍历完毕
        if(from >= sequence.length){
            //记住叶子节点
            leaf.add(parent);
            return;
        }
        for(String item : sequence[from]){
            Node child = new Node(item, parent);
            buildNode(child, sequence, from+item.length(), leaf);
        }
    }
323133
public void showConflict(){
        int emptySlot=0;
        //key:冲突长度 value:冲突个数
        Map<Integer, Integer> map = new HashMap<>();
        for(TrieNode<V> node : ROOT_NODES_INDEX){
            if(node == null){
                emptySlot++;
            }else{
                int i=0;
                while((node = node.getSibling()) != null){
                    i++;
                }
                if(i > 0){
                    Integer count = map.get(i);
                    if(count == null){
                        count = 1;
                    }else{
                        count++;
                    }
                    map.put(i, count);
                }
            }
        }
        int count=0;
        for(int key : map.keySet()){
            int value = map.get(key);
            count += key*value;
            LOGGER.info("冲突次数为："+key+" 的元素个数："+value);
        }
        LOGGER.info("冲突次数："+count);
        LOGGER.info("总槽数："+INDEX_LENGTH);
        LOGGER.info("用槽数："+(INDEX_LENGTH-emptySlot));
        LOGGER.info("使用率："+(float)(INDEX_LENGTH-emptySlot)/INDEX_LENGTH*100+"%");
        LOGGER.info("剩槽数："+emptySlot);
    }
271178
function (params) {
      var item = params[this._getNum(params.length - 1)];
      // 枚举类型可以没有属性
      if (!item) {
        return null;
      }
      var enumEleType = params && params[0].type;
      var enumEleDatatype = this.ds.find(function (dt) {
        return dt.id === enumEleType;
      });
      var enumEleSysType = null;
      if (enumEleDatatype.params.length) {
        // 自定义的字符或者数值类型
        // enumEleSysType = enumEleDatatype.params[0].type;
        // 根据 format 取值，这里有些老数据，params 的值没有正确设置
        if (enumEleDatatype.format === 4) {
          // 数值类型
          enumEleSysType = 10002;
        } else {
          // 其他都是字符串类型
          enumEleSysType = 10001;
        }
      } else {
        enumEleSysType = enumEleDatatype.id;
      }
      return this._getMockOfSysDatatype({
        id: enumEleSysType,
        defaultValue: item.defaultValue,
        genExpression: item.genExpression
      });
    }
422790
function(start, end, step) { // 用于生成整数数组
            step || (step = 1)
            if (end == null) {
                end = start || 0
                start = 0
            }
            var index = -1,
                    length = Math.max(0, Math.ceil((end - start) / step)),
                    result = Array(length)
            while (++index < length) {
                result[index] = start
                start += step
            }
            return result
        }
1213221
function () {
            var me = this;
            function optimze( range ) {
                var child = me.document.body.firstChild,
                    collapsed = range.collapsed;
                while ( child && child.firstChild ) {
                    range.setStart( child, 0 );
                    child = child.firstChild;
                }
                if ( !range.startContainer ) {
                    range.setStart( me.document.body, 0 )
                }
                if ( collapsed ) {
                    range.collapse( true );
                }
            }

            if ( me._cachedRange != null ) {
                return this._cachedRange;
            }
            var range = new baidu.editor.dom.Range( me.document );

            if ( browser.ie9below ) {
                var nativeRange = me.getIERange();
                if ( nativeRange ) {
                    //备份的_bakIERange可能已经实效了，dom树发生了变化比如从源码模式切回来，所以try一下，实效就放到body开始位置
                    try{
                        transformIERangeToRange( nativeRange, range );
                    }catch(e){
                        optimze( range );
                    }

                } else {
                    optimze( range );
                }
            } else {
                var sel = me.getNative();
                if ( sel && sel.rangeCount ) {
                    var firstRange = sel.getRangeAt( 0 );
                    var lastRange = sel.getRangeAt( sel.rangeCount - 1 );
                    range.setStart( firstRange.startContainer, firstRange.startOffset ).setEnd( lastRange.endContainer, lastRange.endOffset );
                    if ( range.collapsed && domUtils.isBody( range.startContainer ) && !range.startOffset ) {
                        optimze( range );
                    }
                } else {
                    //trace:1734 有可能已经不在dom树上了，标识的节点
                    if ( this._bakRange && domUtils.inDoc( this._bakRange.startContainer, this.document ) ){
                        return this._bakRange;
                    }
                    optimze( range );
                }
            }
            return this._bakRange = range;
        }
579482
function(command, bodyLength, status) {
        if (null == bodyLength) {
            bodyLength = 0
        }

        if (null == status) {
            status = 0
        }

        // ----------- 存放1字节的command和1字节的status
        var buffer = new Buffer(2)
        buffer.writeUInt8(command, 0)
        buffer.writeUInt8(status, 1)

        // 生成8bytes存放body length的buffer
        var blBuffer = helpers.number2Buffer(bodyLength, 8)

        // 拼接
        return Buffer.concat([blBuffer, buffer])
    }