综合分析模块 “onlyWhereSql”: true, wheres

   "polymeric": {
      //控制第三方权限配置
      "presetSql": [
        //{
        //  "connName": "ConnCpc",
        //  "value": "",
        //  "name": ""
        //}
      ],
      // #region 数据二次处理插件
      //请求的结果处理
      //"njcResult": {
      //  "args": [],
      //  "moduleName": "~/Config/AppNodeJs/{ownerId}/plugins/{mkey}/{resField}",
      //  "functionName": null
      //},
      ////请求的参数设置
      //"njcArgs": {
      //  "args": [],
      //  "moduleName": "~/Config/AppNodeJs/{ownerId}/plugins/{mkey}/{resField}-query",
      //  "functionName": null
      //},
      // #endregion 数据二次处理插件
      "guidMethod": "None",
      //来源组合接口
      //"dataFromType": "Merge",
      "original": "",
      "auth": true,
      "isList": true,
      //开启只执行responseField里面配置
      //"onlySqlList": true,
      "selectSql": {
      },
      "show": "factory_id,product_num,defective_num,genuine_num,material_num,consume_num,poly_date",
      // cpc_product_task_user  user_type 0 未知 1 管理员 2 法人 3 员工 4 会计 5 财务 6 采购员 7 生产员 8 班组 9 厂长 10 仓管 11 供应商 12 客户 13 派单员 14 上报员 15 总部职员 16 总部领导
      // 只使用 wheres 里面组合语句
      "onlyWhereSql": true,
      "wheres": [
        "select factory_id,sum(product_num) product_num,sum(defective_num) defective_num,sum(genuine_num) genuine_num,sum(material_num) material_num,sum(consume_num) consume_num,max(start_date) poly_date from cpc_product_task",
        " {where_sql}",
        " is_enabled=1 and audit_status=1 and status in (1,2,3,4)",
        // #endregion 本月
        "{s-if:_mapperType}{op-eq:0} and start_date between @_currentMonthS and @_currentMonthE {op-eq:0}{e-if:_mapperType}",
        // #endregion 本月
        // #region 上个月
        "{s-if:_mapperType}{op-eq:1} and start_date between @_currentPrevMonthS and @_currentPrevMonthE {op-eq:1}{e-if:_mapperType}",
        // #endregion 上个月
        // #region 本周
        "{s-if:_mapperType}{op-eq:2} and start_date between @_currentWeekS and @_currentWeekE {op-eq:2}{e-if:_mapperType}",
        // #endregion 本周
        // #region 上一周
        "{s-if:_mapperType}{op-eq:3} and start_date between @_currentPrevWeekS and @_currentPrevWeekE {op-eq:3}{e-if:_mapperType}",
        // #endregion 上一周
        // #region 今年
        "{s-if:_mapperType}{op-eq:4} and start_date between @_currentYearS and @_currentYearE {op-eq:4}{e-if:_mapperType}",
        // #endregion 今年
        // #region 去年
        "{s-if:_mapperType}{op-eq:5} and start_date between @_currentPrevYearS and @_currentPrevYearE {op-eq:5}{e-if:_mapperType}",
        // #endregion 去年
        // #region 当日
        "{s-if:_mapperType}{op-eq:6} and start_date between @_currentDayS  and @_currentDayS {op-eq:6}{e-if:_mapperType}",
        // #endregion 当日
        // #region 昨日
        "{s-if:_mapperType}{op-eq:7} and start_date between @_currentPrevDayS and @_currentPrevDayE {op-eq:7}{e-if:_mapperType}",
        // #endregion 昨日
        // #region 工厂名称  产品工单号
        " and (",
        " product_no like concat('%',@pushName,'%')",
        " or",
        " factory_id in (select fact_id from cpc_ws_factory where is_enabled=1 and audit_status=1 and fact_name like concat('%',@pushName,'%'))",
        ")",
        " and product_task_id in (select product_task_id from cpc_product_task_user where ({{_whereSqlCpcFxyUserType}} {{_whereSqlCpcFxyRoleId}}) and is_enabled=1)",
        // #endregion 工厂名称  产品工单号
        " group by  factory_id  order by",
        // #region 正品数前20
        "{s-if:sortType0} consume_num desc {e-if:sortType0}",
        // #endregion 正品数前20
        // #region 次品数前20
        "{s-if:sortType1} defective_num desc {e-if:sortType1}",
        // #endregion 次品数前20
        // #region 消耗量前20
        "{s-if:sortType2} genuine_num desc {e-if:sortType2}",
        // #endregion 消耗量前20
        " limit 0,20"
      ]
    }

\Services\DbSqlService$ResSql.cs


 case RequestModuleType.Detail:
                    SetUsedSqlDetail(pfGloal, sqlConfig, dictionaryUrl);
                    //公共的sql语句
                    if (sqlConfig.ResponseFieldTemp.OnlyWhereSql == true)
                    {
                        sqlConfig.SelectSql.Detail = String.Join("", sqlConfig.ResponseFieldTemp.Wheres);
                    }
                    if (sqlConfig.TemplateUsedSql != null && sqlConfig.TemplateUsedSql.Count > 0)
                    {
                        sbSql.Append(sqlConfig.SelectSql.Detail);
                        foreach (var item in sqlConfig.TemplateUsedSql)
                        {
                            sbSql.Replace("{" + item.Key + "}", item.Value.Sql);
                        }
                        sqlConfig.SelectSql.Detail = sbSql.ToString();
                    }
                    break;
                case RequestModuleType.List:
                    if (sqlConfig.ResponseFieldTemp.OnlyWhereSql == true)
                    {
                        SetUsedSqlList(pfGloal, sqlConfig, dictionaryUrl);
                        sqlConfig.SelectSql.List = String.Join("", sqlConfig.ResponseFieldTemp.Wheres);
                    }
                    else if (sqlConfig.ResponseFieldTemp.IsList == true || isList == true)
                    {
                        SetUsedSqlList(pfGloal, sqlConfig, dictionaryUrl);
                    }
                    else
                    {
                        SetUsedSqlPage(pfGloal, sqlConfig, dictionaryUrl);
                        sqlConfig.SelectSql.List = sqlConfig.SelectSql.Page;
                    }
                    //公共的sql语句
                    if (sqlConfig.TemplateUsedSql != null && sqlConfig.TemplateUsedSql.Count > 0)
                    {
                        sbSql.Append(sqlConfig.SelectSql.List);
                        foreach (var item in sqlConfig.TemplateUsedSql)
                        {
                            sbSql.Replace("{" + item.Key + "}", item.Value.Sql);
                        }
                        sqlConfig.SelectSql.List = sbSql.ToString();
                    }
                    break;
                case RequestModuleType.Page:
                    SetUsedSqlPage(pfGloal, sqlConfig, dictionaryUrl);
                    if (sqlConfig.ResponseFieldTemp.OnlyWhereSql == true)
                    {
                        sqlConfig.SelectSql.Page = String.Join("", sqlConfig.ResponseFieldTemp.Wheres);
                    }
                    //公共的sql语句
                    if (sqlConfig.TemplateUsedSql != null && sqlConfig.TemplateUsedSql.Count > 0)
                    {
                        sbSql.Append(sqlConfig.SelectSql.Page);
                        sbSqlCount.Append(sqlConfig.SelectSql.Count);
                        foreach (var item in sqlConfig.TemplateUsedSql)
                        {
                            sbSql.Replace("{" + item.Key + "}", item.Value.Sql);
                        }
                        foreach (var item in sqlConfig.TemplateUsedSql)
                        {
                            sbSqlCount.Replace("{" + item.Key + "}", item.Value.Sql);
                        }
                        sqlConfig.SelectSql.Count = sbSqlCount.ToString();
                        sqlConfig.SelectSql.Page = sbSql.ToString();
                    }
                    break;
文档更新时间: 2022-07-15 13:54   作者:admin