public string createIPQC(RepairOrderRequest param) { DateTime now = SSGlobalConfig.Now; IList <CV_QM_REPAIR_ORDER> orderList = param.orderList; Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("PN", "IPQC"); dict.Add("Y", now.ToString("yyyyMMdd")); string message = ""; //创建IPQC表单 using (TransactionScope ts = new TransactionScope()) { string ipqcSequence = createCode("IPQCRule", dict); QM_REPAIR_IPQC ipqc = new QM_REPAIR_IPQC() { TGuid = Guid.NewGuid(), Sequence = ipqcSequence, OrderID = orderList[0].OrderID, ReportLine = orderList[0].ReportLine, ReportWorkshop = orderList[0].ReportWorkshop, DefID = orderList[0].DefID, DefName = orderList[0].DefDescript, Status = "新建", CreatedBy = param.user, CreatedOn = now }; ipqcbo.Insert(ipqc); foreach (CV_QM_REPAIR_ORDER tmp in orderList) { QM_REPAIR_IPQC_DETAIL detail = new QM_REPAIR_IPQC_DETAIL() { TGuid = ipqc.TGuid, SN = tmp.AbnormalitySN, ReportID = tmp.ReportID, Result = tmp.Result, ReportTerminal = tmp.ReportTerminal, ProductDecision = tmp.ProductDecision, QualityDecision = tmp.QualityDecision }; ipqc_detailbo.Insert(detail); //修改SN状态为IPQC(7) string cmd_ipqcSql1 = string.Format(CultureInfo.InvariantCulture, ipqcSql1, 7, tmp.AbnormalitySN); alt_bscbo.ExecuteNonQueryBySql(cmd_ipqcSql1); } //创建预警信息 string cmd_altsql = string.Format(CultureInfo.InvariantCulture, ipqcAltSql, ipqc.DefID + ipqc.DefName, ipqc.OrderID, orderList[0].LineName, ipqcSequence); log.Info("createIPQC Sql : " + cmd_altsql); DataTable dt = alt_bscbo.GetDataTableBySql(cmd_altsql); if (dt.Rows.Count > 0) { //开始推送 PM_ALT_MESSAGE msg = alt_messagebo.GetEntity(SafeConvert.ToInt64(dt.Rows[0]["MsgPK"].ToString())); if (alt_bscbo.ExecuteNotify(msg)) { message = ipqcSequence; ts.Complete(); } else { message = "NG,推送失败,请重新提交.."; } } } return(message); }
public string addFirstCheck(AddFirstCheckRequest param) { string message = ""; Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("PN", "SJ" + param.snOrderList[0].OrderID); DateTime now = SSGlobalConfig.Now; CV_QM_FIRSTCHECK_SN snOrder = param.snOrderList[0]; //先获得首检检验项 string SubBopID = null; if (snOrder.Step == "装配" || snOrder.Step == "检定" || snOrder.Step == "包装") { //查询step是否为包装或者装配,若是,则查询需加上subbopid SubBopID = snOrder.Step; } IList <CV_QM_PROCESSITEM> processItemList = _ICV_QM_PROCESSITEMBO.GetEntitiesByOrderID(snOrder.OrderID, "1", SubBopID);//首检InspectSource = 1 if (processItemList.Count() == 0) { message = "NG,无首检检验项信息"; } else { QM_PROCESS_TOP top = new QM_PROCESS_TOP() { Source = 1, SequenceStatus = "待检", SapOrderID = snOrder.SalesOrderID, //SAP订单 WorkOrderID = snOrder.OrderID, //MES工单 MinSampleSize = param.minSampleSize, //最小抽样数量 SampleQua = param.snOrderList.Count, //抽样数量 MaterielID = snOrder.DefID, //物料编码 MaterielVer = snOrder.DefVer, //物料版本 MaterielDescript = snOrder.DefDescript, //物料描述 PlantID = snOrder.PlanPlant, //工厂ID Plant = snOrder.PlantName, //工厂名称 Step = snOrder.Step, //工序 Workshop = snOrder.DepartID, //车间 LineID = snOrder.LineID, //产线ID ProdLine = snOrder.LineName, //产线名称 CreateBy = param.user, //创建者 CreateTime = now //创建时间 }; using (TransactionScope ts = new TransactionScope()) { top.Sequence = createCode("FirstInspectRule", dict);//首检单号 //创建首检单 _IQM_PROCESS_TOPBO.Insert(top); //获得刚创建的首检单 QM_PROCESS_TOP_QueryParam topParam = new QM_PROCESS_TOP_QueryParam() { Source = 1, Sequence = top.Sequence }; //查询KID top = _IQM_PROCESS_TOPBO.GetEntitiesByQueryParam(topParam)[0]; foreach (CV_QM_FIRSTCHECK_SN tmp in param.snOrderList) { QM_PROCESS_MIDDLE middle = new QM_PROCESS_MIDDLE() { KID = top.KID, Sequence = top.Sequence, SN = tmp.LotID, SNStatus = "待检" }; _IQM_PROCESS_MIDDLEBO.Insert(middle); } //查询KLID IList <QM_PROCESS_MIDDLE> middleList = _IQM_PROCESS_MIDDLEBO.GetByKid(top.KID.Value); //操作底表 foreach (QM_PROCESS_MIDDLE middleTmp in middleList) { foreach (CV_QM_PROCESSITEM item in processItemList) { QM_PROCESS_BOTTOM bottom = new QM_PROCESS_BOTTOM() { KLID = middleTmp.KLID, Sequence = middleTmp.Sequence, SN = middleTmp.SN, MaterielID = top.MaterielID, ItemIndex = item.InforDetailID, Item = item.InspectItemDes, ItemStatus = "待检", ItemProperty = item.InspectItemProperty.Equals("2") ? "定量" : "定性", }; if (!string.IsNullOrEmpty(item.TargetValue)) { bottom.Target = SafeConvert.ToDouble(item.TargetValue); } if (!string.IsNullOrEmpty(item.UpperLimit)) { bottom.UpperBound = SafeConvert.ToDouble(item.UpperLimit); } if (!string.IsNullOrEmpty(item.LowerLimit)) { bottom.LowerBound = SafeConvert.ToDouble(item.LowerLimit); } _IQM_PROCESS_BOTTOMBO.Insert(bottom); } } //创建预警信息 string cmd_altsql = string.Format(CultureInfo.InvariantCulture, firstAltSql, top.ProdLine, top.WorkOrderID, top.Sequence); DataTable dt = bscbo.GetDataTableBySql(cmd_altsql); if (dt.Rows.Count > 0) { //开始推送 PM_ALT_MESSAGE msg = alt_messagebo.GetEntity(SafeConvert.ToInt64(dt.Rows[0]["MsgPK"].ToString())); if (alt_bscbo.ExecuteNotify(msg)) { message = top.Sequence; ts.Complete(); } else { message = "NG,推送失败,请重新提交.."; } } } } return(message); }