泛微 OA - 根据流程 requestid 获取流程中的附件

本文介绍了如何在泛微OA系统中,通过封装的GetDocApiByRequestId接口,利用requestid获取加密上传的附件信息,包括url地址、id和上传者,然后在本地下载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

泛微 OA - 根据流程 requestid 获取流程中的附件

在泛微 OA 流程中,附件是通过加密上传的,如果在第三方系统想要调用 OA 系统获取 OA 附件,暂时没有很好的方法实现。但是可以在本地进行调用,得到附件 url 地址、附件 id、附件上传者等信息,拿到这些信息后,可以用过 url 地址在本地下载。

废话不多说,演示开始,封装了一个小代码:

GetDocApiByRequestId.java

此路径记得白名单加白:/test/workflow/getDocApiByRequestId

@Path("/test/workflow/getDocApiByRequestId")
public class GetDocApiByRequestId extends GetDocApiByRequestIdAction {
}

GetDocApiByRequestIdAction.java

public class GetDocApiByRequestIdAction {
    Logger logger = LoggerFactory.getLogger(GetDocApiByRequestIdAction.class);

    @GET
    @Path("/getDoc")
    @Produces(MediaType.APPLICATION_JSON)
    public String doGet(@Context HttpServletRequest request) throws Exception {
        String token = request.getHeader("token"); // 获取 token、appid、userid,在下文会用到
        String appid = request.getHeader("appid");
        String userid = request.getHeader("userid");
        String requestid = request.getParameter("requestid");
        Map<String, Object> resultMap = new HashMap<>(3);

        if (requestid.isEmpty() || 判断requestid 是否在流程中存在,此处不再演示了) {
            resultMap.put("code", "fail");
            resultMap.put("data", "");
            resultMap.put("msg", "requestid 错误");
            return JSON.toJSONString(resultMap);
        }

        // 目标地址,此地址是泛微官方获取流程数据的接口,原文链接:https://e-cloudstore.com/ec/api/applist/index.html#/
        String url = "http://192.168.190.5:8080/api/workflow/paService/getRequestResources?requestid=" + requestid;
        HttpGet httpGet = new HttpGet(url);

        // 设置类型 "application/x-www-form-urlencoded" "application/json"
        httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded");
        httpGet.setHeader("token", token);
        httpGet.setHeader("appid", appid);
        httpGet.setHeader("userid", userid);
        logger.info("调用 url: " + httpGet.getURI());

        // httpClient实例化
        CloseableHttpClient httpClient = HttpClients.createDefault();
        // 执行请求并获取返回
        HttpResponse response = httpClient.execute(httpGet);
        HttpEntity entity = response.getEntity();
        logger.info("返回状态码:" + response.getStatusLine());

        // 显示结果
        BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));
        String line = null;
        StringBuffer responseSB = new StringBuffer();
        while ((line = reader.readLine()) != null) {
            responseSB.append(line);
        }
        logger.info("返回消息:" + responseSB);

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode jsonNode = objectMapper.readTree(responseSB.toString());
        JsonNode dataNode = jsonNode.get("data");

        List<DocEntity> list = new ArrayList<>();
        for (int i=0; i< dataNode.size(); i++) {
            DocEntity docEntity =  objectMapper.convertValue(dataNode.get(i), DocEntity.class);
            list.add(docEntity);
        }

        resultMap.put("code", "success");
        resultMap.put("data", list);
        resultMap.put("msg", "获取成功");

        reader.close();
        httpClient.close();
        return JSON.toJSONString(resultMap);
    }
}

附件信息的实体类:
DocEntity.java

@Data
@NoArgsConstructor
@AllArgsConstructor
public class DocEntity {
    private String createdate; // 附件上传日期
    private String createrName; // 创建人名字
    private String createrid; // 用户id
    private String createtime; // 上传具体时间
    private String downloadUrl; // 附件 url (本次演示重点要得到的内容)
    private String id; // 附件id
    private String name; // 附件名字
    private String type; // 附件形式
}

代码结束,打包上传服务器,postman 演示:

url:

http://192.168.190.5:8080/api/test/workflow/getDocApiByRequestId/getDoc

记得在请求头中携带 token、appid、加密后的 userid

在这里插入图片描述

获取成功,在 url 前面拼接服务器地址就可以下载附件了。

<think>嗯,用户问的是OA系统中存储所有流程的数据表的位置。首先,我需要回想一下之前接触过的OA数据库结构。根据用户提供的引用内容,他们提到了workflow_billdetailtable和workflow_docshareinfo这两个表。我记得OA流程数据主要存储在几个核心表中,比如主表可能记录流程的基本信息,明细表存放具体字段数据。 首先,用户需要找到所有流程的数据表,可能涉及主表和明细表。引用[1]提到workflow_billdetailtable用于存储明细字段数据,而主表可能对应workflow_bill。那主表结构应该是workflow_bill,其中包含流程表单的基本信息,如流程ID、名称等。另外,流程实例的数据可能存放在workflow_requestbase,这个表可能有流程实例的ID、状态、创建时间等信息。 另外,流程的节点和权限信息可能在workflow_flownode和workflow_base中。用户可能需要这些表来查询流程的具体步骤和权限设置。还有流程文件附件,引用[2]提到使用workflow_docshareinfo,根据docid查询附件路径,这可能和流程中的文档存储有关。 需要确认这些表的结构,用户可能需要通过SQL查询来获取具体信息,比如select * from workflow_requestbase来查看流程实例数据。同时,提醒用户注意权限问题,避免直接操作生产数据库,最好在测试环境进行验证。</think>根据OA系统的数据库设计,流程数据主要通过以下核心表进行存储: 1. **流程表单主表** 主表结构存储在$workflow\_bill$表中,通过SQL可查询所有流程主表信息: ```sql select billid,tablename from workflow_bill ``` 该表记录流程ID(billid)与对应的物理表名(tablename)[^1] 2. **流程明细表** 明细表信息存储在$workflow\_billdetailtable$中,包含明细表与主表的关联关系: ```sql select billid,tablename from workflow_billdetailtable ``` 每个明细表通过billid与主表关联 3. **流程实例数据** 已发起的流程实例数据存储在$workflow\_requestbase$表: ```sql select requestid,workflowid,currentnodetype,createdate from workflow_requestbase ``` 包含流程实例ID、流程模板ID、当前节点状态等关键信息 4. **流程文件存储** 流程附件路径信息通过$workflow\_docshareinfo$表查询: ```sql select docid,filepath from workflow_docshareinfo where requestid=流程实例ID ``` 可根据具体流程实例ID定位附件存储位置[^2]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值