Beispiel #1
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;
        }
Beispiel #2
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;
        }
Beispiel #3
0
 public ReturnValueInfo UpdateProjectAdditionalInformation(ProjectAdditionalInformation_pai_Info infoObject)
 {
     ReturnValueInfo result = new ReturnValueInfo();
     try
     {
         //result = mPrintProjectDA.Update(infoObject);
     }
     catch (Exception ex)
     {
         result.boolValue = false;
         result.messageText = ex.Message;
     }
     return result;
 }