using FineUIPro; using Model; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace BLL { public static class CQMSDataService { public static SGGLDB db = Funs.DB; public static List BeUnderConstructionList = ProjectService.GetProjectWorkList().Where(x => (x.ProjectAttribute == "GONGCHENG" || x.ProjectAttribute == null)).Select(x => x.ProjectId).ToList(); #region 获取列表 /// /// 记录数 /// public static int count { get; set; } public static List GetCQMSData_CQMSByModle(CQMSData_CQMS table) { var db = Funs.DB; var q = from x in db.CQMSData_CQMS where (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && (string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) && (string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) && (string.IsNullOrEmpty(table.UnitName) || x.UnitName.Contains(table.UnitName)) orderby x.ReportDate descending select x ; return q.ToList(); } /// 获取分页列表 /// /// 页码 /// 每页数量 /// public static IEnumerable getListData(CQMSData_CQMS table, Grid Grid1) { var q = GetCQMSData_CQMSByModle(table); count = q.Count(); if (count == 0) return null; // q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList(); // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); return from x in q select new { x.Id, x.UnitId, x.CollCropCode, x.UnitName, x.ReportDate, x.TrainPersonNum, x.TechnicalDisclosePersonNum, x.UseNum, x.OKNum, x.CompanyPersonNum, x.BranchPersonNum, x.ProjectPersonNum, x.ProblemNum, x.ProblemCompletedNum, x.ProblemNotCompletedNum, x.SNum, x.ANum, x.BNum, x.CNum, x.KeyProcessNum, x.KeyProcessOKNum, x.SpecialProcessNum, x.SpecialProcessOKNum, x.ConcealedWorksNum, x.ConcealedWorksOKNum, x.UnitProjectOnesNum, x.UnitProjectOnesOKNum, x.MaterialInRecheckNum, x.MaterialInRecheckOKNum, x.SingleProjectNum, x.UnitProjectNum, x.SubProjectNum, x.SubdivisionalWorksNum, x.InspectionLotNum, x.State, x.CreateDate, x.CreateMan }; } #endregion 获取列表 #region 新增、编辑、删除 public static void AddCQMSData_CQMS(CQMSData_CQMS newtable) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var table = new CQMSData_CQMS { Id = newtable.Id, UnitId = newtable.UnitId, CollCropCode = newtable.CollCropCode, UnitName = newtable.UnitName, ReportDate = newtable.ReportDate, TrainPersonNum = newtable.TrainPersonNum, TechnicalDisclosePersonNum = newtable.TechnicalDisclosePersonNum, UseNum = newtable.UseNum, OKNum = newtable.OKNum, CompanyPersonNum = newtable.CompanyPersonNum, BranchPersonNum = newtable.BranchPersonNum, ProjectPersonNum = newtable.ProjectPersonNum, ProblemNum = newtable.ProblemNum, ProblemCompletedNum = newtable.ProblemCompletedNum, ProblemNotCompletedNum = newtable.ProblemNotCompletedNum, SNum = newtable.SNum, ANum = newtable.ANum, BNum = newtable.BNum, CNum = newtable.CNum, KeyProcessNum = newtable.KeyProcessNum, KeyProcessOKNum = newtable.KeyProcessOKNum, SpecialProcessNum = newtable.SpecialProcessNum, SpecialProcessOKNum = newtable.SpecialProcessOKNum, ConcealedWorksNum = newtable.ConcealedWorksNum, ConcealedWorksOKNum = newtable.ConcealedWorksOKNum, UnitProjectOnesNum = newtable.UnitProjectOnesNum, UnitProjectOnesOKNum = newtable.UnitProjectOnesOKNum, MaterialInRecheckNum = newtable.MaterialInRecheckNum, MaterialInRecheckOKNum = newtable.MaterialInRecheckOKNum, SingleProjectNum = newtable.SingleProjectNum, UnitProjectNum = newtable.UnitProjectNum, SubProjectNum = newtable.SubProjectNum, SubdivisionalWorksNum = newtable.SubdivisionalWorksNum, InspectionLotNum = newtable.InspectionLotNum, EquipmentInspectionNum = newtable.EquipmentInspectionNum, EquipmentInspectionQualifiedNum = newtable.EquipmentInspectionQualifiedNum, MachineInspectionNum = newtable.MachineInspectionNum, MachineInspectionQualifiedNum = newtable.MachineInspectionQualifiedNum, PersonInspectionNum = newtable.PersonInspectionNum, PersonInspectionQualifiedNum = newtable.PersonInspectionQualifiedNum, MaterialInspectionNum = newtable.MaterialInspectionNum, MaterialInspectionQualifiedNum = newtable.MaterialInspectionQualifiedNum, ConstructSolutionNum = newtable.ConstructSolutionNum, ConstructSolutionProjectApproveNum = newtable.ConstructSolutionProjectApproveNum, ConstructSolutionUnitApproveNum = newtable.ConstructSolutionUnitApproveNum, SpecialEquipmentQualityAssuranceSystemNum = newtable.SpecialEquipmentQualityAssuranceSystemNum, DesignDetailsNum = newtable.DesignDetailsNum, UnitProjectAcceptNum = newtable.UnitProjectAcceptNum, UnitProjectAcceptOKNum = newtable.UnitProjectAcceptOKNum, SubProjectAcceptNum = newtable.SubProjectAcceptNum, SubProjectAcceptOKNum = newtable.SubProjectAcceptOKNum, SubdivisionalWorksAcceptNum = newtable.SubdivisionalWorksAcceptNum, SubdivisionalWorksAcceptOKNum = newtable.SubdivisionalWorksAcceptOKNum, State = newtable.State, CreateDate = newtable.CreateDate, CreateMan = newtable.CreateMan }; db.CQMSData_CQMS.InsertOnSubmit(table); db.SubmitChanges(); } } public static void UpdateCQMSData_CQMS(CQMSData_CQMS newtable) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == newtable.Id); if (table != null) { table.Id = newtable.Id; table.UnitId = newtable.UnitId; table.CollCropCode = newtable.CollCropCode; table.UnitName = newtable.UnitName; table.ReportDate = newtable.ReportDate; table.TrainPersonNum = newtable.TrainPersonNum; table.TechnicalDisclosePersonNum = newtable.TechnicalDisclosePersonNum; table.UseNum = newtable.UseNum; table.OKNum = newtable.OKNum; table.CompanyPersonNum = newtable.CompanyPersonNum; table.BranchPersonNum = newtable.BranchPersonNum; table.ProjectPersonNum = newtable.ProjectPersonNum; table.ProblemNum = newtable.ProblemNum; table.ProblemCompletedNum = newtable.ProblemCompletedNum; table.ProblemNotCompletedNum = newtable.ProblemNotCompletedNum; table.SNum = newtable.SNum; table.ANum = newtable.ANum; table.BNum = newtable.BNum; table.CNum = newtable.CNum; table.KeyProcessNum = newtable.KeyProcessNum; table.KeyProcessOKNum = newtable.KeyProcessOKNum; table.SpecialProcessNum = newtable.SpecialProcessNum; table.SpecialProcessOKNum = newtable.SpecialProcessOKNum; table.ConcealedWorksNum = newtable.ConcealedWorksNum; table.ConcealedWorksOKNum = newtable.ConcealedWorksOKNum; table.UnitProjectOnesNum = newtable.UnitProjectOnesNum; table.UnitProjectOnesOKNum = newtable.UnitProjectOnesOKNum; table.MaterialInRecheckNum = newtable.MaterialInRecheckNum; table.MaterialInRecheckOKNum = newtable.MaterialInRecheckOKNum; table.SingleProjectNum = newtable.SingleProjectNum; table.UnitProjectNum = newtable.UnitProjectNum; table.SubProjectNum = newtable.SubProjectNum; table.SubdivisionalWorksNum = newtable.SubdivisionalWorksNum; table.InspectionLotNum = newtable.InspectionLotNum; table.EquipmentInspectionNum = newtable.EquipmentInspectionNum; table.EquipmentInspectionQualifiedNum = newtable.EquipmentInspectionQualifiedNum; table.MachineInspectionNum = newtable.MachineInspectionNum; table.MachineInspectionQualifiedNum = newtable.MachineInspectionQualifiedNum; table.PersonInspectionNum = newtable.PersonInspectionNum; table.PersonInspectionQualifiedNum = newtable.PersonInspectionQualifiedNum; table.MaterialInspectionNum = newtable.MaterialInspectionNum; table.MaterialInspectionQualifiedNum = newtable.MaterialInspectionQualifiedNum; table.ConstructSolutionNum = newtable.ConstructSolutionNum; table.ConstructSolutionProjectApproveNum = newtable.ConstructSolutionProjectApproveNum; table.ConstructSolutionUnitApproveNum = newtable.ConstructSolutionUnitApproveNum; table.SpecialEquipmentQualityAssuranceSystemNum = newtable.SpecialEquipmentQualityAssuranceSystemNum; table.DesignDetailsNum = newtable.DesignDetailsNum; table.UnitProjectAcceptNum = newtable.UnitProjectAcceptNum; table.UnitProjectAcceptOKNum = newtable.UnitProjectAcceptOKNum; table.SubProjectAcceptNum = newtable.SubProjectAcceptNum; table.SubProjectAcceptOKNum = newtable.SubProjectAcceptOKNum; table.SubdivisionalWorksAcceptNum = newtable.SubdivisionalWorksAcceptNum; table.SubdivisionalWorksAcceptOKNum = newtable.SubdivisionalWorksAcceptOKNum; table.State = newtable.State; table.CreateMan = newtable.CreateMan; table.CreateDate = newtable.CreateDate; db.SubmitChanges(); } } } public static void DeleteCQMSData_CQMSById(string id) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var table = db.CQMSData_CQMS.FirstOrDefault(x => x.Id == id); if (table != null) { db.CQMSData_CQMS.DeleteOnSubmit(table); db.SubmitChanges(); } } } #endregion public static CQMSData_CQMS GetCQMSData_CQMSById(string id) { var db = Funs.DB; return db.CQMSData_CQMS.FirstOrDefault(x => x.Id == id); } public static CQMSData GetItemById(string id) { var model = GetCQMSData_CQMSById(id); var data = new CQMSData(); var item = new CqmsDataItem(); if (model != null) { item.Id = model.Id; item.ReportDate = model.ReportDate.Value.ToShortDateString(); item.UnitId = model.UnitId; item.CollCropCode = model.CollCropCode; item.TrainPersonNum = model.TrainPersonNum; item.TechnicalDisclosePersonNum = model.TechnicalDisclosePersonNum; item.UseNum = model.UseNum; item.OKNum = model.OKNum; item.CompanyPersonNum = model.CompanyPersonNum; item.BranchPersonNum = model.BranchPersonNum; item.ProjectPersonNum = model.ProjectPersonNum; item.ProblemNum = model.ProblemNum; item.ProblemCompletedNum = model.ProblemCompletedNum; item.ProblemNotCompletedNum = model.ProblemNotCompletedNum; item.ProblemRate = ""; item.SNum = model.SNum; item.ANum = model.ANum; item.BNum = model.BNum; item.CNum = model.CNum; item.KeyProcessNum = model.KeyProcessNum; item.KeyProcessOKNum = model.KeyProcessOKNum; item.KeyProcessRate = ""; item.SpecialProcessNum = model.SpecialProcessNum; item.SpecialProcessOKNum = model.SpecialProcessOKNum; item.SpecialProcessRate = ""; item.ConcealedWorksNum = model.ConcealedWorksNum; item.ConcealedWorksOKNum = model.ConcealedWorksOKNum; item.ConcealedWorksRate = ""; item.UnitProjectOnesNum = model.UnitProjectOnesNum; item.UnitProjectOnesOKNum = model.UnitProjectOnesOKNum; item.UnitProjectOnesRate = ""; item.MaterialInRecheckNum = model.MaterialInRecheckNum; item.MaterialInRecheckOKNum = model.MaterialInRecheckOKNum; item.MaterialInRecheckRate = ""; item.SingleProjectNum = model.SingleProjectNum; item.UnitProjectNum = model.UnitProjectNum; item.SubProjectNum = model.SubProjectNum; item.SubdivisionalWorksNum = model.SubdivisionalWorksNum; item.InspectionLotNum = model.InspectionLotNum; item.EquipmentInspectionNum = model.EquipmentInspectionNum; item.EquipmentInspectionQualifiedNum = model.EquipmentInspectionQualifiedNum; item.MachineInspectionNum = model.MachineInspectionNum; item.MachineInspectionQualifiedNum = model.MachineInspectionQualifiedNum; item.PersonInspectionNum = model.PersonInspectionNum; item.PersonInspectionQualifiedNum = model.PersonInspectionQualifiedNum; item.MaterialInspectionNum = model.MaterialInspectionNum; item.MaterialInspectionQualifiedNum = model.MaterialInspectionQualifiedNum; item.ConstructSolutionNum = model.ConstructSolutionNum; item.ConstructSolutionProjectApproveNum = model.ConstructSolutionProjectApproveNum; item.ConstructSolutionUnitApproveNum = model.ConstructSolutionUnitApproveNum; item.SpecialEquipmentQualityAssuranceSystemNum = model.SpecialEquipmentQualityAssuranceSystemNum; item.DesignDetailsNum = model.DesignDetailsNum; item.UnitProjectAcceptNum = model.UnitProjectAcceptNum; item.UnitProjectAcceptOKNum = model.UnitProjectAcceptOKNum; item.SubProjectAcceptNum = model.SubProjectAcceptNum; item.SubProjectAcceptOKNum = model.SubProjectAcceptOKNum; item.SubdivisionalWorksAcceptNum = model.SubdivisionalWorksAcceptNum; item.SubdivisionalWorksAcceptOKNum = model.SubdivisionalWorksAcceptOKNum; } var cqmsDataItems = new List(); cqmsDataItems.Add(item); data.CQMSDataItems = cqmsDataItems; return data; } public static async Task GetTodayCQMSData_CQMS() { // var data = new CQMSData(); // data = StatisticalData(); // return data; var modelTask = StatisitcalDataAsync(); var model = await modelTask; CQMSData data = model; return data; } public static CQMSData_CQMS GetTodayData() { var q = (from x in Funs.DB.CQMSData_CQMS where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date select x).FirstOrDefault(); return q; } public static CQMSData_CQMS GetSubUnitCqmsDataByDate(string Unitid, DateTime? reportdate) { var result = new Model.CQMSData_CQMS(); if (reportdate == null) { return result; } var projectlist = BLL.ProjectService.GetProjectWorkList(Unitid); var base_Unit = UnitService.GetUnitByUnitId(Unitid); var ProjectData = (from x in Funs.DB.Project_CQMSData_CQMS where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId) select x).ToList(); result = new CQMSData_CQMS { UnitId = Unitid, CollCropCode = base_Unit.CollCropCode, UnitName = base_Unit.UnitName, ReportDate = DateTime.Now.Date, TrainPersonNum = ProjectData.Sum(x => x.TrainPersonNum), TechnicalDisclosePersonNum = ProjectData.Sum(x => x.TechnicalDisclosePersonNum), UseNum = ProjectData.Sum(x => x.UseNum), OKNum = ProjectData.Sum(x => x.OKNum), CompanyPersonNum = GetCompanyPersonNum(), BranchPersonNum = GetBranchPersonNum(), ProjectPersonNum = ProjectData.Sum(x => x.ProjectPersonNum), ProblemNum = ProjectData.Sum(x => x.ProblemNum), ProblemCompletedNum = ProjectData.Sum(x => x.ProblemCompletedNum), ProblemNotCompletedNum = ProjectData.Sum(x => x.ProblemNotCompletedNum), SNum = ProjectData.Sum(x => x.SNum), ANum = ProjectData.Sum(x => x.ANum), BNum = ProjectData.Sum(x => x.BNum), CNum = ProjectData.Sum(x => x.CNum), KeyProcessNum = ProjectData.Sum(x => x.KeyProcessNum), KeyProcessOKNum = ProjectData.Sum(x => x.KeyProcessOKNum), SpecialProcessNum = ProjectData.Sum(x => x.SpecialProcessNum), SpecialProcessOKNum = ProjectData.Sum(x => x.SpecialProcessOKNum), ConcealedWorksNum = ProjectData.Sum(x => x.ConcealedWorksNum), ConcealedWorksOKNum = ProjectData.Sum(x => x.ConcealedWorksOKNum), UnitProjectOnesNum = ProjectData.Sum(x => x.UnitProjectOnesNum), UnitProjectOnesOKNum = ProjectData.Sum(x => x.UnitProjectOnesOKNum), MaterialInRecheckNum = ProjectData.Sum(x => x.MaterialInRecheckNum), MaterialInRecheckOKNum = ProjectData.Sum(x => x.MaterialInRecheckOKNum), SingleProjectNum = ProjectData.Sum(x => x.SingleProjectNum), UnitProjectNum = ProjectData.Sum(x => x.UnitProjectNum), SubProjectNum = ProjectData.Sum(x => x.SubProjectNum), SubdivisionalWorksNum = ProjectData.Sum(x => x.SubdivisionalWorksNum), InspectionLotNum = ProjectData.Sum(x => x.InspectionLotNum), CreateMan = Const.sysglyId, CreateDate = DateTime.Now }; return result; } public static void UpdateTodyData_State() { var q = GetTodayData(); if (q != null) { q.State = Const.CNCEC_State_1; UpdateCQMSData_CQMS(q); } } public static bool IsReportByDate(DateTime dateTime) { var result = false; var q = (from x in Funs.DB.CQMSData_CQMS where x.ReportDate >= dateTime.Date && x.ReportDate < dateTime.Date.AddDays(1).Date select x).ToList(); if (q.Count > 0) result = true; return result; } /// /// 判断当天是否已统计 /// /// public static bool IsReportByToday() { var result = false; var q = (from x in Funs.DB.CQMSData_CQMS where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date select x).ToList(); if (q.Count > 0) result = true; return result; } public static ReturnData PushCncec(string id) { var baseurl = "/api/CQMSData/SaveCQMSData"; var item = GetItemById(id); var str = JsonConvert.SerializeObject(item); var responeData = ServerService.PushCNCEC(str, baseurl); return responeData; } public static CQMSData StatisticalData() { var thisUnitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) thisUnitId = thisUnit.UnitId; var base_Unit = UnitService.GetUnitByUnitId(thisUnitId); Project_CQMSDataService.StatisticalAllProjectData(); var ProjectData = (from x in Funs.DB.Project_CQMSData_CQMS where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date select x).ToList(); var table = new CQMSData_CQMS { UnitId = thisUnitId, CollCropCode = base_Unit.CollCropCode, UnitName = base_Unit.UnitName, ReportDate = DateTime.Now.Date, TrainPersonNum = ProjectData.Sum(x => x.TrainPersonNum), TechnicalDisclosePersonNum = ProjectData.Sum(x => x.TechnicalDisclosePersonNum), UseNum = ProjectData.Sum(x => x.UseNum), OKNum = ProjectData.Sum(x => x.OKNum), CompanyPersonNum = GetCompanyPersonNum(), BranchPersonNum = GetBranchPersonNum(), ProjectPersonNum = ProjectData.Sum(x => x.ProjectPersonNum), ProblemNum = ProjectData.Sum(x => x.ProblemNum), ProblemCompletedNum = ProjectData.Sum(x => x.ProblemCompletedNum), ProblemNotCompletedNum = ProjectData.Sum(x => x.ProblemNotCompletedNum), SNum = ProjectData.Sum(x => x.SNum), ANum = ProjectData.Sum(x => x.ANum), BNum = ProjectData.Sum(x => x.BNum), CNum = ProjectData.Sum(x => x.CNum), KeyProcessNum = ProjectData.Sum(x => x.KeyProcessNum), KeyProcessOKNum = ProjectData.Sum(x => x.KeyProcessOKNum), SpecialProcessNum = ProjectData.Sum(x => x.SpecialProcessNum), SpecialProcessOKNum = ProjectData.Sum(x => x.SpecialProcessOKNum), ConcealedWorksNum = ProjectData.Sum(x => x.ConcealedWorksNum), ConcealedWorksOKNum = ProjectData.Sum(x => x.ConcealedWorksOKNum), UnitProjectOnesNum = ProjectData.Sum(x => x.UnitProjectOnesNum), UnitProjectOnesOKNum = ProjectData.Sum(x => x.UnitProjectOnesOKNum), MaterialInRecheckNum = ProjectData.Sum(x => x.MaterialInRecheckNum), MaterialInRecheckOKNum = ProjectData.Sum(x => x.MaterialInRecheckOKNum), SingleProjectNum = ProjectData.Sum(x => x.SingleProjectNum), UnitProjectNum = ProjectData.Sum(x => x.UnitProjectNum), SubProjectNum = ProjectData.Sum(x => x.SubProjectNum), SubdivisionalWorksNum = ProjectData.Sum(x => x.SubdivisionalWorksNum), InspectionLotNum = ProjectData.Sum(x => x.InspectionLotNum), EquipmentInspectionNum = ProjectData.Sum(x => x.EquipmentInspectionNum), EquipmentInspectionQualifiedNum = ProjectData.Sum(x => x.EquipmentInspectionQualifiedNum), MachineInspectionNum = ProjectData.Sum(x => x.MachineInspectionNum), MachineInspectionQualifiedNum = ProjectData.Sum(x => x.MachineInspectionQualifiedNum), PersonInspectionNum = ProjectData.Sum(x => x.PersonInspectionNum), PersonInspectionQualifiedNum = ProjectData.Sum(x => x.PersonInspectionQualifiedNum), MaterialInspectionNum = ProjectData.Sum(x => x.MaterialInspectionNum), MaterialInspectionQualifiedNum = ProjectData.Sum(x => x.MaterialInspectionQualifiedNum), ConstructSolutionNum = ProjectData.Sum(x => x.ConstructSolutionNum), ConstructSolutionProjectApproveNum = ProjectData.Sum(x => x.ConstructSolutionProjectApproveNum), ConstructSolutionUnitApproveNum = ProjectData.Sum(x => x.ConstructSolutionUnitApproveNum), SpecialEquipmentQualityAssuranceSystemNum = ProjectData.Sum(x => x.SpecialEquipmentQualityAssuranceSystemNum), DesignDetailsNum = ProjectData.Sum(x => x.DesignDetailsNum), UnitProjectAcceptNum = ProjectData.Sum(x => x.UnitProjectAcceptNum), UnitProjectAcceptOKNum = ProjectData.Sum(x => x.UnitProjectAcceptOKNum), SubProjectAcceptNum = ProjectData.Sum(x => x.SubProjectAcceptNum), SubProjectAcceptOKNum = ProjectData.Sum(x => x.SubProjectAcceptOKNum), SubdivisionalWorksAcceptNum = ProjectData.Sum(x => x.SubdivisionalWorksAcceptNum), SubdivisionalWorksAcceptOKNum = ProjectData.Sum(x => x.SubdivisionalWorksAcceptOKNum), CreateMan = Const.sysglyId, CreateDate = DateTime.Now }; if (IsReportByToday()) { table.Id = GetTodayData().Id; table.State = Const.CNCEC_State_1; UpdateCQMSData_CQMS(table); } else { table.Id = SQLHelper.GetNewID(); table.State = Const.CNCEC_State_0; AddCQMSData_CQMS(table); } var data = new CQMSData(); data = GetDataByCQMSData_CQMS(table); return data; } /// /// 获取质量统计数据 /// public static async Task StatisitcalDataAsync() { var thisUnitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) thisUnitId = thisUnit.UnitId; var baseUnit = UnitService.GetUnitByUnitId(thisUnitId); // 并行执行异步方法 var companyPersonNumTask = CQMSDataService.GetCompanyPersonNumAsync(); //获取企业总部人数 var branchPersonNumTask = CQMSDataService.GetBranchPersonNumAsync(); //获取分支机构人数 var projectPersonNumTask = CQMSDataService.GetProjectPersonNumAsync(); //获取项目专职人数 var trainPersonNumTask = CQMSDataService.GetTrainPersonNumAsync(); //获取质量培训人次数 var technicalDisclosePersonTask = CQMSDataService.GetTechnicalDisclosePersonNumAsync(); //获取技术交底人次数 var inspectionEquipmentTask = CQMSDataService.GetComprehensive_InspectionEquipmentAsync(); //获取设备报验 var inspectionPersonTask = CQMSDataService.GetComprehensive_InspectionPersonAsync(); //获取人员报验 var inspectionMachineTask = CQMSDataService.GetComprehensive_InspectionMachineAsync(); //获取机具报验 var useNumTask = CQMSDataService.GetUseNumAsync(); //获取在用计量器具数 var okNumTask = CQMSDataService.GetOkNumAsync(); //获取校准合格数 var singleProjectNumTask = CQMSDataService.GetSingleProjectNumAsync(); //获取单项工程个数 var unitProjectNumTask = CQMSDataService.GetUnitProjectNumAsync(); //获取单位工程个数 var subProjectNuTask = CQMSDataService.GetSubProjectNumAsync(); //获取分部工程个数 var subdivisionalWorksNuTask = CQMSDataService.GetSubdivisionalWorksNumAsync(); //获取分项工程个数 var inspectionLotNumTask = CQMSDataService.GetInspectionLotNumAsync(); //获取检验批个数 var constructSolutionTask = CQMSDataService.GetConstructSolutionAsync(); //施工方案数量 var cqmsProblemTask = CQMSDataService.GetCQMSProblemAsync(); //获取企业级、项目级质量问题 //质量验收数据 var keyProcessNumTask = CQMSDataService.GetKeyProcessNumAsync(); //获取关键工序验收数 var keyProcessOKNumTask = CQMSDataService.GetKeyProcessOkNumAsync(); //获取关键工序验收合格数 var specialProcessNumTask = CQMSDataService.GetSpecialProcessNumAsync(); //获取特殊过程验收数 var specialProcessOKNumTask = CQMSDataService.GetSpecialProcessOkNumAsync(); //获取特殊过程验收合格数 var concealedWorksNumTask = CQMSDataService.GetConcealedWorksNumAsync(); //获取隐蔽工程验收数 var concealedWorksOKNumTask = CQMSDataService.GetConcealedWorksOkNumAsync(); //获取隐蔽工程验收合格数 var unitProjectAcceptNumTask = CQMSDataService.GetUnitProjectAcceptNumAsync(); //获取单位工程验收数 var unitProjectAcceptOKNumTask = CQMSDataService.GetUnitProjectAcceptOKNumAsync(); //获取单位工程验收合格数 var subProjectAcceptNumTask = CQMSDataService.GetSubProjectAcceptNumAsync(); //获取分部工程验收数 var subProjectAcceptOKNumTask = CQMSDataService.GetSubProjectAcceptOKNumAsync(); //获取分部工程验收合格数 var subdivisionalWorksAcceptNumTask = CQMSDataService.GetSubdivisionalWorksAcceptNumAsync(); //获取分项工程验收数 var subdivisionalWorksAcceptOKNumTask = CQMSDataService.GetSubdivisionalWorksAcceptOKNumAsync(); //获取分项工程验收合格数 var materialInRecheckNumTask = CQMSDataService.GetMaterialInRecheckNumAsync(); //获取复核材料数 var materialInRecheckOKNumTask = CQMSDataService.GetMaterialInRecheckOKNumAsync(); //获取复核材料合格数 // 等待所有异步方法执行完成 await Task.WhenAll( companyPersonNumTask, branchPersonNumTask, projectPersonNumTask, trainPersonNumTask, technicalDisclosePersonTask, inspectionEquipmentTask, inspectionPersonTask, inspectionMachineTask, useNumTask, okNumTask, singleProjectNumTask, unitProjectNumTask, subProjectNuTask, subdivisionalWorksNuTask, inspectionLotNumTask, constructSolutionTask, cqmsProblemTask, keyProcessNumTask, keyProcessOKNumTask, specialProcessNumTask, specialProcessOKNumTask, concealedWorksNumTask, concealedWorksOKNumTask, unitProjectAcceptNumTask, unitProjectAcceptOKNumTask, subProjectAcceptNumTask, subProjectAcceptOKNumTask, subdivisionalWorksAcceptNumTask, subdivisionalWorksAcceptOKNumTask, materialInRecheckNumTask, materialInRecheckOKNumTask ); // 统一获取异步方法的返回值 var companyPersonNum = await companyPersonNumTask; var branchPersonNum = await branchPersonNumTask; var projectPersonNumList = await projectPersonNumTask; var trainPersonNumList = await trainPersonNumTask; var technicalDisclosePersonList = await technicalDisclosePersonTask; var inspectionEquipmentList = await inspectionEquipmentTask; var inspectionPersonList = await inspectionPersonTask; var inspectionMachineList = await inspectionMachineTask; var useNum = await useNumTask; var okNum = await okNumTask; var singleProjectNum = await singleProjectNumTask; var unitProjectNum = await unitProjectNumTask; var subProjectNum = await subProjectNuTask; var subdivisionalWorksNum = await subdivisionalWorksNuTask; var inspectionLotNum = await inspectionLotNumTask; var constructSolutionList = await constructSolutionTask; var cqmsProblemList = await cqmsProblemTask; var keyProcessNum = await keyProcessNumTask; var keyProcessOKNum = await keyProcessOKNumTask; var specialProcessNum = await specialProcessNumTask; var specialProcessOKNum = await specialProcessOKNumTask; var concealedWorksNum = await concealedWorksNumTask; var concealedWorksOKNum = await concealedWorksOKNumTask; var unitProjectAcceptNum = await unitProjectAcceptNumTask; var unitProjectAcceptOKNum = await unitProjectAcceptOKNumTask; var subProjectAcceptNum = await subProjectAcceptNumTask; var subProjectAcceptOKNum = await subProjectAcceptOKNumTask; var subdivisionalWorksAcceptNum = await subdivisionalWorksAcceptNumTask; var subdivisionalWorksAcceptOKNum = await subdivisionalWorksAcceptOKNumTask; var materialInRecheckNum = await materialInRecheckNumTask; var materialInRecheckOKNum = await materialInRecheckOKNumTask; // 构造结果对象 var table = new CQMSData_CQMS { UnitId = thisUnitId, CollCropCode = baseUnit.CollCropCode, UnitName = baseUnit.UnitName, ReportDate = DateTime.Now.Date, CompanyPersonNum = companyPersonNum,// BranchPersonNum = branchPersonNum,// ProjectPersonNum = projectPersonNumList.Count(), TrainPersonNum = trainPersonNumList.Count(), TechnicalDisclosePersonNum = technicalDisclosePersonList.Sum(x => x.TrainPersonNum), EquipmentInspectionNum = inspectionEquipmentList.Count(), EquipmentInspectionQualifiedNum = inspectionEquipmentList.Where(x => x.SamplingResult == "1").Count(), PersonInspectionNum = inspectionPersonList.Count(), PersonInspectionQualifiedNum = inspectionPersonList.Where(x => x.IsOnSite.HasValue && x.IsOnSite == true).Count(), MachineInspectionNum = inspectionMachineList.Count(), MachineInspectionQualifiedNum = inspectionMachineList.Where(x => x.IsCheckOK.HasValue && x.IsCheckOK == true).Count(), MaterialInspectionNum = 0, MaterialInspectionQualifiedNum = 0, UseNum = useNum.Count(), OKNum = okNum.Count(), SingleProjectNum = singleProjectNum.Count(), UnitProjectNum = unitProjectNum.Count(), SubProjectNum = subProjectNum.Count(), SubdivisionalWorksNum = subdivisionalWorksNum.Count(), InspectionLotNum = inspectionLotNum.Sum(x => x.Sum), ConstructSolutionNum = constructSolutionList.Count(), ConstructSolutionProjectApproveNum = constructSolutionList.Where(x => x.State == "1").Count(), ConstructSolutionUnitApproveNum = 0,// SpecialEquipmentQualityAssuranceSystemNum = 0,// DesignDetailsNum = technicalDisclosePersonList.Sum(x => x.TrainPersonNum), ProblemNum = cqmsProblemList.Count(), ProblemCompletedNum = cqmsProblemList.Where(x => x.State == "7").Count(), ProblemNotCompletedNum = cqmsProblemList.Where(x => x.State != "7").Count(), KeyProcessNum = keyProcessNum.Count(), KeyProcessOKNum = keyProcessOKNum.Count(), SpecialProcessNum = specialProcessNum.Count(), SpecialProcessOKNum = specialProcessOKNum.Count(), ConcealedWorksNum = concealedWorksNum.Count(), ConcealedWorksOKNum = concealedWorksOKNum.Count(), UnitProjectAcceptNum = unitProjectAcceptNum.Count(), UnitProjectAcceptOKNum = unitProjectAcceptOKNum.Count(), SubProjectAcceptNum = subProjectAcceptNum.Count(), SubProjectAcceptOKNum = subProjectAcceptOKNum.Count(), SubdivisionalWorksAcceptNum = subdivisionalWorksAcceptNum.Count(), SubdivisionalWorksAcceptOKNum = subdivisionalWorksAcceptOKNum.Count(), MaterialInRecheckNum = materialInRecheckNum.Count(), MaterialInRecheckOKNum = materialInRecheckOKNum.Count() }; #region 添加项目统计数据 Project_CQMSDataService.DeleteProject_CQMSData_CQMByDate(DateTime.Now.Date); foreach (var projectid in BeUnderConstructionList) { var projectCqmsData = new Project_CQMSData_CQMS { Id = SQLHelper.GetNewID(), ProjectId = projectid, UnitId = thisUnitId, CollCropCode = baseUnit.CollCropCode, UnitName = baseUnit.UnitName, ReportDate = DateTime.Now.Date, CompanyPersonNum = companyPersonNum,// BranchPersonNum = branchPersonNum,// ProjectPersonNum = projectPersonNumList.Count(x => x.ProjectId == projectid), TrainPersonNum = trainPersonNumList.Count(x => x.ProjectId == projectid), TechnicalDisclosePersonNum = technicalDisclosePersonList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), EquipmentInspectionNum = inspectionEquipmentList.Count(x => x.ProjectId == projectid), EquipmentInspectionQualifiedNum = inspectionEquipmentList.Where(x => x.SamplingResult == "1" && x.ProjectId == projectid).Count(), PersonInspectionNum = inspectionPersonList.Count(x => x.ProjectId == projectid), PersonInspectionQualifiedNum = inspectionPersonList.Where(x => x.IsOnSite.HasValue && x.IsOnSite == true && x.ProjectId == projectid).Count(), MachineInspectionNum = inspectionMachineList.Count(x => x.ProjectId == projectid), MachineInspectionQualifiedNum = inspectionMachineList.Where(x => x.IsCheckOK.HasValue && x.IsCheckOK == true && x.ProjectId == projectid).Count(), MaterialInspectionNum = 0, MaterialInspectionQualifiedNum = 0, UseNum = useNum.Count(x => x.ProjectId == projectid), OKNum = okNum.Count(x => x.ProjectId == projectid), SingleProjectNum = singleProjectNum.Count(x => x.ProjectId == projectid), UnitProjectNum = unitProjectNum.Count(x => x.ProjectId == projectid), SubProjectNum = subProjectNum.Count(x => x.ProjectId == projectid), SubdivisionalWorksNum = subdivisionalWorksNum.Count(x => x.ProjectId == projectid), InspectionLotNum = inspectionLotNum.Where(x => x.ProjectId == projectid).Sum(x => x.Sum), ConstructSolutionNum = constructSolutionList.Count(x => x.ProjectId == projectid), ConstructSolutionProjectApproveNum = constructSolutionList.Where(x => x.State == "1" && x.ProjectId == projectid).Count(), ConstructSolutionUnitApproveNum = 0,// SpecialEquipmentQualityAssuranceSystemNum = 0,// DesignDetailsNum = technicalDisclosePersonList.Where(x => x.ProjectId == projectid).Sum(x => x.TrainPersonNum), ProblemNum = cqmsProblemList.Count(x => x.ProjectId == projectid), ProblemCompletedNum = cqmsProblemList.Where(x => x.State == "7" && x.ProjectId == projectid).Count(), ProblemNotCompletedNum = cqmsProblemList.Where(x => x.State != "7" && x.ProjectId == projectid).Count(), KeyProcessNum = keyProcessNum.Count(x => x.ProjectId == projectid), KeyProcessOKNum = keyProcessOKNum.Count(x => x.ProjectId == projectid), SpecialProcessNum = specialProcessNum.Count(x => x.ProjectId == projectid), SpecialProcessOKNum = specialProcessOKNum.Count(x => x.ProjectId == projectid), ConcealedWorksNum = concealedWorksNum.Count(x => x.ProjectId == projectid), ConcealedWorksOKNum = concealedWorksOKNum.Count(x => x.ProjectId == projectid), UnitProjectAcceptNum = unitProjectAcceptNum.Count(x => x.ProjectId == projectid), UnitProjectAcceptOKNum = unitProjectAcceptOKNum.Count(x => x.ProjectId == projectid), SubProjectAcceptNum = subProjectAcceptNum.Count(x => x.ProjectId == projectid), SubProjectAcceptOKNum = subProjectAcceptOKNum.Count(x => x.ProjectId == projectid), SubdivisionalWorksAcceptNum = subdivisionalWorksAcceptNum.Count(x => x.ProjectId == projectid), SubdivisionalWorksAcceptOKNum = subdivisionalWorksAcceptOKNum.Count(x => x.ProjectId == projectid), MaterialInRecheckNum = materialInRecheckNum.Count(x => x.ProjectId == projectid), MaterialInRecheckOKNum = materialInRecheckOKNum.Count(x => x.ProjectId == projectid) }; Project_CQMSDataService.AddProject_CQMSData_CQMS(projectCqmsData); } #endregion if (IsReportByToday()) { table.Id = GetTodayData().Id; table.State = Const.CNCEC_State_1; UpdateCQMSData_CQMS(table); } else { table.Id = SQLHelper.GetNewID(); table.State = Const.CNCEC_State_0; AddCQMSData_CQMS(table); } var data = new CQMSData(); data = GetDataByCQMSData_CQMS(table); return data; } public static CQMSData GetDataByCQMSData_CQMS(CQMSData_CQMS table) { var data = new CQMSData(); var item = new CqmsDataItem(); item.Id = table.Id; item.ReportDate = table.ReportDate.Value.ToShortDateString(); item.UnitId = table.UnitId; item.CollCropCode = table.CollCropCode; item.TrainPersonNum = table.TrainPersonNum; item.TechnicalDisclosePersonNum = table.TechnicalDisclosePersonNum; item.UseNum = table.UseNum; item.OKNum = table.OKNum; item.CompanyPersonNum = table.CompanyPersonNum; item.BranchPersonNum = table.BranchPersonNum; item.ProjectPersonNum = table.ProjectPersonNum; item.ProblemNum = table.ProblemNum; item.ProblemCompletedNum = table.ProblemCompletedNum; item.ProblemNotCompletedNum = table.ProblemNotCompletedNum; item.ProblemRate = ""; item.SNum = table.SNum; item.ANum = table.ANum; item.BNum = table.BNum; item.CNum = table.CNum; item.KeyProcessNum = table.KeyProcessNum; item.KeyProcessOKNum = table.KeyProcessOKNum; item.KeyProcessRate = ""; item.SpecialProcessNum = table.SpecialProcessNum; item.SpecialProcessOKNum = table.SpecialProcessOKNum; item.SpecialProcessRate = ""; item.ConcealedWorksNum = table.ConcealedWorksNum; item.ConcealedWorksOKNum = table.ConcealedWorksOKNum; item.ConcealedWorksRate = ""; item.UnitProjectOnesNum = table.UnitProjectOnesNum; item.UnitProjectOnesOKNum = table.UnitProjectOnesOKNum; item.UnitProjectOnesRate = ""; item.MaterialInRecheckNum = table.MaterialInRecheckNum; item.MaterialInRecheckOKNum = table.MaterialInRecheckOKNum; item.MaterialInRecheckRate = ""; item.SingleProjectNum = table.SingleProjectNum; item.UnitProjectNum = table.UnitProjectNum; item.SubProjectNum = table.SubProjectNum; item.SubdivisionalWorksNum = table.SubdivisionalWorksNum; item.InspectionLotNum = table.InspectionLotNum; item.EquipmentInspectionNum = table.EquipmentInspectionNum; item.EquipmentInspectionQualifiedNum = table.EquipmentInspectionQualifiedNum; item.MachineInspectionNum = table.MachineInspectionNum; item.MachineInspectionQualifiedNum = table.MachineInspectionQualifiedNum; item.PersonInspectionNum = table.PersonInspectionNum; item.PersonInspectionQualifiedNum = table.PersonInspectionQualifiedNum; item.MaterialInspectionNum = table.MaterialInspectionNum; item.MaterialInspectionQualifiedNum = table.MaterialInspectionQualifiedNum; item.ConstructSolutionNum = table.ConstructSolutionNum; item.ConstructSolutionProjectApproveNum = table.ConstructSolutionProjectApproveNum; item.ConstructSolutionUnitApproveNum = table.ConstructSolutionUnitApproveNum; item.SpecialEquipmentQualityAssuranceSystemNum = table.SpecialEquipmentQualityAssuranceSystemNum; item.DesignDetailsNum = table.DesignDetailsNum; item.UnitProjectAcceptNum = table.UnitProjectAcceptNum; item.UnitProjectAcceptOKNum = table.UnitProjectAcceptOKNum; item.SubProjectAcceptNum = table.SubProjectAcceptNum; item.SubProjectAcceptOKNum = table.SubProjectAcceptOKNum; item.SubdivisionalWorksAcceptNum = table.SubdivisionalWorksAcceptNum; item.SubdivisionalWorksAcceptOKNum = table.SubdivisionalWorksAcceptOKNum; var cqmsDataItems = new List(); cqmsDataItems.Add(item); data.CQMSDataItems = cqmsDataItems; return data; } /// /// 获取企业总部人数 /// /// public static int GetCompanyPersonNum() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId where x.IsOnJob == true && y.IsCQMS == true && x.UnitId == unitId select x).Count(); return result; } /// /// 获取企业总部人数(异步) /// /// public static async Task GetCompanyPersonNumAsync() { return await Task.Run(GetCompanyPersonNum); } /// /// 获取分支机构人数 /// /// public static int GetBranchPersonNum() { var unitId = string.Empty; var thisUnit = CommonService.GetIsThisUnit(); if (thisUnit != null) unitId = thisUnit.UnitId; var result = (from x in Funs.DB.Person_CompanyBranchPerson join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId where x.IsOnJob == true && y.IsCQMS == true && x.UnitId != unitId select x).Count(); return result; } /// /// 获取分支机构人数(异步) /// /// public static async Task GetBranchPersonNumAsync() { return await Task.Run(GetBranchPersonNum); } /// /// 获取项目专职人数 /// /// public static IEnumerable GetProjectPersonNum() { var result = (from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && y.IsCQMS == true && x.IsUsed == true select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = x.Sex == null ? "" : (x.Sex == "1" ? "男" : "女"), IdentityCard = x.IdentityCard, WorkPostName = y.WorkPostName == null ? "" : y.WorkPostName, Phone = x.Telephone }).ToList(); result = result .GroupBy(x => x.IdentityCard) .Select(g => g.FirstOrDefault()) .ToList(); return result; } /// /// 获取项目专职人数(异步) /// /// public static async Task> GetProjectPersonNumAsync() { return await Task.Run(GetProjectPersonNum); } /// /// 获取质量培训人次数 /// /// public static List GetTrainPersonNum() { var result = (from x in Funs.DB.Comprehensive_InspectionPerson join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() join u in Funs.DB.Base_Unit on x.UnitId equals u.UnitId into uGroup from u in uGroup.DefaultIfEmpty() join y in Funs.DB.SitePerson_Person on x.InspectionPersonId equals y.PersonId into yGroup from y in yGroup.DefaultIfEmpty() join m in Funs.DB.Base_WorkPost on y.WorkPostId equals m.WorkPostId into mGroup from m in mGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.IsTrain == true && x.CompileDate > Const.DtmarkTime select new Model.OfSafetySupervisorsOutput { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitId = u.UnitId, UnitName = u.UnitName, Name = x.PersonName, Sex = y.Sex == null ? "" : (y.Sex == "1" ? "男" : "女"), IdentityCard = y.IdentityCard, WorkPostName = m.WorkPostName == null ? "" : m.WorkPostName, Phone = y.Telephone }).ToList(); return result; } /// /// 获取质量培训人次数(异步) /// /// public static async Task> GetTrainPersonNumAsync() { return await Task.Run(GetTrainPersonNum); } /// /// 获取技术交底人次数 /// /// public static int GetTechnicalDisclosePersonNum() { var result = (from x in Funs.DB.Comprehensive_DesignDetails where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select x.JoinPersonNum).ToList().Sum(x => x.Value); return result; } /// /// 获取技术交底人次数 /// /// public static List GetTechnicalDisclosePerson() { var result = (from x in Funs.DB.Comprehensive_DesignDetails join p in Funs.DB.Base_Project on x.ProjectId equals p.ProjectId into pGroup from p in pGroup.DefaultIfEmpty() where BeUnderConstructionList.Contains(p.ProjectId) && x.CompileDate > Const.DtmarkTime select new Model.EduTrainOutput() { ProjectId = x.ProjectId, ProjectName = p.ProjectName, UnitName = "", Id = x.DesignDetailsId, TrainTitle = "", TrainStartDate = null, TrainEndDate = null, TrainPersonNum = x.JoinPersonNum ?? 0, }).ToList(); return result; } /// /// 获取技术交底人次数(异步) /// /// public static async Task> GetTechnicalDisclosePersonNumAsync() { return await Task.Run(GetTechnicalDisclosePerson); } /// /// 获取设备报验 /// /// public static List GetComprehensive_InspectionEquipment() { var result = (from x in Funs.DB.Comprehensive_InspectionEquipment where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取设备报验(异步) /// /// public static async Task> GetComprehensive_InspectionEquipmentAsync() { return await Task.Run(GetComprehensive_InspectionEquipment); } /// /// 获取人员报验 /// /// public static List GetComprehensive_InspectionPerson() { var result = (from x in Funs.DB.Comprehensive_InspectionPerson where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取人员报验(异步) /// /// public static async Task> GetComprehensive_InspectionPersonAsync() { return await Task.Run(GetComprehensive_InspectionPerson); } /// /// 获取机具报验 /// /// public static List GetComprehensive_InspectionMachine() { var result = (from x in Funs.DB.Comprehensive_InspectionMachine where BeUnderConstructionList.Contains(x.ProjectId) && x.CompileDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取机具报验(异步) /// /// public static async Task> GetComprehensive_InspectionMachineAsync() { return await Task.Run(GetComprehensive_InspectionMachine); } /// /// 获取在用计量器具数 /// /// public static List GetUseNum() { var result = (from x in Funs.DB.Comprehensive_InspectionMachine where BeUnderConstructionList.Contains(x.ProjectId) && x.IsOnSite == true && x.InspectionType.Contains("计量") && x.CompileDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取在用计量器具数(异步) /// /// public static async Task> GetUseNumAsync() { return await Task.Run(GetUseNum); } /// /// 获取校准合格数 /// /// public static List GetOkNum() { var result = (from x in Funs.DB.Comprehensive_InspectionMachine where BeUnderConstructionList.Contains(x.ProjectId) && x.IsOnSite == true && x.InspectionType.Contains("计量") && x.IsCheckOK == true && x.CompileDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取校准合格数(异步) /// /// public static async Task> GetOkNumAsync() { return await Task.Run(GetOkNum); } /// /// 获取单项工程个数 /// /// public static List GetSingleProjectNum() { var result = (from x in Funs.DB.Project_Installation where BeUnderConstructionList.Contains(x.ProjectId) && x.SuperInstallationId == "0" select x).ToList(); return result; } /// /// 获取单项工程个数(异步) /// /// public static async Task> GetSingleProjectNumAsync() { return await Task.Run(GetSingleProjectNum); } /// /// 获取单位工程个数 /// /// public static List GetUnitProjectNum() { var result = (from x in Funs.DB.WBS_UnitWork where BeUnderConstructionList.Contains(x.ProjectId) select x).ToList(); return result; } /// /// 获取单位工程个数(异步) /// /// public static async Task> GetUnitProjectNumAsync() { return await Task.Run(GetUnitProjectNum); } /// /// 获取分部工程个数 /// /// public static List GetSubProjectNum() { var result = (from x in Funs.DB.WBS_DivisionProject where BeUnderConstructionList.Contains(x.ProjectId) && x.SubItemType == "1" && x.IsSelected == true select x).ToList(); return result; } /// /// 获取分部工程个数(异步) /// /// public static async Task> GetSubProjectNumAsync() { return await Task.Run(GetSubProjectNum); } /// /// 获取分项工程个数 /// /// public static List GetSubdivisionalWorksNum() { var result = (from x in Funs.DB.WBS_DivisionProject where BeUnderConstructionList.Contains(x.ProjectId) && x.SubItemType == "3" && x.IsSelected == true select x).ToList(); return result; } /// /// 获取分项工程个数(异步) /// /// public static async Task> GetSubdivisionalWorksNumAsync() { return await Task.Run(GetSubdivisionalWorksNum); } /// /// 获取检验批个数 /// /// public static List GetInspectionLotNum() { var result = (from x in Funs.DB.WBS_BreakdownProject where BeUnderConstructionList.Contains(x.ProjectId) && x.IsSelected == true group x by x.ProjectId into g select new Model.WBSBreakdownProjectOutput() { ProjectId = g.Key, Sum = g.Count(), }).ToList(); return result; } /// /// 获取检验批个数(异步) /// /// public static async Task> GetInspectionLotNumAsync() { return await Task.Run(GetInspectionLotNum); } /// /// 施工方案数量 /// /// public static List GetConstructSolution() { var result = (from x in Funs.DB.Solution_CQMSConstructSolution where BeUnderConstructionList.Contains(x.ProjectId) select x).ToList(); return result; } /// /// 施工方案数量(异步) /// /// public static async Task> GetConstructSolutionAsync() { return await Task.Run(GetConstructSolution); } /// /// 获取质量问题 /// /// public static List GetCQMSProblem() { var result = (from x in Funs.DB.Check_CheckControl where BeUnderConstructionList.Contains(x.ProjectId) && x.CheckDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取质量问题(异步) /// /// public static async Task> GetCQMSProblemAsync() { return await Task.Run(GetCQMSProblem); } /// /// 获取分支机构巡检质量问题 /// /// public static List GetBranchCQMSProblem() { var result = (from x in Funs.DB.View_DCGL_CheckRectifyListFromSUB where BeUnderConstructionList.Contains(x.ProjectId) && x.ProblemTypes == "1" && x.CheckDate > Const.DtmarkTime select x).ToList(); return result; } /// /// 获取分支机构巡检质量问题(异步) /// /// public static async Task> GetBranchCQMSProblemAsync() { return await Task.Run(GetBranchCQMSProblem); } #region 质量验收数据 /// /// 获取关键工序验收数 /// /// public static List GetKeyProcessNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "1" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取关键工序验收数(异步) /// /// public static async Task> GetKeyProcessNumAsync() { return await Task.Run(GetKeyProcessNum); } /// /// 获取关键工序验收合格数 /// /// public static List GetKeyProcessOkNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "1" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取关键工序验收合格数(异步) /// /// public static async Task> GetKeyProcessOkNumAsync() { return await Task.Run(GetKeyProcessOkNum); } /// /// 获取特殊过程验收数 /// /// public static List GetSpecialProcessNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "2" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取特殊过程验收数(异步) /// /// public static async Task> GetSpecialProcessNumAsync() { return await Task.Run(GetSpecialProcessNum); } /// /// 获取特殊过程验收合格数 /// /// public static List GetSpecialProcessOkNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "2" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取特殊过程验收合格数(异步) /// /// public static async Task> GetSpecialProcessOkNumAsync() { return await Task.Run(GetSpecialProcessOkNum); } /// /// 获取隐蔽工程验收数 /// /// public static List GetConcealedWorksNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "3" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取隐蔽工程验收数(异步) /// /// public static async Task> GetConcealedWorksNumAsync() { return await Task.Run(GetConcealedWorksNum); } /// /// 获取隐蔽工程验收合格数 /// /// public static List GetConcealedWorksOkNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "3" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取隐蔽工程验收合格数(异步) /// /// public static async Task> GetConcealedWorksOkNumAsync() { return await Task.Run(GetConcealedWorksOkNum); } /// /// 获取单位工程验收数 /// /// public static List GetUnitProjectAcceptNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "4" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取单位工程验收数(异步) /// /// public static async Task> GetUnitProjectAcceptNumAsync() { return await Task.Run(GetUnitProjectAcceptNum); } /// /// 获取单位工程验收合格数 /// /// public static List GetUnitProjectAcceptOKNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "4" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取单位工程验收合格数(异步) /// /// public static async Task> GetUnitProjectAcceptOKNumAsync() { return await Task.Run(GetUnitProjectAcceptOKNum); } /// 获取材料进场复验数 /// /// public static List GetMaterialInRecheckNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "5" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取材料进场复验数(异步) /// /// public static async Task> GetMaterialInRecheckNumAsync() { return await Task.Run(GetMaterialInRecheckNum); } /// /// 获取材料进场复验数合格数 /// /// public static List GetMaterialInRecheckOKNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "5" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取材料进场复验数合格数(异步) /// /// public static async Task> GetMaterialInRecheckOKNumAsync() { return await Task.Run(GetMaterialInRecheckOKNum); } /// /// 获取分部工程验收数 /// /// public static List GetSubProjectAcceptNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "5" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取分部工程验收数(异步) /// /// public static async Task> GetSubProjectAcceptNumAsync() { return await Task.Run(GetSubProjectAcceptNum); } /// /// 获取分部工程验收合格数 /// /// public static List GetSubProjectAcceptOKNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "5" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取分部工程验收合格数(异步) /// /// public static async Task> GetSubProjectAcceptOKNumAsync() { return await Task.Run(GetSubProjectAcceptOKNum); } /// /// 获取分项工程验收数 /// /// public static List GetSubdivisionalWorksAcceptNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "6" && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取分项工程验收数(异步) /// /// public static async Task> GetSubdivisionalWorksAcceptNumAsync() { return await Task.Run(GetSubdivisionalWorksAcceptNum); } /// /// 获取分项工程验收合格数 /// /// public static List GetSubdivisionalWorksAcceptOKNum() { var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId where BeUnderConstructionList.Contains(y.ProjectId) && y.CheckAcceptType == "6" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime select new Model.InspectionManagementOutput() { ProjectId = y.ProjectId, //ProjectName = p.ProjectName, //UnitName = UnitService.getUnitNamesUnitIds(x.UnitIds), Id = x.InspectionDetailId, BreakdownCode = y.BreakdownCode, BreakdownName = y.BreakdownName, Basis = y.Basis, CheckPoints = y.CheckPoints, }).ToList(); return result; } /// /// 获取分项工程验收合格数(异步) /// /// public static async Task> GetSubdivisionalWorksAcceptOKNumAsync() { return await Task.Run(GetSubdivisionalWorksAcceptOKNum); } #endregion } }