|
@@ -60,10 +60,10 @@ namespace JLHHJSvr.Helper
|
|
decimal hard_around_row = mx.hard_around_row.Value;
|
|
decimal hard_around_row = mx.hard_around_row.Value;
|
|
if (bednet.typename.IndexOf("袋装", StringComparison.Ordinal) >= 0) hard_around_row *= 2;
|
|
if (bednet.typename.IndexOf("袋装", StringComparison.Ordinal) >= 0) hard_around_row *= 2;
|
|
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧排列个数-宽】", $"(【弹簧排列个数-宽】 - {hard_around_row})");
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧计算个数(宽)】", $"(【弹簧计算个数(宽)】 - {hard_around_row})");
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧排列个数-长】", $"(【弹簧排列个数-长】 - {hard_around_row})");
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧计算个数(长)】", $"(【弹簧计算个数(长)】 - {hard_around_row})");
|
|
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧排列个数-宽】", $"(【弹簧排列个数-宽】 - {hard_around_row})");
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧计算个数(宽)】", $"(【弹簧计算个数(宽)】 - {hard_around_row})");
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧排列个数-长】", $"(【弹簧排列个数-长】 - {hard_around_row})");
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧计算个数(长)】", $"(【弹簧计算个数(长)】 - {hard_around_row})");
|
|
}
|
|
}
|
|
|
|
|
|
if (mx.if_pocket_around == 1)
|
|
if (mx.if_pocket_around == 1)
|
|
@@ -71,10 +71,10 @@ namespace JLHHJSvr.Helper
|
|
decimal pocket_around_row = mx.pocket_around_row.Value;
|
|
decimal pocket_around_row = mx.pocket_around_row.Value;
|
|
if (bednet.typename.IndexOf("袋装", StringComparison.Ordinal) >= 0) pocket_around_row *= 2;
|
|
if (bednet.typename.IndexOf("袋装", StringComparison.Ordinal) >= 0) pocket_around_row *= 2;
|
|
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧排列个数-宽】", $"(【弹簧排列个数-宽】 - {pocket_around_row})");
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧计算个数(宽)】", $"(【弹簧计算个数(宽)】 - {pocket_around_row})");
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧排列个数-长】", $"(【弹簧排列个数-长】 - {pocket_around_row})");
|
|
|
|
- mx.spring_mtrl_cost_replace_formula = ReplaceWith(mx.spring_mtrl_cost_replace_formula, "【弹簧计算个数(长)】", $"(【弹簧计算个数(长)】 - {pocket_around_row})");
|
|
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧排列个数-宽】", $"(【弹簧排列个数-宽】 - {pocket_around_row})");
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧计算个数(宽)】", $"(【弹簧计算个数(宽)】 - {pocket_around_row})");
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧排列个数-长】", $"(【弹簧排列个数-长】 - {pocket_around_row})");
|
|
|
|
+ mx.spring_mtrl_cost_replace_formula = mx.spring_mtrl_cost_replace_formula.Replace("【弹簧计算个数(长)】", $"(【弹簧计算个数(长)】 - {pocket_around_row})");
|
|
}
|
|
}
|
|
|
|
|
|
mx.spring_mtrl_cost = Calculate(mx.spring_mtrl_cost_replace_formula, "弹簧材料总成本").DecimalValue;
|
|
mx.spring_mtrl_cost = Calculate(mx.spring_mtrl_cost_replace_formula, "弹簧材料总成本").DecimalValue;
|
|
@@ -374,7 +374,7 @@ namespace JLHHJSvr.Helper
|
|
{
|
|
{
|
|
bednet.packet_mtrl_cost_replace_formula = bednet.packet_mtrl_formula;
|
|
bednet.packet_mtrl_cost_replace_formula = bednet.packet_mtrl_formula;
|
|
bool sqlCal = !string.IsNullOrEmpty(bednet.packet_mtrl_formula) && bednet.packet_mtrl_formula.Substring(0, 2) == "@@";
|
|
bool sqlCal = !string.IsNullOrEmpty(bednet.packet_mtrl_formula) && bednet.packet_mtrl_formula.Substring(0, 2) == "@@";
|
|
- bednet.packet_mtrl_cost_replace_formula = ReplaceWith(bednet.packet_mtrl_cost_replace_formula, "@@", "");
|
|
|
|
|
|
+ bednet.packet_mtrl_cost_replace_formula = bednet.packet_mtrl_cost_replace_formula.Replace("@@", "");
|
|
|
|
|
|
if(sqlCal) bednet.packet_mtrl_cost += Convert.ToDecimal(SqlCalculate(bednet.packet_mtrl_cost_replace_formula, "包装总成本"));
|
|
if(sqlCal) bednet.packet_mtrl_cost += Convert.ToDecimal(SqlCalculate(bednet.packet_mtrl_cost_replace_formula, "包装总成本"));
|
|
else bednet.packet_mtrl_cost += Calculate(bednet.packet_mtrl_cost_replace_formula, "包装总成本").DecimalValue;
|
|
else bednet.packet_mtrl_cost += Calculate(bednet.packet_mtrl_cost_replace_formula, "包装总成本").DecimalValue;
|
|
@@ -386,7 +386,7 @@ namespace JLHHJSvr.Helper
|
|
{
|
|
{
|
|
bednet.packet_hr_cost_replace_formula = bednet.packet_hr_formula;
|
|
bednet.packet_hr_cost_replace_formula = bednet.packet_hr_formula;
|
|
bool sqlCal = !string.IsNullOrEmpty(bednet.packet_hr_formula) && bednet.packet_hr_formula.Substring(0, 2) == "@@";
|
|
bool sqlCal = !string.IsNullOrEmpty(bednet.packet_hr_formula) && bednet.packet_hr_formula.Substring(0, 2) == "@@";
|
|
- bednet.packet_hr_cost_replace_formula = ReplaceWith(bednet.packet_hr_cost_replace_formula, "@@", "");
|
|
|
|
|
|
+ bednet.packet_hr_cost_replace_formula = bednet.packet_hr_cost_replace_formula.Replace("@@", "");
|
|
|
|
|
|
if (sqlCal) bednet.packet_hr_cost += Convert.ToDecimal(SqlCalculate(bednet.packet_hr_cost_replace_formula, "包装人工成本"));
|
|
if (sqlCal) bednet.packet_hr_cost += Convert.ToDecimal(SqlCalculate(bednet.packet_hr_cost_replace_formula, "包装人工成本"));
|
|
else bednet.packet_hr_cost += Calculate(bednet.packet_hr_cost_replace_formula, "包装人工成本").DecimalValue;
|
|
else bednet.packet_hr_cost += Calculate(bednet.packet_hr_cost_replace_formula, "包装人工成本").DecimalValue;
|
|
@@ -1180,17 +1180,13 @@ namespace JLHHJSvr.Helper
|
|
formula_replacements[key] = value;
|
|
formula_replacements[key] = value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- private string ReplaceWith(string input, string oldValue, string newValue)
|
|
|
|
- {
|
|
|
|
- return input.Replace(oldValue, newValue);
|
|
|
|
- }
|
|
|
|
private TData CalculateVarFormula(string varname)
|
|
private TData CalculateVarFormula(string varname)
|
|
{
|
|
{
|
|
varname = $"【{varname}】";
|
|
varname = $"【{varname}】";
|
|
if (!formula_replacements.ContainsKey(varname)) return null;
|
|
if (!formula_replacements.ContainsKey(varname)) return null;
|
|
- return Calculate(varname);
|
|
|
|
|
|
+ return Calculate(formula_replacements[varname], varname);
|
|
}
|
|
}
|
|
- private TData Calculate(string expression,string name = "")
|
|
|
|
|
|
+ private void FormatExpression(ref string expression)
|
|
{
|
|
{
|
|
ConvertToEnglishSymbols(expression);
|
|
ConvertToEnglishSymbols(expression);
|
|
|
|
|
|
@@ -1200,11 +1196,6 @@ namespace JLHHJSvr.Helper
|
|
// 创建正则表达式对象
|
|
// 创建正则表达式对象
|
|
Regex regex = new Regex(pattern);
|
|
Regex regex = new Regex(pattern);
|
|
|
|
|
|
- foreach (var replacement in formula_replacements)
|
|
|
|
- {
|
|
|
|
- expression = expression.Replace(replacement.Key, replacement.Value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// 使用正则表达式匹配输入字符串
|
|
// 使用正则表达式匹配输入字符串
|
|
MatchCollection matches = regex.Matches(expression);
|
|
MatchCollection matches = regex.Matches(expression);
|
|
|
|
|
|
@@ -1222,6 +1213,10 @@ namespace JLHHJSvr.Helper
|
|
{
|
|
{
|
|
expression = expression.Replace(replacement.Key, Convert.ToString(replacement.Value));
|
|
expression = expression.Replace(replacement.Key, Convert.ToString(replacement.Value));
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ private TData Calculate(string expression,string name = "")
|
|
|
|
+ {
|
|
|
|
+ FormatExpression(ref expression);
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -1234,45 +1229,7 @@ namespace JLHHJSvr.Helper
|
|
|
|
|
|
private object SqlCalculate(string expression, string name = "")
|
|
private object SqlCalculate(string expression, string name = "")
|
|
{
|
|
{
|
|
- ConvertToEnglishSymbols(expression);
|
|
|
|
-
|
|
|
|
- expression = ReplaceWith(expression, "@@", "");
|
|
|
|
-
|
|
|
|
- // 定义正则表达式模式,匹配包含【】的内容
|
|
|
|
- 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));
|
|
|
|
- }
|
|
|
|
|
|
+ FormatExpression(ref expression);
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -1494,11 +1451,14 @@ namespace JLHHJSvr.Helper
|
|
bednet.createtime = dtNow;
|
|
bednet.createtime = dtNow;
|
|
bednet.createby = context.tokendata.username;
|
|
bednet.createby = context.tokendata.username;
|
|
|
|
|
|
- var nettype = new u_bednet_type() { bednettypeid = bednet.bednettypeid };
|
|
|
|
- DbSqlHelper.SelectOne(cmd, nettype, "typecode");
|
|
|
|
|
|
+ if(string.IsNullOrEmpty(bednet.bednetcode))
|
|
|
|
+ {
|
|
|
|
+ var nettype = new u_bednet_type() { bednettypeid = bednet.bednettypeid };
|
|
|
|
+ DbSqlHelper.SelectOne(cmd, nettype, "typecode");
|
|
|
|
|
|
- // 编号-年月日+流水
|
|
|
|
- bednet.bednetcode = $"{nettype.typecode}-{dtNow.ToString("yyyyMMdd")}{(bednet.bednetid.Value % 10000).ToString("D4")}";
|
|
|
|
|
|
+ // 编号-年月日+流水
|
|
|
|
+ bednet.bednetcode = $"{nettype.typecode}-{dtNow.ToString("yyyyMMdd")}{(bednet.bednetid.Value % 10000).ToString("D4")}";
|
|
|
|
+ }
|
|
|
|
|
|
DbSqlHelper.Insert(cmd, "u_bednet", null, bednet, fields);
|
|
DbSqlHelper.Insert(cmd, "u_bednet", null, bednet, fields);
|
|
}
|
|
}
|
|
@@ -1553,5 +1513,40 @@ namespace JLHHJSvr.Helper
|
|
var fieldsHs = "bednetid_mattressid, typeid, cmpdate, cmpemp, nottax_dept_cost, dept_cost, foreign_cost";
|
|
var fieldsHs = "bednetid_mattressid, typeid, cmpdate, cmpemp, nottax_dept_cost, dept_cost, foreign_cost";
|
|
DbSqlHelper.Insert(cmd, "u_his_price", null, hisprice, fieldsHs);
|
|
DbSqlHelper.Insert(cmd, "u_his_price", null, hisprice, fieldsHs);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void CopyBedNet(u_bednet bednet,u_bednetmx bednetmx,out int newId)
|
|
|
|
+ {
|
|
|
|
+ var bedNet_copy = new u_bednet() { bednetid = bednet.bednetid};
|
|
|
|
+
|
|
|
|
+ GetBedNet(bedNet_copy);
|
|
|
|
+
|
|
|
|
+ var bedNetMxList = GetBedNetMxList(bednet.bednetid.Value);
|
|
|
|
+ var springList = GetBedNetSpringList(bednet.bednetid.Value);
|
|
|
|
+
|
|
|
|
+ // 判断copy_bedNet.bednetcode是否存在@@字符串,如果存在,则删除@@后面的字符串,包括@@
|
|
|
|
+ if (bedNet_copy.bednetcode.IndexOf("@@") > -1)
|
|
|
|
+ {
|
|
|
|
+ bedNet_copy.bednetcode = bedNet_copy.bednetcode.Substring(bedNet_copy.bednetcode.IndexOf("@@"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bedNet_copy.bednetcode += " @@";
|
|
|
|
+ bedNet_copy.bednetcode += DateTime.Now.ToString("yyyMMdd_mmhhss");
|
|
|
|
+ bedNet_copy.bednetid = 0;
|
|
|
|
+ bedNet_copy.mattress_width = bednet.mattress_width;
|
|
|
|
+ bedNet_copy.mattress_length = bednet.mattress_length;
|
|
|
|
+
|
|
|
|
+ foreach(var mx in bedNetMxList)
|
|
|
|
+ {
|
|
|
|
+ if(bednetmx.spring_qty_width > 0 && bednetmx.spring_qty_length > 0)
|
|
|
|
+ {
|
|
|
|
+ mx.spring_qty_length = bednetmx.spring_qty_length;
|
|
|
|
+ mx.spring_qty_width = bednetmx.spring_qty_width;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SaveBedNet(bedNet_copy, bedNetMxList, springList);
|
|
|
|
+
|
|
|
|
+ newId = bedNet_copy.bednetid.Value;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|