Esempio n. 1
0
        /// <summary>
        /// 增加某日班次信息
        /// </summary>
        /// <param name="machineNO"></param>
        /// <param name="date"></param>
        private void AddShiftInfo(string machineNO, DateTime date, DBContext trans)
        {
            try
            {

                IList<ShiftTypeMaster_stm_Info> types = trans.CurrentSession.QueryOver<ShiftTypeMaster_stm_Info>().And(d => d.stm_lIsAtive == true).List();

                foreach (var type in types)
                {
                    var criteria = trans.CurrentSession.QueryOver<ShiftInfo_sifo_Info>();
                    criteria.And(d => d.sifo_dProdDate == date.Date);
                    criteria.And(d => d.sifo_cMachineNO == machineNO);
                    criteria.And(d => d.sifo_iSTMID == type.stm_iRecordID);
                    var existShift = criteria.List<ShiftInfo_sifo_Info>();
                    if (existShift.Count == 0)
                    {

                        #region 班次信息
                        ShiftInfo_sifo_Info shift = new ShiftInfo_sifo_Info();
                        shift.sifo_RecordID = Guid.NewGuid();
                        shift.sifo_iSTMID = type.stm_iRecordID;
                        shift.sifo_lSync = false;
                        shift.sifo_lOvertime = false;
                        shift.sifo_cType = string.Empty;
                        shift.sifo_dProdDate = date.Date;
                        shift.sifo_cMachineNO = machineNO;
                        shift.sifo_dBeginTime = Common.Util.DateUtil.Convert(date.Date, type.stm_cBeginTime);
                        shift.sifo_dEndTime = Common.Util.DateUtil.Convert(date.Date, type.stm_cEndTime);

                        if (shift.sifo_dEndTime <= shift.sifo_dBeginTime)
                        {
                            shift.sifo_dEndTime = shift.sifo_dEndTime.Value.AddDays(1);
                        }

                        shift.sifo_dAddDate = DateTime.Now;
                        trans.CurrentSession.Save(shift);
                        #endregion

                    }
                    else
                    {
                        //Common.General.BLLoger.Debug("ShiftBL.AddPerDayShift_PPC 班次已經存在,不再創建");
                    }

                }

            }
            catch (Exception ex)
            {
                Common.General.BLLoger.Error("ShiftBL.AddShiftInfo 安排日期:" + date.ToString(Common.DefineConstantValue.gc_DateFormat) + "的班次時出現異常:", ex);
            }
        }
Esempio n. 2
0
 private ShiftInfo_sifo_Info GetNextShiftInfo(ShiftInfo_sifo_Info shift)
 {
     ShiftInfo_sifo_Info nextShift = null;
     using (DBContext trans = new DBContext())
     {
         var query = trans.CurrentSession.QueryOver<ShiftInfo_sifo_Info>();
         query.And(d => d.sifo_dBeginTime.Value >= shift.sifo_dEndTime);
         query.OrderBy(d => d.sifo_dBeginTime);
         nextShift = query.Take(1).SingleOrDefault();
     }
     return nextShift;
 }
Esempio n. 3
0
        public ShiftProjList_spl_Info SetCurrentShiftProj(PrintProject_ppj_Info project, ShiftInfo_sifo_Info shiftInfo)
        {
            ShiftProjList_spl_Info spl = null;
            try
            {
                if (project != null && project.ppj_RecordID != Guid.Empty)
                {
                    using (DBContext uow = DBContext.Begin())
                    {

                        if (shiftInfo != null && shiftInfo.sifo_RecordID != Guid.Empty)
                        {
                            spl = new ShiftProjList_spl_Info();
                            spl.spl_RecordID = Guid.NewGuid();
                            spl.spl_SIFOID = shiftInfo.sifo_RecordID;
                            spl.spl_PPJID = project.ppj_RecordID;
                            spl.spl_dBeginTime = DateTime.Now;
                            spl.spl_dAddDate = DateTime.Now;
                            spl.spl_iBeginQTY = project.ppj_iCountProdNum;
                            uow.CurrentSession.Save(spl);
                        }

                    }

                }
            }
            catch (Exception ex)
            {
                spl = null;
                Common.General.BLLoger.Info(ex);
            }
            return spl;
        }
Esempio n. 4
0
 public void UpdateShiftInfo_PPC(ShiftInfo_sifo_Info shiftInfo)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
        //public bool ChangetShift(string machineID, ref ShiftProjList_spl_Info shiftProject)
        //{
        //    try
        //    {
        //        mLog.Debug("執行轉班邏輯");
        //        ShiftProjList_spl_Info newSpl = null;
        //        ShiftProjList_spl_Info oldSpl = shiftProject;
        //        using (Transaction uow = Transaction.Begin())
        //        {
        //            mLog.Debug("更新班次內工程 ShiftProjList_spl_Info");
        //            oldSpl.spl_dLastDate = DateTime.Now;
        //            oldSpl.spl_dEndTime = oldSpl.ShiftInfo.sifo_dEndTime;
        //            oldSpl.spl_lSync = false;
        //            uow.CurrentSession.Update(oldSpl);
        //            #region
        //            ShiftInfo_sifo_Info nextShift = null;
        //            var query = uow.CurrentSession.QueryOver<ShiftInfo_sifo_Info>();
        //            query.And(d => d.sifo_dBeginTime >= DateTime.Now);
        //            query.And(d => d.sifo_cMachineNO == machineID).OrderBy(d => d.sifo_dBeginTime);
        //            IList<ShiftInfo_sifo_Info> list = query.List<ShiftInfo_sifo_Info>();
        //            if (list.Count > 0)
        //            {
        //                nextShift = list[0];
        //            }
        //            else
        //            {
        //                //todo:creat new shift
        //            }
        //            mLog.Debug("創建新的班次內工程 ShiftProjList_spl_Info");
        //            newSpl = new ShiftProjList_spl_Info();
        //            newSpl.spl_RecordID = Guid.NewGuid();
        //            newSpl.spl_SIFOID = nextShift.sifo_RecordID;
        //            newSpl.spl_PPJID = oldSpl.spl_PPJID;
        //            newSpl.spl_dBeginTime = nextShift.sifo_dBeginTime.Value;
        //            newSpl.spl_dProdBegin = nextShift.sifo_dBeginTime.Value;
        //            newSpl.spl_dAddDate = DateTime.Now;
        //            newSpl.spl_iBeginQTY = oldSpl.PrintProject.ppj_iCountProdNum;
        //            newSpl.spl_iBeginQTY = shiftProject.spl_iEndQTY;
        //            uow.CurrentSession.Save(newSpl);
        //            uow.CurrentSession.Flush();
        //            newSpl.PrintProject = oldSpl.PrintProject;
        //            newSpl.ShiftInfo = nextShift;
        //            shiftProject = newSpl;
        //            #endregion
        //            #region 結束工程停機記錄
        //            ProjectStopRecord_psrd_Info psrd = uow.CurrentSession.QueryOver<ProjectStopRecord_psrd_Info>().And(d => d.psrd_SPLID == oldSpl.spl_RecordID).And(d => d.psrd_dEndTime == null).Take(1).SingleOrDefault();
        //            if (psrd != null)
        //            {
        //                psrd.psrd_dEndTime = oldSpl.ShiftInfo.sifo_dEndTime;
        //                psrd.psrd_dLastDate = DateTime.Now;
        //                psrd.psrd_lSync = false;
        //                uow.CurrentSession.Update(psrd);
        //                mLog.Debug("創建跨班次停機記錄 ProjectStopRecord_psrd_Info");
        //                ProjectStopRecord_psrd_Info nextPsrd = new ProjectStopRecord_psrd_Info();
        //                nextPsrd.psrd_RecordID = Guid.NewGuid();
        //                nextPsrd.psrd_dBeginTime = nextShift.sifo_dBeginTime.Value;
        //                nextPsrd.psrd_dAddDate = DateTime.Now;
        //                nextPsrd.psrd_PPJID = newSpl.spl_PPJID;
        //                nextPsrd.psrd_SPLID = newSpl.spl_RecordID;
        //                nextPsrd.psrd_cTypeID = CustEnum.RecordType.NORMAL.ToString();
        //                uow.CurrentSession.Save(nextPsrd);
        //            }
        //            #endregion
        //            #region 結束幾臺空閒狀態
        //            SpareStatus_ssts_Info ssts = uow.CurrentSession.QueryOver<SpareStatus_ssts_Info>().And(d => d.sst_cMachineNO == machineID)
        //        .And(d => d.sst_iSIFOID == oldSpl.spl_SIFOID).And(d => d.sst_dEndTime == null).Take(1).SingleOrDefault();
        //            if (ssts != null)
        //            {
        //                ssts.sst_dEndTime = oldSpl.ShiftInfo.sifo_dEndTime;
        //                ssts.sst_dLastDate = DateTime.Now;
        //                ssts.sst_lSync = false;
        //                uow.CurrentSession.Update(ssts);
        //                mLog.Debug("創建跨班次空閒記錄 SpareStatus_ssts_Info");
        //                SpareStatus_ssts_Info nextSsts = new SpareStatus_ssts_Info();
        //                nextSsts.sst_cMachineNO = machineID;
        //                nextSsts.sst_dBeginTime = nextShift.sifo_dBeginTime.Value;
        //                nextSsts.sst_iSIFOID = nextShift.sifo_RecordID;
        //                nextSsts.sst_dAddDate = DateTime.Now;
        //                uow.CurrentSession.Save(nextSsts);
        //            }
        //            #endregion
        //        }
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        mLog.Error(ex);
        //    }
        //    return false;
        //}
        public bool ChangeShift(string machineID, ShiftInfo_sifo_Info currentShift, ShiftInfo_sifo_Info nextShift, ScheduleProjList_swl_Info scheduleProject, PrintProject_ppj_Info printProject, ShiftProjList_spl_Info shiftProject)
        {
            mLog.Info("班次轉換新邏輯");

            try
            {
                if (currentShift == null)
                {
                    throw new Exception("當前班次對象不能為空");
                }
                if (nextShift == null)
                {
                    throw new Exception("下一班次對象不能為空");
                }
                using (DBContext uow = DBContext.Begin())
                {
                    try
                    {

                        if (printProject != null && shiftProject != null && shiftProject.spl_RecordID != Guid.Empty)
                        {
                            PrintProject_ppj_Info currentProject = printProject;
                            ShiftProjList_spl_Info currentShiftProject = shiftProject;

                            #region 更新班次內工程
                            mLog.Debug("更新班次內工程 ShiftProjList_spl_Info");
                            currentShiftProject.spl_dLastDate = DateTime.Now;
                            currentShiftProject.spl_dEndTime = currentShift.sifo_dEndTime;
                            currentShiftProject.spl_lSync = false;

                            //就餐時間
                            #region 準備時間計算

                            if (currentShiftProject.spl_dProdBegin.HasValue)//沒有結束準備
                            {
                                currentShiftProject.spl_iPrepairTime = TimeCalculater.ShiftProjectActualPrepairTime(uow, currentShiftProject);
                                currentProject.ppj_iActualPrepairTime += currentShiftProject.spl_iPrepairTime;
                            }

                            #endregion

                            #region  正常生產時間
                            currentShiftProject.spl_iProdSumTime = TimeCalculater.ShiftProjectProdTime(uow, currentShiftProject);
                            #endregion

                            uow.CurrentSession.Update(currentShiftProject);

                            #endregion

                            #region 創建新的班次內工程

                            mLog.Debug("創建新的班次內工程 ShiftProjList_spl_Info");
                            ShiftProjList_spl_Info newSpl = new ShiftProjList_spl_Info();
                            newSpl.spl_RecordID = Guid.NewGuid();
                            newSpl.spl_SIFOID = nextShift.sifo_RecordID;
                            newSpl.spl_PPJID = currentShiftProject.spl_PPJID;
                            newSpl.spl_dBeginTime = nextShift.sifo_dBeginTime.Value;
                            newSpl.spl_dAddDate = DateTime.Now;
                            newSpl.spl_iBeginQTY = currentShiftProject.spl_iEndQTY;
                            newSpl.spl_iEndQTY = currentShiftProject.spl_iEndQTY;
                            if (currentShiftProject.spl_dProdBegin != null)
                            {
                                newSpl.spl_dProdBegin = nextShift.sifo_dBeginTime.Value;
                            }
                            else
                            {
                                newSpl.spl_dProdBegin = null;
                            }

                            uow.CurrentSession.Save(newSpl);

                            #endregion

                            #region 結束工程停機記錄

                            ProjectStopRecord_psrd_Info psrd = uow.CurrentSession.QueryOver<ProjectStopRecord_psrd_Info>()
                                .And(d => d.psrd_SPLID == currentShiftProject.spl_RecordID)
                                .And(d => d.psrd_dEndTime == null).Take(1).SingleOrDefault();

                            if (psrd != null)
                            {
                                psrd.psrd_dEndTime = currentShift.sifo_dEndTime;
                                psrd.psrd_dLastDate = DateTime.Now;
                                psrd.psrd_lSync = false;
                                psrd.psrd_iActualStopTime = TimeCalculater.ProjectStopRecordActualTime(uow, psrd);
                                uow.CurrentSession.Update(psrd);

                                mLog.Debug("更新跨更的班次內工程的停機時間");
                                currentShiftProject.spl_iStopTime += psrd.psrd_iActualStopTime;

                                uow.CurrentSession.Update(currentShiftProject);

                                currentProject.ppj_iStopTime += psrd.psrd_iActualStopTime;
                                currentProject.ppj_iStopTimes++;
                                uow.CurrentSession.Update(currentProject);

                                //mLog.Debug("創建跨班次停機記錄 ProjectStopRecord_psrd_Info");
                                //ProjectStopRecord_psrd_Info nextPsrd = new ProjectStopRecord_psrd_Info();
                                //nextPsrd.psrd_RecordID = Guid.NewGuid();
                                //nextPsrd.psrd_dBeginTime = nextShift.sifo_dBeginTime.Value;
                                //nextPsrd.psrd_dAddDate = DateTime.Now;
                                //nextPsrd.psrd_PPJID = newSpl.spl_PPJID;
                                //nextPsrd.psrd_SPLID = newSpl.spl_RecordID;
                                //nextPsrd.psrd_cTypeID = CustEnum.RecordType.NORMAL.ToString();
                                //uow.CurrentSession.Save(nextPsrd);

                                //newSpl.spl_iStopTimes++;
                                //uow.CurrentSession.Update(newSpl);

                            }

                            #endregion
                        }

                        #region 結束機台空閒狀態

                        SpareStatus_sst_Info ssts = uow.CurrentSession.QueryOver<SpareStatus_sst_Info>().And(d => d.sst_cMachineNO == machineID)
                    .And(d => d.sst_iSIFOID == currentShift.sifo_RecordID).And(d => d.sst_dEndTime == null).Take(1).SingleOrDefault();
                        if (ssts != null)
                        {
                            IdleState_ism_Info ism = null;
                            if (ssts.sst_StatusID == Guid.Empty)
                            {
                                ism = uow.CurrentSession.QueryOver<IdleState_ism_Info>().And(d => d.ism_lIsBuildin && d.ism_lIsAtive).Take(1).SingleOrDefault();
                                if (ism != null)
                                {

                                    ssts.sst_cStatusName = ism.ism_cStateName;
                                    ssts.sst_StatusID = ism.ism_RecordID;
                                }
                            }
                            ssts.sst_dEndTime = currentShift.sifo_dEndTime;
                            ssts.sst_dLastDate = DateTime.Now;
                            ssts.sst_lSync = false;
                            uow.CurrentSession.Update(ssts);

                            mLog.Debug("創建跨班次空閒記錄 SpareStatus_ssts_Info");
                            SpareStatus_sst_Info nextSsts = new SpareStatus_sst_Info();
                            nextSsts.sst_RecordID = Guid.NewGuid();
                            nextSsts.sst_cMachineNO = machineID;
                            nextSsts.sst_dBeginTime = nextShift.sifo_dBeginTime.Value;
                            nextSsts.sst_iSIFOID = nextShift.sifo_RecordID;
                            nextSsts.sst_dAddDate = DateTime.Now;

                            if (ism != null)
                            {
                                nextSsts.sst_cStatusName = ism.ism_cStateName;
                                nextSsts.sst_StatusID = ism.ism_RecordID;
                            }

                            uow.CurrentSession.Save(nextSsts);

                        }

                        #endregion

                    }
                    catch (Exception)
                    {
                        uow.CanCommit = false;
                        throw;
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                string message = "班次轉換新邏輯,machineID=" + machineID + "\r\n";
                message += "PrintProject_ppj_Info=" + Common.Util.JsonUtil.JsonSerializer<PrintProject_ppj_Info>(printProject) + "\r\n";
                message += "ShiftProjList_spl_Info=" + Common.Util.JsonUtil.JsonSerializer<ShiftProjList_spl_Info>(shiftProject) + "\r\n";
                Common.Util.MessageUtil.SendDevMail(message, ex);
                mLog.Error(ex);
                return false;
                // throw;
            }
        }
Esempio n. 6
0
        public ShiftInfo_sifo_Info GetNextShift(ShiftInfo_sifo_Info shift)
        {
            ShiftInfo_sifo_Info nextShift = null;
            try
            {
                nextShift = GetNextShiftInfo(shift);
                if (nextShift == null)
                {
                    AddPerDayShift_PPC(shift.sifo_cMachineNO);
                    nextShift = GetNextShiftInfo(shift);
                }

            }
            catch (Exception ex)
            {
                Common.General.BLLoger.Error(ex);
            }

            return nextShift;
        }
Esempio n. 7
0
        public ReturnValueInfo RestartProject(ScheduleProjList_swl_Info schProject, ref PrintProject_ppj_Info project, ShiftInfo_sifo_Info shift)
        {
            ReturnValueInfo result = new ReturnValueInfo();
            try
            {

                using (DBContext uow = DBContext.Begin())
                {

                    try
                    {
                        //工程状态轉化為準備中
                        schProject.swl_cProjStatus = CustEnum.ProjectStatus.PREPARE.ToString();
                        schProject.swl_lSync = false;
                        uow.CurrentSession.Update(schProject);

                        #region 重新創建一條印刷工程擴展信息記錄
                        PrintProject_ppj_Info ppj_restart = new PrintProject_ppj_Info();
                        ppj_restart.ppj_RecordID = Guid.NewGuid();
                        ppj_restart.ppj_SWLID = schProject.swl_RecordID;
                        ppj_restart.ppj_lActiveRecord = true;
                        ppj_restart.ppj_lSync = false;
                        ppj_restart.ppj_dAddDate = DateTime.Now;
                        ppj_restart.ppj_dProjBeginTime = DateTime.Now;
                        ppj_restart.ppj_cRank = "";

                        ppj_restart.ppj_iSpeed = project.ppj_iSpeed;
                        ppj_restart.ppj_iQCInterval = project.ppj_iQCInterval;
                        ppj_restart.ppj_iPertimeProdNum = project.ppj_iPertimeProdNum;

                        ppj_restart.ppj_lActiveRecord = true;

                        #region 工程附件信息
                        ProjectAdditionalInformation_pai_Info paiInfo = new ProjectAdditionalInformation_pai_Info();
                        paiInfo.pai_PPJRecordID = ppj_restart.ppj_RecordID;
                        paiInfo.pai_iFrontProcessDefectiveQty = 0;
                        paiInfo.pai_iFrontProcessWasteQty = 0;
                        paiInfo.pai_iGoldPaperTimes = 0;
                        paiInfo.pai_iRevolution = 0;
                        paiInfo.pai_iTemperature = 0;
                        paiInfo.pai_cUnit = string.Empty;
                        paiInfo.pai_iUnitLength = 0;
                        paiInfo.pai_iUVLuminosity = 0;
                        paiInfo.pai_iUnitWidth = 0;
                        uow.CurrentSession.Save(paiInfo);
                        ppj_restart.AdditionalInformation = paiInfo;
                        #endregion

                        #region 准备工作项目

                        var query = uow.CurrentSession.QueryOver<ProjectPreJobItem_ppji_Info>();
                        Guid ppjId = project.ppj_RecordID;
                        query.And(d => d.ppji_PPJID == ppjId);
                        IList<ProjectPreJobItem_ppji_Info> ppjis = query.List<ProjectPreJobItem_ppji_Info>();
                        ppj_restart.PrepareJobItems = ppjis;
                        foreach (ProjectPreJobItem_ppji_Info item in ppjis)
                        {
                            item.ppji_PPJID = ppj_restart.ppj_RecordID;
                            uow.CurrentSession.Save(item);
                        }
                        #endregion

                        uow.CurrentSession.Save(ppj_restart);

                        #endregion

                        #region 創建新的班次內工程信息
                        ShiftProjList_spl_Info shiftProject = new ShiftProjList_spl_Info();
                        shiftProject.spl_RecordID = Guid.NewGuid();
                        shiftProject.spl_dBeginTime = DateTime.Now;
                        shiftProject.spl_dAddDate = DateTime.Now;
                        shiftProject.spl_SIFOID = shift.sifo_RecordID;
                        shiftProject.spl_PPJID = ppj_restart.ppj_RecordID;
                        uow.CurrentSession.Save(shiftProject);
                        #endregion

                        #region 班次空閒狀態結束
                        SpareStatus_sst_Info info = uow.CurrentSession.QueryOver<SpareStatus_sst_Info>().And(d => d.sst_iSIFOID == shift.sifo_RecordID).And(d => d.sst_dEndTime == null).Take(1).SingleOrDefault();
                        if (info != null)
                        {
                            info.sst_dEndTime = DateTime.Now;
                            info.sst_dLastDate = DateTime.Now;
                            uow.CurrentSession.Update(info);

                        }
                        #endregion

                        if (ppj_restart.ShiftProjects == null)
                        {
                            ppj_restart.ShiftProjects = new List<ShiftProjList_spl_Info>();
                        }
                        ppj_restart.ShiftProjects.Add(shiftProject);
                        project = ppj_restart;
                    }
                    catch
                    {
                        uow.CanCommit = false;
                        throw;
                    }

                }

                result.boolValue = true;

            }
            catch (Exception ex)
            {
                result.boolValue = false;
                result.messageText = Resource.B0026 + ":" + ex.Message;
                Common.General.BLLoger.Error(result.messageText);
            }
            return result;
        }
Esempio n. 8
0
        public ReturnValueInfo CreateProdutionProject(ShiftInfo_sifo_Info shift, ScheduleProjList_swl_Info swl)
        {
            ReturnValueInfo result = new ReturnValueInfo();

            try
            {
                using (DBContext uow = DBContext.Begin())
                {

                    try
                    {

                        swl.swl_cProjStatus = CustEnum.ProjectStatus.PREPARE.ToString();

                        #region 生成印刷工程數據

                        PrintProject_ppj_Info ppj = new PrintProject_ppj_Info();
                        ppj.ppj_RecordID = Guid.NewGuid();
                        ppj.ppj_SWLID = swl.swl_RecordID;
                        //工程狀態轉換為準備中,設置工程開始時間為當前時間
                        ppj.ppj_dProjBeginTime = DateTime.Now;

                        ppj.ppj_dLastDate = ppj.ppj_dAddDate = DateTime.Now;
                        ppj.ppj_lActiveRecord = true;
                        ppj.ppj_lSync = false;
                        ppj.ppj_cRank = "";

                        #region 設置默認值

                        IList<CodeMaster_cmt_Info> cmts = uow.CurrentSession.QueryOver<CodeMaster_cmt_Info>().Where(d => d.cmt_cKey1 == CustEnum.KEY1.TYPEVALUE.ToString() && d.cmt_cKey2 == CustEnum.KEY2.DEFAULT.ToString() && d.cmt_cValue == CustEnum.DEFALUT.PERTIMEQTY.ToString()).List<CodeMaster_cmt_Info>();
                        if (cmts.Count == 1)
                        {
                            ppj.ppj_iPertimeProdNum = (int)cmts[0].cmt_fNumber;
                        }

                        //cmts = uow.CurrentSession.QueryOver<CodeMaster_cmt_Info>().Where(d => d.cmt_cKey1 == CustEnum.KEY1.TYPEVALUE.ToString() && d.cmt_cKey2 == CustEnum.KEY2.DEFAULT.ToString() && d.cmt_cValue == CustEnum.DEFALUT.PRODUTIONSPEED.ToString()).List<CodeMaster_cmt_Info>();
                        //if (cmts.Count == 1)
                        //{
                        //    ppj.ppj_iSpeed = (int)cmts[0].cmt_fNumber;
                        //}

                        IList<MachineMaster_mmt_Info> machineInfo = uow.CurrentSession.QueryOver<MachineMaster_mmt_Info>().Where(d => d.mmt_cMachineID == swl.swl_cMachineNO).List<MachineMaster_mmt_Info>();
                        if (machineInfo.Count == 1)
                        {
                            int produceSpeed = 0;
                            int.TryParse(machineInfo[0].mmt_cModel, out produceSpeed);//由於數據庫暫時沒有目標車速的欄位,GISS用機台型號錄入數值代替
                            ppj.ppj_iSpeed = produceSpeed;
                        }

                        cmts = uow.CurrentSession.QueryOver<CodeMaster_cmt_Info>().Where(d => d.cmt_cKey1 == CustEnum.KEY1.TYPEVALUE.ToString() && d.cmt_cKey2 == CustEnum.KEY2.DEFAULT.ToString() && d.cmt_cValue == CustEnum.DEFALUT.QCINTERVAL.ToString()).List<CodeMaster_cmt_Info>();
                        if (cmts.Count == 1)
                        {
                            ppj.ppj_iQCInterval = (int)cmts[0].cmt_fNumber;
                        }
                        else
                        {
                            ppj.ppj_iQCInterval = 30;
                        }

                        cmts = uow.CurrentSession.QueryOver<CodeMaster_cmt_Info>().Where(d => d.cmt_cKey1 == CustEnum.KEY1.TYPEVALUE.ToString() && d.cmt_cKey2 == CustEnum.KEY2.DEFAULT.ToString() && d.cmt_cValue == CustEnum.DEFALUT.PROD_STOP_COND.ToString()).List<CodeMaster_cmt_Info>();
                        if (cmts.Count == 1)
                        {
                            swl.PROD_STOP_COND = (int)cmts[0].cmt_fNumber;
                        }
                        else
                        {
                            swl.PROD_STOP_COND = 8;
                        }
                        #endregion

                        #endregion

                        #region 工程附件信息
                        ProjectAdditionalInformation_pai_Info paiInfo = new ProjectAdditionalInformation_pai_Info();
                        paiInfo.pai_PPJRecordID = ppj.ppj_RecordID;
                        paiInfo.pai_iFrontProcessDefectiveQty = 0;
                        paiInfo.pai_iFrontProcessWasteQty = 0;
                        paiInfo.pai_iGoldPaperTimes = 0;
                        paiInfo.pai_iRevolution = 0;
                        paiInfo.pai_iTemperature = 0;
                        paiInfo.pai_cUnit = string.Empty;
                        paiInfo.pai_iUnitLength = 0;
                        paiInfo.pai_iUVLuminosity = 0;
                        paiInfo.pai_iUnitWidth = 0;
                        uow.CurrentSession.Save(paiInfo);
                        ppj.AdditionalInformation = paiInfo;
                        #endregion

                        #region 生成印刷工程準備工作項
                        //IProjectPreJobItemDA projectPreJodItemDA = DAL.Factory.HBPMS.SQLiteDAFacotry.GetDAL<IProjectPreJobItemDA>(DAL.Factory.HBPMS.SQLiteDAFacotry.ProjectPreJodItemDA);

                        //prol.PrepareJobItems = new List<ProjectPreJobItem_ppji_Info>();

                        #endregion

                        #region 班次內工程
                        ShiftProjList_spl_Info shiftProject = new ShiftProjList_spl_Info();
                        shiftProject.spl_RecordID = Guid.NewGuid();
                        shiftProject.spl_SIFOID = shift.sifo_RecordID;
                        shiftProject.spl_PPJID = ppj.ppj_RecordID;
                        shiftProject.spl_dBeginTime = ppj.ppj_dProjBeginTime;
                        shiftProject.spl_lSync = false;
                        shiftProject.spl_dLastDate = shiftProject.spl_dAddDate = DateTime.Now;
                        uow.CurrentSession.Save(shiftProject);
                        #endregion

                        #region 班次空閒狀態結束
                        SpareStatus_sst_Info info = uow.CurrentSession.QueryOver<SpareStatus_sst_Info>().And(d => d.sst_iSIFOID == shift.sifo_RecordID).And(d => d.sst_dEndTime == null).Take(1).SingleOrDefault();
                        if (info != null)
                        {
                            info.sst_dEndTime = DateTime.Now;
                            info.sst_dLastDate = DateTime.Now;

                            if (info.sst_StatusID == Guid.Empty)
                            {
                                IdleState_ism_Info ism = uow.CurrentSession.QueryOver<IdleState_ism_Info>().And(d => d.ism_lIsBuildin && d.ism_lIsAtive).Take(1).SingleOrDefault();
                                if (ism != null)
                                {
                                    info.sst_cStatusName = ism.ism_cStateName;
                                    info.sst_StatusID = ism.ism_RecordID;
                                }
                            }

                            var dinnerTime = (int)uow.CurrentSession.QueryOver<DinnerRecord_dnr_Info>().And(d => d.dsm_sstID == info.sst_RecordID).And(d => d.dnr_dEndTime != null).List().Sum(d => (d.dnr_dEndTime.Value - d.dnr_dBeginTime.Value).TotalSeconds);

                            if (info.sst_dEndTime.HasValue)
                            {
                                info.sst_iTime = (int)(info.sst_dEndTime.Value - info.sst_dBeginTime.Value).TotalSeconds - dinnerTime;
                            }

                            uow.CurrentSession.Update(info);

                        }
                        #endregion

                        ppj.ShiftProjects = new List<ShiftProjList_spl_Info>();
                        ppj.ShiftProjects.Add(shiftProject);
                        result.ValueObject = ppj;

                        uow.CurrentSession.Save(ppj);
                        uow.CurrentSession.Update(swl);
                    }
                    catch (Exception)
                    {
                        uow.CanCommit = false;
                        throw;
                    }

                }
                result.boolValue = true;
            }
            catch (Exception ex)
            {
                Common.General.BLLoger.Debug("call ProjectPPCBL.CreateProdutionProject", ex);
                result.boolValue = false;
                result.ValueObject = ex;
                result.messageText = ex.Message;
            }

            return result;
        }
Esempio n. 9
0
        /// <summary>
        /// 班次信息
        /// </summary>
        /// <param name="machineID"></param>
        /// <returns></returns>
        public List<ShiftInfo_sifo_Info> GetShiftInfo(string machineID)
        {
            try
            {
                List<ShiftInfo_sifo_Info> list = new List<ShiftInfo_sifo_Info>();
                if (!string.IsNullOrEmpty(machineID))
                {
                    StringBuilder strSql = new StringBuilder();
                    strSql.AppendLine("select");
                    strSql.AppendLine("sifo_RecordID,sifo_iSTMID,sifo_dProdDate,sifo_cMachineNO,sifo_DutyCaptainID,sifo_iOffDutySetID,sifo_dBeginTime,sifo_dEndTime,sifo_lOvertime,sifo_cType,sifo_lSync,sifo_dAddDate,sifo_dLastDate ");
                    strSql.AppendLine("from ShiftInfo_sifo ");
                    strSql.AppendLine("where sifo_cMachineNO='" + machineID + "' and datediff(day,sifo_dProdDate,getdate())<=7");

                    using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                    {
                        while (sdr.Read())
                        {
                            ShiftInfo_sifo_Info model = new ShiftInfo_sifo_Info();
                            if (sdr["sifo_RecordID"] != null && sdr["sifo_RecordID"].ToString() != "")
                            {
                                model.sifo_RecordID = new Guid(sdr["sifo_RecordID"].ToString());
                            }
                            if (sdr["sifo_iSTMID"] != null && sdr["sifo_iSTMID"].ToString() != "")
                            {
                                model.sifo_iSTMID = int.Parse(sdr["sifo_iSTMID"].ToString());
                            }
                            if (sdr["sifo_dProdDate"] != null && sdr["sifo_dProdDate"].ToString() != "")
                            {
                                model.sifo_dProdDate = DateTime.Parse(sdr["sifo_dProdDate"].ToString());
                            }
                            if (sdr["sifo_cMachineNO"] != null && sdr["sifo_cMachineNO"].ToString() != "")
                            {
                                model.sifo_cMachineNO = sdr["sifo_cMachineNO"].ToString();
                            }
                            if (sdr["sifo_DutyCaptainID"] != null && sdr["sifo_DutyCaptainID"].ToString() != "")
                            {
                                model.sifo_DutyCaptainID = new Guid(sdr["sifo_DutyCaptainID"].ToString());
                            }
                            if (sdr["sifo_iOffDutySetID"] != null && sdr["sifo_iOffDutySetID"].ToString() != "")
                            {
                                model.sifo_iOffDutySetID = int.Parse(sdr["sifo_iOffDutySetID"].ToString());
                            }
                            if (sdr["sifo_dBeginTime"] != null && sdr["sifo_dBeginTime"].ToString() != "")
                            {
                                model.sifo_dBeginTime = DateTime.Parse(sdr["sifo_dBeginTime"].ToString());
                            }
                            if (sdr["sifo_dEndTime"] != null && sdr["sifo_dEndTime"].ToString() != "")
                            {
                                model.sifo_dEndTime = DateTime.Parse(sdr["sifo_dEndTime"].ToString());
                            }
                            if (sdr["sifo_lOvertime"] != null && sdr["sifo_lOvertime"].ToString() != "")
                            {
                                if ((sdr["sifo_lOvertime"].ToString() == "1") || (sdr["sifo_lOvertime"].ToString().ToLower() == "true"))
                                {
                                    model.sifo_lOvertime = true;
                                }
                                else
                                {
                                    model.sifo_lOvertime = false;
                                }
                            }
                            if (sdr["sifo_cType"] != null && sdr["sifo_cType"].ToString() != "")
                            {
                                model.sifo_cType = sdr["sifo_cType"].ToString();
                            }
                            if (sdr["sifo_lSync"] != null && sdr["sifo_lSync"].ToString() != "")
                            {
                                if ((sdr["sifo_lSync"].ToString() == "1") || (sdr["sifo_lSync"].ToString().ToLower() == "true"))
                                {
                                    model.sifo_lSync = true;
                                }
                                else
                                {
                                    model.sifo_lSync = false;
                                }
                            }
                            if (sdr["sifo_dAddDate"] != null && sdr["sifo_dAddDate"].ToString() != "")
                            {
                                model.sifo_dAddDate = DateTime.Parse(sdr["sifo_dAddDate"].ToString());
                            }
                            if (sdr["sifo_dLastDate"] != null && sdr["sifo_dLastDate"].ToString() != "")
                            {
                                model.sifo_dLastDate = DateTime.Parse(sdr["sifo_dLastDate"].ToString());
                            }
                            list.Add(model);
                        }

                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 10
0
 private string GetShiftInfoSQL(ShiftInfo_sifo_Info model)
 {
     StringBuilder strSql = new StringBuilder();
     StringBuilder strSql1 = new StringBuilder();
     StringBuilder strSql2 = new StringBuilder();
     if (model.sifo_RecordID != null)
     {
         strSql1.Append("sifo_RecordID,");
         strSql2.Append("'" + model.sifo_RecordID + "',");
     }
     if (model.sifo_iSTMID != null)
     {
         strSql1.Append("sifo_iSTMID,");
         strSql2.Append("" + model.sifo_iSTMID + ",");
     }
     if (model.sifo_dProdDate != null)
     {
         strSql1.Append("sifo_dProdDate,");
         strSql2.Append("'" + model.sifo_dProdDate.ToString("yyyy-MM-dd") + "',");
     }
     if (model.sifo_cMachineNO != null)
     {
         strSql1.Append("sifo_cMachineNO,");
         strSql2.Append("'" + model.sifo_cMachineNO + "',");
     }
     if (model.sifo_DutyCaptainID != null)
     {
         strSql1.Append("sifo_DutyCaptainID,");
         strSql2.Append("'" + model.sifo_DutyCaptainID + "',");
     }
     if (model.sifo_iOffDutySetID != null)
     {
         strSql1.Append("sifo_iOffDutySetID,");
         strSql2.Append("" + model.sifo_iOffDutySetID + ",");
     }
     if (model.sifo_dBeginTime != null)
     {
         strSql1.Append("sifo_dBeginTime,");
         strSql2.Append("'" + model.sifo_dBeginTime.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     if (model.sifo_dEndTime != null)
     {
         strSql1.Append("sifo_dEndTime,");
         strSql2.Append("'" + model.sifo_dEndTime.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     if (model.sifo_lOvertime != null)
     {
         strSql1.Append("sifo_lOvertime,");
         strSql2.Append("" + (model.sifo_lOvertime ? 1 : 0) + ",");
     }
     if (model.sifo_cType != null)
     {
         strSql1.Append("sifo_cType,");
         strSql2.Append("'" + model.sifo_cType + "',");
     }
     if (model.sifo_lSync != null)
     {
         strSql1.Append("sifo_lSync,");
         strSql2.Append("" + (model.sifo_lSync ? 1 : 0) + ",");
     }
     if (model.sifo_dAddDate != null)
     {
         strSql1.Append("sifo_dAddDate,");
         strSql2.Append("'" + model.sifo_dAddDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     if (model.sifo_dLastDate != null)
     {
         strSql1.Append("sifo_dLastDate,");
         strSql2.Append("'" + model.sifo_dLastDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     strSql.Append("insert into ShiftInfo_sifo(");
     strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
     strSql.Append(")");
     strSql.Append(" values (");
     strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
     strSql.Append(")");
     return strSql.ToString();
 }
Esempio n. 11
0
        /// <summary>
        /// 班次信息
        /// </summary>
        /// <param name="machineID"></param>
        /// <returns></returns>
        public List<ShiftInfo_sifo_Info> GetShiftInfo()
        {
            try
            {
                List<ShiftInfo_sifo_Info> list = new List<ShiftInfo_sifo_Info>();

                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select");
                strSql.AppendLine("sifo_RecordID,sifo_iSTMID,sifo_dProdDate,sifo_cMachineNO,sifo_DutyCaptainID,sifo_iOffDutySetID,sifo_dBeginTime,sifo_dEndTime,sifo_lOvertime,sifo_cType,sifo_lSync,sifo_dAddDate,sifo_dLastDate ");
                strSql.AppendLine("from ShiftInfo_sifo ");
                strSql.AppendLine("where (sifo_dProdDate Between '" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and '" + DateTime.Now.ToString("yyyy-MM-dd") + "')");

                using (SQLiteDataReader sdr = DbHelperSQLite.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        ShiftInfo_sifo_Info model = new ShiftInfo_sifo_Info();
                        if (sdr["sifo_RecordID"] != null && sdr["sifo_RecordID"].ToString() != "")
                        {
                            model.sifo_RecordID = new Guid(sdr["sifo_RecordID"].ToString());
                        }
                        if (sdr["sifo_iSTMID"] != null && sdr["sifo_iSTMID"].ToString() != "")
                        {
                            model.sifo_iSTMID = int.Parse(sdr["sifo_iSTMID"].ToString());
                        }
                        if (sdr["sifo_dProdDate"] != null && sdr["sifo_dProdDate"].ToString() != "")
                        {
                            model.sifo_dProdDate = DateTime.Parse(sdr["sifo_dProdDate"].ToString());
                        }
                        if (sdr["sifo_cMachineNO"] != null && sdr["sifo_cMachineNO"].ToString() != "")
                        {
                            model.sifo_cMachineNO = sdr["sifo_cMachineNO"].ToString();
                        }
                        if (sdr["sifo_DutyCaptainID"] != null && sdr["sifo_DutyCaptainID"].ToString() != "")
                        {
                            model.sifo_DutyCaptainID = new Guid(sdr["sifo_DutyCaptainID"].ToString());
                        }
                        if (sdr["sifo_iOffDutySetID"] != null && sdr["sifo_iOffDutySetID"].ToString() != "")
                        {
                            model.sifo_iOffDutySetID = int.Parse(sdr["sifo_iOffDutySetID"].ToString());
                        }
                        if (sdr["sifo_dBeginTime"] != null && sdr["sifo_dBeginTime"].ToString() != "")
                        {
                            model.sifo_dBeginTime = DateTime.Parse(sdr["sifo_dBeginTime"].ToString());
                        }
                        if (sdr["sifo_dEndTime"] != null && sdr["sifo_dEndTime"].ToString() != "")
                        {
                            model.sifo_dEndTime = DateTime.Parse(sdr["sifo_dEndTime"].ToString());
                        }
                        if (sdr["sifo_lOvertime"] != null && sdr["sifo_lOvertime"].ToString() != "")
                        {
                            if ((sdr["sifo_lOvertime"].ToString() == "1") || (sdr["sifo_lOvertime"].ToString().ToLower() == "true"))
                            {
                                model.sifo_lOvertime = true;
                            }
                            else
                            {
                                model.sifo_lOvertime = false;
                            }
                        }
                        if (sdr["sifo_cType"] != null && sdr["sifo_cType"].ToString() != "")
                        {
                            model.sifo_cType = sdr["sifo_cType"].ToString();
                        }
                        if (sdr["sifo_lSync"] != null && sdr["sifo_lSync"].ToString() != "")
                        {
                            if ((sdr["sifo_lSync"].ToString() == "1") || (sdr["sifo_lSync"].ToString().ToLower() == "true"))
                            {
                                model.sifo_lSync = true;
                            }
                            else
                            {
                                model.sifo_lSync = false;
                            }
                        }
                        if (sdr["sifo_dAddDate"] != null && sdr["sifo_dAddDate"].ToString() != "")
                        {
                            model.sifo_dAddDate = DateTime.Parse(sdr["sifo_dAddDate"].ToString());
                        }
                        if (sdr["sifo_dLastDate"] != null && sdr["sifo_dLastDate"].ToString() != "")
                        {
                            model.sifo_dLastDate = DateTime.Parse(sdr["sifo_dLastDate"].ToString());
                        }
                        list.Add(model);
                    }
                }

                return list;
            }
            catch(Exception ex)
            {
                throw ex ;
            }
        }