| 
															
																@@ -1023,15 +1023,15 @@ module.exports = app => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																          * @param {Object} ctx - 全局上下文 
															 | 
															
															 | 
															
																          * @param {Object} ctx - 全局上下文 
															 | 
														
													
												
													
														
															| 
															 | 
															
																          */ 
															 | 
															
															 | 
															
																          */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         async downloadZip(ctx) { 
															 | 
															
															 | 
															
																         async downloadZip(ctx) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            const zipFilename = `${ctx.tender.data.name}-台账分解-附件.zip`; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            const time = Date.now(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            const zipPath = `app/public/upload/${ctx.tender.id}/ledger/fu_jian_zip${time}.zip`; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             const responseData = { 
															 | 
															
															 | 
															
																             const responseData = { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 err: 0, 
															 | 
															
															 | 
															
																                 err: 0, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 msg: '', 
															 | 
															
															 | 
															
																                 msg: '', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             }; 
															 | 
															
															 | 
															
																             }; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             try { 
															 | 
															
															 | 
															
																             try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 const { fileIds = [] } = JSON.parse(ctx.request.body.data); 
															 | 
															
															 | 
															
																                 const { fileIds = [] } = JSON.parse(ctx.request.body.data); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                const zipFilename = `${ctx.tender.data.name}-台账分解-附件.zip`; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                const time = Date.now(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                const zipPath = `app/public/upload/${ctx.tender.id}/ledger/fu_jian_zip${time}.zip`; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 const size = await ctx.service.ledgerAtt.compressedFile(fileIds, zipPath); 
															 | 
															
															 | 
															
																                 const size = await ctx.service.ledgerAtt.compressedFile(fileIds, zipPath); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 // 解决中文无法下载问题 
															 | 
															
															 | 
															
																                 // 解决中文无法下载问题 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase(); 
															 | 
															
															 | 
															
																                 const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -1056,11 +1056,21 @@ module.exports = app => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                         fs.unlinkSync(path.resolve(this.app.baseDir, zipPath)); 
															 | 
															
															 | 
															
																                         fs.unlinkSync(path.resolve(this.app.baseDir, zipPath)); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                     } 
															 | 
															
															 | 
															
																                     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 }); 
															 | 
															
															 | 
															
																                 }); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                readStream.on('error', error => { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                    this.log(error); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                // fs的错误不能被try catch捕捉 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                readStream.on('error', err => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    this.log(err); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    if (fs.existsSync(path.resolve(this.app.baseDir, zipPath))) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        fs.unlinkSync(path.resolve(this.app.baseDir, zipPath)); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    responseData.err = 1; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    responseData.msg = err.toString(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    ctx.body = responseData; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 }); 
															 | 
															
															 | 
															
																                 }); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             } catch (err) { 
															 | 
															
															 | 
															
																             } catch (err) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 this.log(err); 
															 | 
															
															 | 
															
																                 this.log(err); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                if (fs.existsSync(path.resolve(this.app.baseDir, zipPath))) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    fs.unlinkSync(path.resolve(this.app.baseDir, zipPath)); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 this.setMessage(err.toString(), this.messageType.ERROR); 
															 | 
															
															 | 
															
																                 this.setMessage(err.toString(), this.messageType.ERROR); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 responseData.err = 1; 
															 | 
															
															 | 
															
																                 responseData.err = 1; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 responseData.msg = err.toString(); 
															 | 
															
															 | 
															
																                 responseData.msg = err.toString(); 
															 |