Bläddra i källkod

1、新增登录失败限制机制
2、新增公式检测,公式参数获取接口

MY 1 månad sedan
förälder
incheckning
3185135db6

+ 27 - 0
JLHHJSvr/BLL/UserHelper.cs

@@ -9,6 +9,7 @@ using LJLib.DAL.SQL;
 using LJLib.Tools.DEncrypt;
 using JLHHJSvr.LJException;
 using System.Linq;
+using DirectService.Tools;
 
 namespace JLHHJSvr.BLL
 {
@@ -290,5 +291,31 @@ namespace JLHHJSvr.BLL
 
             return rslt;
         }
+        /// <summary>
+        /// 判断用户是否已锁定
+        /// </summary>
+        /// <param name="user"></param>
+        /// <returns></returns>
+        public static bool IsLocked(u_user_jlhprice user)
+        {
+            // 检查是否在最近一个月内累计5次错误
+            var cutoff = DateTime.UtcNow.AddMonths(-1);
+            return user.empid != 0 && user.access_failed_count >= 5
+                    && user.last_failed_attempt_time >= cutoff;
+        }
+        /// <summary>
+        /// 账号解锁
+        /// </summary>
+        /// <param name="user"></param>
+        /// <returns></returns>
+        public static bool UnLock(SqlCommand cmd, List<int> empids)
+        {
+            if (empids == null && empids.Count <= 0) return false;
+            cmd.CommandText = $@"UPDATE u_user_jlhprice SET access_failed_count = 0,
+                                    last_failed_attempt_time = GETUTCDATE()
+                                WHERE u_user_jlhprice.empid IN {ListEx.getString(empids)}";
+            cmd.Parameters.Clear();
+            return cmd.ExecuteNonQuery() == 1;
+        }
     }
 }

+ 23 - 0
JLHHJSvr/Com/FormulaCheck.cs

@@ -0,0 +1,23 @@
+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 FormulaCheckRequest : ILJRequest<FormulaCheckResponse>
+    {
+        public override string GetApiName()
+        {
+            return "FormulaCheck";
+        }
+        public string token { get; set; }
+        public string formula { get; set; }
+    }
+
+    public sealed class FormulaCheckResponse : LJResponse
+    {
+    }
+}

+ 23 - 0
JLHHJSvr/Com/GetFormulaVarList.cs

@@ -0,0 +1,23 @@
+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 GetFormulaVarListRequest : ILJRequest<GetFormulaVarListResponse>
+    {
+        public override string GetApiName()
+        {
+            return "GetFormulaVarList";
+        }
+        public string token { get; set; }
+    }
+
+    public sealed class GetFormulaVarListResponse : LJResponse
+    {
+        public List<Recursion2> recursionList { get; set; }
+    }
+}

+ 27 - 0
JLHHJSvr/Com/UnLockUser.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 获取用户列表
+    /// </summary>
+    public sealed class UnLockUserRequest : ILJRequest<UnLockUserResponse>
+    {
+        public override string GetApiName()
+        {
+            return "UnLockUser";
+        }
+        public string token { get; set; }
+        public List<int> useridList { get; set; }
+    }
+
+    public sealed class UnLockUserResponse : LJResponse
+    {
+    }
+}

+ 10 - 0
JLHHJSvr/DBA/DBModle/u_user_jlhprice.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using JLHHJSvr.BLL;
 using LJLib.DAL.SQL;
 
 namespace JLHHJSvr.DBA.DBModle
@@ -32,5 +33,14 @@ namespace JLHHJSvr.DBA.DBModle
         public string pricelist_seestr { get; set; }
         public string pricelist_editstr { get; set; }
         public int usermode { get; set; }
+        public int access_failed_count { get; set; }
+        public DateTime? last_failed_attempt_time { get; set; }
+        public bool isLocked
+        {
+            get
+            {
+                return UserHelper.IsLocked(this);
+            }
+        }
     }
 }

+ 175 - 0
JLHHJSvr/DataStore/_Mapper_fixedParamters.xml

@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<data>
+  <json>
+    [
+      { label: "床垫宽", value: 1 },
+      { label: "床垫长", value: 1 },
+      { label: "床垫高", value: 1 },
+      { label: "规格宽", value: 1 },
+      { label: "规格长", value: 1 },
+      { label: "规格高", value: 1 },
+      { label: "双簧", value: 1 },
+      { label: "弹叉数量", value: 1 },
+      { label: "包装方式", value: 1 },
+      { label: "包装数量", value: 1 },
+      { label: "运输方式", value: 1 },
+      { label: "包装材料", value: 1 },
+      { label: "床网类别", value: 1 },
+      { label: "工厂利润率", value: 1 },
+      { label: "部门利润率", value: 1 },
+      { label: "佣金点数", value: 1 },
+      { label: "额外点数", value: 1 },
+      { label: "额外费用", value: 1 },
+      { label: "汇率", value: 1 },
+      { label: "税率", value: 1 },
+      { label: "卷包", value: 1 },
+      { label: "大小单系数", value: 1 },
+      { label: "大小单类型", value: 1 },
+      { label: "弹簧排列个数-宽", value: 1 },
+      { label: "弹簧排列个数-长", value: 1 },
+      { label: "弹簧计算个数(宽)", value: 1 },
+      { label: "弹簧计算个数(长)", value: 1 },
+      { label: "边铁条数", value: 1 },
+      { label: "条数", value: 1 },
+      { label: "弹簧重/个", value: 1 },
+      { label: "弹簧重", value: 1 },
+      { label: "弹簧单价", value: 1 },
+      { label: "四周口袋-排数", value: 1 },
+      { label: "四周口袋", value: 1 },
+      { label: "四周加硬-排数", value: 1 },
+      { label: "四周加硬", value: 1 },
+      { label: "弹簧克重", value: 1 },
+      { label: "床网高", value: 1 },
+      { label: "口袋弹簧高度", value: 1 },
+      { label: "口袋弹簧心径", value: 1 },
+      { label: "加硬弹簧单价", value: 1 },
+      { label: "口袋弹簧单价", value: 1 },
+      { label: "中心直径", value: 1 },
+      { label: "线径MM", value: 1 },
+      { label: "高度CM", value: 1 },
+      { label: "口径CM", value: 1 },
+      { label: "圈数", value: 1 },
+      { label: "克重KG", value: 1 },
+      { label: "卷排列宽", value: 1 },
+      { label: "卷排列长", value: 1 },
+      { label: "排列宽", value: 1 },
+      { label: "排列长", value: 1 },
+      { label: "弹簧材料总成本", value: 1 },
+      { label: "蛇线材料成本", value: 1 },
+      { label: "弹簧总人工成本", value: 1 },
+      { label: "四周口袋弹簧成本", value: 1 },
+      { label: "四周口袋无纺布成本", value: 1 },
+      { label: "四周加硬材料成本", value: 1 },
+      { label: "四周加硬人力成本", value: 1 },
+      { label: "入袋无纺布材料成本", value: 1 },
+      { label: "胶水材料成本", value: 1 },
+      { label: "底面无纺布材料成本", value: 1 },
+      { label: "边铁人力成本", value: 1 },
+      { label: "边铁材料成本", value: 1 },
+      { label: "C钉/夹码材料成本", value: 1 },
+      { label: "C钉/夹码人力成本", value: 1 },
+      { label: "海绵包边材料成本", value: 1 },
+      { label: "海绵包边人力成本", value: 1 },
+      { label: "填充海绵成本", value: 1 },
+      { label: "封边材料成本", value: 1 },
+      { label: "封边人力成本", value: 1 },
+      { label: "弹叉材料成本", value: 1 },
+      { label: "弹叉人力成本", value: 1 },
+      { label: "胶条/包角材料成本", value: 1 },
+      { label: "胶条/包角人力成本", value: 1 },
+      { label: "上垫层物料成本", value: 1 },
+      { label: "下垫层物料成本", value: 1 },
+      { label: "上垫层人力成本", value: 1 },
+      { label: "下垫层人力成本", value: 1 },
+      { label: "包装总成本", value: 1 },
+      { label: "包装人工成本", value: 1 },
+      { label: "外销加点", value: 1 },
+      { label: "总材料成本", value: 1 },
+      { label: "总人力费用", value: 1 },
+      { label: "FOB", value: 1 },
+      { label: "车间成本", value: 1 },
+      { label: "不含税出厂价", value: 1 },
+      { label: "部门不含税价", value: 1 },
+      { label: "税金", value: 1 },
+      { label: "部门含税价", value: 1 },
+      { label: "外币价", value: 1 },
+      { label: "钢丝重量", value: 1 },
+      { label: "边铁重量", value: 1 },
+      { label: "计划价", value: 1 },
+      { label: "四周加硬重量", value: 1 },
+      { label: "入袋无纺布重量", value: 1 },
+      { label: "面底无纺布重量", value: 1 },
+      { label: "上/下垫层重量", value: 1 },
+      { label: "C钉/夹码重量", value: 1 },
+      { label: "海绵包边重量", value: 1 },
+      { label: "填充海绵重量", value: 1 },
+      { label: "封边材料重量", value: 1 },
+      { label: "弹叉材料重量", value: 1 },
+      { label: "特殊工艺费用", value: 1 },
+      { label: "压包数量", value: 1 },
+      { label: "卷包直径", value: 1 },
+      { label: "顶布裥棉外布套做法", value: 1 },
+      { label: "面料外布套做法", value: 1 },
+      { label: "内布套上覆", value: 1 },
+      { label: "内布套侧爱", value: 1 },
+      { label: "内布套下覆", value: 1 },
+      { label: "面料上覆", value: 1 },
+      { label: "面料侧爱", value: 1 },
+      { label: "面料下覆", value: 1 },
+      { label: "面拆", value: 1 },
+      { label: "中拆", value: 1 },
+      { label: "底拆", value: 1 },
+      { label: "部门让利点数", value: 1 },
+      { label: "折扣率", value: 1 },
+      { label: "大柜-普通地区-地区FOB费用", value: 1 },
+      { label: "大柜-特定地区-地区FOB费用", value: 1 },
+      { label: "小柜-普通地区-地区FOB费用", value: 1 },
+      { label: "小柜-特定地区-地区FOB费用", value: 1 },
+      { label: "大柜-柜型立方数", value: 1 },
+      { label: "小柜-柜型立方数", value: 1 },
+      { label: "大柜-柜型米数", value: 1 },
+      { label: "小柜-柜型米数", value: 1 },
+      { label: "木托方式", value: 1 },
+      { label: "物料单价", value: 1 },
+      { label: "物料克重", value: 1 },
+      { label: "幅宽", value: 1 },
+      { label: "数量", value: 1 },
+      { label: "物料厚度", value: 1 },
+      { label: "固定厚度", value: 1 },
+      { label: "厚度", value: 1 },
+      { label: "按面积单价", value: 1 },
+      { label: "物料名称", value: 1 },
+      { label: "物料收缩率", value: 1 },
+      { label: "垫层", value: 1 },
+      { label: "布料幅宽", value: 1 },
+      { label: "布套高", value: 1 },
+      { label: "收缩率", value: 1 },
+      { label: "纸箱宽", value: 1 },
+      { label: "垫层数量", value: 1 },
+      { label: "制造费用", value: 1 },
+      { label: "管理费点", value: 1 },
+      { label: "人工费用", value: 1 },
+      { label: "边带条数", value: 1 },
+      { label: "边带费用", value: 1 },
+      { label: "材料成本", value: 1 },
+      { label: "散单金额", value: 1 },
+      { label: "拼侧数量", value: 1 },
+      { label: "大侧数量", value: 1 },
+      { label: "工艺点数", value: 1 },
+      { label: "内布套简单款", value: 1 },
+      { label: "内布套复杂款", value: 1 },
+      { label: "内布套点数", value: 1 },
+      { label: "拆装数量", value: 1 },
+      { label: "拆装点数", value: 1 },
+      { label: "海绵扣点", value: 1 },
+      { label: "大小单", value: 1 },
+      { label: "大小单类型", value: 1 },
+      { label: "大小单系数", value: 1 },
+      { label: "款式系数", value: 1 },
+      { label: "管理费用点", value: 1 },
+      { label: "公司利润点", value: 1 },
+      { label: "底价", value: 1 },
+      { label: "佣金", value: 1 }
+    ]
+  </json>
+</data>

+ 71 - 0
JLHHJSvr/Excutor/FormulaCheckExcutor.cs

@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text.RegularExpressions;
+using DirectService.Tools;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.LJFramework.Tools;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using Newtonsoft.Json.Linq;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class FormulaCheckExcutor : ExcutorBase<FormulaCheckRequest, FormulaCheckResponse>
+    {
+        protected override void ExcuteInternal(FormulaCheckRequest request, object state, FormulaCheckResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+
+            if(string.IsNullOrEmpty(request.formula))
+            {
+                rslt.ErrMsg = "公式为空,请检查!";
+                return;
+            }
+            
+            var replacements = new Dictionary<string, decimal>();
+
+            var formula = request.formula.Replace("(", "(")
+                 .Replace(")", ")")
+                 .Replace(",", ",")
+                 .Replace("。", ".")
+                 .Replace(":", ":")
+                 .Replace(";", ";")
+                 .Replace("“", "\"")
+                 .Replace("”", "\"")
+                 .Replace("‘", "'")
+                 .Replace("’", "'");
+            // 定义正则表达式模式,匹配包含【】的内容
+            string pattern = @"【(.*?)】";
+            Regex regex = new Regex(pattern);
+            MatchCollection matches = regex.Matches(formula);
+            foreach (Match match in matches)
+            {
+                if (!replacements.ContainsKey(match.Value))
+                {
+                    replacements.Add(match.Value, 999M);
+                }
+            }
+
+            // 相关变量会默认代入999,主要验证运算逻辑是否合理即可。避免除数为0即可
+            foreach (var item in replacements)
+            {
+                formula = formula.Replace(item.Key, "(" + item.Value + ")");
+            }
+
+            if (LJExprParser.CheckFormula(formula,out var arg_msg))
+            {
+                rslt.ErrMsg = $"解析表达式{request.formula}失败:{arg_msg}";
+            }
+        }
+    }
+}

+ 94 - 0
JLHHJSvr/Excutor/GetFormulaVarListExcutor.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using Newtonsoft.Json.Linq;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class GetFormulaVarListExcutor : ExcutorBase<GetFormulaVarListRequest, GetFormulaVarListResponse>
+    {
+        protected override void ExcuteInternal(GetFormulaVarListRequest request, object state, GetFormulaVarListResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+
+            rslt.recursionList = new List<Recursion2>();
+            // 变量定义
+            var varRecusionChilds = new List<Recursion2>();
+            rslt.recursionList.Add(new Recursion2() { text = "变量定义", value = 0, children = varRecusionChilds });
+            // 工艺加点设置
+            var workShipChilds = new List<Recursion2>();
+            rslt.recursionList.Add(new Recursion2() { text = "工艺加点设置", value = 0, children = workShipChilds });
+            // 固定参数
+            var fixedVarChilds = new List<Recursion2>();
+            rslt.recursionList.Add(new Recursion2() { text = "固定变量", value = 0, children = fixedVarChilds });
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                var selectStr = string.Empty;
+                var param = new Dictionary<string, object>();
+                var outputFields = string.Empty;
+
+                // 变量定义
+                selectStr = "SELECT varname FROM u_bednet_var";
+                outputFields = "varname";
+                var bednetVarList = new List<u_bednet_var>();
+                DbSqlHelper.SelectJoin(cmd, selectStr, null, param, "varid", outputFields, 0, 0, bednetVarList);
+                foreach(var child in bednetVarList)
+                {
+                    varRecusionChilds.Add(new Recursion2()
+                    {
+                        text = child.varname,
+                        value = 1
+                    });
+                }
+
+                // 加点工艺
+                selectStr = "SELECT workmanshipname FROM u_workmanship_add";
+                outputFields = "workmanshipname";
+                var workshipList = new List<u_workmanship_add>();
+                DbSqlHelper.SelectJoin(cmd, selectStr, null, param, "workmanshipid", outputFields, 0, 0, workshipList);
+                foreach (var child in workshipList)
+                {
+                    workShipChilds.Add(new Recursion2()
+                    {
+                        text = child.workmanshipname,
+                        value = 1
+                    });
+                }
+            }
+
+            var queryparams = new JObject();
+            var commonExcutor = new CommonDynamicSelectExcutor();
+            var commonRequest = new CommonDynamicSelectRequest()
+            {
+                token = request.token,
+                dsname = "_Mapper_fixedParamters",
+                queryparams = queryparams
+            };
+
+            var billResponse = commonExcutor.Excute(commonRequest, state) as CommonDynamicSelectResponse;
+            if (billResponse != null && billResponse.datatable != null && billResponse.datatable.Any())
+            {
+                var fiexdList = billResponse.datatable;
+                foreach(var item in fiexdList)
+                {
+                    fixedVarChilds.Add(new Recursion2() { text = Convert.ToString(item["label"]),value = Convert.ToInt32(item["value"]) });
+                }
+            }
+        }
+    }
+}

+ 1 - 1
JLHHJSvr/Excutor/GetUserListExcutor.cs

@@ -29,7 +29,7 @@ namespace JLHHJSvr.Excutor
 
                 rslt.userList = new List<u_user_jlhprice>();
                 DbSqlHelper.Select(cmd, "u_user_jlhprice", null, null, null, 0, 0, rslt.userList, null,
-                    "empid, userid, username, rightstring, descrp, deptstr, usermode, outrepstr, pricelist_seestr, pricelist_editstr");
+                    "empid, userid, username, rightstring, descrp, deptstr, usermode, outrepstr, pricelist_seestr, pricelist_editstr,access_failed_count,last_failed_attempt_time");
             }
         }
     }

+ 79 - 29
JLHHJSvr/Excutor/LoginExcutor.cs

@@ -6,7 +6,9 @@ using System.Linq;
 using System.Text;
 using JLHHJSvr.BLL;
 using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
 using JLHHJSvr.DBA.DBModle;
+using JLHHJSvr.LJException;
 using LJLib.DAL.SQL;
 using LJLib.Net.SPI.Server;
 using LJLib.Tools.DEncrypt;
@@ -35,40 +37,88 @@ namespace JLHHJSvr.Excutor
             using (var cmd = con.CreateCommand())
             {
                 con.Open();
-
-                if (DbSqlHelper.SelectOne(cmd, "u_user_jlhprice", "userid = @usercode",
-                    new Dictionary<string, object>() {{"@usercode", request.usercode}}, stUser,
-                    "userid, empid, username, usermode, psw") != 1)
+                
+                try
                 {
-                    rslt.ErrMsg = "用户名不存在或密码错误";
-                    return;
-                }
+                    if (DbSqlHelper.SelectOne(cmd, "u_user_jlhprice", "userid = @usercode",
+                    new Dictionary<string, object>() { { "@usercode", request.usercode } }, stUser,
+                    "userid, empid, username, usermode, psw, access_failed_count, last_failed_attempt_time") != 1)
+                    {
+                        rslt.ErrMsg = "用户名不存在或密码错误";
+                        return;
+                    }
+
+                    // 判断是否lock
+                    if (stUser.isLocked)
+                    {
+                        throw new LJCommonException("登录连续错误5次,账号已锁定,请联系管理员解锁!");
+                    }
+
+                    psw_bczh3 pswhelper = new psw_bczh3();
+                    if (pswhelper.GetEntrypt(request.psw, 0, "123457851239866") != stUser.psw)
+                    {
+                        using (cmd.Transaction = con.BeginTransaction())
+                        {
+                            try
+                            {
+                                cmd.CommandText = @"UPDATE u_user_jlhprice SET access_failed_count = CASE 
+                                                    WHEN last_failed_attempt_time < @failedDate THEN 1 
+                                                    ELSE access_failed_count + 1 
+                                                 END,
+                                                 last_failed_attempt_time = GETUTCDATE()
+                                                WHERE u_user_jlhprice.empid = @empid";
+                                cmd.Parameters.Clear();
+                                cmd.Parameters.AddWithValue("@failedDate", DateTime.UtcNow.AddMonths(-1));
+                                cmd.Parameters.AddWithValue("@empid", stUser.empid);
+                                cmd.ExecuteNonQuery();
+
+                                cmd.Transaction.Commit();
+                            }
+                            catch (Exception e)
+                            {
+                                cmd.Transaction.Rollback();
+                            }
+                        }
+                        
+                        throw new LJCommonException($"密码错误,剩余尝试次数:{5 - stUser.access_failed_count + 1} 次(共 5 次)");
+                    }
 
-                psw_bczh3 pswhelper = new psw_bczh3();
-                if (pswhelper.GetEntrypt(request.psw, 0, "123457851239866") != stUser.psw)
+                    string token = Guid.NewGuid().ToString();
+                    rslt.token = token;
+                    rslt.username = stUser.username;
+                    rslt.usercode = stUser.userid;
+                    rslt.empid = stUser.empid;
+                    rslt.usermode = stUser.usermode;
+                    rslt.rsltFunids = UserHelper.FilterMyFunids(cmd, stUser.empid);
+                    var tokenData = new TokenData
+                    {
+                        empid = stUser.empid,
+                        usercode = stUser.userid,
+                        userid = stUser.empid,
+                        username = stUser.username,
+                        usermode = stUser.usermode
+                    };
+                    BllHelper.SetToken(token, tokenData);
+
+                    // 登录成功,清除错误次数
+                    using (cmd.Transaction = con.BeginTransaction())
+                    {
+                        try
+                        {
+                            UserHelper.UnLock(cmd, new List<int>() { stUser.empid });
+                            cmd.Transaction.Commit();
+                        }
+                        catch (Exception e)
+                        {
+                            cmd.Transaction.Rollback();
+                        }
+                    }
+                }
+                catch(LJCommonException ex)
                 {
-                    rslt.ErrMsg = "用户名不存在或密码错误";
-                    return;
+                    rslt.ErrMsg = ex.Message;
                 }
-
-                rslt.rsltFunids = UserHelper.FilterMyFunids(cmd, stUser.empid);
             }
-
-            string token = Guid.NewGuid().ToString();
-            rslt.token = token;
-            rslt.username = stUser.username;
-            rslt.usercode = stUser.userid;
-            rslt.empid = stUser.empid;
-            rslt.usermode = stUser.usermode;
-            var tokenData = new TokenData
-            {
-                empid = stUser.empid,
-                usercode = stUser.userid,
-                userid = stUser.empid,
-                username = stUser.username,
-                usermode = stUser.usermode
-            };
-            BllHelper.SetToken(token,tokenData);
         }
     }
 }

+ 53 - 0
JLHHJSvr/Excutor/UnLockUserExcutor.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.DBA.DBModle;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using LJLib.Tools.DEncrypt;
+using LJLib.Tools.Encry;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class UnLockUserExcutor : ExcutorBase<UnLockUserRequest, UnLockUserResponse>
+    {
+        protected override void ExcuteInternal(UnLockUserRequest request, object state, UnLockUserResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+            if (request.useridList == null || request.useridList.Count == 0)
+            {
+                rslt.ErrMsg = "至少提交一条需要解锁的记录";
+                return;
+            }
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                using (cmd.Transaction = con.BeginTransaction())
+                {
+                    try
+                    {
+                        UserHelper.UnLock(cmd, request.useridList);
+                        cmd.Transaction.Commit();
+                    }
+                    catch (Exception e)
+                    {
+                        cmd.Transaction.Rollback();
+                        rslt.ErrMsg = e.Message;
+                    }
+                }
+            }
+        }
+    }
+}

+ 3 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -139,6 +139,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("GetUserList", typeof(GetUserListRequest), new GetUserListExcutor());//获取用户列表
                 excutorManager.AddMap("SaveUserList", typeof(SaveUserListRequest), new SaveUserListExcutor());//保存用户列表
                 excutorManager.AddMap("DelUserList", typeof(DelUserListRequest), new DelUserListExcutor());//删除用户列表
+                excutorManager.AddMap("UnLockUser", typeof(UnLockUserRequest), new UnLockUserExcutor());//删除用户列表
                 excutorManager.AddMap("GetSysFuncPwr", typeof(GetSysFuncPwrRequest), new GetSysFuncPwrExcutor());//获取权限列表
                 excutorManager.AddMap("GetDept", typeof(GetDeptRequest), new GetDeptExcutor());//获取部门列表
                 excutorManager.AddMap("GetPriceList", typeof(GetPriceListRequest), new GetPriceListExcutor());//获取价格表列表
@@ -229,6 +230,8 @@ namespace JLHHJSvr
                 excutorManager.AddMap("SaveMattressExtraType", typeof(SaveMattressExtraTypeRequest), new SaveMattressExtraTypeExcutor());// 保存床网分区类型
                 excutorManager.AddMap("DeleteMattressExtraType", typeof(DeleteMattressExtraTypeRequest), new DeleteMattressExtraTypeExcutor());// 删除床网分区类型
 
+                excutorManager.AddMap("GetFormulaVarList",typeof(GetFormulaVarListRequest),new GetFormulaVarListExcutor());
+                excutorManager.AddMap("FormulaCheck", typeof(FormulaCheckRequest),new FormulaCheckExcutor());
             }
             catch (Exception ex)
             {

+ 7 - 4
JLHHJSvr/JLHHJSvr.csproj

@@ -102,12 +102,15 @@
     <Compile Include="Com\DeleteMattressExtraType.cs" />
     <Compile Include="Com\DeleteMattressExtra.cs" />
     <Compile Include="Com\Model\replacement_bednet.cs" />
+    <Compile Include="Com\FormulaCheck.cs" />
+    <Compile Include="Com\GetFormulaVarList.cs" />
     <Compile Include="Com\Model\u_mattress_computed.cs" />
     <Compile Include="Com\Model\u_mattress_extra_type.cs" />
     <Compile Include="Com\Model\u_mattress_extra.cs" />
     <Compile Include="Com\Model\u_mattress_mx_extra.cs" />
     <Compile Include="Com\SaveMattressExtraType.cs" />
     <Compile Include="Com\SaveMattressExtra.cs" />
+    <Compile Include="Com\UnLockUser.cs" />
     <Compile Include="Com\UpdateMtrlPrice.cs" />
     <Compile Include="Com\DelCarList.cs" />
     <Compile Include="Com\DeleteBedNet.cs" />
@@ -136,7 +139,6 @@
     <Compile Include="Com\GetComputeSpring.cs" />
     <Compile Include="Com\GetERPMtrlTypeList.cs" />
     <Compile Include="Com\GetMattressImportDW2.cs" />
-    <Compile Include="Com\GetSemiFinishedMxList.cs" />
     <Compile Include="Com\GetMattressPackagMx.cs" />
     <Compile Include="Com\GetComputeMattress.cs" />
     <Compile Include="Com\GetComputeBednet.cs" />
@@ -152,7 +154,6 @@
     <Compile Include="Com\GetPriceList.cs" />
     <Compile Include="Com\GetSysFuncPwr.cs" />
     <Compile Include="Com\GetFormulaCompute.cs" />
-    <Compile Include="Com\ImportSpring.cs" />
     <Compile Include="Com\MattressJS2Audit.cs" />
     <Compile Include="Com\MattressJSAudit.cs" />
     <Compile Include="Com\MattressYWAudit.cs" />
@@ -292,8 +293,11 @@
     <Compile Include="Excutor\CopyMtrlDefExcutor.cs" />
     <Compile Include="Excutor\DeleteMattressExtraTypeExcutor.cs" />
     <Compile Include="Excutor\DeleteMattressExtraExcutor.cs" />
+    <Compile Include="Excutor\FormulaCheckExcutor.cs" />
+    <Compile Include="Excutor\GetFormulaVarListExcutor.cs" />
     <Compile Include="Excutor\SaveMattressExtraTypeExcutor.cs" />
     <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" />
@@ -323,7 +327,6 @@
     <Compile Include="Excutor\GetCarListExcutor.cs" />
     <Compile Include="Excutor\GetComputeSpringExcutor.cs" />
     <Compile Include="Excutor\GetERPMtrlTypeListExcutor.cs" />
-    <Compile Include="Excutor\GetSemiFinishedMxListExcutor.cs" />
     <Compile Include="Excutor\GetMattressPackagMxExcutor.cs" />
     <Compile Include="Excutor\GetMattressImportDW2Excutor.cs" />
     <Compile Include="Excutor\GetComputeMattressExcutor.cs" />
@@ -346,7 +349,6 @@
     <Compile Include="Excutor\GetUserListExcutor.cs" />
     <Compile Include="Excutor\GetUserPowerExcutor.cs" />
     <Compile Include="Excutor\HelloWordExcutor.cs" />
-    <Compile Include="Excutor\ImportSpringExcutor.cs" />
     <Compile Include="Excutor\LoginExcutor.cs" />
     <Compile Include="Excutor\MattressJS2AuditExcutor.cs" />
     <Compile Include="Excutor\MattressJSAuditExcutor.cs" />
@@ -391,6 +393,7 @@
     <Compile Include="Excutor\SetSysUserFileStringExcutor.cs" />
     <Compile Include="Excutor\SetOptionExcutor.cs" />
     <Compile Include="Helper\BedNetHelper.cs" />
+    <Compile Include="Helper\CacheHelper.cs" />
     <Compile Include="Helper\ERPHelper.cs" />
     <Compile Include="Helper\InterfaceHelper.cs" />
     <Compile Include="Helper\MattressHelper.cs" />

+ 7 - 0
JLHHJSvr/LJFrameWork/Tools/LJExprParser.cs

@@ -11,6 +11,13 @@ namespace JLHHJSvr.LJFramework.Tools
 {
     public class LJExprParser
     {
+        public static bool CheckFormula(string expr,out string arg_msg)
+        {
+            var parser = new TExprParserChina(expr);
+            // 
+            arg_msg = parser.ErrorMessage;
+            return parser.HasError;
+        }
         public static TExprParserEx Parse(string expr)
         {
             if (string.IsNullOrEmpty(expr)) return new TExprParserChina("");