|  | @@ -58,12 +58,34 @@ class GljDao {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      //获得用户的补充工料机和用户当前所在编办的标准工料机
 | 
	
		
			
				|  |  | -    getGljItems (stdGljLibId, userId, compilationId, callback){
 | 
	
		
			
				|  |  | +    async getGljItems (stdGljLibId, userId, compilationId, callback){
 | 
	
		
			
				|  |  |          let me = this;
 | 
	
		
			
				|  |  |          let rst = {stdGljs: [], complementaryGljs: []};
 | 
	
		
			
				|  |  | +        //批量获取异步
 | 
	
		
			
				|  |  | +       /* let functions = [];
 | 
	
		
			
				|  |  | +        let count = await stdGljModel.find({repositoryId: stdGljLibId, $or: [{deleted: null}, {deleted: false}]}).count();
 | 
	
		
			
				|  |  | +        let findCount = Math.ceil(count/500);
 | 
	
		
			
				|  |  | +        for(let i = 0, len = findCount; i < len; i++){
 | 
	
		
			
				|  |  | +            functions.push((function(flag) {
 | 
	
		
			
				|  |  | +                return function (cb) {
 | 
	
		
			
				|  |  | +                    stdGljModel.find({repositoryId: stdGljLibId, deleted: null}, cb).skip(flag).sort({ID: 1}).limit(500);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            })(i*500));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        async.parallel(functions,  function (err, results) {
 | 
	
		
			
				|  |  | +            if(err){
 | 
	
		
			
				|  |  | +                callback(err, null);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else{
 | 
	
		
			
				|  |  | +                for(let stdGljs of results){
 | 
	
		
			
				|  |  | +                    rst.stdGljs = rst.stdGljs.concat(stdGljs);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                callback(0, rst);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });*/
 | 
	
		
			
				|  |  |          async.parallel([
 | 
	
		
			
				|  |  | -            function (cb) {
 | 
	
		
			
				|  |  | -                stdGljModel.find({repositoryId: stdGljLibId}, function (err, stdGljs) {
 | 
	
		
			
				|  |  | +           async function (cb) {
 | 
	
		
			
				|  |  | +               /* stdGljModel.find({repositoryId: stdGljLibId}, function (err, stdGljs) {
 | 
	
		
			
				|  |  |                      if(err){
 | 
	
		
			
				|  |  |                          cb(err);
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -72,7 +94,48 @@ class GljDao {
 | 
	
		
			
				|  |  |                          rst.stdGljs = stdGljs;
 | 
	
		
			
				|  |  |                          cb(null);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | +                });*/
 | 
	
		
			
				|  |  | +               try{
 | 
	
		
			
				|  |  | +                   let stdGljs = [];
 | 
	
		
			
				|  |  | +                   let first = await stdGljModel.find({repositoryId: stdGljLibId}).sort({ID: 1}).limit(1);
 | 
	
		
			
				|  |  | +                   let count = await stdGljModel.find({repositoryId: stdGljLibId, $or: [{deleted: null}, {deleted: false}]}).count();
 | 
	
		
			
				|  |  | +                   let findCount = Math.ceil(count/500);
 | 
	
		
			
				|  |  | +                   let flag = first[0].ID;
 | 
	
		
			
				|  |  | +                   //let flag = 0;
 | 
	
		
			
				|  |  | +                   //批量获取,非skip
 | 
	
		
			
				|  |  | +                   for(let i = 0, len = findCount; i < len; i++){
 | 
	
		
			
				|  |  | +                       let tempStdGlj;
 | 
	
		
			
				|  |  | +                       if(i === 0){
 | 
	
		
			
				|  |  | +                           tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null, ID: {$gte: flag}}).sort({ID: 1}).limit(500);
 | 
	
		
			
				|  |  | +                           if(tempStdGlj.length > 0){
 | 
	
		
			
				|  |  | +                               flag = tempStdGlj[tempStdGlj.length - 1].ID;
 | 
	
		
			
				|  |  | +                           }
 | 
	
		
			
				|  |  | +                       }
 | 
	
		
			
				|  |  | +                       else {
 | 
	
		
			
				|  |  | +                           tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null, ID: {$gt: flag}}).sort({ID: 1}).limit(500);
 | 
	
		
			
				|  |  | +                           if(tempStdGlj.length > 0){
 | 
	
		
			
				|  |  | +                               flag = tempStdGlj[tempStdGlj.length - 1].ID;
 | 
	
		
			
				|  |  | +                           }
 | 
	
		
			
				|  |  | +                       }
 | 
	
		
			
				|  |  | +                       if(tempStdGlj){
 | 
	
		
			
				|  |  | +                           stdGljs = stdGljs.concat(tempStdGlj);
 | 
	
		
			
				|  |  | +                       }
 | 
	
		
			
				|  |  | +                   }
 | 
	
		
			
				|  |  | +               /*    for(let i = 0, len = findCount; i < len; i++){
 | 
	
		
			
				|  |  | +                       let tempStdGlj = await stdGljModel.find({repositoryId: stdGljLibId, deleted: null}).skip(flag).sort({ID: 1}).limit(500);
 | 
	
		
			
				|  |  | +                       if(tempStdGlj.length > 0){
 | 
	
		
			
				|  |  | +                           flag = flag + 500;
 | 
	
		
			
				|  |  | +                           stdGljs = stdGljs.concat(tempStdGlj);
 | 
	
		
			
				|  |  | +                       }
 | 
	
		
			
				|  |  | +                   }*/
 | 
	
		
			
				|  |  | +                   me.sortToNumber(stdGljs);
 | 
	
		
			
				|  |  | +                   rst.stdGljs = stdGljs;
 | 
	
		
			
				|  |  | +                   cb(null);
 | 
	
		
			
				|  |  | +               }
 | 
	
		
			
				|  |  | +               catch (err){
 | 
	
		
			
				|  |  | +                   cb(err);
 | 
	
		
			
				|  |  | +               }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              function (cb) {
 | 
	
		
			
				|  |  |                  complementaryGljModel.find({userId: userId, compilationId: compilationId}, function (err, complementaryGljs) {
 |