evoToK3Cloud/ruoyi-common/src/main/java/com/ruoyi/common/utils/JdUtils.java

1558 lines
63 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.ruoyi.common.utils;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.google.gson.*;
import com.kingdee.bos.webapi.entity.RepoRet;
import com.kingdee.bos.webapi.sdk.K3CloudApi;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.HashMap;
import java.util.Map;
import static com.ruoyi.common.core.mapper.BaseMapperPlus.log;
import static org.aspectj.bridge.MessageUtil.fail;
public class JdUtils {
/**
* 汇报单 审核
*
* @return
*/
public static String HBshenhe(String huiBNum) {
K3CloudApi client = new K3CloudApi();
JsonObject jsonObject = new JsonObject();
JsonArray numbers = new JsonArray();
numbers.add(huiBNum);//汇报单下推成功后会有生成的检验单编码
jsonObject.add("Numbers", numbers);
jsonObject.addProperty("Ids", "");
jsonObject.addProperty("SelectedPostId", 0);
jsonObject.addProperty("UseOrgId", 0);
jsonObject.addProperty("NetworkCtrl", "");
jsonObject.addProperty("IgnoreInterationFlag", "");
jsonObject.addProperty("UseBatControlTimes", "false");
String jsonData = jsonObject.toString();
try {
//业务对象标识
String formId = "PRD_MORPT";
//调用接口
String resultJson = client.push(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
JsonParser parser = new JsonParser();
JsonObject resultObject = parser.parse(resultJson).getAsJsonObject();
String extractedValue = resultObject.getAsJsonObject("ResponseStatus")
.getAsJsonArray("SuccessEntitys")
.get(0)
.getAsJsonObject()
.get("Number")
.getAsString();
return extractedValue;//返回检验单编号
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return "0";
}
} catch (Exception e) {
fail(e.getMessage());
return null;
}
}
/**
* 汇报单提交 审核
*
* @return
*/
public static boolean HBsubmit(String huiBNum) {
K3CloudApi client = new K3CloudApi();
JsonObject jsonObject = new JsonObject();
JsonArray numbers = new JsonArray();
numbers.add(huiBNum);//汇报单下推成功后会有生成的检验单编码
jsonObject.add("Numbers", numbers);
jsonObject.addProperty("Ids", "");
jsonObject.addProperty("SelectedPostId", 0);
jsonObject.addProperty("UseOrgId", 0);
jsonObject.addProperty("NetworkCtrl", "");
jsonObject.addProperty("IgnoreInterationFlag", "");
String jsonData = jsonObject.toString();
try {
//业务对象标识
String formId = "PRD_MORPT";//检验单
//调用接口
String resultJson = client.submit(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
return true;
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return false;
}
} catch (Exception e) {
fail(e.getMessage());
return false;
}
}
/*
生产订单下推汇报单
返回汇报单编号
汇报单编号需要提交审核
汇报单下推审核单-返回审核单编号
审核单查询返回fid entryid 合格数 不合格数
更新 合格数 不合格数
/**
* 入库单保存
*
* @return
*/
public static boolean updateRuKu(HashMap<String, String> ruKuNumMap) {
K3CloudApi client = new K3CloudApi();
JsonObject jsonObject = new JsonObject();
// 创建空的 JSON 数组
JsonArray emptyArray = new JsonArray();
// 设置需要更新的字段
jsonObject.add("NeedUpDateFields", emptyArray);
// 设置需要返回的字段
jsonObject.add("NeedReturnFields", emptyArray);
// 设置是否删除条目
jsonObject.addProperty("IsDeleteEntry", "true");
// 设置子系统ID
jsonObject.addProperty("SubSystemId", "");
// 设置是否验证基础数据字段
jsonObject.addProperty("IsVerifyBaseDataField", "false");
// 设置是否批量填写条目
jsonObject.addProperty("IsEntryBatchFill", "true");
// 设置验证标志
jsonObject.addProperty("ValidateFlag", "true");
// 设置编号搜索
jsonObject.addProperty("NumberSearch", "true");
// 设置是否自动调整字段
jsonObject.addProperty("IsAutoAdjustField", "false");
// 设置交互标志
jsonObject.addProperty("InterationFlags", "");
// 设置是否忽略交互标志
jsonObject.addProperty("IgnoreInterationFlag", "");
// 设置是否控制精度
jsonObject.addProperty("IsControlPrecision", "false");
// 设置验证重复 JSON
jsonObject.addProperty("ValidateRepeatJson", "false");
// 创建嵌套的 Model 对象
JsonObject modelObject = new JsonObject();
modelObject.addProperty("FID", ruKuNumMap.get("FID"));
// 创建 FEntity 数组
JsonArray fEntityArray = new JsonArray();
JsonObject fEntityObject = new JsonObject();
fEntityObject.addProperty("FEntryID", ruKuNumMap.get("FENTITY_FEntryID"));
fEntityObject.addProperty("FRealQty", ruKuNumMap.get("FRealQty"));
fEntityArray.add(fEntityObject);
modelObject.add("FEntity", fEntityArray);
// 将 Model 对象添加到主对象中
jsonObject.add("Model", modelObject);
// 使用 Gson 将 JsonObject 转换为 JSON 字符串
Gson gson = new Gson();
String jsonString = gson.toJson(jsonObject);
System.out.println(jsonString);
try {
//业务对象标识
String formId = "PRD_INSTOCK";
//调用接口
String resultJson = client.save(formId, jsonString);
//用于记录结果
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
return true;
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return false;
}
} catch (Exception e) {
fail(e.getMessage());
return false;
}
}
/**
* 检验单保存
*/
public static boolean updateQc(HashMap<String, String> jianYanMap) {
K3CloudApi client = new K3CloudApi();
// 创建空的 JSON 对象
JsonObject jsonObject = new JsonObject();
// 创建空的 JSON 数组
JsonArray emptyArray = new JsonArray();
// 设置需要更新的字段
jsonObject.add("NeedUpDateFields", emptyArray);
// 设置需要返回的字段
jsonObject.add("NeedReturnFields", emptyArray);
// 设置是否删除条目
jsonObject.addProperty("IsDeleteEntry", "true");
// 设置子系统ID
jsonObject.addProperty("SubSystemId", "");
// 设置是否验证基础数据字段
jsonObject.addProperty("IsVerifyBaseDataField", "false");
// 设置是否批量填写条目
jsonObject.addProperty("IsEntryBatchFill", "true");
// 设置验证标志
jsonObject.addProperty("ValidateFlag", "true");
// 设置编号搜索
jsonObject.addProperty("NumberSearch", "true");
// 设置是否自动调整字段
jsonObject.addProperty("IsAutoAdjustField", "false");
// 设置交互标志
jsonObject.addProperty("InterationFlags", "");
// 设置是否忽略交互标志
jsonObject.addProperty("IgnoreInterationFlag", "");
// 设置是否控制精度
jsonObject.addProperty("IsControlPrecision", "false");
// 设置验证重复 JSON
jsonObject.addProperty("ValidateRepeatJson", "false");
// 创建嵌套的 Model 对象
JsonObject modelObject = new JsonObject();
modelObject.addProperty("FID", jianYanMap.get("FID"));
// 创建 FEntity 数组
JsonArray fEntityArray = new JsonArray();
JsonObject fEntityObject = new JsonObject();
fEntityObject.addProperty("FEntryID", jianYanMap.get("FID"));
fEntityObject.addProperty("FQualifiedQty", jianYanMap.get("FQualifiedQty"));
fEntityObject.addProperty("FUnqualifiedQty", jianYanMap.get("FUnqualifiedQty"));
// 创建 FPolicyDetail 数组
JsonArray fPolicyDetailArray = new JsonArray();
JsonObject fPolicyDetailObject = new JsonObject();
fPolicyDetailObject.addProperty("FDetailID", jianYanMap.get("FDetailID"));
fPolicyDetailObject.addProperty("FPolicyQty", jianYanMap.get("FPolicyQty"));
fPolicyDetailObject.addProperty("FPolicyStatus", "A");
fPolicyDetailArray.add(fPolicyDetailObject);
fEntityObject.add("FPolicyDetail", fPolicyDetailArray);
fEntityArray.add(fEntityObject);
modelObject.add("FEntity", fEntityArray);
// 将 Model 对象添加到主对象中
jsonObject.add("Model", modelObject);
// 使用 Gson 将 JsonObject 转换为 JSON 字符串
Gson gson = new Gson();
String jsonString = gson.toJson(jsonObject);
System.out.println(jsonString);
try {
//业务对象标识
String formId = "PRD_PickMtrl";
//调用接口
String resultJson = client.save(formId, jsonString);
//用于记录结果
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
return true;
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return false;
}
} catch (Exception e) {
fail(e.getMessage());
return false;
}
}
/**
* 领料单保存
*
* @return
*/
public static String updateLinliao(HashMap<String, String> linLiaoMap) {
K3CloudApi client = new K3CloudApi();
// 创建空的 JSON 对象
JsonObject jsonObject = new JsonObject();
// 创建空的 JSON 数组
JsonArray emptyArray = new JsonArray();
// 设置需要更新的字段
jsonObject.add("NeedUpDateFields", emptyArray);
// 设置需要返回的字段
jsonObject.add("NeedReturnFields", emptyArray);
// 设置是否删除条目
jsonObject.addProperty("IsDeleteEntry", "true");
// 设置子系统ID
jsonObject.addProperty("SubSystemId", "");
// 设置是否验证基础数据字段
jsonObject.addProperty("IsVerifyBaseDataField", "false");
// 设置是否批量填写条目
jsonObject.addProperty("IsEntryBatchFill", "true");
// 设置验证标志
jsonObject.addProperty("ValidateFlag", "true");
// 设置编号搜索
jsonObject.addProperty("NumberSearch", "true");
// 设置是否自动调整字段
jsonObject.addProperty("IsAutoAdjustField", "false");
// 设置交互标志
jsonObject.addProperty("InterationFlags", "");
// 设置是否忽略交互标志
jsonObject.addProperty("IgnoreInterationFlag", "");
// 设置是否控制精度
jsonObject.addProperty("IsControlPrecision", "false");
// 设置验证重复 JSON
jsonObject.addProperty("ValidateRepeatJson", "false");
// 创建嵌套的 Model 对象
JsonObject modelObject = new JsonObject();
//在更新时FID为必填
modelObject.addProperty("FID", linLiaoMap.get("FID"));
// 创建 FEntity 数组
JsonArray fEntityArray = new JsonArray();
JsonObject fEntityObject = new JsonObject();
//在更新时分录明细单额的FEntryID为必填
fEntityObject.addProperty("FEntryID", linLiaoMap.get("FENTITY_FEntryID"));
fEntityObject.addProperty("FActualQty", 2);
fEntityArray.add(fEntityObject);
modelObject.add("FEntity", fEntityArray);
// 将 Model 对象添加到主对象中
jsonObject.add("Model", modelObject);
String jsonString = jsonObject.toString();
System.out.println(jsonString);
try {
//业务对象标识
String formId = "PRD_PickMtrl";
//调用接口
String resultJson = client.save(formId, jsonString);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
return "success";
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return "faile";
}
} catch (Exception e) {
fail(e.getMessage());
}
return jsonString;
}
/**
* 入库单查询
*
* @return
*/
public static HashMap<String, String> ruKuSel(String ruKuNum) {
HashMap<String, String> resultMap = new HashMap<>();
K3CloudApi client = new K3CloudApi();
JsonObject filterString = new JsonObject();
filterString.addProperty("FieldName", "FBillNo");
filterString.addProperty("Compare", "67");
filterString.addProperty("Value", ruKuNum);
filterString.addProperty("Left", "");
filterString.addProperty("Right", "");
filterString.addProperty("Logic", "0");
JsonArray filterArray = new JsonArray();
filterArray.add(filterString);
JsonObject data = new JsonObject();
data.addProperty("FormId", "PRD_INSTOCK");
data.addProperty("FieldKeys", "FID,FENTITY_FEntryID,FRealQty, ");
data.add("FilterString", filterArray);
data.addProperty("OrderString", "");
data.addProperty("TopRowCount", 0);
data.addProperty("StartRow", 0);
data.addProperty("Limit", 2000);
data.addProperty("SubSystemId", "");
System.out.println(data.toString());
String jsonString = data.toString();
//调用接口
String resultJson = null;
try {
resultJson = String.valueOf(client.executeBillQuery(jsonString));
System.out.println("接口返回结果: " + resultJson);
// 解析 resultJson 数据
JsonParser parser = new JsonParser();
JsonArray jsonArray = parser.parse(resultJson).getAsJsonArray();
// 用于记录结果的HashMap
for (int i = 0; i < jsonArray.size(); i++) {
JsonArray innerArray = jsonArray.get(i).getAsJsonArray();
String FID = innerArray.get(0).getAsString();
String FENTITY_FEntryID = innerArray.get(1).getAsString();
String FRealQty = innerArray.get(2).getAsString();
resultMap.put("FID", FID);
resultMap.put("FENTITY_FEntryID", FENTITY_FEntryID);
resultMap.put("FRealQty", FRealQty);
}
return resultMap;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 检验单查询
*
* @return
*/
public static HashMap<String, String> qcSelect(String jianYanNum) {
HashMap<String, String> resultMap = new HashMap<>();
K3CloudApi client = new K3CloudApi();
JsonObject filterString = new JsonObject();
filterString.addProperty("FieldName", "FBillNo");
filterString.addProperty("Compare", "67");
filterString.addProperty("Value", jianYanNum);
filterString.addProperty("Left", "");
filterString.addProperty("Right", "");
filterString.addProperty("Logic", "0");
JsonArray filterArray = new JsonArray();
filterArray.add(filterString);
JsonObject data = new JsonObject();
data.addProperty("FormId", "QM_InspectBill");
data.addProperty("FieldKeys", "FID,FENTITY_FEntryID,FDetailID,FQualifiedQty,FUnqualifiedQty ");
data.add("FilterString", filterArray);
data.addProperty("OrderString", "");
data.addProperty("TopRowCount", 0);
data.addProperty("StartRow", 0);
data.addProperty("Limit", 2000);
data.addProperty("SubSystemId", "");
System.out.println(data.toString());
String jsonString = data.toString();
//调用接口
String resultJson = null;
try {
resultJson = String.valueOf(client.executeBillQuery(jsonString));
System.out.println("接口返回结果: " + resultJson);
// 解析 resultJson 数据
JsonParser parser = new JsonParser();
JsonArray jsonArray = parser.parse(resultJson).getAsJsonArray();
// 用于记录结果的HashMap
for (int i = 0; i < jsonArray.size(); i++) {
JsonArray innerArray = jsonArray.get(i).getAsJsonArray();
String FID = innerArray.get(0).getAsString();
String FENTITY_FEntryID = innerArray.get(1).getAsString();
String FDetailID = innerArray.get(2).getAsString();
String FQualifiedQty = innerArray.get(3).getAsString();
String FUnqualifiedQty = innerArray.get(4).getAsString();
resultMap.put("FID", FID);
resultMap.put("FENTITY_FEntryID", FENTITY_FEntryID);
resultMap.put("FDetailID", FDetailID);
resultMap.put("FQualifiedQty", FQualifiedQty);
resultMap.put("FUnqualifiedQty", FUnqualifiedQty);
}
return resultMap;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 领料单查询
*
* @return
*/
public static HashMap<String, String> linLiaoSelect(String soutNum) {
HashMap<String, String> resultMap = new HashMap<>();
K3CloudApi client = new K3CloudApi();
JsonObject filterString = new JsonObject();
filterString.addProperty("FieldName", "FBillNo");
filterString.addProperty("Compare", "67");
filterString.addProperty("Value", soutNum);
filterString.addProperty("Left", "");
filterString.addProperty("Right", "");
filterString.addProperty("Logic", "0");
JsonArray filterArray = new JsonArray();
filterArray.add(filterString);
JsonObject data = new JsonObject();
data.addProperty("FormId", "PRD_PickMtrl");
data.addProperty("FieldKeys", "FID,FENTITY_FEntryID,FMaterialId.FNumber,FActualQty");
data.add("FilterString", filterArray);
data.addProperty("OrderString", "");
data.addProperty("TopRowCount", 0);
data.addProperty("StartRow", 0);
data.addProperty("Limit", 2000);
data.addProperty("SubSystemId", "");
System.out.println(data.toString());
String jsonString = data.toString();
try {
//调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonString));
System.out.println("接口返回结果: " + resultJson);
// 解析 resultJson 数据
JsonParser parser = new JsonParser();
JsonArray jsonArray = parser.parse(resultJson).getAsJsonArray();
// 用于记录结果的HashMap
for (int i = 0; i < jsonArray.size(); i++) {
JsonArray innerArray = jsonArray.get(i).getAsJsonArray();
String FID = innerArray.get(0).getAsString();
String FENTITY_FEntryID = innerArray.get(1).getAsString();
String FMaterialId = innerArray.get(2).getAsString();
String FActualQty = innerArray.get(3).getAsString();
resultMap.put("FID", FID);
resultMap.put("FENTITY_FEntryID", FENTITY_FEntryID);
resultMap.put("FMaterialId", FMaterialId);
resultMap.put("FActualQty", FActualQty);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* 检验单提交
*
* @return
*/
public static void submit11() {
K3CloudApi client = new K3CloudApi();
JsonObject jsonObject = new JsonObject();
JsonArray numbers = new JsonArray();
numbers.add("FQC000003");//汇报单下推成功后会有生成的检验单编码
jsonObject.add("Numbers", numbers);
jsonObject.addProperty("Ids", "");
jsonObject.addProperty("SelectedPostId", 0);
jsonObject.addProperty("UseOrgId", 0);
jsonObject.addProperty("NetworkCtrl", "");
jsonObject.addProperty("IgnoreInterationFlag", "");
String jsonData = jsonObject.toString();
try {
//业务对象标识
String formId = "QM_InspectBill";
//调用接口
String resultJson = client.submit(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
}
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* 汇报单下推至检验单
*/
public static String hbToQc(String jianYanNum) {
K3CloudApi client = new K3CloudApi();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("Ids", "");
JsonArray numbersArray = new JsonArray();
numbersArray.add(jianYanNum);
jsonObject.add("Numbers", numbersArray);
jsonObject.addProperty("EntryIds", "");
jsonObject.addProperty("RuleId", "QM_PRDMoRpt2Inspect");
jsonObject.addProperty("TargetBillTypeId", "");
jsonObject.addProperty("TargetFormId", "");
jsonObject.addProperty("IsEnableDefaultRule", false);
jsonObject.addProperty("IsDraftWhenSaveFail", true);
jsonObject.add("CustomParams", new JsonObject());
String jsonData = jsonObject.toString();
try {
//业务对象标识
String formId = "PRD_MORPT";
//调用接口
String resultJson = client.push(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
JsonParser parser = new JsonParser();
JsonObject resultObject = parser.parse(resultJson).getAsJsonObject();
String extractedValue = resultObject.getAsJsonObject("ResponseStatus")
.getAsJsonArray("SuccessEntitys")
.get(0)
.getAsJsonObject()
.get("Number")
.getAsString();
return extractedValue;//返回检验单编号
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return "0";
}
} catch (Exception e) {
fail(e.getMessage());
return null;
}
}
/**
* 汇报单下推至入库单
* return extractedValue 返回入库单
*/
public static String submitToRuku(String hbNum) {
K3CloudApi client = new K3CloudApi();
//调用汇报单查询接口
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("Ids", "");
JsonArray numbersArray = new JsonArray();
numbersArray.add(hbNum);
jsonObject.add("Numbers", numbersArray);
jsonObject.addProperty("EntryIds", "");
jsonObject.addProperty("RuleId", "PRD_MODIRECTSENDTOINSTOCK");
jsonObject.addProperty("TargetBillTypeId", "");
jsonObject.addProperty("TargetFormId", "");
jsonObject.addProperty("IsEnableDefaultRule", false);
jsonObject.addProperty("IsDraftWhenSaveFail", false);
jsonObject.add("CustomParams", new JsonObject());
String jsonData = jsonObject.toString();
try {
//业务对象标识
String formId = "PRD_MORPT";
//调用接口
String resultJson = client.push(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
JsonParser parser = new JsonParser();
JsonObject resultObject = parser.parse(resultJson).getAsJsonObject();
String extractedValue = resultObject.getAsJsonObject("ResponseStatus")
.getAsJsonArray("SuccessEntitys")
.get(0)
.getAsJsonObject()
.get("Number")
.getAsString();
return extractedValue;//返入库单编号
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return "0";
}
} catch (Exception e) {
fail(e.getMessage());
return null;
}
}
/**
* 提交
*
* @return
*/
public static int submit() {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
String jsonData = "{\"CreateOrgId\":0,\"Numbers\":[],\"Ids\":\"\",\"SelectedPostId\":0,\"UseOrgId\":0,\"NetworkCtrl\":\"\",\"IgnoreInterationFlag\":\"\"}";
try {
//业务对象标识
String formId = "PRD_PPBOM";
//调用接口
String resultJson = client.submit(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
}
} catch (Exception e) {
fail(e.getMessage());
}
return 1;
}
public static int pickingPush() {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject jsonObject = new JsonObject();
JsonArray numbersArray = new JsonArray();
numbersArray.add("SOUT00000012");
jsonObject.add("Numbers", numbersArray);
jsonObject.addProperty("Ids", "100018");
jsonObject.addProperty("SelectedPostId", 0);
jsonObject.addProperty("UseOrgId", 0);
jsonObject.addProperty("NetworkCtrl", "");
jsonObject.addProperty("IgnoreInterationFlag", "");
String jsonData = jsonObject.toString();
try {
//业务对象标识
String formId = "PRD_PPBOM";
//调用接口
String resultJson = client.audit(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
}
} catch (Exception e) {
fail(e.getMessage());
}
return 1;
}
/*
* 用料清单下推生产领料单
*/
/**
* 生产用料清单单据查询
*
* @return
*/
public static String[] documentInquiry1(String FMOBillNO) {
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_PPBOM");
json.addProperty("FieldKeys", "FID,FBillNo,FMaterialId.FNumber,FQty,F_UCHN_Text");
JsonArray filterString = new JsonArray();
JsonObject filter = new JsonObject();
filter.addProperty("FieldName", "F_UCHN_Text");
filter.addProperty("Compare", "17");
filter.addProperty("Value", FMOBillNO);
filter.addProperty("Left", "");
filter.addProperty("Right", "");
filter.addProperty("Logic", "0");
filterString.add(filter);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonString = json.toString();
try {
//调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonString));
System.out.println("接口返回结果: " + resultJson);
// 解析 resultJson 数据
JsonArray jsonArray = new JsonParser().parse(resultJson).getAsJsonArray();
String[] resultArray = new String[jsonArray.size()];
int index = 0;
for (JsonElement element : jsonArray) {
JsonObject obj = element.getAsJsonObject();
String fid = obj.get("FID").getAsString();
String fMaterialId = obj.get("FMaterialId.FNumber").getAsString();
String fUchnText = obj.get("F.UCHN.Text").getAsString();
String fQty = obj.get("FQty").getAsString();
resultArray[index] = "FMaterialId.FNumber: " + fMaterialId + ", F.UCHN.Text: " + fUchnText + ",FID: " + fid + ",FQty: " + fQty;
index++;
}
return resultArray;
//用于记录结果
} catch (Exception e) {
e.printStackTrace();
return new String[0];
}
}
/**
* 生产汇报单查询
*
* @return
*/
public static String[] reportSheetInquiry() {
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MORPT");
json.addProperty("FieldKeys", "FMaterialId.FNumber,F_UCHN_Text");
JsonArray filterString = new JsonArray();
JsonObject filter = new JsonObject();
filter.addProperty("FieldName", "F_UCHN_Text");
filter.addProperty("Compare", "17");
filter.addProperty("Value", "YF-001-24");
filter.addProperty("Left", "");
filter.addProperty("Right", "");
filter.addProperty("Logic", "0");
filterString.add(filter);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonString = json.toString();
K3CloudApi client = new K3CloudApi();
try {
//调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonString));
System.out.println("接口返回结果: " + resultJson);
// 解析 resultJson 数据
JsonArray jsonArray = new JsonParser().parse(resultJson).getAsJsonArray();
String[] resultArray = new String[jsonArray.size()];
int index = 0;
for (JsonElement element : jsonArray) {
JsonObject obj = element.getAsJsonObject();
String fMaterialId = obj.get("FMaterialId.FNumber").getAsString();
String fUchnText = obj.get("F.UCHN.Text").getAsString();
resultArray[index] = "FMaterialId.FNumber: " + fMaterialId + ", F.UCHN.Text: " + fUchnText;
index++;
}
return resultArray;
//用于记录结果
} catch (Exception e) {
e.printStackTrace();
return new String[0];
}
}
/**
* 生产领料单保存
*
* @return
*/
public static String pickingUpdate() {
K3CloudApi client = new K3CloudApi();
String jsonData = "{\n" +
" \"NeedUpDateFields\":[\n" +
"\n" +
" ],\n" +
" \"NeedReturnFields\":[\n" +
"\n" +
" ],\n" +
" \"IsDeleteEntry\":\"true\",\n" +
" \"SubSystemId\":\"\",\n" +
" \"IsVerifyBaseDataField\":\"false\",\n" +
" \"IsEntryBatchFill\":\"true\",\n" +
" \"ValidateFlag\":\"true\",\n" +
" \"NumberSearch\":\"true\",\n" +
" \"IsAutoAdjustField\":\"false\",\n" +
" \"InterationFlags\":\"\",\n" +
" \"IgnoreInterationFlag\":\"\",\n" +
" \"IsControlPrecision\":\"false\",\n" +
" \"ValidateRepeatJson\":\"false\",\n" +
" \"Model\":{\n" +
" \"FID\":0,\n" +
" \"FBillType\":{\n" +
" \"FNUMBER\":\"\"\n" +
" },\n" +
" \"FDate\":\"1900-01-01\",\n" +
" \"FStockOrgId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FStockId0\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FPrdOrgId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FWorkShopId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FOwnerTypeId0\":\"\",\n" +
" \"FOwnerId0\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FPickerId\":{\n" +
"\n" +
" },\n" +
" \"FSTOCKERID\":{\n" +
" \"FNAME\":\"\"\n" +
" },\n" +
" \"FDescription\":\"\",\n" +
" \"FCurrId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FIsCrossTrade\":\"false\",\n" +
" \"FVmiBusiness\":\"false\",\n" +
" \"FScanBox\":\"\",\n" +
" \"FSourceType\":\"\",\n" +
" \"FIsOwnerTInclOrg\":\"false\",\n" +
" \"FEntity\":[\n" +
" {\n" +
" \"FEntryID\":0,\n" +
" \"FParentMaterialId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FBaseStockActualQty\":0,\n" +
" \"FConsome\":\"\",\n" +
" \"FFPMBillNo\":\"\",\n" +
" \"FOptQueue\":\"\",\n" +
" \"FReserveType\":\"\",\n" +
" \"FMaterialId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FUnitID\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FAppQty\":0,\n" +
" \"FActualQty\":0,\n" +
" \"FEntryVmiBusiness\":\"false\",\n" +
" \"FOptPlanBillNo\":\"\",\n" +
" \"FStockId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FOptPlanBillId\":0,\n" +
" \"FStockLocId\":{\n" +
"\n" +
" },\n" +
" \"FWorkCenterId\":{\n" +
" \"FNUMBER\":\"\"\n" +
" },\n" +
" \"FOptDetailId\":0,\n" +
" \"FLot\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FCobyBomEntryID\":0,\n" +
" \"FProcessId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FBomId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FGroupRow\":\"\",\n" +
" \"FSrcPickEntryId\":0,\n" +
" \"FSrcBusinessType\":\"\",\n" +
" \"FQueryStockUpdate\":\"\",\n" +
" \"FStockStatusId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FProduceDate\":\"1900-01-01\",\n" +
" \"FTransRetFormId\":\"\",\n" +
" \"FTransRetBillNo\":\"\",\n" +
" \"FTransRetId\":0,\n" +
" \"FTransRetEntryId\":0,\n" +
" \"FSendRowId\":\"\",\n" +
" \"FTransRetEntrySeq\":0,\n" +
" \"FCheckReturnMtrl\":\"false\",\n" +
" \"FIsOverLegalOrg\":\"false\",\n" +
" \"FPlanEntryID\":0,\n" +
" \"FEntrtyMemo\":\"\",\n" +
" \"FISSUEINFOENTRYID\":0,\n" +
" \"FMtoNo\":\"\",\n" +
" \"FProjectNo\":\"\",\n" +
" \"FMoBillNo\":\"\",\n" +
" \"FMoEntryId\":0,\n" +
" \"FPPBomEntryId\":0,\n" +
" \"FOperId\":0,\n" +
" \"FOwnerTypeId\":\"\",\n" +
" \"FStockUnitId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FStockAppQty\":0,\n" +
" \"FStockActualQty\":0,\n" +
" \"FStockAllowOverQty\":0,\n" +
" \"FSecUnitId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FSecActualQty\":0,\n" +
" \"FSecAllowOverQty\":0,\n" +
" \"FMoId\":0,\n" +
" \"FMoEntrySeq\":0,\n" +
" \"FAllowOverQty\":0,\n" +
" \"FPPBomBillNo\":\"\",\n" +
" \"FBaseUnitId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FBaseAppQty\":0,\n" +
" \"FBaseActualQty\":0,\n" +
" \"FBaseAllowOverQty\":0,\n" +
" \"FEntryWorkShopId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FAuxPropId\":{\n" +
"\n" +
" },\n" +
" \"FKeeperTypeId\":\"\",\n" +
" \"FKeeperId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FOwnerId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FExpiryDate\":\"1900-01-01\",\n" +
" \"FSrcBillType\":\"\",\n" +
" \"FSrcBillNo\":\"\",\n" +
" \"FPrice\":0,\n" +
" \"FEntrySrcInterId\":0,\n" +
" \"FAmount\":0,\n" +
" \"FEntrySrcEnteryId\":0,\n" +
" \"FEntrySrcEntrySeq\":0,\n" +
" \"FParentOwnerTypeId\":\"\",\n" +
" \"FParentOwnerId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FSRCBIZBILLTYPE\":{\n" +
" \"FNAME\":\"\"\n" +
" },\n" +
" \"FSRCBIZBILLNO\":\"\",\n" +
" \"FSRCBIZINTERID\":0,\n" +
" \"FSRCBIZENTRYID\":0,\n" +
" \"FSRCBIZENTRYSEQ\":0,\n" +
" \"FPickingStatus\":0,\n" +
" \"FSerialSubEntity\":[\n" +
" {\n" +
" \"FDetailID\":0,\n" +
" \"FSerialNo\":\"\",\n" +
" \"FSerialId\":{\n" +
" \"FNumber\":\"\"\n" +
" },\n" +
" \"FSerialNote\":\"\",\n" +
" \"FIsAppInspect\":\"\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
try {
//业务对象标识
String formId = "PRD_PickMtrl";
//调用接口
String resultJson = client.save(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
} else {
fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
}
} catch (Exception e) {
fail(e.getMessage());
}
return null;
}
/**
* 通用查询
*
* @param jsonData
* @return
*/
public static void documentInquiry(String jsonData) {
int flag = 0;
//读取配置初始化SDK
K3CloudApi client = new K3CloudApi();
try {
//调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonData));
System.out.println("接口返回结果: " + resultJson);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 通用下推
*
* @param formId
* @param jsonData
* @return
*/
public static String pushDatasToJd(String formId, String jsonData) {
int flag = 0;
//读取配置初始化SDK
K3CloudApi client = new K3CloudApi();
try {
//调用接口
String resultJson = client.push(formId, jsonData);
//用于记录结果
Gson gson = new Gson();
//对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
flag = 1;
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
return gson.toJson(repoRet.getResult());
} else {
flag = 0;
System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult().getResponseStatus()));
return gson.toJson(repoRet.getResult());
}
} catch (Exception e) {
e.printStackTrace();
}
return "1";
}
public static Map<String, String> selectKuCun(String matrialsCode) {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "STK_Inventory");
json.addProperty("FieldKeys", "FMaterialId.FNumber,FMaterialName,FStockName,FStockUnitId.FName,FBaseQty");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", matrialsCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
Map<String, String> resultMap = new HashMap<>();
try {
//调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonData));
if (resultJson.length() <= 2) {
resultMap.put("inventory", "0");
resultMap.put("materialCode", "");
resultMap.put("stockName", "");
resultMap.put("materialName", "");
resultMap.put("stockUnit", "");
}
resultJson = resultJson.substring(2, resultJson.length() - 2);
String[] split = resultJson.split(",");
String value1 = split[0];
String value2 = split[1];
String value3 = split[2];
String value4 = split[3];
String value5 = split[4];
resultMap.put("materialCode", value1);
resultMap.put("materialName", value2);
resultMap.put("stockName", value3);
resultMap.put("stockUnit", value4);
resultMap.put("inventory", value5);
System.out.println("图号: " + value1);
System.out.println("名称: " + value2);
System.out.println("仓库: " + value3);
System.out.println("单位: " + value4);
System.out.println("数量: " + value5);
System.out.println("接口返回结果: " + resultJson);
} catch (Exception e) {
resultMap.put("error", e.getMessage());
}
return resultMap;
}
/**
* 同步金蝶生产清单
*
* @param
* @return
*/
public static Map<String, String> synchronize_lists() {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys", "FID,F_UCHN_Text,FBillType.FNUMBER,FMaterialId.FNumber,FMaterialName,FQty,FBillType.FNUMBER,FWorkShopID.FNumber,FDate,FProductType,FPickMtrlStatus");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "F_UCHN_Text");
filterObject.addProperty("Compare", "17");
filterObject.addProperty("Value", "QB");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
Map<String, String> resultMap = new HashMap<>();
try {
//调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonData));
JSONArray jsonArray = new JSONArray(resultJson);
if (!jsonArray.isEmpty()) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
jsonObject.getInt("FID");
}
}
} catch (Exception e) {
resultMap.put("error", e.getMessage());
}
return resultMap;
}
/**
* 同步采购订单 到金蝶生产计划列表
*
* @Log(title = "金蝶生产计划", businessType = BusinessType.OTHER)
*/
@Log(title = "金蝶生产计划", businessType = BusinessType.OTHER)
@GetMapping("/list1")
public void purchase_Order1() {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_PurchaseOrder");
json.addProperty("FieldKeys", "FID,FBillNo,F_UCHN_Text2,FMaterialId.FNumber,FMaterialName,FQty,FDate,FDeliveryDate,FSupplierId,FMRPCloseStatus,FTaxPrice,FSupplierId.FName");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "F_UCHN_Text2");
filterObject.addProperty("Compare", "17");
filterObject.addProperty("Value", "QB");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
System.out.println(jsonData);
try {
// 调用接口并获取结果
String input = String.valueOf(client.executeBillQuery(jsonData));
input = input.substring(2, input.length() - 2);
String[] split = input.split("], \\[");
for (String imProduction : split) {
/* String[] imPro = imProduction.split(",");
ImProductionPlanPro imProductionPlanPro = new ImProductionPlanPro();
imProductionPlanPro.setFidNumber(imPro[1]);//金蝶单据编码
imProductionPlanPro.setProductionCode(imPro[2]);//生产令号
imProductionPlanPro.setFidNumber(imPro[3]);//图号
imProductionPlanPro.setFigureName(imPro[4]);//名称
BigDecimal bigDecimal = new BigDecimal(imPro[5]);
// imProductionPlanPro.setOneNumber(bigDecimal);//数量
imProductionPlanPro.setItemPrice(new BigDecimal(imPro[10]));//物料单价
imProductionPlanPro.setImVendor(imPro[11]);//供应商
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date parse = simpleDateFormat.parse(imPro[6]);
imProductionPlanPro.setProcureTime(parse);//采购时间FDate
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date parse1 = simpleDateFormat2.parse(imPro[7]);
imProductionPlanPro.setDeliveryTime(parse);//交货时间FDeliveryDate
imProductionPlanPro.setTaxPrice(BigDecimal.valueOf(0.00123));//金额
imProductionPlanPro.setDocumentStatus(imPro[9]);//单据状态FDocumentStatus
imProductionPlanPro.setPickmtrlStatus(imPro[10]);//领料状态 生产订单
imProductionPlanPro.setOrderFlag("采购订单");//订单标记
System.out.println(imProductionPlanPro);
System.out.println("==================分隔符==================");
iImProductionPlanProService.updateByFidNumber(imProductionPlanPro);*/
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static JsonArray loadMaterialQuery(String DrawingNumber, String name) {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FNumber,FName,FBaseUnitId.FNumber");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", DrawingNumber);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FName");
filterObject2.addProperty("Compare", "67");
filterObject2.addProperty("Value", name);
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject);
filterString.add(filterObject2);
log.debug("构建查询条件...");
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
System.out.println(jsonData);
JsonArray jsonArray = null;
try {
// 调用接口并获取结果
String input = String.valueOf(client.billQuery(jsonData));
Gson gson = new Gson();
jsonArray = gson.fromJson(input, JsonArray.class);
String string = jsonArray.toString();
if (string.equals("[]")) {
return null;
}
System.out.println(jsonArray);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return jsonArray;
}
public static JsonArray loadMaterialQueryDrawingNumber(String DrawingNumber) {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FNumber,FName,FBaseUnitId.FNumber");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", DrawingNumber);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
log.debug("构建查询条件...");
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
System.out.println(jsonData);
JsonArray jsonArray = null;
try {
// 调用接口并获取结果
String input = String.valueOf(client.billQuery(jsonData));
Gson gson = new Gson();
jsonArray = gson.fromJson(input, JsonArray.class);
String string = jsonArray.toString();
if (string.equals("[]")) {
return null;
}
System.out.println(jsonArray);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return jsonArray;
}
public static JSONArray loadMaterial() {
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FNumber,FName,FCategoryID.FNumber,F_SVRI_Assistant.FNumber,FErpClsID,FBaseUnitId.FName");
JsonArray filterString = new JsonArray();
log.debug("构建查询条件...");
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
int pageNo = 0;
json.addProperty("StartRow", pageNo);
// 通过无限循环来持续查询数据,直到没有更多数据为止
JSONArray list = new JSONArray();
while (true) {
// 将当前的JSON对象转换为字符串以符合查询接口的参数要求
String jsonData = json.toString();
try {
// 调用客户端的billQuery方法传入JSON字符串作为查询参数
String input = String.valueOf(client.billQuery(jsonData));
// 将返回的JSON字符串转换为JSONArray对象
JSONArray objects1 = new JSONArray(input);
/// 如果返回的数组为空,则表示没有更多数据,退出循环
if (objects1.size() == 0) {
break;
}
// 将本次查询到的数据添加到总的查询结果数组中
list.addAll(objects1);
// 更新页码,为下一次查询准备
pageNo++;
// 更新JSON对象中的StartRow属性用于下一次查询的分页
json.addProperty("StartRow", pageNo * 10000);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// 循环结束后,返回总的查询结果数组
return list;
}
/*
物料属性查询
*/
public static JsonArray loadMaterialShuxing(String DrawingNumber, String name) {
log.debug("构建查询条件=======>"+"查询图号:"+DrawingNumber+"物料名称:"+name +"的属性");
K3CloudApi client = new K3CloudApi();
//请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FErpClsID");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", DrawingNumber);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FName");
filterObject2.addProperty("Compare", "67");
filterObject2.addProperty("Value", name);
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject);
filterString.add(filterObject2);
log.debug("构建查询条件...");
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 2000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
System.out.println(jsonData);
JsonArray jsonArray = null;
try {
// 调用接口并获取结果
String input = String.valueOf(client.billQuery(jsonData));
Gson gson = new Gson();
jsonArray = gson.fromJson(input, JsonArray.class);
String string = jsonArray.toString();
} catch (Exception e) {
e.printStackTrace();
}
return jsonArray;
}
}