using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using DirectService.Tools;
using JLHHJSvr.BLL;
using JLHHJSvr.Com;
using JLHHJSvr.Com.Model;
using JLHHJSvr.Helper;
using JLHHJSvr.LJException;
using JLHHJSvr.Tools;
using LJLib.DAL.SQL;
using LJLib.Net.SPI.Server;
using LJLib.SQLEX;

namespace JLHHJSvr.Excutor
{
    internal sealed class GetMattressPackagMxExcutor : ExcutorBase<GetMattressPackagMxRequest, GetMattressPackagMxResponse>
    {
        protected override void ExcuteInternal(GetMattressPackagMxRequest request, object state, GetMattressPackagMxResponse rslt)
        {
            var tokendata = BllHelper.GetToken(request.token);
            if (tokendata == null)
            {
                rslt.ErrMsg = "会话已经中断，请重新登录";
                return;
            }
            if (request.mattresstypeid == 0)
            {
                rslt.ErrMsg = "床垫类别不能为0";
                return;
            }

            using (var con = GlobalVar.ConnectionString.NewSqlConnection())
            using (var cmd = con.CreateCommand())
            {
                con.Open();

                var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
                var dw_2 = new List<u_mattress_mx_mtrl>();

                //   导入 2-按包装方式  的公式
                helper.wf_import_bz(request.packtype, ref dw_2);

                helper.wf_sort_mx(ref dw_2);
                helper.wf_default_mtrlid(request.pricelistid, ref dw_2);

                rslt.mattressMx = dw_2;

            }
        }
    }
}
