| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package com.sckw.erp.service;
- import com.google.gson.Gson;
- import com.kingdee.bos.webapi.entity.IdentifyInfo;
- import com.kingdee.bos.webapi.entity.QueryParam;
- import com.kingdee.bos.webapi.sdk.K3CloudApi;
- import com.sckw.erp.entity.BdCustomer;
- import com.sckw.erp.entity.BdMaterial;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import javax.annotation.PostConstruct;
- import java.util.List;
- import java.util.Objects;
- /**
- * @author xucaiqin
- * @date 2025-05-20 09:54:00
- */
- @Service
- @Slf4j
- public class ApiService {
- protected K3CloudApi api;
- @Value("${kd.accid}")
- private String AcctID;
- @Value("${kd.username}")
- private String UserName;
- @Value("${kd.appid}")
- private String AppID;
- @Value("${kd.appsec}")
- private String AppSec;
- @Value("${kd.serviceUrl}")
- private String ServerUrl;
- @PostConstruct
- private void init() {
- if (Objects.isNull(this.api)) {
- IdentifyInfo widen = new IdentifyInfo();
- widen.setUserName(UserName);
- widen.setAppId(AppID);
- widen.setdCID(AcctID);
- widen.setAppSecret(AppSec);
- widen.setlCID(2052);
- widen.setServerUrl(ServerUrl);
- this.api = new K3CloudApi(widen, false);
- }
- }
- public List<Object> query(String name, Integer pageNo, Integer pageSize) {
- if (Objects.isNull(pageSize)) {
- pageSize = 20;
- }
- if (Objects.isNull(pageNo)) {
- pageNo = 0;
- }
- QueryParam<String> para = new QueryParam<>();
- para.setFormId("bd_customer");
- para.setFieldKeys("FNumber,FName");
- para.setFilterString("FName like '%" + name + "%'");
- para.setOrderString("");
- para.setTopRowCount(0);
- para.setStartRow(pageNo);
- para.setLimit(pageSize);
- List<Object> result;
- try {
- result = this.api.executeBillQuery(para, BdCustomer.class);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return result;
- }
- public List<Object> queryMaterial(String name, Integer pageNo, Integer pageSize) {
- if (Objects.isNull(pageSize)) {
- pageSize = 20;
- }
- if (Objects.isNull(pageNo)) {
- pageNo = 0;
- }
- QueryParam<String> para = new QueryParam<>();
- para.setFormId("BD_Material");
- para.setFieldKeys("FNumber,FName");
- para.setFilterString("FName like '%" + name + "%'");
- para.setOrderString("");
- para.setTopRowCount(0);
- para.setStartRow(pageNo);
- para.setLimit(pageSize);
- List<Object> lists;
- try {
- lists = api.executeBillQuery(para, BdMaterial.class);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return lists;
- }
- }
|