Example #1
0
        /// <summary>
        /// 停機記錄實際停機時間=停機開始時間-停機結束時間-就餐時間
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public static int ProjectStopRecordActualTime(DBContext db, ProjectStopRecord_psrd_Info stopRecord)
        {
            if (stopRecord.psrd_dBeginTime != null && stopRecord.psrd_dEndTime != null)
            {

                #region 当前停机记录的就餐时间
                var dinnerQuery = db.CurrentSession.QueryOver<DinnerRecord_dnr_Info>().And(d => d.dsm_ppjID == stopRecord.psrd_PPJID);
                dinnerQuery.And(d => d.dsm_splID == stopRecord.psrd_SPLID);
                dinnerQuery.And(d => d.dsm_psrdID == stopRecord.psrd_RecordID);
                int dinnerTime = (int)dinnerQuery.And(d => d.dnr_DSMID != Guid.Empty).List().Sum(d => (d.dnr_dEndTime.Value - d.dnr_dBeginTime.Value).TotalSeconds);
                #endregion
                int total = (int)(stopRecord.psrd_dEndTime.Value - stopRecord.psrd_dBeginTime.Value).TotalSeconds - dinnerTime;
                return total;
            }
            return 0;
        }
Example #2
0
        public List<IModelObject> SearchRecord(ProjectStopRecord_psrd_Info searchInfo)
        {
            try
            {
                List<IModelObject> listObj = new List<IModelObject>();
                List<ProjectStopRecord_psrd_Info> listRes = this._stopRecordDA.SearchRecords(searchInfo);
                foreach (ProjectStopRecord_psrd_Info item in listRes)
                {
                    listObj.Add(item);
                }
                return listObj;
            }
            catch (Exception Ex)
            {

                throw Ex;
            }
        }
        private void dtpQuery_ValueChanged(object sender, EventArgs e)
        {
            ProjectStopRecord_psrd_Info queryInfo = new ProjectStopRecord_psrd_Info();

            queryInfo.psrd_dBeginTime = dtpQuery.Value;

            List<IModelObject> returnList = new List<IModelObject>();

            try
            {
                returnList = this._stopRecordBL.SearchRecord(queryInfo);

                lvPrinterDetails.SetDataSource(returnList);
            }
            catch (Exception Ex)
            {

                ShowErrorMessage(Ex.Message);
            }
        }
Example #4
0
        public ReturnValueInfo UpdateStopRecordReason(ProjectStopRecord_psrd_Info recordInfo)
        {
            using (DBContext uow = DBContext.Begin())
            {
                try
                {
                    ReturnValueInfo rvInfo = new ReturnValueInfo();

                    var stopReason_old = uow.CurrentSession.QueryOver<ProjectStopReason_pjsr_Info>().Where(d => d.pjsr_PSRDID == recordInfo.psrd_RecordID).List();
                    foreach (ProjectStopReason_pjsr_Info old in stopReason_old)
                    {
                        uow.CurrentSession.Delete(old);
                    }

                    if (recordInfo.StopReasonList != null)
                    {
                        int stopTime = 0;
                        foreach (ProjectStopReason_pjsr_Info pjsrItem in recordInfo.StopReasonList)
                        {
                            if (pjsrItem.pjsr_iSRMID > 0 && recordInfo.psrd_RecordID != Guid.Empty)
                            {
                                pjsrItem.pjsr_dAddDate = DateTime.Now;
                                pjsrItem.pjsr_dLastDate = DateTime.Now;
                                pjsrItem.pjsr_PPJID = recordInfo.psrd_PPJID;
                                pjsrItem.pjsr_PSRDID = recordInfo.psrd_RecordID;
                                pjsrItem.pjsr_lSync = false;
                                uow.CurrentSession.Save(pjsrItem);
                                if (!pjsrItem.StopReasonMasterInfo.srm_lIsParallelable)
                                {
                                    stopTime += pjsrItem.StopReasonMasterInfo.srm_iPredictedTime;
                                }
                            }
                        }

                        recordInfo = uow.CurrentSession.Load<ProjectStopRecord_psrd_Info>(recordInfo.psrd_RecordID);
                        recordInfo.psrd_iPredictStopTime = stopTime * 60;
                        recordInfo.psrd_lSync = false;
                        uow.CurrentSession.Update(recordInfo);
                    }

                    rvInfo.boolValue = true;
                    return rvInfo;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #5
0
        public ReturnValueInfo UpdateStopRecord(ProjectStopRecord_psrd_Info recordInfo)
        {
            using (DBContext uow = DBContext.Begin())
            {
                try
                {

                    ReturnValueInfo rvInfo = new ReturnValueInfo();

                    uow.CurrentSession.Update(recordInfo);

                    var stopReason_old = uow.CurrentSession.QueryOver<ProjectStopReason_pjsr_Info>().Where(d => d.pjsr_PSRDID == recordInfo.psrd_RecordID).List();
                    foreach (ProjectStopReason_pjsr_Info old in stopReason_old)
                    {
                        uow.CurrentSession.Delete(old);
                    }

                    if (recordInfo.StopReasonList != null)
                    {
                        foreach (ProjectStopReason_pjsr_Info pjsrItem in recordInfo.StopReasonList)
                        {
                            uow.CurrentSession.Save(pjsrItem);
                        }
                    }

                    rvInfo.boolValue = true;
                    return rvInfo;
                }
                catch (Exception ex)
                {

                    throw ex;
                }
            }
        }
Example #6
0
        public List<ProjectStopRecord_psrd_Info> SearchRecord_Sqlite(ProjectStopRecord_psrd_Info searchInfo)
        {
            throw new NotImplementedException();
            //try
            //{
            //    Dictionary<string, object> param = new Dictionary<string, object>();

            //    if (searchInfo.psrd_RecordID != Guid.Empty)
            //    {
            //        param.Add("psrd_RecordID", searchInfo.psrd_RecordID);
            //    }

            //    if (searchInfo.psrd_SPLID != Guid.Empty)
            //    {
            //        param.Add("psrd_SPLID", searchInfo.psrd_SPLID);
            //    }

            //    if (!string.IsNullOrEmpty(searchInfo.psrd_cTypeID))
            //    {
            //        param.Add("psrd_cTypeID", searchInfo.psrd_cTypeID);
            //    }

            //    IList<ProjectStopRecord_psrd_Info> listRecord = this._IProjectStopRecordDA_Sqlite.GetEntities<ProjectStopRecord_psrd_Info>(param);
            //    listRecord = listRecord.OrderByDescending(d => d.psrd_dBeginTime).ToList();
            //    if (listRecord.Count > 0)
            //    {
            //        Guid ppjID = listRecord[0].psrd_PPJID;
            //        Dictionary<string, object> paramProblem = new Dictionary<string, object>();
            //        paramProblem.Add("pjsr_PPJID", ppjID);
            //        IList<ProjectStopReason_pjsr_Info> listReason = this._IProjectStopRecordDA_Sqlite.GetEntities<ProjectStopReason_pjsr_Info>(paramProblem);
            //        foreach (ProjectStopRecord_psrd_Info psrd in listRecord)
            //        {
            //            psrd.StopReasonList = new Iesi.Collections.Generic.HashedSet<ProjectStopReason_pjsr_Info>();
            //            psrd.StopReasonList.AddAll(listReason.Where(d => d.pjsr_PSRDID == psrd.psrd_RecordID).ToList());
            //        }

            //    }

            //    return listRecord.ToList();
            //}
            //catch (Exception ex)
            //{

            //    throw ex;
            //}
        }
Example #7
0
 public ProjectStopRecord_psrd_Info SearchRecord_Sqlite(Guid iRecordID)
 {
     try
     {
         ProjectStopRecord_psrd_Info searchInfo = new ProjectStopRecord_psrd_Info();
         searchInfo.psrd_RecordID = iRecordID;
         List<ProjectStopRecord_psrd_Info> listRecord = SearchRecord_Sqlite(searchInfo);
         ProjectStopRecord_psrd_Info psrdInfo = new ProjectStopRecord_psrd_Info();
         if (listRecord != null)
         {
             psrdInfo = listRecord.FirstOrDefault();
         }
         else
         {
             psrdInfo = null;
         }
         return psrdInfo;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
        public List<ProjectStopRecord_psrd_Info> SearchRecord(ProjectStopRecord_psrd_Info searchInfo)
        {
            List<ProjectStopRecord_psrd_Info> returnList = null;

            try
            {
                if (searchInfo != null)
                {
                    //returnList = this._projectStopRecordDA.FindEntities<ProjectStopRecord_psrd_Info>(searchInfo).ToList();
                }
            }
            catch (Exception Ex)
            {

                throw Ex;
            }

            return returnList;
        }
Example #9
0
        public ReturnValueInfo InsertRecord_Sqlite(ProjectStopRecord_psrd_Info recordInfo)
        {
            using (DBContext uow = DBContext.Begin())
            {
                try
                {

                    ReturnValueInfo rvInfo = new ReturnValueInfo();

                    object objRecord = uow.CurrentSession.Save(recordInfo);

                    if (recordInfo.StopReasonList != null)
                    {
                        foreach (ProjectStopReason_pjsr_Info pjsrItem in recordInfo.StopReasonList)
                        {

                            object objSubRecord = uow.CurrentSession.Save(pjsrItem);
                        }
                    }

                    //if (recordInfo.StopReasonList != null)
                    //{
                    //    int stopTime = 0;
                    //    foreach (ProjectStopReason_pjsr_Info pjsrItem in recordInfo.StopReasonList)
                    //    {
                    //        if (pjsrItem.pjsr_iSRMID > 0 && recordInfo.psrd_RecordID != Guid.Empty)
                    //        {
                    //            pjsrItem.pjsr_dAddDate = DateTime.Now;
                    //            pjsrItem.pjsr_dLastDate = DateTime.Now;
                    //            pjsrItem.pjsr_PPJID = recordInfo.psrd_PPJID;
                    //            pjsrItem.pjsr_PSRDID = recordInfo.psrd_RecordID;
                    //            pjsrItem.pjsr_lSync = false;
                    //            uow.CurrentSession.Save(pjsrItem);
                    //            if (!pjsrItem.StopReasonMasterInfo.srm_lIsParallelable)
                    //            {
                    //                stopTime += pjsrItem.StopReasonMasterInfo.srm_iPredictedTime;
                    //            }
                    //        }
                    //    }

                    //    recordInfo = uow.CurrentSession.Load<ProjectStopRecord_psrd_Info>(recordInfo.psrd_RecordID);
                    //    recordInfo.psrd_iPredictStopTime = stopTime * 60;
                    //    recordInfo.psrd_lSync = false;
                    //    uow.CurrentSession.Update(recordInfo);
                    //}

                    rvInfo.boolValue = true;
                    return rvInfo;
                }
                catch (Exception ex)
                {

                    throw ex;
                }
            }
        }
Example #10
0
        /// <summary>
        /// 獲得符合日期的班次內工程信息 by SIMON
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        private List<ComboboxDataInfo> GetShirtProjList(ProjectStopRecord_psrd_Info query)
        {
            List<ComboboxDataInfo> infoList = new List<ComboboxDataInfo>();

            if (query != null)
            {
                string strSQL = string.Empty;
                strSQL += "select Convert(nvarchar(max), spl_RecordID) as ValueMember,swl_cItemName as DisplayMember" + Environment.NewLine;
                strSQL += "from dbo.ShiftProjList_spl" + Environment.NewLine;
                strSQL += "left join dbo.PrintProject_ppj" + Environment.NewLine;
                strSQL += "on spl_PPJID=ppj_RecordID" + Environment.NewLine;
                strSQL += "left join dbo.ScheduleProjList_swl" + Environment.NewLine;
                strSQL += "on ppj_SWLID=swl_RecordID" + Environment.NewLine;
                strSQL += "where" + Environment.NewLine;
                strSQL += "((spl_dBeginTime<='" + query.psrd_dBeginTime.Value.ToString("yyyy-MM-dd HH:mm") + "' and spl_dEndTime >='" + query.psrd_dBeginTime.Value.ToString("yyyy-MM-dd HH:mm") + "' )" + Environment.NewLine;
                strSQL += "or" + Environment.NewLine;
                strSQL += "(spl_dBeginTime<='" + query.psrd_dEndTime.Value.ToString("yyyy-MM-dd HH:mm") + "' and spl_dEndTime >='" + query.psrd_dEndTime.Value.ToString("yyyy-MM-dd HH:mm") + "' ))" + Environment.NewLine;

                IEnumerable<ComboboxDataInfo> infos = null;
                try
                {
                    using (MainDBDataContext db = new MainDBDataContext())
                    {
                        infos = db.ExecuteQuery<ComboboxDataInfo>(strSQL, new object[] { });
                        if (infos != null)
                        {
                            foreach (ComboboxDataInfo item in infos)
                            {
                                infoList.Add(item);
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }

            return infoList;
        }
Example #11
0
        /// <summary>
        /// 生產中停機超時
        /// </summary>
        /// <param name="uow"></param>
        /// <param name="schProj"></param>
        /// <param name="printProj"></param>
        /// <param name="shiftProject"></param>
        /// <param name="stopRecord"></param>
        /// <returns></returns>
        public bool ProduceStop2Long(DBContext uow, ScheduleProjList_swl_Info schProj, PrintProject_ppj_Info printProj, ShiftProjList_spl_Info shiftProject, ProjectStopRecord_psrd_Info stopRecord)
        {
            try
            {
                int actualStopTime = (int)(DateTime.Now - stopRecord.psrd_dBeginTime.Value).TotalSeconds;
                if (actualStopTime > stopRecord.psrd_iPredictStopTime)
                {
                    #region 更新印刷工程信息
                    schProj.swl_iIsByModify = true;
                    schProj.swl_cProjStatus = CustEnum.ProjectStatus.PROD_STOP_OT.ToString();
                    schProj.swl_dStatusChange = DateTime.Now;
                    schProj.swl_dLastDate = DateTime.Now;
                    uow.CurrentSession.Update(uow.CurrentSession.Merge(schProj));
                    #endregion
                }

                return true;
            }
            catch (Exception ex)
            {
                uow.CanCommit = false;
                mLog.Error("PLCBL.ProduceStop2Long" + ex);
                return false;
            }
        }
Example #12
0
        /// <summary>
        /// 生產中停機
        /// </summary>
        /// <param name="uow"></param>
        /// <param name="schProj"></param>
        /// <param name="printProj"></param>
        /// <param name="shiftProject"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool ProduceStop(DBContext uow, ScheduleProjList_swl_Info schProj, PrintProject_ppj_Info printProj, ShiftProjList_spl_Info shiftProject, PLCData_pda_Info data)
        {
            try
            {
                #region 停機記錄
                ProjectStopRecord_psrd_Info psrd = new ProjectStopRecord_psrd_Info();
                psrd.psrd_RecordID = Guid.NewGuid();
                psrd.psrd_PPJID = shiftProject.spl_PPJID;
                psrd.psrd_SPLID = shiftProject.spl_RecordID;
                psrd.psrd_dBeginTime = schProj.PROD_STOP_Datetime;
                psrd.psrd_dAddDate = DateTime.Now;
                psrd.psrd_dLastDate = DateTime.Now;
                psrd.psrd_cTypeID = CustEnum.RecordType.NORMAL.ToString();
                psrd.psrd_iPredictStopTime = 0;
                psrd.psrd_lSync = false;
                uow.CurrentSession.Save(psrd);
                #endregion

                #region 更新印刷工程信息
                schProj.swl_cProjStatus = CustEnum.ProjectStatus.PROD_STOP.ToString();
                schProj.swl_dStatusChange = DateTime.Now;
                schProj.swl_dLastDate = DateTime.Now;
                schProj.swl_iIsByModify = true;
                uow.CurrentSession.Update(schProj);
                #endregion

                #region 生产工程
                printProj.ppj_fMachineSpeed = data.pda_iMachineSpeed;
                printProj.ppj_iStopTimes += 1;
                uow.CurrentSession.Update(printProj);
                #endregion

                #region 班次內工程
                shiftProject.spl_iStopTimes += 1;
                uow.CurrentSession.Update(shiftProject);
                #endregion

                #region 用餐記錄
                //工程在生產中進入就餐,但由於工程進入生產中停機狀態有一定時間的約定延遲,如果超過這個時間,進入停機狀態,需要更新就餐時工程的狀態
                var dinnerQuery = uow.CurrentSession.QueryOver<DinnerRecord_dnr_Info>().And(d => d.dsm_swlID == schProj.swl_RecordID);
                dinnerQuery.And(d => d.dsm_ppjID == printProj.ppj_RecordID);
                dinnerQuery.And(d => d.dsm_splID == shiftProject.spl_RecordID);
                dinnerQuery.And(d => d.dsm_cProjectStatus == CustEnum.ProjectStatus.PROD_IN.ToString());
                dinnerQuery = dinnerQuery.OrderBy(d => d.dnr_dBeginTime).Desc;

                var listDinner = dinnerQuery.And(d => d.dnr_DSMID != null).List();
                if (listDinner.Count > 0)
                {
                    DinnerRecord_dnr_Info dnr = listDinner[0];
                    if (dnr.dnr_dBeginTime >= psrd.psrd_dBeginTime)//用餐開始時間在停機開始時間之後,因此需要將用餐記錄的工程狀態更新為“PROD_STOP”,並更新停機記錄ID
                    {
                        dnr.dsm_cProjectStatus = CustEnum.ProjectStatus.PROD_STOP.ToString();
                        dnr.dsm_psrdID = psrd.psrd_RecordID;
                        dnr.dnr_dLastDate = DateTime.Now;
                        uow.CurrentSession.Update(dnr);
                    }

                }
                #endregion

                return true;
            }
            catch (Exception ex)
            {
                uow.CanCommit = false;
                mLog.Error("PLCBL.ProduceStop" + ex);
                return false;
            }
        }
Example #13
0
        /// <summary>
        /// 獲得符合日期的班次內工程信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        private List<ComboboxDataInfo> GetShirtProjList(ProjectStopRecord_psrd_Info rrecordInfo)
        {
            List<ComboboxDataInfo> infoList = new List<ComboboxDataInfo>();
            try
            {
                using (DBContext uow = new DBContext())
                {
                    string strSQL = string.Empty;
                    strSQL += "select spl_RecordID as ValueMember,swl_cItemName as DisplayMember" + Environment.NewLine;
                    strSQL += "from ShiftProjList_spl" + Environment.NewLine;
                    strSQL += "left join PrintProject_ppj" + Environment.NewLine;
                    strSQL += "on spl_PPJID=ppj_RecordID" + Environment.NewLine;
                    strSQL += "left join ScheduleProjList_swl" + Environment.NewLine;
                    strSQL += "on ppj_SWLID=swl_RecordID" + Environment.NewLine;
                    strSQL += "where" + Environment.NewLine;
                    strSQL += "((spl_dBeginTime<='" + rrecordInfo.psrd_dBeginTime.Value.ToString("yyyy-MM-dd HH:mm") + "' and spl_dEndTime >='" + rrecordInfo.psrd_dBeginTime.Value.ToString("yyyy-MM-dd HH:mm") + "' )" + Environment.NewLine;
                    strSQL += "or" + Environment.NewLine;
                    strSQL += "(spl_dBeginTime<='" + rrecordInfo.psrd_dEndTime.Value.ToString("yyyy-MM-dd HH:mm") + "' and spl_dEndTime >='" + rrecordInfo.psrd_dEndTime.Value.ToString("yyyy-MM-dd HH:mm") + "' ))" + Environment.NewLine;

                    ISQLQuery query = uow.CurrentSession.CreateSQLQuery(strSQL.ToString());

                    var s = query.List();
                    if (s != null)
                    {
                        foreach (object[] objItem in s)
                        {
                            ComboboxDataInfo info = new ComboboxDataInfo();

                            info.DisplayMember = objItem[1].ToString();

                            info.ValueMember = objItem[0].ToString();

                            infoList.Add(info);
                        }
                    }
                }
            }
            catch (Exception Ex)
            {

                throw Ex;
            }

            return infoList;
        }