Selaa lähdekoodia

1、新增请求日志
2、床垫报价-保存的时候自动增加特殊工艺费用
3、复制配置窗口增加产品补充审核限制
4、优化获取缓存数据函数

MY 1 kuukausi sitten
vanhempi
commit
4de2d95610

+ 27 - 0
JLHHJSvr/Com/PingToken.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.BLL;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 上传文件
+    /// </summary>
+    public sealed class PingTokenRequest : ILJRequest<PingTokenResponse>
+    {
+        public string token { get; set; }
+        public override string GetApiName()
+        {
+            return "PingToken";
+        }
+    }
+
+    public sealed class PingTokenResponse : LJResponse
+    {
+        public string data { get; set; }
+    }
+}

+ 3 - 0
JLHHJSvr/DataStore/web_mattress_choose.xml

@@ -77,6 +77,9 @@ FROM u_mattress
 	<when notnull="@arg_erp_mtrlcode">
 		EXISTS (SELECT 1 FROM dbo.SC_SPLIT(@arg_erp_mtrlcode, ',') A WHERE A.Item <> '' AND (u_mattress.erp_mtrlcode LIKE '%'+LTRIM(RTRIM(A.Item))+'%'))
 	</when>
+	<when notnull="@js1_flag">
+		u_mattress.js1_flag = @js1_flag
+	</when>
   </where>
   <orderstr>
 	mattressid DESC

+ 33 - 0
JLHHJSvr/Excutor/PingTokenExcutor.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using Jayrock.Json;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using LJLib.SQLEX;
+using LJLib.Tools.Encry;
+using Newtonsoft.Json;
+using static NPOI.HSSF.Util.HSSFColor;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class PingTokenExcutor : ExcutorBase<PingTokenRequest, PingTokenResponse>
+    {
+        protected override void ExcuteInternal(PingTokenRequest request, object state, PingTokenResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+
+            rslt.data = JsonConvert.SerializeObject(tokendata);
+        }
+    }
+}

+ 1 - 1
JLHHJSvr/Excutor/SaveMattressExcutor.cs

@@ -141,7 +141,7 @@ namespace JLHHJSvr.Excutor
                 {
                     try
                     {
-                        mattressHelper.SaveMattressPro(_mattress, false);
+                        mattressHelper.SaveMattressPro(_mattress);
 
                         rslt.mattressid = _mattress.mattressid;
                         rslt.mattresscode = _mattress.mattresscode;

+ 3 - 2
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -16,6 +16,7 @@ using JLHHJSvr.Excutor;
 using JLHHJSvr.Excutor.APP;
 using JLHHJSvr.LJLib.HttpServer;
 using LJLib;
+using LJLib.TextLog;
 
 namespace JLHHJSvr
 {
@@ -57,7 +58,7 @@ namespace JLHHJSvr
         internal static void Init()
         {
             Trace.Listeners.Clear();
-            Trace.Listeners.Add(new LocalTraceListener(new SyncLogger(new Logger(App_Data))));
+            Trace.Listeners.Add(new LocalTraceListener(new SyncLogger(new Logger(App_Data)),new RequestLogger()));
 
             try
             {
@@ -135,7 +136,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("GetSysUserFileString", typeof(GetSysUserFileStringRequest), new GetSysUserFileStringExcutor());
                 excutorManager.AddMap("SetSysUserFileString", typeof(SetSysUserFileStringRequest), new SetSysUserFileStringExcutor());
                 excutorManager.AddMap("CommonDynamicSelect", typeof(CommonDynamicSelectRequest), new CommonDynamicSelectExcutor());
-
+                excutorManager.AddMap("PingToken", typeof(PingTokenRequest), new PingTokenExcutor());//没啥用
                 excutorManager.AddMap("GetFileByMd5", typeof(GetFileByMd5Request), new GetFileByMd5Excutor());//根据md5获取文件
                 excutorManager.AddMap("PostFile", typeof(PostFileRequest), new PostFileExcutor());//上传文件
                 excutorManager.AddMap("GetUserList", typeof(GetUserListRequest), new GetUserListExcutor());//获取用户列表

+ 5 - 2
JLHHJSvr/Helper/BedNetHelper.cs

@@ -2080,14 +2080,17 @@ namespace JLHHJSvr.Helper
             if (bednetMx.if_part == 1 && springList.Count > 0)
             {
 
-                if (!new List<string> { "3", "5", "7", "三", "三区", "五", "五区", "七", "七区" }.Contains(bednet.duo_qv_str))
+                if (!new List<string> { "2", "3", "5", "7", "三", "三区", "五", "五区", "七", "七区","左右区" }.Contains(bednet.duo_qv_str))
                 {
                     throw new LJCommonException("主规格的床网多区设置有误,请重新设置");
                     return;
                 }
 
                 var _duoQty = bednet.duo_qv_str;
-                if (new List<string> { "三", "三区" }.Contains(bednet.duo_qv_str))
+                if (new List<string> { "2", "左右", "左右区" }.Contains(bednet.duo_qv_str))
+                {
+                    _duoQty = "2";
+                } else if (new List<string> { "三", "三区" }.Contains(bednet.duo_qv_str))
                 {
                     _duoQty = "3";
                 } 

+ 23 - 12
JLHHJSvr/Helper/CacheHelper.cs

@@ -42,34 +42,45 @@ namespace JLHHJSvr.Helper
 
         #region 获取数据
         private static readonly Dictionary<Type, object> _cacheServiceRegistry = new Dictionary<Type, object>();
-        
-        public TEntity GetData<TEntity,TMapping>(object key)
-            where TEntity : class, new() 
-            where TMapping : new()
+
+        public TEntity GetData<TEntity, TMapping>(object key)
+        where TEntity : class, new()
+        where TMapping : new()
         {
+            // 找到接口中的 TKey
             var mappingType = typeof(TMapping);
-
             var iface = mappingType.GetInterfaces()
                 .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICacheMapping<,>));
-            if (iface == null) throw new InvalidOperationException($"{mappingType.Name} must implement ICacheMapping<TKey, TValue>");
 
-            var genericArgs = iface.GetGenericArguments();
-            var keyType = genericArgs[0];
+            if (iface == null)
+                throw new InvalidOperationException($"{mappingType.Name} must implement ICacheMapping<TKey, TValue>");
 
-            // 找到私有的强类型实现方法并用 MakeGenericMethod 构造
+            var keyType = iface.GetGenericArguments()[0];
+
+            // 获取私有泛型方法
             var method = typeof(CacheHelper).GetMethod(nameof(GetDataInternal), BindingFlags.Instance | BindingFlags.NonPublic);
             var gm = method.MakeGenericMethod(keyType, typeof(TEntity), mappingType);
 
             // 调用并返回(Invoke 返回 object)
-            return (TEntity) gm.Invoke(this, new object[] { key });
+            return (TEntity)gm.Invoke(this, new object[] { key });
         }
 
         private TValue GetDataInternal<TKey, TValue, TMapping>(object key)
             where TMapping : ICacheMapping<TKey, TValue>, new()
             where TValue : class, new()
         {
-            var mapping = new TMapping();
-            return mapping.GetInstance(cmd, (TKey)key);
+            var mappingType = typeof(TMapping);
+
+            if (!_cacheServiceRegistry.TryGetValue(mappingType, out var serviceObj))
+            {
+                // 没有就创建
+                var cacheService = new CacheService<TKey, TValue>(new GenericLoader<TKey, TValue>(new TMapping()));
+                _cacheServiceRegistry.Add(mappingType, cacheService);
+                serviceObj = cacheService;
+            }
+
+            var service = (ICacheService<TKey, TValue>)serviceObj;
+            return service.Get(cmd, (TKey)key);
         }
         #endregion
     }

+ 32 - 77
JLHHJSvr/Helper/MattressHelper.cs

@@ -2132,6 +2132,7 @@ namespace JLHHJSvr.Helper
                 mattress_copy.extras_cost = mattress.extras_cost;
                 mattress_copy.moneyrate = mattress.moneyrate;
                 mattress_copy.discount = mattress.discount;
+                mattress_copy.createby = mattress.createby;
 
                 var mattressMxMtrlList = GetMattressMxMtrl(mattress.mattressid);
 
@@ -2167,76 +2168,50 @@ namespace JLHHJSvr.Helper
                     throw new LJCommonException(e.Message);
                 }
 
-                SaveMattress(mattress_copy, mattressMxMtrlList, mattressMxExtra1List, mattressMxExtra2List, true, mattress.createby);
-                CopyMattressInterface(mattress.mattressid,mattress_copy.mattressid);
-
                 var mattressSubspecs = GetMattressSubspecs(mattress.mattressid);
-                foreach (var sub in mattressSubspecs)
-                {
-                    var submattress_copy = GetMattress(sub.mattressid);
-                    submattress_copy.parentid = mattress_copy.mattressid;
-                    submattress_copy.deptid = mattress_copy.deptid;
-                    submattress_copy.createby = mattress_copy.createby;
-
-                    var mattressMxList = GetMattressMxMtrl(sub.mattressid);
-
-                    foreach (var submx in mattressMxList)
-                    {
-                        submx.mattressid = 0;
-                        submx.mattressmxid = 0;
-                    }
-
-                    var mattressMxExtra1 = GetMattressMxExtra(sub.mattressid, 1);
 
-                    foreach (var mx in mattressMxExtra1)
-                    {
-                        mx.mattressid = 0;
-                        mx.mattressmxid = 0;
-                    }
-
-                    var mattressMxExtra2 = GetMattressMxExtra(sub.mattressid, 2);
-
-                    foreach (var mx in mattressMxExtra2)
-                    {
-                        mx.mattressid = 0;
-                        mx.mattressmxid = 0;
-                    }
+                foreach(var sub in mattressSubspecs)
+                {
+                    sub.copy_id = sub.mattressid;
+                    sub.createby = mattress.createby;
+                    sub.mattressid = 0;
 
-                    // 判断copy_bedNet.bednetcode是否存在@@字符串,如果存在,则删除@@后面的字符串,包括@@
-                    if (submattress_copy.mattresscode.IndexOf("@@") > -1)
+                    if (sub.mattresscode.IndexOf("@@") > -1)
                     {
-                        submattress_copy.mattresscode = submattress_copy.mattresscode.Substring(submattress_copy.mattresscode.IndexOf("@@"));
+                        sub.mattresscode = sub.mattresscode.Substring(sub.mattresscode.IndexOf("@@"));
                     }
 
-                    submattress_copy.mattresscode += " @@";
-                    submattress_copy.mattresscode += DateTime.Now.ToString("yyyMMdd_mmhhss");
+                    sub.mattresscode += " @@";
+                    sub.mattresscode += DateTime.Now.ToString("yyyMMdd_mmhhss");
 
-                    if (submattress_copy.mattressrelcode.IndexOf("@@") > -1)
+                    if (sub.mattressrelcode.IndexOf("@@") > -1)
                     {
-                        submattress_copy.mattressrelcode = submattress_copy.mattressrelcode.Substring(submattress_copy.mattressrelcode.IndexOf("@@"));
+                        sub.mattressrelcode = sub.mattressrelcode.Substring(sub.mattressrelcode.IndexOf("@@"));
                     }
 
-                    submattress_copy.mattressrelcode += " @@";
-                    submattress_copy.mattressrelcode += DateTime.Now.ToString("yyyMMdd_mmhhss");
-
-                    submattress_copy.mattressid = 0;
+                    sub.mattressrelcode += " @@";
+                    sub.mattressrelcode += DateTime.Now.ToString("yyyMMdd_mmhhss");
 
-                    submattress_copy.mattress_width = mattress.mattress_width > 0 ? mattress.mattress_width : submattress_copy.mattress_width;
-                    submattress_copy.mattress_length = mattress.mattress_length > 0 ? mattress.mattress_length : submattress_copy.mattress_length;
+                    sub.mattress_width = mattress.mattress_width > 0 ? mattress.mattress_width : sub.mattress_width;
+                    sub.mattress_length = mattress.mattress_length > 0 ? mattress.mattress_length : sub.mattress_length;
 
-                    if (!"维持原状".Equals(mattress.area)) submattress_copy.area = mattress.area;
-                    if (!"维持原状".Equals(mattress.cabinet_type)) submattress_copy.cabinet_type = mattress.cabinet_type;
+                    if (!"维持原状".Equals(mattress.area)) sub.area = mattress.area;
+                    if (!"维持原状".Equals(mattress.cabinet_type)) sub.cabinet_type = mattress.cabinet_type;
 
-                    if (mattress.packtype == 0) submattress_copy.packqty = mattress.packqty;
-
-                    submattress_copy.js1_flag = 0;
-                    submattress_copy.js1_auditingrep = string.Empty;
-                    submattress_copy.js1_auditingdate = null;
+                    if (mattress.packtype == 0) sub.packqty = mattress.packqty;
+                }
 
-                    submattress_copy.xd_flag = 0;
+                var _mattress = ObjectHelper.DeepCopy(mattress_copy);
+                _mattress.mxList = mattressMxMtrlList;
+                _mattress.extraList = mattressMxExtra1List;
+                _mattress.extraCostList = mattressMxExtra2List;
+                _mattress.subspecsList = mattressSubspecs;
+                SaveMattressPro(_mattress);
+                CopyMattressInterface(mattress_copy.mattressid,mattress.mattressid);
 
-                    SaveMattress(submattress_copy, mattressMxList, mattressMxExtra1, mattressMxExtra2, true, mattress.createby);
-                    CopyMattressInterface(sub.mattressid,submattress_copy.mattressid);
+                foreach (var sub in mattressSubspecs)
+                {
+                    CopyMattressInterface(sub.copy_id.Value,sub.mattressid);
                 }
 
                 foreach (var mx in mxlist)
@@ -2829,7 +2804,7 @@ namespace JLHHJSvr.Helper
                 AutoInit.AutoInitS(mattress);
                 // 
                 mattress.createtime = context.opdate;
-                if (mattress.parentid == null || mattress.parentid == 0) mattress.createby = context.tokendata.username;
+                if (string.IsNullOrEmpty(mattress.createby)) mattress.createby = context.tokendata.username;
 
                 mattress.mattressid = BllHelper.GetID(cmd, "u_mattress");
                 fields += ",mattressid, createtime, createby";
@@ -3201,26 +3176,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("卷包直径有误,卷包包装必须有卷包直径!");
             }
 
-            // 特殊工艺数量汇总
-            if(mattress.extraList != null && mattress.extraList.Count > 0)
-            {
-                foreach(var mx in mattress.extraList)
-                {
-                    var matchedItems = mattress.mxList
-                    .Where(t => t != null &&
-                               !string.IsNullOrEmpty(t.mtrlname) &&
-                               !string.IsNullOrEmpty(mx.extraname) &&
-                               t.mtrlname.Trim().Equals(mx.extraname.Trim()))
-                    .ToList();
-
-                    if (matchedItems.Any())
-                    {
-                        mx.qty = matchedItems.Sum(t => t?.qty ?? 0);
-                    }
-
-                    if (mx.qty == null || mx.qty == 0) mx.qty = 1;
-                }
-            }
+            InitMattressExtra(mattress.mxList, mattress.extraList);
         }
         /// <summary>
         /// 初始化床垫保存自动生成特殊工艺
@@ -3278,7 +3234,6 @@ namespace JLHHJSvr.Helper
                 }
                 extraList.Add(extra);
             }
-
         }
         #endregion
 

+ 3 - 1
JLHHJSvr/JLHHJSvr.csproj

@@ -142,6 +142,7 @@
     <Compile Include="Com\Model\u_softbed.cs" />
     <Compile Include="Com\Model\u_softbed_formula.cs" />
     <Compile Include="Com\Model\u_softbed_mx.cs" />
+    <Compile Include="Com\PingToken.cs" />
     <Compile Include="Com\ReCalculateERPCost.cs" />
     <Compile Include="Com\RefreshBedNetInterface.cs" />
     <Compile Include="Com\RefreshBedNetInterfaceQd.cs" />
@@ -355,6 +356,7 @@
     <Compile Include="Excutor\ImportMtrlPriceByExcelExcutor.cs" />
     <Compile Include="Excutor\JLH_FetchPriceExcutor.cs" />
     <Compile Include="Excutor\ChangePasswordExcutor.cs" />
+    <Compile Include="Excutor\PingTokenExcutor.cs" />
     <Compile Include="Excutor\ReCalculateERPCostExcutor.cs" />
     <Compile Include="Excutor\RefreshBedNetInterfaceExcutor.cs" />
     <Compile Include="Excutor\RefreshBedNetInterfaceQdExcutor.cs" />
@@ -620,7 +622,7 @@
     <Compile Include="StreamHelper\StreamHelper.cs" />
     <Compile Include="TextLog\ILogger.cs" />
     <Compile Include="TextLog\Logger.cs" />
-    <Compile Include="TextLog\ReuestLogger.cs" />
+    <Compile Include="TextLog\RequestLogger.cs" />
     <Compile Include="TextLog\SyncLogger.cs" />
     <Compile Include="Tools\AutoInit.cs" />
     <Compile Include="Tools\CalculateFormula.cs" />

+ 2 - 0
JLHHJSvr/LJLib.Net.SPI.Server/ExcutorBase.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Diagnostics;
 using LJLib.Net.SPI.Com;
+using Newtonsoft.Json;
 
 namespace LJLib.Net.SPI.Server
 {
@@ -23,6 +24,7 @@ namespace LJLib.Net.SPI.Server
             try
             {
                 T1 req = request as T1;
+                if (req != null) Trace.Write($"{typeof(T1).Name}请求报文:\r\n{JsonConvert.SerializeObject(req)}", "Request");
                 if (req == null)
                 {
                     rslt.ErrMsg = "request不能转换成类型" + typeof(T1).Name;

+ 51 - 0
JLHHJSvr/LocalLog/LocalTraceListener.cs

@@ -14,8 +14,10 @@ namespace LJLib.LocalLog
         private object _syncRoot = new object();
 
         private ILogger _logger = null;
+        private ILogger _requestLogger = null;
         public bool HasStack { get; set; }
         public LocalTraceListener(ILogger logger) { _logger = logger; }
+        public LocalTraceListener(ILogger logger, ILogger requestLogger) { _logger = logger; _requestLogger = requestLogger; }
         public override void Write(string message)
         {
             lock (_syncRoot)
@@ -56,5 +58,54 @@ namespace LJLib.LocalLog
         {
             Write(message);
         }
+
+        public override void Write(string message, string category)
+        {
+            try
+            {
+                if (HasStack)
+                {
+                    var stack = new StackTrace().ToString();
+                    var key = stack;
+
+                    var index = message.IndexOf(": ");
+                    if (index >= 0)
+                    {
+                        key += message.Substring(0, index);
+                    }
+
+                    bool shouldWrite = false;
+                    lock (_syncRoot)
+                    {
+                        if (!oldStack.ContainsKey(key)) // 避免重复堆栈
+                        {
+                            oldStack.Add(key, 1);
+                            shouldWrite = true;
+                        }
+                    }
+
+                    if (shouldWrite)
+                    {
+                        GetLogger(category).WriteLog(message + "\r\n" + stack);
+                    }
+                }
+                else
+                {
+                    GetLogger(category).WriteLog(message);
+                }
+            }
+            catch (Exception ex)
+            {
+                System.Diagnostics.Trace.WriteLine(ex.ToString(), "LoggerError");
+            }
+        }
+        private ILogger GetLogger(string category)
+        {
+            if (string.Equals(category, "Request", StringComparison.OrdinalIgnoreCase))
+            {
+                return _requestLogger ?? _logger;
+            }
+            return _logger;
+        }
     }
 }

+ 2 - 2
JLHHJSvr/TextLog/ReuestLogger.cs

@@ -4,12 +4,12 @@ using System.IO;
 
 namespace LJLib.TextLog
 {
-    internal class ReuestLogger : ILogger
+    internal class RequestLogger : ILogger
     {
         private readonly string _logDir;
         private readonly object _syncRoot = new object();
 
-        public ReuestLogger(string logDir = null)
+        public RequestLogger(string logDir = null)
         {
             // 默认目录为执行目录下的 log 文件夹
             _logDir = logDir ?? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log");

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

@@ -2161,6 +2161,7 @@ export const useHooks = (t?: any) => {
     return new Promise((resolve, reject) => {
       let _params = {
         arg_deptid: state.mainData[0].deptid,
+        js1_flag: 1,
         ...params
       };
       state.MattressDialogProps = {