Bläddra i källkod

核价后台:1、拆分床垫清单生成物料与清单接口;2、修复床垫清单配置中说明重复问题

chen_yjin 1 vecka sedan
förälder
incheckning
e0502de5e8

+ 3 - 3
JLHHJSvr/Com/CreatMtrlPf.cs

@@ -7,17 +7,17 @@ using LJLib.Net.SPI.Com;
 
 namespace JLHHJSvr.Com
 {
-    public sealed class CreatMtrlPfRequest : ILJRequest<CreatMtrlPfResponse>
+    public sealed class CreatMtrldefRequest : ILJRequest<CreatMtrldefResponse>
     {
         public override string GetApiName()
         {
-            return "CreatMtrlPf";
+            return "CreatMtrldef";
         }
         public string token { get; set; }
         public int mattressid { get; set; }
     }
 
-    public sealed class CreatMtrlPfResponse : LJResponse
+    public sealed class CreatMtrldefResponse : LJResponse
     {
         public u_mattress mattress { get; set; }
     }

+ 102 - 0
JLHHJSvr/Excutor/CreatMtrldefExcutor.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.Helper;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using Newtonsoft.Json.Linq;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class CreatMtrldefExcutor : ExcutorBase<CreatMtrldefRequest, CreatMtrldefResponse>
+    {
+        Dictionary<string, object> replacements = new Dictionary<string, object>();
+
+        protected override void ExcuteInternal(CreatMtrldefRequest request, object state, CreatMtrldefResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+            if (request.mattressid <= 0)
+            {
+                rslt.ErrMsg = "床垫id参数为空!";
+                return;
+            }
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                var mattress = new u_mattress();
+                if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", request.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") != 1)
+                {
+                    rslt.ErrMsg = "床垫报价单匹配失败";
+                    return;
+                }
+
+                var interfaceList = new List<u_mattress_interface>();
+                var selectStr = @"SELECT u_mattress_interface.mattressid
+	                            ,printid
+	                            ,itemname
+	                            ,bj_pzname
+	                            ,bj_namemx
+	                            ,actual_size
+	                            ,sb_craft
+	                            ,actual_size_sb
+	                            ,erp_pzid
+	                            ,ss_rate
+	                            ,ls_rate
+	                            ,bj_inputtype
+                                ,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";
+                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", request.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();
+
+                if (mattress.erp_mtrlid <= 0)
+                {
+                    mattress = l1Helper.GetMattressMsg(mattress, interfaceList);
+
+                    var errMsg = l1Helper.SaveMtrldef(mattress, interfaceList);
+                    if (!string.IsNullOrEmpty(errMsg))
+                    {
+                        rslt.ErrMsg = errMsg;
+                        return;
+                    }
+                }
+            }
+        }
+
+        /// <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; }
+        }
+    }
+}

+ 8 - 42
JLHHJSvr/Excutor/CreatMtrlPfExcutor.cs

@@ -11,11 +11,11 @@ using Newtonsoft.Json.Linq;
 
 namespace JLHHJSvr.Excutor
 {
-    internal sealed class CreatMtrlPfExcutor : ExcutorBase<CreatMtrlPfRequest, CreatMtrlPfResponse>
+    internal sealed class CreatPrdPfExcutor : ExcutorBase<CreatMtrldefRequest, CreatMtrldefResponse>
     {
         Dictionary<string, object> replacements = new Dictionary<string, object>();
 
-        protected override void ExcuteInternal(CreatMtrlPfRequest request, object state, CreatMtrlPfResponse rslt)
+        protected override void ExcuteInternal(CreatMtrldefRequest request, object state, CreatMtrldefResponse rslt)
         {
             var tokendata = BllHelper.GetToken(request.token);
             if (tokendata == null)
@@ -41,48 +41,9 @@ namespace JLHHJSvr.Excutor
                     return;
                 }
 
-                var interfaceList = new List<u_mattress_interface>();
-                var selectStr = @"SELECT u_mattress_interface.mattressid
-	                            ,printid
-	                            ,itemname
-	                            ,bj_pzname
-	                            ,bj_namemx
-	                            ,actual_size
-	                            ,sb_craft
-	                            ,actual_size_sb
-	                            ,erp_pzid
-	                            ,ss_rate
-	                            ,ls_rate
-	                            ,bj_inputtype
-                                ,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";
-                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", request.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();
-
-                if (mattress.erp_mtrlid <= 0)
-                {
-                    mattress = l1Helper.GetMattressMsg(mattress, interfaceList);
-
-                    var errMsg = l1Helper.SaveMtrldef(mattress, interfaceList);
-                    if (!string.IsNullOrEmpty(errMsg))
-                    {
-                        rslt.ErrMsg = errMsg;
-                        return;
-                    }
-                }
-
                 var mattress_interface_qd_list = new List<u_mattress_interface_qd>();
 
-                selectStr = @"SELECT u_mattress_interface_qd.mattressid 
+                var selectStr = @"SELECT u_mattress_interface_qd.mattressid 
 	                            ,u_mattress_interface_qd.printid 
 	                            ,u_mattress_interface_qd.itemname 
 	                            ,u_mattress_interface_qd.bj_pzname 
@@ -182,6 +143,11 @@ namespace JLHHJSvr.Excutor
 
                 l1Req.token = GlobalVar.ERP_TOKEN;
 
+                var l1Helper = HelperBase.GetHelper<ERPHelper>(cmd);
+                l1Helper.context = new HelperBase.Context() { tokendata = tokendata };
+
+                l1Helper.CheckLogin();
+
                 var l1Rslt = l1Helper.DoExecute("SavePrdPf", JObject.FromObject(l1Req));
                 rslt.ErrMsg = $"{l1Rslt.GetValue("ErrMsg")}";
             }

+ 2 - 2
JLHHJSvr/Excutor/DelMtrlPfExcutor.cs

@@ -17,11 +17,11 @@ using Newtonsoft.Json.Linq;
 
 namespace JLHHJSvr.Excutor
 {
-    internal sealed class DelMtrlPfExcutor : ExcutorBase<CreatMtrlPfRequest, CreatMtrlPfResponse>
+    internal sealed class DelMtrlPfExcutor : ExcutorBase<CreatMtrldefRequest, CreatMtrldefResponse>
     {
         Dictionary<string, object> replacements = new Dictionary<string, object>();
 
-        protected override void ExcuteInternal(CreatMtrlPfRequest request, object state, CreatMtrlPfResponse rslt)
+        protected override void ExcuteInternal(CreatMtrldefRequest request, object state, CreatMtrldefResponse rslt)
         {
             var tokendata = BllHelper.GetToken(request.token);
             if (tokendata == null)

+ 3 - 2
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -213,9 +213,10 @@ namespace JLHHJSvr
                 excutorManager.AddMap("SaveMattressInterface", typeof(SaveMattressInterfaceRequest), new SaveMattressInterfaceExcutor());// 床垫接口清单补充审核撤审
                 excutorManager.AddMap("RefreshMattressInterface", typeof(RefreshMattressInterfaceRequest), new RefreshMattressInterfaceExcutor());// 刷新床垫配置清单
                 excutorManager.AddMap("RefreshMattressInterfaceQd", typeof(RefreshMattressInterfaceQdRequest), new RefreshMattressInterfaceQdExcutor());// 刷新床垫清单
-                excutorManager.AddMap("CreatMtrlPf", typeof(CreatMtrlPfRequest), new CreatMtrlPfExcutor());// 生成L1清单
+                excutorManager.AddMap("CreatMtrldef", typeof(CreatMtrldefRequest), new CreatMtrldefExcutor());// 生成L1物料
                 excutorManager.AddMap("UpdateMtrlPrice", typeof(UpdateMtrlPriceRequest), new UpdateMtrlPriceExcutor());// 更新L1计划价
-                excutorManager.AddMap("DelMtrlPf", typeof(CreatMtrlPfRequest), new DelMtrlPfExcutor());// 删除L1清单
+                excutorManager.AddMap("DelMtrlPf", typeof(CreatMtrldefRequest), new DelMtrlPfExcutor());// 删除L1清单
+                excutorManager.AddMap("CreatPrdPf", typeof(CreatMtrldefRequest), new CreatPrdPfExcutor());// 生成L1清单
 
                 excutorManager.AddMap("GetERPMtrldefList", typeof(GetERPMtrldefListRequest), new GetERPMtrldefListExcutor());// 获取ERP物料资料
                 excutorManager.AddMap("GetERPConfigureList", typeof(GetERPConfigureListRequest), new GetERPConfigureListExcutor());// 获取ERP配置资料

+ 50 - 6
JLHHJSvr/Helper/InterfaceHelper.cs

@@ -13,6 +13,7 @@ using System.Collections.Generic;
 using System.Data.SqlClient;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Web;
 using System.Xml.Linq;
@@ -595,6 +596,7 @@ namespace JLHHJSvr.Helper
             var mianList1 = new HashSet<string> { "面裥绵", "底裥绵" };
             var mianList2 = new string[4] { "顶布裥棉1", "顶布裥棉2", "顶布裥棉3", "顶布裥棉4" };
             var mianList3 = new HashSet<string> { "普通大侧", "上下拼侧1", "上下拼侧2", "上下拼侧3", "左右拼侧1", "左右拼侧2", "左右拼侧3", "小侧1", "小侧2", "小侧3" };
+            var mianList4 = new HashSet<string> { "小侧1", "小侧2", "小侧3" };
 
             var name_arr = new string[5];
             foreach (var mx in mxlist)
@@ -610,28 +612,68 @@ namespace JLHHJSvr.Helper
                 }
             }
 
+            if (mianList4.Contains(key))
+            {
+                var _index = 0;
+                Regex regex = new Regex(@"\d+");
+                Match match = regex.Match(key);
+                _index = Convert.ToInt32(match.Value) - 1;
+                for (int i = 0; i < mianList4.Count; i++)
+                {
+                    XiaoCePeizhi.SetValue(name_arr[i], i, _index);
+                }
+            }
+
             var sb = new StringBuilder();
             foreach (var name2 in name_arr)
             {
                 sb.Append(name2);
             }
 
-            if (sb.Length > 0)
+            if (sb.Length > 0 || mianList2.Contains(key))
             {
                 if (!string.IsNullOrEmpty(chastrArr[1])) interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[1], 2, name_arr));
                 interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[2], 1, new string[] { "" }));
                 if (chastrArr.Length > 3) interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[3], 1, new string[] { "" }));
             }
 
-            foreach (var name in chastrArr)
+            if (mianList3.Contains(key)) { 
+                foreach (var name in chastrArr)
+                {
+                    if (string.IsNullOrEmpty(name)) continue;
+                    // 计算小测是否添加说明
+                    bool ifInert = true;
+                    if (mianList4.Contains(key))
+                    {
+                        ifInert = ifHasXiaoceMtrl();
+                    }
+                    if (name.Contains("说明") && ifInert)
+                    {
+                        interfaceList.Add(InserMattressInterfacePz(chastrArr[0], name, 1, new string[] { "" }));
+                    }
+                }
+            }
+
+        }
+        private bool ifHasXiaoceMtrl()
+        {
+            bool hasVal = false;
+            for (int i = 0; i < XiaoCePeizhi.GetLength(0); i++)
             {
-                if (string.IsNullOrEmpty(name)) continue;
-                if (name.Contains("说明"))
+                for (int j = 0; j < XiaoCePeizhi.GetLength(1); j++)
                 {
-                    interfaceList.Add(InserMattressInterfacePz(chastrArr[0], name, 1, new string[] { "" }));
+                    if (!string.IsNullOrEmpty(XiaoCePeizhi[i, j]))
+                    {
+                        hasVal = true;
+                        break;
+                    }
+                }
+                if (hasVal)
+                {
+                    break;
                 }
             }
-            
+            return hasVal;
         }
 
         private void SetFormulaTypeZeroPzName(u_mattress_mx_mtrl mx, string key, int[] powerArr, string[] name_arr)
@@ -1670,6 +1712,8 @@ namespace JLHHJSvr.Helper
         #region 全局变量
         // 储存顶布裥棉数据
         private string[,] DingBuLianMian = new string[4,5];
+        // 储存顶布裥棉数据
+        private string[,] XiaoCePeizhi = new string[3, 5];
         private enum PackType
         {
             压包 = 0,

+ 3 - 3
JLHHJSvr/JLHHJSvr.csproj

@@ -218,7 +218,7 @@
     <Compile Include="Com\SaveMattress.cs" />
     <Compile Include="Com\SaveMattressBcp.cs" />
     <Compile Include="Com\SaveMattressFormula.cs" />
-    <Compile Include="Com\CreatMtrlPf.cs" />
+    <Compile Include="Com\CreatMtrldef.cs" />
     <Compile Include="Com\SaveMattressInterface.cs" />
     <Compile Include="Com\SaveMattressType.cs" />
     <Compile Include="Com\SaveMtrlDef.cs" />
@@ -291,6 +291,7 @@
     <Compile Include="Excutor\CommonDynamicSelectExcutor.cs" />
     <Compile Include="Excutor\CopyMattressAuditedExcutor.cs" />
     <Compile Include="Excutor\CopyMtrlDefExcutor.cs" />
+    <Compile Include="Excutor\CreatPrdPfExcutor.cs" />
     <Compile Include="Excutor\DeleteMattressExtraTypeExcutor.cs" />
     <Compile Include="Excutor\DeleteMattressExtraExcutor.cs" />
     <Compile Include="Excutor\FormulaCheckExcutor.cs" />
@@ -299,7 +300,6 @@
     <Compile Include="Excutor\SaveMattressExtraExcutor.cs" />
     <Compile Include="Excutor\UnLockUserExcutor.cs" />
     <Compile Include="Excutor\UpdateMtrlPriceExcutor.cs" />
-    <Compile Include="Excutor\DelMtrlPfExcutor.cs" />
     <Compile Include="Excutor\DelCarListExcutor.cs" />
     <Compile Include="Excutor\DeleteBedNetAreaExcutor.cs" />
     <Compile Include="Excutor\DeleteBedNetExcutor.cs" />
@@ -374,7 +374,7 @@
     <Compile Include="Excutor\SaveMattressAuditingExcutor.cs" />
     <Compile Include="Excutor\SaveMattressBcpExcutor.cs" />
     <Compile Include="Excutor\SaveMattressFormulaExcutor.cs" />
-    <Compile Include="Excutor\CreatMtrlPfExcutor.cs" />
+    <Compile Include="Excutor\CreatMtrldefExcutor.cs" />
     <Compile Include="Excutor\SaveMattressInterfaceExcutor.cs" />
     <Compile Include="Excutor\SaveMattressTypeExcutor.cs" />
     <Compile Include="Excutor\SaveMtrlDefExcutor.cs" />