From bdc209ecb15b7b53e82fbc77e1e4590cc09a9dc9 Mon Sep 17 00:00:00 2001 From: CPL <1179393954@qq.com> Date: Thu, 21 Mar 2024 15:04:26 +0800 Subject: [PATCH] =?UTF-8?q?V2.0.5=20=E6=9B=B4=E6=96=B0=E9=92=A2=E4=B8=9D?= =?UTF-8?q?=E6=96=AD=E8=A3=82=EF=BC=8C=E6=AE=8B=E8=83=B6=E5=A0=B5=E5=AD=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BanBoShi/Properties/AssemblyInfo.cs | 4 +- .../BanBoShi/SysCtrl/SysEnum.cs | 12 +- .../BanBoShi/SysCtrl/SysMgr.cs | 89 ++- .../BanBoShi/SysCtrl/SysUpdata.cs | 7 +- .../SysUI/DefectPicShow/DataQueryFrm.cs | 12 +- .../SysUI/DefectPicShow/DefectImageShowFrm.cs | 3 +- .../SysUI/DefectPicShow/DistributionFrm.cs | 5 +- .../SysUI/ProcessStep/Prop/SizeDefectProp.cs | 67 +- halftoneproject-master/Models/Order.cs | 2 + .../Service/OrderService.cs | 730 +++++++++--------- 更新日志.txt | 1 + 11 files changed, 513 insertions(+), 419 deletions(-) diff --git a/halftoneproject-master/BanBoShi/Properties/AssemblyInfo.cs b/halftoneproject-master/BanBoShi/Properties/AssemblyInfo.cs index 1b21aaea..1913f76a 100644 --- a/halftoneproject-master/BanBoShi/Properties/AssemblyInfo.cs +++ b/halftoneproject-master/BanBoShi/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.5.0")] -[assembly: AssemblyFileVersion("2.0.5.0")] +[assembly: AssemblyVersion("2.0.5.1")] +[assembly: AssemblyFileVersion("2.0.5.1")] diff --git a/halftoneproject-master/BanBoShi/SysCtrl/SysEnum.cs b/halftoneproject-master/BanBoShi/SysCtrl/SysEnum.cs index f25f08e0..75f69e3b 100644 --- a/halftoneproject-master/BanBoShi/SysCtrl/SysEnum.cs +++ b/halftoneproject-master/BanBoShi/SysCtrl/SysEnum.cs @@ -133,6 +133,10 @@ namespace MaiMuAOI.SysCtrl sx, [Description("断栅")] ds, + [Description("钢丝断裂")] + gsdl, + [Description("残胶堵孔")] + cjdk, } public enum DefectNameEnum { @@ -147,7 +151,9 @@ namespace MaiMuAOI.SysCtrl 压线, 斜边, 栅线, - 断栅 + 断栅, + 钢丝断裂, + 残胶堵孔 } public enum ValType { @@ -405,6 +411,10 @@ namespace MaiMuAOI.SysCtrl XBCount, [Description("栅线数量")] SXCount, + [Description("钢丝断裂数量")] + GSDLCount, + [Description("残胶堵孔数量")] + CJDKCount, [Description("检测单号")] DetectOrder, diff --git a/halftoneproject-master/BanBoShi/SysCtrl/SysMgr.cs b/halftoneproject-master/BanBoShi/SysCtrl/SysMgr.cs index b9f81aed..c9a3799f 100644 --- a/halftoneproject-master/BanBoShi/SysCtrl/SysMgr.cs +++ b/halftoneproject-master/BanBoShi/SysCtrl/SysMgr.cs @@ -2934,6 +2934,12 @@ namespace MaiMuAOI.SysCtrl case "sx": order.SXCount++; break; + case "gsdl": + order.GSDLCount++; + break; + case "cjdk": + order.CJDKCount++; + break; } } } @@ -6254,28 +6260,13 @@ namespace MaiMuAOI.SysCtrl //判断是否合格 DefectCodeEnum defectCode; - string defectNames = ""; - //if (model.QualifiedCriterionList != null && model.QualifiedCriterionList.Count > 0) - //{ - // int itemDefectCount; - // foreach (var item in model.QualifiedCriterionList) - // { - // defectCode = EnumExtension.Convert2Enum(item.DefectCode); - // itemDefectCount = getDefectCountFromCode(order, defectCode); - // if (item.MaxDefectCount > -1 && itemDefectCount > item.MaxDefectCount) - // { - // order.Qualified = false; - // defectNames += $"{EnumExtension.GetEnumDescription(defectCode)}({itemDefectCount}),"; - // } - // } - //} - //else + string defectNames = ""; { #region 结果判断 Log("结果", "结果判断"); int itemDefectCount; bool isGetQua = false; - for (int enumcnt = 0; enumcnt < 12; enumcnt++) + for (int enumcnt = 0; enumcnt < 14; enumcnt++) { isGetQua = false; //判断是否是过滤项 @@ -6485,7 +6476,7 @@ namespace MaiMuAOI.SysCtrl { Log("结果", "默认判断"); int itemDefectCount; - for (int enumcnt = 0; enumcnt < 12; enumcnt++) + for (int enumcnt = 0; enumcnt < 14; enumcnt++) { itemDefectCount = getDefectCountFromCode(order, (DefectCodeEnum)enumcnt); if (itemDefectCount > 0) @@ -6684,6 +6675,10 @@ namespace MaiMuAOI.SysCtrl return order.XBCount; case DefectCodeEnum.sx: return order.SXCount; + case DefectCodeEnum.gsdl: + return order.GSDLCount; + case DefectCodeEnum.cjdk: + return order.CJDKCount; default: return 0; } @@ -8618,6 +8613,26 @@ namespace MaiMuAOI.SysCtrl CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code, ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code }); + if (!string.IsNullOrEmpty(defectParam.ExcelGSDLCount)) + CurrPrintInfos.Add(new PrintInfo() + { + IsLabel = false, + IsValue = false, + PrintKey = defectParam.ExcelGSDLCount, + PrintCode = "ExcelGSDLCount", + CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code, + ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code + }); + if (!string.IsNullOrEmpty(defectParam.ExcelCJDKCount)) + CurrPrintInfos.Add(new PrintInfo() + { + IsLabel = false, + IsValue = false, + PrintKey = defectParam.ExcelCJDKCount, + PrintCode = "ExcelCJDKCount", + CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code, + ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code + }); } if (defectParam.OpenPrintLabel) { @@ -8741,6 +8756,26 @@ namespace MaiMuAOI.SysCtrl CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code, ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code }); + if (!string.IsNullOrEmpty(defectParam.LabelGSDLCount)) + CurrPrintInfos.Add(new PrintInfo() + { + IsLabel = true, + IsValue = false, + PrintKey = defectParam.LabelGSDLCount, + PrintCode = "LabelGSDLCount", + CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code, + ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code + }); + if (!string.IsNullOrEmpty(defectParam.LabelCJDKCount)) + CurrPrintInfos.Add(new PrintInfo() + { + IsLabel = true, + IsValue = false, + PrintKey = defectParam.LabelCJDKCount, + PrintCode = "LabelCJDKCount", + CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code, + ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code + }); } } #endregion @@ -9376,6 +9411,12 @@ namespace MaiMuAOI.SysCtrl case PrintDataEnum.SXCount: value = order.SXCount.ToString(); break; + case PrintDataEnum.GSDLCount: + value = order.GSDLCount.ToString(); + break; + case PrintDataEnum.CJDKCount: + value = order.CJDKCount.ToString(); + break; } break; } @@ -9536,6 +9577,12 @@ namespace MaiMuAOI.SysCtrl case "LabelSXCount": value = order.SXCount.ToString(); break; + case "LabelGSDLCount": + value = order.GSDLCount.ToString(); + break; + case "LabelCJDKCount": + value = order.CJDKCount.ToString(); + break; } printData.Add(item.PrintKey, value); } @@ -9611,6 +9658,12 @@ namespace MaiMuAOI.SysCtrl case "ExcelSXCount": value = order.SXCount.ToString(); break; + case "ExcelGSDLCount": + value = order.GSDLCount.ToString(); + break; + case "ExcelCJDKCount": + value = order.CJDKCount.ToString(); + break; } printData.Add(item.PrintKey, value); } diff --git a/halftoneproject-master/BanBoShi/SysCtrl/SysUpdata.cs b/halftoneproject-master/BanBoShi/SysCtrl/SysUpdata.cs index abbcd268..fa15d704 100644 --- a/halftoneproject-master/BanBoShi/SysCtrl/SysUpdata.cs +++ b/halftoneproject-master/BanBoShi/SysCtrl/SysUpdata.cs @@ -9,7 +9,7 @@ namespace MaiMuAOI.SysCtrl public class SysUpdata { //系统信息 - public static string Info = "软件名称:版博士\r\n软件版本:V2.0.5\r\n公司:迈沐智能科技有限公司\r\n"; + public static string Info = "软件名称:版博士\r\n软件版本:V2.0.5A\r\n公司:迈沐智能科技有限公司\r\n"; public static string Updata = "V2.0:\r\n" + "\t新版本,新流程,兼容老流程\r\n" + @@ -52,7 +52,8 @@ namespace MaiMuAOI.SysCtrl "\t4.打印配置移动到产品和流程中\r\n" + "\t5.开启前部相机查看小图功能\r\n" + "\t6.加入可开启单边计算目数功能\r\n" + - "V2.0.5:\r\n" + - "\t1.测试项加入SP2—主栅宽度\r\n"; + "V2.0.5A:\r\n" + + "\t1.测试项加入SP2—主栅宽度\r\n" + + "\t2.缺陷项加入钢丝断裂,残胶堵孔\r\n"; } } diff --git a/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DataQueryFrm.cs b/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DataQueryFrm.cs index 86674e00..cf2ded7d 100644 --- a/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DataQueryFrm.cs +++ b/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DataQueryFrm.cs @@ -581,7 +581,9 @@ namespace MaiMuAOI.SysUI.DefectPicShow dt.Columns.Add(new DataColumn("划伤数量", typeof(int)));//在表中添加int类型的列 dt.Columns.Add(new DataColumn("压线数量", typeof(int)));//在表中添加int类型的列 dt.Columns.Add(new DataColumn("斜边数量", typeof(int)));//在表中添加int类型的列 - dt.Columns.Add(new DataColumn("栅线数量", typeof(int)));//在表中添加int类型的列 + dt.Columns.Add(new DataColumn("栅线数量", typeof(int)));//在表中添加int类型的列 + dt.Columns.Add(new DataColumn("钢丝断裂数量", typeof(int)));//在表中添加int类型的列 + dt.Columns.Add(new DataColumn("残胶堵孔数量", typeof(int)));//在表中添加int类型的列 //插入按钮 dataGridView1.DataSource = dt; @@ -795,6 +797,8 @@ namespace MaiMuAOI.SysUI.DefectPicShow dr["压线数量"] = item.YXCount; dr["斜边数量"] = item.XBCount; dr["栅线数量"] = item.SXCount; + dr["钢丝断裂数量"] = item.GSDLCount; + dr["残胶堵孔数量"] = item.CJDKCount; dts.Rows.Add(dr);//在表的对象的行里添加此行 } @@ -1266,7 +1270,9 @@ namespace MaiMuAOI.SysUI.DefectPicShow dt.Columns.Add(new DataColumn("划伤数量", typeof(int)));//在表中添加int类型的列 dt.Columns.Add(new DataColumn("压线数量", typeof(int)));//在表中添加int类型的列 dt.Columns.Add(new DataColumn("斜边数量", typeof(int)));//在表中添加int类型的列 - dt.Columns.Add(new DataColumn("栅线数量", typeof(int)));//在表中添加int类型的列 + dt.Columns.Add(new DataColumn("栅线数量", typeof(int)));//在表中添加int类型的列 + dt.Columns.Add(new DataColumn("钢丝断裂数量", typeof(int)));//在表中添加int类型的列 + dt.Columns.Add(new DataColumn("残胶堵孔数量", typeof(int)));//在表中添加int类型的列 foreach (var item in QueryAllOrders) @@ -1317,6 +1323,8 @@ namespace MaiMuAOI.SysUI.DefectPicShow dr["压线数量"] = item.YXCount; dr["斜边数量"] = item.XBCount; dr["栅线数量"] = item.SXCount; + dr["钢丝断裂数量"] = item.GSDLCount; + dr["残胶堵孔数量"] = item.CJDKCount; dt.Rows.Add(dr);//在表的对象的行里添加此行 } diff --git a/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DefectImageShowFrm.cs b/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DefectImageShowFrm.cs index 7d66ff05..783f812e 100644 --- a/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DefectImageShowFrm.cs +++ b/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DefectImageShowFrm.cs @@ -18,7 +18,8 @@ namespace MaiMuAOI.SysUI.DefectPicShow public partial class DefectImageShowFrm : Form { private Color[] colorList = { Color.Red, Color.Green, Color.DarkViolet , Color.Magenta, Color.Orange, Color.Brown, - Color.Olive, Color.PaleGreen, Color.CadetBlue,Color.Aqua,Color.YellowGreen,Color.Blue,Color.SpringGreen,Color.Fuchsia,Color.White }; + Color.Olive, Color.PaleGreen, Color.CadetBlue,Color.Aqua,Color.YellowGreen,Color.Blue, + Color.SpringGreen,Color.Fuchsia,Color.Wheat,Color.AliceBlue,Color.Azure }; private Order mOrder; private string imgPath; private int defectType; diff --git a/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DistributionFrm.cs b/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DistributionFrm.cs index 1395ba92..fc7049df 100644 --- a/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DistributionFrm.cs +++ b/halftoneproject-master/BanBoShi/SysUI/DefectPicShow/DistributionFrm.cs @@ -32,8 +32,9 @@ namespace MaiMuAOI.SysUI.DefectPicShow private Yolo_Class yolo = new Yolo_Class(); private int currDefectIndex = 0; private Color[] colorList = { Color.Red, Color.Green, Color.DarkViolet , Color.Magenta, Color.Orange, Color.Brown, - Color.Olive, Color.PaleGreen, Color.CadetBlue,Color.Aqua,Color.YellowGreen,Color.Blue,Color.SpringGreen,Color.Fuchsia,Color.White }; - private string[] DefectCodes = { "dk", "zw","xws","gsyc","qk", "zk","pp","hs","yx", "xb", "sx","ds"}; + Color.Olive, Color.PaleGreen, Color.CadetBlue,Color.Aqua,Color.YellowGreen,Color.Blue, + Color.SpringGreen,Color.Fuchsia,Color.Wheat,Color.AliceBlue,Color.Azure }; + private string[] DefectCodes = { "dk", "zw","xws","gsyc","qk", "zk","pp","hs","yx", "xb", "sx","ds","gsdl" ,"cjdk"}; #region 表格数据类型 private class DefectStruct { diff --git a/halftoneproject-master/BanBoShi/SysUI/ProcessStep/Prop/SizeDefectProp.cs b/halftoneproject-master/BanBoShi/SysUI/ProcessStep/Prop/SizeDefectProp.cs index ed622c6c..03164ceb 100644 --- a/halftoneproject-master/BanBoShi/SysUI/ProcessStep/Prop/SizeDefectProp.cs +++ b/halftoneproject-master/BanBoShi/SysUI/ProcessStep/Prop/SizeDefectProp.cs @@ -62,60 +62,69 @@ namespace MaiMuAOI.SysUI.ProcessStep.Prop [PropertyOrder(45), Browsable(true), Category("5 走位"), DisplayName("5.5 Y方向步进次数"), Description("使用手动设置的步进次数")] public int Ystep { get; set; } - [PropertyOrder(51), Browsable(true), Category("6 打印"), DisplayName("6.1 开启Excel打印"), Description("启用本工序数据打印")] + [PropertyOrder(51), Browsable(true), Category("6 打印"), DisplayName("6.01 开启Excel打印"), Description("启用本工序数据打印")] public bool OpenPrint { get; set; } - [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.2 打印缺陷总数"), Description("打印数据的位置")] + [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.02 打印缺陷总数"), Description("打印数据的位置")] public string ExcelDefectCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.3 打印堵孔数量"), Description("打印数据的位置")] + [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.03 打印堵孔数量"), Description("打印数据的位置")] public string ExcelDKCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.4 打印脏污数量"), Description("打印数据的位置")] + [PropertyOrder(54), Browsable(true), Category("6 打印"), DisplayName("6.04 打印脏污数量"), Description("打印数据的位置")] public string ExcelZWCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.5 打印钢丝异常数量"), Description("打印数据的位置")] + [PropertyOrder(55), Browsable(true), Category("6 打印"), DisplayName("6.05 打印钢丝异常数量"), Description("打印数据的位置")] public string ExcelGSYCCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.6 打印纤维丝数量"), Description("打印数据的位置")] + [PropertyOrder(56), Browsable(true), Category("6 打印"), DisplayName("6.06 打印纤维丝数量"), Description("打印数据的位置")] public string ExcelXWSCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.7 打印缺口数量数量"), Description("打印数据的位置")] + [PropertyOrder(57), Browsable(true), Category("6 打印"), DisplayName("6.07 打印缺口数量"), Description("打印数据的位置")] public string ExcelQKCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.8 打印针孔数量"), Description("打印数据的位置")] + [PropertyOrder(58), Browsable(true), Category("6 打印"), DisplayName("6.08 打印针孔数量"), Description("打印数据的位置")] public string ExcelZKCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.9 打印泡泡数量"), Description("打印数据的位置")] + [PropertyOrder(59), Browsable(true), Category("6 打印"), DisplayName("6.09 打印泡泡数量"), Description("打印数据的位置")] public string ExcelPPCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.10 打印划伤数量"), Description("打印数据的位置")] + [PropertyOrder(60), Browsable(true), Category("6 打印"), DisplayName("6.10 打印划伤数量"), Description("打印数据的位置")] public string ExcelHSCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.11 打印压线数量"), Description("打印数据的位置")] + [PropertyOrder(61), Browsable(true), Category("6 打印"), DisplayName("6.11 打印压线数量"), Description("打印数据的位置")] public string ExcelYXCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.12 打印斜边数量"), Description("打印数据的位置")] + [PropertyOrder(62), Browsable(true), Category("6 打印"), DisplayName("6.12 打印斜边数量"), Description("打印数据的位置")] public string ExcelXBCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.13 打印栅线数量"), Description("打印数据的位置")] + [PropertyOrder(63), Browsable(true), Category("6 打印"), DisplayName("6.13 打印栅线数量"), Description("打印数据的位置")] public string ExcelSXCount { get; set; } - [PropertyOrder(54), Browsable(true), Category("7 标签打印"), DisplayName("7.1 开启标签打印"), Description("启用本工序数据打印")] + [PropertyOrder(64), Browsable(true), Category("6 打印"), DisplayName("6.14 打印钢丝断裂数量"), Description("打印数据的位置")] + public string ExcelGSDLCount { get; set; } + [PropertyOrder(65), Browsable(true), Category("6 打印"), DisplayName("6.15 打印残胶堵孔数量"), Description("打印数据的位置")] + public string ExcelCJDKCount { get; set; } + + [PropertyOrder(71), Browsable(true), Category("7 标签打印"), DisplayName("7.01 开启标签打印"), Description("启用本工序数据打印")] public bool OpenPrintLabel { get; set; } - [PropertyOrder(52), Browsable(true), Category("7 标签打印"), DisplayName("7.2 标签打印缺陷总数"), Description("打印数据的位置")] + [PropertyOrder(72), Browsable(true), Category("7 标签打印"), DisplayName("7.02 标签打印缺陷总数"), Description("打印数据的位置")] public string LabelDefectCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("7 标签打印"), DisplayName("7.3 标签打印堵孔数量"), Description("打印数据的位置")] + [PropertyOrder(73), Browsable(true), Category("7 标签打印"), DisplayName("7.03 标签打印堵孔数量"), Description("打印数据的位置")] public string LabelDKCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("7 标签打印"), DisplayName("7.4 标签打印脏污数量"), Description("打印数据的位置")] + [PropertyOrder(74), Browsable(true), Category("7 标签打印"), DisplayName("7.04 标签打印脏污数量"), Description("打印数据的位置")] public string LabelZWCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("7 标签打印"), DisplayName("7.5 标签打印钢丝异常数量"), Description("打印数据的位置")] + [PropertyOrder(75), Browsable(true), Category("7 标签打印"), DisplayName("7.05 标签打印钢丝异常数量"), Description("打印数据的位置")] public string LabelGSYCCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("7 标签打印"), DisplayName("7.6 标签打印纤维丝数量"), Description("打印数据的位置")] + [PropertyOrder(76), Browsable(true), Category("7 标签打印"), DisplayName("7.06 标签打印纤维丝数量"), Description("打印数据的位置")] public string LabelXWSCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("7 标签打印"), DisplayName("7.7 标签打印缺口数量数量"), Description("打印数据的位置")] + [PropertyOrder(77), Browsable(true), Category("7 标签打印"), DisplayName("7.07 标签打印缺口数量"), Description("打印数据的位置")] public string LabelQKCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("7 标签打印"), DisplayName("7.8 标签打印针孔数量"), Description("打印数据的位置")] + [PropertyOrder(78), Browsable(true), Category("7 标签打印"), DisplayName("7.08 标签打印针孔数量"), Description("打印数据的位置")] public string LabelZKCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("7 标签打印"), DisplayName("7.9 标签打印泡泡数量"), Description("打印数据的位置")] + [PropertyOrder(79), Browsable(true), Category("7 标签打印"), DisplayName("7.09 标签打印泡泡数量"), Description("打印数据的位置")] public string LabelPPCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("7 标签打印"), DisplayName("7.10 标签打印划伤数量"), Description("打印数据的位置")] + [PropertyOrder(80), Browsable(true), Category("7 标签打印"), DisplayName("7.10 标签打印划伤数量"), Description("打印数据的位置")] public string LabelHSCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("7 标签打印"), DisplayName("7.11 标签打印压线数量"), Description("打印数据的位置")] + [PropertyOrder(81), Browsable(true), Category("7 标签打印"), DisplayName("7.11 标签打印压线数量"), Description("打印数据的位置")] public string LabelYXCount { get; set; } - [PropertyOrder(52), Browsable(true), Category("7 标签打印"), DisplayName("7.12 标签打印斜边数量"), Description("打印数据的位置")] + [PropertyOrder(82), Browsable(true), Category("7 标签打印"), DisplayName("7.12 标签打印斜边数量"), Description("打印数据的位置")] public string LabelXBCount { get; set; } - [PropertyOrder(53), Browsable(true), Category("7 打印"), DisplayName("7.13 打印栅线数量"), Description("打印数据的位置")] + [PropertyOrder(83), Browsable(true), Category("7 标签打印"), DisplayName("7.13 标签打印栅线数量"), Description("打印数据的位置")] public string LabelSXCount { get; set; } + [PropertyOrder(84), Browsable(true), Category("7 标签打印"), DisplayName("7.12 标签打印钢丝断裂数量"), Description("打印数据的位置")] + public string LabelGSDLCount { get; set; } + [PropertyOrder(85), Browsable(true), Category("7 标签打印"), DisplayName("7.13 标签打印残胶堵孔数量"), Description("打印数据的位置")] + public string LabelCJDKCount { get; set; } - [PropertyOrder(71), Browsable(true), Category("8 控制"), DisplayName("8.1 禁用工序"), Description("禁用本工序(True-是;False-否)")] + [PropertyOrder(91), Browsable(true), Category("8 控制"), DisplayName("8.1 禁用工序"), Description("禁用本工序(True-是;False-否)")] public bool Disable { get; set; } public SizeDefectProp() @@ -164,6 +173,8 @@ namespace MaiMuAOI.SysUI.ProcessStep.Prop ExcelYXCount = ""; ExcelXBCount = ""; ExcelSXCount = ""; + ExcelGSDLCount = ""; + ExcelCJDKCount = ""; LabelDefectCount = ""; LabelDKCount = ""; @@ -177,6 +188,8 @@ namespace MaiMuAOI.SysUI.ProcessStep.Prop LabelYXCount = ""; LabelXBCount = ""; LabelSXCount = ""; + LabelGSDLCount = ""; + LabelCJDKCount = ""; } /// diff --git a/halftoneproject-master/Models/Order.cs b/halftoneproject-master/Models/Order.cs index 71fad863..06450731 100644 --- a/halftoneproject-master/Models/Order.cs +++ b/halftoneproject-master/Models/Order.cs @@ -158,6 +158,8 @@ namespace Models public int YXCount { get; set; }//压线数量 public int XBCount { get; set; }//斜边数量 new public int SXCount { get; set; }//栅线数量 new + public int GSDLCount { get; set; }//钢丝断裂 new + public int CJDKCount { get; set; }//残胶堵孔 new #endregion /// diff --git a/halftoneproject-master/Service/OrderService.cs b/halftoneproject-master/Service/OrderService.cs index 7386343e..d5cc9d63 100644 --- a/halftoneproject-master/Service/OrderService.cs +++ b/halftoneproject-master/Service/OrderService.cs @@ -1,364 +1,368 @@ -using Models; -using Newtonsoft.Json; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Dynamic; -using System.Linq; -using System.Linq.Expressions; -using System.Text; -using System.Threading.Tasks; - -namespace Service -{ - public class OrderService : Repository - { - public bool InsertNav(Models.Order model) - { - return base.AsSugarClient().InsertNav(model) - .Include(m => m.OrderHistoryList) - .Include(a => a.DefectInfoList) - .Include (b => b.SizeDefectInfoList) - .Include(b => b.SizeDefectAverageInfoList) - .ExecuteCommand(); - } - public bool DelNav(Models.Order model) - { - return base.AsSugarClient().DeleteNav(model) - .Include(a => a.OrderHistoryList) - .Include(a => a.DefectInfoList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList - .Include(b => b.SizeDefectInfoList) - .Include(b => b.SizeDefectAverageInfoList) - .ExecuteCommand(); - } - - public int UpdateNav(Models.Order model) - { +using Models; +using Newtonsoft.Json; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Dynamic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace Service +{ + public class OrderService : Repository + { + public bool InsertNav(Models.Order model) + { + return base.AsSugarClient().InsertNav(model) + .Include(m => m.OrderHistoryList) + .Include(a => a.DefectInfoList) + .Include (b => b.SizeDefectInfoList) + .Include(b => b.SizeDefectAverageInfoList) + .ExecuteCommand(); + } + public bool DelNav(Models.Order model) + { + return base.AsSugarClient().DeleteNav(model) + .Include(a => a.OrderHistoryList) + .Include(a => a.DefectInfoList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList + .Include(b => b.SizeDefectInfoList) + .Include(b => b.SizeDefectAverageInfoList) + .ExecuteCommand(); + } + + public int UpdateNav(Models.Order model) + { return base.AsSugarClient().Updateable(model).IgnoreColumns(ignoreAllNullColumns: true) - .ExecuteCommand(); - } - //----------------------- - public List GetList(string tablename, string fields, string domain, string orderby) - { - int totalCount=0; - return GetList(tablename,fields, domain, orderby, 0, 0, ref totalCount); - } - public List GetList(string tablename,string fields, string domain, string orderby, int pageNum, int pageSize, ref int totalCount) - { - var sql = base.AsSugarClient().Queryable(tablename,""); - if (!string.IsNullOrWhiteSpace(domain)) - sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); - if (!string.IsNullOrWhiteSpace(fields) && fields!="*") - sql = sql.Select(fields); - if (!string.IsNullOrWhiteSpace(orderby)) - sql = sql.OrderBy(orderby); - else - sql = sql.OrderBy("id desc"); - - if(pageNum==0 && pageSize == 0) - return sql.ToList(); - else - return sql.ToPageList(pageNum, pageSize, ref totalCount); - } - - public List GetListEx(string fields, string domain, string orderby, int pageNum, int pageSize, ref int totalCount) - { - var sql = base.AsSugarClient().Queryable() - .Includes(m => m.StepInfo) - .Includes(m => m.ProductInfo).Includes(m => m.ProductInfo.AttachmentList) - .Includes(m => m.DefectInfoList) - .Includes(m => m.OrderHistoryList) - .Includes(m => m.SizeDefectInfoList) - .Includes(m => m.SizeDefectAverageInfoList); - //var sql = base.AsSugarClient().Queryable(tablename, ""); - if (!string.IsNullOrWhiteSpace(domain)) - sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); - if (!string.IsNullOrWhiteSpace(fields) && fields != "*") - sql = sql.Select(fields); - if (!string.IsNullOrWhiteSpace(orderby)) - sql = sql.OrderBy(orderby); - else - sql = sql.OrderBy("id desc"); - - if (pageNum == 0 && pageSize == 0) - return sql.ToList(); - else - return sql.ToPageList(pageNum, pageSize, ref totalCount); - } - public int DeleteList(string tablename, string domain) - { - var where = base.Context.Utilities.JsonToConditionalModels(domain); - return base.AsSugarClient().Deleteable().AS(tablename).Where(where).ExecuteCommand();//批量 - } - //public int DeleteIdList(string tablename, int[] ids) - //{ - // return base.AsSugarClient().Deleteable().AS(tablename).Where("Id in (@id) ", new { id = ids }).ExecuteCommand();//批量 - //} - /// - /// 批量更新+新增 - /// - /// - /// - /// - public int UpdateableList(string tablename, string lstDatas,string[] updateColumns=null) - { - int result = 0; - var list = JsonConvert.DeserializeObject>>(lstDatas); - base.AsSugarClient().Ado.BeginTran(); - foreach (Dictionary item in list) - { - if (!item.ContainsKey("Id") || Convert.ToInt32(item["Id"]) < 1) - result += base.AsSugarClient().Insertable(item).AS(tablename).ExecuteCommand(); - else - { - if(updateColumns==null || updateColumns.Length==0) - result += base.AsSugarClient().Updateable(item).WhereColumns("Id").AS(tablename).ExecuteCommand(); - else - result += base.AsSugarClient().Updateable(item).UpdateColumns(updateColumns).WhereColumns("Id").AS(tablename).ExecuteCommand(); - } - } - base.AsSugarClient().Ado.CommitTran(); - return result; - } - public bool UpdateableListEx(Order order) - { - return base.AsSugarClient().UpdateNav(order) - .Include(m => m.OrderHistoryList) - .ExecuteCommand(); - } - public List GetListNav(int pageNum, int pageSize, ref int totalCount, Expression> exp) - { - return base.AsSugarClient().Queryable() - .Includes(m => m.ProductInfo.ToList(x => new Product() { Name = x.Name, Spec = x.Spec })) - .Includes(m => m.StepInfo.ToList(x => new Step() { Name = x.Name })) - .Where(exp) - .ToPageList(pageNum, pageSize, ref totalCount); - } - public Order GetModelNav(string sn) - { - return base.AsSugarClient().Queryable() - .Includes(m => m.ProductInfo,x=>x.AssistStepInfo, info => info.ProcessList.OrderBy(x => x.Order).ToList()) //多级 - .Includes(m => m.DefectInfoList) - .First(m => m.SN == sn); - } - //获取产品 - public List GetProductList() - { - var db = base.Change();//切换仓储(新功能) - return db.AsSugarClient().Queryable() - .OrderBy(x => x.Name) - .ToList(); - } - //获取流程工序 - public List GetStepList() - { - var db = base.Change();//切换仓储(新功能) - return db.AsSugarClient().Queryable() - .OrderBy(x => x.Name) - .ToList(); - } - - //分页 - //public List GetOrderPage(Expression> where, int pagesize, int pageindex) - //{ - // return base.GetPageList(where, new SqlSugar.PageModel() { PageIndex = pageindex, PageSize = pagesize }); //使用自已的仓储方法 - //} - - //调用仓储扩展方法 - //public List GetOrderByJson(string Json) - //{ - // return base.CommQuery(Json); - //} - - /// - /// 按产品和批次 统计 合格率 - /// - /// - /// - /// - /// - /// - /// - public string GetReport_Qualified( string domain, string orderby,int pageNum, int pageSize, ref int totalCount) - { - var sql = base.AsSugarClient().Queryable() - .LeftJoin((a, b) => a.ProductId == b.Id); - if (!string.IsNullOrWhiteSpace(domain)) - sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); - var sql2 = sql.GroupBy((a,b) => new { a.ProductId,b.Name,b.Code, a.BatchId }) - .Select((a,b) => new { a.ProductId,b.Name,b.Code, a.BatchId, Qualified = SqlFunc.AggregateSum(a.Qualified ? 1 : 0), Total = SqlFunc.AggregateSum(1) }); - - if (!string.IsNullOrWhiteSpace(orderby)) - sql2 = sql2.OrderBy(orderby); - - if (pageNum == 0 && pageSize == 0) - return sql2.ToJson(); - else - return sql2.ToJsonPage(pageNum, pageSize, ref totalCount); - } - /// - /// 按日期统计合格率(日期段<=30,因只显示天) - /// - /// - /// - /// - /// - /// - /// - public string GetReport_Qualified_Date(string domain, string orderby, int pageNum, int pageSize, ref int totalCount) - { - var sql = base.AsSugarClient().Queryable(); - if (!string.IsNullOrWhiteSpace(domain)) - sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); - var sql2 = sql.GroupBy((a) => new { CreateTime = a.CreateTime.Date }) //DATE_FORMAT(NOW(), '%Y-%m-%d') - .Select((a) => new { a.CreateTime.Date, Qualified = SqlFunc.AggregateSum(a.Qualified ? 1 : 0), Total = SqlFunc.AggregateSum(1) }); - - if (!string.IsNullOrWhiteSpace(orderby)) - sql2 = sql2.OrderBy(orderby); - - if (pageNum == 0 && pageSize == 0) - return sql2.ToJson(); - else - return sql2.ToJsonPage(pageNum, pageSize, ref totalCount); - } - /// - /// 合格率[0,100,50,50] - /// - /// - /// - public List> GetReport_Qualified_Total() - { - List> result =new List>(); - int liQualifiedCount, liTotal; - DateTime now = DateTime.Now.AddDays(-1); - //DateTime now = DateTime.Parse("2023-6-13"); - //当天 - var sql = base.AsSugarClient().Queryable();//只能执行一次,不能复用 - liQualifiedCount = liTotal = 0; - var list=sql.Where(m=>m.CreateTime>=now.Date && !SqlFunc.EqualsNull(m.Qualified,null)) - .GroupBy(m=>m.Qualified) - .Select((a) => new { a.Qualified, Count= SqlFunc.AggregateCount(a.Id) }) - .ToList(); - foreach(var item in list) - { - if (item.Qualified) - liQualifiedCount = item.Count; - liTotal += item.Count; - } - //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); - result.Add(new List{ liTotal, liQualifiedCount }); - //最近一月 - sql = base.AsSugarClient().Queryable(); - now = DateTime.Now.AddDays(-30); - liQualifiedCount = liTotal = 0; - list = sql.Where(m => m.CreateTime >= now.Date && !SqlFunc.EqualsNull(m.Qualified, null)) - .GroupBy(m => m.Qualified) - .Select((a) => new { a.Qualified, Count = SqlFunc.AggregateCount(a.Id) }) - .ToList(); - foreach (var item in list) - { - if (item.Qualified) - liQualifiedCount = item.Count; - liTotal += item.Count; - } - //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); - result.Add(new List { liTotal, liQualifiedCount }); - //最近一季 - sql = base.AsSugarClient().Queryable(); - now = DateTime.Now.AddDays(-90); - liQualifiedCount = liTotal = 0; - list = sql.Where(m => m.CreateTime >= now.Date && !SqlFunc.EqualsNull(m.Qualified, null)) - .GroupBy(m => m.Qualified) - .Select((a) => new { a.Qualified, Count = SqlFunc.AggregateCount(a.Id) }) - .ToList(); - foreach (var item in list) - { - if (item.Qualified) - liQualifiedCount = item.Count; - liTotal += item.Count; - } - //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); - result.Add(new List { liTotal, liQualifiedCount }); - //最近一年 - sql = base.AsSugarClient().Queryable(); - now = DateTime.Now.AddDays(-365); - liQualifiedCount = liTotal = 0; - list = sql.Where(m => m.CreateTime >= now.Date && !SqlFunc.EqualsNull(m.Qualified, null)) - .GroupBy(m => m.Qualified) - .Select((a) => new { a.Qualified, Count = SqlFunc.AggregateCount(a.Id) }) - .ToList(); - foreach (var item in list) - { - if (item.Qualified) - liQualifiedCount = item.Count; - liTotal += item.Count; - } - //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); - result.Add(new List { liTotal, liQualifiedCount }); - - return result; - } - /// - /// 按日期统计各缺陷数 - /// - /// - /// - /// - /// - /// - /// - public string GetReport_Defects_Date(string domain, string orderby, int pageNum, int pageSize, ref int totalCount) - { - var sql = base.AsSugarClient().Queryable(); - if (!string.IsNullOrWhiteSpace(domain)) - sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); - var sql2 = sql.GroupBy((a) => new { CreateTime = a.CreateTime.Date }) - .Select((a) => new { a.CreateTime.Date, - Total = SqlFunc.AggregateSum(1), - 堵孔 = SqlFunc.AggregateSum(a.DKCount), - 脏污 = SqlFunc.AggregateSum(a.ZWCount), - 钢丝异常 = SqlFunc.AggregateSum(a.GSYCCount), - 纤维丝 = SqlFunc.AggregateSum(a.XWSCount), - 缺口 = SqlFunc.AggregateSum(a.QKCount), - 针孔 = SqlFunc.AggregateSum(a.ZKCount), - 泡泡 = SqlFunc.AggregateSum(a.PPCount), - 划伤 = SqlFunc.AggregateSum(a.HSCount), - 压线 = SqlFunc.AggregateSum(a.YXCount), - 斜边 = SqlFunc.AggregateSum(a.XBCount), - 栅线 = SqlFunc.AggregateSum(a.SXCount), - }); - - if (!string.IsNullOrWhiteSpace(orderby)) - sql2 = sql2.OrderBy(orderby); - - if (pageNum == 0 && pageSize == 0) - return sql2.ToJson(); - else - return sql2.ToJsonPage(pageNum, pageSize, ref totalCount); - } - /// - /// 缺陷总数 - /// - /// - /// - public string GetReport_Defects_Total(string domain) - { - var sql = base.AsSugarClient().Queryable(); - if (!string.IsNullOrWhiteSpace(domain)) - sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); - return sql.Select((a) => new { - 堵孔 = SqlFunc.AggregateSum(a.DKCount), - 脏污 = SqlFunc.AggregateSum(a.ZWCount), - 钢丝异常 = SqlFunc.AggregateSum(a.GSYCCount), - 纤维丝 = SqlFunc.AggregateSum(a.XWSCount), - 缺口 = SqlFunc.AggregateSum(a.QKCount), - 针孔 = SqlFunc.AggregateSum(a.ZKCount), - 泡泡 = SqlFunc.AggregateSum(a.PPCount), - 划伤 = SqlFunc.AggregateSum(a.HSCount), - 压线 = SqlFunc.AggregateSum(a.YXCount), - 斜边 = SqlFunc.AggregateSum(a.XBCount), - 栅线 = SqlFunc.AggregateSum(a.SXCount), - }).ToJson(); - } - } -} + .ExecuteCommand(); + } + //----------------------- + public List GetList(string tablename, string fields, string domain, string orderby) + { + int totalCount=0; + return GetList(tablename,fields, domain, orderby, 0, 0, ref totalCount); + } + public List GetList(string tablename,string fields, string domain, string orderby, int pageNum, int pageSize, ref int totalCount) + { + var sql = base.AsSugarClient().Queryable(tablename,""); + if (!string.IsNullOrWhiteSpace(domain)) + sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); + if (!string.IsNullOrWhiteSpace(fields) && fields!="*") + sql = sql.Select(fields); + if (!string.IsNullOrWhiteSpace(orderby)) + sql = sql.OrderBy(orderby); + else + sql = sql.OrderBy("id desc"); + + if(pageNum==0 && pageSize == 0) + return sql.ToList(); + else + return sql.ToPageList(pageNum, pageSize, ref totalCount); + } + + public List GetListEx(string fields, string domain, string orderby, int pageNum, int pageSize, ref int totalCount) + { + var sql = base.AsSugarClient().Queryable() + .Includes(m => m.StepInfo) + .Includes(m => m.ProductInfo).Includes(m => m.ProductInfo.AttachmentList) + .Includes(m => m.DefectInfoList) + .Includes(m => m.OrderHistoryList) + .Includes(m => m.SizeDefectInfoList) + .Includes(m => m.SizeDefectAverageInfoList); + //var sql = base.AsSugarClient().Queryable(tablename, ""); + if (!string.IsNullOrWhiteSpace(domain)) + sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); + if (!string.IsNullOrWhiteSpace(fields) && fields != "*") + sql = sql.Select(fields); + if (!string.IsNullOrWhiteSpace(orderby)) + sql = sql.OrderBy(orderby); + else + sql = sql.OrderBy("id desc"); + + if (pageNum == 0 && pageSize == 0) + return sql.ToList(); + else + return sql.ToPageList(pageNum, pageSize, ref totalCount); + } + public int DeleteList(string tablename, string domain) + { + var where = base.Context.Utilities.JsonToConditionalModels(domain); + return base.AsSugarClient().Deleteable().AS(tablename).Where(where).ExecuteCommand();//批量 + } + //public int DeleteIdList(string tablename, int[] ids) + //{ + // return base.AsSugarClient().Deleteable().AS(tablename).Where("Id in (@id) ", new { id = ids }).ExecuteCommand();//批量 + //} + /// + /// 批量更新+新增 + /// + /// + /// + /// + public int UpdateableList(string tablename, string lstDatas,string[] updateColumns=null) + { + int result = 0; + var list = JsonConvert.DeserializeObject>>(lstDatas); + base.AsSugarClient().Ado.BeginTran(); + foreach (Dictionary item in list) + { + if (!item.ContainsKey("Id") || Convert.ToInt32(item["Id"]) < 1) + result += base.AsSugarClient().Insertable(item).AS(tablename).ExecuteCommand(); + else + { + if(updateColumns==null || updateColumns.Length==0) + result += base.AsSugarClient().Updateable(item).WhereColumns("Id").AS(tablename).ExecuteCommand(); + else + result += base.AsSugarClient().Updateable(item).UpdateColumns(updateColumns).WhereColumns("Id").AS(tablename).ExecuteCommand(); + } + } + base.AsSugarClient().Ado.CommitTran(); + return result; + } + public bool UpdateableListEx(Order order) + { + return base.AsSugarClient().UpdateNav(order) + .Include(m => m.OrderHistoryList) + .ExecuteCommand(); + } + public List GetListNav(int pageNum, int pageSize, ref int totalCount, Expression> exp) + { + return base.AsSugarClient().Queryable() + .Includes(m => m.ProductInfo.ToList(x => new Product() { Name = x.Name, Spec = x.Spec })) + .Includes(m => m.StepInfo.ToList(x => new Step() { Name = x.Name })) + .Where(exp) + .ToPageList(pageNum, pageSize, ref totalCount); + } + public Order GetModelNav(string sn) + { + return base.AsSugarClient().Queryable() + .Includes(m => m.ProductInfo,x=>x.AssistStepInfo, info => info.ProcessList.OrderBy(x => x.Order).ToList()) //多级 + .Includes(m => m.DefectInfoList) + .First(m => m.SN == sn); + } + //获取产品 + public List GetProductList() + { + var db = base.Change();//切换仓储(新功能) + return db.AsSugarClient().Queryable() + .OrderBy(x => x.Name) + .ToList(); + } + //获取流程工序 + public List GetStepList() + { + var db = base.Change();//切换仓储(新功能) + return db.AsSugarClient().Queryable() + .OrderBy(x => x.Name) + .ToList(); + } + + //分页 + //public List GetOrderPage(Expression> where, int pagesize, int pageindex) + //{ + // return base.GetPageList(where, new SqlSugar.PageModel() { PageIndex = pageindex, PageSize = pagesize }); //使用自已的仓储方法 + //} + + //调用仓储扩展方法 + //public List GetOrderByJson(string Json) + //{ + // return base.CommQuery(Json); + //} + + /// + /// 按产品和批次 统计 合格率 + /// + /// + /// + /// + /// + /// + /// + public string GetReport_Qualified( string domain, string orderby,int pageNum, int pageSize, ref int totalCount) + { + var sql = base.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.ProductId == b.Id); + if (!string.IsNullOrWhiteSpace(domain)) + sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); + var sql2 = sql.GroupBy((a,b) => new { a.ProductId,b.Name,b.Code, a.BatchId }) + .Select((a,b) => new { a.ProductId,b.Name,b.Code, a.BatchId, Qualified = SqlFunc.AggregateSum(a.Qualified ? 1 : 0), Total = SqlFunc.AggregateSum(1) }); + + if (!string.IsNullOrWhiteSpace(orderby)) + sql2 = sql2.OrderBy(orderby); + + if (pageNum == 0 && pageSize == 0) + return sql2.ToJson(); + else + return sql2.ToJsonPage(pageNum, pageSize, ref totalCount); + } + /// + /// 按日期统计合格率(日期段<=30,因只显示天) + /// + /// + /// + /// + /// + /// + /// + public string GetReport_Qualified_Date(string domain, string orderby, int pageNum, int pageSize, ref int totalCount) + { + var sql = base.AsSugarClient().Queryable(); + if (!string.IsNullOrWhiteSpace(domain)) + sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); + var sql2 = sql.GroupBy((a) => new { CreateTime = a.CreateTime.Date }) //DATE_FORMAT(NOW(), '%Y-%m-%d') + .Select((a) => new { a.CreateTime.Date, Qualified = SqlFunc.AggregateSum(a.Qualified ? 1 : 0), Total = SqlFunc.AggregateSum(1) }); + + if (!string.IsNullOrWhiteSpace(orderby)) + sql2 = sql2.OrderBy(orderby); + + if (pageNum == 0 && pageSize == 0) + return sql2.ToJson(); + else + return sql2.ToJsonPage(pageNum, pageSize, ref totalCount); + } + /// + /// 合格率[0,100,50,50] + /// + /// + /// + public List> GetReport_Qualified_Total() + { + List> result =new List>(); + int liQualifiedCount, liTotal; + DateTime now = DateTime.Now.AddDays(-1); + //DateTime now = DateTime.Parse("2023-6-13"); + //当天 + var sql = base.AsSugarClient().Queryable();//只能执行一次,不能复用 + liQualifiedCount = liTotal = 0; + var list=sql.Where(m=>m.CreateTime>=now.Date && !SqlFunc.EqualsNull(m.Qualified,null)) + .GroupBy(m=>m.Qualified) + .Select((a) => new { a.Qualified, Count= SqlFunc.AggregateCount(a.Id) }) + .ToList(); + foreach(var item in list) + { + if (item.Qualified) + liQualifiedCount = item.Count; + liTotal += item.Count; + } + //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); + result.Add(new List{ liTotal, liQualifiedCount }); + //最近一月 + sql = base.AsSugarClient().Queryable(); + now = DateTime.Now.AddDays(-30); + liQualifiedCount = liTotal = 0; + list = sql.Where(m => m.CreateTime >= now.Date && !SqlFunc.EqualsNull(m.Qualified, null)) + .GroupBy(m => m.Qualified) + .Select((a) => new { a.Qualified, Count = SqlFunc.AggregateCount(a.Id) }) + .ToList(); + foreach (var item in list) + { + if (item.Qualified) + liQualifiedCount = item.Count; + liTotal += item.Count; + } + //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); + result.Add(new List { liTotal, liQualifiedCount }); + //最近一季 + sql = base.AsSugarClient().Queryable(); + now = DateTime.Now.AddDays(-90); + liQualifiedCount = liTotal = 0; + list = sql.Where(m => m.CreateTime >= now.Date && !SqlFunc.EqualsNull(m.Qualified, null)) + .GroupBy(m => m.Qualified) + .Select((a) => new { a.Qualified, Count = SqlFunc.AggregateCount(a.Id) }) + .ToList(); + foreach (var item in list) + { + if (item.Qualified) + liQualifiedCount = item.Count; + liTotal += item.Count; + } + //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); + result.Add(new List { liTotal, liQualifiedCount }); + //最近一年 + sql = base.AsSugarClient().Queryable(); + now = DateTime.Now.AddDays(-365); + liQualifiedCount = liTotal = 0; + list = sql.Where(m => m.CreateTime >= now.Date && !SqlFunc.EqualsNull(m.Qualified, null)) + .GroupBy(m => m.Qualified) + .Select((a) => new { a.Qualified, Count = SqlFunc.AggregateCount(a.Id) }) + .ToList(); + foreach (var item in list) + { + if (item.Qualified) + liQualifiedCount = item.Count; + liTotal += item.Count; + } + //result.Add(liTotal == 0 ? 0 : (liQualifiedCount * 100 / liTotal)); + result.Add(new List { liTotal, liQualifiedCount }); + + return result; + } + /// + /// 按日期统计各缺陷数 + /// + /// + /// + /// + /// + /// + /// + public string GetReport_Defects_Date(string domain, string orderby, int pageNum, int pageSize, ref int totalCount) + { + var sql = base.AsSugarClient().Queryable(); + if (!string.IsNullOrWhiteSpace(domain)) + sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); + var sql2 = sql.GroupBy((a) => new { CreateTime = a.CreateTime.Date }) + .Select((a) => new { a.CreateTime.Date, + Total = SqlFunc.AggregateSum(1), + 堵孔 = SqlFunc.AggregateSum(a.DKCount), + 脏污 = SqlFunc.AggregateSum(a.ZWCount), + 钢丝异常 = SqlFunc.AggregateSum(a.GSYCCount), + 纤维丝 = SqlFunc.AggregateSum(a.XWSCount), + 缺口 = SqlFunc.AggregateSum(a.QKCount), + 针孔 = SqlFunc.AggregateSum(a.ZKCount), + 泡泡 = SqlFunc.AggregateSum(a.PPCount), + 划伤 = SqlFunc.AggregateSum(a.HSCount), + 压线 = SqlFunc.AggregateSum(a.YXCount), + 斜边 = SqlFunc.AggregateSum(a.XBCount), + 栅线 = SqlFunc.AggregateSum(a.SXCount), + 钢丝断裂 = SqlFunc.AggregateSum(a.GSDLCount), + 残胶堵孔 = SqlFunc.AggregateSum(a.CJDKCount), + }); + + if (!string.IsNullOrWhiteSpace(orderby)) + sql2 = sql2.OrderBy(orderby); + + if (pageNum == 0 && pageSize == 0) + return sql2.ToJson(); + else + return sql2.ToJsonPage(pageNum, pageSize, ref totalCount); + } + /// + /// 缺陷总数 + /// + /// + /// + public string GetReport_Defects_Total(string domain) + { + var sql = base.AsSugarClient().Queryable(); + if (!string.IsNullOrWhiteSpace(domain)) + sql = sql.Where(base.Context.Utilities.JsonToConditionalModels(domain)); + return sql.Select((a) => new { + 堵孔 = SqlFunc.AggregateSum(a.DKCount), + 脏污 = SqlFunc.AggregateSum(a.ZWCount), + 钢丝异常 = SqlFunc.AggregateSum(a.GSYCCount), + 纤维丝 = SqlFunc.AggregateSum(a.XWSCount), + 缺口 = SqlFunc.AggregateSum(a.QKCount), + 针孔 = SqlFunc.AggregateSum(a.ZKCount), + 泡泡 = SqlFunc.AggregateSum(a.PPCount), + 划伤 = SqlFunc.AggregateSum(a.HSCount), + 压线 = SqlFunc.AggregateSum(a.YXCount), + 斜边 = SqlFunc.AggregateSum(a.XBCount), + 栅线 = SqlFunc.AggregateSum(a.SXCount), + 钢丝断裂 = SqlFunc.AggregateSum(a.GSDLCount), + 残胶堵孔 = SqlFunc.AggregateSum(a.CJDKCount), + }).ToJson(); + } + } +} diff --git a/更新日志.txt b/更新日志.txt index 48b458a2..d77837e3 100644 --- a/更新日志.txt +++ b/更新日志.txt @@ -69,3 +69,4 @@ V2.0.4: 6.加入可开启单边计算目数功能 V2.0.5: 1.测试项加入SP2—主栅宽度 + 2.缺陷项加入钢丝断裂,残胶堵孔