public Object Get(string OrderNo, string BatchNo, string WorkProcedure, string StartTime, string EndTime)
        {
            string strWhere = "";

            if (OrderNo == null)
            {
                OrderNo = "";
            }
            if (BatchNo == null)
            {
                BatchNo = "";
            }
            if (WorkProcedure == null)
            {
                WorkProcedure = "";
            }
            strWhere = " where OrderNo not in (select OrderNo  from ZL_FeedbackExHandle ) and OrderNo like '%" + OrderNo + "%' and BatchNo like '%" + BatchNo + "%'";
            if (WorkProcedure != "")
            {
                strWhere += " and WorkProcedure='" + WorkProcedure + "'";
            }
            if (StartTime != null && StartTime != "" && EndTime != null && EndTime != "")
            {
                strWhere += " and FeedbackTime between '" + StartTime + "' and '" + EndTime + " 23:59:59'";
            }
            strWhere += " order by FeedbackTime desc";
            using (SqlConnection sqlconnection = new SqlConnection(_connectionString))
            {
                FeedbackBaseService      bllBase   = new FeedbackBaseService(sqlconnection);
                FeedbackExReasonService  bllReason = new FeedbackExReasonService(sqlconnection);
                FeedbackExProblemService bllPro    = new FeedbackExProblemService(sqlconnection);
                CodeService bllCode = new CodeService(sqlconnection);

                List <FeedbackBase> baseList = bllBase.GetOrderInfoByWhere(strWhere);
                List <FeedInfo>     InfoList = new List <FeedInfo>();
                if (baseList != null && baseList.Count > 0)
                {
                    for (int i = 0; i < baseList.Count; i++)
                    {
                        FeedInfo info = new FeedInfo();
                        info.OrderNo       = baseList[i].OrderNo;
                        info.WorkProcedure = baseList[i].WorkProcedure;
                        info.Model         = baseList[i].Model;
                        info.BatchNo       = baseList[i].BatchNo;
                        info.Qty           = baseList[i].Qty;
                        info.EquipmentName = baseList[i].EquipmentName;
                        info.EquipmentNo   = baseList[i].EquipmentNo;
                        info.FeedbackMan   = baseList[i].FeedbackMan;
                        info.FeedbackTime  = baseList[i].FeedbackTime.ToString("yyyy-MM-dd HH:mm");
                        List <FeedbackExReason> reason = bllReason.GetReasonByWhere(" where OrderNo='" + baseList[i].OrderNo + "'");
                        info.ReasonList = reason;
                        List <FeedbackExProblem> problem     = bllPro.GetProblemByWhere(" where OrderNo='" + baseList[i].OrderNo + "'");
                        List <Problem>           problemList = new List <Problem>();
                        if (problem != null && problem.Count > 0)
                        {
                            for (int j = 0; j < problem.Count; j++)
                            {
                                Problem newProblem   = new Problem();
                                string  QualityClass = "";
                                string  Suggestion   = "";
                                string  CodeString   = problem[j].CodeString;
                                Code    code         = bllCode.GetCodeByWhere(" where CodeString='" + CodeString + "'").FirstOrDefault();
                                newProblem.code = code;
                                if (code != null)
                                {
                                    QualityClass = code.QualityClass;
                                    Suggestion   = code.Suggestion;
                                }
                                newProblem.QualityClass   = QualityClass;
                                newProblem.Suggestion     = Suggestion;
                                newProblem.CodeString     = CodeString;
                                newProblem.OrderNo        = baseList[i].OrderNo;
                                newProblem.PicturePath    = problem[j].PicturePath;
                                newProblem.ProblemDetails = problem[j].ProblemDetails;
                                newProblem.ProblemID      = problem[j].ProblemID;
                                problemList.Add(newProblem);
                            }
                        }
                        info.ProblemList = problemList;
                        InfoList.Add(info);
                    }
                }
                return(InfoList);
            }
        }
        public Object AddFeedback([FromBody] FeedbackData PostData)
        {
            ResultData result = new ResultData();

            using (SqlConnection sqlconnection = new SqlConnection(conString))
            {
                bool flag = true;
                FeedbackBaseService service  = new FeedbackBaseService(sqlconnection);
                List <FeedbackBase> BaseList = service.GetOrderInfoByWhere(" where OrderNo='" + PostData.OrderNo + "'");
                if (sqlconnection.State == ConnectionState.Closed)
                {
                    sqlconnection.Open();
                }
                SqlTransaction transaction = sqlconnection.BeginTransaction();
                try
                {
                    FeedbackBase feedbackbase = new FeedbackBase();
                    feedbackbase.OrderNo     = PostData.OrderNo;
                    feedbackbase.Model       = PostData.Model;
                    feedbackbase.FeedbackMan = PostData.FeedbackMan;
                    //feedbackbase.FeedbackTime = DateTime.Now;
                    feedbackbase.Qty           = PostData.Qty;
                    feedbackbase.WorkProcedure = PostData.WorkProcedure;
                    feedbackbase.BatchNo       = PostData.BatchNo;
                    feedbackbase.EquipmentName = PostData.EquipmentName;
                    feedbackbase.EquipmentNo   = PostData.EquipmentNo;
                    feedbackbase.ProductClass  = PostData.ProductClass;
                    if (PostData.FeedbackTime == "")
                    {
                        feedbackbase.FeedbackTime = DateTime.Now;
                    }
                    else
                    {
                        feedbackbase.FeedbackTime = Convert.ToDateTime(PostData.FeedbackTime);
                    }

                    feedbackbase.Status       = PostData.Status;
                    feedbackbase.ProblemLevel = PostData.ProblemLevel;
                    //FeedbackBaseService service = new FeedbackBaseService(sqlconnection);
                    //List<FeedbackBase> BaseList= service.GetOrderInfoByWhere(" where OrderNo='" + PostData.OrderNo + "'",transaction);
                    if (BaseList != null && BaseList.Count > 0)
                    {
                        flag = service.Delete(PostData.OrderNo, transaction);
                    }
                    if (!Directory.Exists(SavePath))
                    {
                        Directory.CreateDirectory(SavePath);
                    }
                    if (service.AddFeedbackBase(feedbackbase, transaction))
                    {
                        FeedbackExProblemService PService = new FeedbackExProblemService(sqlconnection);
                        FeedbackExReasonService  RService = new FeedbackExReasonService(sqlconnection);
                        BllProductCard           BllCard  = new BllProductCard(sqlconnection);
                        FeedbackExProblem        Problem  = new FeedbackExProblem();
                        FeedbackExReason         Reason   = new FeedbackExReason();
                        foreach (var list in PostData.ReasonData)
                        {
                            if (list.ReasonType != "" && list.ReasonDetails != "")
                            {
                                Reason.ReasonType    = list.ReasonType;
                                Reason.ReasonDetails = list.ReasonDetails;
                                Reason.OrderNo       = PostData.OrderNo;
                                if (!RService.AddReason(Reason, transaction))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                        }
                        foreach (var list in PostData.ProblemData)
                        {
                            if (list.CodeString != "" || list.PicturePath != "" || list.ProblemDetails != "")
                            {
                                Problem.CodeString = list.CodeString;
                                Problem.OrderNo    = PostData.OrderNo;
                                string PicturePath = list.PicturePath;
                                string filePath    = "";
                                if (PicturePath != "" && PicturePath != null)
                                {
                                    var chrPath = PicturePath.Split('|');
                                    for (int iPath = 0; iPath < chrPath.Length; iPath++)
                                    {
                                        if (chrPath[iPath].Contains("base64"))
                                        {
                                            SaveImage save     = new SaveImage();
                                            string    fileName = DateTime.Now.Ticks.ToString();
                                            save.SaveInageForBase(chrPath[iPath].Split(',')[1], SavePath, fileName);
                                            filePath = filePath + "ProblemPicture/" + fileName + ".png" + ",";
                                        }
                                        else if (chrPath[iPath] != "")
                                        {
                                            string tempPath = "";
                                            for (var i = 0; i < chrPath[iPath].Split('/').Length; i++)
                                            {
                                                if (i >= 3)
                                                {
                                                    tempPath = tempPath + chrPath[iPath].Split('/')[i] + "/";
                                                }
                                            }
                                            if (tempPath != "")
                                            {
                                                tempPath = tempPath.Substring(0, tempPath.LastIndexOf("/"));
                                                filePath = filePath + tempPath + ",";
                                            }
                                        }
                                    }
                                }
                                if (filePath != "")
                                {
                                    filePath = filePath.Substring(0, filePath.LastIndexOf(","));
                                }

                                Problem.PicturePath    = filePath;
                                Problem.ProblemDetails = list.ProblemDetails;
                                if (!PService.AddProblem(Problem, transaction))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                        }
                        foreach (var list in PostData.CardList)
                        {
                            list.FKOrderNo = PostData.OrderNo;
                            if (!BllCard.InsertCard(list, transaction))
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (PostData.IfQC)
                        {
                            FeedbackExHandleService BllHandler = new FeedbackExHandleService(sqlconnection);
                            FeedbackExHandle        Handler    = new FeedbackExHandle();
                            Handler.HandleMan        = PostData.HandleMan;
                            Handler.HandleNote       = PostData.HandleNote;
                            Handler.HandleSuggestion = PostData.HandleSuggestion;
                            Handler.HandleTime       = DateTime.Now;
                            Handler.QualityClass     = PostData.QualityClass;
                            Handler.OrderNo          = PostData.OrderNo;
                            if (!BllHandler.AddHandle(Handler, transaction))
                            {
                                flag = false;
                            }
                        }
                        if (flag)
                        {
                            transaction.Commit();
                            result.ErrMsg = "";
                            result.Result = true;
                            return(result);
                        }
                        else
                        {
                            transaction.Rollback();
                            result.ErrMsg = "反馈失败";
                            result.Result = false;
                            return(result);
                        }
                    }
                    else
                    {
                        transaction.Rollback();
                        result.ErrMsg = "反馈失败";
                        result.Result = false;
                        return(result);
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    result.Result = false;
                    if (ex.Message.Contains("重复键"))
                    {
                        result.ErrMsg = "已存在相同的单号,编码不能重复添加";
                    }
                    else
                    {
                        result.ErrMsg = ex.Message;
                    }
                    return(result);
                }
            }
        }
        public Object GetQualityOrder(long PageIndex, long PageSize, string OrderNo,
            string WorkProcedure, string BatchNo, string Model, string EquipmentNo,
            string FeedbackMan, string StartTime, string EndTime, string Status)
        {
            using (SqlConnection con = new SqlConnection(_ConString))
            {
                try
                {
                    OrderNo = IsNull(OrderNo);WorkProcedure = IsNull(WorkProcedure);
                    BatchNo = IsNull(BatchNo);Model = IsNull(Model);
                    EquipmentNo = IsNull(EquipmentNo);FeedbackMan = IsNull(FeedbackMan);
                    StartTime = IsNull(StartTime);EndTime = IsNull(EndTime);
                    Status = IsNull(Status);
                    string strWhere = @" where OrderNo like '%{0}%' and WorkProcedure like
 '%{1}%' and BatchNo like '%{2}%' and Model like '%{3}%' and EquipmentNo like '%{4}%' and FeedbackMan like '%{5}%'  ";
                    strWhere = string.Format(strWhere, OrderNo, WorkProcedure, BatchNo, Model, EquipmentNo, FeedbackMan);
                    if (StartTime != "" &&  EndTime != "" )
                    {
                        strWhere += " and FeedbackTime between '" + StartTime + "' and '" + EndTime + " 23:59:59'";
                    }
                    if (Status == "T1")
                    {
                        //待处理
                        strWhere += " and Status!='P' ";
                    }
                    else if (Status == "P")
                    {
                        //已完成
                        strWhere += " and Status='P' ";
                    }
                    else if (Status == "B")
                    {
                        //待审批
                        strWhere += " and Status='B'";
                    }
                    BllApprovalStream Bll = new BllApprovalStream(con);
                    FeedbackBaseService BllBase = new FeedbackBaseService(con);
                    FeedbackExReasonService BllReason = new FeedbackExReasonService(con);
                    FeedbackExProblemService BllPro = new FeedbackExProblemService(con);
                    BllProductCard BllCard = new BllProductCard(con);
                    List<ReturnData> RequestList = new List<ReturnData>();
                    long RowCount = 0, PageCount = 0;
                    List<FeedbackBase> BaseList = BllBase.GetQualityOrder(PageIndex,PageSize,strWhere,out RowCount);

                    foreach(var node in BaseList)
                    {
                        ReturnData Request = new ReturnData();
                        //①基础信息
                        string Request_OrderNo = node.OrderNo;
                        Request.OrderNo = Request_OrderNo;
                        Request.BatchNo = node.BatchNo;
                        Request.WorkProcedure = node.WorkProcedure;
                        Request.Model = node.Model;
                        Request.FeedbackMan = node.FeedbackMan;
                        Request.FeedbackTime = node.FeedbackTime.ToString("yyyy-MM-dd HH:mm");
                        Request.EquipmentName = node.EquipmentName;
                        Request.EquipmentNo = node.EquipmentNo;
                        Request.Qty = node.Qty;
                        Request.Status = node.Status;
                        Request.ProductClass = node.ProductClass;
                        //②原因信息
                        Request.ReasonList = BllReason.GetReasonByWhere(" where OrderNo='" + Request_OrderNo + "'");
                        //③问题
                        List<FeedbackExProblem> ProList = BllPro.GetProblemByWhere("  where OrderNo = '" + Request_OrderNo + "'");
                        Request.ProblemList = GetProblemList(ProList, con);
                        //④处理
                        Request.ApStream = Bll.GetStream(" where OrderNo='" + node.OrderNo + "'");
                        //⑤客户列表
                        Request.CardList = BllCard.GetCard(" where FKOrderNo='" + node.OrderNo + "'");
                        Request.RowCount = RowCount;
                        RequestList.Add(Request);
                    }
                    return RequestList;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
        public Object Get(string OrderNo, string WorkProcedure, string BatchNo, string Model, string EquipmentNo,
                          string FeedbackMan, string StartTime, string EndTime, string HPrint, string Status)
        {
            OrderNo       = IsNull(OrderNo);
            WorkProcedure = IsNull(WorkProcedure);
            BatchNo       = IsNull(BatchNo);
            Model         = IsNull(Model);
            EquipmentNo   = IsNull(EquipmentNo);
            FeedbackMan   = IsNull(FeedbackMan);
            StartTime     = IsNull(StartTime);
            EndTime       = IsNull(EndTime);
            HPrint        = IsNull(HPrint);
            Status        = IsNull(Status);
            string strWhere = @" where OrderNo like '%{0}%' and WorkProcedure like
 '%{1}%' and BatchNo like '%{2}%' and Model like '%{3}%' and EquipmentNo like '%{4}%' and FeedbackMan like '%{5}%'  ";

            strWhere = string.Format(strWhere, OrderNo, WorkProcedure, BatchNo, Model, EquipmentNo, FeedbackMan);
            if (StartTime != "" && StartTime != null & EndTime != "" && EndTime != null)
            {
                strWhere += " and FeedbackTime between '" + StartTime + "' and '" + EndTime + " 23:59:59'";
            }
            if (HPrint == "0")
            {
                strWhere += " and (HPrint=0 or HPrint is null)";
            }
            else if (HPrint == "1")
            {
                strWhere += " and HPrint=1 ";
            }
            if (Status == "T1")
            {
                //待处理
                strWhere += " and Status!='P' ";
            }
            else if (Status == "P")
            {
                //已完成
                strWhere += " and Status='P' ";
            }
            else if (Status == "2")
            {
                //待审批
                strWhere += " and Status!='P'";
            }
            strWhere += " order by FeedbackTime desc";
            using (SqlConnection con = new SqlConnection(_connectionString))
            {
                try
                {
                    BllApprovalStream        Bll         = new BllApprovalStream(con);
                    FeedbackBaseService      BllBase     = new FeedbackBaseService(con);
                    FeedbackExReasonService  BllReason   = new FeedbackExReasonService(con);
                    FeedbackExProblemService BllPro      = new FeedbackExProblemService(con);
                    FeedbackExHandleService  BllHandle   = new FeedbackExHandleService(con);
                    List <FeedbackBase>      BaseList    = BllBase.GetOrderInfoByWhere(strWhere);
                    List <Completed_Request> RequestList = new List <Completed_Request>();
                    if (BaseList != null && BaseList.Count > 0)
                    {
                        foreach (var node in BaseList)
                        {
                            Completed_Request Request = new Completed_Request();
                            //①基础信息
                            string Request_OrderNo = node.OrderNo;
                            Request.OrderNo       = Request_OrderNo;
                            Request.BatchNo       = node.BatchNo;
                            Request.WorkProcedure = node.WorkProcedure;
                            Request.Model         = node.Model;
                            Request.FeedbackMan   = node.FeedbackMan;
                            Request.FeedbackTime  = node.FeedbackTime.ToString("yyyy-MM-dd HH:mm");
                            Request.EquipmentName = node.EquipmentName;
                            Request.EquipmentNo   = node.EquipmentNo;
                            Request.Qty           = node.Qty;
                            Request.Status        = node.Status;

                            //②原因信息
                            Request.ReasonList = BllReason.GetReasonByWhere(" where OrderNo='" + Request_OrderNo + "'");
                            //③问题
                            List <FeedbackExProblem> ProList = BllPro.GetProblemByWhere("  where OrderNo = '" + Request_OrderNo + "'");
                            Request.ProblemList = GetProblemList(ProList, con);
                            //④处理
                            FeedbackExHandle feedbackExHandle = BllHandle.GetHandler(" where OrderNo='" + Request_OrderNo + "'").FirstOrDefault();
                            ExHandle         ExHandle         = new ExHandle();
                            if (feedbackExHandle != null)
                            {
                                ExHandle.HandleMan        = feedbackExHandle.HandleMan;
                                ExHandle.HandleTime       = feedbackExHandle.HandleTime.ToString("yyyy-MM-dd HH:mm");
                                ExHandle.HandleSuggestion = feedbackExHandle.HandleSuggestion;
                                ExHandle.QualityClass     = feedbackExHandle.QualityClass;
                                ExHandle.HandleNote       = feedbackExHandle.HandleNote;
                            }
                            Request.Handler  = ExHandle;
                            Request.ApStream = Bll.GetStream(" where OrderNo='" + node.OrderNo + "'");


                            //⑤关联
                            //循环找出最顶层的批号
                            string Loop = node.BatchNo;
                            bool   flag = true;
                            while (flag)
                            {
                                string strsql = "select ParentNo from ZL_ParentTable where ChildNo='" + Loop + "' ";
                                Parent parent = con.Query <Parent>(strsql).FirstOrDefault();
                                if (parent != null)
                                {
                                    Loop = parent.ParentNo;
                                }
                                else
                                {
                                    flag = false;
                                }
                            }
                            //根据最顶层批号进行递归算法,查找相关的批号
                            string strJson = "{\"ParentNo\":\"" + Loop + "\",\"ChildNo\":[" + GetJson(Loop, con) + "]}";
                            Request.Relate = strJson;
                            RequestList.Add(Request);
                        }
                    }
                    return(RequestList);
                }
                catch (Exception ex)
                {
                    string ErrMsg = ex.Message;
                    return("");
                }
                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }
Exemplo n.º 5
0
        public Object InsertOrder(OrderInfo PostData)
        {
            ResultData    result = new ResultData();//返回数据类型
            SqlConnection con    = new SqlConnection(conString);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            //验证是否已存在该单号的单据,存在删除,再添加,不存在直接添加
            bool   Delete  = false;//false:不存在,true:存在
            string OrderNo = PostData.OrderNo != null? PostData.OrderNo:"";

            OrderNo = OrderNo.Trim();
            FeedbackBaseService BllBase = new FeedbackBaseService(con);
            Guid NewID = BllBase.GetNewID();

            FeedbackBase Base = BllBase.GetOrderInfoByWhere(" where OrderNo='" + OrderNo + "'").FirstOrDefault();

            if (Base != null)
            {
                Delete = true;
            }
            SqlTransaction tran = con.BeginTransaction();

            try
            {
                if (Delete)
                {
                    if (!BllBase.Delete(OrderNo, tran))//删除旧单据
                    {
                        result.ErrMsg = "提交失败,原因:删除原始信息异常";
                        result.Result = false;
                        return(result);
                    }
                }
                //定义保存的数据

                string       EmployeeID = PostData.EmployeeID;
                FeedbackBase Domain     = new FeedbackBase();
                Domain.ID            = NewID;
                Domain.OrderNo       = OrderNo;//单号,控制表以KZ开头,反馈单已FK开头
                Domain.BatchNo       = PostData.BatchNo;
                Domain.Model         = PostData.Model;
                Domain.Qty           = PostData.Qty;
                Domain.Status        = "0";//默认T1顺序审批人
                Domain.WorkProcedure = PostData.WorkProcedure;
                Domain.EquipmentName = PostData.EquipmentName;
                Domain.EquipmentNo   = PostData.EquipmentNo;
                Domain.FeedbackMan   = PostData.FeedbackMan;
                Domain.ProblemLevel  = PostData.ProblemLevel;//审批流程代号
                Domain.ImageList     = PostData.ImageList;
                Domain.ImageHtml     = PostData.ImageHtml;

                if (PostData.FeedbackTime == null || PostData.FeedbackTime == "")
                {
                    PostData.FeedbackTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                }
                Domain.FeedbackTime = Convert.ToDateTime(PostData.FeedbackTime);
                Domain.ProductClass = PostData.ProductClass;
                int OrderType  = 0;
                int FlowTempId = 1;
                if (OrderNo.StartsWith("FK"))
                {
                    FlowTempId = 0;
                    OrderType  = 0;
                }
                else
                {
                    FlowTempId = 1;
                    OrderType  = 1;
                }
                Domain.OrderType  = OrderType;
                Domain.Measure    = PostData.Measure != null ? PostData.Measure : "";
                Domain.Report     = PostData.Report != null ? PostData.Report : "";
                Domain.EmployeeID = EmployeeID;
                List <ProductCard.CardInfo> CardList    = PostData.CardList;
                List <OrderReason>          ReasonData  = PostData.ReasonData;
                List <OrderProblem>         ProblemData = PostData.ProblemData;

                #region ======Post请求:录入审批系统=====
                //GeneralMethod Method = new GeneralMethod();
                string title = "";
                if (FlowTempId == 1)
                {
                    title = "质量控制流程(" + OrderNo + ")";
                }
                else
                {
                    title = "质量反馈流程(" + OrderNo + ")";
                }

                string urls = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("host.json", optional: true).Build().GetSection("ApprovalPostAddress").Value;
                using (HttpClient Client = new HttpClient())
                {
                    var values = new List <KeyValuePair <string, string> >();
                    values.Add(new KeyValuePair <string, string>("Title", title));
                    values.Add(new KeyValuePair <string, string>("InstanceID", NewID.ToString()));
                    values.Add(new KeyValuePair <string, string>("FlowID", "D3BBCCBF-8968-4833-8A0F-CE5B19B718E2"));
                    values.Add(new KeyValuePair <string, string>("Account", EmployeeID));
                    values.Add(new KeyValuePair <string, string>("WorkProcedure", PostData.WorkProcedure));
                    var content  = new FormUrlEncodedContent(values);
                    var response = Client.PostAsync(urls, content);
                    response.Wait();

                    HttpResponseMessage resp = response.Result;

                    var res2 = resp.Content.ReadAsStringAsync();
                    res2.Wait();
                    string  Message = res2.Result;
                    JObject Robj    = JObject.Parse(Message);
                    if (Robj["result"].ToString() == "1")
                    {
                        Domain.TechnologistMembers = Robj["msg"].ToString();
                    }
                    else
                    {
                        Exception ex = new Exception(Robj["msg"] + "(远端接入失败)");
                        throw ex;
                    }
                }
                #endregion



                if (BllBase.Insert(Domain, tran))
                {
                    FeedbackExProblemService BllProblem = new FeedbackExProblemService(con);
                    FeedbackExReasonService  BllReason  = new FeedbackExReasonService(con);
                    BllProductCard           BllCard    = new BllProductCard(con);
                    for (int i = 0; i < ProblemData.Count; i++)
                    {
                        FeedbackExProblem Problem = new FeedbackExProblem();
                        Problem.OrderNo        = OrderNo;
                        Problem.CodeString     = ProblemData[i].codeString;
                        Problem.TopClass       = ProblemData[i].topClass;
                        Problem.RoomName       = ProblemData[i].roomName;
                        Problem.Problem        = ProblemData[i].problem;
                        Problem.TypeName       = ProblemData[i].typeName;
                        Problem.Present        = ProblemData[i].present;
                        Problem.ProblemDetails = ProblemData[i].problemDetails;
                        Problem.Suggestion     = ProblemData[i].suggestion;
                        Problem.QualityClass   = ProblemData[i].qualityClass;
                        Problem.ProblemLevel   = ProblemData[i].problemLevel;
                        if (ProblemData[i].suggestion != "" && ProblemData[i].suggestion != null && ProblemData[i].suggestion.Contains("suggestion"))
                        {
                            JArray JList = JArray.Parse(ProblemData[i].suggestion);
                            foreach (var node in JList)
                            {
                                string suggestion = node["suggestion"].ToString();
                                if (!BllBase.InsertOrderSuggestion(tran, suggestion, OrderNo, ProblemData[i].codeString))
                                {
                                    Exception ex = new Exception("提交失败,原因:保存质量问题编码处理意见失败");
                                    throw ex;
                                }
                            }
                        }

                        if (!BllProblem.AddProblem(Problem, tran))
                        {
                            Exception ex = new Exception("提交失败,原因:质量问题提交异常");
                            throw ex;
                        }
                    }
                    for (int i = 0; i < ReasonData.Count; i++)
                    {
                        FeedbackExReason Reason = new FeedbackExReason();
                        Reason.OrderNo       = OrderNo;
                        Reason.ReasonDetails = ReasonData[i].reasonDetails;
                        Reason.ReasonType    = ReasonData[i].reasonType;
                        if (!BllReason.AddReason(Reason, tran))
                        {
                            Exception ex = new Exception("提交失败,原因:原因分析提交异常");
                            throw ex;
                        }
                    }
                    foreach (var node in CardList)
                    {
                        node.FKOrderNo = OrderNo;
                        if (!BllCard.InsertCard(node, tran))
                        {
                            Exception ex = new Exception("提交失败,原因:客户信息提交异常");
                            throw ex;
                        }
                    }

                    tran.Commit();
                    result.Result = true;
                    result.ErrMsg = "提交成功";
                }
                else
                {
                    result.Result = false;
                    result.ErrMsg = "提交失败,原因:基础信息提交异常";
                    BllBase.DeleteWorkFlowTask(NewID.ToString(), tran);
                    tran.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                tran.Dispose();
                try
                {
                    BllBase.DeleteWorkFlowTask(NewID.ToString());
                }
                catch (Exception ex2)
                {
                }
                result.Result = false;
                result.ErrMsg = ex.Message;
                return(result);
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 6
0
        public Object GetOrderInfo(long PageIndex, long PageSize, string OrderNo,
                                   string WorkProcedure, string BatchNo, string Model, string EquipmentNo,
                                   string FeedbackMan, string StartTime, string EndTime, string Status, int OrderType)
        {
            OrderNo       = OrderNo != null ? OrderNo : "";
            WorkProcedure = WorkProcedure != null ? WorkProcedure : "";
            BatchNo       = BatchNo != null ? BatchNo : "";
            Model         = Model != null ? Model : "";
            EquipmentNo   = EquipmentNo != null ? EquipmentNo : "";;
            FeedbackMan   = FeedbackMan != null ? FeedbackMan : "";
            StartTime     = StartTime != null ? StartTime : "";
            EndTime       = EndTime != null ? EndTime : "";
            Status        = Status != null ? Status : "";
            string strWhere = @"   OrderNo like '%{0}%' and isnull(WorkProcedure,'') like
 '%{1}%' and isnull(BatchNo,'') like '%{2}%' and isnull(Model,'') like '%{3}%' and  isnull(EquipmentNo,'') like '%{4}%' and isnull(FeedbackMan,'') like '%{5}%'  ";

            strWhere = string.Format(strWhere, OrderNo, WorkProcedure, BatchNo, Model, EquipmentNo, FeedbackMan);
            if (StartTime != "" & EndTime != "")
            {
                strWhere += " and FeedbackTime between '" + StartTime + "' and '" + EndTime + " 23:59:59'";
            }

            /*
             *  Status表示订单状态,该值存在以下几种情况: Null:全部,E:待处理;W:待确认;T:处理中;P:已完成;B:已退单;
             *  W状态下:b.Status=0&&b.StepID=私有公共变量WaitConfirmStepID
             *  E状态下: b.Status=0&&b.StepID=私有公共变量WaitHandleStepID,即QC所在步骤StepID
             *  T状态下: b.Status=0
             *  P状态下:b.Status=2
             *  B状态下:b.Status=3
             */
            switch (Status)
            {
            case "E":
                strWhere += @" and (b.Status=0 and b.StepID='" + WaitHandleStepID + "')";
                break;

            case "W":
                strWhere += @" and (b.Status=0 and b.StepID='" + WaitConfirmStepID + "')";
                break;

            case "T":
                strWhere += @" and (b.Status=0)";
                break;

            case "P":
                strWhere += @" and (b.Status=2)";
                break;

            case "B":
                strWhere += @" and (b.Status=3)";
                break;

            default:
                break;
            }
            strWhere += " and OrderType=" + OrderType + "  ";
            using (SqlConnection con = new SqlConnection(conString))
            {
                try
                {
                    BllApprovalStream        BllStream = new BllApprovalStream(con);
                    FeedbackBaseService      BllBase = new FeedbackBaseService(con);
                    FeedbackExReasonService  BllReason = new FeedbackExReasonService(con);
                    FeedbackExProblemService BllPro = new FeedbackExProblemService(con);
                    BllProductCard           BllCard = new BllProductCard(con);
                    long RowCount = 0, PageCount = 0;
                    List <FeedbackBase> BaseList  = BllBase.GetOrderByWorkFlowTaskOnPage(PageIndex, PageSize, strWhere, out RowCount);
                    List <OrderInfo>    OrderList = new List <OrderInfo>();
                    if (BaseList != null && BaseList.Count > 0)
                    {
                        foreach (var node in BaseList)
                        {
                            OrderInfo Item = new OrderInfo();
                            //①基础信息
                            Item.OrderNo       = node.OrderNo;
                            Item.BatchNo       = node.BatchNo;
                            Item.Model         = node.Model;
                            Item.Qty           = node.Qty;
                            Item.ProductClass  = node.ProductClass;
                            Item.WorkProcedure = node.WorkProcedure;
                            Item.EquipmentName = node.EquipmentName;
                            Item.EquipmentNo   = node.EquipmentNo;
                            Item.FeedbackMan   = node.FeedbackMan;
                            Item.FeedbackTime  = node.FeedbackTime.ToString("yyyy-MM-dd HH:mm");
                            Item.ProblemLevel  = node.ProblemLevel;
                            Item.Report        = node.Report;
                            Item.Measure       = node.Measure;
                            //Item.Status= node.Status;
                            Item.Status     = node.ProvalStatus.ToString();
                            Item.EmployeeID = node.EmployeeID;
                            Item.StepID     = node.StepID;
                            Item.StepName   = node.StepName;
                            Item.ID         = (node.ID).ToString();
                            Item.PrevStatus = node.PrevStatus;
                            Item.IsControl  = node.IsControl;
                            Item.ImageList  = node.ImageList;



                            //②质量问题
                            List <FeedbackExProblem> Problem      = BllPro.GetProblemByWhere(" where OrderNo='" + node.OrderNo + "'");
                            List <OrderProblem>      OrderProblem = new List <OrderProblem>();
                            foreach (var list in Problem)
                            {
                                OrderProblem Obj_Problem = new OrderProblem();
                                Obj_Problem.codeString     = list.CodeString;
                                Obj_Problem.topClass       = list.TopClass;
                                Obj_Problem.roomName       = list.RoomName;
                                Obj_Problem.typeName       = list.TypeName;
                                Obj_Problem.present        = list.Present;
                                Obj_Problem.problem        = list.Problem;
                                Obj_Problem.suggestion     = list.Suggestion;
                                Obj_Problem.problemDetails = list.ProblemDetails;
                                Obj_Problem.qualityClass   = list.QualityClass;
                                Obj_Problem.problemLevel   = list.ProblemLevel;
                                OrderProblem.Add(Obj_Problem);
                            }
                            Item.ProblemData = OrderProblem;
                            //③原因分析
                            List <FeedbackExReason> Reason      = BllReason.GetReasonByWhere(" where OrderNo='" + node.OrderNo + "'");
                            List <OrderReason>      OrderReason = new List <OrderController.OrderReason>();
                            foreach (var list in Reason)
                            {
                                OrderReason Obj_Reason = new OrderReason();
                                Obj_Reason.reasonType    = list.ReasonType;
                                Obj_Reason.reasonDetails = list.ReasonDetails;
                                Obj_Reason.orderNo       = list.OrderNo;
                                OrderReason.Add(Obj_Reason);
                            }
                            Item.ReasonData = OrderReason;
                            //④客户信息
                            Item.CardList = BllCard.GetCard(" where FKOrderNo='" + node.OrderNo + "' and CardNo <>''");
                            //⑤反馈单处理意见
                            Item.ApprovalStream = BllStream.GetStream(" where OrderNo='" + node.OrderNo + "' and StreamType=0");
                            if (OrderType == 1)
                            {
                                //⑥控制表处理意见
                                Item.ControlStream = BllStream.GetStream(" where OrderNo='" + node.OrderNo + "' and StreamType=1");
                            }
                            Item.RowCount = RowCount;
                            OrderList.Add(Item);
                        }
                    }
                    return(OrderList);
                }
                catch (Exception ex)
                {
                    string ErrMsg = ex.Message;
                    return("");
                }
                finally
                {
                    if (con.State != ConnectionState.Closed)
                    {
                        con.Close();
                    }
                }
            }
        }