From c2bc05c2ac333b7674841fdfddbb8f70e409d18e Mon Sep 17 00:00:00 2001 From: 10191 <506754232@qq.com> Date: Wed, 24 Jun 2026 20:31:39 +0800 Subject: [PATCH] 11 --- HJGL_DS/BLL/Funs.cs | 146 ++++++++++-------- .../DataIn/DrawingRecognitionContent.aspx.cs | 20 ++- 2 files changed, 97 insertions(+), 69 deletions(-) diff --git a/HJGL_DS/BLL/Funs.cs b/HJGL_DS/BLL/Funs.cs index 621b7a4..5a434d1 100644 --- a/HJGL_DS/BLL/Funs.cs +++ b/HJGL_DS/BLL/Funs.cs @@ -4,19 +4,20 @@ namespace BLL using System.Collections.Generic; using System.Globalization; using System.Data.Linq; + using System.Text.RegularExpressions; /// - /// ͨ÷ࡣ + /// ͨ�÷����ࡣ /// public static class Funs { /// - /// άһDB + /// ά��һ��DB���� /// private static Dictionary dataBaseLinkList = new System.Collections.Generic.Dictionary(); /// - /// άһDB + /// ά��һ��DB���� /// public static System.Collections.Generic.Dictionary DBList { @@ -27,7 +28,7 @@ namespace BLL } /// - /// ݿַ + /// ���ݿ������ַ��� /// private static string connString; @@ -37,7 +38,7 @@ namespace BLL public static string usingMatId; /// - /// ݿַ + /// ���ݿ������ַ����� /// public static string ConnString { @@ -45,7 +46,7 @@ namespace BLL { if (connString == null) { - throw new NotSupportedException("ַ"); + throw new NotSupportedException("�����������ַ�����"); } return connString; @@ -55,7 +56,7 @@ namespace BLL { if (connString != null) { - throw new NotSupportedException("ã"); + throw new NotSupportedException("���������ã�"); } connString = value; @@ -69,7 +70,7 @@ namespace BLL } /// - /// λ + /// ��λ���� /// public static string UnitSet { @@ -78,7 +79,7 @@ namespace BLL } /// - /// · + /// ·�� /// public static string RootPath { @@ -87,7 +88,7 @@ namespace BLL } /// - /// ϵͳ + /// ϵͳ�� /// public static string SystemName { @@ -95,7 +96,7 @@ namespace BLL set; } /// - /// AD + /// AD���� /// public static string ADomainUrl { @@ -103,7 +104,7 @@ namespace BLL set; } /// - /// APPصַ + /// APP���ص�ַ /// public static string APPUrl { @@ -121,7 +122,7 @@ namespace BLL /// - /// ÿҳ + /// ÿҳ���� /// public static int PageSize { @@ -130,7 +131,7 @@ namespace BLL } = 15; /// - /// ݿġ + /// ���ݿ������ġ� /// public static Model.SGGLDB DB { @@ -146,50 +147,50 @@ namespace BLL } /// - /// ΪĿ "ѡ" + /// ΪĿ����������� "��ѡ��" �� /// - /// Ŀ + /// Ŀ�������� public static void PleaseSelect(System.Web.UI.WebControls.DropDownList DDL) { - DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- ѡ -", "0")); + DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- ��ѡ�� -", "0")); return; } /// - /// ΪĿ "ѡ" + /// ΪĿ����������� "��ѡ��" �� /// - /// Ŀ + /// Ŀ�������� public static void FineUIPleaseSelect(FineUIPro.DropDownList DDL) { - DDL.Items.Insert(0, new FineUIPro.ListItem("- ѡ -", BLL.Const._Null)); + DDL.Items.Insert(0, new FineUIPro.ListItem("- ��ѡ�� -", BLL.Const._Null)); return; } /// - /// ΪĿ "±" + /// ΪĿ����������� "���±���" �� /// - /// Ŀ + /// Ŀ�������� public static void ReCompileSelect(System.Web.UI.WebControls.DropDownList DDL) { - DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("±", "0")); + DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("���±���", "0")); return; } /// - /// ΪĿ "±" + /// ΪĿ����������� "���±���" �� /// - /// Ŀ + /// Ŀ�������� public static void FineUIReCompileSelect(FineUIPro.DropDownList DDL) { - DDL.Items.Insert(0, new FineUIPro.ListItem("±", "0")); + DDL.Items.Insert(0, new FineUIPro.ListItem("���±���", "0")); return; } /// - /// ַǷΪ + /// �ַ����Ƿ�Ϊ������ /// - /// Ҫַ - /// ǻ + /// Ҫ�����ַ��� + /// �����ǻ�� public static bool IsDecimal(string decimalStr) { if (String.IsNullOrEmpty(decimalStr)) @@ -210,10 +211,10 @@ namespace BLL } /// - /// жһַǷ + /// �ж�һ���ַ����Ƿ������� /// - /// Ҫַ - /// ǻ + /// Ҫ�����ַ��� + /// �����ǻ�� public static bool IsInteger(string integerStr) { if (String.IsNullOrEmpty(integerStr)) @@ -234,10 +235,10 @@ namespace BLL } /// - /// ȡµ + /// ��ȡ�µ����� /// - /// Ҫת - /// µ + /// Ҫת�������� + /// �µ����� public static string InterceptDecimal(object number) { if (number == null) @@ -284,11 +285,11 @@ namespace BLL } /// - /// жַӵnλʼԺǷΪ0 + /// �ж��ַ����ӵ�nλ��ʼ�Ժ��Ƿ�Ϊ0 /// - /// Ҫжϵַ - /// ʼλ - /// falseΪ0trueΪ0 + /// Ҫ�жϵ��ַ��� + /// ��ʼ��λ�� + /// false����Ϊ0��true��Ϊ0 public static bool GetStr(string number, int n) { for (int i = n; i < number.Length; i++) @@ -302,11 +303,11 @@ namespace BLL } /// - /// ȡַ + /// ��ȡ�ַ������� /// - /// Ҫȡַ - /// - /// ȡַ + /// Ҫ��ȡ���ַ��� + /// ���� + /// ��ȡ���ַ��� public static string GetSubStr(object str, object n) { if (str != null) @@ -325,7 +326,7 @@ namespace BLL /// - /// ıתʱ + /// �����ı�ת��ʱ������ /// /// public static DateTime? GetNewDateTime(string time) @@ -349,7 +350,7 @@ namespace BLL } /// - /// ıת + /// �����ı�ת������ /// /// public static decimal? GetNewDecimal(string value) @@ -373,7 +374,7 @@ namespace BLL } /// - /// ıת + /// �����ı�ת������ /// /// public static decimal GetNewDecimalOrZero(string value) @@ -385,19 +386,42 @@ namespace BLL { returnValue = decimal.Parse(value); } - catch (Exception ex) + catch (Exception) { - ErrLogInfo.WriteLog(ex); - return returnValue; + // 如果直接解析失败(如带单位 "10M", "5KM", "3KG"),取前面的数字部分 + try + { + Match match = Regex.Match(value, @"\d+\.?\d*"); + if (match.Success && decimal.TryParse(match.Value, out decimal number)) + { + returnValue = number; + } + } + catch (Exception ex) + { + ErrLogInfo.WriteLog(ex); + } } } return returnValue; } + /// + /// 从qty字符串中提取单位(如 "10M" → "M", "5KG" → "KG", "33.4 mm" → "mm", "10" → "") + /// + public static string GetUnitFromQty(string value) + { + if (string.IsNullOrEmpty(value)) return ""; + Match match = Regex.Match(value.Trim(), @"^\d+\.?\d*\s*(.*)$"); + if (match.Success) + return match.Groups[1].Value.Trim(); + return ""; + } + /// - /// ıת + /// �����ı�ת���������� /// /// public static int? GetNewInt(string value) @@ -421,7 +445,7 @@ namespace BLL } /// - /// ıת + /// �����ı�ת���������� /// /// public static int GetNewIntOrZero(string value) @@ -443,7 +467,7 @@ namespace BLL } /// - /// ָϴļ + /// ָ���ϴ��ļ������� /// /// public static string GetNewFileName() @@ -453,7 +477,7 @@ namespace BLL } /// - /// ݱʶַlist + /// ���ݱ�ʶ�����ַ���list /// /// /// @@ -470,24 +494,24 @@ namespace BLL } /// - /// ݵһҳ͵ڶҳܼ¼ȷҪӡҳ + /// ���ݵ�һҳ�͵ڶ�ҳ�������ܼ�¼����ȷ����Ҫ��ӡ��ҳ /// - /// һҳ - /// ڶҳ - /// ܼ¼ + /// ��һҳ���� + /// �ڶ�ҳ���� + /// �ܼ�¼�� /// public static int GetPagesCountByPageSize(int pageSize1, int pageSize2, int count) { int pagesCount = 0; - if (pageSize1 >= count) //ܼ¼Сڵڵһҳ + if (pageSize1 >= count) //�ܼ�¼��С�ڵ��ڵ�һҳ���� { pagesCount = 1; } - else if (count > pageSize1 && count <= (pageSize1 + pageSize2)) //ܼ¼ڵһҳСڵڵһҳӵڶҳ + else if (count > pageSize1 && count <= (pageSize1 + pageSize2)) //�ܼ�¼�����ڵ�һҳ������С�ڵ��ڵ�һҳ�ӵڶ�ҳ������ { pagesCount = 2; } - else //ܼ¼ڵһҳӵڶҳ + else //�ܼ�¼�����ڵ�һҳ�ӵڶ�ҳ������ { int lastCount = count - pageSize1; decimal c = Convert.ToDecimal(Math.Round(Convert.ToDecimal(lastCount) / Convert.ToDecimal(pageSize2), 2)); @@ -506,7 +530,7 @@ namespace BLL } /// - /// ȡϴη + /// ��ȡ�ϴη������ /// /// public static string GetRepariMark(string repairMark) diff --git a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs index 51927c9..0e44d45 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/DrawingRecognitionContent.aspx.cs @@ -394,7 +394,7 @@ namespace FineUIPro.Web.HJGL.DataIn row["category"] = item.Value("category"); row["description"] = item.Value("description"); row["spec"] = item.Value("spec"); - row["qty"] = item.Value("qty").Replace("M","").Replace("m",""); + row["qty"] = item.Value("qty"); row["page_no"] = item.Value("page_no"); row["remark"] = item.Value("remark"); if (string.IsNullOrEmpty(row["drawing_number"].ToString())) @@ -462,7 +462,8 @@ namespace FineUIPro.Web.HJGL.DataIn g.Key.category, g.Key.spec, g.Key.description, - qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field("qty"))) + qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field("qty"))), + unit = g.Select(r => Funs.GetUnitFromQty(r.Field("qty") ?? "")).FirstOrDefault(u => !string.IsNullOrEmpty(u)) ?? "" }); foreach (var g in groups2) { @@ -471,7 +472,7 @@ namespace FineUIPro.Web.HJGL.DataIn newRow["drawing_number"] = g.drawing_number; newRow["category"] = g.category; newRow["spec"] = g.spec; - newRow["qty"] = g.qty; + newRow["qty"] = g.qty.ToString() + g.unit; newRow["description"] = g.description; dtGroupByDrawing.Rows.Add(newRow); } @@ -507,7 +508,8 @@ namespace FineUIPro.Web.HJGL.DataIn g.Key.category, g.Key.spec, g.Key.description, - qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field("qty"))) + qty = g.Sum(r => Funs.GetNewDecimalOrZero(r.Field("qty"))), + unit = g.Select(r => Funs.GetUnitFromQty(r.Field("qty") ?? "")).FirstOrDefault(u => !string.IsNullOrEmpty(u)) ?? "" }); foreach (var g in groups3) { @@ -516,7 +518,7 @@ namespace FineUIPro.Web.HJGL.DataIn newRow["pipe_no"] = g.pipe_no; newRow["category"] = g.category; newRow["spec"] = g.spec; - newRow["qty"] = g.qty; + newRow["qty"] = g.qty.ToString() + g.unit; newRow["description"] = g.description; dtGroupByPipe.Rows.Add(newRow); } @@ -559,12 +561,14 @@ namespace FineUIPro.Web.HJGL.DataIn row["description"] = g.Key.desc; decimal totalQty = 0; + string unit = ""; foreach (var r in g) { - if (decimal.TryParse(r["qty"].ToString(), out decimal qty)) - totalQty += qty; + totalQty += Funs.GetNewDecimalOrZero(r["qty"].ToString()); + if (string.IsNullOrEmpty(unit)) + unit = Funs.GetUnitFromQty(r["qty"].ToString()); } - row["qty"] = totalQty.ToString(); + row["qty"] = totalQty.ToString() + unit; dtSummary.Rows.Add(row); } }