zhangyao 2 mesi fa
parent
commit
812c2d9ca3

+ 43 - 0
com.awspaas.user.apps.donenow_ctt/src/com/awspaas/user/apps/donenow_ctt/event/DeductionPayDWFormatSQLEvent.java

@@ -0,0 +1,43 @@
+package com.awspaas.user.apps.donenow_ctt.event;
+
+import com.actionsoft.bpms.dw.design.event.DataWindowFormatSQLEventInterface;
+import com.actionsoft.bpms.dw.exec.component.DataView;
+import com.actionsoft.bpms.server.UserContext;
+import com.actionsoft.sdk.local.SDK;
+import com.actionsoft.sdk.local.api.Logger;
+
+import java.util.Map;
+
+public class DeductionPayDWFormatSQLEvent implements DataWindowFormatSQLEventInterface {
+    private static final Logger LOGGER = SDK.getLogAPI().getLogger(DeductionPayDWFormatSQLEvent.class);//记录
+
+    /**
+     * 格式化sql
+     * @param userContext
+     * @param dataView
+     * @param sql
+     * @return
+     */
+    @Override
+    public String formatSQL(UserContext userContext, DataView dataView, String sql) {
+
+        LOGGER.info("初始sql:" + sql);
+
+        try {
+            Map<String, Object> sqlParam = dataView.getDatagrid().getSqlParams();
+
+            LOGGER.info("sqlParam:" + sqlParam.toString());
+
+            if (sqlParam.containsKey("ID") && sqlParam.get("ID") != null) {
+                sql = sql.replace("UPPER(d.ID) = :ID", "FIND_IN_SET(ID,:ID)>0");
+                sql = sql.replace("d.ID = :ID", "FIND_IN_SET(ID,:ID)>0");
+            }
+
+        } catch (Exception ex) {
+            LOGGER.error("格式化sql异常:" + ex.getMessage());
+        }
+
+        LOGGER.info("格式化后的sql:" + sql);
+        return sql;
+    }
+}