From a39332f6a19f9ff2a688a47dc9d509ea1f185053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=8E?= Date: Mon, 12 May 2025 13:37:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(ic):=20=E4=BC=98=E5=8C=96=20subcontractRec?= =?UTF-8?q?eipt=20=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 .project 文件中添加过滤资源配置,优化项目结构 - 在 QuerySync 类中添加 queryMaterial 方法,支持查询物料信息 - 重构 SubcontractReceiptResource 类中的查询逻辑: - 优化参数提取和处理,不再强制验证必填项 - 改进分页参数处理,设为必传项 - 调整查询条件生成逻辑,适应新的参数处理方式 --- .../SubcontractReceiptResource.java | 145 ++++++++++-------- .../public/nccloud/api/uapbd/QuerySync.java | 9 ++ 2 files changed, 88 insertions(+), 66 deletions(-) diff --git a/ic/src/public/nccloud/openapi/ic/subcontractReceipt/SubcontractReceiptResource.java b/ic/src/public/nccloud/openapi/ic/subcontractReceipt/SubcontractReceiptResource.java index 79f2b2c..d87f870 100644 --- a/ic/src/public/nccloud/openapi/ic/subcontractReceipt/SubcontractReceiptResource.java +++ b/ic/src/public/nccloud/openapi/ic/subcontractReceipt/SubcontractReceiptResource.java @@ -55,33 +55,39 @@ public class SubcontractReceiptResource extends AbstractNCCRestResource { if (jObject == null) { return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); } - JSONObject bject = jObject.getJSONObject("ufinterface"); - if (bject == null) { + JSONObject ufinterface = jObject.getJSONObject("ufinterface"); + if (ufinterface == null) { return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); } - // ҳ - JSONObject pageInfo = bject.getJSONObject("pageInfo"); + // ҳΪش + JSONObject pageInfo = ufinterface.getJSONObject("pageInfo"); + if (pageInfo == null) { + return ResultMessageUtil.exceptionToJSON(new BusinessException("ҳϢ(pageInfo)Ϊ")); + } + OpenApiPageInfo openApiPageInfo = new OpenApiPageInfo(); - int pageIndex = 1, pageSize = 20; - if (pageInfo != null) { - pageIndex = pageInfo.getIntValue("pageIndex") > 0 ? pageInfo.getIntValue("pageIndex") : 1; - pageSize = pageInfo.getIntValue("pageSize") > 0 ? pageInfo.getIntValue("pageSize") : 20; - openApiPageInfo.setPageIndex(pageIndex); - openApiPageInfo.setPageSize(pageSize); - } + int pageIndex = pageInfo.getIntValue("pageIndex") > 0 ? pageInfo.getIntValue("pageIndex") : 1; + int pageSize = pageInfo.getIntValue("pageSize") > 0 ? pageInfo.getIntValue("pageSize") : 20; + openApiPageInfo.setPageIndex(pageIndex); + openApiPageInfo.setPageSize(pageSize); - // ȡѯ - Map param = extractAndValidateParams(jObject); + // ȡѯǿ֤ + Map param = new HashMap<>(); + boolean hasConditions = extractParams(ufinterface, param); - // ʹApiResourceParamUtilsɲѯ - ApiResourceParamUtils apiUtils = new ApiResourceParamUtils(); - String condition = apiUtils.parseParmToSql(new SubcontInHeadVO(), param, ApiResourceParamUtils.BYCODE); - if (condition.endsWith("and ")) { - condition = condition.substring(0, condition.length() - 4); - } - if (condition.trim().isEmpty()) { - condition = "1=1"; + // ѯѯȫ + String condition = "1=1"; + if (hasConditions) { + // ʹApiResourceParamUtilsɲѯ + ApiResourceParamUtils apiUtils = new ApiResourceParamUtils(); + condition = apiUtils.parseParmToSql(new SubcontInHeadVO(), param, ApiResourceParamUtils.BYCODE); + if (condition.endsWith("and ")) { + condition = condition.substring(0, condition.length() - 4); + } + if (condition.trim().isEmpty()) { + condition = "1=1"; + } } // ѯз @@ -131,63 +137,70 @@ public class SubcontractReceiptResource extends AbstractNCCRestResource { } /** - * ȡ֤ + * ȡǿ֤ * - * @param jObject JSON - * @return Map - * @throws BusinessException Уʧʱ׳쳣 + * @param ufinterface JSON + * @param param ҪIJMap + * @return Ƿвѯ */ - private Map extractAndValidateParams(JSONObject jObject) throws BusinessException { - Map param = new HashMap<>(); - jObject = (JSONObject) jObject.get("ufinterface"); + private boolean extractParams(JSONObject ufinterface, Map param) { + boolean hasConditions = false; + // ȡ - String pk_group = jObject.getString("pk_group"); - String name = jObject.getString("name"); - String code = jObject.getString("code"); - String createdate = jObject.getString("createdate"); - String ncindustry = jObject.getString("ncindustry"); - String pk_currtype = jObject.getString("pk_currtype"); - String pk_exratescheme = jObject.getString("pk_exratescheme"); - String vbillcode = jObject.getString("vbillcode"); - String pk_org = jObject.getString("pk_org"); - String dbilldate = jObject.getString("dbilldate"); + String pk_group = ufinterface.getString("pk_group"); + String name = ufinterface.getString("name"); + String code = ufinterface.getString("code"); + String createdate = ufinterface.getString("createdate"); + String ncindustry = ufinterface.getString("ncindustry"); + String pk_currtype = ufinterface.getString("pk_currtype"); + String pk_exratescheme = ufinterface.getString("pk_exratescheme"); + String vbillcode = ufinterface.getString("vbillcode"); + String pk_org = ufinterface.getString("pk_org"); + String dbilldate = ufinterface.getString("dbilldate"); - // ֶУ - if (pk_group == null || pk_group.trim().isEmpty()) { - throw new BusinessException("(pk_group)Ϊ"); + // ӵMap - ֻӷǿղ + if (pk_group != null && !pk_group.trim().isEmpty()) { + param.put("pk_group", pk_group); + hasConditions = true; } - if (name == null || name.trim().isEmpty()) { - throw new BusinessException("(name)Ϊ"); + if (name != null && !name.trim().isEmpty()) { + param.put("name", name); + hasConditions = true; } - if (code == null || code.trim().isEmpty()) { - throw new BusinessException("(code)Ϊ"); + if (code != null && !code.trim().isEmpty()) { + param.put("code", code); + hasConditions = true; } - if (createdate == null || createdate.trim().isEmpty()) { - throw new BusinessException("ʱ(createdate)Ϊ"); + if (createdate != null && !createdate.trim().isEmpty()) { + param.put("createdate", createdate); + hasConditions = true; } - if (ncindustry == null || ncindustry.trim().isEmpty()) { - throw new BusinessException("UAPҵ(ncindustry)Ϊ"); + if (ncindustry != null && !ncindustry.trim().isEmpty()) { + param.put("ncindustry", ncindustry); + hasConditions = true; } - if (pk_currtype == null || pk_currtype.trim().isEmpty()) { - throw new BusinessException("λ(pk_currtype)Ϊ"); + if (pk_currtype != null && !pk_currtype.trim().isEmpty()) { + param.put("pk_currtype", pk_currtype); + hasConditions = true; } - if (pk_exratescheme == null || pk_exratescheme.trim().isEmpty()) { - throw new BusinessException("һʷ(pk_exratescheme)Ϊ"); + if (pk_exratescheme != null && !pk_exratescheme.trim().isEmpty()) { + param.put("pk_exratescheme", pk_exratescheme); + hasConditions = true; + } + if (vbillcode != null && !vbillcode.trim().isEmpty()) { + param.put("vbillcode", vbillcode); + hasConditions = true; + } + if (pk_org != null && !pk_org.trim().isEmpty()) { + param.put("pk_org", pk_org); + hasConditions = true; + } + if (dbilldate != null && !dbilldate.trim().isEmpty()) { + param.put("dbilldate", dbilldate); + hasConditions = true; } - // ӵMap - param.put("pk_group", pk_group); - param.put("name", name); - param.put("code", code); - param.put("createdate", createdate); - param.put("ncindustry", ncindustry); - param.put("pk_currtype", pk_currtype); - param.put("pk_exratescheme", pk_exratescheme); - if (vbillcode != null) param.put("vbillcode", vbillcode); - if (pk_org != null) param.put("pk_org", pk_org); - if (dbilldate != null) param.put("dbilldate", dbilldate); - - return param; + return hasConditions; } @Override diff --git a/uapbd/src/public/nccloud/api/uapbd/QuerySync.java b/uapbd/src/public/nccloud/api/uapbd/QuerySync.java index 43cff15..34d270b 100644 --- a/uapbd/src/public/nccloud/api/uapbd/QuerySync.java +++ b/uapbd/src/public/nccloud/api/uapbd/QuerySync.java @@ -39,6 +39,8 @@ public class QuerySync extends AbstractNCCRestResource { switch (type) { case "queryStordoc": return queryStordoc(ufinterface); + case "queryMaterial": + return queryMaterial(ufinterface); default: return ResultMessageUtil.exceptionToJSON(new Exception("ֵ֧Ľӿ: " + type)); } @@ -56,4 +58,11 @@ public class QuerySync extends AbstractNCCRestResource { return null; } + /** + * ѯϢ + */ + private JSONString queryMaterial(ApiUfinterface apiUfinterface) { + + return null; + } } \ No newline at end of file