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

业务后台:1、修复床网报价计算偏差问题
2、修复床垫报价垫层生成错乱问题
3、优化计算错误提示信息

chen_yjin 5 hónapja
szülő
commit
83cfbcbd84

+ 37 - 0
JLHHJSvr/Com/GetMattressImportDW2.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.Com.Model;
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    public sealed class GetMattressImportDW2Request : ILJRequest<GetMattressImportDW2Response>
+    {
+        public string GetApiName()
+        {
+            return "GetMattressImportDW2";
+        }
+        public string token { get; set; }
+        public int mattresstypeid { get; set; }
+        /// <summary>
+        /// 是否为半成品
+        /// </summary>
+        public int ifbcptype { get; set; }
+        /// <summary>
+        /// 包装方式   tinyint   选择 0-压包,1-卷包,2-国内
+        /// </summary>
+        public int packtype { get; set; }
+    }
+
+    public sealed class GetMattressImportDW2Response : LJResponse
+    {
+        public decimal? biandai_qty { get; set; }
+        /// <summary>
+        /// 所有明细
+        /// </summary>
+        public List<u_mattress_mx_mtrl> mattressMx { get; set; }
+        public List<replacement> diancengarea { get; set; }
+}
+}

+ 15 - 0
JLHHJSvr/Com/Model/u_mattress_mx_mtrl.cs

@@ -21,6 +21,9 @@ namespace JLHHJSvr.Com.Model
         public decimal? qty { get; set; }
         public decimal? costamt { get; set; }
         public int? if_15strip { get; set; }
+        /// <summary>
+        /// 是否异常,1:异常,0:正常
+        /// </summary>
         public int? if_success { get; set; }
         public decimal? shrinkage { get; set; }
         public string replace_formula { get; set; }
@@ -45,6 +48,18 @@ namespace JLHHJSvr.Com.Model
         public string sortcode { get; set; }
         public string mtrlname { get; set; }
         public int? copty_mtrlid { get; set; }
+        /// <summary>
+        /// 计算错误信息
+        /// </summary>
+        public string message { get; set; }
+        public string addmx { get; set; }
+        public string delmx { get; set; }
+        /// <summary>
+        /// 按物料(无物料,单物料,多物料)
+        /// </summary>
+        public int? if_mtrl { get; set; }
+
+
         #endregion
     }
 }

+ 2 - 0
JLHHJSvr/Com/SaveMattress.cs

@@ -30,6 +30,8 @@ namespace JLHHJSvr.Com
     public sealed class SaveMattressResponse : LJResponse
     {
         public int mattressid { get; set; }
+        public string mattresscode { get; set; }
         public string message { get; set; }
+        public List<string> mxmessage { get; set; }
     }
 }

+ 3 - 1
JLHHJSvr/DataStore/web_bednet_choose.xml

@@ -12,9 +12,11 @@
 		u_bednet.createtime,
 		u_bednet.bednetname,
 		u_bednet.nottax_factory_cost,
-		u_bednet_type.typename
+		u_bednet_type.typename,
+		u_bednetmx.bednet_height
 		from u_bednet
 		inner join u_bednet_type ON u_bednet_type.bednettypeid = u_bednet.bednettypeid
+		left outer join u_bednetmx ON u_bednetmx.bednetid = u_bednet.bednetid
 	</selectstr>
 	<where>
 		<when notnull="@arg_deptid">

+ 507 - 0
JLHHJSvr/Excutor/GetMattressImportDW2Excutor.cs

@@ -0,0 +1,507 @@
+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;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class GetMattressImportDW2Excutor : ExcutorBase<GetMattressImportDW2Request, GetMattressImportDW2Response>
+    {
+        protected override void ExcuteInternal(GetMattressImportDW2Request request, object state, GetMattressImportDW2Response rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+            if (request.mattresstypeid == 0)
+            {
+                rslt.ErrMsg = "床垫类别不能为0";
+                return;
+            }
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                // 初始化属性
+                //foreach (var mx in request.mattressMx)
+                //{
+                //    AutoInit.AutoInitS(cmd, mx);
+                //}
+
+                using (cmd.Transaction = con.BeginTransaction())
+                {
+
+                    var mattersstype = new u_mattress_type() { mattresstypeid = request.mattresstypeid };
+                    DbSqlHelper.SelectOne(cmd, mattersstype, "biandaiqty, if_top_side, if_button_sdie, if_big_side, if_small_side, if_v_side, if_in_cloth_cover, if_out_cloth_cover, if_small_side2, if_small_side3, if_v_side2, if_v_side3, dianceng_sort, dianceng_area");
+                    rslt.biandai_qty = mattersstype.biandaiqty;
+
+                    AutoInit.AutoInitS(cmd, mattersstype);
+
+                    var selectStr = @"
+                            SELECT formulaid
+	                            ,formulakind
+	                            ,formulatype
+	                            ,sortcode
+	                            ,if_mtrl
+	                            ,formula
+	                            ,usetype
+	                            ,if_packtype0
+	                            ,if_packtype1
+	                            ,if_packtype2
+	                            ,default_mtrlid
+	                            ,createtime
+	                            ,createby
+	                            ,useformula
+	                            ,gydscrp
+	                            ,mtrltype
+                            FROM u_mattress_formula";
+                    var outFields = "formulaid, formulakind, formulatype, sortcode, if_mtrl, formula, usetype, if_packtype0, if_packtype1, if_packtype2, default_mtrlid, createtime, createby, useformula, gydscrp, mtrltype";
+                    var whereList = new List<string>();
+                    whereList.Add("u_mattress_formula.formulatype IN (0, 1, 2, 3, 99, 104)");
+                    whereList.Add("u_mattress_formula.usetype = @usetype");
+                    var param = new Dictionary<string, object>();
+
+
+                    //   导入 0-通用类型  的公式
+                    param.Add("@usetype", 0);
+                    var mattressFormulaList0 = new List<u_mattress_formula>();
+                    DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), param, "formulatype, sortcode", outFields, 0, 0, mattressFormulaList0);
+
+                    var dw_2 = new List<u_mattress_mx_mtrl>();
+
+                    foreach (var mx in mattressFormulaList0)
+                    {
+                        if (new[] { 11, 12, 32, 33, 13, 14, 29, 999, 1201 }.Contains(mx.formulakind.Value)) continue;
+
+                        var newDw2 = new u_mattress_mx_mtrl();
+                        AutoInit.AutoInitS(newDw2);
+                        if (mx.if_mtrl > 1)
+                        {
+                            newDw2.addmx = "+";
+                            newDw2.delmx = "-";
+                        }
+                        newDw2.formulatype = mx.formulatype;
+                        newDw2.if_mtrl = mx.if_mtrl;
+                        newDw2.formulaid = mx.formulaid;
+                        newDw2.sortcode = mx.sortcode;
+                        newDw2.formulakind = mx.formulakind;
+                        newDw2.formula = mx.formula;
+                        newDw2.useformula = mx.useformula;
+                        newDw2.gydscrp = mx.gydscrp;
+
+                        dw_2.Add(newDw2);
+                    }
+
+                    //   导入 1-按床垫类别  的公式
+                    var mattressFormulaList1 = new List<u_mattress_formula>();
+                    param.Clear();
+                    param.Add("@usetype", 1);
+                    DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), param, "formulatype, sortcode", outFields, 0, 0, mattressFormulaList1);
+
+                    foreach (var mx in mattressFormulaList1)
+                    {
+                        var ls_chastr = "";
+
+                        if (request.ifbcptype == 1)
+                        {
+                            if (new[] { 0, 40, 50, 60, 70, 80, 1, 41, 51, 61, 71, 81, 2, 42, 52, 62, 72, 82, 3, 43, 53, 63, 73, 83, 4, 44, 54, 64, 74, 84 }.Contains(mx.formulakind.Value))
+                            {
+                                continue;
+                            }
+                        }
+
+                        if (new[] { 0, 40, 50, 60, 70, 80 }.Contains(mx.formulakind.Value))
+                        {
+                            ls_chastr = "面裥绵";
+                            if (mattersstype.if_top_side == 0) continue;
+                        }
+
+                        if (new[] { 1, 41, 51, 61, 71, 81 }.Contains(mx.formulakind.Value))
+                        {
+                            ls_chastr = "底裥绵";
+                            if (mattersstype.if_button_sdie == 0) continue;
+                        }
+
+                        if (new[] { 2, 42, 52, 62, 72, 82 }.Contains(mx.formulakind.Value))
+                        {
+                            ls_chastr = "普通大侧";
+                            if (mattersstype.if_big_side == 0) continue;
+                        }
+
+                        if (new[] { 3, 43, 53, 63, 73, 83 }.Contains(mx.formulakind.Value))
+                        {
+                            ls_chastr = "小侧1";
+                            if (mattersstype.if_small_side == 0) continue;
+                        }
+
+                        if (new[] { 4, 44, 54, 64, 74, 84 }.Contains(mx.formulakind.Value))
+                        {
+                            ls_chastr = "V侧1";
+                            if (mattersstype.if_v_side == 0) continue;
+                        }
+
+                        if (new[] { 101, 102, 103, 104, 105, 106 }.Contains(mx.formulakind.Value))
+                        {
+                            if (mattersstype.if_in_cloth_cover == 0) continue;
+                        }
+
+                        if (new[] { 111, 112, 113, 114, 115, 116 }.Contains(mx.formulakind.Value))
+                        {
+                            if (mattersstype.if_out_cloth_cover == 0) continue;
+                        }
+
+                        var newDw2 = new u_mattress_mx_mtrl();
+                        AutoInit.AutoInitS(newDw2);
+                        if (mx.if_mtrl > 1)
+                        {
+                            newDw2.addmx = "+";
+                            newDw2.delmx = "-";
+                        }
+                        newDw2.formulatype = mx.formulatype;
+                        newDw2.if_mtrl = mx.if_mtrl;
+                        newDw2.formulaid = mx.formulaid;
+                        newDw2.sortcode = mx.sortcode;
+                        newDw2.formulakind = mx.formulakind;
+                        newDw2.formula = mx.formula;
+                        newDw2.chastr = ls_chastr;
+                        newDw2.useformula = mx.useformula;
+                        newDw2.gydscrp = mx.gydscrp;
+
+                        dw_2.Add(newDw2);
+                    }
+
+
+                    //   导入 2-按包装方式  的公式
+                    var mattressFormulaList2 = new List<u_mattress_formula>();
+                    param.Clear();
+                    param.Add("@usetype", 2);
+                    DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), param, "formulatype, sortcode", outFields, 0, 0, mattressFormulaList2);
+
+                    foreach (var mx in mattressFormulaList2)
+                    {
+                        if (request.packtype == 0 && mx.if_packtype0 != 1) continue;
+                        if (request.packtype == 1 && mx.if_packtype1 != 1) continue;
+                        if (request.packtype == 2 && mx.if_packtype2 != 1) continue;
+
+                        var newDw2 = new u_mattress_mx_mtrl();
+                        AutoInit.AutoInitS(newDw2);
+                        if (mx.if_mtrl > 1)
+                        {
+                            newDw2.addmx = "+";
+                            newDw2.delmx = "-";
+                        }
+                        newDw2.formulatype = mx.formulatype;
+                        newDw2.if_mtrl = mx.if_mtrl;
+                        newDw2.formulaid = mx.formulaid;
+                        newDw2.sortcode = mx.sortcode;
+                        newDw2.formulakind = mx.formulakind;
+                        newDw2.formula = mx.formula;
+                        newDw2.useformula = mx.useformula;
+                        newDw2.gydscrp = mx.gydscrp;
+
+                        dw_2.Add(newDw2);
+                    }
+
+
+                    //加多一个 小侧2
+                    if (mattersstype.if_small_side2 == 1 && request.ifbcptype == 0)
+                    {
+                        wf_add_side(cmd, new[] { 3, 83, 43, 53, 63, 73 }, "小侧2", ref dw_2);
+                    }
+                    //加多一个 小侧3
+                    if (mattersstype.if_small_side3 == 1 && request.ifbcptype == 0)
+                    {
+                        wf_add_side(cmd, new[] { 3, 83, 43, 53, 63, 73 }, "小侧3", ref dw_2);
+                    }
+                    //加多一个 V侧2
+                    if (mattersstype.if_v_side2 == 1 && request.ifbcptype == 0)
+                    {
+                        wf_add_side(cmd, new[] { 4, 84, 44, 54, 64, 74 }, "V侧2", ref dw_2);
+                    }
+                    //加多一个 V侧3
+                    if (mattersstype.if_v_side3 == 1 && request.ifbcptype == 0)
+                    {
+                        wf_add_side(cmd, new[] { 4, 84, 44, 54, 64, 74 }, "V侧3", ref dw_2);
+                    }
+
+                    // 在 床垫类型 定义里面   按垫层默认配置  自动带出 垫层配置  和  垫层可选项
+                    if (!string.IsNullOrEmpty(mattersstype.dianceng_sort))
+                    {
+                        wf_add_dianceng_bytype(cmd, mattersstype.dianceng_sort, ref dw_2);
+                    }
+
+                    rslt.diancengarea = new List<replacement>();
+                    if (!string.IsNullOrEmpty(mattersstype.dianceng_area))
+                    {
+                        rslt.diancengarea = wf_add_dianceng_area_bytype(cmd, mattersstype.dianceng_area);
+                    }
+
+                    // u_mattress_formula_formulatype A xu A u_mattress_formula_sortcode A u_mattress_mx_mtrl_formulaid A
+                    dw_2.Sort((a, b) =>
+                    {
+                        if (a.formulatype != b.formulatype)
+                        {
+                            return a.formulatype.Value.CompareTo(b.formulatype.Value);
+                        }
+                        if (a.xu != b.xu)
+                        {
+                            return a.xu.Value.CompareTo(b.xu.Value);
+                        }
+                        if (a.sortcode != b.sortcode)
+                        {
+                            return a.sortcode.CompareTo(b.sortcode);
+                        }
+                        return a.formulaid.Value.CompareTo(b.formulaid.Value);
+                    });
+
+
+                    rslt.mattressMx = dw_2;
+
+                }
+            }
+        }
+
+        private void wf_add_side(SqlCommand cmd, int[] formulakindList, string arg_name, ref List<u_mattress_mx_mtrl> dw_2)
+        {
+            foreach(int ll_formulakind in formulakindList)
+            {
+                cmd.CommandText = @"SELECT TOP 1
+	                                    formulatype,
+	                                    formulaid,
+	                                    sortcode,
+	                                    formula,
+	                                    if_mtrl,
+	                                    useformula,
+	                                    gydscrp
+                                    FROM u_mattress_formula
+                                    WHERE formulakind = @formulakind
+	                                    AND u_mattress_formula.formulatype in (0,1,2,3)";
+                cmd.Parameters.Clear();
+                cmd.Parameters.AddWithValue("@formulakind", ll_formulakind);
+                using (var reader = cmd.ExecuteReader())
+                {
+                    if (reader.Read())
+                    {
+                        var newDw2 = new u_mattress_mx_mtrl();
+                        AutoInit.AutoInitS(newDw2);
+                        if (Convert.ToInt32(reader["if_mtrl"]) > 1)
+                        {
+                            newDw2.addmx = "+";
+                            newDw2.delmx = "-";
+                        }
+                        newDw2.formulatype = Convert.ToInt32(reader["formulatype"]);
+                        newDw2.if_mtrl = Convert.ToInt32(reader["if_mtrl"]);
+                        newDw2.formulaid = Convert.ToInt32(reader["formulaid"]);
+                        newDw2.sortcode = arg_name;
+                        newDw2.formulakind = ll_formulakind;
+                        newDw2.formula = Convert.ToString(reader["formula"]);
+                        newDw2.chastr = arg_name;
+                        newDw2.useformula = Convert.ToString(reader["useformula"]);
+                        newDw2.gydscrp = Convert.ToString(reader["gydscrp"]);
+
+                        dw_2.Add(newDw2);
+                    }
+                }
+            }
+
+        }
+        private void wf_add_dianceng_bytype(SqlCommand cmd, string dianceng_sort, ref List<u_mattress_mx_mtrl> dw_2)
+        {
+            var arg_dianceng_sort = dianceng_sort.Replace(",", " , ");
+            arg_dianceng_sort = arg_dianceng_sort.Replace("~r~n", "");
+            arg_dianceng_sort = arg_dianceng_sort.Replace("~r", "");
+            arg_dianceng_sort = arg_dianceng_sort.Replace("~n", "");
+
+            //var ls_pzsplitstr_arr = f_pb_split(arg_dianceng_sort, "/");
+            var ls_pzsplitstr_arr = arg_dianceng_sort.Split('/');
+            string arg_left_str, arg_right_str;
+            int ll_formulakind;
+            int index = 0;
+
+            foreach (var ls_pzsplitstr in ls_pzsplitstr_arr)
+            {
+                index++;
+                arg_left_str = "";
+                arg_right_str = "";
+
+                wf_get_str(ls_pzsplitstr, ref arg_left_str, ref arg_right_str);
+
+                switch(arg_left_str)
+                {
+                    case "垫层":
+                        ll_formulakind = 32;
+                        break;
+                    case "床网":
+                        ll_formulakind = 999;
+                        break;
+                    case "顶布":
+                        ll_formulakind = 12;
+                        break;
+                    case "毡类":
+                        ll_formulakind = 13;
+                        break;
+                    case "打底无纺布":
+                        ll_formulakind = 14;
+                        break;
+                    case "网面布料":
+                        ll_formulakind = 29;
+                        break;
+                    default:
+                        ll_formulakind = -1;
+                        break;
+                }
+
+                if (ll_formulakind == -1) continue;
+
+                cmd.CommandText = @"SELECT TOP 1
+	                                    formulatype,
+	                                    formulaid,
+	                                    sortcode,
+	                                    formula,
+	                                    if_mtrl,
+	                                    useformula,
+	                                    gydscrp
+                                    FROM u_mattress_formula
+                                    WHERE formulakind = @formulakind
+	                                    AND u_mattress_formula.formulatype in (0,1,2,3)";
+                cmd.Parameters.Clear();
+                cmd.Parameters.AddWithValue("@formulakind", ll_formulakind);
+                using (var reader = cmd.ExecuteReader())
+                {
+                    if (reader.Read())
+                    {
+                        var newDw2 = new u_mattress_mx_mtrl();
+                        AutoInit.AutoInitS(newDw2);
+                        if (Convert.ToInt32(reader["if_mtrl"]) > 1)
+                        {
+                            newDw2.addmx = "+";
+                            newDw2.delmx = "-";
+                        }
+                        newDw2.formulatype = Convert.ToInt32(reader["formulatype"]);
+                        newDw2.if_mtrl = 2;
+                        newDw2.formulaid = Convert.ToInt32(reader["formulaid"]);
+                        newDw2.sortcode = Convert.ToString(reader["sortcode"]);
+                        newDw2.formulakind = ll_formulakind;
+                        newDw2.formula = Convert.ToString(reader["formula"]);
+                        newDw2.chastr = wf_set_area_text(arg_right_str);
+                        newDw2.qty = 1;
+                        newDw2.xu = index;
+                        newDw2.useformula = Convert.ToString(reader["useformula"]);
+                        newDw2.gydscrp = Convert.ToString(reader["gydscrp"]);
+
+                        dw_2.Add(newDw2);
+                    }
+                }
+
+            }
+        }
+        private void wf_get_str(string arg_source, ref string arg_left_str, ref string arg_right_str)
+        {
+            if (string.IsNullOrEmpty(arg_source)) return;
+
+            int commaPosition = arg_source.IndexOf(',');
+
+            if (commaPosition > 0)
+            {
+                arg_left_str = arg_source.Substring(0, commaPosition).Trim();
+                arg_right_str = arg_source.Substring(commaPosition + 1).Trim();
+            }
+            else
+            {
+                arg_left_str = arg_source.Trim();
+                arg_right_str = "";
+            }
+        }
+
+        private string wf_set_area_text(string arg_str)
+        {
+            string ls_rtn = "";
+
+            // V侧1
+            // V侧2
+            // V侧3
+            // 小侧1
+            // 小侧2
+            // 小侧3
+            // 大侧
+
+            if (arg_str.IndexOf("大侧") >= 0)
+            {
+                ls_rtn = "大侧";
+            }
+            else if (arg_str.IndexOf("小侧1") >= 0)
+            {
+                ls_rtn = "小侧1";
+            }
+            else if (arg_str.IndexOf("小侧2") >= 0)
+            {
+                ls_rtn = "小侧2";
+            }
+            else if (arg_str.IndexOf("小侧3") >= 0)
+            {
+                ls_rtn = "小侧3";
+            }
+            else if (arg_str.IndexOf("V侧1") >= 0)
+            {
+                ls_rtn = "V侧1";
+            }
+            else if (arg_str.IndexOf("V侧2") >= 0)
+            {
+                ls_rtn = "V侧2";
+            }
+            else if (arg_str.IndexOf("V侧3") >= 0)
+            {
+                ls_rtn = "V侧3";
+            }
+            else
+            {
+                ls_rtn = "";
+            }
+
+            return ls_rtn;
+        }
+        private List<replacement> wf_add_dianceng_area_bytype(SqlCommand cmd, string dianceng_area)
+        {
+            string ls_dianceng_area = dianceng_area;
+            var diancengarea = new List<replacement>();
+
+            // 替换中文逗号和其他特殊字符
+            ls_dianceng_area = ls_dianceng_area.Replace(',', ',');
+            ls_dianceng_area = ls_dianceng_area.Replace("\r\n", "");
+            ls_dianceng_area = ls_dianceng_area.Replace("\r", "");
+            ls_dianceng_area = ls_dianceng_area.Replace("\n", "");
+
+            // 分割字符串
+            //string[] ls_pzsplitstr_arr = f_pb_split(ls_dianceng_area, "/");
+            var ls_pzsplitstr_arr = ls_dianceng_area.Split('/');
+
+            for (int ll_i = 0; ll_i < ls_pzsplitstr_arr.Length; ll_i++)
+            {
+                string trimmedStr = ls_pzsplitstr_arr[ll_i].Trim();
+                if (string.IsNullOrEmpty(trimmedStr)) continue;
+
+                var child = new replacement()
+                {
+                    label = wf_set_area_text(trimmedStr.Trim()),
+                    value = wf_set_area_text(trimmedStr.Trim())
+                };
+                diancengarea.Add(child);
+            }
+            return diancengarea;
+        }
+    }
+}

+ 11 - 0
JLHHJSvr/Excutor/SaveMattressExcutor.cs

@@ -69,6 +69,16 @@ namespace JLHHJSvr.Excutor
                         rslt.message = e.Message;
                     }
 
+                    var mxmessageList = request.mattressMx.Where(item => !string.IsNullOrEmpty(item.message)).ToList();
+                    if (mxmessageList.Any())
+                    {
+                        rslt.mxmessage = new List<string>();
+                        foreach (var mx in mxmessageList)
+                        {
+                            rslt.mxmessage.Add(mx.message);
+                        }
+                    }
+
                     try
                     {
                         helper.SaveMattress(request.mattress, request.mattressMx);
@@ -81,6 +91,7 @@ namespace JLHHJSvr.Excutor
                         cmd.Transaction.Commit();
 
                         rslt.mattressid = request.mattress.mattressid;
+                        rslt.mattresscode = request.mattress.mattresscode;
                     }
                     catch (Exception e)
                     {

+ 1 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -153,6 +153,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("DeleteConfigureCode", typeof(DeleteConfigureCodeRequest), new DeleteConfigureCodeExcutor());// 删除部件选配项
                 excutorManager.AddMap("SaveConfigureCodeMx", typeof(SaveConfigureCodeMxRequest), new SaveConfigureCodeMxExcutor());// 保存部件选配项值
                 excutorManager.AddMap("DeleteConfigureCodeMx", typeof(DeleteConfigureCodeMxRequest), new DeleteConfigureCodeMxExcutor());// 删除部件选配项值
+                excutorManager.AddMap("GetMattressImportDW2", typeof(GetMattressImportDW2Request), new GetMattressImportDW2Excutor());// 下拉选择床垫类别
                 excutorManager.AddMap("SaveMattress", typeof(SaveMattressRequest), new SaveMattressExcutor());// 保存床垫报价
                 excutorManager.AddMap("SaveMattressAuditing", typeof(SaveMattressAuditingRequest), new SaveMattressAuditingExcutor());// 床垫报价:业务下单/取消
                 excutorManager.AddMap("DelMattress", typeof(DelMattressRequest), new DelMattressExcutor());// 床垫报价:删除

+ 2 - 1
JLHHJSvr/Helper/BedNetHelper.cs

@@ -1146,7 +1146,8 @@ namespace JLHHJSvr.Helper
                 spring.center_diameter = _spring.center_diameter == null ? 0 : _spring.center_diameter;
 
                 decimal fabrics = (decimal)((mx.bednet_height.Value + _spring.center_diameter.Value + 2) * (_spring.center_diameter.Value * (decimal)3.14 + 1)) / 10000;
-                AddKeyValue("入袋无纺布方数", fabrics);
+                string fabrics_str = fabrics.ToString("###0.#####");
+                AddKeyValue("入袋无纺布方数", fabrics_str);
 
                 decimal fabrics_price = getMtrlPrice(2, bednet.pricelistid.Value, mx.fabrics1_mtrlid.Value);
                 if (fabrics_price > 0) AddKeyValue("无纺布单价", fabrics_price);

+ 79 - 22
JLHHJSvr/Helper/MattressHelper.cs

@@ -142,13 +142,22 @@ namespace JLHHJSvr.Helper
                 expression = expression.Replace("@@", "");
                 mx.replace_formula = expression;
 
-                if (sqlCal)
+                try
                 {
-                    mx.costamt = Convert.ToDecimal(SqlCalculate(expression, "成本金额"));
+                    if (sqlCal)
+                    {
+                        mx.costamt = Convert.ToDecimal(SqlCalculate(expression, "成本金额"));
+                    }
+                    else
+                    {
+                        mx.costamt = Calculate(expression, "成本金额").DecimalValue;
+                    }
+                    mx.if_success = 0;
                 }
-                else
+                catch (Exception e)
                 {
-                    mx.costamt = Calculate(expression, "成本金额").DecimalValue;
+                    mx.if_success = 1;
+                    mx.message = e.Message;
                 }
                 #endregion
 
@@ -157,13 +166,21 @@ namespace JLHHJSvr.Helper
                 use_expression = use_expression.Replace("@@", "");
                 mx.replace_useformula = use_expression;
 
-                if (sqlCal)
+                try
                 {
-                    mx.useqty = Convert.ToDecimal(SqlCalculate(use_expression, "清单用量"));
+                    if (sqlCal)
+                    {
+                        mx.useqty = Convert.ToDecimal(SqlCalculate(use_expression, "清单用量"));
+                    }
+                    else
+                    {
+                        mx.useqty = Calculate(use_expression, "清单用量").DecimalValue;
+                    }
                 }
-                else
+                catch (Exception e)
                 {
-                    mx.useqty = Calculate(use_expression, "清单用量").DecimalValue;
+                    mx.if_success = 1;
+                    mx.message = e.Message;
                 }
                 #endregion
             }
@@ -434,10 +451,10 @@ namespace JLHHJSvr.Helper
         {
             mx.mtrlname = !string.IsNullOrEmpty(mx.mtrlname) ? mx.mtrlname.Trim() : "null";
 
-            mx.shrinkage = mx.shrinkage == 0 ? 1 : mx.shrinkage;
+            decimal _shrinkage = mx.shrinkage.Value == 0 ? (decimal)1 : mx.shrinkage.Value;
 
             //取mtrldef.name的前两位
-            AddKeyValue("名称前2位", mx.mtrlname.Substring(0, 2));
+            AddKeyValue("名称前2位", mx.mtrlname.Length > 2 ? mx.mtrlname.Substring(0, 2) : mx.mtrlname);
             AddKeyValue("物料单价", mx.price);
             AddKeyValue("物料克重", mx.gram_weight);
             AddKeyValue("幅宽", mx.cloth_width);
@@ -447,7 +464,7 @@ namespace JLHHJSvr.Helper
             AddKeyValue("厚度", mx.thickness);
             AddKeyValue("按面积单价", mx.if_areaprice);
             AddKeyValue("物料名称", mx.mtrlname);
-            AddKeyValue("物料收缩率", mx.shrinkage);
+            if (_shrinkage > 0) AddKeyValue("物料收缩率", _shrinkage);
         }
         /// <summary>
         /// 添加大侧,小侧,V侧高度公式替换
@@ -636,7 +653,7 @@ namespace JLHHJSvr.Helper
                         mattress.loading_type = "卷包(进箱)";
                         fob_expression = "【地区FOB费用】/(【柜型立方数】 / (( 【纸箱宽】  /100+0.03)*(【纸箱宽】/100+0.03)*(【规格宽】/ 100 +0.1)))";
                         cubage_expression = "( 【纸箱宽】  /100+0.03)*(【纸箱宽】/100+0.03)*(【规格宽】/ 100 +0.1)";
-                        AddKeyValue("【纸箱宽】", bz.mtrlname.Substring(0, 2));
+                        AddKeyValue("【纸箱宽】", bz.mtrlname.Length > 2 ? bz.mtrlname.Substring(0, 2) : bz.mtrlname);
                         break; 
                     }
                 }
@@ -764,6 +781,24 @@ namespace JLHHJSvr.Helper
             AddKeyValue("总材料成本", mattress.total_material_cost);
             #endregion
 
+            #region 标准金额
+            // 查找点数
+            decimal _rate = GetWorkmanshipRate(mattress, "num_10", "标准");
+            _rate = _rate == 0 ? 1 : _rate;
+
+            mattress.foreign_cost_bz = mattress.dept_cost / _rate;
+            AddKeyValue("标准金额", mattress.foreign_cost_bz);
+            #endregion
+
+            #region 大单金额
+            // 查找点数
+            decimal _rate2 = GetWorkmanshipRate(mattress, "num_11", "大单");
+            _rate2 = _rate2 == 0 ? 1 : _rate2;
+
+            mattress.foreign_cost_dd = mattress.dept_cost / _rate2;
+            AddKeyValue("大单金额", mattress.foreign_cost_dd);
+            #endregion
+
             CalCulateCostNew(mattress, "标准");
             CalCulateCostNew(mattress, "大单");
             CalCulateCostNew(mattress, "散单");
@@ -845,7 +880,7 @@ namespace JLHHJSvr.Helper
             string field = pinceCnt > 3 || (hasBigSide && (pinceCnt == 2 || pinceCnt == 3)) ? "num_3" : hasBigSide ? "num_1" : pinceCnt == 2 || pinceCnt == 3 ? "num_2" : string.Empty;
 
             // 查找点数
-            mattress.profitrate_point = GetWorkmanshipRate(mattress, field);
+            mattress.profitrate_point = GetWorkmanshipRate(mattress, field, "工艺点数");
             AddKeyValue("工艺点数", mattress.profitrate_point);
         }
         /// <summary>
@@ -881,7 +916,7 @@ namespace JLHHJSvr.Helper
 
                 // 查找点数
                 //var workmanship = new u_workmanship_add() { deptid = mattress.deptid, mattresstypeid = mattress.mattresstypeid, workmanshipname = field };
-                mattress.butao_point = GetWorkmanshipRate(mattress, field);
+                mattress.butao_point = GetWorkmanshipRate(mattress, field, "内布套点数");
             }
             AddKeyValue("内布套点数", mattress.butao_point);
         }
@@ -902,7 +937,7 @@ namespace JLHHJSvr.Helper
             string field = cnt == 1 ? "num_6" : (cnt > 1 ? "num_7" : "");
 
             // 查找点数
-            mattress.chaizhuang_point = GetWorkmanshipRate(mattress, field);
+            mattress.chaizhuang_point = GetWorkmanshipRate(mattress, field, "拆装点数");
             AddKeyValue("拆装点数", mattress.chaizhuang_point);
         }
         /// <summary>
@@ -917,7 +952,7 @@ namespace JLHHJSvr.Helper
                 string field = "num_8";
 
                 // 查找点数
-                mattress.haimian_point = GetWorkmanshipRate(mattress, field);
+                mattress.haimian_point = GetWorkmanshipRate(mattress, field, "海绵扣点");
             }
             AddKeyValue("海绵扣点", mattress.haimian_point);
         }
@@ -925,23 +960,45 @@ namespace JLHHJSvr.Helper
         /// 获取工厂利润率
         /// </summary>
         /// <param name="mattress"></param>
-        /// <param name="field"></param>
+        /// <param name="field">旧表字段名</paramD>
+        /// <param name="label">新表变量名</paramD>
         /// <returns></returns>
-        public decimal GetWorkmanshipRate(u_mattress mattress, string field)
+        public decimal GetWorkmanshipRate(u_mattress mattress, string field, string label)
         {
             decimal rate = 0;
             if (field == "") return 0;
-            //cmd.CommandText = @"SELECT rate FROM u_workmanship_add WHERE deptid = @deptid AND  mattresstypeid = @mattresstypeid AND  workmanshipname = @workmanshipname";
-            cmd.CommandText = @"SELECT " + field + " FROM u_workmanship_dianshu WHERE deptid = @deptid AND  mattresstypeid = @mattresstypeid";
+
+            cmd.CommandText = @"SELECT formula, rate FROM u_workmanship_add WHERE deptid = @deptid AND  mattresstypeid = @mattresstypeid AND  workmanshipname = @workmanshipname";
             cmd.Parameters.Clear();
             cmd.Parameters.AddWithValue("@deptid", mattress.deptid);
             cmd.Parameters.AddWithValue("@mattresstypeid", mattress.mattresstypeid);
-            //cmd.Parameters.AddWithValue("@workmanshipname", field);
+            cmd.Parameters.AddWithValue("@workmanshipname", label);
             using (var reader = cmd.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     rate = reader[field] == null ? 0 : Convert.ToDecimal(reader[field]);
+
+                    var _formula = Convert.ToString(reader["formula"]);
+                    if (!string.IsNullOrEmpty(_formula))
+                    {
+                        AddKeyValue(label, rate);
+                        rate = Calculate(mattress.hrcost_replace_formula, label).DecimalValue;
+                    }
+                }
+            }
+            if (rate == 0)
+            {
+                cmd.CommandText = @"SELECT " + field + " FROM u_workmanship_dianshu WHERE deptid = @deptid AND  mattresstypeid = @mattresstypeid";
+                cmd.Parameters.Clear();
+                cmd.Parameters.AddWithValue("@deptid", mattress.deptid);
+                cmd.Parameters.AddWithValue("@mattresstypeid", mattress.mattresstypeid);
+                using (var reader = cmd.ExecuteReader())
+                {
+                    if (reader.Read())
+                    {
+                        rate = reader[field] == null ? 0 : Convert.ToDecimal(reader[field]);
+                    }
                 }
             }
             return rate;
@@ -957,7 +1014,7 @@ namespace JLHHJSvr.Helper
             string field = "散单".Equals(typename) ? "num_9" : "标准".Equals(typename) ? "num_10" : "大单".Equals(typename) ? "num_11" : "";
 
             // 查找点数
-            decimal _rate = GetWorkmanshipRate(mattress, field);
+            decimal _rate = GetWorkmanshipRate(mattress, field, typename);
             mattress.dannum_rate = _rate == 0 ? 1 : _rate;
             AddKeyValue("大小单", mattress.dannum_rate);
         }

+ 2 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -100,6 +100,7 @@
     <Compile Include="Com\GetBedNetVarList.cs" />
     <Compile Include="Com\GetBillList.cs" />
     <Compile Include="Com\GetCarList.cs" />
+    <Compile Include="Com\GetMattressImportDW2.cs" />
     <Compile Include="Com\GetComputeMattress.cs" />
     <Compile Include="Com\GetComputeBednet.cs" />
     <Compile Include="Com\GetDept.cs" />
@@ -251,6 +252,7 @@
     <Compile Include="Excutor\GetBedNetVarListExcutor.cs" />
     <Compile Include="Excutor\GetBillListExcutor.cs" />
     <Compile Include="Excutor\GetCarListExcutor.cs" />
+    <Compile Include="Excutor\GetMattressImportDW2Excutor.cs" />
     <Compile Include="Excutor\GetComputeMattressExcutor.cs" />
     <Compile Include="Excutor\GetComputeBednetExcutor.cs" />
     <Compile Include="Excutor\GetDeptExcutor.cs" />