コード例 #1
0
        /// <summary>
        /// 从收货明细获取生成目标单据的数据源。
        /// </summary>
        /// <param name="ctx">上下文对象。</param>
        /// <param name="sql">SQL语句。</param>
        /// <param name="objectTypeId">单据类型。</param>
        /// <param name="billIds">单据主键。</param>
        /// <returns>返回查询的结果集。</returns>
        public GenTargetArgs[] GetGenTargetSource(Context ctx, GenTargetSourceSql sql, string objectTypeId, object[] billIds)
        {
            if (!billIds.Any())
            {
                return(new GenTargetArgs[0]);
            }

            var dbService = ServiceHelper.GetService <IDBService>();
            var sqlParams = new List <SqlParam>();

            sqlParams.Add(new SqlParam(sql.BillIdsParamName, KDDbType.udt_inttable, billIds.Distinct().ToArray()));
            var collection = dbService.ExecuteDynamicObject(ctx: ctx, strSQL: sql.SqlString, paramList: sqlParams.ToArray());

            var result = collection.GroupBy(g => new
            {
                ObjectTypeId  = objectTypeId,
                BillId        = g.Property <long>("FBILLID"),
                BillNo        = g.Property <string>("FBILLNO"),
                SourceFormId  = g.Property <string>("FSOURCEFORMID"),
                TargetFormId  = g.Property <string>("FTARGETFORMID"),
                ConvertRuleId = g.Property <string>("FCONVERTRULEID"),
                Date          = g.Property("FDATE", DateTime.Now).Date
            }).Select(g =>
            {
                var args           = new GenTargetArgs();
                args.ObjectTypeId  = g.Key.ObjectTypeId;
                args.BillId        = g.Key.BillId;
                args.BillNo        = g.Key.BillNo;
                args.SourceFormId  = g.Key.SourceFormId;
                args.TargetFormId  = g.Key.TargetFormId;
                args.ConvertRuleId = g.Key.ConvertRuleId;
                args.Date          = g.Key.Date;

                g.Select(b =>
                {
                    DataLinkSource row = new DataLinkSource(args);
                    row.SId            = b.Property <long>("FSID");
                    row.SBillId        = b.Property <long>("FSBILLID");
                    row.NoticeFormId   = b.Property <string>("FNOTICEFORMID");
                    row.Qty            = b.Property <long>("FQTY");
                    row.PHMXWgt        = b.Property <long>("FPHMXWgt");
                    row.Cty            = b.Property <long>("FCTY");
                    row.LotNo          = b.Property <string>("FLOTNO");
                    row.ProduceDate    = b.Property <object>("FPRODUCEDATE").Adaptive(date => date == null || date.Equals(default(DateTime)) ? default(DateTime?) : new DateTime?(date.ToType <DateTime>()));
                    row.ExpiryDate     = b.Property <object>("FEXPIRYDATE").Adaptive(date => date == null || date.Equals(default(DateTime)) ? default(DateTime?) : new DateTime?(date.ToType <DateTime>()));
                    return(row);
                }).ToList().Adaptive(lst => args.DataRows.AddRange(lst));

                return(args);
            }).ToArray();

            return(result);
        }//end method
コード例 #2
0
 /// <summary>
 /// 构造方法。
 /// </summary>
 /// <param name="rule">单据转换规则。</param>
 /// <param name="dataEntities">数据包。</param>
 /// <param name="argument">生成目标单据参数。</param>
 /// <param name="option">操作额外参数。</param>
 public BeforeUploadTargetDataEventArgs(ConvertRuleElement rule, DynamicObject[] dataEntities, GenTargetArgs argument, OperateOption option)
 {
     this.Rule         = rule;
     this.DataEntities = dataEntities;
     this.Argument     = argument;
     this.Option       = option;
 }