Beispiel #1
0
        public override JobExecuteState ExecuteCustomImp(string strJobKey)
        {
            JobExecuteState jobExecuteState1 = new JobExecuteState();
            DTOResponse     dtoResponse1     = new DTOResponse();
            DCSInfService   dcsInfService    = new DCSInfService();
            string          str1             = "AcceptWcsUpdateInfEquitmentStaus";
            DTOResponse     dtoResponse2     = SysParamsService.CheckPrarams(new SysParamsReuqest()
            {
                ParamsName = str1
            });
            bool isSuccess;

            if (dtoResponse2.IsSuccess)
            {
                SysParams resultObject = dtoResponse2.ResultObject as SysParams;
                if (resultObject == null)
                {
                    jobExecuteState1.MessageText = "系统参数为空";
                    return(jobExecuteState1);
                }
                if (resultObject.PARAVALUE == "TRUE")
                {
                    DTOResponse     dtoResponse3     = dcsInfService.UpdateEquipmentStatus();
                    JobExecuteState jobExecuteState2 = jobExecuteState1;
                    isSuccess = dtoResponse3.IsSuccess;
                    string str2 = isSuccess.ToString();
                    jobExecuteState2.ReturnValue = str2;
                    jobExecuteState1.MessageCode = dtoResponse3.MessageCode;
                    jobExecuteState1.MessageText = dtoResponse3.MessageText;
                }
            }
            string      str3         = "UpdateKanbanFormInfEquitmentStaus";
            DTOResponse dtoResponse4 = SysParamsService.CheckPrarams(new SysParamsReuqest()
            {
                ParamsName = str3
            });

            if (dtoResponse4.IsSuccess)
            {
                SysParams resultObject = dtoResponse4.ResultObject as SysParams;
                if (resultObject == null)
                {
                    jobExecuteState1.MessageText = "系统参数为空";
                    return(jobExecuteState1);
                }
                if (resultObject.PARAVALUE == "TRUE")
                {
                    DTOResponse     dtoResponse3     = dcsInfService.UpdateKanbanFormEquipmentStatus();
                    JobExecuteState jobExecuteState2 = jobExecuteState1;
                    isSuccess = dtoResponse3.IsSuccess;
                    string str2 = isSuccess.ToString();
                    jobExecuteState2.ReturnValue = str2;
                    jobExecuteState1.MessageCode = dtoResponse3.MessageCode;
                    jobExecuteState1.MessageText = dtoResponse3.MessageText;
                }
            }
            return(jobExecuteState1);
        }
Beispiel #2
0
        public DTOResponse TaskHandle()
        {
            DTOResponse    dtoResponse = new DTOResponse();
            IDbConnection  dbCon       = (IDbConnection)null;
            IDbTransaction dbTrans     = (IDbTransaction)null;
            string         id          = (string)null;
            string         msg         = (string)null;

            try
            {
                HelperDbOperation.BeginTransaction(ref dbCon, ref dbTrans);
                INF_JOBFEEDBACKEntity jobFeedBack = dbCon.Select <INF_JOBFEEDBACKEntity>((Expression <Func <INF_JOBFEEDBACKEntity, bool> >)(x => x.STATUS == 0 && x.RESPONDCOUNT < 1)).OrderBy <INF_JOBFEEDBACKEntity, string>((Func <INF_JOBFEEDBACKEntity, string>)(x => x.ENTERDATE)).OrderBy <INF_JOBFEEDBACKEntity, string>((Func <INF_JOBFEEDBACKEntity, string>)(x => x.JOBID)).OrderBy <INF_JOBFEEDBACKEntity, string>((Func <INF_JOBFEEDBACKEntity, string>)(x => x.FEEDBACKSTATUS)).FirstNonDefault <INF_JOBFEEDBACKEntity>();
                if (jobFeedBack == null)
                {
                    dtoResponse.IsSuccess   = false;
                    dtoResponse.MessageText = "当前没有请求需要处理!";
                    return(dtoResponse);
                }
                id = jobFeedBack.ID;
                TaskEntity projTaskEntity = OrmLiteReadExpressionsApi.Single <TaskEntity>(dbCon, (Expression <Func <TaskEntity, bool> >)(x => x.TASKNO == jobFeedBack.JOBID));
                if (projTaskEntity == null)
                {
                    TaskStepEntity stepEntity = OrmLiteReadExpressionsApi.Single <TaskStepEntity>(dbCon, (Expression <Func <TaskStepEntity, bool> >)(x => x.ID == jobFeedBack.JOBID));
                    if (stepEntity != null)
                    {
                        stepEntity.STEPSTATE = "3";
                        dbCon.Update <TaskStepEntity>(stepEntity, (Expression <Func <TaskStepEntity, bool> >)(x => x.ID == stepEntity.ID), (Action <IDbCommand>)null);
                        TaskEntity taskEntity = OrmLiteReadExpressionsApi.Single <TaskEntity>(dbCon, (Expression <Func <TaskEntity, bool> >)(x => x.TASKNO == stepEntity.TASKNO));
                        //dtoResponse = BPCommon.NextTaskStep(dbCon, dbTrans, taskEntity);
                        if (!dtoResponse.IsSuccess)
                        {
                            return(dtoResponse);
                        }
                        jobFeedBack.STATUS = 1;
                        ++jobFeedBack.RESPONDCOUNT;
                        jobFeedBack.RESPONDDATE = Utils.GetTodayNow();
                        jobFeedBack.RESPONDMSG  = "反馈成功";
                        dbCon.Update <INF_JOBFEEDBACKEntity>(jobFeedBack, (Action <IDbCommand>)null);
                        dtoResponse.IsSuccess   = true;
                        dtoResponse.MessageText = "子任务" + jobFeedBack.JOBID + "处理成功!";
                        return(dtoResponse);
                    }
                    dtoResponse.IsSuccess   = false;
                    dtoResponse.MessageText = "查找任务" + jobFeedBack.JOBID + "失败!";
                    dtoResponse.MessageCode = "9999";
                    return(dtoResponse);
                }
                this.InsertTaskStat(jobFeedBack);
                if (projTaskEntity.TASKTCLASS == "3")
                {
                    if (jobFeedBack.FEEDBACKSTATUS == "1")
                    {
                        projTaskEntity.TASKSTATE   = jobFeedBack.FEEDBACKSTATUS;
                        projTaskEntity.STARTDATE   = Utils.GetTodayNow();
                        projTaskEntity.TASKMESSAGE = "任务开始";
                    }
                    if (jobFeedBack.FEEDBACKSTATUS == "99")
                    {
                        projTaskEntity.TASKSTATE   = jobFeedBack.FEEDBACKSTATUS;
                        projTaskEntity.ENDDATE     = Utils.GetTodayNow();
                        projTaskEntity.TASKMESSAGE = "任务结束";
                    }
                }
                else
                {
                    if (jobFeedBack.FEEDBACKSTATUS == "1")
                    {
                        projTaskEntity.TASKSTATE   = jobFeedBack.FEEDBACKSTATUS;
                        projTaskEntity.STARTDATE   = Utils.GetTodayNow();
                        projTaskEntity.TASKMESSAGE = "任务开始";
                    }
                    if (jobFeedBack.FEEDBACKSTATUS == "3")
                    {
                        projTaskEntity.TRUCKNO      = jobFeedBack.EXTATTR1;
                        projTaskEntity.TRUCKNO_PLAN = Utils.GetTodayNow();
                        projTaskEntity.TASKMESSAGE  = "设备开始执行";
                    }
                    if (jobFeedBack.FEEDBACKSTATUS == "99")
                    {
                        projTaskEntity.TASKSTATE   = jobFeedBack.FEEDBACKSTATUS;
                        projTaskEntity.ENDDATE     = Utils.GetTodayNow();
                        projTaskEntity.TASKMESSAGE = "任务结束";
                        string sql1 = string.Format("UPDATE PROJ_LOCATION_DETAIL SET STORESTATE='0' WHERE LOCATIONNO='{0}'", (object)projTaskEntity.SOURCE01);
                        dbCon.ExecuteSql(sql1);
                        string sql2 = string.Format("UPDATE PROJ_LOCATION_DETAIL SET STORESTATE='1' WHERE LOCATIONNO='{0}'", (object)projTaskEntity.DESTINATION01);
                        dbCon.ExecuteSql(sql2);
                        string sql3 = string.Format("UPDATE PROJ_ULDINFO SET CURRLOC='{2}',MODIFYBY='{3}',MODIFYDATE='{4}',CURRSTATE=CURRSTATE+1 WHERE ULDNO='{0}' AND P01='{1}'", (object)projTaskEntity.PALLETNO, (object)projTaskEntity.BILLID, (object)projTaskEntity.DESTINATION01, (object)projTaskEntity.TASKNO, (object)Utils.GetDatetime());
                        dbCon.ExecuteSql(sql3);
                        string sql4 = string.Format("UPDATE PROJ_ULDCARRYPLAN SET P10='{2}',MODIFYBY='{3}',MODIFYDATE='{4}' WHERE PLANNO='{0}' AND ULDNO='{1}'", (object)projTaskEntity.BILLID, (object)projTaskEntity.PALLETNO, (object)projTaskEntity.DESTINATION02, (object)projTaskEntity.TASKNO, (object)Utils.GetDatetime());
                        dbCon.ExecuteSql(sql4);
                        if (SysParamsService.CheckPrarams("SimulatorTaskOver").ToLower() == "true")
                        {
                            this.UpdateInfEquipmentStatus(dbCon, dbTrans, projTaskEntity);
                        }
                        //dtoResponse = BPCommon.NextTaskStep(dbCon, dbTrans, projTaskEntity);
                        if (!dtoResponse.IsSuccess)
                        {
                            return(dtoResponse);
                        }
                        this.GetDataFromDCS(new List <long>()
                        {
                            long.Parse(projTaskEntity.TASKNO)
                        });
                    }
                }
                jobFeedBack.STATUS = 1;
                ++jobFeedBack.RESPONDCOUNT;
                jobFeedBack.RESPONDDATE = Utils.GetTodayNow();
                jobFeedBack.RESPONDMSG  = "反馈成功";
                int num1 = dbCon.Update <INF_JOBFEEDBACKEntity>(jobFeedBack, (Action <IDbCommand>)null);
                int num2 = dbCon.Update <TaskEntity>(projTaskEntity, (Action <IDbCommand>)null);
                if (num1 == 1 && num2 == 1)
                {
                    dtoResponse.IsSuccess   = true;
                    dtoResponse.MessageText = "执行操作成功!";
                }
                return(dtoResponse);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                DCSInfService.logger.Error((object)ex);
                return(dtoResponse);
            }
            finally
            {
                HelperDbOperation.EndTransaction(dtoResponse.IsSuccess, ref dbCon, ref dbTrans);
                if (dtoResponse.MessageCode == "9999")
                {
                    this.UpdataJobFeedBack(id, msg);
                }
            }
        }
Beispiel #3
0
        public DTOResponse UpdateEquipmentStatus()
        {
            DTOResponse    dtoResponse = new DTOResponse();
            IDbConnection  dbCon       = (IDbConnection)null;
            IDbTransaction dbTrans     = (IDbTransaction)null;

            try
            {
                object obj = HelperDbOperation.ExecuteScalar("SELECT ID FROM PROJ_ULDSCENE WHERE SCENESTATE=1");
                HelperDbOperation.BeginTransaction(ref dbCon, ref dbTrans);
                List <INF_EQUIPMENTSTATUSEntity> equipmentstatusEntityList = dbCon.Select <INF_EQUIPMENTSTATUSEntity>((Expression <Func <INF_EQUIPMENTSTATUSEntity, bool> >)(x => x.WMSLOCNUM == "none" && x.STATUS == 0));
                foreach (INF_EQUIPMENTSTATUSEntity equipmentstatusEntity in equipmentstatusEntityList)
                {
                    if (equipmentstatusEntity.EQUIPMENTSTATUS == "1")
                    {
                        string str1     = "0";
                        string str2     = "故障代码:" + equipmentstatusEntity.EQUIPMENTSTATUS;
                        string todayNow = Utils.GetTodayNow();
                        string sql1     = string.Format("UPDATE PROJ_LOCATION_DETAIL SET LOCATIONSTATE='{1}',OPMESSAGE='{2}',OPDATE='{3}',OPBY='dcs' WHERE CONTROLID='{0}'", (object)equipmentstatusEntity.EQUIPMENTID, (object)str1, (object)str2, (object)todayNow);
                        int    num1     = dbCon.ExecuteSql(sql1);
                        string sql2     = (string)null;
                        int    num2     = 0;
                        string sql3     = (string)null;
                        int    num3     = 0;
                        int    num4     = 0;
                        if (Convert.ToInt32(obj) < 100)
                        {
                            sql2 = string.Format("UPDATE PROJ_STATIONINFO SET STATIONSTATE='{1}',OPMESSAGE='{2}',OPDATE='{3}',OPBY='dcs' WHERE CONTROLNO IN (SELECT GROUPNO FROM PROJ_LOCATION_DETAIL WHERE CONTROLID='{0}')", (object)equipmentstatusEntity.EQUIPMENTID, (object)"1", (object)str2, (object)todayNow);
                            num2 = dbCon.ExecuteSql(sql2);
                            sql3 = string.Format("UPDATE PROJ_STATIONINFO SET STATIONSTATE='{1}',OPMESSAGE='{2}',OPDATE='{3}',OPBY='dcs' WHERE CONTROLNO IN (SELECT AREANO FROM PROJ_LOCATION_DETAIL WHERE CONTROLID='{0}')", (object)equipmentstatusEntity.EQUIPMENTID, (object)"1", (object)str2, (object)todayNow);
                            num3 = dbCon.ExecuteSql(sql3);
                            if (SysParamsService.CheckPrarams("StationErrorUpdateRelate").ToLower() == "true")
                            {
                                string sql4 = string.Format("UPDATE PROJ_STATIONINFO SET ISCLOSE={1} WHERE STATIONNO IN ( SELECT RELATENO FROM PROJ_STATIONRELATE WHERE STATIONNO IN ( SELECT AREANO FROM PROJ_LOCATION_DETAIL WHERE CONTROLID='{0}'))", (object)equipmentstatusEntity.EQUIPMENTID, (object)0);
                                num4 = dbCon.ExecuteSql(sql4);
                            }
                        }
                        DCSInfService.logger.Info((object)sql2);
                        DCSInfService.logger.Info((object)sql3);
                        DCSInfService.logger.Info((object)(equipmentstatusEntity.EQUIPMENTID + ":" + num1.ToString() + "/" + num2.ToString() + "/" + num3.ToString() + " " + str2));
                        SysAlterInfoService.InsertAlterInfo("2", equipmentstatusEntity.EQUIPMENTID + "故障恢复!" + str2, "1");
                    }
                    else
                    {
                        string str1     = "error";
                        string str2     = "故障代码:" + equipmentstatusEntity.EQUIPMENTSTATUS;
                        string todayNow = Utils.GetTodayNow();
                        string sql1     = string.Format("UPDATE PROJ_LOCATION_DETAIL SET LOCATIONSTATE='{1}',OPMESSAGE='{2}',OPDATE='{3}',OPBY='dcs' WHERE CONTROLID='{0}'", (object)equipmentstatusEntity.EQUIPMENTID, (object)str1, (object)str2, (object)todayNow);
                        int    num1     = dbCon.ExecuteSql(sql1);
                        string sql2     = (string)null;
                        int    num2     = 0;
                        string sql3     = (string)null;
                        int    num3     = 0;
                        int    num4     = 0;
                        if (Convert.ToInt32(obj) < 100)
                        {
                            sql2 = string.Format("UPDATE PROJ_STATIONINFO SET STATIONSTATE='{1}',OPMESSAGE='{2}',OPDATE='{3}',OPBY='dcs' WHERE CONTROLNO IN (SELECT GROUPNO FROM PROJ_LOCATION_DETAIL WHERE CONTROLID='{0}')", (object)equipmentstatusEntity.EQUIPMENTID, (object)"0", (object)str2, (object)todayNow);
                            num2 = dbCon.ExecuteSql(sql2);
                            sql3 = string.Format("UPDATE PROJ_STATIONINFO SET STATIONSTATE='{1}',OPMESSAGE='{2}',OPDATE='{3}',OPBY='dcs' WHERE CONTROLNO IN (SELECT AREANO FROM PROJ_LOCATION_DETAIL WHERE CONTROLID='{0}')", (object)equipmentstatusEntity.EQUIPMENTID, (object)"0", (object)str2, (object)todayNow);
                            num3 = dbCon.ExecuteSql(sql3);
                            if (SysParamsService.CheckPrarams("StationErrorUpdateRelate").ToLower() == "true")
                            {
                                string sql4 = string.Format("UPDATE PROJ_STATIONINFO SET ISCLOSE={1} WHERE STATIONNO IN ( SELECT RELATENO FROM PROJ_STATIONRELATE WHERE STATIONNO IN ( SELECT AREANO FROM PROJ_LOCATION_DETAIL WHERE CONTROLID='{0}'))", (object)equipmentstatusEntity.EQUIPMENTID, (object)9);
                                num4 = dbCon.ExecuteSql(sql4);
                            }
                        }
                        DCSInfService.logger.Info((object)sql2);
                        DCSInfService.logger.Info((object)sql3);
                        DCSInfService.logger.Info((object)(equipmentstatusEntity.EQUIPMENTID + ":" + num1.ToString() + "/" + num2.ToString() + "/" + num3.ToString() + " " + str2));
                        SysAlterInfoService.InsertAlterInfo("2", equipmentstatusEntity.EQUIPMENTID + "发生故障!" + str2, "1");
                    }
                    string sql = string.Format("UPDATE INF_EQUIPMENTSTATUS SET STATUS=1,MODIFYDATE='{1}' WHERE ID='{0}'", (object)equipmentstatusEntity.ID, (object)Utils.GetDatetime());
                    dbCon.ExecuteSql(sql);
                }
                dtoResponse.IsSuccess   = true;
                dtoResponse.MessageText = "执行设备状态更新:" + equipmentstatusEntityList.Count.ToString();
                return(dtoResponse);
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                DCSInfService.logger.Error((object)ex);
                return(dtoResponse);
            }
            finally
            {
                HelperDbOperation.EndTransaction(dtoResponse.IsSuccess, ref dbCon, ref dbTrans);
            }
        }