فهرست منبع

业务后台:主副规格生成床网明细逻辑更新

chen_yjin 3 ماه پیش
والد
کامیت
cd9480e4e5

+ 8 - 0
JLHHJSvr/Com/Model/u_mattress.cs

@@ -141,6 +141,14 @@ namespace JLHHJSvr.Com.Model
         #region 其他
         public int? pricelistid { get; set; }
         public int? copy_id { get; set; }
+        /// <summary>
+        /// 主副规格记录:弹簧排列个数-宽
+        /// </summary>
+        public int? spring_qty_width { get; set; }
+        /// <summary>
+        /// 主副规格记录:弹簧排列个数-长
+        /// </summary>
+        public int? spring_qty_length { get; set; }
         #endregion
     }
 }

+ 29 - 9
JLHHJSvr/DataStore/web_mattress_subspecs.xml

@@ -2,14 +2,26 @@
 <select>
 	<selectstr>
 		SELECT
-		mattressid,
-		mattresscode,
-		mattress_width,
-		mattress_length,
-		mattress_height,
-		parentid
-
-		From u_mattress
+			u_mattress.mattressid,
+			mattresscode,
+			mattress_width,
+			mattress_length,
+			mattress_height,
+			parentid,
+			ISNULL(vv_mattress.mtrlid, 0) AS mtrlid,
+			ISNULL(u_bednetmx.spring_qty_width, 0) AS spring_qty_width,
+			ISNULL(u_bednetmx.spring_qty_length, 0) AS spring_qty_length
+		FROM u_mattress
+		LEFT OUTER JOIN (
+			SELECT
+				u_mattress_mx_mtrl.mattressid,
+				u_mattress_mx_mtrl.mtrlid
+				,u_mattress_formula.formulakind as formulakind
+			FROM u_mattress_mx_mtrl
+			LEFT JOIN u_mattress_formula On u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
+			WHERE formulatype = 99
+		) vv_mattress on vv_mattress.mattressid = u_mattress.mattressid
+		LEFT OUTER JOIN u_bednetmx on u_bednetmx.bednetid = vv_mattress.mtrlid
 	</selectstr>
 	<where>
 		<when notnull="@arg_mattressid">
@@ -19,12 +31,20 @@
 		</when>
 	</where>
 	<orderstr>
-		mattressid DESC
+		mattressid
 	</orderstr>
 	<displayfields>
 		<field field="mattress_width" datatype="integer">床垫宽/CM</field>
 		<field field="mattress_length" datatype="integer">床垫长/CM</field>
 		<field field="mattress_height" datatype="integer">床垫高/CM</field>
+		<field field="spring_qty_width" datatype="number">
+			弹簧排列
+			个数-宽
+		</field>
+		<field field="spring_qty_length" datatype="number">
+			弹簧排列
+			个数-长
+		</field>
 		<field field="mattresscode">报价唯一码</field>
 	</displayfields>
 </select>

+ 38 - 20
JLHHJSvr/Excutor/GetComputeSpringExcutor.cs

@@ -33,28 +33,37 @@ namespace JLHHJSvr.Excutor
                 rslt.ErrMsg = "缺少主表信息";
                 return;
             }
-            if (request.bednet.bednettypeid <= 0)
+
+            if (request.bednet.bednetid > 0 && request.bednetMx == null)
             {
-                rslt.ErrMsg = "请选择床网类型";
-                return;
+                // 床垫报价-主副规格,计算弹簧排列长宽
             }
-            if (request.bednetMx == null || !request.bednetMx.Any())
+            else
             {
-                rslt.ErrMsg = "缺少报价明细";
-                return;
-            }
-            // 检查是否填写床网高度
-
-            foreach (var mx in request.bednetMx)
-            {
-                if (mx.bednet_height == null || mx.bednet_height <= 0)
+                if (request.bednet.bednettypeid <= 0)
                 {
-                    rslt.ErrMsg = "请填写床网高";
+                    rslt.ErrMsg = "请选择床网类型";
                     return;
                 }
-                else
+                if (request.bednetMx == null || !request.bednetMx.Any())
                 {
-                    request.bednet.mattress_height = mx.bednet_height;
+                    rslt.ErrMsg = "缺少报价明细";
+                    return;
+                }
+
+                // 检查是否填写床网高度
+
+                foreach (var mx in request.bednetMx)
+                {
+                    if (mx.bednet_height == null || mx.bednet_height <= 0)
+                    {
+                        rslt.ErrMsg = "请填写床网高";
+                        return;
+                    }
+                    else
+                    {
+                        request.bednet.mattress_height = mx.bednet_height;
+                    }
                 }
             }
 
@@ -63,19 +72,28 @@ namespace JLHHJSvr.Excutor
             {
                 con.Open();
 
+                var helper = HelperBase.GetHelper<BedNetHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
+                var _bednet = request.bednet;
+
+                if (request.bednet.bednetid > 0 && request.bednetMx == null)
+                {
+                    // 床垫报价-主副规格,计算弹簧排列长宽
+                    _bednet = helper.GetBedNet(request.bednet.bednetid.Value);
+                    _bednet.pricelistid = request.bednet.pricelistid;
+                    request.bednetMx = helper.GetBedNetMxList(request.bednet.bednetid.Value);
+                }
+
                 // 初始化属性
-                AutoInit.AutoInitS(cmd, request.bednet);
+                AutoInit.AutoInitS(cmd, _bednet);
 
                 foreach (var mx in request.bednetMx)
                 {
                     AutoInit.AutoInitS(cmd, mx);
                 }
 
-                var helper = HelperBase.GetHelper<BedNetHelper>(cmd,new HelperBase.Context() { tokendata = tokendata});
-
                 try
                 {
-                    helper.CalCulateSpringQty(request.bednet, request.bednetMx);
+                    helper.CalCulateSpringQty(_bednet, request.bednetMx);
                 }
                 catch (Exception e)
                 {
@@ -85,7 +103,7 @@ namespace JLHHJSvr.Excutor
 
                 rslt.formulas = helper.FormulaReplacements;
 
-                rslt.bednet = request.bednet;
+                rslt.bednet = _bednet;
                 rslt.bednetMx = request.bednetMx;
             }
         }

+ 102 - 3
JLHHJSvr/Excutor/SaveMattressExcutor.cs

@@ -61,6 +61,8 @@ namespace JLHHJSvr.Excutor
 
                     var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
 
+                    var helperBednet = HelperBase.GetHelper<BedNetHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
+
                     //try
                     //{
                     //    helper.CalCulateFormula(request.mattress, request.mattressMx);
@@ -88,7 +90,7 @@ namespace JLHHJSvr.Excutor
                     //    {
                     //        helper.CopyMattressInterface(request.mattress.copy_id.Value, request.mattress.mattressid);
                     //    }
-                        
+
                     //    cmd.Transaction.Commit();
 
                     //    rslt.mattressid = request.mattress.mattressid;
@@ -131,8 +133,10 @@ namespace JLHHJSvr.Excutor
 
                         if (request.subspecs != null && request.subspecs.Count > 0)
                         {
+                            // 排序:宽、长,从小到大
+                            var _subspecs = request.subspecs.OrderBy(o => o.mattress_width).ThenBy(o => o.mattress_length).ToList();
                             // 副规格
-                            foreach (var submx in request.subspecs)
+                            foreach (var submx in _subspecs)
                             {
                                 var _mattress = ObjectHelper.DeepCopy(request.mattress);
                                 _mattress.parentid = request.mattress.mattressid;
@@ -145,12 +149,107 @@ namespace JLHHJSvr.Excutor
                                 var _mattressMx = new List<u_mattress_mx_mtrl>();
                                 if (request.mattressMx != null && request.mattressMx.Any())
                                 {
-                                    foreach (var item in request.mattressMx)
+                                    foreach (var itemMx in request.mattressMx)
                                     {
+                                        var item = ObjectHelper.DeepCopy(itemMx);
                                         item.mattressid = _mattress.mattressid;
                                         item.mattressmxid = 0;
                                         item.message = "";
 
+                                        #region 副规格床网自动匹配/新增逻辑
+                                        if (item.formulatype == 99 && item.mtrlid > 0)
+                                        {
+                                            var oBednet = new u_bednet();
+                                            var _bednet = helperBednet.GetBedNet(item.mtrlid.Value);
+                                            var _bednetMx = helperBednet.GetBedNetMxList(item.mtrlid.Value);
+                                            var _bednetSpring = helperBednet.GetBedNetSpringList(item.mtrlid.Value);
+
+                                            _bednet.mattress_width = submx.mattress_width - (request.mattress.mattress_width - _bednet.mattress_width);
+                                            _bednet.mattress_length = submx.mattress_length - (request.mattress.mattress_length - _bednet.mattress_length);
+
+                                            if (_bednetMx.Count > 0)
+                                            {
+                                                cmd.CommandText = @"SELECT TOP 1 u_bednet.bednetid
+                                                                            ,u_bednet_type.typename
+                                                                            ,bednetcode
+                                                                            ,mattress_width
+                                                                            ,mattress_length
+                                                                            ,mattress_height
+                                                                            ,nottax_factory_cost
+                                                                    FROM u_bednetmx
+                                                                    INNER JOIN u_bednet on u_bednet.bednetid = u_bednetmx.bednetid
+                                                                    INNER JOIN u_bednet_type on u_bednet_type.bednettypeid = u_bednet.bednettypeid
+                                                                    WHERE u_bednet.bednettypeid = @bednettypeid
+	                                                                    AND u_bednet.mattress_width = @mattress_width
+	                                                                    AND u_bednet.mattress_length = @mattress_length
+	                                                                    AND u_bednetmx.bednet_height = @bednet_height
+	                                                                    AND u_bednetmx.springid = @springid
+	                                                                    AND u_bednetmx.spring_qty_width = @spring_qty_width
+	                                                                    AND u_bednetmx.spring_qty_length = @spring_qty_length
+	                                                                    AND u_bednetmx.if_side_iron = @if_side_iron
+	                                                                    AND u_bednetmx.side_iron_qty = @side_iron_qty
+	                                                                    AND u_bednetmx.fabrics2_mtrlid = @fabrics2_mtrlid
+	                                                                    AND u_bednetmx.fabrics1_mtrlid = @fabrics1_mtrlid
+                                                                    ";
+                                                cmd.Parameters.Clear();
+                                                cmd.Parameters.AddWithValue("@bednettypeid", _bednet.bednettypeid);
+                                                cmd.Parameters.AddWithValue("@mattress_width", _bednet.mattress_width);
+                                                cmd.Parameters.AddWithValue("@mattress_length", _bednet.mattress_length);
+                                                cmd.Parameters.AddWithValue("@bednet_height", _bednetMx[0].bednet_height);
+                                                cmd.Parameters.AddWithValue("@springid", _bednetMx[0].springid);
+                                                cmd.Parameters.AddWithValue("@spring_qty_width", submx.spring_qty_width);
+                                                cmd.Parameters.AddWithValue("@spring_qty_length", submx.spring_qty_length);
+                                                cmd.Parameters.AddWithValue("@if_side_iron", _bednetMx[0].if_side_iron);
+                                                cmd.Parameters.AddWithValue("@side_iron_qty", _bednetMx[0].side_iron_qty);
+                                                cmd.Parameters.AddWithValue("@fabrics2_mtrlid", _bednetMx[0].fabrics2_mtrlid);
+                                                cmd.Parameters.AddWithValue("@fabrics1_mtrlid", _bednetMx[0].fabrics1_mtrlid);
+                                                using (var reader = cmd.ExecuteReader())
+                                                {
+                                                    if (reader.Read())
+                                                    {
+                                                        oBednet = new u_bednet() {
+                                                            bednetid = Convert.ToInt32(reader["bednetid"]),
+                                                            typename = Convert.ToString(reader["typename"]),
+                                                            bednetcode = Convert.ToString(reader["bednetcode"]),
+                                                            mattress_width = Convert.ToInt32(reader["mattress_width"]),
+                                                            mattress_length = Convert.ToInt32(reader["mattress_length"]),
+                                                            mattress_height = Convert.ToInt32(reader["mattress_height"]),
+                                                            nottax_factory_cost = Convert.ToDecimal(reader["nottax_factory_cost"])
+                                                        };
+                                                    }
+                                                }
+                                            }
+
+                                            // 匹配失败,自动新建
+                                            if (oBednet.bednetid == null)
+                                            {
+                                                oBednet = _bednet;
+                                                _bednetMx[0].spring_qty_width = submx.spring_qty_width;
+                                                _bednetMx[0].spring_qty_length = submx.spring_qty_length;
+
+                                                oBednet.bednetid = 0;
+
+                                                helperBednet.SaveBedNet(oBednet, _bednetMx, _bednetSpring);
+                                            }
+
+                                            var _mtrlname = oBednet.typename +
+                                                            " " +
+                                                            oBednet.bednetcode +
+                                                            " " +
+                                                            oBednet.mattress_width +
+                                                            "*" +
+                                                            oBednet.mattress_length +
+                                                            "*" +
+                                                            oBednet.mattress_height;
+
+                                            item.mtrlid = oBednet.bednetid;
+                                            item.mtrlname = _mtrlname;
+                                            item.price = oBednet.nottax_factory_cost;
+                                            item.qty = 1;
+
+                                        }
+                                        #endregion
+
                                         _mattressMx.Add(item);
                                     }
                                 }

+ 1 - 1
JLHHJSvr/Helper/BedNetHelper.cs

@@ -1846,7 +1846,7 @@ namespace JLHHJSvr.Helper
                                         fabrics2_weight_replace_formula,felt_weight_replace_formula,cnail_weight_replace_formula,sponge_weight_replace_formula,
                                         sponge_weight_tc_replace_formula,edge_weight_replace_formula,fork_weight_replace_formula,spring_weight_qty,
                                         side_iron_weight_qty,hard_around_weight_qty,fabrics1_weight_qty,fabrics2_weight_qty,felt_weight_qty,cnail_weight_qty,
-                                        sponge_weight_qty,sponge_weight_tc_qty,edge_weight_qty,fork_weight_qty,sum_weight,if_jb";
+                                        sponge_weight_qty,sponge_weight_tc_qty,edge_weight_qty,fork_weight_qty,sum_weight,if_jb,flag";
 
             var fieldsMx = @"bednetmxid,bednetid,spring_qty_width,spring_qty_length,bednet_height,wire_mtrlid,springid,if_part,if_15strip,
                                         if_pocket_around,pocket_around_springid,pocket_around_row,pocket_around_wire_price,pocket_around_spring_cost,