Beispiel #1
0
        public IQueryable <EQPRepairInfoDTO> GetInfo(EQPRepairInfoSearchDTO searchModel, List <int> Organization_UIDs, Page page, out int totalcount, out decimal allcost)
        {
            var query = from M in DataContext.EQPRepair_Info
                        join equipinfo in DataContext.Equipment_Info
                        on M.EQP_Uid equals equipinfo.EQP_Uid
                        join project in DataContext.System_Project
                        on equipinfo.Project_UID equals project.Project_UID into temp
                        from aa in temp.DefaultIfEmpty()
                        join funplant in DataContext.System_Function_Plant
                        on equipinfo.System_FunPlant_UID equals funplant.System_FunPlant_UID
                        select new EQPRepairInfoDTO
            {
                EQP_Location             = equipinfo.EQP_Location,
                Class_Desc               = equipinfo.Class_Desc,
                EQP_Plant_No             = equipinfo.EQP_Plant_No,
                Repair_Uid               = M.Repair_Uid,
                Equipment                = equipinfo.Equipment,
                Status                   = M.Status,
                Error_Types              = M.Error_Types,
                Error_Level              = M.Error_Level,
                Contact                  = M.Contact,
                Contact_tel              = M.Contact_tel,
                Error_Time               = M.Error_Time,
                Repair_BeginTime         = M.Repair_BeginTime,
                Repair_EndTime           = M.Repair_EndTime,
                TotalTime                = Math.Round((double)(SqlFunctions.DateDiff("MINUTE", M.Repair_BeginTime, M.Repair_EndTime) == null ? 0 : (int)SqlFunctions.DateDiff("MINUTE", M.Repair_BeginTime, M.Repair_EndTime)) / 60, 2),
                Labor_List               = M.Labor_List,
                Update_Part              = M.Update_Part,
                Labor_Time               = M.Labor_Time,
                All_RepairCost           = M.All_RepairCost,
                Modified_Date            = M.Modified_Date,
                Process                  = equipinfo.Process,
                Reason_Types             = M.Reason_Types,
                Repair_Reason            = M.Repair_Reason,
                Reason_Analysis          = M.Reason_Analysis,
                Repair_Remark            = M.Repair_Remark,
                OP_TYPES                 = funplant.OP_Types,
                Mfg_Serial_Num           = equipinfo.Mfg_Serial_Num,
                Project_Name             = aa.Project_Name,
                FunPlant                 = funplant.FunPlant,
                Repair_id                = M.Repair_id,
                Repair_Result            = M.Repair_Result,
                Repair_Method            = M.Repair_Method,
                Apply_Time               = (DateTime)M.Apply_Time,
                Organization_UID         = aa.Organization_UID,
                FunPlant_OrganizationUID = funplant.FunPlant_OrganizationUID.Value,
                Mentioner                = M.Mentioner,
                CostCtr_UID              = M.CostCtr_UID,
                CostCtr_ID               = M.CostCtr_info.CostCtr_ID,
                CostCtr_Description      = M.CostCtr_info.CostCtr_Description,
                //Modified_Date=M.Modified_Date,
            };

            if (searchModel.Organization_UID != 0)
            {
                query = query.Where(m => m.Organization_UID == searchModel.Organization_UID);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Project_Name))
            {
                query = query.Where(m => m.Project_Name.Contains(searchModel.Project_Name));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.FunPlant))
            {
                query = query.Where(m => m.FunPlant.Contains(searchModel.FunPlant));
            }
            if (searchModel.CostCtr_UID != 0)
            {
                query = query.Where(m => m.CostCtr_UID == searchModel.CostCtr_UID);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Process))
            {
                query = query.Where(m => m.Process.Contains(searchModel.Process));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Mfg_Serial_Num))
            {
                query = query.Where(m => m.Mfg_Serial_Num.Contains(searchModel.Mfg_Serial_Num));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Error_Types))
            {
                query = query.Where(m => m.Error_Types.Contains(searchModel.Error_Types));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_id))
            {
                query = query.Where(m => m.Repair_id.Contains(searchModel.Repair_id));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.EQP_Location))
            {
                query = query.Where(m => m.EQP_Location == searchModel.EQP_Location);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Class_Desc))
            {
                query = query.Where(m => m.Class_Desc.Contains(searchModel.Class_Desc));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Contact))
            {
                query = query.Where(m => m.Contact.Contains(searchModel.Contact));
            }
            if (searchModel.End_Date_From.Year != 1)
            {
                query = query.Where(m => m.Repair_EndTime >= searchModel.End_Date_From);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Error_Level))
            {
                query = query.Where(m => m.Error_Level == searchModel.Error_Level);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_Result))
            {
                query = query.Where(m => m.Repair_Result == searchModel.Repair_Result);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Update_Part))
            {
                query = query.Where(m => m.Update_Part.Contains(searchModel.Update_Part));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Labor_List))
            {
                query = query.Where(m => m.Labor_List.Contains(searchModel.Labor_List));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Status))
            {
                query = query.Where(m => m.Status == searchModel.Status);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_Result))
            {
                query = query.Where(m => m.Repair_Result == searchModel.Repair_Result);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Mentioner))
            {
                query = query.Where(m => m.Mentioner.Contains(searchModel.Mentioner));
            }
            if (searchModel.End_Date_To.Year != 1)
            {
                searchModel.End_Date_To = searchModel.End_Date_To.AddDays(1);
                query = query.Where(m => m.Repair_EndTime < searchModel.End_Date_To);
            }
            //根据功能厂过滤
            if (searchModel.FunPlant_OrganizationUID != 0)
            {
                query = query.Where(m => m.FunPlant_OrganizationUID == searchModel.FunPlant_OrganizationUID);
            }
            // 只是针对厂区的过滤
            if (Organization_UIDs.Count > 0)
            {
                query = query.Where(m => Organization_UIDs.Contains(m.Organization_UID));
            }


            totalcount = query.Count();
            if (totalcount == 0)
            {
                allcost = 0;
            }
            else
            {
                allcost = (decimal)query.Sum(m => (SqlFunctions.DateDiff("MINUTE", m.Repair_BeginTime, m.Repair_EndTime)) == null ? 0 : (SqlFunctions.DateDiff("MINUTE", m.Repair_BeginTime, m.Repair_EndTime)));
            }
            query = query.OrderByDescending(m => m.Modified_Date).ThenBy(m => m.Contact).GetPage(page);
            return(query);
        }
Beispiel #2
0
        public List <EQPRepairInfoDTO> DoAllEQPMaintenanceReprot(EQPRepairInfoSearchDTO searchModel, List <int> Organization_UIDs)
        {
            var query = from M in DataContext.EQPRepair_Info
                        join equipinfo in DataContext.Equipment_Info
                        on M.EQP_Uid equals equipinfo.EQP_Uid into temp
                        from aa in temp.DefaultIfEmpty()
                        join funplant in DataContext.System_Function_Plant
                        on aa.System_FunPlant_UID equals funplant.System_FunPlant_UID into temp2
                        from bb in temp2.DefaultIfEmpty()
                        join project in DataContext.System_Project
                        on aa.Project_UID equals project.Project_UID into temp3
                        from cc in temp3.DefaultIfEmpty()
                        select new EQPRepairInfoDTO
            {
                Class_Desc               = aa.Class_Desc,
                Repair_Uid               = M.Repair_Uid,
                Repair_id                = M.Repair_id,
                Repair_Date              = M.Error_Time.Year.ToString() + (M.Error_Time.Month > 9 ? M.Error_Time.Month.ToString() : "0" + M.Error_Time.Month.ToString()) + (M.Error_Time.Day > 9 ? M.Error_Time.Day.ToString() : "0" + M.Error_Time.Day.ToString()),
                Repair_Time              = M.Error_Time.Year.ToString() + "-" + (M.Error_Time.Month > 9 ? M.Error_Time.Month.ToString() : "0" + M.Error_Time.Month.ToString()) + "-" + (M.Error_Time.Day > 9 ? M.Error_Time.Day.ToString() : "0" + M.Error_Time.Day.ToString()) + " " + M.Error_Time.Hour.ToString() + ":" + M.Error_Time.Minute.ToString(),
                Repair_Reason            = M.Repair_Reason,
                Error_Types              = M.Error_Types,
                Reason_Analysis          = M.Reason_Analysis,
                Repair_Method            = M.Repair_Method,
                Repair_BeginTime         = M.Repair_BeginTime,
                Repair_EndTime           = M.Repair_EndTime,
                TotalTime                = Math.Round((double)(SqlFunctions.DateDiff("MINUTE", M.Repair_BeginTime, M.Repair_EndTime) == null ? 0 : (int)SqlFunctions.DateDiff("MINUTE", M.Repair_BeginTime, M.Repair_EndTime)) / 60, 2),
                Labor_List               = M.Labor_List,
                All_RepairCost           = M.All_RepairCost,
                Update_Part              = M.Update_Part,
                Repair_Remark            = M.Repair_Remark,
                Modified_Date            = M.Modified_Date,
                Reason_Types             = M.Reason_Types,
                Repair_Result            = M.Repair_Result,
                Contact                  = M.Contact,
                EQP_Location             = aa.EQP_Location,
                FunPlant                 = bb.FunPlant,
                OP_TYPES                 = bb.OP_Types,
                Project_Name             = cc.Project_Name,
                EQP_Plant_No             = aa.EQP_Plant_No,
                Equipment                = aa.Equipment,
                Process                  = aa.Process,
                Mfg_Serial_Num           = aa.Mfg_Serial_Num,
                Apply_Time               = M.Apply_Time,
                Error_Level              = M.Error_Level,
                Status                   = M.Status,
                Contact_tel              = M.Contact_tel,
                Organization_UID         = cc.Organization_UID,
                FunPlant_OrganizationUID = bb.FunPlant_OrganizationUID.Value,
                Mentioner                = M.Mentioner,
                CostCtr_UID              = M.CostCtr_UID,
                CostCtr_ID               = M.CostCtr_info.CostCtr_ID,
                CostCtr_Description      = M.CostCtr_info.CostCtr_Description
            };

            if (searchModel.Organization_UID != 0)
            {
                query = query.Where(m => m.Organization_UID == searchModel.Organization_UID);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Project_Name))
            {
                query = query.Where(m => m.Project_Name.Contains(searchModel.Project_Name));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.FunPlant))
            {
                query = query.Where(m => m.FunPlant.Contains(searchModel.FunPlant));
            }
            if (searchModel.CostCtr_UID != 0)
            {
                query = query.Where(m => m.CostCtr_UID == searchModel.CostCtr_UID);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Process))
            {
                query = query.Where(m => m.Process.Contains(searchModel.Process));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Mfg_Serial_Num))
            {
                query = query.Where(m => m.Mfg_Serial_Num.Contains(searchModel.Mfg_Serial_Num));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Error_Types))
            {
                query = query.Where(m => m.Error_Types.Contains(searchModel.Error_Types));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_id))
            {
                query = query.Where(m => m.Repair_id.Contains(searchModel.Repair_id));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.EQP_Location))
            {
                query = query.Where(m => m.EQP_Location == searchModel.EQP_Location);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Class_Desc))
            {
                query = query.Where(m => m.Class_Desc.Contains(searchModel.Class_Desc));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Contact))
            {
                query = query.Where(m => m.Contact.Contains(searchModel.Contact));
            }
            if (searchModel.End_Date_From.Year != 1)
            {
                query = query.Where(m => m.Repair_EndTime >= searchModel.End_Date_From);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Error_Level))
            {
                query = query.Where(m => m.Error_Level == searchModel.Error_Level);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_Result))
            {
                query = query.Where(m => m.Repair_Result == searchModel.Repair_Result);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Update_Part))
            {
                query = query.Where(m => m.Update_Part.Contains(searchModel.Update_Part));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Labor_List))
            {
                query = query.Where(m => m.Labor_List.Contains(searchModel.Labor_List));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Status))
            {
                query = query.Where(m => m.Status == searchModel.Status);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_Result))
            {
                query = query.Where(m => m.Repair_Result == searchModel.Repair_Result);
            }
            if (searchModel.End_Date_To.Year != 1)
            {
                searchModel.End_Date_To = searchModel.End_Date_To.AddDays(1);
                query = query.Where(m => m.Repair_EndTime < searchModel.End_Date_To);
            }
            // 只是针对厂区的过滤
            if (Organization_UIDs.Count > 0)
            {
                query = query.Where(m => Organization_UIDs.Contains(m.Organization_UID));
            }

            return(query.ToList());
        }
Beispiel #3
0
        public IQueryable <EQPRepairInfoDTO> GetReportInfo(EQPRepairInfoSearchDTO searchModel, List <int> Organization_UIDs, Page page, out int totalcount, out decimal allcost)
        {
            var query = from M in DataContext.EQPRepair_Info
                        join equipinfo in DataContext.Equipment_Info
                        on M.EQP_Uid equals equipinfo.EQP_Uid into temp
                        from aa in temp.DefaultIfEmpty()
                        join funplant in DataContext.System_Function_Plant
                        on aa.System_FunPlant_UID equals funplant.System_FunPlant_UID into temp2
                        from bb in temp2.DefaultIfEmpty()
                        join project in DataContext.System_Project
                        on aa.Project_UID equals project.Project_UID into temp3
                        from cc in temp3.DefaultIfEmpty()

                        join materialupdateinfo in DataContext.Meterial_UpdateInfo
                        on M.Repair_Uid equals materialupdateinfo.Repair_Uid into temp4
                        from dd in temp4.DefaultIfEmpty()

                        join materialinfo in DataContext.Material_Info
                        on dd.Material_Uid equals materialinfo.Material_Uid into temp5
                        from ee in temp5.DefaultIfEmpty()
                        select new EQPRepairInfoDTO
            {
                Class_Desc       = aa.Class_Desc,
                Repair_Uid       = M.Repair_Uid,
                Repair_id        = M.Repair_id,
                Repair_Date      = M.Error_Time.Year.ToString() + (M.Error_Time.Month > 9 ? M.Error_Time.Month.ToString() : "0" + M.Error_Time.Month.ToString()) + (M.Error_Time.Day > 9 ? M.Error_Time.Day.ToString() : "0" + M.Error_Time.Day.ToString()),
                Repair_Time      = M.Error_Time.Year.ToString() + "-" + (M.Error_Time.Month > 9 ? M.Error_Time.Month.ToString() : "0" + M.Error_Time.Month.ToString()) + "-" + (M.Error_Time.Day > 9 ? M.Error_Time.Day.ToString() : "0" + M.Error_Time.Day.ToString()) + " " + M.Error_Time.Hour.ToString() + ":" + M.Error_Time.Minute.ToString(),
                Repair_Reason    = M.Repair_Reason,
                Error_Types      = M.Error_Types,
                Reason_Analysis  = M.Reason_Analysis,
                Repair_Method    = M.Repair_Method,
                Repair_BeginTime = M.Repair_BeginTime,
                Repair_EndTime   = M.Repair_EndTime,
                TotalTime        = Math.Round((double)(SqlFunctions.DateDiff("MINUTE", M.Repair_BeginTime, M.Repair_EndTime) == null ? 0 : (int)SqlFunctions.DateDiff("MINUTE", M.Repair_BeginTime, M.Repair_EndTime)) / 60, 2),
                Labor_List       = M.Labor_List,
                All_RepairCost   = M.All_RepairCost,
                Update_Part      = M.Update_Part,
                Repair_Remark    = M.Repair_Remark,
                Modified_Date    = M.Modified_Date,
                Reason_Types     = M.Reason_Types,
                Repair_Result    = M.Repair_Result,
                Contact          = M.Contact,
                EQP_Location     = aa.EQP_Location,
                FunPlant         = bb.FunPlant,
                OP_TYPES         = bb.OP_Types,
                Project_Name     = cc.Project_Name,
                EQP_Plant_No     = aa.EQP_Plant_No,
                Equipment        = aa.Equipment,
                Process          = aa.Process,
                Mfg_Serial_Num   = aa.Mfg_Serial_Num,

                Material_Name            = ee.Material_Name,
                Material_Id              = ee.Material_Id,
                Material_Types           = ee.Material_Types,
                Material_Uid             = SqlFunctions.StringConvert((decimal)ee.Material_Uid),
                Apply_Time               = M.Apply_Time,
                Error_Level              = M.Error_Level,
                Status                   = M.Status,
                Contact_tel              = M.Contact_tel,
                Organization_UID         = cc.Organization_UID,
                FunPlant_OrganizationUID = bb.FunPlant_OrganizationUID.Value,
                Mentioner                = M.Mentioner
            };

            if (searchModel.Organization_UID != 0)
            {
                query = query.Where(m => m.Organization_UID == searchModel.Organization_UID);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Project_Name))
            {
                query = query.Where(m => m.Project_Name.Contains(searchModel.Project_Name));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.FunPlant))
            {
                query = query.Where(m => m.FunPlant.Contains(searchModel.FunPlant));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Process))
            {
                query = query.Where(m => m.Process.Contains(searchModel.Process));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Mfg_Serial_Num))
            {
                query = query.Where(m => m.Mfg_Serial_Num.Contains(searchModel.Mfg_Serial_Num));
            }

            //EMT
            if (!string.IsNullOrWhiteSpace(searchModel.Equipment))
            {
                query = query.Where(m => m.Equipment.Contains(searchModel.Equipment));
            }
            //厂内编号
            if (!string.IsNullOrWhiteSpace(searchModel.EQP_Plant_No))
            {
                query = query.Where(m => m.EQP_Plant_No.Contains(searchModel.EQP_Plant_No));
            }
            //配件名称
            if (!string.IsNullOrWhiteSpace(searchModel.Material_Name))
            {
                query = query.Where(ee => ee.Material_Name.Contains(searchModel.Material_Name));
            }
            //配件料号
            if (!string.IsNullOrWhiteSpace(searchModel.Material_Id))
            {
                query = query.Where(ee => ee.Material_Uid.Contains(searchModel.Material_Id));
            }
            //配件型号
            if (!string.IsNullOrWhiteSpace(searchModel.Material_Types))
            {
                query = query.Where(ee => ee.Material_Types.Contains(searchModel.Material_Types));
            }

            if (!string.IsNullOrWhiteSpace(searchModel.Error_Types))
            {
                query = query.Where(m => m.Error_Types.Contains(searchModel.Error_Types));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_id))
            {
                query = query.Where(m => m.Repair_id.Contains(searchModel.Repair_id));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.EQP_Location))
            {
                query = query.Where(m => m.EQP_Location == searchModel.EQP_Location);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Class_Desc))
            {
                query = query.Where(m => m.Class_Desc.Contains(searchModel.Class_Desc));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Contact))
            {
                query = query.Where(m => m.Contact.Contains(searchModel.Contact));
            }
            if (searchModel.End_Date_From.Year != 1)
            {
                query = query.Where(m => m.Repair_EndTime >= searchModel.End_Date_From);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Error_Level))
            {
                query = query.Where(m => m.Error_Level == searchModel.Error_Level);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_Result))
            {
                query = query.Where(m => m.Repair_Result == searchModel.Repair_Result);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Update_Part))
            {
                query = query.Where(m => m.Update_Part.Contains(searchModel.Update_Part));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Labor_List))
            {
                query = query.Where(m => m.Labor_List.Contains(searchModel.Labor_List));
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Status))
            {
                query = query.Where(m => m.Status == searchModel.Status);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Repair_Result))
            {
                query = query.Where(m => m.Repair_Result == searchModel.Repair_Result);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.Mentioner))
            {
                query = query.Where(m => m.Mentioner.Contains(searchModel.Mentioner));
            }
            if (searchModel.End_Date_To.Year != 1)
            {
                searchModel.End_Date_To = searchModel.End_Date_To.AddDays(1);
                query = query.Where(m => m.Repair_EndTime < searchModel.End_Date_To);
            }
            // 只是针对厂区的过滤
            if (Organization_UIDs.Count > 0)
            {
                query = query.Where(m => Organization_UIDs.Contains(m.Organization_UID));
            }

            totalcount = query.Count();
            if (totalcount == 0)
            {
                allcost = 0;
            }
            else
            {
                allcost = (decimal)query.Sum(m => (SqlFunctions.DateDiff("MINUTE", m.Repair_BeginTime, m.Repair_EndTime)) == null ? 0 : (SqlFunctions.DateDiff("MINUTE", m.Repair_BeginTime, m.Repair_EndTime)));
            }
            query = query.OrderByDescending(m => m.Modified_Date).ThenBy(m => m.Contact).GetPage(page);
            return(query);
        }