| 
					
				 | 
			
			
				@@ -728,12 +728,25 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async updateToLedger(transaction, tid, cid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 找出本条变更属于新增部位的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.gcl_id WHERE b.tid = ? AND b.cid = ? GROUP BY a.id'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam = [this.ctx.service.changeLedger.tableName, this.tableName, tid, cid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const result = await transaction.query(sql, sqlParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql2 = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.mx_id WHERE b.tid = ? AND b.cid = ?'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam2 = [this.ctx.service.changePos.tableName, this.tableName, tid, cid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const result2 = await transaction.query(sql2, sqlParam2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const allList = await transaction.select(this.tableName, { where: { tid, cid } }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const result = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const result2 = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (const l of allList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const changeLedgerInfo = await transaction.get(this.ctx.service.changeLedger.tableName, { id: l.gcl_id }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (changeLedgerInfo && this._.findIndex(result, { id: l.gcl_id }) === -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    result.push(changeLedgerInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const changePosInfo = await transaction.get(this.ctx.service.changePos.tableName, { id: l.mx_id }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (changePosInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    result2.push(changePosInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const sql = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.gcl_id WHERE b.tid = ? AND b.cid = ? GROUP BY a.id'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const sqlParam = [this.ctx.service.changeLedger.tableName, this.tableName, tid, cid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const result = await transaction.query(sql, sqlParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const sql2 = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.mx_id WHERE b.tid = ? AND b.cid = ?'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const sqlParam2 = [this.ctx.service.changePos.tableName, this.tableName, tid, cid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // const result2 = await transaction.query(sql2, sqlParam2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (result.length > 0 || result2.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const changeLedgerGclIdList = this._.map(result, 'id'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const changeLedgerIdList = this._.uniq(this._.map(result, 'ledger_pid'));// 父节点集合 
			 |