public List <String> getCheckStatus()
        {
            QM_PROCESS_TOP_QueryParam param = new QM_PROCESS_TOP_QueryParam()
            {
                Source = 1
            };
            IList <QM_PROCESS_TOP> QM_PROCESS_TOPs = _IQM_PROCESS_TOPBO.GetEntitiesByQueryParam(param);;
            List <String>          sequenceStatus  = QM_PROCESS_TOPs.Select(a => a.SequenceStatus).Distinct().ToList <String>();

            return(sequenceStatus);
        }
 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, "备注提交失败!"));
     }
 }
 //分页获得FQC检验
 public QM_Page_Return filterInspectionPage(QM_PROCESS_TOP_QueryParam param)
 {
     return(process_topbo.filterFQCInspectionTop(param));
 }
 public QM_Page_Return filterFirstInspectionPage(QM_PROCESS_TOP_QueryParam param)
 {
     return(_ICV_QM_PROCESS_TOPBO.filterFQCInspectionTop(param));
 }
        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);
        }