feat(ic): 优化 subcontractReceipt 查询接口并添加新功能
- 在 .project 文件中添加过滤资源配置,优化项目结构 - 在 QuerySync 类中添加 queryMaterial 方法,支持查询物料信息 - 重构 SubcontractReceiptResource 类中的查询逻辑: - 优化参数提取和处理,不再强制验证必填项 - 改进分页参数处理,设为必传项 - 调整查询条件生成逻辑,适应新的参数处理方式
This commit is contained in:
parent
a4631eacee
commit
a39332f6a1
|
@ -55,34 +55,40 @@ 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");
|
||||
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);
|
||||
// 处理分页参数,设为必传
|
||||
JSONObject pageInfo = ufinterface.getJSONObject("pageInfo");
|
||||
if (pageInfo == null) {
|
||||
return ResultMessageUtil.exceptionToJSON(new BusinessException("分页信息(pageInfo)为必填项"));
|
||||
}
|
||||
|
||||
// 提取查询参数
|
||||
Map<String, Object> param = extractAndValidateParams(jObject);
|
||||
OpenApiPageInfo openApiPageInfo = new OpenApiPageInfo();
|
||||
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<String, Object> param = new HashMap<>();
|
||||
boolean hasConditions = extractParams(ufinterface, param);
|
||||
|
||||
// 查询条件:若无条件则查询全部
|
||||
String condition = "1=1";
|
||||
if (hasConditions) {
|
||||
// 使用ApiResourceParamUtils生成查询条件
|
||||
ApiResourceParamUtils apiUtils = new ApiResourceParamUtils();
|
||||
String condition = apiUtils.parseParmToSql(new SubcontInHeadVO(), param, ApiResourceParamUtils.BYCODE);
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
// 查询所有符合条件的主键
|
||||
if (baseDAO == null) {
|
||||
|
@ -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<String, Object> extractAndValidateParams(JSONObject jObject) throws BusinessException {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
jObject = (JSONObject) jObject.get("ufinterface");
|
||||
private boolean extractParams(JSONObject ufinterface, Map<String, Object> 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)为必填项");
|
||||
}
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
throw new BusinessException("名称(name)为必填项");
|
||||
}
|
||||
if (code == null || code.trim().isEmpty()) {
|
||||
throw new BusinessException("编码(code)为必填项");
|
||||
}
|
||||
if (createdate == null || createdate.trim().isEmpty()) {
|
||||
throw new BusinessException("成立时间(createdate)为必填项");
|
||||
}
|
||||
if (ncindustry == null || ncindustry.trim().isEmpty()) {
|
||||
throw new BusinessException("所属UAP行业(ncindustry)为必填项");
|
||||
}
|
||||
if (pk_currtype == null || pk_currtype.trim().isEmpty()) {
|
||||
throw new BusinessException("本位币(pk_currtype)为必填项");
|
||||
}
|
||||
if (pk_exratescheme == null || pk_exratescheme.trim().isEmpty()) {
|
||||
throw new BusinessException("外币汇率方案(pk_exratescheme)为必填项");
|
||||
}
|
||||
|
||||
// 添加到参数Map
|
||||
// 添加到参数Map - 只添加非空参数
|
||||
if (pk_group != null && !pk_group.trim().isEmpty()) {
|
||||
param.put("pk_group", pk_group);
|
||||
hasConditions = true;
|
||||
}
|
||||
if (name != null && !name.trim().isEmpty()) {
|
||||
param.put("name", name);
|
||||
hasConditions = true;
|
||||
}
|
||||
if (code != null && !code.trim().isEmpty()) {
|
||||
param.put("code", code);
|
||||
hasConditions = true;
|
||||
}
|
||||
if (createdate != null && !createdate.trim().isEmpty()) {
|
||||
param.put("createdate", createdate);
|
||||
hasConditions = true;
|
||||
}
|
||||
if (ncindustry != null && !ncindustry.trim().isEmpty()) {
|
||||
param.put("ncindustry", ncindustry);
|
||||
hasConditions = true;
|
||||
}
|
||||
if (pk_currtype != null && !pk_currtype.trim().isEmpty()) {
|
||||
param.put("pk_currtype", pk_currtype);
|
||||
hasConditions = true;
|
||||
}
|
||||
if (pk_exratescheme != null && !pk_exratescheme.trim().isEmpty()) {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
return param;
|
||||
return hasConditions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue