public QM_PROCESS_TOP middleSubmit(IList <QM_PROCESS_MIDDLE> list)
        {
            QM_PROCESS_TOP top  = null;
            string         user = list[0].Attribute10;
            Boolean        flag = true;

            list[0].Attribute10 = null;
            DateTime now = SSGlobalConfig.Now;

            using (TransactionScope ts = new TransactionScope())
            {
                foreach (QM_PROCESS_MIDDLE middle in list)
                {
                    if (middle.SNResult == "NG")
                    {
                        flag = false;
                    }
                    middle.SNStatus = "已检";
                    _IQM_PROCESS_MIDDLEBO.UpdateSome(middle);
                }
                QM_PROCESS_TOP topEntity = new QM_PROCESS_TOP()
                {
                    KID            = list.First().KID,
                    SequenceStatus = "已检",
                    SequenceResult = flag ? "OK" : "NG",
                    InspectTime    = now,
                    InspectUser    = user
                };
                _IQM_PROCESS_TOPBO.UpdateSome(topEntity);
                top = _IQM_PROCESS_TOPBO.GetEntity(topEntity.KID.Value);
                ts.Complete();
            }
            return(top);
        }
        public void addInspection(int source)
        {
            //获得检验单流水号,通过调用查询获得
            string sequence = "";

            if (source == 3)
            {
                //半成品
                dict.Clear();
                dict.Add("PN", "FQC");
                dict.Add("Y", SSGlobalConfig.Now.ToString("yyyyMMdd"));
                sequence = createCode("FQCRule", dict);
            }
            else if (source == 4)
            {
                //成品抽检
                dict.Clear();
                dict.Add("PN", "OQC");
                dict.Add("Y", SSGlobalConfig.Now.ToString("yyyyMMdd"));
                sequence = createCode("OQCRule", dict);
            }
            QM_PROCESS_TOP top = new QM_PROCESS_TOP()
            {
                Source         = source,//指明是FQC
                Sequence       = sequence,
                CreateTime     = DateTime.Now,
                SequenceStatus = "待检"
            };

            //插入数据
            process_topbo.Insert(top);
        }
        //底表数据提交
        public string createStrictInspection(QM_PROCESS_TOP_HUT_Param param)
        {
            QM_PROCESS_TOP         topData = param.top;
            IList <QM_PROCESS_HUT> hutList = param.hutList;

            //获得加严检验单号
            dict.Clear();
            dict.Add("PN", topData.Sequence);
            string newSequence = createCode("SrictInspectionRule", dict);

            if (!string.IsNullOrEmpty(newSequence))
            {
                //清空
                topData.KID            = null;
                topData.SequenceResult = null;
                topData.InspectTime    = null;
                topData.InspectUser    = null;
                topData.remark         = null;
                //
                topData.SequenceStatus = "新建";
                topData.Source         = 5;
                topData.StrictType     = topData.Source == 3 ? 1 : 2;//加严单类型
                //关联检验单号
                topData.Attribute01 = topData.Sequence;
                //加严检验单号
                topData.Sequence = newSequence;
                using (TransactionScope ts = new TransactionScope())
                {
                    process_topbo.Insert(topData);

                    //关联箱号
                    if (hutList != null)
                    {
                        for (int i = 0; i < hutList.Count; i++)
                        {
                            QM_PROCESS_HUT hut = hutList[i];
                            hut.Sequence = newSequence;
                            if (hut.Attribute05.Equals("insert"))
                            {
                                hut.Attribute05 = null;
                                process_hutbo.Insert(hutList[i]);
                            }
                            else if (hutList[i].Attribute05.Equals("delete"))
                            {
                                hut.Attribute05 = null;
                                process_hutbo.Delete(hutList[i]);
                            }
                        }
                    }
                    ts.Complete();
                }
            }
            return(newSequence);
        }
        public IList <QM_PROCESS_MIDDLE> getMiddleDatas(String kid)
        {
            QM_PROCESS_TOP entity = _IQM_PROCESS_TOPBO.GetEntity(int.Parse(kid));

            if (entity.SequenceStatus == "待检")
            {
                entity.SequenceStatus = "检验中";
            }
            _IQM_PROCESS_TOPBO.UpdateSome(entity);
            return(_IQM_PROCESS_MIDDLEBO.GetByKid(int.Parse(kid)));
        }
 public HttpResponseMessage saveNote(QM_PROCESS_TOP_QueryParam param)
 {
     try
     {
         QM_PROCESS_TOP entity = _IQM_PROCESS_TOPBO.GetEntity((int)param.KID);
         entity.remark = param.remark;
         _IQM_PROCESS_TOPBO.UpdateSome(entity);
         return(Request.CreateResponse(HttpStatusCode.OK, "备注提交成功!"));
     }
     catch
     {
         return(Request.CreateResponse(HttpStatusCode.OK, "备注提交失败!"));
     }
 }
Exemple #6
0
        public QM_PROCESS_TOP addFQCInspection()
        {
            //获得检验单流水号,通过调用查询获得
            string         sequence = "FQC" + DateTime.Now.ToString("yyyyMMddHHmmss");
            QM_PROCESS_TOP top      = new QM_PROCESS_TOP()
            {
                Source         = 3,//指明是FQC
                Sequence       = sequence,
                SequenceStatus = "待检"
            };
            //插入数据
            string sql = "insert into " + QM_PROCESS_TOP_DB + " (Source,Sequence,SequenceStatus) values( " + top.Source
                         + ", '" + top.Sequence + "', '" + top.SequenceStatus + "')";

            log.Info(sql);
            if (bsc_bo.ExecuteNonQueryBySql(sql) != 0)
            {
                return(top);
            }
            return(null);
        }
        public string strictWMSHut(QM_PROCESS_TOP param)
        {
            //获得该加严单已选的入库箱号
            IList <QM_PROCESS_HUT> processHutList = getSequenceHut(param.Sequence);

            if (processHutList == null || processHutList.Count == 0)
            {
                return("尚未选择箱号");
            }
            else
            {
                Inspection insInfo = new Inspection()
                {
                    SESSIONID   = SafeConvert.ToString(Guid.NewGuid()),
                    QAORDERTYPE = param.Source == 5 ? "2" : "3", //质检来源
                    PRUEFLOS    = param.Sequence,                //检验批号
                    //MATNR 物料编码,MBLNR 物料凭证号,MJAHR 物料凭证年份
                    MATNR    = param.MaterielID,
                    MBLNR    = "",
                    MJAHR    = "",
                    LOSMENGE = param.SampleQua.Value,     //抽样数量
                    WERKS    = param.PlantID,             //工厂编码
                    HutID    = new List <InspectionHut>() //箱号
                };
                int i = 0, cnt = processHutList.Count;
                for (i = 0; i < cnt; i++)
                {
                    insInfo.HutID.Add(new InspectionHut()
                    {
                        HutID = processHutList[i].HutID
                    });                                                                        //箱号
                }
                RetuenInspection rt = null;
                try
                {
                    rt = api_wmsbo.strictWMSHut(insInfo);
                }
                catch (Exception ex)
                {
                    return("调用WMS接口失败:" + ex.Message);
                }

                //rt = JsonConvert.DeserializeObject<RetuenInspection>("{\"Success\":true,\"Message\":\"成功\",\"PRUEFLOS\":\"FQC20180530006-01\",\"HutID\":[{\"HutID\":\"12000022\"},{\"HutID\":\"12000035\"}]}");

                if (!rt.Success)
                {
                    return("WMS回传信息:" + rt.Message);
                }
                else
                {
                    for (i = 0; i < rt.HutID.Count; i++)
                    {
                        string cmd_updateHutSql = string.Format(CultureInfo.InvariantCulture, updateHutSql, rt.PRUEFLOS, rt.HutID[i].HutID);
                        bsc_bo.ExecuteNonQueryBySql(cmd_updateHutSql);
                    }
                    //更新状态
                    param.SequenceStatus = "待检";
                    process_topbo.UpdateSome(param);
                    return("");
                }
            }
        }
        //增加中表/底表数据
        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 DateTime middleSubmitData(QM_PROCESS_TOP param)
 {
     param.InspectTime = SSGlobalConfig.Now;
     process_topbo.UpdateSome(param);
     return(param.InspectTime.Value);
 }
 //更改某检验单
 public void updateInspectionTop(QM_PROCESS_TOP param)
 {
     process_topbo.UpdateSome(param);
 }
Exemple #11
0
        //增加中表/底表数据
        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);
        }
 //分页获得FQC检验
 public ReturnValue abnormalToOA(QM_PROCESS_TOP param)
 {
     return(CreateInstance().ProcessToOA(Convert.ToInt32(param.KID), param.user));
 }
        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);
        }