UiAuto|泛微Ecology系统附件下载插件

  在《UiAuto|泛微Ecology系统附件上传插件》中我曾写过上传附件到公司内网门户系统(泛微Ecology)的插件。此次在处理另一个需求的时候需要从系统中下载附件到本地,当然对于数字员工的场景开发,我还是期望尽可能的不通过RPA实现,所以就有了这个插件,通过调用系统接口的方式实现文件的下载。插件源码如下:

package.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{
"id": "zjtEcologyFileDownload",
"name": "zjfwfiledownload",
"description": "泛微ecology9系统接口对接功能",
"version": "1.0.0",
"author": "chendi",
"language": "python",
"license": "Official",
"main": "index.py",
"uiauto_config": {
"attribution_id": "file_operation",
"attribution_name": "文件处理",
"operations": [
{
"category_id": "ecology",
"category_name": "ecology",
"operation_id": "downloadToEcology",
"operation_name": "附件下载",
"method": "downloadToEcology",
"type": "Convention",
"input": [
{
"name": "必填属性",
"id": "required_params",
"properties": [
{
"id": "urlip",
"name": "泛微系统IP",
"type": "text",
"required": true,
"value": ""
},
{
"id": "pcip",
"name": "本机IP",
"type": "text",
"required": true,
"value": ""
},
{
"id": "userName",
"name": "登陆用户",
"type": "text",
"required": true,
"value": ""
},
{
"id": "pwd",
"name": "登陆密码",
"type": "password",
"required": true,
"value": ""
},
{
"id": "docid",
"name": "文件ID",
"type": "text",
"required": true,
"value": ""
},
{
"id": "filename",
"name": "附件名(含后缀)",
"type": "text",
"required": true,
"value": ""
},
{
"id": "path",
"name": "文件路径",
"type": "path",
"required": true,
"value": "",
"options":{
"select_type":"openDirectory"
}
}
]
}
],
"output": {
"is_allow_global_use": true,
"description": "文件下载结果",
"value": ""
}
}
]
}
}


index.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- encoding:utf-8 -*-
'''
@description: 从泛微Ecology9系统中下载附件
@Time : 2023-06-20
@Author : CHENDI
@Version : 1.0.0
@Contact : henanchendi@163.com
'''

import base64
from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import


# 根据关键字检索word内容
def downloadToEcology(params):
# 获取参数
urlip = params.get('urlip')
pcip = params.get('pcip')
userName = params.get('userName')
pwd = params.get('pwd')
filename = params.get('filename')
path = params.get('path')
docid = params.get('docid')

# 访问接口,获取session
imp = Import('http://localhost/services/DocService')
doctor = ImportDoctor(imp)
url = 'http://{}/services/DocService?wsdl'.format(urlip)
client = Client(url,doctor=doctor)
# 获取session
result = client.service.login(userName,pwd,0,pcip)

# 获取文件信息
ArrayOfDocAttachment = client.factory.create('ns2:ArrayOfDocAttachment')
docinfo = client.factory.create('ns2:DocInfo')
DocAttach = client.factory.create('ns2:DocAttachment')
getdoc = client.service.getDoc(docid,result)
docinfo = getdoc
ArrayOfDocAttachment = docinfo.attachments.DocAttachment
DocAttach=ArrayOfDocAttachment[0]
content = base64.b64decode(DocAttach.filecontent)
with open(path+'\\'+filename,'wb') as f:
f.write(content)
return True

if __name__ == '__main__':
pass


商业转载请联系作者获得授权,非商业转载请注明出处。

支付宝打赏 微信打赏

如果文章对你有帮助,欢迎点击上方按钮打赏作者

UiAuto|泛微Ecology系统附件下载插件
http://hncd1024.github.io/2023/06/21/UiAuto_ecologyFileDownload/
作者
CHEN DI
发布于
2023-06-21
许可协议