evoToK3Cloud/ruoyi-system/src/main/java/com/ruoyi/system/runner/JdUtil.java
tzy 2cc73d72d7 工艺日志推送
bom日志推送
2025-11-09 19:15:14 +08:00

3230 lines
142 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.system.runner;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.kingdee.bos.webapi.entity.RepoRet;
import com.kingdee.bos.webapi.sdk.K3CloudApi;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.JdUtils;
import com.ruoyi.system.domain.BomDetails;
import com.ruoyi.system.domain.PartCost;
import com.ruoyi.system.domain.dto.*;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.jdmain.rouplan.Model;
import org.aspectj.bridge.MessageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.ruoyi.common.core.domain.R.fail;
public class JdUtil {
private static final Logger log = LoggerFactory.getLogger(JdUtil.class);
static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 入库状态
public static JsonArray storageProduce(String number, String FMaterialIdCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "STK_InStock");
json.addProperty("FieldKeys", "F_UCHN_Text2,FMaterialId.FNumber,FMaterialName,FRealQty,FDocumentStatus");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "F_UCHN_Text2");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", number);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMaterialId.FNumber");
filterObject1.addProperty("Compare", "67");
filterObject1.addProperty("Value", FMaterialIdCode);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");// 排序字段,字符串类型
json.addProperty("TopRowCount", 0);// 返回总行数,整型
json.addProperty("StartRow", 0);// 开始行索引,整型
json.addProperty("Limit", 1000);// 最大行数整型不能超过10000
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
System.out.println(jsonData);
JsonArray jsonArray;
try {
// 调用接口并获取结果
String jsonStr = String.valueOf(client.billQuery(jsonData));
System.out.println(jsonStr);
Gson gson = new Gson();
jsonArray = gson.fromJson(jsonStr, JsonArray.class);
System.out.println(jsonArray);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
return jsonArray;
}
public static JsonArray storageProduce1(String number, String FMaterialIdCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_INSTOCK");
json.addProperty("FieldKeys", "F_UCHN_Text,FMaterialId.FNumber,FMaterialName,FRealQty,FDocumentStatus");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "F_UCHN_Text");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", number);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMaterialId.FNumber");
filterObject1.addProperty("Compare", "67");
filterObject1.addProperty("Value", FMaterialIdCode);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");// 排序字段,字符串类型
json.addProperty("TopRowCount", 0);// 返回总行数,整型
json.addProperty("StartRow", 0);// 开始行索引,整型
json.addProperty("Limit", 1000);// 最大行数整型不能超过10000
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
System.out.println(jsonData);
JsonArray jsonArray;
try {
// 调用接口并获取结果
String jsonStr = String.valueOf(client.billQuery(jsonData));
System.out.println(jsonStr);
Gson gson = new Gson();
jsonArray = gson.fromJson(jsonStr, JsonArray.class);
System.out.println(jsonArray);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
return jsonArray;
}
/*
* 查询库存
*/
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;
}
public static JsonArray selectKuCun1(List<ImMaterialVo> list) {
if (list == null || list.isEmpty()) {
return new JsonArray();
}
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();
for (ImMaterialVo imMaterialVo : list) {
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", imMaterialVo.getMaterialCode());
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();
JsonArray jsonArray;
try {
// 调用接口
String resultJson = String.valueOf(client.executeBillQuery(jsonData));
jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
} catch (Exception e) {
return null;
}
return jsonArray;
}
public static BigDecimal selectKuCun2(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();
BigDecimal fBaseQty = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null) {
for (JsonElement jsonElement : jsonArray) {
JsonObject asJsonObject = jsonElement.getAsJsonObject();
fBaseQty = asJsonObject.get("FBaseQty").getAsBigDecimal();
}
} else {
fBaseQty = BigDecimal.valueOf(0.0);
}
} catch (Exception e) {
return null;
}
return fBaseQty;
}
public static List<Model> getSelecPlan(String rooteProdet) {
List<ProductionRouteTwoVo> planOrderList = getSelectProceOrder(rooteProdet);
List<PlanPrcessNumDTO> plannedProcesses = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
for (ProductionRouteTwoVo planOrder : planOrderList) {
JsonObject json = new JsonObject();
json.addProperty("FormId", "SFC_OperationPlanning");
json.addProperty("FieldKeys",
"FID,FSubEntity_FDetailID,FProductId.FNumber,FOperNumber,FEntity_FEntryID,FProcessId.FName,FSeqNumber,FSeqName,FPlanStartTime,FPlanFinishTime,"
+
"FOperPlanStartTime,FOperPlanFinishTime");
json.addProperty("FieldKeys",
"F_HBYT_SCLH,FProductId.FNumber,FProductName,FMOQty , FOperNumber,FWorkCenterId.FName ,FProcessId.FName,FOperDescription,FOptCtrlCodeId.FName,FOperQty ,FOperPlanStartTime ,FOperPlanFinishTime,FPlanStartTime,FPlanFinishTime");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMONumber");
filterObject.addProperty("Compare", "="); // 改为等号运算符
// filterObject.addProperty("Value", planOrder.getFBillNo());
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
System.out.println(
// "生成查询计划订单查询 " + planOrder.getFBillNo() + " 的结果: " + resultJson
);
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
continue;
}
ObjectMapper objectMapper = new ObjectMapper();
List<PlanPrcessNumDTO> plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PlanPrcessNumDTO>>() {
});
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
plannedProcesses.addAll(plannedProcessList);
}
} catch (Exception e) {
}
}
// 转换为 List<Model> 格式
return null;
}
public static List<ProductionRouteTwoVo> getSelectProceOrder(String rooteProdet) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys", "F_HBYT_SCLH,FBillNo ,FMaterialId.FNumber,FMaterialName");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "F_HBYT_SCLH");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", rooteProdet);
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();
String resultJson;
try {
// 调用API接口
resultJson = String.valueOf(client.billQuery(jsonData));
// 使用Gson解析为JsonArray因为返回数据是直接的数组
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 将JsonArray转为PlanOrder列表
ObjectMapper objectMapper = new ObjectMapper();
List<ProductionRouteTwoVo> productionRouteTwoVos = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<ProductionRouteTwoVo>>() {
});
// 输出或返回结果
return productionRouteTwoVos;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/*
* 材料bom
* {
* "FMATERIALID.FNumber": "001HD24.01.01.017.0",
* "FITEMNAME": "行走原点标定",
* "FMATERIALIDCHILD.FNumber": "001HD24.01.01.016.2",
* "FCHILDITEMNAME": "不锈钢标尺",
* "FNUMERATOR": 1,
* "FDENOMINATOR": 1,
* "FChildBaseUnitID.FNumber": "jian"
* },
*/
public static List<Model> getPlanOrderVo(String materialCode) {
List<ProductionRouteTwoVo> planOrderList = getSelectProceOrder(materialCode);
List<PlanPrcessNumDTO> plannedProcesses = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
for (ProductionRouteTwoVo planOrder : planOrderList) {
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_BOM");
json.addProperty("FieldKeys",
"F_HBYT_SCLH,FMaterialID.FNumber,FMaterialID.FNumber2,FMaterialName1,FNumerator,FDenominator,FUnitID2.FName");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialID.FNumber");
filterObject.addProperty("Compare", "="); // 改为等号运算符
// filterObject.addProperty("Value", planOrder.getFBillNo());
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
System.out.println(
// "生成查询计划订单查询 " + planOrder.getFBillNo() + " 的结果: " + resultJson
);
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
continue;
}
ObjectMapper objectMapper = new ObjectMapper();
List<PlanPrcessNumDTO> plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PlanPrcessNumDTO>>() {
});
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
plannedProcesses.addAll(plannedProcessList);
}
} catch (Exception e) {
}
}
// 转换为 List<Model> 格式
return null;
}
// 查询物料是否为按图订制
/**
* 库存预留信息查询
*
* @param materialCode
* @return
*/
public static List<InvReserveAnalyzeRptDTO> getInvReserveAnalyzeRpt(String materialCode) {
List<InvReserveAnalyzeRptDTO> rptDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject jsonData = new JsonObject();
jsonData.addProperty("FieldKeys", "FMATERIALNUMBER,FMaterialName,FDemandTypeName,FSecQty,FSecAVBQty");
jsonData.addProperty("SchemeId", "");
jsonData.addProperty("StartRow", 0);
jsonData.addProperty("Limit", 2000);
jsonData.addProperty("IsVerifyBaseDataField", "true");
JsonArray filterArray = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("Left", "");
filterObject.addProperty("FieldName", "FMATERIALNUMBER");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterArray.add(filterObject);
jsonData.add("FilterString", filterArray);
JsonObject model = new JsonObject();
model.addProperty("FStockOrgId", "1");
JsonObject beginMaterialId = new JsonObject();
beginMaterialId.addProperty("FNUMBER", materialCode);
model.add("FBeginMaterialId", beginMaterialId);
model.addProperty("FDemandType", "PLN_FORECAST,PLN_PLANORDER,PRD_PPBOM,SAL_SaleOrder");
model.addProperty("FNeedTransOnly", false);
jsonData.add("Model", model);
String jsonString = jsonData.toString();
String formId = "PLN_InvReserveAnalyzeRpt";
String resultJson = null;
try {
resultJson = client.getSysReportData(formId, jsonString);
} catch (Exception e) {
System.err.println("Error fetching data for materialCode: " + materialCode);
e.printStackTrace();
return new ArrayList<>();
}
if (resultJson == null) {
System.err.println("No data returned for materialCode: " + materialCode);
return new ArrayList<>();
}
JsonObject resultObject = new Gson().fromJson(resultJson, JsonObject.class);
JsonArray rows = resultObject.getAsJsonObject("Result").getAsJsonArray("Rows");
if (rows == null) {
System.err.println("No data returned for materialCode: " + materialCode);
return new ArrayList<>();
}
System.out.println("库存预留单===========>" + rows);
for (JsonElement rowElement : rows) {
JsonArray row = rowElement.getAsJsonArray();
InvReserveAnalyzeRptDTO analyzeRptDTO = new InvReserveAnalyzeRptDTO();
analyzeRptDTO.setFMATERIALNUMBER(getStringFromJsonArray(row, 0));
analyzeRptDTO.setFMaterialName(getStringFromJsonArray(row, 1));
analyzeRptDTO.setFDemandTypeName(getStringFromJsonArray(row, 2));
analyzeRptDTO.setFSecQty(getDoubleFromJsonArray(row, 3));
analyzeRptDTO.setFSecAVBQty(getDoubleFromJsonArray(row, 4));
rptDTOS.add(analyzeRptDTO);
}
return rptDTOS;
}
private static String getStringFromJsonArray(JsonArray array, int index) {
return array.size() > index && !array.get(index).isJsonNull() ? array.get(index).getAsString() : "";
}
private static double getDoubleFromJsonArray(JsonArray array, int index) {
if (array.size() > index && !array.get(index).isJsonNull()) {
String value = array.get(index).getAsString();
if (!value.isEmpty()) {
try {
return Double.parseDouble(value);
} catch (NumberFormatException e) {
System.err.println("NumberFormatException for value: " + value);
}
}
}
return 0.0;
}
/**
* 查询生产订单单据体
* 查询
*
* @param materialCode
* @return
*/
public static List<ProMoDTO> getProMoList(String materialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FNoStockInQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "="); // 改为等号运算符
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FStatus");
filterObject1.addProperty("Compare", "106"); // 改为等号运算符
filterObject1.addProperty("Value", 5);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FStatus");
filterObject2.addProperty("Compare", "106"); // 改为等号运算符
filterObject2.addProperty("Value", 6);
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject2);
JsonObject filterObject3 = new JsonObject();
filterObject3.addProperty("FieldName", "FStatus");
filterObject3.addProperty("Compare", "106"); // 改为等号运算符
filterObject3.addProperty("Value", 7);
filterObject3.addProperty("Left", "");
filterObject3.addProperty("Right", "");
filterObject3.addProperty("Logic", 0);
filterString.add(filterObject3);
JsonObject filterObject4 = new JsonObject();
filterObject4.addProperty("FieldName", "FNoStockInQty");
filterObject4.addProperty("Compare", "21"); // 改为等号运算符
filterObject4.addProperty("Value", 0);
filterObject4.addProperty("Left", "");
filterObject4.addProperty("Right", "");
filterObject4.addProperty("Logic", 0);
filterString.add(filterObject4);
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();
List<ProMoDTO> promoList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
promoList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<ProMoDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return promoList; // 返回结果
}
/**
* 查询生产订单未入库 本项目除外
* 查询
*
* @param materialCode
* @return
*/
public static List<ProMoDTO> getProMoListLimitByProCode(String materialCode, String proCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FNoStockInQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "="); // 改为等号运算符
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FStatus");
filterObject1.addProperty("Compare", "106"); // 改为等号运算符
filterObject1.addProperty("Value", 5);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FStatus");
filterObject2.addProperty("Compare", "106"); // 改为等号运算符
filterObject2.addProperty("Value", 6);
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject2);
JsonObject filterObject3 = new JsonObject();
filterObject3.addProperty("FieldName", "FStatus");
filterObject3.addProperty("Compare", "106"); // 改为等号运算符
filterObject3.addProperty("Value", 7);
filterObject3.addProperty("Left", "");
filterObject3.addProperty("Right", "");
filterObject3.addProperty("Logic", 0);
filterString.add(filterObject3);
JsonObject filterObject4 = new JsonObject();
filterObject4.addProperty("FieldName", "FNoStockInQty");
filterObject4.addProperty("Compare", "21"); // 改为等号运算符
filterObject4.addProperty("Value", 0);
filterObject4.addProperty("Left", "");
filterObject4.addProperty("Right", "");
filterObject4.addProperty("Logic", 0);
filterString.add(filterObject4);
JsonObject filterObject5 = new JsonObject();
filterObject5.addProperty("FieldName", "F_HBYT_SCLH");
filterObject5.addProperty("Compare", "83");
filterObject5.addProperty("Value", proCode);//筛选条件 生产令号
filterObject5.addProperty("Left", "");
filterObject5.addProperty("Right", "");
filterObject5.addProperty("Logic", 0);
filterString.add(filterObject5);
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();
List<ProMoDTO> promoList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
promoList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<ProMoDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return promoList; // 返回结果
}
/**
* 查询生产订单未入库 本项目
* 查询
*
* @param materialCode
* @return
*/
public static List<ProMoDTO> getProMoListByProCode(String materialCode, String proCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FNoStockInQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "="); // 改为等号运算符
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FStatus");
filterObject1.addProperty("Compare", "106"); // 改为等号运算符
filterObject1.addProperty("Value", 5);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FStatus");
filterObject2.addProperty("Compare", "106"); // 改为等号运算符
filterObject2.addProperty("Value", 6);
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject2);
JsonObject filterObject3 = new JsonObject();
filterObject3.addProperty("FieldName", "FStatus");
filterObject3.addProperty("Compare", "106"); // 改为等号运算符
filterObject3.addProperty("Value", 7);
filterObject3.addProperty("Left", "");
filterObject3.addProperty("Right", "");
filterObject3.addProperty("Logic", 0);
filterString.add(filterObject3);
JsonObject filterObject4 = new JsonObject();
filterObject4.addProperty("FieldName", "FNoStockInQty");
filterObject4.addProperty("Compare", "21"); // 改为等号运算符
filterObject4.addProperty("Value", 0);
filterObject4.addProperty("Left", "");
filterObject4.addProperty("Right", "");
filterObject4.addProperty("Logic", 0);
filterString.add(filterObject4);
JsonObject filterObject5 = new JsonObject();
filterObject5.addProperty("FieldName", "F_HBYT_SCLH");
filterObject5.addProperty("Compare", "=");
filterObject5.addProperty("Value", proCode);//筛选条件 生产令号
filterObject5.addProperty("Left", "");
filterObject5.addProperty("Right", "");
filterObject5.addProperty("Logic", 0);
filterString.add(filterObject5);
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();
List<ProMoDTO> promoList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
promoList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<ProMoDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return promoList; // 返回结果
}
/**
* 查询采购订单 单据体
* 将预留量更改为 剩余未入库数量20250325
*
* @param materialCode
* @return
*/
public static List<PurchaseOrderDTO> getPurchaseOrderList(String materialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_PurchaseOrder");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FRemainStockINQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "="); // 改为等号运算符
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMRPCloseStatus");
filterObject1.addProperty("Compare", "105"); // 改为等号运算符
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);// 从 PlanOrderVo 获取生产令号
filterString.add(filterObject1);
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();
List<PurchaseOrderDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PurchaseOrderDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
/**
* 查询采购订单 单据体
* 将预留量更改为 剩余未入库数量20250325
*
* @param materialCode
* @return
*/
public static List<PurchaseOrderDTO> getPurchaseOrderListByProCode(String materialCode, String proCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_PurchaseOrder");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FRemainStockINQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMRPCloseStatus");
filterObject1.addProperty("Compare", "105");
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "F_UCHN_Text2");
filterObject2.addProperty("Compare", "83");
filterObject2.addProperty("Value", proCode);// 生产令号
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject2);
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();
List<PurchaseOrderDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PurchaseOrderDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
public static List<PurchaseRequestDTO> getPurchaseRequestByProCode(String materialCode, String proCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_Requisition");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FReqQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "F_UCHN_Text");
filterObject1.addProperty("Compare", "=");
filterObject1.addProperty("Value", proCode);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
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();
List<PurchaseRequestDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PurchaseRequestDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
// 采购申请(本项目除外)
public static List<PurchaseRequestDTO> getPurchaseRequestByLimitProCode(String materialCode, String proCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_Requisition");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FReqQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "F_UCHN_Text");
filterObject1.addProperty("Compare", "83");
filterObject1.addProperty("Value", proCode);
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
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();
List<PurchaseRequestDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PurchaseRequestDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
/**
* 查询生产用料清单单据体
* 查询子项物料的未领料量
*
* @param materialCode
* @return
*/
public static List<JDProductionDTO> getWeiLingliaoLimBen(String materialCode, String procode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_PPBOM");
json.addProperty("FieldKeys",
"FMaterialID2.FNumber,FMaterialName1,FNoPickedQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialID2.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMoEntryStatus");
filterObject1.addProperty("Compare", "5");
filterObject1.addProperty("Value", "7");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FMoEntryStatus");// 改为等号运算符
filterObject2.addProperty("Compare", "5");
filterObject2.addProperty("Value", "5");
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject2);
JsonObject filterObject3 = new JsonObject();
filterObject3.addProperty("FieldName", "FMoEntryStatus");
filterObject3.addProperty("Compare", "5");
filterObject3.addProperty("Value", "6");
filterObject3.addProperty("Left", "");
filterObject3.addProperty("Right", "");
filterObject3.addProperty("Logic", 0);
filterString.add(filterObject3);
JsonObject filterObject4 = new JsonObject();
filterObject4.addProperty("FieldName", "FDocumentStatus");
filterObject4.addProperty("Compare", "105");
filterObject4.addProperty("Value", "C");//单据状态:已审核
filterObject4.addProperty("Left", "");
filterObject4.addProperty("Right", "");
filterObject4.addProperty("Logic", 0);
filterString.add(filterObject4);
JsonObject filterObject5 = new JsonObject();
filterObject5.addProperty("FieldName", "F_HBYT_SCLH");
filterObject5.addProperty("Compare", "=");
filterObject5.addProperty("Value", procode);//筛选条件 生产令号
filterObject5.addProperty("Left", "");
filterObject5.addProperty("Right", "");
filterObject5.addProperty("Logic", 0);
filterString.add(filterObject5);
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();
List<JDProductionDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JDProductionDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
/**
* 查询生产用料清单单据体
* 查询子项物料的未领料量
*
* @param materialCode
* @return
*/
public static List<JDProductionDTO> getWeiLingliao(String materialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_PPBOM");
json.addProperty("FieldKeys",
"FMaterialID2.FNumber,FMaterialName1,FNoPickedQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialID2.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMoEntryStatus");
filterObject1.addProperty("Compare", "5");
filterObject1.addProperty("Value", "7");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FMoEntryStatus");// 改为等号运算符
filterObject2.addProperty("Compare", "5");
filterObject2.addProperty("Value", "5");
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject2);
JsonObject filterObject3 = new JsonObject();
filterObject3.addProperty("FieldName", "FMoEntryStatus");
filterObject3.addProperty("Compare", "5");
filterObject3.addProperty("Value", "6");
filterObject3.addProperty("Left", "");
filterObject3.addProperty("Right", "");
filterObject3.addProperty("Logic", 0);
filterString.add(filterObject3);
JsonObject filterObject4 = new JsonObject();
filterObject4.addProperty("FieldName", "FDocumentStatus");
filterObject4.addProperty("Compare", "105");
filterObject4.addProperty("Value", "C");//单据状态:已审核
filterObject4.addProperty("Left", "");
filterObject4.addProperty("Right", "");
filterObject4.addProperty("Logic", 0);
filterString.add(filterObject4);
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();
List<JDProductionDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JDProductionDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
/**
* 查询生产用料清单单据体
* 查询子项物料的未领料量限制生产令号
*
* @param materialCode
* @return
*/
public static List<JDProductionDTO> getWeiLingliaoByProcode(String materialCode, String procode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_PPBOM");
json.addProperty("FieldKeys",
"FMaterialID2.FNumber,FMaterialName1,FNoPickedQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialID2.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", materialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMoEntryStatus");
filterObject1.addProperty("Compare", "5");
filterObject1.addProperty("Value", "7");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FMoEntryStatus");// 改为等号运算符
filterObject2.addProperty("Compare", "5");
filterObject2.addProperty("Value", "5");
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject2);
JsonObject filterObject3 = new JsonObject();
filterObject3.addProperty("FieldName", "FMoEntryStatus");
filterObject3.addProperty("Compare", "5");
filterObject3.addProperty("Value", "6");
filterObject3.addProperty("Left", "");
filterObject3.addProperty("Right", "");
filterObject3.addProperty("Logic", 0);
filterString.add(filterObject3);
JsonObject filterObject4 = new JsonObject();
filterObject4.addProperty("FieldName", "FDocumentStatus");
filterObject4.addProperty("Compare", "105");
filterObject4.addProperty("Value", "C");//单据状态:已审核
filterObject4.addProperty("Left", "");
filterObject4.addProperty("Right", "");
filterObject4.addProperty("Logic", 0);
filterString.add(filterObject4);
JsonObject filterObject5 = new JsonObject();
filterObject5.addProperty("FieldName", "F_HBYT_SCLH");
filterObject5.addProperty("Compare", "83");
filterObject5.addProperty("Value", procode);//筛选条件 生产令号
filterObject5.addProperty("Left", "");
filterObject5.addProperty("Right", "");
filterObject5.addProperty("Logic", 0);
filterString.add(filterObject5);
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();
List<JDProductionDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JDProductionDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
public static List<JDInventoryDTO> getKuCun(String materialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "STK_Inventory");
json.addProperty("FieldKeys",
"FMaterialId.FNumber,FMaterialName,FBaseQty");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMaterialId.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
List<JDInventoryDTO> plannedProcessList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
plannedProcessList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JDInventoryDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return plannedProcessList; // 返回结果
}
public static Double getKeyong(String materialCode) {
List<InvReserveAnalyzeRptDTO> analyzeRpt = getInvReserveAnalyzeRpt(materialCode);
if (analyzeRpt.isEmpty()) {
System.err.println("No inventory data found for materialCode: " + materialCode);
return 0.0; // 返回 0.0 而不是 null
}
double fSecAVBQty = 0.0;
double fSecQty = 0.0;
fSecAVBQty = analyzeRpt.get(0).getFSecAVBQty();
for (InvReserveAnalyzeRptDTO analyzeRptDTO : analyzeRpt) {
if (analyzeRptDTO.getFSecQty() != null) {
fSecQty += analyzeRptDTO.getFSecQty();
}
}
double productionQty = 0.0;
List<ProMoDTO> proMoList = getProMoList(materialCode);
if (proMoList != null) {
for (ProMoDTO proMoDTO : proMoList) {
productionQty += proMoDTO.getFQty();
}
}
double purchaseQty = 0.0;
List<PurchaseOrderDTO> purchaseOrderList = getPurchaseOrderList(materialCode);
if (purchaseOrderList != null) {
for (PurchaseOrderDTO purchaseOrderDTO : purchaseOrderList) {
purchaseQty += purchaseOrderDTO.getFRemainStockINQty();
}
}
return fSecAVBQty + productionQty + purchaseQty - fSecQty;
}
// 金蝶物料查询
public static int isMaterialVerification(String DrawingNumber, String name) {
if (DrawingNumber == null || DrawingNumber.isEmpty() || name == null || name.isEmpty()) {
return 0;
}
JsonArray jsonArray = JdUtils.loadMaterialQuery(DrawingNumber, name);
if (jsonArray == null) {
return 0;
} else {
for (JsonElement jsonElement : jsonArray) {
String FNumber = jsonElement.getAsJsonObject().get("FNumber").getAsString();
String FName = jsonElement.getAsJsonObject().get("FName").getAsString();
// 检查名称是否一致
if (FNumber.equals(DrawingNumber)) {
if (!FName.equals(name)) {
log.warn("编码相同但名称不同: 编码 = {}, 名称 = {}, 查询到的名称 = {}", DrawingNumber, name, FName);
return 3; // 编码相同但名称不同
}
return 1; // 编码和名称都一致
}
}
return 1; // 编码未找到返回1表示正常
}
}
/*本接口用于实现物料清单 的禁用功能*/
public static void jtestForbidMaterial(String FNumber) throws Exception {
K3CloudApi api = new K3CloudApi();
String data = "{\"CreateOrgId\": 0,\"Numbers\": [" + "\"" + FNumber + "\"" + "],\"Ids\": \"\",\"PkEntryIds\":[],\"NetworkCtrl\": \"\",\"IgnoreInterationFlag\": \"\"}";
String result = api.excuteOperation("ENG_BOM", "Forbid", data);
Gson gson = new Gson();
RepoRet repoRet = gson.fromJson(result, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
System.out.printf("物料禁用接口: %s%n", gson.toJson(repoRet.getResult()));
} else {
fail("物料提交接口: " + gson.toJson(repoRet.getResult()));
}
}
//用料清单查询接口腹肌无聊
public static List<JinYongDTO> getFuji(String materialCode) {
List<JinYongDTO> jinYongDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_BOM");
json.addProperty("FieldKeys", "FNumber");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMATERIALIDCHILD.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<JinYongDTO> JinYongDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JinYongDTO>>() {
});
if (JinYongDTOList != null && !JinYongDTOList.isEmpty()) {
jinYongDTOS.addAll(JinYongDTOList);
}
} else {
log.warn("未找到与bom版本号 " + materialCode + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return jinYongDTOS;
}
//查询物料 FMATERIALID SubHeadEntity5FEntryId
public static List<JdEntry> getEntryID(String materialCode) {
List<JdEntry> jinYongDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FMATERIALID,SubHeadEntity5_FEntryId");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<JdEntry> JinYongDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JdEntry>>() {
});
if (JinYongDTOList != null && !JinYongDTOList.isEmpty()) {
jinYongDTOS.addAll(JinYongDTOList);
}
} else {
log.warn("未找到与bom版本号 " + materialCode + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return jinYongDTOS;
}
//修改物料工时,固定单位=分
public static void atestSaveMaterial(int FMATERIALID, int fEntryId, String materialCode, double laborTime) throws Exception {
K3CloudApi api = new K3CloudApi(false);
// 创建主 JSON 对象
JsonObject mainObject = new JsonObject();
// 创建 NeedUpDateFields 数组
JsonArray needUpdateFields = new JsonArray();
needUpdateFields.add("SubHeadEntity5");
needUpdateFields.add("FStdLaborProcessTime");
needUpdateFields.add("FMATERIALID");
needUpdateFields.add("FStandHourUnitId");
JsonArray needReturnFields = new JsonArray();
needReturnFields.add("SubHeadEntity5_FEntryId");
needReturnFields.add("FStdLaborProcessTime");
needReturnFields.add("FNumber");
// 设置 IsDeleteEntry 字段
mainObject.addProperty("IsDeleteEntry", "false");
// 创建 Model 对象
JsonObject modelObject = new JsonObject();
modelObject.addProperty("FMATERIALID", FMATERIALID);
modelObject.addProperty("FNumber", materialCode);
// 创建 SubHeadEntity5 对象
JsonObject subHeadEntity5 = new JsonObject();
subHeadEntity5.addProperty("FEntryId", fEntryId);
subHeadEntity5.addProperty("FStdLaborProcessTime", laborTime);
subHeadEntity5.addProperty("FStandHourUnitId", "60");
// 将 SubHeadEntity5 添加到 Model 对象
modelObject.add("SubHeadEntity5", subHeadEntity5);
// 将 NeedUpDateFields 和 NeedReturnFields 添加到主对象
mainObject.add("NeedUpDateFields", needUpdateFields);
mainObject.add("NeedReturnFields", needReturnFields);
// 将 Model 添加到主对象
mainObject.add("Model", modelObject);
String data = mainObject.toString();
String result = api.save("BD_Material", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
System.out.printf("物料保存接口: %s%n", gson.toJson(sRet.getResult()));
} else {
fail("物料保存接口: " + gson.toJson(sRet.getResult()));
}
}
//新增父级物料
public static int loadChengPinMaterialPreservation(BomDetails bomDetail, Double fbWorkTime) {
K3CloudApi client = new K3CloudApi();
// 创建一个空的JsonObject
JsonObject json = new JsonObject();
// 添加IsAutoSubmitAndAudit字段
json.addProperty("IsAutoSubmitAndAudit", "true");
// 创建Model对象并加入JsonObject
JsonObject model = new JsonObject();
json.add("Model", model);
// 添加Model字段
model.addProperty("FMATERIALID", 0);
if (!(bomDetail.getDanZhong() == null)) {
model.addProperty("F_HBYT_DZ", bomDetail.getDanZhong());
}
model.addProperty("FNumber", bomDetail.getFNumber());
model.addProperty("FName", bomDetail.getFName());
// 创建FMaterialGroup对象并加入Model
JsonObject fMaterialGroup = new JsonObject();
fMaterialGroup.addProperty("FNumber", "A000106");
model.add("FMaterialGroup", fMaterialGroup);
model.addProperty("FIsHandleReserve", true);
// 创建SubHeadEntity对象并加入Model
JsonObject subHeadEntity = new JsonObject();
model.add("SubHeadEntity", subHeadEntity);
subHeadEntity.addProperty("FErpClsID", "2");
subHeadEntity.addProperty("FFeatureItem", "1");
// 创建FCategoryID对象并加入SubHeadEntity
JsonObject fCategoryID = new JsonObject();
fCategoryID.addProperty("FNumber", "CHLB05_SYS");// 产成品
subHeadEntity.add("FCategoryID", fCategoryID);
// 创建FTaxRateId对象并加入SubHeadEntity
JsonObject fTaxRateId = new JsonObject();
fTaxRateId.addProperty("FNUMBER", "SL02_SYS");
subHeadEntity.add("FTaxRateId", fTaxRateId);
// 创建FBaseUnitId对象并加入SubHeadEntity
JsonObject fBaseUnitId = new JsonObject();
fBaseUnitId.addProperty("FNumber", "008");
subHeadEntity.add("FBaseUnitId", fBaseUnitId);
subHeadEntity.addProperty("FIsPurchase", true);
subHeadEntity.addProperty("FIsInventory", true);
// 成品不允许委外
// subHeadEntity.addProperty("FIsSubContract", true);
subHeadEntity.addProperty("FIsSale", true);
subHeadEntity.addProperty("FIsProduce", true);
// 创建SubHeadEntity1对象并加入Model
JsonObject subHeadEntity1 = new JsonObject();
model.add("SubHeadEntity1", subHeadEntity1);
JsonObject fStoreUnitId = new JsonObject();
fStoreUnitId.addProperty("FNumber", "008");
subHeadEntity1.add("FStoreUnitID", fStoreUnitId);
subHeadEntity1.addProperty("FUnitConvertDir", "1");
// 创建FStockId对象并加入SubHeadEntity1
JsonObject fStockId = new JsonObject();
// 判断是产成品还是企标
String cangKu = "CK011";
fStockId.addProperty("FNumber", cangKu);
subHeadEntity1.add("FStockId", fStockId);
// 创建FCurrencyId对象并加入SubHeadEntity1
JsonObject fCurrencyId = new JsonObject();
fCurrencyId.addProperty("FNumber", "PRE001");
subHeadEntity1.add("FCurrencyId", fCurrencyId);
subHeadEntity1.addProperty("FIsSNPRDTracy", false);
subHeadEntity1.addProperty("FSNManageType", "1");
subHeadEntity1.addProperty("FSNGenerateTime", "1");
subHeadEntity1.addProperty("FBoxStandardQty", 0.0);
// 创建FPurchaseUnitId对象并加入SubHeadEntity1
JsonObject fPurchaseUnitId = new JsonObject();
fPurchaseUnitId.addProperty("FNumber", "008");
subHeadEntity1.add("FPurchaseUnitId", fPurchaseUnitId);
// 创建SubHeadEntity3对象并加入Model
JsonObject subHeadEntity3 = new JsonObject();
model.add("SubHeadEntity3", subHeadEntity3);
// 创建FPurchasePriceUnitId对象并加入SubHeadEntity3
JsonObject fPurchasePriceUnitId = new JsonObject();
fPurchasePriceUnitId.addProperty("FNumber", "008");
subHeadEntity3.add("FPurchasePriceUnitId", fPurchasePriceUnitId);
subHeadEntity3.addProperty("FIsQuota", false);
subHeadEntity3.addProperty("FQuotaType", "1");
// 创建SubHeadEntity6对象并加入Model 检验项
JsonObject subHeadEntity6 = new JsonObject();
model.add("SubHeadEntity6", subHeadEntity6);
subHeadEntity6.addProperty("FCheckProduct", true);
subHeadEntity6.addProperty("FCheckReturn", true);
// 创建SubHeadEntity5对象并加入Model
JsonObject subHeadEntity5 = new JsonObject();
model.add("SubHeadEntity5", subHeadEntity5);
// 创建FProduceUnitId对象并加入SubHeadEntity5
JsonObject fProduceUnitId = new JsonObject();
fProduceUnitId.addProperty("FNumber", "008");
subHeadEntity5.add("FProduceUnitId", fProduceUnitId);
// 创建FProduceBillType对象并加入SubHeadEntity5
JsonObject fProduceBillType = new JsonObject();
fProduceBillType.addProperty("FNUMBER", "SCDD05_SYS");
subHeadEntity5.add("FProduceBillType", fProduceBillType);
// 创建FBOMUnitId对象并加入SubHeadEntity5
JsonObject fBOMUnitId = new JsonObject();
fBOMUnitId.addProperty("FNumber", "008");
subHeadEntity5.add("FBOMUnitId", fBOMUnitId);
subHeadEntity5.addProperty("FIsMainPrd", true);
subHeadEntity5.addProperty("FIssueType", "1");
// 创建FPickStockId对象并加入SubHeadEntity5
JsonObject fPickStockId = new JsonObject();
fPickStockId.addProperty("FNumber", "CK012");
subHeadEntity1.add("FPickStockId", fPickStockId);
subHeadEntity5.addProperty("FOverControlMode", "1");
subHeadEntity5.addProperty("FStdLaborProcessTime", fbWorkTime);
subHeadEntity5.addProperty("FStandHourUnitId", "60");
subHeadEntity5.addProperty("FBackFlushType", "1");
String jsonData = json.toString();
System.out.println(jsonData);
try {
// 业务对象标识
String formId = "BD_MATERIAL";
// 调用接口
String resultJson = client.save(formId, jsonData);
// 用于记录结果
Gson gson = new Gson();
// 对返回结果进行解析和校验
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
log.debug("接口返回结果: %s%n" + gson.toJson(repoRet.getResult()));
return 1;
} else {
MessageUtil.fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
log.error("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
return 0;
}
} catch (Exception e) {
MessageUtil.fail(e.getMessage());
return 0;
}
}
//查询物料 作用于更新到物料的 仓位 是否启用VMI
public static List<JdEntryVmi> getEntryID2(String materialCode) {
List<JdEntryVmi> jinYongDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FMATERIALID,SubHeadEntity1_FEntryId,SubHeadEntity3_FEntryId");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
log.info("查询物料是否启用VMI的接口参数: {}", jsonData);
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<JdEntryVmi> entryVmis = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JdEntryVmi>>() {
});
if (entryVmis != null && !entryVmis.isEmpty()) {
jinYongDTOS.addAll(entryVmis);
}
} else {
log.warn("未找到与 " + materialCode + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return jinYongDTOS;
}
//更新VMI
public static String updateVMI(int FMATERIALID, int fEntryId1, int fEntryId2, String cangkunum, String cangWeiNum) throws Exception {
K3CloudApi api = new K3CloudApi(false);
JsonObject json = new JsonObject();
// 创建 NeedUpDateFields 数组
JsonArray needUpDateFields = new JsonArray();
needUpDateFields.add("SubHeadEntity1");
needUpDateFields.add("FMATERIALID");
needUpDateFields.add("SubHeadEntity3");
needUpDateFields.add("FStockPlaceId");
needUpDateFields.add("FStockId");
needUpDateFields.add("FIsVmiBusiness");
//needUpDateFields.add("FIsVmiBusiness");
json.add("NeedUpDateFields", needUpDateFields);
// 添加 IsDeleteEntry 属性
json.addProperty("IsDeleteEntry", "false");
// 创建 Model 对象
JsonObject model = new JsonObject();
model.addProperty("FMATERIALID", FMATERIALID);
// 创建 SubHeadEntity1 对象
JsonObject subHeadEntity1 = new JsonObject();
subHeadEntity1.addProperty("FEntryId", fEntryId1);
// 创建 FStockId 对象
JsonObject fStockId = new JsonObject();
fStockId.addProperty("FNumber", cangkunum);
subHeadEntity1.add("FStockId", fStockId);
// 创建 FStockPlaceId 对象
JsonObject fStockPlaceId = new JsonObject();
JsonObject fStockPlaceIdFF100002 = new JsonObject();
fStockPlaceIdFF100002.addProperty("FNumber", cangWeiNum);
//
// fStockPlaceId.add("FSTOCKPLACEID__FF100002", fStockPlaceIdFF100002);
fStockPlaceId.add("FSTOCKPLACEID__FF100002", fStockPlaceIdFF100002);
subHeadEntity1.add("FStockPlaceId", fStockPlaceId);
model.add("SubHeadEntity1", subHeadEntity1);
// 创建 SubHeadEntity3 对象
JsonObject subHeadEntity3 = new JsonObject();
subHeadEntity3.addProperty("FEntryId", fEntryId2);
subHeadEntity3.addProperty("FIsVmiBusiness", "true");
model.add("SubHeadEntity3", subHeadEntity3);
json.add("Model", model);
String data = json.toString();
String result = api.save("BD_Material", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
String successMessage = String.format("物料 %s 保存成功", sRet.getResult().getResponseStatus());
System.out.println(successMessage);
return successMessage;
} else {
String errorMessage = String.format("物料 %s 保存失败: %s", FMATERIALID, gson.toJson(sRet.getResult()));
System.out.println(errorMessage);
return errorMessage;
}
}
public static void updateDanzhong(int FMATERIALID, String danzhong) throws Exception {
K3CloudApi api = new K3CloudApi(false);
JsonObject json = new JsonObject();
// 创建 NeedUpDateFields 数组
JsonArray needUpDateFields = new JsonArray();
needUpDateFields.add("FMATERIALID");
needUpDateFields.add("F_HBYT_DZ");
//needUpDateFields.add("FIsVmiBusiness");
json.add("NeedUpDateFields", needUpDateFields);
// 添加 IsDeleteEntry 属性
json.addProperty("IsDeleteEntry", "false");
JsonObject model = new JsonObject();
model.addProperty("FMATERIALID", FMATERIALID); // 创建 Model 对象
model.addProperty("F_HBYT_DZ", danzhong);
json.add("Model", model);
String data = json.toString();
String result = api.save("BD_Material", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
String successMessage = String.format("物料 %s 保存成功", sRet.getResult().getResponseStatus());
System.out.println(successMessage);
} else {
String errorMessage = String.format("物料 %s 保存失败: %s", FMATERIALID, gson.toJson(sRet.getResult()));
System.out.println(errorMessage);
}
}
//查询物料清单 的 行iD
public static List<JdHuoZhu> getFID(String materialCode) {
List<JdHuoZhu> jinYongDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_BOM");
json.addProperty("FieldKeys", "FTreeEntity_FENTRYID,FID");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMATERIALIDCHILD.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<JdHuoZhu> JinYongDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JdHuoZhu>>() {
});
if (JinYongDTOList != null && !JinYongDTOList.isEmpty()) {
jinYongDTOS.addAll(JinYongDTOList);
}
} else {
log.warn("未找到与bom版本号 " + materialCode + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return jinYongDTOS;
}
//更新物料清单 的 行ID
public static String updateHuozhu(int FID, int FENTRYID, String code) throws Exception {
K3CloudApi api = new K3CloudApi(false);
JsonObject json = new JsonObject();
// 构建 NeedUpDateFields 数组
JsonArray needUpDateFields = new JsonArray();
needUpDateFields.add("FID");
needUpDateFields.add("FOWNERTYPEID");
needUpDateFields.add("FOWNERID");
needUpDateFields.add("FTreeEntity");
needUpDateFields.add("FTreeEntity_FENTRYID");
json.add("NeedUpDateFields", needUpDateFields);
// 添加 IsDeleteEntry 字段
json.addProperty("IsDeleteEntry", "false");
// 构建 Model 对象
JsonObject model = new JsonObject();
model.addProperty("FID", FID);
// 构建 FTreeEntity 数组
JsonArray fTreeEntity = new JsonArray();
JsonObject fTreeEntityItem = new JsonObject();
fTreeEntityItem.addProperty("FENTRYID", FENTRYID);
fTreeEntityItem.addProperty("FOWNERTYPEID", "BD_Supplier");
// 构建 FOWNERID 对象
JsonObject fOwnerId = new JsonObject();
fOwnerId.addProperty("FNumber", "GYS_070");
fTreeEntityItem.add("FOWNERID", fOwnerId);
fTreeEntity.add(fTreeEntityItem);
model.add("FTreeEntity", fTreeEntity);
json.add("Model", model);
String data = json.toString();
String result = api.save("ENG_BOM", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
String successMessage = String.format("物料清单 %s 保存成功", sRet.getResult().getResponseStatus());
log.info("更新货主信息物料编码==>" + code + " 保存成功");
return successMessage;
} else {
String errorMessage = String.format("物料 %s 保存失败: %s", FENTRYID, gson.toJson(sRet.getResult()));
log.info("更新货主信息物料编码" + code + "保存失败" + "原因:" + gson.toJson(sRet.getResult()));
return errorMessage;
}
}
//查询物料清单 的 行iD
public static JdHuoZhu getFIDToProductionOrder(PlanOrderVo planOrder) {
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys", "FTreeEntity_FENTRYID,FID");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FBillNo");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", planOrder.getFBillNo());
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<JdHuoZhu> jinYongDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JdHuoZhu>>() {
});
if (jinYongDTOList != null && !jinYongDTOList.isEmpty()) {
return jinYongDTOList.get(0); // 返回第一个对象
}
} else {
log.warn("未找到与次生产订单的FID " + planOrder.getFBillNo() + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return null; // 如果没有找到,返回 null
}
//保存更新生产订单的开工时间
public static String updateOrder(JdHuoZhu jdHuoZhu, Model numDTO, Date xuStartTime, Date xuEndTime) throws Exception {
String planStartDate = dateFormat.format(xuStartTime);
String planFinishDate = dateFormat.format(xuEndTime);
K3CloudApi api = new K3CloudApi(false);
JsonObject json = new JsonObject();
// 构建 NeedUpDateFields 数组
JsonArray needUpDateFields = new JsonArray();
needUpDateFields.add("FID");
needUpDateFields.add("FPlanStartDate");
needUpDateFields.add("FTreeEntity_FENTRYID");
needUpDateFields.add("FPlanFinishDate");
json.add("NeedUpDateFields", needUpDateFields);
// 添加 IsDeleteEntry 字段
json.addProperty("IsDeleteEntry", "false");
// 构建 Model 对象
JsonObject model = new JsonObject();
model.addProperty("FID", jdHuoZhu.getFID());
// 构建 FTreeEntity 数组
JsonArray fTreeEntity = new JsonArray();
JsonObject fTreeEntityItem = new JsonObject();
fTreeEntityItem.addProperty("FPlanStartDate", planStartDate);
fTreeEntityItem.addProperty("FPlanFinishDate", planFinishDate);
fTreeEntityItem.addProperty("FENTRYID", jdHuoZhu.getFTreeEntityFENTRYID());
fTreeEntity.add(fTreeEntityItem);
model.add("FTreeEntity", fTreeEntity);
json.add("Model", model);
String data = json.toString();
String result = api.save("PRD_MO", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
String successMessage = String.format("生产订单 %s 保存成功", sRet.getResult().getResponseStatus());
log.info("物料编码" + numDTO.getFID() + "保存成功");
return successMessage;
} else {
String errorMessage = String.format("物料 %s 保存失败: %s", +numDTO.getFID(), gson.toJson(sRet.getResult()));
log.info("物料编码" + numDTO.getFID() + "保存失败" + "原因:" + gson.toJson(sRet.getResult()));
return errorMessage;
}
}
public static List<SubHeadEntityDTO> getSubHeadEntity1Id(String materialCode) {
List<SubHeadEntityDTO> subHeadEntityDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "BD_MATERIAL");
json.addProperty("FieldKeys", "FMATERIALID,SubHeadEntity1_FEntryId");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
log.info("查询物料是否启用VMI的接口参数: {}", jsonData);
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<SubHeadEntityDTO> JinYongDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<SubHeadEntityDTO>>() {
});
if (JinYongDTOList != null && !JinYongDTOList.isEmpty()) {
subHeadEntityDTOS.addAll(JinYongDTOList);
}
} else {
log.warn("未找到与bom版本号 " + materialCode + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return subHeadEntityDTOS;
}
public static String updateKunCun(int FMATERIALID, int fEntryId1, int fMaxPOQty, int FSafeStock) throws Exception {
K3CloudApi api = new K3CloudApi(false);
JsonObject json = new JsonObject();
// 创建 NeedUpDateFields 数组
JsonArray needUpDateFields = new JsonArray();
needUpDateFields.add("SubHeadEntity1");
needUpDateFields.add("FMATERIALID");
needUpDateFields.add("SubHeadEntity4");
needUpDateFields.add("FIsEnableMaxStock");
needUpDateFields.add("FIsEnableSafeStock");
needUpDateFields.add("FMinPOQty");
needUpDateFields.add("FMaxPOQty");
needUpDateFields.add("FSafeStock");
json.add("NeedUpDateFields", needUpDateFields);
// 添加 IsDeleteEntry 属性
json.addProperty("IsDeleteEntry", "false");
// 创建 Model 对象
JsonObject model = new JsonObject();
model.addProperty("FMATERIALID", FMATERIALID);
// 创建 SubHeadEntity1 对象
JsonObject subHeadEntity1 = new JsonObject();
model.add("SubHeadEntity1", subHeadEntity1);
subHeadEntity1.addProperty("FEntryId", fEntryId1);
// 创建 FStockId 对象
JsonObject fStockId = new JsonObject();
subHeadEntity1.addProperty("FIsEnableMaxStock", true);
subHeadEntity1.addProperty("FIsEnableSafeStock", true);
subHeadEntity1.addProperty("FSafeStock", FSafeStock);
JsonObject subHeadEntity4 = new JsonObject();
model.add("SubHeadEntity4", subHeadEntity4);
subHeadEntity4.addProperty("FEntryId", fEntryId1);
subHeadEntity4.addProperty("FMaxPOQty", fMaxPOQty);
subHeadEntity4.addProperty("FMinPOQty", fMaxPOQty);
json.add("Model", model);
String data = json.toString();
String result = api.save("BD_Material", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
String successMessage = String.format("物料 %s 保存成功", sRet.getResult().getResponseStatus().getSuccessEntitys());
System.out.println(successMessage);
return successMessage;
} else {
String errorMessage = String.format("物料 %s 保存失败: %s", FMATERIALID, gson.toJson(sRet.getResult().getResponseStatus().getErrors()));
System.out.println(errorMessage);
return errorMessage;
}
}
//获取用料清单 根据父级物料编码,作为bom校验使用
public static List<JdValidateBomDTO> getSelectBomList(String FMaterialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_BOM");
json.addProperty("FieldKeys",
"FID,FMATERIALID.FNumber,FNumber,FITEMNAME,FUNITID.FName,FCHILDITEMNAME,FCHILDITEMPROPERTY,FMATERIALIDCHILD.FNumber,FNUMERATOR,FDENOMINATOR,F_HBYT_BJBM,F_HBYT_BJMC");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMATERIALID.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", FMaterialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObjec1 = new JsonObject();
filterObjec1.addProperty("FieldName", "FForbidStatus");
filterObjec1.addProperty("Compare", "105");
filterObjec1.addProperty("Value", "A");
filterObjec1.addProperty("Left", "");
filterObjec1.addProperty("Right", "");
filterObjec1.addProperty("Logic", 0);
filterString.add(filterObjec1);
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();
String resultJson;
try {
// 调用API接口
resultJson = String.valueOf(client.billQuery(jsonData));
// 将JsonArray转为JdValidateBomDTO列表
return JdUtil.transformToJdValidateBomDTO(resultJson);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String updateOldFuNumber(String FMATERIALID, String FNumber, String FOldNumber) throws Exception {
K3CloudApi api = new K3CloudApi(false);
JsonObject json = new JsonObject();
// 创建 NeedUpDateFields 数组
JsonArray needUpDateFields = new JsonArray();
needUpDateFields.add("FMATERIALID");
needUpDateFields.add("FNumber");
needUpDateFields.add("FOldNumber");
json.add("NeedUpDateFields", needUpDateFields);
// 添加 IsDeleteEntry 属性
json.addProperty("IsDeleteEntry", "false");
// 创建 Model 对象
JsonObject model = new JsonObject();
model.addProperty("FMATERIALID", FMATERIALID);
model.addProperty("FNumber", FNumber);
model.addProperty("FOldNumber", FOldNumber);
json.add("Model", model);
String data = json.toString();
String result = api.save("BD_Material", data);
Gson gson = new Gson();
RepoRet sRet = gson.fromJson(result, RepoRet.class);
if (sRet.isSuccessfully()) {
String successMessage = String.format("物料 %s 保存成功", sRet.getResult().getResponseStatus());
return successMessage;
} else {
String errorMessage = String.format("物料 %s 保存失败: %s", FMATERIALID, gson.toJson(sRet.getResult()));
return errorMessage;
}
}
public static List<JdValidateBomDTO> transformToJdValidateBomDTO(String jsonData) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonArray jsonArray = new Gson().fromJson(jsonData, JsonArray.class);
Map<String, JdValidateBomDTO> bomMap = new HashMap<>();
for (JsonElement element : jsonArray) {
JsonObject obj = element.getAsJsonObject();
String key = obj.get("FID").getAsString() + "_" +
obj.get("FMATERIALID.FNumber").getAsString() + "_" +
obj.get("FNumber").getAsString() + "_" +
obj.get("FITEMNAME").getAsString();
JdValidateBomDTO parentDTO = bomMap.computeIfAbsent(key, k -> {
JdValidateBomDTO dto = new JdValidateBomDTO();
dto.setFID(obj.get("FID").getAsString());
dto.setFNumber(obj.get("FMATERIALID.FNumber").getAsString());
// 记录BOM版本号金蝶返回的 FNumber 字段)
dto.setFNumberVersion(obj.get("FNumber").getAsString());
dto.setFName(obj.get("FITEMNAME").getAsString());
dto.setChilds(new ArrayList<>());
return dto;
});
JdChildDTO childDTO = new JdChildDTO();
childDTO.setPartdiagramCode(obj.get("F_HBYT_BJBM").getAsString());
childDTO.setPartdiagramName(obj.get("F_HBYT_BJMC").getAsString());
childDTO.setWareHouse(obj.get("FUNITID.FName").getAsString());
childDTO.setPartNumber(obj.get("FMATERIALIDCHILD.FNumber").getAsString());
childDTO.setName(obj.get("FCHILDITEMNAME").getAsString());
childDTO.setStats(obj.get("FCHILDITEMPROPERTY").getAsString());
childDTO.setQuantity(obj.get("FNUMERATOR").getAsDouble());
childDTO.setDenominator(obj.get("FDENOMINATOR").getAsDouble());
parentDTO.getChilds().add(childDTO);
}
return new ArrayList<>(bomMap.values());
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
/**
* 获取生产用料清单
*
* @param F_HBYT_SCLH
* @return
*/
public static List<MaterialUsageDTO2> getPRD_PPBOM(String F_HBYT_SCLH) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_PPBOM");
json.addProperty("FieldKeys",
"F_HBYT_SCLH,FMaterialID.FNumber,FMaterialName,FUnitID2.FName,FMaterialID2.FNumber,FMaterialName1,FNumerator,FDenominator,FMustQty,FPickedQty,F_HBYT_CZ,F_HBYT_DZ");
// 创建过滤条件
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "F_HBYT_SCLH");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", F_HBYT_SCLH);
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();
List<MaterialUsageDTO2> materialUsageDTO2List = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
materialUsageDTO2List = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<MaterialUsageDTO2>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return materialUsageDTO2List; // 返回结果
}
//用料清单查询接口腹肌无聊
public static List<JinYongDTO> getEngBom(String materialCode) {
List<JinYongDTO> jinYongDTOS = new ArrayList<>();
K3CloudApi client = new K3CloudApi();
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_BOM");
json.addProperty("FieldKeys", "FNumber");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMATERIALIDCHILD.FNumber");
filterObject.addProperty("Compare", "=");
filterObject.addProperty("Value", materialCode);
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
List<JinYongDTO> JinYongDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JinYongDTO>>() {
});
if (JinYongDTOList != null && !JinYongDTOList.isEmpty()) {
jinYongDTOS.addAll(JinYongDTOList);
}
} else {
log.warn("未找到与bom版本号 " + materialCode + " 相关的记录");
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return jinYongDTOS;
}
/**
* 获取固定工艺路线
*
* @param FMaterialCode
* @return
*/
public static List<ProcessRouteDTO> getRouteGuDing(String FMaterialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_Route");
json.addProperty("FieldKeys",
"FNumber,FOperNumber,FWorkCenterId.FName,FProcessId.FName,FOperDescription,FOptCtrlCodeId.FName,FActivity1Qty,FActivity1UnitID.FName");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMATERIALID.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", FMaterialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FForbidStatus");
filterObject1.addProperty("Compare", "105");
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(jsonArray.toString(), new TypeReference<List<ProcessRouteDTO>>() {
});
} else {
return Collections.emptyList();
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return Collections.emptyList();
}
/**
* 获取物料清单
*
* @param FMaterialCode
* @return
*/
public static List<MaterialUseDTO> getMaterialUseX(String FMaterialCode) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "ENG_BOM");
json.addProperty("FieldKeys", "FNumber,FMATERIALIDCHILD.FNumber,FCHILDITEMNAME,FCHILDUNITID.FName,FNUMERATOR,FDENOMINATOR,F_HBYT_DZ,F_HBYT_CZ");
JsonArray filterString = new JsonArray();
JsonObject filterObject = new JsonObject();
filterObject.addProperty("FieldName", "FMATERIALID.FNumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", FMaterialCode);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FForbidStatus");
filterObject1.addProperty("Compare", "105");
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
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();
try {
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray != null && jsonArray.size() > 0) {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(jsonArray.toString(), new TypeReference<List<MaterialUseDTO>>() {
});
} else {
return Collections.emptyList();
}
} catch (Exception e) {
log.error("调用接口时发生异常: " + e.getMessage(), e);
}
return Collections.emptyList();
}
/**
* 查询金蝶资产卡片
*
* @return
*/
public static List<JdKingdeeAssetCardVo> getKingdeeAssetCards() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "FA_CARD");
json.addProperty("FieldKeys", "FAlterID,FAssetTypeID.FName,FNumber,FUnitID.FName,FAssetNO,FPositionID.FName,FQuantity,FName,FManufacturer,FKEEPERID.FName,FModifyDate,FCreateDate");
// 创建过滤条件
JsonArray filterString = new JsonArray();
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
List<JdKingdeeAssetCardVo> promoList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
promoList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<JdKingdeeAssetCardVo>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return promoList; // 返回结果
}
public static List<PurchaseOrderExcelDTO> getPurchaseOrder() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_PurchaseOrder");
json.addProperty("FieldKeys", "FBillNo,FDate,FSupplierId.FName,FMaterialId.FNumber,FMaterialName,FQty,FDeliveryDate,F_UCHN_Text2,FCreateDate");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FCloseStatus");
filterObject.addProperty("Compare", "105");
filterObject.addProperty("Value", "A");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FMRPCloseStatus");
filterObject1.addProperty("Compare", "105");
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FDocumentStatus");
filterObject2.addProperty("Compare", "105");
filterObject2.addProperty("Value", "C");
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 0);
filterString.add(filterObject2);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
List<PurchaseOrderExcelDTO> purcs = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
purcs = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PurchaseOrderExcelDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return purcs; // 返回结果
}
/**
* 采购申请单
*/
public static List<PurchaseRequestExcelDTO> getPurchaseRequestOrder() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PUR_Requisition");
json.addProperty("FieldKeys", "FBillNo,FBillTypeID,FDocumentStatus,FCloseStatus,FSuggestPurDate,FSuggestSupplierId.FName,FMaterialId.FNumber,FMaterialName,FCreateDate,FPriceUnitId.FName,FReqQty,FArrivalDate,FApplicationDate,F_UCHN_Text,FCreatorId.FName");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FDocumentStatus");
filterObject.addProperty("Compare", "105");
filterObject.addProperty("Value", "C");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FCloseStatus");
filterObject1.addProperty("Compare", "105");
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
String jsonData = json.toString();
List<PurchaseRequestExcelDTO> purchaseRequestExcelDTOList = null;
try {
// 调用接口
String resultJson = String.valueOf(client.billQuery(jsonData));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
// 使用 ObjectMapper 将 JsonArray 转换为 List<PlannedProcessVo>
ObjectMapper objectMapper = new ObjectMapper();
purchaseRequestExcelDTOList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<PurchaseRequestExcelDTO>>() {
});
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return purchaseRequestExcelDTOList; // 返回结果
}
public static List<ConstructionDelayDTO> getConstructionDelay() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys", "F_HBYT_SCLH,FBillNo,FWorkShopID.FName,FMaterialId.FNumber,FMaterialName,FPlanStartDate,FPlanFinishDate,FPickMtrlStatus");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FStatus");
filterObject.addProperty("Compare", "105");
filterObject.addProperty("Value", "4");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FPickMtrlStatus");
filterObject1.addProperty("Compare", "29");
filterObject1.addProperty("Value", "1");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
List<ConstructionDelayDTO> constructionDelayDTOList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<ConstructionDelayDTO> pageList = objectMapper.readValue(
jsonArray.toString(), new TypeReference<List<ConstructionDelayDTO>>() {
});
constructionDelayDTOList.addAll(pageList);
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return constructionDelayDTOList; // 返回结果
}
public static List<PartCost> getObtainPartData() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_PickMtrl");
json.addProperty("FieldKeys", "FMaterialId.FNumber,FSpecification,FMaterialName,FPrice,FCreateDate,FEntryWorkShopId.FName,FUnitID.FName,FStockId.FName");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FDocumentStatus");
filterObject.addProperty("Compare", "105");
filterObject.addProperty("Value", "C");
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", 10000);
json.addProperty("SubSystemId", "");
List<PartCost> partCostBoList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<PartCost> pageList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<PartCost>>() {
});
partCostBoList.addAll(pageList);
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return partCostBoList; // 返回结果
}
/**
* 获取生产订单开工未领料数据
* 不包含暂停状态的项目
*/
public static List<ProductionOrderDTO> getProductionOrder() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "PRD_MO");
json.addProperty("FieldKeys", "F_HBYT_SCLH,FBillNo,FDocumentStatus,FMaterialId.FNumber,FMaterialName,F_UCHN_BaseProperty_qtr,FUnitId.FName,FWorkShopID.FName,FQty,FStatus,FPickMtrlStatus,FPlanStartDate,FPlanFinishDate");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FPickMtrlStatus");
filterObject.addProperty("Compare", "29");
filterObject.addProperty("Value", "1");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "F_HBYT_SCLH");
filterObject1.addProperty("Compare", "34");
filterObject1.addProperty("Value", "暂停");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 0);
filterString.add(filterObject1);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
List<ProductionOrderDTO> productionOrderDTOList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<ProductionOrderDTO> pageList = objectMapper.readValue(
jsonArray.toString(), new TypeReference<List<ProductionOrderDTO>>() {
});
productionOrderDTOList.addAll(pageList);
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return productionOrderDTOList; // 返回结果
}
/**
* 待转序查询,工序转移单非委外列表
* 不包含暂停状态的项目
*/
public static List<ProcessTransferFormDTO> getProcessTransferForm() {
//TOdo: 创建实体类
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "SFC_OperationTransfer");
json.addProperty("FieldKeys", "F_HBYT_SCLH,FProductId.FNumber,FBillNo,FMOBillNo,FDocumentStatus,FProductName,FOutDeptId.FName,FOutOperNumber,FOutProcessId.FName,FInDeptId.FName,FInOperNumber,FInProcessId.FName,FOperUnitId.FName,FOperTransferQty,FOperQualifiedQty,FOperProFailQty,FCreateDate");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FDocumentStatus");
filterObject.addProperty("Compare", "105");
filterObject.addProperty("Value", "B");
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 1);
filterString.add(filterObject);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FDocumentStatus");
filterObject2.addProperty("Compare", "105");
filterObject2.addProperty("Value", "A");
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 1);
filterString.add(filterObject2);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
List<ProcessTransferFormDTO> processTransferFormDTOList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<ProcessTransferFormDTO> pageList = objectMapper.readValue(
jsonArray.toString(), new TypeReference<List<ProcessTransferFormDTO>>() {
});
processTransferFormDTOList.addAll(pageList);
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return processTransferFormDTOList; // 返回结果
}
/**
* 质检检验单 ,数据用来判定是否质检
*/
public static List<InspectionSheetDTO> getQMInspectBill() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "SFC_OperationTransfer");
json.addProperty("FieldKeys", "F_UCHN_Text,FBillNo,FDocumentStatus,FMaterialId.FNumber,FMaterialName,FMaterialModel,FQCStatus,FInspectResult,FUnitID.FName,FInspectQty,FQualifiedQty,FUnqualifiedQty");
// 创建过滤条件
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
//质检转态计划1 质检开始2 质检状态3 FQCStatus
filterObject.addProperty("FieldName", "FQCStatus");
filterObject.addProperty("Compare", "29");
filterObject.addProperty("Value", "1");
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", 10000);
json.addProperty("SubSystemId", "");
List<InspectionSheetDTO> inspectionSheetDTOList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<InspectionSheetDTO> pageList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<InspectionSheetDTO>>() {
});
inspectionSheetDTOList.addAll(pageList);
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return inspectionSheetDTOList; // 返回结果
}
/**
* 工序汇报单 用来查询是否入库
* 判断条件是否入库点,合格数量和入库数量是否相同
*/
public static List<ProcessReportDTO> getProcessReport() {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "SFC_OperationReport");
json.addProperty("FieldKeys", "F_HBYT_SCLH,FBillNo,FMoNumber,FWorkShopID.FName,FOperNumber,FOperDescription,FQuaQty,FFinishQty,FStockInQuaAuxQty,FStockInFailAuxQty,F_HBYT_RKD,FDate");
// 是否为入库点
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "F_HBYT_RKD");
filterObject.addProperty("Compare", "74");
filterObject.addProperty("Value", true);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObject1 = new JsonObject();
filterObject1.addProperty("FieldName", "FDocumentStatus");
filterObject1.addProperty("Compare", "105");
filterObject1.addProperty("Value", "A");
filterObject1.addProperty("Left", "");
filterObject1.addProperty("Right", "");
filterObject1.addProperty("Logic", 1);
filterString.add(filterObject1);
JsonObject filterObject2 = new JsonObject();
filterObject2.addProperty("FieldName", "FDocumentStatus");
filterObject2.addProperty("Compare", "105");
filterObject2.addProperty("Value", "B");
filterObject2.addProperty("Left", "");
filterObject2.addProperty("Right", "");
filterObject2.addProperty("Logic", 1);
filterString.add(filterObject2);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
List<ProcessReportDTO> processReportDTOList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<ProcessReportDTO> pageList = objectMapper.readValue(jsonArray.toString(), new TypeReference<List<ProcessReportDTO>>() {
});
processReportDTOList.addAll(pageList);
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
return processReportDTOList; // 返回结果
}
/**
* 从金蝶获取质检看板数据
*/
public static List<ProcessInspectionDTO> getUninspectedData() {
List<ProcessInspectionDTO> kingdeeWorkCenterDataVos = new ArrayList<>();
try {
K3CloudApi client = new K3CloudApi();
// 调用金蝶接口
String execute = client.execute(
"Ljint.Kingdee.YiTe.KanBan.WebApi.QualityWebApi.ExecuteService,Ljint.Kingdee.YiTe.KanBan.WebApi",
new String[]{" "}
);
// 解析返回结果
JSONObject response = JSONObject.parseObject(execute);
if (response == null) {
log.error("金蝶接口返回为空!");
return Collections.emptyList();
}
if (!"true".equalsIgnoreCase(response.getString("IsSuccess"))) {
String errorMsg = response.getString("Message");
log.error("金蝶接口调用失败:{}", errorMsg);
return Collections.emptyList();
}
// 获取数据数组
JSONArray dataArray = response.getJSONArray("data");
if (dataArray == null || dataArray.isEmpty()) {
log.warn("金蝶接口返回的质检数据为空!");
return Collections.emptyList();
}
// 解析每个工段下的 QueryList
for (int i = 0; i < dataArray.size(); i++) {
JSONArray queryList = dataArray.getJSONObject(i).getJSONArray("QueryList");
if (queryList == null || queryList.isEmpty()) {
continue;
}
for (int j = 0; j < queryList.size(); j++) {
JSONObject item = queryList.getJSONObject(j);
if (item == null) continue;
// 转换为实体对象
ProcessInspectionDTO data = new ProcessInspectionDTO();
data.setMoBillNo(item.getString("MoBillNo"));
data.setMoOrderNo(item.getString("MoOrderNo"));
data.setSubOrderNo(item.getString("SubOrderNo"));
data.setFMaterialName(item.getString("FMaterialName"));
data.setFProcessName(item.getString("FProcessName"));
data.setFWorkCenterName(item.getString("FWorkCenterName"));
data.setFInspectStatus(item.getString("FInspectStatus"));
data.setFWaitInspectQty(item.getInteger("FWaitInspectQty"));
data.setFFinishInspectQty(item.getInteger("FFinishInspectQty"));
data.setFQuaQty(item.getInteger("FQuaQty"));
data.setFReworkQty(item.getInteger("FReworkQty"));
data.setFFailQty(item.getInteger("FFailQty"));
data.setFSubmitInspectTime(item.getString("FSubmitInspectTime"));
data.setFFinishInspectTime(item.getString("FFinishInspectTime"));
data.setFDescription(item.getString("FDescription"));
kingdeeWorkCenterDataVos.add(data);
}
}
} catch (Exception e) {
log.error("调用金蝶接口获取质检看板数据异常:{}", e.getMessage(), e);
return Collections.emptyList();
}
return kingdeeWorkCenterDataVos;
}
/**
* 工序汇报单 用来查询是否入库
* 判断条件是否入库点,合格数量和入库数量是否相同
*/
public static OperationPlannDTO getOperationPlann(String FBillNo) {
K3CloudApi client = new K3CloudApi();
// 请求参数要求为json字符串
JsonObject json = new JsonObject();
json.addProperty("FormId", "SFC_OperationPlanning");
json.addProperty("FieldKeys", "FOperNumber,FOperQty,FProcessId.FName");
// 是否为入库点
JsonObject filterObject = new JsonObject();
JsonArray filterString = new JsonArray();
filterObject.addProperty("FieldName", "FMONumber");
filterObject.addProperty("Compare", "67");
filterObject.addProperty("Value", FBillNo);
filterObject.addProperty("Left", "");
filterObject.addProperty("Right", "");
filterObject.addProperty("Logic", 0);
filterString.add(filterObject);
JsonObject filterObjec1t = new JsonObject();
filterObjec1t.addProperty("FieldName", "FOperStatus");
filterObjec1t.addProperty("Compare", "105");
filterObjec1t.addProperty("Value", "4");
filterObjec1t.addProperty("Left", "");
filterObjec1t.addProperty("Right", "");
filterObjec1t.addProperty("Logic", 0);
filterString.add(filterObjec1t);
json.add("FilterString", filterString);
json.addProperty("OrderString", "");
json.addProperty("TopRowCount", 0);
json.addProperty("StartRow", 0);
json.addProperty("Limit", 10000);
json.addProperty("SubSystemId", "");
List<OperationPlannDTO> processReportDTOList = new ArrayList<>();
int pageSize = 10000;
int startRow = 0;
ObjectMapper objectMapper = new ObjectMapper();
try {
while (true) {
JsonObject pageJson = new Gson().fromJson(json.toString(), JsonObject.class);
pageJson.addProperty("StartRow", startRow);
pageJson.addProperty("Limit", pageSize);
String resultJson = String.valueOf(client.billQuery(pageJson.toString()));
JsonArray jsonArray = new Gson().fromJson(resultJson, JsonArray.class);
if (jsonArray == null || jsonArray.size() == 0) {
break;
}
List<OperationPlannDTO> pageList = objectMapper.readValue(jsonArray.toString(),
new TypeReference<List<OperationPlannDTO>>() {
});
if (pageList != null && !pageList.isEmpty()) {
processReportDTOList.addAll(pageList);
}
if (jsonArray.size() < pageSize) {
break;
}
startRow += pageSize;
}
} catch (Exception e) {
e.printStackTrace(); // 输出异常日志
}
if (processReportDTOList.isEmpty()) {
return null;
}
// 选择工序号最小的作为代表项(通常为最后一道工序)
OperationPlannDTO best = null;
int bestOper = Integer.MAX_VALUE;
for (OperationPlannDTO dto : processReportDTOList) {
int oper = Integer.MAX_VALUE;
try {
String numStr = dto.getFOperNumber();
if (numStr != null) {
oper = Integer.parseInt(numStr.trim());
}
} catch (Exception ignore) {
oper = Integer.MAX_VALUE;
}
if (oper <= bestOper) {
bestOper = oper;
best = dto;
}
}
return best;
}
}