Parcourir la source

核价后台:1、修复床网报价,四周加硬、四周口袋的弹簧单价读取错误; 2、床垫清单,当配置类型为0时,读取默认值并获取相应配置明细

chen_yjin il y a 11 heures
Parent
commit
02ef8e3710
2 fichiers modifiés avec 51 ajouts et 53 suppressions
  1. 50 52
      JLHHJSvr/Helper/BedNetHelper.cs
  2. 1 1
      JLHHJSvr/Helper/InterfaceHelper.cs

+ 50 - 52
JLHHJSvr/Helper/BedNetHelper.cs

@@ -286,7 +286,9 @@ namespace JLHHJSvr.Helper
                 {
                     bednet.snake_wire_mtrl_cost_replace_formula = bednet.snake_wire_mtrl_formula;
 
-                    CalSnakeCol(bednet,spring);
+                    #region 替换蛇线单价  snake_wire_diameter
+                    GetSpringPrice(bednet.pricelistid.Value, "蛇线单价", 0, bednet.snake_wire_diameter.Value);
+                    #endregion
 
                     var rp_formula = "";
                     bednet.snake_wire_mtrl_cost += Calculate(bednet.snake_wire_mtrl_cost_replace_formula, out rp_formula, "蛇线材料成本").DecimalValue;
@@ -301,6 +303,20 @@ namespace JLHHJSvr.Helper
                 {
                     mx.pocket_around_spring_cost_replace_formula = bednet.pocket_around_spring_formula;
 
+                    #region wf_cmp_pocket_around_dw2 口袋弹簧单价
+                    var springPocket = GetSpringPrice(bednet.pricelistid.Value, "口袋弹簧单价", mx.pocket_around_springid);
+
+                    if (springPocket.height > 0)
+                    {
+                        AddKeyValue("口袋弹簧高度", springPocket.height);
+                    }
+
+                    if (springPocket.center_diameter > 0)
+                    {
+                        AddKeyValue("口袋弹簧心径", springPocket.center_diameter);
+                    }
+                    #endregion
+
                     var rp_formula = "";
                     mx.pocket_around_spring_cost = Calculate(mx.pocket_around_spring_cost_replace_formula, out rp_formula, "四周口袋弹簧成本").DecimalValue;
                     mx.pocket_around_spring_cost_replace_formula = rp_formula;
@@ -308,6 +324,10 @@ namespace JLHHJSvr.Helper
                     AddKeyValue("四周口袋弹簧成本", bednet.pocket_around_spring_cost);
                     AddFormulaMxKeyValue("【四周口袋弹簧成本】", bednet.pocket_around_spring_formula);
                 }
+                else
+                {
+                    AddKeyValue("口袋弹簧单价", 0);
+                }
                 #endregion 计算 四周口袋弹簧成本 结束
 
                 #region 计算 四周口袋无纺布成本 开始
@@ -329,6 +349,10 @@ namespace JLHHJSvr.Helper
                 {
                     mx.hard_around_mtrl_cost_replace_formula = bednet.hard_around_mtrl_formula;
 
+                    #region wf_cmp_hard_around_dw2 四周加硬弹簧单价
+                    GetSpringPrice(bednet.pricelistid.Value, "加硬弹簧单价", mx.hard_around_springid);
+                    #endregion
+
                     var rp_formula = "";
                     mx.hard_around_mtrl_cost = Calculate(mx.hard_around_mtrl_cost_replace_formula, out rp_formula, "四周加硬材料成本").DecimalValue;
                     mx.hard_around_mtrl_cost_replace_formula = rp_formula;
@@ -347,6 +371,10 @@ namespace JLHHJSvr.Helper
                     AddKeyValue("四周加硬材料成本", bednet.hard_around_mtrl_cost);
                     AddFormulaMxKeyValue("【四周加硬材料成本】", bednet.hard_around_mtrl_formula);
                 }
+                else
+                {
+                    AddKeyValue("加硬弹簧单价", 0);
+                }
                 #endregion 计算 四周加硬材料成本 结束
 
                 #region 计算 四周加硬人力成本 开始
@@ -952,7 +980,7 @@ namespace JLHHJSvr.Helper
                 }
                 else
                 {
-                    AddKeyValue("四周加硬重量", 0);
+                    AddKeyValue("上/下垫层重量", 0);
                 }
 
                 bednet.felt_weight_replace_formula += felt_weight_formula_replace_formula;
@@ -1290,44 +1318,7 @@ namespace JLHHJSvr.Helper
                 AddKeyValue("床网高", mx.bednet_height);
             }
 
-            if (spring.height > 0)
-            {
-                AddKeyValue("口袋弹簧高度", spring.height);
-            }
-
-            if (spring.center_diameter > 0)
-            {
-                AddKeyValue("口袋弹簧心径", spring.center_diameter);
-            }
-
-            if (spring.line_diameter == null)
-            {
-                spring.line_diameter = 0;
-            }
-
-            cmd.CommandText = @"SELECT TOP 1 isnull(u_mtrl_price_pricelist.price, 0) AS price
-                                FROM u_mtrl_price_pricelist
-                                INNER JOIN u_mtrl_price ON u_mtrl_price.mtrlid = u_mtrl_price_pricelist.mtrlid
-                                WHERE cast(u_mtrl_price.name AS DECIMAL(18, 5)) = @line_diameter
-	                                AND u_mtrl_price.mtrltype = 0
-	                                AND u_mtrl_price_pricelist.pricelistid = @pricelistid";
-            cmd.Parameters.Clear();
-            cmd.Parameters.AddWithValue("@line_diameter", spring.line_diameter);
-            cmd.Parameters.AddWithValue("@pricelistid", bednet.pricelistid);
-            decimal price = 0;
-            using (var reader = cmd.ExecuteReader())
-            {
-                if (reader.Read())
-                {
-                    price = Convert.ToDecimal(reader["price"]);
-
-                    price /= 1000;
-                }
-            }
-
-            AddKeyValue("加硬弹簧单价", price);
-            AddKeyValue("口袋弹簧单价", price);
-            AddKeyValue("弹簧单价", price);
+            GetSpringPrice(bednet.pricelistid.Value, "弹簧单价", 0, spring.line_diameter ?? 0);
         }
         /// <summary>
         /// 用于床网报价 弹簧材料总成本 弹簧人工总成本
@@ -1590,9 +1581,18 @@ namespace JLHHJSvr.Helper
             #endregion 计算 下垫层 结束
         }
 
-        private void CalSnakeCol(u_bednet bednet,u_spring spring)
+        private u_spring GetSpringPrice(int pricelistid, string KeyName, int? springId, decimal line_diameter = 0)
         {
-            #region 替换蛇线单价  snake_wire_diameter
+            var spring = new u_spring() { springid = springId };
+            if (line_diameter == 0)
+            {
+                 DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,height,center_diameter");
+            } 
+            else
+            {
+                spring.line_diameter = line_diameter;
+            }
+
             cmd.CommandText = @"SELECT TOP 1 isnull(u_mtrl_price_pricelist.price, 0) AS price
                                 FROM u_mtrl_price_pricelist
                                 INNER JOIN u_mtrl_price ON u_mtrl_price.mtrlid = u_mtrl_price_pricelist.mtrlid
@@ -1600,8 +1600,8 @@ namespace JLHHJSvr.Helper
 	                                AND u_mtrl_price.mtrltype = 0
 	                                AND u_mtrl_price_pricelist.pricelistid = @pricelistid";
             cmd.Parameters.Clear();
-            cmd.Parameters.AddWithValue("@line_diameter", spring.line_diameter);
-            cmd.Parameters.AddWithValue("@pricelistid", bednet.pricelistid);
+            cmd.Parameters.AddWithValue("@line_diameter", spring.line_diameter ?? 0);
+            cmd.Parameters.AddWithValue("@pricelistid", pricelistid);
             decimal price = 0;
             using (var reader = cmd.ExecuteReader())
             {
@@ -1613,11 +1613,9 @@ namespace JLHHJSvr.Helper
                 }
             }
 
-            if (price > 0)
-            {
-                AddKeyValue("蛇线单价", price);
-            }
-            #endregion
+            AddKeyValue(KeyName, price);
+
+            return spring;
         }
 
         private decimal getMtrlPrice(int mtrltype, int pricelistid, int mtrlid)
@@ -2349,7 +2347,7 @@ namespace JLHHJSvr.Helper
 
                         // Use StringBuilder to efficiently build ls_t_temp
                         StringBuilder sb = new StringBuilder(ls_t_temp);
-                        for (int i = 1; i <= springList.Count; i++)
+                        for (int i = 1; i < springList.Count; i++)
                         {
                             ls_t_name = GetSpringName(springList[i].springid.Value);
                             pos = ls_t_name.IndexOf('/');
@@ -2700,8 +2698,8 @@ namespace JLHHJSvr.Helper
         {
 
             // 默认方法
-            AddFormulaKeyValue("弹簧排列个数-宽", "if(【卷包】=1,round(【床垫宽】/(【中心直径】-【卷排列宽】),0),round(【床垫宽】/(【中心直径】-【排列宽】),0))");
-            AddFormulaKeyValue("弹簧排列个数-长", "if(【卷包】=1,round(【床垫长】/(【中心直径】-【卷排列长】),0),round(【床垫长】/(【中心直径】-【排列长】),0))");
+            AddFormulaKeyValue("弹簧排列个数-宽", "if(【卷包】=1,round((【床垫宽】- 2)/(【中心直径】-【卷排列宽】),0),round((【床垫宽】- 2)/(【中心直径】-【排列宽】),0))");
+            AddFormulaKeyValue("弹簧排列个数-长", "if(【卷包】=1,round((【床垫长】- 2)/(【中心直径】-【卷排列长】),0),round((【床垫长】- 2)/(【中心直径】-【排列长】),0))");
 
             InitReplaceMents(bednet);
 

+ 1 - 1
JLHHJSvr/Helper/InterfaceHelper.cs

@@ -154,7 +154,7 @@ namespace JLHHJSvr.Helper
                 interfaceList = RefreshMattressInterfaceList(mattressid, configuretype);
             } else
             {
-                MattressInterfaceFindERPPz(mattressid, interfaceList);
+                MattressInterfaceFindERPPz(mattressid, interfaceList, configuretype);
             }