自定义openapi插件获取基础资料已分配的使用组织原创
3人赞赏了该文章
495次浏览
编辑于2023年12月29日 15:02:40
一、需求
需要查询基础资料已分配的组织
二、解决方案
可以通过自定义openapi实现,本文描述使用插件方式处理。以下可参考物料使用组织
三、步骤
1、编写openapi插件
@ApiController(desc = "查询物料使用组织", value = "bd") public class MaterialUseOrgApiService implements Serializable { private static final long serialVersionUID = 4434540944862841235L; private static Log logger = LogFactory.getLog(MaterialUseOrgApiService.class); private static final String ERR_CODE_OPERATE_FAILED = "777"; private static final String ERR_CODE_SYS_EX = "999"; @ApiPostMapping(value = "/getMaterialUseOrg") public CustomApiResult<List<MaterialUseOrgRes>> getMaterialUseOrg( @NotEmpty @ApiParam(value = "物料ID列表") List<Long> materialIdList) { CustomApiResult<List<MaterialUseOrgRes>> result = null; boolean resultSuccess = true; List<MaterialUseOrgRes> apiResult = new LinkedList<>(); try { SqlBuilder sql = new SqlBuilder(); sql.append("select fuseorgid,fdataid from t_bd_material_u where ").appendIn("fdataid", materialIdList.toArray()); DataSet dataSet = DB.queryDataSet("getMaterialUseOrg", DBRoute.basedata, sql); while (dataSet.hasNext()){ MaterialUseOrgRes matUseOrg = new MaterialUseOrgRes(); Row row = dataSet.next(); matUseOrg.setUseOrgId(row.getLong("fuseorgid")); matUseOrg.setMaterialId(row.getLong("fdataid")); apiResult.add(matUseOrg); } // 返回结果 if (resultSuccess) { result = CustomApiResult.success(apiResult); } else { result = CustomApiResult.fail(ERR_CODE_OPERATE_FAILED, "operate fail."); result.setData(apiResult); } } catch (Throwable e) { logger.error("MaterialUseOrgApiService exception", e); result = CustomApiResult.fail(ERR_CODE_SYS_EX, e.getMessage()); result.setData(apiResult); } return result; } } @ApiModel class MaterialUseOrgRes { @ApiParam(value = "物料ID") private Long materialId; @ApiParam(value = "物料使用组织ID") private Long useOrgId; public Long getMaterialId() { return materialId; } public void setMaterialId(Long materialId) { this.materialId = materialId; } public Long getUseOrgId() { return useOrgId; } public void setUseOrgId(Long useOrgId) { this.useOrgId = useOrgId; } }
2、openapi ->API管理->新增->自定义API(java插件)
3、输入新增信息
4、测试调用
5、发布API
四、适用访问
所有关联了使用组织的基础资料。
参考资料:
https://vip.kingdee.com/article/294499338318073088?productLineId=29&isKnowledge=2
赞 3
3人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读