|
@@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|
|
using System.Data.SqlClient;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace JLHHJSvr.Helper
|
|
@@ -17,6 +18,7 @@ namespace JLHHJSvr.Helper
|
|
|
class MattressHelper : HelperBase
|
|
|
{
|
|
|
private Dictionary<string, object> replacements = new Dictionary<string, object>();
|
|
|
+ private Dictionary<string, string> formula_replacements = new Dictionary<string, string>();
|
|
|
|
|
|
public void CalCulateFormula(u_mattress mattress, List<u_mattress_mx_mtrl> mxlist)
|
|
|
{
|
|
@@ -104,26 +106,13 @@ namespace JLHHJSvr.Helper
|
|
|
expression = expression.Replace("@@", "");
|
|
|
mx.replace_formula = expression;
|
|
|
|
|
|
- try
|
|
|
+ if (sqlCal)
|
|
|
{
|
|
|
- if (sqlCal)
|
|
|
- {
|
|
|
- cmd.CommandText = $@"{expression}";
|
|
|
- cmd.Parameters.Clear();
|
|
|
- var result = cmd.ExecuteScalar();
|
|
|
- if(result != null && result != DBNull.Value)
|
|
|
- {
|
|
|
- mx.costamt = Convert.ToDecimal(result);
|
|
|
- }
|
|
|
- } else
|
|
|
- {
|
|
|
- var res = LJExprParser.Parse(expression);
|
|
|
- mx.costamt = res.Result.DecimalValue;
|
|
|
- }
|
|
|
+ mx.costamt = Convert.ToDecimal(SqlCalculate(expression, "成本金额"));
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
- throw new LJCommonException($"计算成本金额公式错误!expression: {expression}" );
|
|
|
+ mx.costamt = Calculate(expression, "成本金额").DecimalValue;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -132,27 +121,13 @@ namespace JLHHJSvr.Helper
|
|
|
use_expression = use_expression.Replace("@@", "");
|
|
|
mx.replace_useformula = use_expression;
|
|
|
|
|
|
- try
|
|
|
+ if (sqlCal)
|
|
|
{
|
|
|
- if (sqlCal)
|
|
|
- {
|
|
|
- cmd.CommandText = $@"{use_expression}";
|
|
|
- cmd.Parameters.Clear();
|
|
|
- var result = cmd.ExecuteScalar();
|
|
|
- if (result != null && result != DBNull.Value)
|
|
|
- {
|
|
|
- mx.useqty = Convert.ToDecimal(result);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var res = LJExprParser.Parse(use_expression);
|
|
|
- mx.useqty = res.Result.DecimalValue;
|
|
|
- }
|
|
|
+ mx.useqty = Convert.ToDecimal(SqlCalculate(use_expression, "清单用量"));
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
- throw new LJCommonException($"计算清单用量公式错误!expression: {use_expression}");
|
|
|
+ mx.useqty = Calculate(use_expression, "清单用量").DecimalValue;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
@@ -310,6 +285,15 @@ namespace JLHHJSvr.Helper
|
|
|
AddKeyValue("面拆", mattress.if_m_chai);
|
|
|
AddKeyValue("中拆", mattress.if_z_chai);
|
|
|
AddKeyValue("底拆", mattress.if_d_chai);
|
|
|
+ AddKeyValue("工厂利润率", mattress.profitrate);
|
|
|
+ AddKeyValue("部门利润率", mattress.dept_profitrate);
|
|
|
+ AddKeyValue("部门让利点数", mattress.dept_profitrate_rangli);
|
|
|
+ AddKeyValue("佣金点数", mattress.commission);
|
|
|
+ AddKeyValue("额外点数", mattress.other_rate);
|
|
|
+ AddKeyValue("额外费用", mattress.extras_cost);
|
|
|
+ AddKeyValue("汇率", mattress.moneyrate);
|
|
|
+ AddKeyValue("税率", mattress.taxrate);
|
|
|
+ AddKeyValue("折扣率", mattress.discount);
|
|
|
// 地区FOB费用,如果存在变量表,会替代
|
|
|
AddKeyValue("大柜-普通-地区FOB费用", 6500);
|
|
|
AddKeyValue("大柜-特定-地区FOB费用", 8500);
|
|
@@ -321,6 +305,15 @@ namespace JLHHJSvr.Helper
|
|
|
// 柜型米数
|
|
|
AddKeyValue("大柜-柜型米数", 12);
|
|
|
AddKeyValue("小柜-柜型米数", 5.9);
|
|
|
+ // 公式
|
|
|
+ AddFormulaKeyValue("【总成本】", "【总材料成本】*【大小单】+【款式费用】+【边带费用】+【额外费用】+【制造费用】");
|
|
|
+ AddFormulaKeyValue("【不含税出厂价】", "【总成本】*(【工厂利润率】+【工艺点数】+【内布套点数】+【拆装点数】+【海绵扣点】)*【管理费点】");
|
|
|
+ AddFormulaKeyValue("【部门不含税价】", "【不含税出厂价】/(【部门利润率】+【部门让利点数】/100)/(1-(【佣金点数】-1))*【额外点数】+【FOB】");
|
|
|
+ AddFormulaKeyValue("【税金】", "【部门不含税价】*(【税率】-1)+【佣金】 * 0.05");
|
|
|
+ AddFormulaKeyValue("【部门含税价】", "(【部门不含税价】+【佣金】 * 0.06)*【税率】*【折扣率】");
|
|
|
+ AddFormulaKeyValue("【外币价】", "【部门含税价】/【汇率】");
|
|
|
+ AddFormulaKeyValue("【底价】", "【底价】/(1-(【佣金点数】-1)-【底价】");
|
|
|
+ AddFormulaKeyValue("【佣金】", "if((【不含税出厂价】+【部门利润】/100)<> 0,【不含税出厂价】/(【部门利润】+【部门让利点数】/ 100),0)");
|
|
|
|
|
|
if (mattress.woodpallettype == 0)
|
|
|
{
|
|
@@ -345,10 +338,12 @@ namespace JLHHJSvr.Helper
|
|
|
,vartype
|
|
|
,varunit
|
|
|
,u_bednet_varmx.varvalue AS varvalue
|
|
|
+ ,formula
|
|
|
FROM u_bednet_var
|
|
|
INNER JOIN u_bednet_varmx ON u_bednet_varmx.varid = u_bednet_var.varid
|
|
|
INNER JOIN u_dept ON u_dept.pricelistid = u_bednet_varmx.pricelistid";
|
|
|
var whereList = new List<string>();
|
|
|
+ whereList.Add("u_bednet_var.varclass < 2");
|
|
|
whereList.Add("u_bednet_var.varkind = @varkind");
|
|
|
whereList.Add("u_dept.deptid = @deptid");
|
|
|
var param = new Dictionary<string, object>();
|
|
@@ -360,6 +355,30 @@ namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
AddKeyValue(netvar.varname, netvar.varvalue);
|
|
|
}
|
|
|
+
|
|
|
+ selectStr = @"SELECT varid
|
|
|
+ ,varkind
|
|
|
+ ,varcode
|
|
|
+ ,varname
|
|
|
+ ,varclass
|
|
|
+ ,vartype
|
|
|
+ ,varunit
|
|
|
+ ,formula
|
|
|
+ FROM u_bednet_var";
|
|
|
+ bednetVarList = new List<u_bednet_var>();
|
|
|
+ whereList = new List<string>();
|
|
|
+ whereList.Add("u_bednet_var.varkind = @varkind");
|
|
|
+ whereList.Add("u_bednet_var.varclass = @varclass");
|
|
|
+ param = new Dictionary<string, object>();
|
|
|
+ param.Add("@varkind", 1);
|
|
|
+ param.Add("@varclass", 2);
|
|
|
+ DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), param, "varid", "varid,varkind,varcode,varname,varclass,vartype,varunit,formula", 0, 0, bednetVarList);
|
|
|
+
|
|
|
+ // 添加替换公式变量
|
|
|
+ foreach (var netvar in bednetVarList)
|
|
|
+ {
|
|
|
+ AddFormulaKeyValue(netvar.varname, netvar.formula);
|
|
|
+ }
|
|
|
}
|
|
|
private void InitMxReplaceMents(u_mattress_mx_mtrl mx)
|
|
|
{
|
|
@@ -589,42 +608,28 @@ namespace JLHHJSvr.Helper
|
|
|
fob_expression = fob_expression.Replace("【柜型米数】", $"【{mattress.cabinet_type.Trim()}-柜型米数】");
|
|
|
}
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
- mattress.fob_replace_formula = fob_expression;
|
|
|
- var res = Calculate(fob_expression);
|
|
|
- mattress.fob = res.DecimalValue;
|
|
|
+ mattress.fob_replace_formula = fob_expression;
|
|
|
+ mattress.fob = Calculate(fob_expression, "FOB").DecimalValue;
|
|
|
+ //半成品:如果PE袋物料是含 半成品专用 的编码,FOB需要除以数量
|
|
|
+ var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
|
|
|
|
|
|
- //半成品:如果PE袋物料是含 半成品专用 的编码,FOB需要除以数量
|
|
|
- var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
|
|
|
- foreach(var bz in bzList)
|
|
|
+ foreach (var bz in bzList)
|
|
|
+ {
|
|
|
+ if (bz.qty.Value > 0 && bz.mtrlname.IndexOf("半成品专用") > -1)
|
|
|
{
|
|
|
- if(bz.qty.Value > 0 && bz.mtrlname.IndexOf("半成品专用") > -1)
|
|
|
- {
|
|
|
- mattress.fob /= bz.qty.Value;
|
|
|
+ mattress.fob /= bz.qty.Value;
|
|
|
|
|
|
- mattress.fob_replace_formula = $"{mattress.fob_replace_formula} / {bz.qty.Value}";
|
|
|
- }
|
|
|
+ mattress.fob_replace_formula = $"{mattress.fob_replace_formula} / {bz.qty.Value}";
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- throw new LJCommonException($"计算FOB公式错误!expression: {fob_expression}");
|
|
|
- }
|
|
|
+
|
|
|
+ AddKeyValue("FOB", mattress.fob);
|
|
|
#endregion
|
|
|
|
|
|
#region 计算体积
|
|
|
if (mattress.fob > 0)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- var res = Calculate(cubage_expression);
|
|
|
- mattress.cubage = res.DecimalValue;
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- throw new LJCommonException($"计算体积公式错误!expression: {cubage_expression}");
|
|
|
- }
|
|
|
+ mattress.cubage = Calculate(cubage_expression, "体积").DecimalValue;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -649,16 +654,11 @@ namespace JLHHJSvr.Helper
|
|
|
}
|
|
|
|
|
|
AddKeyValue("垫层数量", diancengCount);
|
|
|
+ AddKeyValue("制造费用", mattress.zhizao_amt);
|
|
|
+ AddKeyValue("管理费点", mattress.guanli_rate);
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
- var res = Calculate(mattress.hrcost_replace_formula);
|
|
|
- mattress.hrcost = res.DecimalValue;
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- throw new LJCommonException($"计算款式费用公式错误!expression: {mattress.hrcost_replace_formula}");
|
|
|
- }
|
|
|
+ mattress.hrcost = Calculate(mattress.hrcost_replace_formula, "款式费用").DecimalValue;
|
|
|
+ AddKeyValue("款式费用", mattress.hrcost);
|
|
|
#endregion
|
|
|
|
|
|
#region 计算边带费用
|
|
@@ -666,15 +666,8 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
AddKeyValue("边带条数", mattress.biandai_qty);
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
- var res = Calculate(mattress.biandaicost_replace_formula);
|
|
|
- mattress.biandaicost = res.DecimalValue;
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- throw new LJCommonException($"计算边带费用公式错误!expression: {mattress.biandaicost_replace_formula}");
|
|
|
- }
|
|
|
+ mattress.biandaicost = Calculate(mattress.biandaicost_replace_formula, "边带费用").DecimalValue;
|
|
|
+ AddKeyValue("边带费用", mattress.biandaicost);
|
|
|
#endregion
|
|
|
|
|
|
#region 辅料 有打钮纽扣 加0.13 工厂利润率
|
|
@@ -701,11 +694,12 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
#region 计算主表 总材料成本
|
|
|
mattress.total_material_cost = mxlist.Sum(t => t.costamt);
|
|
|
+ AddKeyValue("总材料成本", mattress.total_material_cost);
|
|
|
#endregion
|
|
|
|
|
|
- CalCulateCost(mattress, "标准");
|
|
|
- CalCulateCost(mattress, "大单");
|
|
|
- CalCulateCost(mattress, "散单");
|
|
|
+ CalCulateCostNew(mattress, "标准");
|
|
|
+ CalCulateCostNew(mattress, "大单");
|
|
|
+ CalCulateCostNew(mattress, "散单");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 计算拼侧最大金额的侧和工厂利润率加点
|
|
@@ -783,6 +777,7 @@ namespace JLHHJSvr.Helper
|
|
|
// 查找点数
|
|
|
var workmanship = new u_workmanship_add() { deptid = mattress.deptid, mattresstypeid = mattress.mattresstypeid, workmanshipname = field };
|
|
|
mattress.profitrate_point = workmanship.rate;
|
|
|
+ AddKeyValue("工艺点数", mattress.profitrate_point);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 计算内布套特殊加点
|
|
@@ -816,6 +811,7 @@ namespace JLHHJSvr.Helper
|
|
|
// 查找点数
|
|
|
var workmanship = new u_workmanship_add() { deptid = mattress.deptid, mattresstypeid = mattress.mattresstypeid, workmanshipname = field };
|
|
|
mattress.butao_point = workmanship.rate;
|
|
|
+ AddKeyValue("内布套点数", mattress.butao_point);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 拆装特殊加点
|
|
@@ -836,6 +832,7 @@ namespace JLHHJSvr.Helper
|
|
|
// 查找点数
|
|
|
var workmanship = new u_workmanship_add() { deptid = mattress.deptid, mattresstypeid = mattress.mattresstypeid, workmanshipname = field };
|
|
|
mattress.chaizhuang_point = workmanship.rate;
|
|
|
+ AddKeyValue("拆装点数", mattress.chaizhuang_point);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 计算海绵款特殊扣点
|
|
@@ -849,6 +846,7 @@ namespace JLHHJSvr.Helper
|
|
|
// 查找点数
|
|
|
var workmanship = new u_workmanship_add() { deptid = mattress.deptid, mattresstypeid = mattress.mattresstypeid, workmanshipname = field };
|
|
|
mattress.haimian_point = workmanship.rate;
|
|
|
+ AddKeyValue("海绵扣点", mattress.haimian_point);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 计算大小单加点
|
|
@@ -863,6 +861,55 @@ namespace JLHHJSvr.Helper
|
|
|
// 查找点数
|
|
|
var workmanship = new u_workmanship_add() { deptid = mattress.deptid, mattresstypeid = mattress.mattresstypeid, workmanshipname = field };
|
|
|
mattress.dannum_rate = workmanship.rate;
|
|
|
+ AddKeyValue("大小单", mattress.dannum_rate);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 计算成本
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mattress"></param>
|
|
|
+ /// <param name="typename"></param>
|
|
|
+ private void CalCulateCostNew(u_mattress mattress, string typename)
|
|
|
+ {
|
|
|
+ #region 总成本
|
|
|
+ CalCulateDanNum(mattress, typename);
|
|
|
+ mattress.total_cost = CalculateVarFormula("总成本").DecimalValue;
|
|
|
+ if (mattress.if_zhedie_type == 1) mattress.total_cost *= 2;
|
|
|
+ AddKeyValue("总成本", mattress.total_cost);
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 不含税出厂价
|
|
|
+ mattress.nottax_factory_cost = CalculateVarFormula("不含税出厂价").DecimalValue;
|
|
|
+ AddKeyValue("不含税出厂价", mattress.nottax_factory_cost);
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 部门不含税价
|
|
|
+ mattress.nottax_dept_cost = CalculateVarFormula("部门不含税价").DecimalValue;
|
|
|
+ AddKeyValue("部门不含税价", mattress.nottax_dept_cost);
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 税金
|
|
|
+ mattress.taxes = CalculateVarFormula("税金").DecimalValue;
|
|
|
+ AddKeyValue("税金", mattress.taxes);
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 部门含税价=(部门不含税价+佣金*0.06)*税率*折扣率(fob>0)
|
|
|
+ if (mattress.fob == 0) {
|
|
|
+ mattress.discount = 1;
|
|
|
+ AddKeyValue("折扣率", mattress.discount);
|
|
|
+ }
|
|
|
+
|
|
|
+ mattress.taxes = CalculateVarFormula("部门含税价").DecimalValue;
|
|
|
+ AddKeyValue("部门含税价", mattress.dept_cost);
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 外币价= 部门含税价/汇率
|
|
|
+ if (mattress.moneyrate > 0)
|
|
|
+ {
|
|
|
+ if ("标准".Equals(typename)) mattress.foreign_cost_bz = mattress.dept_cost / mattress.moneyrate;
|
|
|
+ else if ("大单".Equals(typename)) mattress.foreign_cost_dd = mattress.dept_cost / mattress.moneyrate;
|
|
|
+ else if ("散单".Equals(typename)) mattress.foreign_cost = mattress.dept_cost / mattress.moneyrate;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 计算成本
|
|
@@ -926,6 +973,17 @@ namespace JLHHJSvr.Helper
|
|
|
replacements[key] = value;
|
|
|
}
|
|
|
}
|
|
|
+ private void AddFormulaKeyValue(string key, string value, bool isReplace = true)
|
|
|
+ {
|
|
|
+ if (!formula_replacements.ContainsKey(key))
|
|
|
+ {
|
|
|
+ formula_replacements.Add(key, value);
|
|
|
+ }
|
|
|
+ else if (isReplace)
|
|
|
+ {
|
|
|
+ formula_replacements[key] = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
private string ConvertToEnglishSymbols(string input)
|
|
|
{
|
|
|
input = input.Replace("(", "(")
|
|
@@ -941,17 +999,107 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
return input;
|
|
|
}
|
|
|
- private TData Calculate(string expression)
|
|
|
+ private TData CalculateVarFormula(string varname)
|
|
|
+ {
|
|
|
+ varname = $"【{varname}】";
|
|
|
+ if (!formula_replacements.ContainsKey(varname)) return null;
|
|
|
+ return Calculate(varname,varname);
|
|
|
+ }
|
|
|
+ private TData Calculate(string expression,string name="")
|
|
|
{
|
|
|
ConvertToEnglishSymbols(expression);
|
|
|
|
|
|
- foreach (var replacement in replacements)
|
|
|
+ // 定义正则表达式模式,匹配包含【】的内容
|
|
|
+ string pattern = @"【(.*?)】";
|
|
|
+
|
|
|
+ // 创建正则表达式对象
|
|
|
+ Regex regex = new Regex(pattern);
|
|
|
+
|
|
|
+ foreach (var replacement in formula_replacements)
|
|
|
+ {
|
|
|
+ expression = expression.Replace(replacement.Key, replacement.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用正则表达式匹配输入字符串
|
|
|
+ MatchCollection matches = regex.Matches(expression);
|
|
|
+
|
|
|
+ var new_replacements = new Dictionary<string, object>();
|
|
|
+
|
|
|
+ foreach (Match match in matches)
|
|
|
+ {
|
|
|
+ if (replacements.TryGetValue(match.Value, out object value2))
|
|
|
+ {
|
|
|
+ new_replacements[match.Value] = value2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var replacement in new_replacements)
|
|
|
{
|
|
|
expression = expression.Replace(replacement.Key, Convert.ToString(replacement.Value));
|
|
|
}
|
|
|
|
|
|
- var res = LJExprParser.Parse(expression);
|
|
|
- return res.Result;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return LJExprParser.Parse(expression).Result;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ throw new LJCommonException($"计算{name}公式错误!expression: {expression},exception: {ex.Message}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private object SqlCalculate(string expression, string name = "")
|
|
|
+ {
|
|
|
+ ConvertToEnglishSymbols(expression);
|
|
|
+
|
|
|
+ expression = expression.Replace("@@", "");
|
|
|
+
|
|
|
+ // 定义正则表达式模式,匹配包含【】的内容
|
|
|
+ string pattern = @"【(.*?)】";
|
|
|
+
|
|
|
+ // 创建正则表达式对象
|
|
|
+ Regex regex = new Regex(pattern);
|
|
|
+
|
|
|
+ // 使用正则表达式匹配输入字符串
|
|
|
+ MatchCollection matches = regex.Matches(expression);
|
|
|
+
|
|
|
+ var new_formula_replacements = new Dictionary<string, string>();
|
|
|
+ var new_replacements = new Dictionary<string, object>();
|
|
|
+
|
|
|
+ foreach (Match match in matches)
|
|
|
+ {
|
|
|
+ // 检查原始字典中是否存在该键,并添加到新字典中
|
|
|
+ if (formula_replacements.TryGetValue(match.Value, out string value))
|
|
|
+ {
|
|
|
+ new_formula_replacements[match.Value] = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (replacements.TryGetValue(match.Value, out object value2))
|
|
|
+ {
|
|
|
+ new_replacements[match.Value] = value2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var replacement in new_formula_replacements)
|
|
|
+ {
|
|
|
+ expression = expression.Replace(replacement.Key, replacement.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var replacement in new_replacements)
|
|
|
+ {
|
|
|
+ expression = expression.Replace(replacement.Key, Convert.ToString(replacement.Value));
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ cmd.CommandText = $@"{expression}";
|
|
|
+ cmd.Parameters.Clear();
|
|
|
+ return cmd.ExecuteScalar();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ throw new LJCommonException($"计算{name}公式错误!expression: {expression},exception: {ex.Message}");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void SaveMattress(u_mattress mattress,List<u_mattress_mx_mtrl> mxlist)
|