Forráskód Böngészése

配置项功能修改

HULEI 1 hónapja
szülő
commit
28842f0d76

+ 34 - 28
com.awspaas.user.apps.donenow_crm/src/com/awspaas/user/apps/donenow_crm/controller/accountController.java

@@ -437,16 +437,35 @@ public class accountController extends BaseController {
     @Mapping(value = "com.awspaas.user.apps.donenow_crm.getProductInfoByContractServiceId")
     public ResponseObject getProductInfoByContractServiceId(UserContext uc, String id) {
         try {
-            // 1. 根据传入的id查询BO_EU_DNCTT_CONTRACT_SERVICE表获取OBJECT_ID
-            String contractServiceSql = "SELECT OBJECT_ID " +
-                    "FROM BO_EU_DNCTT_CONTRACT_SERVICE " +
-                    "WHERE id = ?";
-            Map<String, Object> contractServiceInfo = DBSql.getMap(contractServiceSql, new Object[]{id});
+            // 1. 原有:查询订单产品关联表获取order_id,再查订单表获取VENDOR_ACCOUNT_ID
+            String orderProductSql = "SELECT order_id FROM BO_EU_DNIVT_ORDER_PRODUCT WHERE CONTRACT_SERVICE_ID = ?";
+            Map<String, Object> orderProductInfo = DBSql.getMap(orderProductSql, new Object[]{id});
+            String vendorAccountId = null;
+            if (orderProductInfo != null && orderProductInfo.get("order_id") != null) {
+                String orderId = orderProductInfo.get("order_id").toString();
+                String orderSql = "SELECT VENDOR_ACCOUNT_ID FROM BO_EU_DNIVT_ORDER WHERE id = ?";
+                Map<String, Object> orderInfo = DBSql.getMap(orderSql, new Object[]{orderId});
+                if (orderInfo != null && orderInfo.get("VENDOR_ACCOUNT_ID") != null) {
+                    vendorAccountId = orderInfo.get("VENDOR_ACCOUNT_ID").toString();
+                }
+            }
+
+            // 2. 新增:根据VENDOR_ACCOUNT_ID查询bo_eu_dncrm_account表获取name
+            String vendorAccountName = null;
+            if (vendorAccountId != null) { // 仅当有vendorAccountId时才查询
+                String accountSql = "SELECT NAME FROM bo_eu_dncrm_account WHERE id = ?";
+                Map<String, Object> accountInfo = DBSql.getMap(accountSql, new Object[]{vendorAccountId});
+                if (accountInfo != null && accountInfo.get("NAME") != null) {
+                    vendorAccountName = accountInfo.get("NAME").toString();
+                }
+            }
 
+            // 3. 原有:查询合同服务、服务、产品信息(保持不变)
+            String contractServiceSql = "SELECT OBJECT_ID FROM BO_EU_DNCTT_CONTRACT_SERVICE WHERE id = ?";
+            Map<String, Object> contractServiceInfo = DBSql.getMap(contractServiceSql, new Object[]{id});
             Map<String, Object> result = new HashMap<>();
 
             if (contractServiceInfo == null || contractServiceInfo.get("OBJECT_ID") == null) {
-                // 未查询到合同服务记录
                 result.put("contractServiceExists", false);
                 result.put("serviceExists", false);
                 result.put("productExists", false);
@@ -455,15 +474,10 @@ public class accountController extends BaseController {
             } else {
                 result.put("contractServiceExists", true);
                 String objectId = contractServiceInfo.get("OBJECT_ID").toString();
-
-                // 2. 根据OBJECT_ID查询BO_EU_DNIVT_SERVICE表获取PRODUCT_ID
-                String serviceSql = "SELECT PRODUCT_ID " +
-                        "FROM BO_EU_DNIVT_SERVICE " +
-                        "WHERE id = ?";
+                String serviceSql = "SELECT PRODUCT_ID FROM BO_EU_DNIVT_SERVICE WHERE id = ?";
                 Map<String, Object> serviceInfo = DBSql.getMap(serviceSql, new Object[]{objectId});
 
                 if (serviceInfo == null || serviceInfo.get("PRODUCT_ID") == null) {
-                    // 未查询到服务记录
                     result.put("serviceExists", false);
                     result.put("productExists", false);
                     result.put("productId", null);
@@ -471,27 +485,19 @@ public class accountController extends BaseController {
                 } else {
                     result.put("serviceExists", true);
                     String productId = serviceInfo.get("PRODUCT_ID").toString();
-
-                    // 3. 根据PRODUCT_ID查询bo_eu_dnivt_product表获取id和NAME
-                    String productSql = "SELECT id, NAME " +
-                            "FROM bo_eu_dnivt_product " +
-                            "WHERE id = ?";
+                    String productSql = "SELECT id, NAME FROM bo_eu_dnivt_product WHERE id = ?";
                     Map<String, Object> productInfo = DBSql.getMap(productSql, new Object[]{productId});
 
-                    if (productInfo == null) {
-                        // 未查询到产品记录
-                        result.put("productExists", false);
-                        result.put("productId", null);
-                        result.put("productName", null);
-                    } else {
-                        // 成功查询到产品信息
-                        result.put("productExists", true);
-                        result.put("productId", productInfo.get("id"));
-                        result.put("productName", productInfo.get("NAME"));
-                    }
+                    result.put("productExists", productInfo != null);
+                    result.put("productId", productInfo != null ? productInfo.get("id") : null);
+                    result.put("productName", productInfo != null ? productInfo.get("NAME") : null);
                 }
             }
 
+            // 4. 新增返回字段:vendorAccountId(原有)和 vendorAccountName(新增)
+            result.put("vendorAccountId", vendorAccountId);
+            result.put("vendorAccountName", vendorAccountName); // 账户名称
+
             ResponseObject responseObject = ResponseObject.newOkResponse();
             responseObject.setData(result);
             return responseObject;

+ 40 - 0
com.awspaas.user.apps.donenow_ctt/src/com/awspaas/user/apps/donenow_ctt/event/contractTest.java

@@ -0,0 +1,40 @@
+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 com.alibaba.fastjson.JSON;
+
+import java.util.Map;
+
+public class contractTest implements DataWindowFormatSQLEventInterface {
+    private static final Logger LOGGER = SDK.getLogAPI().getLogger(testcommission.class);
+
+    @Override
+    public String formatSQL(UserContext userContext, DataView dataView, String sql) {
+        try {
+            Map<String, Object> sqlParam = dataView.getDatagrid().getSqlParams();
+            LOGGER.info("【初始SQL】" + sql);
+            LOGGER.info("【查询参数】" + JSON.toJSONString(sqlParam));
+
+            String sql1 = " 1=1 ";
+
+            if (sqlParam.containsKey("ITEM_DATE") && sql.contains("a.ITEM_DATE")) {
+                sql1 += " AND UPPER(d.ITEM_DATE) like :ITEM_DATE ";
+                sql = sql.replace("AND UPPER(a.ITEM_DATE) like :ITEM_DATE", "");
+            }
+
+
+            sql = sql.replace("2 = 2", sql1);
+            LOGGER.info("【拼接后SQL】" + sql);
+
+        } catch (Exception e) {
+            LOGGER.error("SQL条件拼接失败", e);
+            e.printStackTrace();
+        }
+
+        return sql;
+    }
+}