refactor(uapbd): 重构 QuerySync 类

- 优化 baseQuery 方法,提高代码复用性
- 新增 processExtraParams 方法
This commit is contained in:
张明 2025-05-13 14:28:31 +08:00
parent 2130d2dbf7
commit 265f42953f
1 changed files with 47 additions and 40 deletions

View File

@ -37,6 +37,8 @@ public class QuerySync extends AbstractNCCRestResource {
private JSONString baseQuery(ApiUfinterface apiUfinterface, String viewName, String pkColumnName) throws DAOException {
Map<String, Object> data = apiUfinterface.getData().getParamdata();
// 处理特殊字段
processExtraParams(data);
JSONObject pageInfo = (JSONObject) JSONObject.toJSON(apiUfinterface.getPageInfo());
data.remove("type"); // 移除类型参数因为它仅用于路由,向下传递会影响查询
@ -109,29 +111,10 @@ public class QuerySync extends AbstractNCCRestResource {
}
}
private JSONString queryCustomer(ApiUfinterface ufinterface) throws DAOException {
return baseQuery(ufinterface, "V_UAPBD_QUERYSYNC_CUSTOMER", "pk_customer");
}
private JSONString queryDept(ApiUfinterface apiUfinterface) throws DAOException {
return baseQuery(apiUfinterface, "V_UAPBD_QUERYSYNC_DEPT", "pk_defdoc");
}
private JSONString queryStordoc(ApiUfinterface apiUfinterface) throws DAOException {
return baseQuery(apiUfinterface, "V_UAPBD_QUERYSYNC_STORDOC", "pk_stordoc");
}
private JSONString querySupplier(ApiUfinterface ufinterface) throws DAOException {
return baseQuery(ufinterface, "V_UAPBD_QUERYSYNC_SUPPLIER", "pk_supplier");
}
/**
* ²éѯÎïÁÏÐÅÏ¢
* 处理类似TS的特殊字段
*/
private JSONString queryMaterial(ApiUfinterface ufinterface) throws DAOException {
Map<String, Object> data = ufinterface.getData().getParamdata();
private static void processExtraParams(Map<String, Object> data) {
// 处理ts参数
if (data.containsKey("ts")) {
Object tsObj = data.get("ts");
@ -155,7 +138,7 @@ public class QuerySync extends AbstractNCCRestResource {
if (tsCondition != null) {
// 检查是否已有其他extraCondition
String existingExtraCondition = data.containsKey("extraCondition") ?
(String) data.get("extraCondition") : "";
(String) data.get("extraCondition") : "";
if (existingExtraCondition.isEmpty()) {
data.put("extraCondition", tsCondition);
@ -167,10 +150,34 @@ public class QuerySync extends AbstractNCCRestResource {
// 从参数中移除ts避免它被直接用于查询条件
data.remove("ts");
}
}
private JSONString queryCustomer(ApiUfinterface ufinterface) throws DAOException {
return baseQuery(ufinterface, "V_UAPBD_QUERYSYNC_CUSTOMER", "pk_customer");
}
private JSONString queryDept(ApiUfinterface apiUfinterface) throws DAOException {
return baseQuery(apiUfinterface, "V_UAPBD_QUERYSYNC_DEPT", "pk_defdoc");
}
private JSONString queryStordoc(ApiUfinterface apiUfinterface) throws DAOException {
return baseQuery(apiUfinterface, "V_UAPBD_QUERYSYNC_STORDOC", "pk_stordoc");
}
private JSONString querySupplier(ApiUfinterface ufinterface) throws DAOException {
return baseQuery(ufinterface, "V_UAPBD_QUERYSYNC_SUPPLIER", "pk_supplier");
}
/**
* 查询物料信息
*/
private JSONString queryMaterial(ApiUfinterface ufinterface) throws DAOException {
Map<String, Object> data = ufinterface.getData().getParamdata();
return baseQuery(ufinterface, "V_UAPBD_QUERYSYNC_MATERIAL", "pk_material");
}
/**
* 查询BOM维护信息
*/