Example #1
0
 /// <summary>
 /// 设置时间段字符串
 /// </summary>
 /// <param name="timeIntervalDTO"></param>
 /// <returns></returns>
 public static TimeIntervalDTO GetTimeInterval(TimeIntervalDTO timeIntervalDTO)
 {
     timeIntervalDTO.SerchStartTime = timeIntervalDTO.StartTime.AddHours(2 * (timeIntervalDTO.TimeIntervalIndex - 1));
     timeIntervalDTO.SerchEndTime   = timeIntervalDTO.StartTime.AddHours(2 * timeIntervalDTO.TimeIntervalIndex);
     timeIntervalDTO.TimeInterval   = timeIntervalDTO.SerchStartTime.ToString(FormatConstants.DateTimeFormatStringByMin).Substring(11) + "-" + timeIntervalDTO.SerchEndTime.ToString(FormatConstants.DateTimeFormatStringByMin).Substring(11);
     return(timeIntervalDTO);
 }
Example #2
0
        public static TimeIntervalDTO GetTimeIntervalDTO(List <GL_ShiftTimeDTO> shiftTimeDTOs, GL_StationDTO item, DateTime dateNow)
        {
            TimeIntervalDTO timeIntervalDTO = new TimeIntervalDTO();

            #region IPQC获取班次相关

            //获取当前站点所在厂区,OP的所有班次
            var shiftTimes = shiftTimeDTOs.Where(o => o.Plant_Organization_UID == item.Plant_Organization_UID && o.BG_Organization_UID == item.BG_Organization_UID);
            //得到当前dateNow时间所属的班次
            var shiftTimeDTO = GetGL_ShiftTimeDTO(shiftTimes.ToList(), dateNow);
            if (shiftTimeDTO != null)
            {
                //得到所属时间dateNow 所在班次的开始时间和技术时间
                DateTime StartTime = Convert.ToDateTime((dateNow.ToString("yyyy-MM-dd ") + shiftTimeDTO.StartTime));
                DateTime EndTime   = Convert.ToDateTime((dateNow.ToString("yyyy-MM-dd ") + shiftTimeDTO.End_Time));
                //同步当前班次的数据
                if (StartTime > EndTime)
                {
                    StartTime = StartTime.AddDays(-1);
                }
                timeIntervalDTO.ShiftTimeID = shiftTimeDTO.ShiftTimeID;
                timeIntervalDTO.StartTime   = StartTime;
                timeIntervalDTO.EndTime     = EndTime;
                timeIntervalDTO.NowDateTime = dateNow;
                timeIntervalDTO.ProductDate = Convert.ToDateTime(StartTime.ToString(FormatConstants.DateTimeFormatStringByDate));
                //设置第几个时间段
                timeIntervalDTO.TimeIntervalIndex = GetTimeIntervalIndex(timeIntervalDTO);
                //设置时间段字符串
                timeIntervalDTO = GetTimeInterval(timeIntervalDTO);
            }
            #endregion

            return(timeIntervalDTO);
        }
Example #3
0
        public static int GetInputNumber(TimeIntervalDTO timeIntervalDTO, int StationID)
        {
            IPQCQualityService iPQCQualityService = new IPQCQualityService(
                new UnitOfWork(_DatabaseFactory),
                new IPQCQUalityReportRepository(_DatabaseFactory),
                new GL_QADetectionPointRepository(_DatabaseFactory),
                new GL_ShiftTimeRepository(_DatabaseFactory),
                new GL_StationRepository(_DatabaseFactory),
                new GL_QATargetYieldRepository(_DatabaseFactory),
                new IPQCQualityDetialRepository(_DatabaseFactory),
                new GL_GoldenStationCTRecordRepository(_DatabaseFactory),
                new GL_WIPHourOutputRepository(_DatabaseFactory)
                );
            int InputNumber = 0;
            //获取两小时的数据索引
            List <int> HourIndexs = new List <int>();

            HourIndexs.Add(timeIntervalDTO.TimeIntervalIndex * 2);
            HourIndexs.Add(timeIntervalDTO.TimeIntervalIndex * 2 - 1);

            var wIPHourOutputDTOs = iPQCQualityService.GetGL_WIPHourOutputDTOs(StationID, timeIntervalDTO.ProductDate.ToString(FormatConstants.DateTimeFormatStringByDate), HourIndexs, timeIntervalDTO.ShiftTimeID);

            if (wIPHourOutputDTOs != null && wIPHourOutputDTOs.Count > 0)
            {
                InputNumber = wIPHourOutputDTOs.Sum(x => x.ActualOutput);
            }
            return(InputNumber);
        }
Example #4
0
        /// <summary>
        /// 设置时间段
        /// </summary>
        /// <param name="timeIntervalDTO"></param>
        /// <returns></returns>
        public static int GetTimeIntervalIndex(TimeIntervalDTO timeIntervalDTO)
        {
            int timeIntervalIndex = 1;
            int hourIndex         = Math.Abs(timeIntervalDTO.StartTime.Hour - timeIntervalDTO.EndTime.Hour);

            hourIndex = hourIndex / 2 + 1;
            for (int k = 1; k <= hourIndex; k++)
            {
                if (timeIntervalDTO.StartTime.AddHours(2 * (k - 1)) < timeIntervalDTO.NowDateTime && timeIntervalDTO.NowDateTime <= timeIntervalDTO.StartTime.AddHours(2 * k))
                {
                    timeIntervalIndex = k;
                }
            }
            return(timeIntervalIndex);
        }
Example #5
0
        public static List <GL_IPQCQualityReportDTO> GetGL_IPQCQualityReportDTOs(GL_StationDTO item, List <GL_IPQCQualityReportDTO> iPQCQualityReportDTOs, TimeIntervalDTO timeIntervalDTO,
                                                                                 List <WP_IPQCDTO> ScanINs, List <WP_IPQCDTO> ScanBACKs, List <WP_IPQCDTO> ScanNGs, List <WP_IPQCDTO> ScanOUTs, GL_QADetectionPointDTO gL_QADetectionPointDTO)
        {
            IPQCQualityService iPQCQualityService = new IPQCQualityService(
                new UnitOfWork(_DatabaseFactory),
                new IPQCQUalityReportRepository(_DatabaseFactory),
                new GL_QADetectionPointRepository(_DatabaseFactory),
                new GL_ShiftTimeRepository(_DatabaseFactory),
                new GL_StationRepository(_DatabaseFactory),
                new GL_QATargetYieldRepository(_DatabaseFactory),
                new IPQCQualityDetialRepository(_DatabaseFactory),
                new GL_GoldenStationCTRecordRepository(_DatabaseFactory),
                new GL_WIPHourOutputRepository(_DatabaseFactory)
                );
            GL_IPQCQualityReportDTO gL_IPQCQualityReportDTO = new GL_IPQCQualityReportDTO();

            #region IPQC时段良率数据组装
            gL_IPQCQualityReportDTO.StationID         = item.StationID;
            gL_IPQCQualityReportDTO.ShiftID           = timeIntervalDTO.ShiftTimeID;
            gL_IPQCQualityReportDTO.TimeInterval      = timeIntervalDTO.TimeInterval;
            gL_IPQCQualityReportDTO.TimeIntervalIndex = timeIntervalDTO.TimeIntervalIndex;
            gL_IPQCQualityReportDTO.ProductDate       = timeIntervalDTO.ProductDate;
            //进料数
            gL_IPQCQualityReportDTO.InputNumber = GetInputNumber(timeIntervalDTO, item.StationID);
            //扫码 IN
            gL_IPQCQualityReportDTO.TestNumber = ScanINs != null ? ScanINs.Count : 0;
            //返修
            gL_IPQCQualityReportDTO.RepairNumber = ScanBACKs != null ? ScanBACKs.Count : 0;
            //NG
            gL_IPQCQualityReportDTO.NGNumber = ScanNGs != null ? ScanNGs.Count : 0;
            //二次OK数 OUT数
            gL_IPQCQualityReportDTO.SecondPassNumber = ScanOUTs != null ? ScanOUTs.Count : 0;
            //一次OK数 (MES-IPQC扫码IN)-(MES-IPQC返修)-(MES-IPQC-NG)
            gL_IPQCQualityReportDTO.FirstPassNumber = gL_IPQCQualityReportDTO.TestNumber - gL_IPQCQualityReportDTO.RepairNumber - gL_IPQCQualityReportDTO.NGNumber;

            #region 设置一次二次良率
            //一次良率  一次OK数/一次检验数
            if (gL_IPQCQualityReportDTO.FirstPassNumber != 0 && gL_IPQCQualityReportDTO.TestNumber != 0)
            {
                gL_IPQCQualityReportDTO.FirstYield = (gL_IPQCQualityReportDTO.FirstPassNumber * 1.0) / gL_IPQCQualityReportDTO.TestNumber;
            }
            else
            {
                gL_IPQCQualityReportDTO.FirstYield = 0.0;
            }
            //二次良率 二次OK数/(二次OK数+NG数)
            if (gL_IPQCQualityReportDTO.SecondPassNumber != 0)
            {
                gL_IPQCQualityReportDTO.SecondYield = (gL_IPQCQualityReportDTO.SecondPassNumber * 1.0) / (gL_IPQCQualityReportDTO.SecondPassNumber + gL_IPQCQualityReportDTO.NGNumber);
            }
            else
            {
                gL_IPQCQualityReportDTO.SecondYield = 0.0;
            }

            #endregion

            #region 设置一次二次目标良率
            var gLQATargetYieldDTOs = iPQCQualityService.GetGLQATargetYieldDTOList(item.StationID, timeIntervalDTO.ProductDate.ToString(FormatConstants.DateTimeFormatStringByDate));
            if (gLQATargetYieldDTOs != null && gLQATargetYieldDTOs.Count > 0)
            {
                var oneTargetYield = gLQATargetYieldDTOs.FirstOrDefault(o => o.Tag == 1);
                if (oneTargetYield != null)
                {
                    //一次目标良率
                    gL_IPQCQualityReportDTO.FirstTargetYield = Convert.ToDouble(oneTargetYield.TargetYield);
                }
                else
                {
                    //一次目标良率
                    gL_IPQCQualityReportDTO.FirstTargetYield = 0;
                }
                var twoTargetYield = gLQATargetYieldDTOs.FirstOrDefault(o => o.Tag == 2);

                if (twoTargetYield != null)
                {
                    //二次目标良率
                    gL_IPQCQualityReportDTO.SecondTargetYield = Convert.ToDouble(twoTargetYield.TargetYield);
                }
                else
                {
                    //二次目标良率
                    gL_IPQCQualityReportDTO.SecondTargetYield = 0;
                }
            }
            else
            {
                //一次目标良率
                gL_IPQCQualityReportDTO.FirstTargetYield = 0;
                //二次目标良率
                gL_IPQCQualityReportDTO.SecondTargetYield = 0;
            }
            #endregion

            //WIP
            gL_IPQCQualityReportDTO.WIP = gL_QADetectionPointDTO.WIP + gL_IPQCQualityReportDTO.InputNumber - gL_IPQCQualityReportDTO.NGNumber - gL_IPQCQualityReportDTO.SecondPassNumber;// - gL_IPQCQualityReportDTO.FirstPassNumber;

            gL_IPQCQualityReportDTO.ModifyTime     = DateTime.Now;
            gL_IPQCQualityReportDTO.NowDateTime    = timeIntervalDTO.NowDateTime;
            gL_IPQCQualityReportDTO.SerchEndTime   = timeIntervalDTO.SerchEndTime;
            gL_IPQCQualityReportDTO.SerchStartTime = timeIntervalDTO.SerchStartTime;

            //  需要查看数据是否存在 如果存在 则要把IPQCQualityReport_UID赋值
            var iPQCQualityReportDTO = iPQCQualityService.GetGLIPQCQualityReportDTO(item.StationID, timeIntervalDTO.ShiftTimeID, timeIntervalDTO.TimeIntervalIndex, timeIntervalDTO.ProductDate, timeIntervalDTO.TimeInterval);
            if (iPQCQualityReportDTO != null)
            {
                gL_IPQCQualityReportDTO.IPQCQualityReport_UID = iPQCQualityReportDTO.IPQCQualityReport_UID;
            }

            iPQCQualityReportDTOs.Add(gL_IPQCQualityReportDTO);
            #endregion

            return(iPQCQualityReportDTOs);
        }
Example #6
0
        public static List <GL_IPQCQualityDetialDTO> GetGL_IPQCQualityDetialDTOs(GL_StationDTO item, List <GL_IPQCQualityDetialDTO> gL_IPQCQualityDetialDTOs, TimeIntervalDTO timeIntervalDTO, List <WP_IPQCDTO> ScanBACKs, List <WP_IPQCDTO> ScanNGs)
        {
            IPQCQualityService iPQCQualityService = new IPQCQualityService(
                new UnitOfWork(_DatabaseFactory),
                new IPQCQUalityReportRepository(_DatabaseFactory),
                new GL_QADetectionPointRepository(_DatabaseFactory),
                new GL_ShiftTimeRepository(_DatabaseFactory),
                new GL_StationRepository(_DatabaseFactory),
                new GL_QATargetYieldRepository(_DatabaseFactory),
                new IPQCQualityDetialRepository(_DatabaseFactory),
                new GL_GoldenStationCTRecordRepository(_DatabaseFactory),
                new GL_WIPHourOutputRepository(_DatabaseFactory)
                );

            #region IPQC不良明细数据组装
            //或取指定时间段的明细数据
            var allGLIPQCQualityDetialDTOs = iPQCQualityService.GetAllGL_IPQCQualityDetialDTO(item.StationID, timeIntervalDTO.ShiftTimeID, timeIntervalDTO.TimeIntervalIndex, timeIntervalDTO.ProductDate, timeIntervalDTO.TimeInterval);
            if (ScanBACKs != null)
            {
                #region 返修不良明细

                var groupScanBACKs = ScanBACKs.GroupBy(a => a.DefectName).Select(g => (new { name = g.Key, count = g.Count() })).ToList();
                foreach (var itemBACK in groupScanBACKs)
                {
                    GL_IPQCQualityDetialDTO gL_IPQCQualityDetialDTO = new GL_IPQCQualityDetialDTO();
                    gL_IPQCQualityDetialDTO.StationID         = item.StationID;
                    gL_IPQCQualityDetialDTO.ShiftID           = timeIntervalDTO.ShiftTimeID;
                    gL_IPQCQualityDetialDTO.TimeInterval      = timeIntervalDTO.TimeInterval;
                    gL_IPQCQualityDetialDTO.TimeIntervalIndex = timeIntervalDTO.TimeIntervalIndex;
                    gL_IPQCQualityDetialDTO.ProductDate       = timeIntervalDTO.ProductDate;
                    gL_IPQCQualityDetialDTO.NGName            = itemBACK.name;
                    gL_IPQCQualityDetialDTO.NGNumber          = itemBACK.count;
                    gL_IPQCQualityDetialDTO.NGType            = "0";
                    gL_IPQCQualityDetialDTO.ModifyTime        = DateTime.Now;

                    //  需要查看数据是否存在, 如果存在 则要把IPQCQualityDetial_UID赋值
                    if (allGLIPQCQualityDetialDTOs != null && allGLIPQCQualityDetialDTOs.Count > 0)
                    {
                        var iPQCQualityDetialDTO = allGLIPQCQualityDetialDTOs.FirstOrDefault(o => o.NGName == itemBACK.name && o.NGType == "0");
                        if (iPQCQualityDetialDTO != null)
                        {
                            gL_IPQCQualityDetialDTO.IPQCQualityDetial_UID = iPQCQualityDetialDTO.IPQCQualityDetial_UID;
                        }
                    }

                    gL_IPQCQualityDetialDTOs.Add(gL_IPQCQualityDetialDTO);
                }
                #endregion
            }
            if (ScanNGs != null)
            {
                #region NG不良明细
                var groupScanNGs = ScanNGs.GroupBy(a => a.DefectName).Select(g => (new { name = g.Key, count = g.Count() })).ToList();
                foreach (var itemNG in groupScanNGs)
                {
                    GL_IPQCQualityDetialDTO gL_IPQCQualityDetialDTO = new GL_IPQCQualityDetialDTO();
                    gL_IPQCQualityDetialDTO.StationID         = item.StationID;
                    gL_IPQCQualityDetialDTO.ShiftID           = timeIntervalDTO.ShiftTimeID;
                    gL_IPQCQualityDetialDTO.TimeInterval      = timeIntervalDTO.TimeInterval;
                    gL_IPQCQualityDetialDTO.TimeIntervalIndex = timeIntervalDTO.TimeIntervalIndex;
                    gL_IPQCQualityDetialDTO.ProductDate       = timeIntervalDTO.ProductDate;
                    gL_IPQCQualityDetialDTO.NGName            = itemNG.name;
                    gL_IPQCQualityDetialDTO.NGNumber          = itemNG.count;
                    gL_IPQCQualityDetialDTO.NGType            = "1";
                    gL_IPQCQualityDetialDTO.ModifyTime        = DateTime.Now;

                    //  需要查看数据是否存在, 如果存在 则要把IPQCQualityDetial_UID赋值
                    if (allGLIPQCQualityDetialDTOs != null && allGLIPQCQualityDetialDTOs.Count > 0)
                    {
                        var iPQCQualityDetialDTO = allGLIPQCQualityDetialDTOs.FirstOrDefault(o => o.NGName == itemNG.name && o.NGType == "1");
                        if (iPQCQualityDetialDTO != null)
                        {
                            gL_IPQCQualityDetialDTO.IPQCQualityDetial_UID = iPQCQualityDetialDTO.IPQCQualityDetial_UID;
                        }
                    }
                    gL_IPQCQualityDetialDTOs.Add(gL_IPQCQualityDetialDTO);
                }
                #endregion
            }
            #endregion

            return(gL_IPQCQualityDetialDTOs);
        }