diff --git a/取样并样程序/SubResult/.vs/SubResult/v17/.suo b/取样并样程序/SubResult/.vs/SubResult/v17/.suo index e8d7bab..9f593d0 100644 Binary files a/取样并样程序/SubResult/.vs/SubResult/v17/.suo and b/取样并样程序/SubResult/.vs/SubResult/v17/.suo differ diff --git a/取样并样程序/SubResult/SubResult/SubResult.csproj b/取样并样程序/SubResult/SubResult/SubResult.csproj index c048cd3..4d0c89a 100644 --- a/取样并样程序/SubResult/SubResult/SubResult.csproj +++ b/取样并样程序/SubResult/SubResult/SubResult.csproj @@ -145,6 +145,7 @@ + diff --git a/取样并样程序/SubResult/SubResult/SurMatSubController.cs b/取样并样程序/SubResult/SubResult/SurMatSubController.cs index 08be5bf..77f6975 100644 --- a/取样并样程序/SubResult/SubResult/SurMatSubController.cs +++ b/取样并样程序/SubResult/SubResult/SurMatSubController.cs @@ -1054,7 +1054,7 @@ namespace ibk.IPD //保存结果数据 SurMatSubService surMatSubService = new SurMatSubService(); - //surMatSubService.SaveQABSMP(ipdi);//自动确认,存储PDO发给MES + surMatSubService.SaveQABSMP(ipdi);//自动确认,存储PDO发给MES //测试test //surMatSubService.SavePlateSmpno(ipdi); //手动确认 @@ -1070,7 +1070,7 @@ namespace ibk.IPD try { //并样存在不做并号 - if (ipdi.Where(p=>p.PLATE_NO==plate.PLATE_NO).Count()>0) + if (ipdi.Where(p => p.PLATE_NO == plate.PLATE_NO).Count() > 0) { continue; } @@ -1098,7 +1098,7 @@ namespace ibk.IPD } //式样号被复用不能再使用 - if (gQP_SMP_SEND_PWHT.Where(p => p.SMP_NO == plate.SMP_NO && ( ConverDataToString( p.TEXT).Contains("并号") || ConverDataToString(p.TEXT).Contains("合并不取样"))).Count() > 0) + if (gQP_SMP_SEND_PWHT.Where(p => p.SMP_NO == plate.SMP_NO && (ConverDataToString(p.TEXT).Contains("并号") || ConverDataToString(p.TEXT).Contains("合并不取样"))).Count() > 0) { logger.InfoFormat("**{0}** 并号或者合并不取样,不能复用。", plate.SMP_NO); continue; @@ -1168,7 +1168,7 @@ namespace ibk.IPD } plate.SMP_NO = smpno.SMP_NO; - + List plateList = gQP_TEST_PLATE.Where(p => p.SMP_NO == smpno.SMP_NO).ToList(); plateList.Add(new QP_TEST_PLATE { @@ -1515,12 +1515,10 @@ namespace ibk.IPD continue; } - - //判断是否是并号过的式样号 gChkQP_SMP_SEND_PWHT = surMatSubService.GetChkQP_SMP_SEND_PWHT(smpno.SMP_NO); - if (gChkQP_SMP_SEND_PWHT.Count()>0) + if (gChkQP_SMP_SEND_PWHT.Count() > 0) { logger.InfoFormat("**{0}--{1}** 并号或者合并不取样,不能复用。", plate.SMP_NO, gChkQP_SMP_SEND_PWHT.FirstOrDefault().TEXT); continue; diff --git a/取样并样程序/SubResult/SubResult/SurMatSubService.cs b/取样并样程序/SubResult/SubResult/SurMatSubService.cs index 0c15e82..05b553b 100644 --- a/取样并样程序/SubResult/SubResult/SurMatSubService.cs +++ b/取样并样程序/SubResult/SubResult/SurMatSubService.cs @@ -11,7 +11,7 @@ using System.Data; using System.Linq; using System.Reflection; using System.Text; - +using System.Threading; namespace ibk.IPD { @@ -2537,6 +2537,13 @@ namespace ibk.IPD //logger.InfoFormat("试样号:{0},钢板号:{1},取样后重量为:{2}+{3},不满足取样重量基准:{4}", smpNoDict, delAddModel.PLATE_NO, smpnoWgtDict[smpNoDict], ConverDataToDecimal(delAddModel.WGT), delAddModel.SMP_STD_WGT); continue; } + + if (smpnoWgtDict[smpNoDict] + ConverDataToDecimal(delAddModel.WGT) > 50) + { + //logger.InfoFormat("试样号:{0},钢板号:{1},取样后重量为:{2}+{3},不满足取样重量基准:{4}", smpNoDict, delAddModel.PLATE_NO, smpnoWgtDict[smpNoDict], ConverDataToDecimal(delAddModel.WGT), delAddModel.SMP_STD_WGT); + continue; + } + } else { @@ -2545,6 +2552,11 @@ namespace ibk.IPD //logger.InfoFormat("试样号:{0},钢板号:{1},取样后重量为:{2},不满足取样重量基准:{3}", smpNoDict, delAddModel.PLATE_NO, smpnoWgtDict[smpNoDict], delAddModel.SMP_STD_WGT); continue; } + if (smpnoWgtDict[smpNoDict] > 50) + { + //logger.InfoFormat("试样号:{0},钢板号:{1},取样后重量为:{2},不满足取样重量基准:{3}", smpNoDict, delAddModel.PLATE_NO, smpnoWgtDict[smpNoDict], delAddModel.SMP_STD_WGT); + continue; + } } #endregion 并样吨位管控 @@ -2621,24 +2633,106 @@ namespace ibk.IPD } } - public void SaveQABSMP_M(IList pdi) { using (IDbContext db = ObjectContainer.GetObject("db")) { try { + logger.InfoFormat("*******钢板去重前,共:{0}条*******", pdi.Count); + + IList distinctList = pdi.GroupBy(p => p.SMP_NO_M) + .Select(g => g.Key) + .Distinct() + .ToList(); + + IList pdiDis = new List(); + + foreach (string strSmpNoM in distinctList) + { + bool blFirst = true; + if (pdi.Where(p => p.SMP_NO_M == strSmpNoM).Count() > 0) + { + //同一板坯号优先 + if (pdi.Where(p => p.SMP_NO_M == strSmpNoM && p.PLATE_NO.Substring(0,10)== strSmpNoM.Substring(0,10)).Count()>0) + { + foreach (var PSNM in pdi.Where(p => p.SMP_NO_M == strSmpNoM && p.PLATE_NO.Substring(0, 10) == strSmpNoM.Substring(0, 10)).ToList()) + { + //钢板号已存在并号集合中不再并号 + if (pdiDis.Where(p => p.PLATE_NO == PSNM.PLATE_NO).Count() > 0) + { + continue; + } + + //第一次赋值P,之后赋值N + if (blFirst) + { + PSNM.SMP_FLG = "P"; + blFirst = false; + } + else + { + PSNM.SMP_FLG = "N"; + } + logger.InfoFormat("同一板坯号优先:{0} 式样号{1}",PSNM.PLATE_NO,strSmpNoM); + pdiDis.Add(PSNM); + } + + } + //其他板坯 + foreach (var PSNM in pdi.Where(p => p.SMP_NO_M == strSmpNoM).ToList()) + { + //钢板号已存在并号集合中不再并号 + if (pdiDis.Where(p=>p.PLATE_NO== PSNM.PLATE_NO).Count()>0) + { + continue; + } + //第一次赋值P,之后赋值N + if (blFirst) + { + PSNM.SMP_FLG = "P"; + blFirst=false; + } + else + { + PSNM.SMP_FLG = "N"; + } + logger.InfoFormat("不同板坯号优先:{0} 式样号{1}", PSNM.PLATE_NO, strSmpNoM); + pdiDis.Add(PSNM); + } + } + } + + logger.InfoFormat("*******钢板去重后,共:{0}条*******", pdiDis.Count); + + //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); db.Execute(" DELETE FROM PDI_SMP_NO_M ");//删除获取最新数据 + db.Execute(" DELETE FROM CONFIRMSMPNO_M ");//删除获取最新数据 + //存储并样去重后信息 - foreach (PDI_SMP_NO_M delAddModel in pdi) - { - //存储动态挂试样号履历 - db.Insert(delAddModel); - logger.InfoFormat("钢板:{0},订单:{1}-{2},试样号:{3}存储成功", delAddModel.PLATE_NO, delAddModel.ORD_NO, delAddModel.ORD_ITEM, delAddModel.SMP_NO); + foreach (PDI_SMP_NO_M delAddModel in pdiDis) + { + //存储手动并样匹配 + CONFIRMSMPNO_M InsertSmpno = GetSmpnoM(delAddModel);//并样去重后信息 + if (InsertSmpno != null && InsertSmpno.SMP_NO != null) + { + db.Insert(InsertSmpno); + //logger.InfoFormat("钢板:{0},订单:{1}-{2},试样号:{3}存储成功", delAddModel.PLATE_NO, delAddModel.ORD_NO, delAddModel.ORD_ITEM, delAddModel.SMP_NO); + } + + //delAddModel.IS_STATE = "1";//下发过存1,没下发默认是0 + + ////存储PDO发送MES + //TBDIPDO InsertPDO = GetPDO(delAddModel); + //db.Insert(InsertPDO); + + //存储动态挂试样号履历 + db.Insert(delAddModel); + logger.InfoFormat("钢板:{0},订单:{1}-{2},试样号:{3}存储成功", delAddModel.PLATE_NO, delAddModel.ORD_NO, delAddModel.ORD_ITEM, delAddModel.SMP_NO); } db.Commit(); @@ -2871,6 +2965,112 @@ namespace ibk.IPD //} return Result; } + + /// + /// Null转换string + /// + /// 参数 + /// + public static string ConverDataToString(string obj) + { + if (obj == null) + { + return string.Empty; + } + else + { + return obj; + } + } + public CONFIRMSMPNO_M GetSmpnoM(PDI_SMP_NO_M pdi) + { + + CONFIRMSMPNO_M Result = new CONFIRMSMPNO_M(); + + //添加之前执行删除操作,目前不需要判断 + //if (SurMatSubController.gCONFIRMSMPNO.Where(p => p.PLATE_NO == pdi.PLATE_NO && p.SMP_NO == pdi.SMP_NO).ToList().Count == 0) + //{ + Result.SMP_NO = pdi.SMP_NO; + //获取原试样标准 + Result.SMP_STDSPEC = pdi.SMP_STDSPEC; + Result.PLATE_NO = pdi.PLATE_NO; + Result.PLATE_STDSPEC = pdi.APLY_STDSPEC; + Result.ORD_NO = pdi.ORD_NO; + Result.ORD_ITEM = pdi.ORD_ITEM; + Result.ORD_STDSPEC = pdi.ORD_STDSPEC; + //Result.INS_DATE = DateTime.Now.ToString("yyyyMMdd"); + Result.INS_DATE = pdi.INS_DATE; + Result.PROC_CD = pdi.PROC_CD; + Result.PLT = pdi.PLT; + Result.ORD_THK = pdi.ORD_THK; + Result.TIMESTAMP = GetTimeStamp(); //TIMESTAMP: 1970.1.1 8:00:00 至当前时间的毫秒数 + Result.CERT_TYPE = pdi.CERT_TYPE; + StringBuilder strData = new StringBuilder(); + strData.Append(("BKDMESMP").PadRight(10));//FORMID:10位 ,BKDERP001 固定 + strData.Append(("").PadRight(12)); // 业务ID号 NUMBER(12) 流水号,需要再应答中带回 + strData.Append((pdi.PLATE_NO).PadRight(14));// 钢板号: VARCHAR2(14) + strData.Append((pdi.SMP_NO).PadRight(14));// 试样号: VARCHAR2(14) + strData.Append((pdi.SYNOPSIS.ToString()).PadRight(1));// 标记: VARCHAR2(14) + Result.DATA = strData.ToString(); + Result.IS_BING = "0"; + + Result.SMP_FLG = pdi.SMP_FLG; + + Result.SMP_NO_M = pdi.SMP_NO_M; + + Thread.Sleep(150); //避免时间戳重复 + //D 状态开头的 船板 不并样 + //if (pdi.CERT_TYPE == "S" && pdi.PROC_CD.StartsWith("D")) + //{ + if (pdi.SMP_NO_M != null ) + { + Result.IS_BING = "2"; + long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + Thread.Sleep(150); + long timestamp2 = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + string timestamp12 = timestamp.ToString().Substring(0, 12); + string timestamp122 = timestamp.ToString().Substring(0, 12); + StringBuilder strData2 = new StringBuilder(); + + // FORMID:10位 ,BKDMESMP01 固定 + // 业务ID号 NUMBER(12) 流水号,需要在应答中带回 + // 钢板号:VARCHAR2(14) + // 产品代码: VARCHAR2(2) + // 实际标记: VARCHAR2(1) + // 位置: VARCHAR2(1) + // 长度: VARCHAR2(10) + // 试样号: VARCHAR2(14) 注:倒数第二位(13位)是9 + + strData2.Append(("BKDMESMP01").PadRight(10));//FORMID:10位 ,BKDERP001 固定 + strData2.Append((timestamp12).PadRight(12)); // 业务ID号 NUMBER(12) 流水号,需要再应答中带回 + strData2.Append(ConverDataToString(pdi.PLATE_NO).PadRight(14));// 钢板号: VARCHAR2(14) + + strData2.Append(ConverDataToString(pdi.PROD_CD).PadRight(2));// 产品代码: VARCHAR2(2) + strData2.Append(ConverDataToString(pdi.SMP_FLG).PadRight(1));// 实际标记: VARCHAR2(1) + strData2.Append(ConverDataToString(pdi.SMP_LOC).PadRight(1));// 位置: VARCHAR2(1) + strData2.Append(ConverDataToString(pdi.SMP_LEN).PadRight(10));// 长度: VARCHAR2(10) + strData2.Append(ConverDataToString(pdi.SMP_NO).PadRight(14));// 试样号: VARCHAR2(14) + //strData2.Append((pdi.SYNOPSIS.ToString()).PadRight(1));// 标记: VARCHAR2(14) + + // FORMID:10位 ,BKDMESMP01 固定 + // 业务ID号 NUMBER(12) 流水号,需要在应答中带回 + // 试样号: VARCHAR2(14) 注:倒数第二位(13位)是9 + // 原式样号:VARCHAR2(14) + + strData2.Append(("$").PadRight(1)); + + strData2.Append(("BKDMESMP02").PadRight(10));//FORMID:10位 ,BKDERP001 固定 + strData2.Append((timestamp122).PadRight(12)); // 业务ID号 NUMBER(12) 流水号,需要再应答中带回 + strData2.Append((pdi.SMP_NO).PadRight(14));// 试样号: VARCHAR2(14) + strData2.Append((pdi.SMP_NO_M).PadRight(14));// 试样号: VARCHAR2(14) + + Result.DATA = strData2.ToString(); + } + //} + + //} + return Result; + } public CONFIRMSMPNO_TEST GetSmpno_TEST(PDI_SMP_NO pdi) { diff --git a/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.exe b/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.exe index dc1c2df..7d0d43b 100644 Binary files a/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.exe and b/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.exe differ diff --git a/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.pdb b/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.pdb index 292f054..35b1d21 100644 Binary files a/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.pdb and b/取样并样程序/SubResult/SubResult/bin/Debug/SubResult.pdb differ diff --git a/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.csproj.CoreCompileInputs.cache b/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.csproj.CoreCompileInputs.cache index 7d47c0b..29be3c2 100644 --- a/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.csproj.CoreCompileInputs.cache +++ b/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -19e2dbee78ae1823a8c8d4c369a452713da1ec4f +467b8f19fc1b909d7f2d1fb20a6397c3bbc4771d diff --git a/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.exe b/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.exe index dc1c2df..7d0d43b 100644 Binary files a/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.exe and b/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.exe differ diff --git a/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.pdb b/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.pdb index 292f054..35b1d21 100644 Binary files a/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.pdb and b/取样并样程序/SubResult/SubResult/obj/Debug/SubResult.pdb differ