Sfoglia il codice sorgente

1、生成/更新物料增加日志捕捉
2、新增获取部分基础资料缓存
3、取消业务下单,不能增加副规格的限制
4、业务选择高压缩弹簧,床网新增【高压缩】
5、床网有海绵填充,新增床网填充海绵条列
6、床垫清单,L1物料编码变更为含糊查询
7、修复有主副规格的产品,被复制出来的排列不会自动更新

MY 2 giorni fa
parent
commit
38c66b9f31

+ 21 - 1
JLHHJSvr/BLL/HelperBase.cs

@@ -1,4 +1,5 @@
-using JLHHJSvr.LJException;
+using JLHHJSvr.Helper;
+using JLHHJSvr.LJException;
 using JLHHJSvr.LJFramework.Tools;
 using LJLib.InstallHelper;
 using Newtonsoft.Json.Linq;
@@ -22,6 +23,10 @@ namespace JLHHJSvr.BLL
         /// 预留的上下文
         /// </summary>
         public Context context { get; set; }
+        /// <summary>
+        /// 数据缓存
+        /// </summary>
+        private CacheHelper _cache;
 
         public static T GetHelper<T>(SqlCommand cmd, Context context = null) where T : HelperBase, new()
         {
@@ -31,6 +36,21 @@ namespace JLHHJSvr.BLL
             return rslt;
         }
 
+        /// <summary>
+        /// 缓存数据库相关信息
+        /// </summary>
+        public CacheHelper Cache
+        {
+            get
+            {
+                if (_cache == null)
+                {
+                    _cache = GetHelper<CacheHelper>(cmd, context);
+                }
+                return _cache;
+            }
+        }
+
         public JObject DoExecute(string apiName, JObject request)
         {
             var url = GlobalVar.ERP_API_URL + "/api/common/" + apiName;

+ 32 - 0
JLHHJSvr/Com/GetSoftBedMxList.cs

@@ -0,0 +1,32 @@
+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 GetSoftBedMxListRequest : ILJRequest<GetSoftBedMxListResponse>
+    {
+        public override string GetApiName()
+        {
+            return "GetSoftBedMxList";
+        }
+        /// <summary>
+        /// 登录token
+        /// </summary>
+        public string token { get; set; }
+        /// <summary>
+        /// 单据id
+        /// </summary>
+        public int billid { get; set; }
+    }
+
+    public sealed class GetSoftBedMxListResponse : LJResponse
+    {
+        //public u_mattress mattress { get; set; }
+        //public List<u_mattress_interface> interfaceList { get; set; }
+        //public List<u_mattress_interface_qd> qdList { get; set; }
+    }
+}

+ 3 - 0
JLHHJSvr/Com/Model/u_configure_codemx.cs

@@ -67,5 +67,8 @@ namespace JLHHJSvr.Com.Model
         public string erp_mtrlcode { get; set; }
         public string wrkgrpcode2 { get; set; }
 
+        #region 辅助
+        public string pzname { get; set; }
+        #endregion
     }
 }

+ 39 - 0
JLHHJSvr/Com/Model/u_configure_codemxbom.cs

@@ -0,0 +1,39 @@
+using LJLib.DAL.SQL;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JLHHJSvr.Com.Model
+{
+    [PK(new[] { "pzid,printid,pid" })]
+    public class u_configure_codemxbom
+    {
+        public int pzid { get; set; }
+        public int printid { get; set; }
+        public int pid { get; set; }
+        public int mtrlid { get; set; }
+        public decimal sonscale { get; set; }
+        public string sonscale_formula { get; set; }
+        public decimal mng_cost_rate { get; set; }
+        public decimal profit_rate { get; set; }
+        public decimal realqty { get; set; }
+        public decimal cost { get; set; }
+        public string cost_emp { get; set; }
+        public DateTime cost_date { get; set; }
+        public decimal sonloss { get; set; }
+        public string sonloss_formula { get; set; }
+        public decimal sondecloss { get; set; }
+        public string sondecloss_formula { get; set; }
+        public int deptid_scll { get; set; }
+        public decimal price { get; set; }
+        public string price_formula { get; set; }
+        #region 辅助
+        public string mtrlname { get; set; }
+        public string mtrlcode { get; set; }
+        public string mtrlmode { get; set; }
+        public string unit { get; set; }
+        #endregion
+    }
+}

+ 41 - 0
JLHHJSvr/Com/Model/u_softbed.cs

@@ -0,0 +1,41 @@
+using LJLib.DAL.SQL;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JLHHJSvr.Com.Model
+{
+    [PK(new[] { "softbed_id" })]
+    public class u_softbed
+    {
+        public int softbed_id { get; set; }
+        public string softbed_code { get; set; }
+        public string softbed_name { get; set; }
+        public int deptid { get; set; }
+        public DateTime? create_time { get; set; }
+        public string create_by { get; set; }
+        public string mtrlmode { get; set; }
+        public string mtrltype { get; set; }
+        public byte has_headboard { get; set; }
+        public byte has_nightstand { get; set; }
+        public byte has_bedframe { get; set; }
+        public byte is_template { get; set; }
+        public int template_id { get; set; }
+        public string template_code { get; set; }
+        public string template_name { get; set; }
+        public decimal commission { get; set; }
+        public decimal taxes { get; set; }
+        public decimal other_rate { get; set; }
+        public decimal extras_cost { get; set; }
+        public decimal moneyrate { get; set; }
+        public string dscrp { get; set; }
+        public decimal costamt { get; set; }
+        public decimal nottax_factory_cost { get; set; }
+        public decimal nottax_dept_cost { get; set; }
+        public decimal dept_cost { get; set; }
+        public decimal foreign_cost { get; set; }
+    }
+
+}

+ 44 - 0
JLHHJSvr/Com/Model/u_softbed_mx.cs

@@ -0,0 +1,44 @@
+using LJLib.DAL.SQL;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JLHHJSvr.Com.Model
+{
+    [PK(new[] { "softbed_id,printid" })]
+    public class u_softbed_mx
+    {
+        public int softbed_id { get; set; }
+        public int printid { get; set; }
+        public int pzid { get; set; }
+        public int pz_pringid { get; set; }
+        public int mtrlid { get; set; }
+        public string mtrlname { get; set; }
+        public string mtrlcode { get; set; }
+        public string mtrlmode { get; set; }
+        public string unit { get; set; }
+        public byte has_type { get; set; }
+        public byte allow_edit { get; set; }
+        public decimal cutting_length { get; set; }
+        public decimal cutting_width { get; set; }
+        public decimal cutting_qty { get; set; }
+        public decimal useqty { get; set; }
+        public string use_formula { get; set; }
+        public string use_formula_str { get; set; }
+        public decimal actual_useqty { get; set; }
+        public decimal loss_rate { get; set; }
+        public decimal price { get; set; }
+        public string price_formula { get; set; }
+        public string price_formula_str { get; set; }
+        public decimal cost_price { get; set; }
+        public decimal cost_amt { get; set; }
+
+        #region 辅助
+        public string pzname { get; set; }
+        public string pzmxname { get; set; }
+        #endregion
+    }
+
+}

+ 34 - 29
JLHHJSvr/Excutor/CreatMtrldefExcutor.cs

@@ -1,6 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Data.SqlClient;
+using System.Diagnostics;
+using System.Linq;
 using JLHHJSvr.BLL;
 using JLHHJSvr.Com;
 using JLHHJSvr.Com.Model;
@@ -35,9 +37,11 @@ namespace JLHHJSvr.Excutor
             {
                 con.Open();
 
+                var toUpdate = new List<u_mattress>();
+
                 foreach (var mattressid in request.list)
                 {
-                    var mattress = new u_mattress();
+                    var mattress = new u_mattress() { mattressid = mattressid };
                     if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", mattressid } }, mattress, "erp_mtrlid,erp_mtrlcode, erp_mtrlname, erp_mtrlmode, erp_mtrltypeid, erp_mtrltype, erp_mtrlunit, erp_mtrlengname,nottax_factory_cost,dept_profitrate,dept_profitrate_rangli,commission,taxes,fob,extras_cost,mattresstypeid,erp_configcodetype,dijia_cost1,dijia_cost2,dijia_cost3,dijia_cost4,old_mtrlname,mattresscode") != 1)
                     {
                         rslt.ErrMsg = "床垫报价单匹配失败";
@@ -60,50 +64,51 @@ namespace JLHHJSvr.Excutor
                                     ,u_configure_code.pzcode
                                     ,u_configure_code.name AS pzname
                                 FROM u_mattress_interface
-                                left outer join u_mattress on u_mattress.mattressid = u_mattress_interface.mattressid
-                                left outer join u_configure_code on u_configure_code.typeid = u_mattress.erp_configcodetype 
-		                                and u_mattress_interface.erp_pzid = u_configure_code.pzid";
+                                INNER JOIN u_mattress on u_mattress.mattressid = u_mattress_interface.mattressid
+                                INNER JOIN u_configure_code on u_configure_code.typeid = u_mattress.erp_configcodetype 
+		                                AND u_mattress_interface.erp_pzid = u_configure_code.pzid";
                     DbSqlHelper.SelectJoin(cmd, selectStr, "u_mattress_interface.mattressid = @mattressid AND u_mattress_interface.erp_pzid > 0 AND u_mattress_interface.bj_pzname <> '' ", new Dictionary<string, object>() { { "@mattressid", mattressid } }, "printid", "mattressid,printid,itemname,bj_pzname,bj_namemx,actual_size,sb_craft,actual_size_sb,erp_pzid,ss_rate,ls_rate,bj_inputtype,pzcode,pzname", 0, 0, interfaceList);
 
-
                     var l1Helper = HelperBase.GetHelper<ERPHelper>(cmd);
                     l1Helper.context = new HelperBase.Context() { tokendata = tokendata };
 
-                    l1Helper.CheckLogin();
-
-                    mattress = l1Helper.GetMattressMsg(mattress, interfaceList);
+                    l1Helper.GetMattressMsg(mattress, interfaceList);
 
+                    l1Helper.CheckLogin();
                     var errMsg = l1Helper.SaveMtrldef(mattress, interfaceList);
                     if (!string.IsNullOrEmpty(errMsg))
                     {
                         rslt.ErrMsg = errMsg;
                         return;
                     }
-                    mattress.mattressid = mattressid;
-                    mattress.creatmtrl_flag = 1;
 
-                    DbSqlHelper.Update(cmd, mattress, "erp_mtrlid, creatmtrl_flag, erp_mtrlcode");
+                    toUpdate.Add(mattress);
+                }
+
+                using(cmd.Transaction = con.BeginTransaction())
+                {
+                    try
+                    {
+                        foreach (var mattress in toUpdate.Where(m => m.erp_mtrlid > 0))
+                        {
+                            mattress.creatmtrl_flag = 1;
 
-                    rslt.mattress = mattress;
+                            DbSqlHelper.Update(cmd, mattress, "erp_mtrlid, creatmtrl_flag, erp_mtrlcode");
+
+                            Trace.Write($"Called By CreateMtrldef,UPDATE INFOS:erp_mtrlid = {mattress.erp_mtrlid},erp_mtrlcod = {mattress.erp_mtrlcode},mattressid = {mattress.mattressid}");
+                            rslt.mattress = mattress;
+                        }
+
+                        cmd.Transaction.Commit();
+                    }
+                    catch (Exception ex) 
+                    {
+                        cmd.Transaction?.Rollback();
+                        Trace.Write($"Transaction failed: {ex.Message}");
+                        throw;
+                    }
                 }
             }
         }
-
-        /// <summary>
-        /// 保存物料清单请求参数,没有传入的参数按默认值
-        /// </summary>
-        private class SavePrdPfRequest
-        {
-            public string token { get; set; }
-            /// <summary>
-            /// 物料清单主表 mtrlid,pfcode,flag,affirmflag,Ifdft,inuse,wrkid
-            /// </summary>
-            public u_mtrl_pf mtrl_pf { get; set; }
-            /// <summary>
-            /// 物料清单明细表 mtrlid,pfcode,sonmtrlid,printid,wrkgrpid,sonpfcode,Sonscale,sonloss,sondecloss
-            /// pfgroup,dscrp,pfgroupqty,pfklmode,azcode,promode
-            /// </summary>
-            public List<u_PrdPF> prdPfs { get; set; }
-        }
     }
 }

+ 42 - 0
JLHHJSvr/Excutor/GetSoftBedMxListExcutor.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using DirectService.Tools;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.Helper;
+using JLHHJSvr.LJException;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using LJLib.SQLEX;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class GetSoftBedMxListExcutor : ExcutorBase<GetSoftBedMxListRequest, GetSoftBedMxListResponse>
+    {
+        protected override void ExcuteInternal(GetSoftBedMxListRequest request, object state, GetSoftBedMxListResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+            if (request.billid <= 0)
+            {
+                rslt.ErrMsg = "软床id有误,请检查!";
+                return;
+            }
+
+            using (var con = GlobalVar.ConnectionString.NewSqlConnection())
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                
+            }
+        }
+    }
+}

+ 1 - 2
JLHHJSvr/Excutor/ReCalculateBedNetNoAuditExcutor.cs

@@ -51,8 +51,7 @@ namespace JLHHJSvr.Excutor
 
                     if (bednet.deptid <= 0) throw new LJCommonException("存在报价单部门id错误,不能重算!");
 
-                    var dept = new u_dept() { deptid = bednet.deptid.Value };
-                    DbSqlHelper.SelectOne(cmd, dept, "pricelistid");
+                    var dept = helper.Cache.getdept(bednet.deptid.Value);
 
                     if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!");
 

+ 1 - 2
JLHHJSvr/Excutor/ReCalculateERPCostExcutor.cs

@@ -55,8 +55,7 @@ namespace JLHHJSvr.Excutor
                     //if (mattress.flag == 1) throw new LJCommonException("存在报价单已审核,不能重算!");
                     if (mattress.deptid <= 0) throw new LJCommonException("存在报价单部门id错误,不能重算!");
 
-                    var dept = new u_dept() { deptid = mattress.deptid.Value };
-                    DbSqlHelper.SelectOne(cmd, dept, "pricelistid");
+                    var dept = helper.Cache.getdept(mattress.deptid.Value);
                     if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!");
                 }
 

+ 1 - 2
JLHHJSvr/Excutor/ReCalculateNoAuditExcutor.cs

@@ -51,8 +51,7 @@ namespace JLHHJSvr.Excutor
 
                     if (mattress.deptid <= 0) throw new LJCommonException("存在报价单部门id错误,不能重算!");
 
-                    var dept = new u_dept() { deptid = mattress.deptid.Value };
-                    DbSqlHelper.SelectOne(cmd, dept, "pricelistid");
+                    var dept = helper.Cache.getdept(mattress.deptid.Value);
 
                     if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!");
 

+ 12 - 12
JLHHJSvr/Excutor/SaveMattressExcutor.cs

@@ -533,18 +533,18 @@ namespace JLHHJSvr.Excutor
                     }
 
                     // 副规格
-                    if (mattressInfo.parentid != null && mattressInfo.parentid > 0)
-                    {
-                        subspecsList = mattressHelper.GetMattressSubspecs(mattressInfo.parentid.Value, "flag, xd_flag, yw_flag, mattresscode, parentid,mattressid,mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode");
-                        foreach(var submx in subspecsList)
-                        {
-                            if (submx.xd_flag == 1)
-                            {
-                                rslt.ErrMsg = "副规格-床垫报价单【" + submx.mattresscode + "】已业务下单,不能修改";
-                                return;
-                            }
-                        }
-                    }
+                    //if (mattressInfo.parentid != null && mattressInfo.parentid > 0)
+                    //{
+                    //    subspecsList = mattressHelper.GetMattressSubspecs(mattressInfo.parentid.Value, "flag, xd_flag, yw_flag, mattresscode, parentid,mattressid,mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode");
+                    //    foreach(var submx in subspecsList)
+                    //    {
+                    //        if (submx.xd_flag == 1)
+                    //        {
+                    //            rslt.ErrMsg = "副规格-床垫报价单【" + submx.mattresscode + "】已业务下单,不能修改";
+                    //            return;
+                    //        }
+                    //    }
+                    //}
                 }
 
                 var _mattress = ObjectHelper.DeepCopy(request.mattress);

+ 32 - 21
JLHHJSvr/Helper/BedNetHelper.cs

@@ -176,8 +176,7 @@ namespace JLHHJSvr.Helper
 
             foreach (var mx in mxlist)
             {
-                var spring = new u_spring() { springid = mx.springid };
-                DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,height,center_diameter");
+                var spring = Cache.getspring(mx.springid.Value);
 
                 // 处理相同公式部分
                 InitMxReplaceMents(bednet, mx, spring);
@@ -1133,8 +1132,7 @@ namespace JLHHJSvr.Helper
 
         private void InitBedNet(u_bednet bednet, Boolean isCalBed = true)
         {
-            var dept = new u_dept() { deptid = bednet.deptid.Value };
-            DbSqlHelper.SelectOne(cmd, dept, "pricelistid,profitrate,moneyrate,discount");
+            var dept = Cache.getdept(bednet.deptid.Value);
 
             //var profirate = new u_factory_profitrate() { deptid = bednet.deptid, bednettypeid_mattresstypeid = bednet.bednettypeid, bednet_or_mattress = 0 };
             //DbSqlHelper.SelectOne(cmd, profirate, "profitrate");
@@ -1400,8 +1398,7 @@ namespace JLHHJSvr.Helper
             AddKeyValue("边铁条数", mx.side_iron_qty);
             AddKeyValue("条数", mx.side_iron_qty);
 
-            var spring = new u_spring() { springid = mx2.springid };
-            DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight");
+            var spring = Cache.getspring(mx2.springid.Value);
 
             spring.gram_weight /= 1000;
             if (spring.gram_weight > 0)
@@ -1446,8 +1443,7 @@ namespace JLHHJSvr.Helper
         /// <param name="mx"></param>
         private void CalSpringMtrlCol2(u_bednet bednet, u_bednetmx mx, List<u_bednetmx_spring> springList, string type)
         {
-            var spring = new u_spring() { springid = mx.springid };
-            DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,center_diameter");
+            var spring = Cache.getspring(mx.springid.Value);
 
             #region 计算 底面无纺布 开始
             //计算 上下无纺布方数 =(B4+C4)*(B4+D4)/10000
@@ -1470,8 +1466,7 @@ namespace JLHHJSvr.Helper
                 {
                     _springid = springList[0].springid;
                 }
-                var _spring = new u_spring() { springid = _springid };
-                DbSqlHelper.SelectOne(cmd, _spring, "line_diameter,gram_weight,center_diameter");
+                var _spring = Cache.getspring(_springid.Value);
 
                 spring.center_diameter = _spring.center_diameter == null ? 0 : _spring.center_diameter;
 
@@ -1663,7 +1658,7 @@ namespace JLHHJSvr.Helper
             var spring = new u_spring() { springid = springId };
             if (line_diameter == 0)
             {
-                DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,height,center_diameter");
+                spring = Cache.getspring(springId.Value);
                 AddKeyValue(springName + "弹簧重/个", spring.gram_weight / 1000);
                 AddKeyValue(springName + "弹簧重", spring.gram_weight / 1000);
             } 
@@ -1693,7 +1688,6 @@ namespace JLHHJSvr.Helper
             }
 
             AddKeyValue(KeyName, price);
-
             return spring;
         }
 
@@ -2483,9 +2477,8 @@ namespace JLHHJSvr.Helper
 
             var mxList = GetBedNetMxList(bednetid);
             var springList = GetBedNetSpringList(bednetid);
-
-            var dept = new u_dept() { deptid = bednet.deptid.Value };
-            DbSqlHelper.SelectOne(cmd, dept, "pricelistid");
+            
+            var dept = Cache.getdept(bednet.deptid.Value); ;
 
             if(bednet.deptid == null || bednet.deptid.Value <= 0)
             {
@@ -2514,10 +2507,12 @@ namespace JLHHJSvr.Helper
             {
                 pzname = "床网名称"
             });
+
+            var sprint_type_name = GetSpringTypeName(mx.springid.Value);
             qdList.Add(new u_bednet_qingdan()
             {
                 pzname = "床网类型",
-                pznamemx = bednetType.typename,
+                pznamemx = $"{("高压缩".Equals(sprint_type_name) ? "高压缩" + bednetType.typename : bednetType.typename)}",
                 amt = 0,
                 useqty = 0
             });
@@ -2917,12 +2912,29 @@ namespace JLHHJSvr.Helper
         }
         public string GetSpringName(int springid)
         {
-            var spring = new u_spring() { springid = springid };
-            DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,height,center_diameter,cyclenum,caliber");
-
+            //var spring = new u_spring() { springid = springid };
+            //DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,height,center_diameter,cyclenum,caliber");
+            var spring = Cache.getspring(springid);
             return spring.name;
         }
 
+        public string GetSpringTypeName(int springid)
+        {
+            string sprintname = "";
+            cmd.CommandText = @"SELECT u_springtype.springtypename FROM u_spring INNER JOIN u_springtype ON u_springtype.springtypeid = u_spring.springtypeid WHERE u_spring.springid = @springid";
+            cmd.Parameters.Clear();
+            cmd.Parameters.AddWithValue("@springid", springid);
+            using(var reader = cmd.ExecuteReader())
+            {
+                if(reader.Read())
+                {
+                    sprintname = Convert.ToString(reader["springtypename"]);
+                }
+            }
+
+            return sprintname;
+        }
+
         public void CalCulateSpringQty(u_bednet bednet, List<u_bednetmx> mxlist, List<u_bednetmx_spring> springList)
         {
 
@@ -2940,8 +2952,7 @@ namespace JLHHJSvr.Helper
                     //多区
                     _springid = springList[0].springid;
                 }
-                var spring = new u_spring() { springid = _springid };
-                DbSqlHelper.SelectOne(cmd, spring, "line_diameter,gram_weight,height,center_diameter,caliber,cyclenum,roll_width,roll_length,arrangement_width,arrangement_height,springtypeid");
+                var spring = Cache.getspring(_springid.Value);
 
                 // 处理相同公式部分
                 InitMxReplaceMents(bednet, mx, spring);

+ 33 - 25
JLHHJSvr/Helper/CacheHelper.cs

@@ -1,47 +1,55 @@
 using JLHHJSvr.BLL;
 using JLHHJSvr.Com.Model;
+using LJLib;
 using LJLib.DAL.SQL;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Web.Caching;
 
 namespace JLHHJSvr.Helper
 {
     internal sealed class CacheHelper : HelperBase
     {
-        /// <summary>
-        /// 部件选配项
-        /// </summary>
-        /// <param name="typeid"></param>
-        /// <param name="name"></param>
-        /// <returns></returns>
-        public erp_configure_code u_configure_code(int typeid, string name)
+        #region 弹簧资料
+        private static LJCache<string, u_spring> _u_spring;
+        public u_spring getspring(int springid)
         {
-            string key = string.Format("typeid:{0},name:{1}", typeid, name);
-            if (_u_configure_code != null)
+            string key = $"springid:{springid}";
+            if (_u_spring == null) _u_spring = new LJCache<string, u_spring>() { DefaultAddMinutes = DefaultCacheMinutes };
+            if (!_u_spring.TryGetValue(key, out u_spring value))
             {
-                if (_u_configure_code.ContainsKey(key))
-                {
-                    return _u_configure_code[key];
-                }
+                var result = new u_spring { springid = springid };
+                DbSqlHelper.SelectOne(cmd, result, "line_diameter,gram_weight,height,center_diameter,caliber,cyclenum,roll_width,roll_length,arrangement_width,arrangement_height,springtypeid");
+                _u_spring.Add(key, result);
+                return result;
             }
-            else
+            return value;
+        }
+        #endregion
+
+        #region 弹簧类型
+        #endregion
+
+        #region 部门
+        private static LJCache<string, u_dept> _u_dept;
+        public u_dept getdept(int deptid)
+        {
+            string key = $"deptid:{deptid}";
+            if(_u_dept == null) _u_dept = new LJCache<string, u_dept>() { DefaultAddMinutes = DefaultCacheMinutes };
+            if (!_u_dept.TryGetValue(key, out u_dept value))
             {
-                _u_configure_code = new Dictionary<string, erp_configure_code>();
+                var result = new u_dept { deptid = deptid };
+                DbSqlHelper.SelectOne(cmd, result, "pricelistid,profitrate,moneyrate,discount,taxes_rate,managerate,com_profitrate,dannum1_rate,dannum2_rate,dannum3_rate,dannum4_rate");
+                _u_dept.Add(key, result);
+                return result;
             }
-            var rslt = new erp_configure_code
-            {
-                typeid = typeid,
-                name = name,
-            };
-            DbSqlHelper.SelectOne(cmd, rslt,
-                "typeid,pzid,pzcode,name,inputtype,configtype,ifcross,ifcheck,ifuse,rulestr,ifnum,decnum,maxnum,minnum");
-            _u_configure_code[key] = rslt;
-            return rslt;
+            return value;
         }
+        #endregion
 
-        private Dictionary<string, erp_configure_code> _u_configure_code = null;
+        private const int DefaultCacheMinutes = 120;
     }
 }

+ 4 - 2
JLHHJSvr/Helper/ERPHelper.cs

@@ -411,8 +411,10 @@ namespace JLHHJSvr.Helper
             {
                 mtrl.erp_mtrlid = (l1Rslt.GetValue("mtrlids") as JArray)[0].Value<int>();
                 mtrl.erp_mtrlcode = (l1Rslt.GetValue("mtrlcodes") as JArray)[0].Value<string>();
-                Trace.Write($"Update erp_mtrlid={mtrl.erp_mtrlid} WHERE mattressid={mtrl.mattressid} AND erp_mtrlcode={mtrl.erp_mtrlcode}");
-                DbSqlHelper.Update(cmd, mtrl, "erp_mtrlid");
+                var caller = new StackTrace().GetFrame(1).GetMethod();
+                //Trace.Write($"Update erp_mtrlid={mtrl.erp_mtrlid} WHERE mattressid={mtrl.mattressid} AND erp_mtrlcode={mtrl.erp_mtrlcode}");
+                //DbSqlHelper.Update(cmd, mtrl, "erp_mtrlid");
+                Trace.Write($"Called By {caller.DeclaringType?.Name}.{caller.Name},INFOS:erp_mtrlid = {mtrl.erp_mtrlid},erp_mtrlcod = {mtrl.erp_mtrlcode},mattressid = {mtrl.mattressid}");
             }
             return errMsg;
         }

+ 5 - 2
JLHHJSvr/Helper/InterfaceHelper.cs

@@ -702,10 +702,11 @@ namespace JLHHJSvr.Helper
             var name_arr = new string[5];
             int bednetid = 0;
             int spongeMtrlid = 0; // 是否有海绵包边物料
+            int spongeTcMtrlid = 0; // 是否有海绵填充物料
 
-            cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid,u_bednet.sponge_mtrlid
+            cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid,u_bednet.sponge_mtrlid,u_bednet.sponge_tc_mtrlid
                                 FROM u_bednetmx
-								LEFT OUTER JOIN u_bednet ON u_bednet.bednetid = u_bednetmx.bednetid
+								INNER JOIN u_bednet ON u_bednet.bednetid = u_bednetmx.bednetid
                                 INNER JOIN (
 	                                SELECT mtrlid
 	                                FROM u_mattress_mx_mtrl
@@ -725,6 +726,7 @@ namespace JLHHJSvr.Helper
                     {
                         bednetid = Convert.ToInt32(reader["bednetid"]);
                         spongeMtrlid = Convert.ToInt32(reader["sponge_mtrlid"]);
+                        spongeTcMtrlid = Convert.ToInt32(reader["sponge_tc_mtrlid"]);
                     }
                 }
             }
@@ -769,6 +771,7 @@ namespace JLHHJSvr.Helper
             interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}生产说明", 1, new string[] { "" }));
 
             if (spongeMtrlid > 0) interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}包边海绵条", 1, new string[] { "" }));
+            if (spongeTcMtrlid > 0) interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}填充海绵条", 1, new string[] { "" }));
         }
         /// <summary>
         /// 网面布料 / 打底无纺布 / 毡类 / 顶布 / 垫层

+ 3 - 6
JLHHJSvr/Helper/MattressHelper.cs

@@ -394,8 +394,7 @@ namespace JLHHJSvr.Helper
         }
         private void InitMattress(u_mattress mattress)
         {
-            var dept = new u_dept() { deptid = mattress.deptid.Value };
-            DbSqlHelper.SelectOne(cmd, dept, "pricelistid,profitrate,moneyrate,discount");
+            var dept = Cache.getdept(mattress.deptid.Value);
             //var profirate = new u_factory_profitrate() { deptid = mattress.deptid, bednettypeid_mattresstypeid = mattress.mattresstypeid, bednet_or_mattress = 1 };
             //DbSqlHelper.SelectOne(cmd, profirate, "profitrate");
             decimal profitrate = 0;
@@ -665,8 +664,7 @@ namespace JLHHJSvr.Helper
             AddFormulaKeyValue("底价", "if((【部门利润率】+【部门让利点数】/100)<> 0,【不含税出厂价】/(【部门利润率】+【部门让利点数】/ 100),0)");
             AddFormulaKeyValue("佣金", "【底价】/(1-(【佣金点数】-1))-【底价】");
 
-            var dept = new u_dept() { deptid = mattress.deptid.Value };
-            DbSqlHelper.SelectOne(cmd, dept, "pricelistid,taxes_rate");
+            var dept = Cache.getdept(mattress.deptid.Value);
             AddKeyValue("税金补偿", dept.taxes_rate);
 
             var bednetVarList = new List<u_bednet_var>();
@@ -1487,8 +1485,7 @@ namespace JLHHJSvr.Helper
             var mattressType = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
             DbSqlHelper.SelectOne(cmd, mattressType, "hrcost_formula,biandaiqty,zhizao_amt,guanli_rate,typerate,dannum1_rate,dannum2_rate,dannum3_rate,dannum4_rate");
 
-            var dept = new u_dept() { deptid = mattress.deptid.Value };
-            DbSqlHelper.SelectOne(cmd, dept, "pricelistid,managerate,com_profitrate,dannum1_rate,dannum2_rate,dannum3_rate,dannum4_rate");
+            var dept = Cache.getdept(mattress.deptid.Value);
             decimal? com_profitrate_dannum = 0;
 
             decimal _rate = 1;

+ 221 - 0
JLHHJSvr/Helper/SoftBedHelper.cs

@@ -0,0 +1,221 @@
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com.Model;
+using LJLib.DAL.SQL;
+using NPOI.SS.Formula.Functions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace JLHHJSvr.Helper
+{
+    internal class SoftBedHelper : HelperBase
+    {
+		/// <summary>
+		/// 获取软床报价单据
+		/// </summary>
+		/// <param name="billid"></param>
+		/// <param name="fields"></param>
+		/// <param name="bill"></param>
+        public u_softbed GetSoftBed(int billid,string fields)
+        {
+            fields = fields ?? @"softbed_id,softbed_code,softbed_name,deptid,create_time,create_by,mtrlmode,mtrltype,has_headboard,has_nightstand,has_bedframe,is_template,
+                                template_id,template_code,template_name,commission,taxes,other_rate,extras_cost,moneyrate,dscrp,costamt,nottax_factory_cost,nottax_dept_cost,
+                                dept_cost,foreign_cost";
+            var bill = new u_softbed() { softbed_id = billid };
+            DbSqlHelper.SelectOne(cmd, bill, fields);
+
+			return bill;
+        }
+
+		/// <summary>
+		/// 获取软床报价单据明细
+		/// </summary>
+		/// <param name="billid"></param>
+		/// <param name="fields"></param>
+		/// <param name="mxlist"></param>
+        public void GetSoftBedMxList(int billid,string fields,out List<u_softbed_mx> mxlist,out List<u_configure_codemx> codeList)
+        {
+            fields = fields ?? @"softbed_id,printid,pzid,pz_printid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
+                                useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,pzmxname";
+            mxlist = new List<u_softbed_mx>();
+
+            var selectStr = @"SELECT u_softbed_mx.softbed_id
+								,u_softbed_mx.printid
+								,u_softbed_mx.pzid
+								,u_softbed_mx.pz_printid
+								,u_softbed_mx.mtrlid
+								,u_softbed_mx.mtrlname
+								,u_softbed_mx.mtrlcode
+								,u_softbed_mx.mtrlmode
+								,u_softbed_mx.unit
+								,u_softbed_mx.has_type
+								,u_softbed_mx.allow_edit
+								,u_softbed_mx.cutting_length
+								,u_softbed_mx.cutting_width
+								,u_softbed_mx.cutting_qty
+								,u_softbed_mx.useqty
+								,u_softbed_mx.use_formula
+								,u_softbed_mx.use_formula_str
+								,u_softbed_mx.actual_useqty
+								,u_softbed_mx.loss_rate
+								,u_softbed_mx.price
+								,u_softbed_mx.price_formula
+								,u_softbed_mx.price_formula_str
+								,u_softbed_mx.cost_price
+								,u_softbed_mx.cost_amt
+								,u_configure_code.name AS pzname
+								,u_configure_codemx.namemx AS pzmxname
+							FROM u_softbed_mx
+								INNER JOIN u_configure_codemx ON u_configure_codemx.pzid = u_softbed_mx.pzid
+											AND u_configure_codemx.printid = u_softbed_mx.pz_printid
+								INNER JOIN u_configure_code ON u_configure_code.pzid = u_configure_codemx.pzid";
+
+            DbSqlHelper.SelectJoin(cmd, selectStr, "softbed_id = @billid", new Dictionary<string, object>() { { "@billid", billid } }, "printid,pz_printid", fields, 0, 0, mxlist);
+
+            codeList = mxlist.GroupBy(item => new { item.pzid, item.pz_pringid })
+                            .Select(group => new u_configure_codemx
+                            {
+                                pzid = group.Key.pzid,
+                                printid = group.Key.pz_pringid,
+                                pzname = group.First().pzname,
+                                namemx = group.First().pzmxname,
+                            })
+                            .ToList();
+        }
+
+		/// <summary>
+		/// 获取软床报价单据明细
+		/// </summary>
+		/// <param name="billid"></param>
+		/// <param name="fields"></param>
+		/// <param name="mxlist"></param>
+        public void GetSoftBedMxList(int billid, string fields, out List<u_softbed_mx> mxlist)
+        {
+            GetSoftBedMxList(billid, fields, out mxlist, out _);
+        }
+
+        /// <summary>
+        /// 根据部件配置项值获取对应BOM明细
+        /// </summary>
+        /// <param name="mxlist"></param>
+        /// <param name="codeList"></param>
+        public List<u_softbed_mx> GetSoftBedMxBomList(int deptid, List<u_configure_codemx> codeList)
+		{
+			var mxlist = new List<u_softbed_mx>();
+
+			foreach(var code in codeList)
+			{
+				var resultList = new List<u_configure_codemxbom>();
+				var outputFields = @"pzid,printid,pid,mtrlid,sonscale,sonscale_formula,mng_cost_rate,profit_rate,realqty,cost,cost_emp,cost_date,sonloss,sonloss_formula,
+									sondecloss,sondecloss_formula,deptid_scll,price,price_formula,mtrlcode,mtrlname,mtrlmode,unit,mtrlsectype,zxmtrlmode,usermtrlmode";
+				var selectStr = @"SELECT u_configure_codemxbom.pzid
+										,u_configure_codemxbom.printid
+										,u_configure_codemxbom.pid
+										,u_configure_codemxbom.mtrlid
+										,u_configure_codemxbom.sonscale
+										,u_configure_codemxbom.sonscale_formula
+										,u_configure_codemxbom.mng_cost_rate
+										,u_configure_codemxbom.profit_rate
+										,u_configure_codemxbom.realqty
+										,u_configure_codemxbom.cost
+										,u_configure_codemxbom.cost_emp
+										,u_configure_codemxbom.cost_date
+										,u_configure_codemxbom.sonloss
+										,u_configure_codemxbom.sonloss_formula
+										,u_configure_codemxbom.sondecloss
+										,u_configure_codemxbom.sondecloss_formula
+										,u_configure_codemxbom.deptid_scll
+										,u_configure_codemxbom.price
+										,u_configure_codemxbom.price_formula
+										,u_mtrldef.mtrlcode
+										,u_mtrldef.mtrlname
+										,u_mtrldef.mtrlmode
+										,u_mtrldef.unit
+										,u_mtrldef.mtrlsectype
+										,u_mtrldef.zxmtrlmode
+										,u_mtrldef.usermtrlmode
+									FROM u_configure_codemxbom
+									INNER JOIN u_mtrldef ON u_configure_codemxbom.mtrlid = u_mtrldef.mtrlid";
+				DbSqlHelper.SelectJoin(cmd,selectStr, 
+					"u_configure_codemxbom.pzid = @pzid AND u_configure_codemxbom.printid = @printid AND u_configure_codemxbom.deptid_scll = @deptid",
+					new Dictionary<string, object>() { { "@pzid", code.pzid }, { "@printid",code.printid},{ "@deptid",deptid } }, 
+					"u_configure_codemxbom.pid", outputFields, 0,0,resultList);
+
+				foreach(var item in resultList)
+				{
+					mxlist.Add(InitSoftBedMxFromBom(item));
+
+					// 
+				}
+			}
+
+
+			return null;
+        }
+
+		public u_softbed_mx InitSoftBedMxFromBom(u_configure_codemxbom bomItem)
+		{
+			var mx = new u_softbed_mx()
+			{
+				pzid = bomItem.pzid,
+				pz_pringid = bomItem.printid,
+				mtrlid = bomItem.mtrlid,
+				mtrlname = bomItem.mtrlname,
+				mtrlcode = bomItem.mtrlcode,
+				mtrlmode = bomItem.mtrlmode,
+				unit = bomItem.unit,
+				allow_edit = 0,
+				has_type = 1, // 1-床头、2-床头柜、4-床架
+				cutting_length = 0,
+				cutting_qty = 0,
+				cutting_width = 0,
+				useqty = bomItem.sonscale,
+				use_formula = "",
+				use_formula_str = bomItem.sonscale_formula,
+				actual_useqty = 0,
+				loss_rate = bomItem.sonloss,
+				price = bomItem.price,
+				price_formula = "",
+				price_formula_str = bomItem.price_formula,
+				cost_price = bomItem.cost,
+				cost_amt = 0
+			};
+
+			// 用量
+
+			// 实际用量: 用量 * 损耗
+			mx.actual_useqty = mx.useqty * mx.loss_rate;
+			// 成本金额: 实际用量 * 成本单价
+			mx.cost_amt = mx.actual_useqty * mx.cost_price;
+
+			return mx;
+        }
+
+        #region 通用公式方法
+        private string ConvertToEnglishSymbols(string input)
+        {
+            input = input.Replace("(", "(")
+                 .Replace(")", ")")
+                 .Replace(",", ",")
+                 .Replace("。", ".")
+                 .Replace(":", ":")
+                 .Replace(";", ";")
+                 .Replace("“", "\"")
+                 .Replace("”", "\"")
+                 .Replace("‘", "'")
+                 .Replace("’", "'");
+
+            return input;
+        }
+        private void FormatExpression(string expression)
+		{
+            expression = ConvertToEnglishSymbols(expression);
+
+
+        }
+        #endregion
+    }
+}

+ 7 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -108,6 +108,7 @@
     <Compile Include="Com\GetComputeMattressById.cs" />
     <Compile Include="Com\GetResetWiptype.cs" />
     <Compile Include="Com\GetMattressSubspecs.cs" />
+    <Compile Include="Com\GetSoftBedMxList.cs" />
     <Compile Include="Com\ImportMtrlPriceByExcel.cs" />
     <Compile Include="Com\JLH_FetchPrice.cs" />
     <Compile Include="Com\ChangePassword.cs" />
@@ -116,6 +117,7 @@
     <Compile Include="Com\Model\Sys_oplog.cs" />
     <Compile Include="Com\Model\u_bednet_interface.cs" />
     <Compile Include="Com\Model\u_bednet_interface_qd.cs" />
+    <Compile Include="Com\Model\u_configure_codemxbom.cs" />
     <Compile Include="Com\Model\u_mtrldef.cs" />
     <Compile Include="Com\Model\u_mtrltype_erp.cs" />
     <Compile Include="Com\Model\u_sc_workgroup_erp.cs" />
@@ -129,6 +131,8 @@
     <Compile Include="Com\Model\u_mattress_mx_extra.cs" />
     <Compile Include="Com\Model\u_mattress_mx_subspecs.cs" />
     <Compile Include="Com\Model\u_bcpcompare.cs" />
+    <Compile Include="Com\Model\u_softbed.cs" />
+    <Compile Include="Com\Model\u_softbed_mx.cs" />
     <Compile Include="Com\ReCalculateERPCost.cs" />
     <Compile Include="Com\RefreshBedNetInterface.cs" />
     <Compile Include="Com\RefreshBedNetInterfaceQd.cs" />
@@ -327,6 +331,7 @@
     <Compile Include="Excutor\GetFormulaVarListExcutor.cs" />
     <Compile Include="Excutor\GetResetWiptypeExcutor.cs" />
     <Compile Include="Excutor\GetMattressSubspecsExcutor.cs" />
+    <Compile Include="Excutor\GetSoftBedMxListExcutor.cs" />
     <Compile Include="Excutor\ImportMtrlPriceByExcelExcutor.cs" />
     <Compile Include="Excutor\JLH_FetchPriceExcutor.cs" />
     <Compile Include="Excutor\ChangePasswordExcutor.cs" />
@@ -438,10 +443,12 @@
       <DependentUpon>Form2.cs</DependentUpon>
     </Compile>
     <Compile Include="Helper\BedNetHelper.cs" />
+    <Compile Include="Helper\CacheHelper.cs" />
     <Compile Include="Helper\ERPHelper.cs" />
     <Compile Include="Helper\InterfaceHelper.cs" />
     <Compile Include="Helper\LogHelper.cs" />
     <Compile Include="Helper\MattressHelper.cs" />
+    <Compile Include="Helper\SoftBedHelper.cs" />
     <Compile Include="Helper\StringEx.cs" />
     <Compile Include="Helper\SysUserFileString.cs" />
     <Compile Include="ImgHelper\ImgHelper.cs" />

+ 18 - 0
JLHHJSvr/LJFrameWork/ljlib.cache/LJCache.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Threading;
+using JLHHJSvr.Com.Model;
 using LJLib.D;
 
 namespace LJLib
@@ -75,6 +76,23 @@ namespace LJLib
             }
         }
 
+        public bool TryGetValue(TKey key, out TValue value)
+        {
+            lock (syncRoot)
+            {
+                if(base.TryGetValue(key,out var entry))
+                {
+                    value = entry;
+
+                    SetDeadLine(key, DateTime.Now.AddMinutes(DefaultAddMinutes));
+                    return true;
+                }
+
+                value = default(TValue);
+                return false;
+            }
+        }
+
 
         #region 稀有成员实现逻辑
 

+ 1 - 0
JLHWEB/src/languages/modules/zh-cn/table.json

@@ -1543,6 +1543,7 @@
     "flag": "财务审核",
     "mattressname": "核价名称",
     "searchKw": "关键字",
+    "searchLike": "含糊查询",
     "searchErpMtrl": "L1物料编码",
     "foreign_cost": "外币价",
     "bi_foreign_cost": "报价金额",

+ 6 - 1
JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

@@ -506,9 +506,14 @@ export const useHooks = (t?: any) => {
     {
       field: "erp_mtrlcode",
       title: "L1物料编码",
+      table: "u_mattress",
       search: {
         el: "input",
-        key: "arg_search"
+        key: "arg_search",
+        titleKey: "searchLike",
+        props: {
+          placeholder: "唯一码/编码/名称"
+        }
       }
     },
     {

+ 8 - 1
JLHWEB/src/views/quote/mattressQuote/detail.vue

@@ -942,7 +942,8 @@ const {
   updateSubspecsTable,
   autoLoadExtraData,
   autoLoadExtraData_chai,
-  getAllFormulaList
+  getAllFormulaList,
+  setMxSpringQtyWidthAndLength
 } = useHooks(t);
 const { toExcelQuote, toExcelQuoteNew } = useHooksCpQuote();
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
@@ -2402,6 +2403,12 @@ const funcAfterMound = async (data: any) => {
         console.log("detail onMounted subSpecsRef.value getData_subSpecs:>> ", res, subSpecsData.value);
 
         updateSubspecsTable();
+
+        if (orderStatus.value == "copy") {
+          subSpecsData.value.forEach(t => {
+            setMxSpringQtyWidthAndLength({ row: t });
+          });
+        }
       });
 
       if (orderStatus.value == "copy") {

+ 2 - 1
JLHWEB/src/views/quote/mattressQuote/hooks/index.tsx

@@ -6256,6 +6256,7 @@ export const useHooks = (t?: any) => {
     getQuoteListMxData,
     autoLoadExtraData,
     autoLoadExtraData_chai,
-    getAllFormulaList
+    getAllFormulaList,
+    setMxSpringQtyWidthAndLength
   };
 };