using RB_MES_API.Models.Cloud;
using System.Data;

namespace RB_MES_API.Controllers.Cloud
{
    /// <summary>
    /// 接收单据用到的子查询
    /// </summary>
    public interface IChiledSelect
    {
        /// <summary>
        /// 供应商基础资料
        /// </summary>
        /// <returns></returns>
        public Task<IList<BD_Supplier>> suppliersAsync(int fid);

        /// <summary>
        /// 物料基础资料
        /// </summary>
        /// <returns></returns>
        public Task<List<BD_Material>> materialsAsync(List<string> numbers);
        ///// <summary>
        ///// 查询采购订单源单信息
        ///// </summary>
        ///// <param name="datatable">传入的数据表</param>
        ///// <param name="fromtypeid">表r_CloudBillQuery的FFormIDTypeID</param>
        ///// <param name="reason"></param>
        ///// <returns></returns>
        //public List<PurchaseOrder> GetPurchaseOrder(DataTable datatable, int fromtypeid, ref string reason);
        /// <summary>
        /// 通过云星空API的查询接口查询源单信息
        /// </summary>
        /// <param name="datatable">接收到MES的数据，已转换为table</param>
        /// <param name="fromtypeid">子查询doctypeid</param>
        /// <param name="reason">如果有错误</param>
        /// <returns></returns>
        public List<T>? GetSourceBillEntry<T>(DataTable datatable, int fromtypeid, ref string reason) where T : class,new();
        /// <summary>
        /// 得到子查询的完整查询条件
        /// </summary>
        /// <param name="datatable">传入的数据表</param>
        /// <param name="optcode">传入的参数格式</param>
        /// <param name="filedstr">查询的参数格式</param>
        /// <returns></returns>
        public string GetChildFiledstr(DataTable datatable, string optcode, string filedstr);
        /// <summary>
        /// Cloud自定义SQL服务查询结果集，带字段名，无输入参数
        /// </summary>
        /// <param name="formtypeid"></param>
        /// <returns>返回的结果集JSON可转换为实体类和DataTable</returns>
        public Task<string> GetCustomRequestTBAsync(int formtypeid);
        /// <summary>
        ///  Cloud自定义SQL服务查询结果集，带字段名，带输入参数
        /// </summary>
        /// <param name="sql">CloudBillQuery的FieldKeys，提前写好SQL，必带WHERE</param>
        /// <param name="filestr">CloudBillQuery的FFiledString</param>
        /// <param name="ordstr">排序字段</param>
        /// <param name="inputdic">输入参数</param>
        /// <returns></returns>
        public Task<string> GetCustomRequestBillAsync(string sql, string filestr, string ordstr, Dictionary<string, object>? inputdic);
        /// <summary>
        /// CLOUD的API直接查询SQL结果集，带输入参数
        /// </summary>
        /// <param name="sql">CloudBillQuery的FieldKeys，提前写好SQL，必带WHERE</param>
        /// <param name="filestr">CloudBillQuery的FFiledString</param>
        /// <param name="ordstr">排序字段</param>
        /// <param name="inputdic">多行条件输入参数</param>
        /// <returns></returns>
        public Task<string> GetCustomRequestTableAsync(string sql, string filestr, string ordstr, List<Dictionary<string, object>> inputdic);
        /// <summary>
        /// 按表r_CustomServices中指定的方法执行SQL插件的方法(包含DataSet，Reader和Scalar、Execute)。
        /// 注意!!!本系统不提供源码校验，成败责任自负...
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public Task<string> GetCustomReaderAsync(string sql, string servicesstubname);
    }
}
