Exemplo n.º 1
0
        public ActionResult Save(LotDefectViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                DefectParameter p = new DefectParameter()
                {
                    Creator         = User.Identity.Name,
                    OperateComputer = Request.UserHostAddress,
                    Operator        = User.Identity.Name,
                    ReasonCodes     = new Dictionary <string, IList <DefectReasonCodeParameter> >(),
                    Remark          = model.Description,
                    LotNumbers      = new List <string>()
                };
                //获取批值。
                string lotNumber = model.LotNumber.ToUpper();
                result = GetLot(lotNumber);
                if (result.Code > 0)
                {
                    return(Json(result));
                }
                p.LotNumbers.Add(lotNumber);

                //组织不良原因代码
                if (!p.ReasonCodes.ContainsKey(lotNumber))
                {
                    p.ReasonCodes.Add(lotNumber, new List <DefectReasonCodeParameter>());
                }

                p.ReasonCodes[lotNumber].Add(new DefectReasonCodeParameter()
                {
                    Description            = model.ReasonDescription,
                    Quantity               = model.DefectQuantity,
                    ReasonCodeCategoryName = model.ReasonCodeCategoryName,
                    ReasonCodeName         = model.ReasonCodeName,
                    ResponsiblePerson      = model.ResponsiblePerson,
                    RouteOperationName     = model.RouteOperationName,
                });

                //批次不良操作。
                using (LotDefectServiceClient client = new LotDefectServiceClient())
                {
                    result = client.Defect(p);
                }
                if (result.Code == 0)
                {
                    result.Message = string.Format("批次 {0} 不良操作成功。", model.LotNumber);
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }
Exemplo n.º 2
0
        public List <string> GetLotDefect(string lotNumber)
        {
            string where = null;
            List <string> XY = new List <string>();

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                if (!string.IsNullOrEmpty(lotNumber))
                {
                    where = string.Format(@"  EXISTS( From LotTransaction as p 
                                                      WHERE p.Key=self.Key.TransactionKey 
                                                      AND p.LotNumber='{0}')"
                                          , lotNumber);
                }
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "EditTime",
                    Where   = where
                };
                MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);
                if (result.Code == 0)
                {
                    List <LotTransactionDefect> list = result.Data.ToList <LotTransactionDefect>();
                    foreach (var item in list)
                    {
                        StringBuilder lie = new  StringBuilder();
                        using (LotDefectServiceClient LotQueryServiceClient = new LotDefectServiceClient())
                        {
                            MethodReturnResult <DataSet> rt = LotQueryServiceClient.GetXY(item.Key.TransactionKey);
                            if (rt.Code == 0 && rt.Data.Tables[0] != null && rt.Data.Tables[0].Rows.Count > 0)
                            {
                                foreach (DataRow i in rt.Data.Tables[0].Rows)
                                {
                                    lie.Append("  " + i[0].ToString() + ";  ");
                                }
                            }
                            XY.Add(item.Key.ReasonCodeName + "   " + lie.ToString());
                            lie = null;
                        }
                    }
                }
            }
            return(XY);
        }
Exemplo n.º 3
0
        public ActionResult Save(LotDefectViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                DefectParameter p = new DefectParameter()
                {
                    Grade           = model.Grade,
                    Creator         = User.Identity.Name,
                    OperateComputer = Request.UserHostAddress,
                    Operator        = User.Identity.Name,
                    ReasonCodes     = new Dictionary <string, IList <DefectReasonCodeParameter> >(),
                    Remark          = model.Description,
                    LotNumbers      = new List <string>()
                };
                //获取批值。
                string lotNumber = model.LotNumber.ToUpper();
                result = GetLot(lotNumber);
                if (result.Code > 0)
                {
                    return(Json(result));
                }
                p.LotNumbers.Add(lotNumber);

                //组织不良原因代码
                if (!p.ReasonCodes.ContainsKey(lotNumber))
                {
                    p.ReasonCodes.Add(lotNumber, new List <DefectReasonCodeParameter>());
                }



                List <DefectPOSParameter> lstDefectPos = new List <DefectPOSParameter>();
                lstDefectPos.Clear();
                if (model.Position != null)
                {
                    for (int i = 0; i < model.Position.Count; i++)
                    {
                        DefectPOSParameter dPOS = new DefectPOSParameter();
                        dPOS.POS_X = model.Position[i].Split(':')[0];
                        dPOS.POS_Y = model.Position[i].Split(':')[1];
                        lstDefectPos.Add(dPOS);
                    }
                }


                DefectReasonCodeParameter defectCodeParam = new DefectReasonCodeParameter()
                {
                    Description            = model.ReasonDescription,
                    Quantity               = model.DefectQuantity,
                    ReasonCodeCategoryName = model.ReasonCodeCategoryName,
                    ReasonCodeName         = model.ReasonCodeName,
                    ResponsiblePerson      = model.ResponsiblePerson,
                    RouteOperationName     = model.RouteOperationName,
                    ListDefectPOSParameter = lstDefectPos
                };

                p.ReasonCodes[lotNumber].Add(defectCodeParam);

                //批次不良操作。
                using (LotDefectServiceClient client = new LotDefectServiceClient())
                {
                    result = client.Defect(p);
                }
                if (result.Code == 0)
                {
                    result.Message = string.Format("批次 {0} 不良操作成功。", model.LotNumber);
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }