Beispiel #1
0
        public bool PauseOrder_Call(string jsonedata)
        {
            COrderList mesEvent = JsonConvert.DeserializeObject <COrderList>(jsonedata);
            //写队列
            WriteMesEvent writeMes = new WriteMesEvent();

            if (writeMes.WriteMesEvent_Call(mesEvent, 3))
            {
                SqlCommand cmd = PmConnections.SchCmd();
                cmd.CommandText = "UPDATE User_MesDailyData SET TaskFinishState = '3',MesResName = '" + mesEvent.MesResName + "', MesOpName = '" + mesEvent.MesOpName + "', bgPerson = '" +
                                  mesEvent.MesOperator + "', updateDateTime = '" + DateTime.Now + "' WHERE UID = '" + mesEvent.OrderUID + "'";
                int result = cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                if (result == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public bool Report_Call(string jsonedata)
        {
            COrderList    mesEvent = JsonConvert.DeserializeObject <COrderList>(jsonedata);
            WriteMesEvent writeMes = new WriteMesEvent();

            if (writeMes.WriteMesEvent_Call(mesEvent, 2))
            {
                //更新mesdailydata
                SqlCommand cmd = PmConnections.SchCmd();
                cmd.CommandText = "SELECT finishedQty,AllfinishedQty,AllJobTaskQty FROM User_MesDailyData WHERE UID = '" + mesEvent.OrderUID + "'";
                SqlDataReader rd = cmd.ExecuteReader();
                rd.Read();
                double serverallfinishedQty = Convert.ToDouble(rd[1]);
                double serverfinishedqty    = Convert.ToDouble(rd[0]);
                double alljobtaskqty        = Convert.ToDouble(rd[2]);
                rd.Close();
                int taskfinishedstate;
                if ((serverallfinishedQty + mesEvent.FinishedQty + mesEvent.FailedQty) == alljobtaskqty)
                {
                    taskfinishedstate = 4;
                }
                else
                {
                    if ((serverfinishedqty + mesEvent.FinishedQty + mesEvent.FailedQty) >= mesEvent.Plannedqty)
                    {
                        taskfinishedstate = 4;
                    }
                    else
                    {
                        taskfinishedstate = 2;
                    }
                }

                cmd.CommandText = "UPDATE User_MesDailyData SET mesResName = '" + mesEvent.MesResName + "', mesOpName = '" + mesEvent.MesOpName + "',finishedQty = finishedQty + '" + (mesEvent.FinishedQty + mesEvent.FailedQty) +
                                  "', failQty = failQty + '" + mesEvent.FailedQty + "', endDateTime = '" + mesEvent.ReportTime + "', updateDateTime = '" + DateTime.Now + "', bgPerson = '" + mesEvent.MesOperator +
                                  "',ScrappedQty = ScrappedQty + '" + mesEvent.ScrappedQty + "', TaskFinishState = '" + taskfinishedstate + "',UserComment = '" + mesEvent.UserComment + " ' WHERE UID = '" + mesEvent.OrderUID + "'";
                cmd.ExecuteNonQuery();
                cmd.CommandText = "UPDATE User_MesDailyData SET AllFinishedQty = AllFinishedQty + '" + (mesEvent.FinishedQty + mesEvent.FailedQty) + "', updateDateTime ='" + DateTime.Now + "' WHERE workID = '" + mesEvent.WorkID +
                                  "' and productID = '" + mesEvent.ProductID + "' and pmOpName = '" + mesEvent.PmOpName + "'";
                int result = cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
 public bool Resume_Call(string jsonedata)
 {
     COrderList mesEvent = JsonConvert.DeserializeObject<COrderList>(jsonedata);
     WriteMesEvent writeMes = new WriteMesEvent();
     if(writeMes.WriteMesEvent_Call(mesEvent,4))
     {
         SqlCommand cmd = PmConnections.SchCmd();
         cmd.CommandText = "UPDATE User_MesDailyData SET TaskFinishState = '0' WHERE UID = '" + mesEvent.OrderUID + "'";
         int result = cmd.ExecuteNonQuery();
         cmd.Connection.Close();
         if (result == 1)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     else
     {
         return false;
     }
 }
Beispiel #4
0
        public bool ChangeResource_Call(string jsonedata)
        {
            COrderList    mesEvent = JsonConvert.DeserializeObject <COrderList>(jsonedata);
            WriteMesEvent writeMes = new WriteMesEvent();

            if (writeMes.WriteMesEvent_Call(mesEvent, 5))
            {
                SqlCommand cmd = PmConnections.SchCmd();
                cmd.CommandText = "UPDATE User_MesDailyData SET pmResName  = '" + mesEvent.ChangeResName + "' WHERE UID = '" + mesEvent.OrderUID + "'";
                int result = cmd.ExecuteNonQuery();
                if (result == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        public bool EndWork(string jsonedata)
        {
            COrderList    mesEvent = JsonConvert.DeserializeObject <COrderList>(jsonedata);
            WriteMesEvent writeMes = new WriteMesEvent();

            if (writeMes.WriteMesEvent_Call(mesEvent, 6))
            {
                thisresname = mesEvent.MesResName;
                SqlDataReader rd;
                SqlCommand    cmd;
                int           taskfinishedstate = -1;
                if (mesEvent.TaskFinishState == 2)
                {
                    //更新mesdailydata
                    cmd             = PmConnections.SchCmd();
                    cmd.CommandText = "SELECT finishedQty,AllfinishedQty,AllJobTaskQty FROM User_MesDailyData WHERE UID = '" + mesEvent.OrderUID + "'";
                    rd = cmd.ExecuteReader();
                    rd.Read();
                    double serverallfinishedQty = Convert.ToDouble(rd[1]);
                    double serverfinishedqty    = Convert.ToDouble(rd[0]);
                    double alljobtaskqty        = Convert.ToDouble(rd[2]);
                    rd.Close();
                    if ((serverallfinishedQty + mesEvent.FinishedQty + mesEvent.FailedQty) == alljobtaskqty)
                    {
                        taskfinishedstate = 4;
                    }
                    else
                    {
                        if ((serverfinishedqty + mesEvent.FinishedQty + mesEvent.FailedQty) >= mesEvent.Plannedqty)
                        {
                            taskfinishedstate = 4;
                        }
                        else
                        {
                            taskfinishedstate = 2;
                        }
                    }

                    cmd.CommandText = "UPDATE User_MesDailyData SET mesResName = '" + mesEvent.MesResName + "', mesOpName = '" + mesEvent.MesOpName + "',finishedQty = finishedQty + '" + (mesEvent.FinishedQty + mesEvent.FailedQty) +
                                      "', failQty = failQty + '" + mesEvent.FailedQty + "', endDateTime = '" + mesEvent.ReportTime + "', updateDateTime = '" + DateTime.Now + "', bgPerson = '" + mesEvent.MesOperator +
                                      "',ScrappedQty = ScrappedQty + '" + mesEvent.ScrappedQty + "', TaskFinishState = '" + taskfinishedstate + "' WHERE UID = '" + mesEvent.OrderUID + "'";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "UPDATE User_MesDailyData SET AllFinishedQty = AllFinishedQty + '" + (mesEvent.FinishedQty + mesEvent.FailedQty) + "', updateDateTime ='" + DateTime.Now + "' WHERE workID = '" + mesEvent.WorkID +
                                      "' and productID = '" + mesEvent.ProductID + "' and pmOpName = '" + mesEvent.PmOpName + "'";
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }

                //查询下一个班次是哪天,第几个班次
                cmd             = PmConnections.SchCmd();
                cmd.CommandText = "SELECT MAX(dayShift) FROM User_MesDailyData WHERE pmResName = '" + mesEvent.PmResName + "' and mesDailyDate ='" + PublicFunc.GetDailyDate(thisresname) + "'";
                rd = cmd.ExecuteReader();
                rd.Read();
                int maxdayshift = Convert.ToInt32(rd[0]);
                rd.Close();
                cmd.Connection.Close();
                int      nextdayshift;
                DateTime nextdailydate;
                if (mesEvent.DayShift < maxdayshift)
                {
                    nextdayshift  = mesEvent.DayShift + 1;
                    nextdailydate = PublicFunc.GetDailyDate(thisresname);
                }
                else
                {
                    nextdayshift  = 1;
                    nextdailydate = PublicFunc.GetDailyDate(thisresname).AddDays(1);
                }
                //先查找这个设备上的下个班次是否有这个订单
                cmd = PmConnections.SchCmd();
                //SELECT COUNT(UID) FROM [sch_test].[dbo].[User_MesDailyData] where pmResName = '纽威立式车床17:2' and  mesDailyDate = '2020-6-20' and workID = '0021905001' and dayShift = 1 and productID = '8311280776' and pmOpName = '精车一'
                cmd.CommandText = "SELECT COUNT(UID) FROM User_MesDailyData WHERE pmResName = '" + thisresname + "' and mesDailyDate = '" + nextdailydate + "' and dayshift = '" + nextdayshift +
                                  "' and workid = '" + mesEvent.WorkID + "' and productid = '" + mesEvent.ProductID + "' and pmOpName = '" + mesEvent.PmOpName + "'";
                rd = cmd.ExecuteReader();
                rd.Read();
                int hasthisorder = Convert.ToInt32(rd[0]);
                rd.Close();
                cmd.Connection.Close();
                if (taskfinishedstate == 4)
                {
                    EndOtherOrder(thisresname);
                    return(true);
                }
                else
                {
                    if (hasthisorder < 1)
                    {
                        cmd             = PmConnections.SchCmd();
                        cmd.CommandText = "UPDATE User_MesDailyData SET mesDailyDate = '" + nextdailydate + "', dayshift = '" + nextdayshift + "' WHERE UID = '" + mesEvent.OrderUID + "'";
                        int result = cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                        if (result > 0)
                        {
                            EndOtherOrder(thisresname);
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        cmd             = PmConnections.SchCmd();
                        cmd.CommandText = "UPDATE User_MesDailyData SET TaskFinishState = '5' WHERE UID = '" + mesEvent.OrderUID + "'";
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                        EndOtherOrder(thisresname);
                        return(true);
                    }
                }
            }
            else
            {
                return(false);
            }
        }