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 要填充的参数Map + * @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