Browse Source

Merge branch 'ETA_1.8.1' into debug

zwxi 10 months ago
parent
commit
b8c6bf6674
2 changed files with 11 additions and 16 deletions
  1. 11 16
      services/smart_report.go
  2. BIN
      static/指标导入模板.xlsx

+ 11 - 16
services/smart_report.go

@@ -136,41 +136,36 @@ import asyncio
 from pyppeteer import launch
 
 async def main():
-    
+
     browser = await launch({
         'executablePath': '%s',
-        'headless': True
+        'headless': True,
+        'args':['--disable-infobars', '--no-sandbox']
     })
     page = await browser.newPage()
     await page.setViewport({
         'width': 1920,
         'height': 1080,
     })
-	# 对于大的PDF生成,可能会时间很久,这里规定不会进行超时处理
     # await page.setDefaultNavigationTimeout(0)
-	# 不再有网络连接时触发
-    await page.goto('%s',{
+    await page.goto('http://testetareport.hzinsights.com/reportshare_pdf?code=56517f19aa289885c43e8db9137fb1b0&viewType=!pdf!',{
         'waitUntil':'networkidle0'
     })
-    
-
+    # Consider handling errors or waiting strategies if necessary
     await page.pdf({
         'path': "%s",
         'printBackground': True,
         'format': "A2",
-        'displayHeaderFooter':True,
-        # 'headerTemplate':'<div></div>',
-        # 'footerTemplate':"<div style='width:100%;text-align:center;font-size:16px'><span class='pageNumber''></span></div>",
         'margin': {
-            'top': 100,
-            'bottom': 100,
-            'left':0,
-            'right':0
+            'top': 10,
+            'bottom': 10,
+            'left':10,
+            'right':10
         }
     })
     await browser.close()
 
-asyncio.run(main())
+asyncio.get_event_loop().run_until_complete(main())
 `
 
 	pyCode = fmt.Sprintf(pyCode, utils.ChromeDrivePath, reportUrl, filePath)
@@ -214,7 +209,7 @@ async def main():
     })
     await browser.close()
 
-asyncio.run(main())
+asyncio.get_event_loop().run_until_complete(main())
 `
 
 	pyCode = fmt.Sprintf(pyCode, utils.ChromeDrivePath, reportUrl, filePath)

BIN
static/指标导入模板.xlsx