//增加中表/底表数据 public QM_PROCESS_Util_Response addStrictMBDatas(QM_PROCESS_Util_Param param) { QM_PROCESS_Util_Response response = new QM_PROCESS_Util_Response(); //判断SN是否在抽检的箱子里面 CV_QM_HUT_SN queryParam = new CV_QM_HUT_SN() { PomOrderID = param.WorkOrderID, //工单 Sequence = param.Sequence, //加严单号 LotID = param.sn //扫描的序列号 }; IList <CV_QM_HUT_SN> hutSnList = cv_hut_snbo.GetEntities(queryParam); if (hutSnList == null || hutSnList.Count == 0) { response.message = param.sn + "不在抽检的箱子里面"; } else { //获得加严检的检验项目(取原单据的最后SN的检验项) string cmd_strictInspectSql = string.Format(CultureInfo.InvariantCulture, strictInspectSql, param.Attribute01);//关联的检验单号 log.Info("获得加严检的检验项目SQL:" + cmd_strictInspectSql); DataTable strictInsTable = bsc_bo.GetDataTableBySql(cmd_strictInspectSql); int i = 0, strictInsCnt = strictInsTable != null ? strictInsTable.Rows.Count : 0; using (TransactionScope ts = new TransactionScope()) { insertInspectionMiddle(param);//新增SN //获得中表主键 (主表KID,SN码) IList <QM_PROCESS_MIDDLE> middleQList = process_middlebo.GetByKIDSN(param.KID.Value, param.sn); //插入底表数据 for (i = 0; i < strictInsCnt; i++) { //填充子表数据 QM_PROCESS_BOTTOM bottom = new QM_PROCESS_BOTTOM() { KLID = middleQList[0].KLID,//中表主键 Sequence = param.Sequence, SN = param.sn, MaterielID = param.MaterielID, ItemIndex = strictInsTable.Rows[i]["ItemIndex"].ToString(), Item = strictInsTable.Rows[i]["Item"].ToString(), ItemProperty = strictInsTable.Rows[i]["ItemProperty"].ToString(), ItemStatus = "待检", }; log.Info("上限--->" + strictInsTable.Rows[i]["UpperBound"]); if (!String.IsNullOrEmpty(strictInsTable.Rows[i]["UpperBound"].ToString())) { bottom.Target = Convert.ToInt32(strictInsTable.Rows[i]["Target"].ToString()); bottom.UpperBound = Convert.ToInt32(strictInsTable.Rows[i]["UpperBound"].ToString()); bottom.LowerBound = Convert.ToInt32(strictInsTable.Rows[i]["LowerBound"].ToString()); } process_bottombo.Insert(bottom); } //重新获得中表的数据 response.middleList = process_middlebo.GetByKid(param.KID.Value); ts.Complete(); } } return(response); }
//增加中表/底表数据 public QM_PROCESS_Util_Response addInspectionMBDatas(QM_PROCESS_Util_Param param) { QM_PROCESS_Util_Response response = new QM_PROCESS_Util_Response(); CV_QM_FIRSTCHECK_SN_QueryParam sn_param = new CV_QM_FIRSTCHECK_SN_QueryParam() { CurrentOrderID = param.WorkOrderID, IsNamePlate = param.IsNamePlate, LotID = param.sn, CurrentStep = param.Step //当前Step }; FirstCheckSnOrder snOrderInfo = api_QM_BO.getInspectionOrderStep(sn_param); if (string.IsNullOrEmpty(snOrderInfo.message)) { CV_QM_FIRSTCHECK_SN info = snOrderInfo.snOrder; info.Step = param.inspectSource == "4" ? null : info.Step;//成品抽检只是在包装工段 IList <CV_QM_PROCESSITEM> processItemList = cv_qm_processitem.GetEntitiesByOrderID(info.OrderID, param.inspectSource, info.Step); if (processItemList.Count() == 0) { response.message = "NG,无检验项信息"; } else { using (TransactionScope ts = new TransactionScope()) { if (param.isFirst) { log.Info("第一个SN,需要更新主表的MES工单和SAP订单"); //操作主表,更新MES工单和SAP订单,物料,产线 QM_PROCESS_TOP topUpdate = new QM_PROCESS_TOP() { KID = param.KID, //主键 WorkOrderID = info.OrderID, //MES工单 SapOrderID = info.SalesOrderID, //SAP订单 MaterielID = info.DefID, //物料 MaterielVer = info.DefVer, //物料版本 MaterielDescript = info.DefDescript, //物料描述 Step = info.Step, PlantID = info.PlanPlant, //工厂ID Plant = info.PlantName, //工厂 Workshop = info.DepartID, //车间 LineID = info.LineID, //产线ID ProdLine = info.LineName //产线 }; process_topbo.UpdateSome(topUpdate); //查询当前主表 response.top = process_topbo.GetEntity(param.KID.Value); } insertInspectionMiddle(param);//新增SN //获得中表主键 (主表KID,SN码) IList <QM_PROCESS_MIDDLE> middleQList = process_middlebo.GetByKIDSN(param.KID.Value, param.sn); //插入底表数据 foreach (CV_QM_PROCESSITEM cv_temp_inspection in processItemList) { //填充子表数据 QM_PROCESS_BOTTOM bottom = new QM_PROCESS_BOTTOM() { KLID = middleQList[0].KLID,//中表主键 Sequence = param.Sequence, SN = param.sn, MaterielID = param.isFirst ? info.DefID : param.MaterielID, ItemIndex = cv_temp_inspection.InforDetailID, Item = cv_temp_inspection.InspectItemDes, ItemStatus = "待检" }; if (!String.IsNullOrEmpty(cv_temp_inspection.InspectItemProperty) && cv_temp_inspection.InspectItemProperty == "1") { bottom.ItemProperty = "定性"; } else { bottom.ItemProperty = "定量"; } if (!String.IsNullOrEmpty(cv_temp_inspection.UpperLimit)) { bottom.Target = Convert.ToInt32(cv_temp_inspection.TargetValue); bottom.UpperBound = Convert.ToInt32(cv_temp_inspection.UpperLimit); bottom.LowerBound = Convert.ToInt32(cv_temp_inspection.LowerLimit); } process_bottombo.Insert(bottom); } //重新获得中表的数据 response.middleList = process_middlebo.GetByKid(param.KID.Value); ts.Complete(); } } } else { response.message = snOrderInfo.message; } return(response); }
//增加中表/底表数据 public QM_PROCESS_Util_Response addFQCInspectionMBDatas(QM_PROCESS_Util_Param param) { QM_PROCESS_Util_Response response = new QM_PROCESS_Util_Response(); //判断SN对应的工单是否为同一个 //查询sn对应的工单 MM_LOTS_EXT pOM_SN_GENERATION = new MM_LOTS_EXT() { LotID = param.sn, }; IList <MM_LOTS_EXT> mm_lot_exts = lot_extbo.GetByQueryParam(pOM_SN_GENERATION); log.Info("addFQCInspectionMBDatas--->" + mm_lot_exts.Count); if (mm_lot_exts.Count == 0) { response.message = param.sn + "不存在对应的MES工单"; } else if (mm_lot_exts.Count > 1) { response.message = param.sn + "对应多个MES工单"; } else { string mesOrderID = mm_lot_exts[0].OrderID; log.Info("param.mesOrderID-->" + param.WorkOrderID); log.Info("mesOrderID-->" + mesOrderID); if (!String.IsNullOrEmpty(mesOrderID) && !String.IsNullOrEmpty(param.WorkOrderID) && !mesOrderID.Equals(param.WorkOrderID)) { response.message = param.sn + "对应的MES工单不一致"; } else { log.Info("sapOrderID-->" + param.SapOrderID); //根据MES工单和SAP订单去获得物料信息,工厂产线信息 CV_POM_ORDER_EXT_QueryParam ext_param = new CV_POM_ORDER_EXT_QueryParam() { PomOrderID = mesOrderID }; IList <CV_POM_ORDER_EXT> cv_order_exts = cv_pom_order_extbo.GetEntities(ext_param); log.Info("cv_order_ext.Count-->" + cv_order_exts.Count); if (cv_order_exts.Count == 0) { response.message = "MES工单'" + mesOrderID + "'不存在对应的数据(物料信息/产线信息)"; } else { //从中间表取数据 CV_PLM_BOP_INSPECTION_DETAIL cv_temp_inspection_param = new CV_PLM_BOP_INSPECTION_DETAIL() { SalesOrderID = cv_order_exts[0].SalesOrderID, SalesOrderSequence = cv_order_exts[0].SalesOrderSeq }; IList <CV_PLM_BOP_INSPECTION_DETAIL> cv_temp_inspections = cv_temp_inspectionbo.getEntities(cv_temp_inspection_param); log.Info("SN对应的检验项数据数为-->" + cv_temp_inspections.Count); if (cv_temp_inspections.Count == 0) { response.message = "该SN号没有FQC检验项数据"; } else { //获得 using (TransactionScope ts = new TransactionScope()) { if (param.isFirst) { log.Info("第一个SN,需要更新主表的MES工单和SAP订单"); //需要更新主表的MES工单和SAP订单 log.Info("sapOrderID-->" + cv_order_exts[0].SapOrderID); //操作主表,更新MES工单和SAP订单,物料,产线 QM_PROCESS_TOP topUpdate = new QM_PROCESS_TOP() { KID = param.KID, //主键 WorkOrderID = mesOrderID, //MES工单 SapOrderID = cv_order_exts[0].SapOrderID, //SAP订单 MaterielID = cv_order_exts[0].DefID, //物料 MaterielVer = cv_order_exts[0].DefVer, //物料版本 MaterielDescript = cv_order_exts[0].DefDescript, //物料描述 Plant = cv_order_exts[0].PlanPlant, //工厂 Workshop = cv_order_exts[0].WorkshopName, //车间 ProdLine = cv_order_exts[0].LineName //产线 }; process_topbo.UpdateSome(topUpdate); //查询当前主表 response.top = process_topbo.GetEntity(param.KID.Value); //string topSql = "update " + QM_PROCESS_TOP_DB + " set WorkOrderID = '" + mesOrderID + "' ,SapOrderID = '" + response.sapOrderID + // "' ,MaterielID = '" + cv_order_ext[0].DefID + "' ,MaterielVer = '" + cv_order_ext[0].DefVer + "' ,MaterielDescript = '" + cv_order_ext[0].DefDescript + // "' ,Plant = '" + cv_order_ext[0].PlanPlant + "' ,Workshop = '" + cv_order_ext[0].WorkshopName + "' ,ProdLine = '" + cv_order_ext[0].LineName + // "' where sequence = '" + param.Sequence + "'"; //操作中表 //string middleSql = "insert into " + QM_PROCESS_MIDDLE_DB + " (KID,Sequence,SN,SNStatus) values( " + param.KID // + ", '" + param.Sequence + " ', '" + param.sn + "','待检')"; } insertFQCInspectionMiddle(param);//新增SN //插入底表数据 foreach (CV_PLM_BOP_INSPECTION_DETAIL cv_temp_inspection in cv_temp_inspections) { //填充子表数据 QM_PROCESS_BOTTOM bottom = new QM_PROCESS_BOTTOM() { KLID = 11,//中表主键 Sequence = param.Sequence, SN = param.sn, MaterielID = param.isFirst ? cv_order_exts[0].DefID : param.WorkOrderID, ItemIndex = cv_temp_inspection.InforDetailID, Item = cv_temp_inspection.InspectItemDes, ItemProperty = cv_temp_inspection.InspectItemProperty, ItemStatus = "待检", }; if (!String.IsNullOrEmpty(cv_temp_inspection.UpperLimit)) { bottom.Target = Convert.ToInt32(cv_temp_inspection.TargetValue); bottom.UpperBound = Convert.ToInt32(cv_temp_inspection.UpperLimit); bottom.LowerBound = Convert.ToInt32(cv_temp_inspection.LowerLimit); } process_bottombo.Insert(bottom); } //重新获得中表的数据 response.middleList = process_middlebo.GetByKid(param.KID.Value); ts.Complete(); } } } } } return(response); }